Skip to content

Commit

Permalink
feat: add packages/ion_identity_client
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-tychon committed Aug 13, 2024
1 parent 670ca61 commit 430b534
Show file tree
Hide file tree
Showing 51 changed files with 1,126 additions and 47 deletions.
33 changes: 15 additions & 18 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
channel: stable
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: android
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: ios
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: linux
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: macos
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: web
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: windows
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819

# User provided section

Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flutter 3.24.0-stable
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {

defaultConfig {
applicationId "io.ice.app.ion"
minSdkVersion flutter.minSdkVersion
minSdkVersion 28
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
4 changes: 4 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-if class androidx.credentials.CredentialManager
-keep class androidx.credentials.playservices.** {
*;
}
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}

include ":app"
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PODS:
- Flutter
- MTBBarcodeScanner (5.0.11)
- OrderedSet (5.0.0)
- passkeys_ios (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -33,6 +35,8 @@ PODS:
- Flutter
- FlutterMacOS
- TOCropViewController (2.6.1)
- ua_client_hints (1.3.1):
- Flutter
- url_launcher_ios (0.0.1):
- Flutter
- video_player_avfoundation (0.0.1):
Expand All @@ -45,12 +49,14 @@ DEPENDENCIES:
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- passkeys_ios (from `.symlinks/plugins/passkeys_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- ua_client_hints (from `.symlinks/plugins/ua_client_hints/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)

Expand All @@ -71,6 +77,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/image_cropper/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
passkeys_ios:
:path: ".symlinks/plugins/passkeys_ios/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
Expand All @@ -83,6 +91,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/darwin"
ua_client_hints:
:path: ".symlinks/plugins/ua_client_hints/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
video_player_avfoundation:
Expand All @@ -96,13 +106,15 @@ SPEC CHECKSUMS:
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
passkeys_ios: fdae8c06e2178a9fcb9261a6cb21fb9a06a81d53
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
ua_client_hints: 3b617011e47bea4b1ea65647efa12860b7280ad5
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3

Expand Down
13 changes: 12 additions & 1 deletion lib/app/features/auth/providers/auth_provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:ice/app/features/auth/data/models/auth_state.dart';
import 'package:ice/app/features/auth/data/models/auth_token.dart';
import 'package:ice/app/features/core/providers/env_provider.dart';
import 'package:ion_identity_client/ion_client.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'auth_provider.g.dart';
Expand All @@ -24,7 +25,17 @@ class Auth extends _$Auth {
Future<void> signIn({required String keyName}) async {
try {
state = const AuthenticationLoading();
await Future<void>.delayed(const Duration(seconds: 2));

final config = IonClientConfig(
appId: 'ap-dhesg-ct1r8-lu8a7rrodm4an8u',
orgId: 'or-625fn-dfjva-8b993vdrf414bkd8',
origin: 'https://dfns.blockchain.ice.vip',
);

final ionClient = IonApiClient.createDefault(config: config);

final result = await ionClient.auth.registerUser(username: keyName);

state = const Authenticated(
authToken: AuthToken(access: 'access', refresh: 'refresh'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class IdentityKeyNameInput extends HookWidget {
Widget build(BuildContext context) {
final hideKeyboardAndCallOnce = useHideKeyboardAndCallOnce();
return TextInput(
keyboardType: TextInputType.emailAddress,
prefixIcon: TextInputIcons(
hasRightDivider: true,
icons: [Assets.images.icons.iconIdentitykey.icon()],
Expand Down
1 change: 1 addition & 0 deletions lib/app/features/core/providers/permissions_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Permissions extends _$Permissions {
() => contactsPermissionStatus,
);
} on MissingPluginException {
} on UnimplementedError {
} finally {
state = Map<PermissionType, PermissionStatus>.unmodifiable(permissions);
}
Expand Down
29 changes: 29 additions & 0 deletions packages/ion_identity_client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/
10 changes: 10 additions & 0 deletions packages/ion_identity_client/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "54e66469a933b60ddf175f858f82eaeb97e48c8d"
channel: "stable"

project_type: package
3 changes: 3 additions & 0 deletions packages/ion_identity_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* This version adds Sign Up with Passkeys.
1 change: 1 addition & 0 deletions packages/ion_identity_client/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
39 changes: 39 additions & 0 deletions packages/ion_identity_client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->

TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.

## Features

TODO: List what your package can do. Maybe include images, gifs, or videos.

## Getting started

TODO: List prerequisites and provide or point to information on how to
start using the package.

## Usage

TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.

```dart
const like = 'sample';
```

## Additional information

TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
9 changes: 9 additions & 0 deletions packages/ion_identity_client/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include: package:very_good_analysis/analysis_options.yaml

analyzer:
errors:
avoid_dynamic_calls: ignore
avoid_positional_boolean_parameters: ignore
lines_longer_than_80_chars: ignore
public_member_api_docs: ignore
unnecessary_library_directive: ignore
5 changes: 5 additions & 0 deletions packages/ion_identity_client/lib/ion_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library ion_identity_client;

export 'src/auth/ion_auth.dart';
export 'src/ion_api_client.dart';
export 'src/ion_client_config.dart';
15 changes: 15 additions & 0 deletions packages/ion_identity_client/lib/src/auth/dtos/authentication.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:ion_identity_client/src/utils/types.dart';

class Authentication {
Authentication({
required this.token,
});

factory Authentication.fromJson(JsonObject map) {
return Authentication(
token: map['token'] as String,
);
}

final String token;
}
21 changes: 21 additions & 0 deletions packages/ion_identity_client/lib/src/auth/dtos/credential.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:ion_identity_client/src/utils/types.dart';

class Credential {
Credential({
required this.uuid,
required this.kind,
required this.name,
});

factory Credential.fromJson(JsonObject map) {
return Credential(
uuid: map['uuid'] as String,
kind: map['kind'] as String,
name: map['name'] as String,
);
}

final String uuid;
final String kind;
final String name;
}
7 changes: 7 additions & 0 deletions packages/ion_identity_client/lib/src/auth/dtos/dtos.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export 'credential.dart';
export 'register_complete_request.dart';
export 'register_complete_response.dart';
export 'register_init_request.dart';
export 'signed_challenge.dart';
export 'user.dart';
export 'wallet.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:ion_identity_client/src/auth/dtos/signed_challenge.dart';
import 'package:ion_identity_client/src/utils/types.dart';

class RegisterCompleteRequest {
RegisterCompleteRequest({
required this.appId,
required this.signedChallenge,
required this.temporaryAuthenticationToken,
});

factory RegisterCompleteRequest.fromJson(JsonObject json) {
return RegisterCompleteRequest(
appId: json['appId'] as String,
signedChallenge: SignedChallenge.fromJson(json['signedChallenge'] as JsonObject),
temporaryAuthenticationToken: json['temporaryAuthenticationToken'] as String,
);
}

final String appId;
final SignedChallenge signedChallenge;
final String temporaryAuthenticationToken;

JsonObject toJson() {
return {
'appId': appId,
'signedChallenge': signedChallenge.toJson(),
'temporaryAuthenticationToken': temporaryAuthenticationToken,
};
}
}
Loading

0 comments on commit 430b534

Please sign in to comment.