Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(native_auth): Make Dart-only #25

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: native_authentication_flutter
name: native_authentication
on:
pull_request:
paths:
- ".github/workflows/native_authentication_flutter.yaml"
- "packages/native/auth/native_authentication_flutter/**"
- ".github/workflows/native_authentication.yaml"
- "packages/native/auth/native_authentication/**"

# Prevent duplicate runs due to Graphite
# https://graphite.dev/docs/troubleshooting#why-are-my-actions-running-twice
Expand All @@ -13,7 +13,7 @@ concurrency:

defaults:
run:
working-directory: packages/native/auth/native_authentication_flutter
working-directory: packages/native/auth/native_authentication

jobs:
build:
Expand All @@ -35,7 +35,7 @@ jobs:
run: dart format --set-exit-if-changed .
- name: Build Example (iOS)
run: flutter build ios --no-codesign
working-directory: packages/native/auth/native_authentication_flutter/example
working-directory: packages/native/auth/native_authentication/example
- name: Build Example (Web)
run: flutter build web
working-directory: packages/native/auth/native_authentication_flutter/example
working-directory: packages/native/auth/native_authentication/example
7 changes: 7 additions & 0 deletions packages/native/auth/native_authentication/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.0.1
# 0.1.0

- Initial release
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# native_authentication_flutter
# native_authentication

A Flutter FFI plugin for performing authentication flows using native APIs.
A Dart-only library for performing authentication flows using native APIs.

The platform implementations for `NativeAuthentication` are:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:lints/recommended.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'native_authentication'
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
PODS:
- Flutter (1.0.0)
- native_authentication_flutter (0.0.1):
- native_authentication (0.0.1):
- Flutter
- objective_c (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- native_authentication_flutter (from `.symlinks/plugins/native_authentication_flutter/ios`)
- native_authentication (from `.symlinks/plugins/native_authentication/ios`)
- objective_c (from `.symlinks/plugins/objective_c/ios`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
native_authentication_flutter:
:path: ".symlinks/plugins/native_authentication_flutter/ios"
native_authentication:
:path: ".symlinks/plugins/native_authentication/ios"
objective_c:
:path: ".symlinks/plugins/objective_c/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
native_authentication_flutter: 79a32bdb0f74194081ccaaf5981419c945f83ff7
native_authentication: 94d8748e8d138b3b492036fc9b36c223906a5306
objective_c: aedd8e7e00e2d8940f8ff085155bb7727fa88e93

PODFILE CHECKSUM: ade96bceabe3919b69c16573938e4268fe3a6c9d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication/native_authentication.dart';

final NativeAuthentication nativeAuth = NativeAuthentication(
logger: Logger.root,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
PODS:
- FlutterMacOS (1.0.0)
- native_authentication_flutter (0.0.1):
- native_authentication (0.0.1):
- FlutterMacOS
- objective_c (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- native_authentication_flutter (from `Flutter/ephemeral/.symlinks/plugins/native_authentication_flutter/macos`)
- native_authentication (from `Flutter/ephemeral/.symlinks/plugins/native_authentication/macos`)
- objective_c (from `Flutter/ephemeral/.symlinks/plugins/objective_c/macos`)

EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral
native_authentication_flutter:
:path: Flutter/ephemeral/.symlinks/plugins/native_authentication_flutter/macos
native_authentication:
:path: Flutter/ephemeral/.symlinks/plugins/native_authentication/macos
objective_c:
:path: Flutter/ephemeral/.symlinks/plugins/objective_c/macos

SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
native_authentication_flutter: 29d54e19f1327b0bacfc48e0e73df4af38be43bd
native_authentication: 8304d578f838dad68192fa10e5e5e9847a5123aa
objective_c: c13d3306e0fbf006bad001fd523e4bf8ebda8953

PODFILE CHECKSUM: 9ebaf0ce3d369aaa26a9ea0e159195ed94724cf3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: native_auth_flutter_example
description: "Demonstrates how to use the native_auth_flutter plugin."
name: native_authentication_example
description: "Demonstrates how to use the native_authentication plugin."
publish_to: 'none'

environment:
Expand All @@ -9,7 +9,7 @@ dependencies:
flutter:
sdk: flutter
logging: ^1.2.0
native_authentication_flutter:
native_authentication:
path: ../

dependency_overrides:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'native_authentication_flutter'
s.name = 'native_authentication'
s.version = '0.0.1'
s.summary = 'Native support for package:native_authentication_flutter'
s.summary = 'Native support for package:native_authentication'
s.description = <<-DESC
Wraps ASWebAuthenticationSession for iOS.
DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ classes:
- dev.celest.native_authentication.Callback
- dev.celest.native_authentication.CallbackSession
- dev.celest.native_authentication.CallbackResult
- io.flutter.embedding.android.FlutterActivity

- java.lang.Runnable
- java.lang.Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:native_authentication_flutter/src/model/callback_session.dart';
import 'package:native_authentication_flutter/src/model/callback_type.dart';
import 'package:native_authentication_flutter/src/native_auth.platform_stub.dart'
if (dart.library.js_interop) 'package:native_authentication_flutter/src/native_auth.platform_web.dart'
if (dart.library.io) 'package:native_authentication_flutter/src/native_auth.platform_io.dart';
import 'package:native_authentication/src/model/callback_session.dart';
import 'package:native_authentication/src/model/callback_type.dart';
import 'package:native_authentication/src/native_auth.platform_stub.dart'
if (dart.library.js_interop) 'package:native_authentication/src/native_auth.platform_web.dart'
if (dart.library.io) 'package:native_authentication/src/native_auth.platform_io.dart';

export 'src/model/callback_session.dart' show CallbackSession;
export 'src/model/callback_type.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:native_authentication_flutter/src/model/exception.dart';
import 'package:native_authentication/src/model/exception.dart';

/// Error codes of a failed OAuth flow.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ import 'dart:io';

import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication_flutter/src/platform/native_auth.android.dart';
import 'package:native_authentication_flutter/src/platform/native_auth.desktop.dart';
import 'package:native_authentication_flutter/src/platform/native_auth.ios.dart';
import 'package:native_authentication_flutter/src/platform/native_auth.macos.dart';
import 'package:native_authentication/native_authentication.dart';
import 'package:native_authentication/src/platform/native_auth.android.dart';
import 'package:native_authentication/src/platform/native_auth.desktop.dart';
import 'package:native_authentication/src/platform/native_auth.ios.dart';
import 'package:native_authentication/src/platform/native_auth.macos.dart';

abstract base class NativeAuthenticationPlatform
implements NativeAuthentication {
factory NativeAuthenticationPlatform({
Logger? logger,
}) {
if (Platform.isAndroid) {
return NativeAuthenticationAndroid(logger: logger);
if (const bool.fromEnvironment('dart.library.ui')) {
if (Platform.isAndroid) {
return NativeAuthenticationAndroid(logger: logger);
}
if (Platform.isIOS) {
return NativeAuthenticationIos(logger: logger);
}
if (Platform.isMacOS) {
return NativeAuthenticationMacOs(logger: logger);
}
}
if (Platform.isIOS) {
return NativeAuthenticationIos(logger: logger);
}
if (Platform.isMacOS) {
return NativeAuthenticationMacOs(logger: logger);
}
if (Platform.isWindows || Platform.isLinux) {
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
return NativeAuthenticationDesktop(logger: logger);
}
throw UnsupportedError('Unsupported platform: ${Platform.operatingSystem}');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:logging/logging.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication/native_authentication.dart';

final class NativeAuthenticationPlatform implements NativeAuthentication {
NativeAuthenticationPlatform({Logger? logger});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';

import 'package:logging/logging.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication_flutter/src/model/callback_session.dart';
import 'package:native_authentication/native_authentication.dart';
import 'package:native_authentication/src/model/callback_session.dart';
import 'package:path/path.dart';
import 'package:web/web.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import 'dart:async';

import 'package:jni/jni.dart';
import 'package:logging/logging.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication_flutter/src/model/callback_session.dart';
import 'package:native_authentication_flutter/src/native/android/jni_bindings.ffi.dart'
import 'package:native_authentication/native_authentication.dart';
import 'package:native_authentication/src/model/callback_session.dart';
import 'package:native_authentication/src/native/android/jni_bindings.ffi.dart'
as android;
import 'package:native_authentication_flutter/src/native_auth.platform_io.dart';
import 'package:native_authentication/src/native_auth.platform_io.dart';

final class NativeAuthenticationAndroid extends NativeAuthenticationPlatform {
NativeAuthenticationAndroid({Logger? logger})
Expand Down Expand Up @@ -116,6 +116,7 @@ final class NativeAuthenticationAndroid extends NativeAuthenticationPlatform {
'Another redirect operation is in progress (id=${currentSession.id})',
);
}
// ignore: invalid_use_of_internal_member
final sessionId = NativeAuthCallbackSessionImpl.nextId();
final cancellationToken = _nativeAuth.startCallback(
sessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'dart:convert';
import 'dart:io';

import 'package:logging/logging.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication_flutter/src/model/callback_session.dart';
import 'package:native_authentication_flutter/src/native_auth.platform_io.dart';
import 'package:native_authentication/native_authentication.dart';
import 'package:native_authentication/src/model/callback_session.dart';
import 'package:native_authentication/src/native_auth.platform_io.dart';
import 'package:stream_transform/stream_transform.dart';

base class NativeAuthenticationDesktop extends NativeAuthenticationPlatform {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'dart:async';
import 'dart:ffi';

import 'package:logging/logging.dart';
import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication_flutter/src/model/callback_session.dart';
import 'package:native_authentication_flutter/src/native/ios/authentication_services.ffi.dart';
import 'package:native_authentication_flutter/src/native_auth.platform_io.dart';
import 'package:native_authentication/native_authentication.dart';
import 'package:native_authentication/src/model/callback_session.dart';
import 'package:native_authentication/src/native/ios/authentication_services.ffi.dart';
import 'package:native_authentication/src/native_auth.platform_io.dart';
import 'package:objective_c/objective_c.dart' as objc;

final class NativeAuthenticationIos extends NativeAuthenticationPlatform {
Expand Down Expand Up @@ -87,6 +87,7 @@ final class NativeAuthenticationIos extends NativeAuthenticationPlatform {
logger?.fine('Started ASWebAuthenticationSession');
completion.future.whenComplete(_cleanUp).ignore();
return NativeAuthCallbackSessionImpl(
// ignore: invalid_use_of_internal_member
NativeAuthCallbackSessionImpl.nextId(),
completion,
session.cancel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:async';
import 'dart:ffi';

import 'package:native_authentication_flutter/native_authentication_flutter.dart';
import 'package:native_authentication_flutter/src/model/callback_session.dart';
import 'package:native_authentication_flutter/src/native/macos/authentication_services.ffi.dart';
import 'package:native_authentication_flutter/src/platform/native_auth.desktop.dart';
import 'package:native_authentication/native_authentication.dart';
import 'package:native_authentication/src/model/callback_session.dart';
import 'package:native_authentication/src/native/macos/authentication_services.ffi.dart';
import 'package:native_authentication/src/platform/native_auth.desktop.dart';
import 'package:objective_c/objective_c.dart' as objc;

final class NativeAuthenticationMacOs extends NativeAuthenticationDesktop {
Expand Down Expand Up @@ -111,6 +111,7 @@ final class NativeAuthenticationMacOs extends NativeAuthenticationDesktop {
logger?.fine('Started ASWebAuthenticationSession');
completion.future.whenComplete(_cleanUp).ignore();
return NativeAuthCallbackSessionImpl(
// ignore: invalid_use_of_internal_member
NativeAuthCallbackSessionImpl.nextId(),
completion,
session.cancel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'native_authentication_flutter'
s.name = 'native_authentication'
s.version = '0.0.1'
s.summary = 'Native support for package:native_authentication_flutter'
s.summary = 'Native support for package:native_authentication'
s.description = <<-DESC
Wraps ASWebAuthenticationSession for macOS.
DESC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: native_authentication_flutter
name: native_authentication
description: Native bindings for platform-specific authentication APIs like ASWebAuthenticationSession and Chrome Custom Tabs.
version: 0.0.1
publish_to: none
version: 0.1.0

environment:
sdk: ^3.3.0
Expand All @@ -11,22 +10,20 @@ dependencies:
async: ^2.11.0
collection: ^1.18.0
ffi: ^2.1.3
flutter:
sdk: flutter
jni: '>=0.9.0 <0.11.0'
logging: ^1.2.0
meta: ^1.15.0
native_assets_cli: ^0.7.2
native_toolchain_c: ^0.5.2
objective_c: ^1.1.0
path: ^1.9.0
plugin_platform_interface: ^2.0.0
stream_transform: ^2.1.0
web: '>=0.5.0 <2.0.0'

dev_dependencies:
ffigen: ^13.0.0
flutter_test:
sdk: flutter
flutter_lints: ^4.0.0
test: any
lints: ^4.0.0
jnigen: ^0.10.0

flutter:
Expand Down
Loading