This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from TBD54566975/use-real-pfi-widget-uri
feat: use real widget uris for PFi
- Loading branch information
Showing
10 changed files
with
116 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:tbdex/tbdex.dart'; | ||
|
||
final didProvider = Provider<String>((ref) => throw UnimplementedError()); | ||
final didProvider = Provider<Did>((ref) => throw UnimplementedError()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
class Pfi { | ||
final String id; | ||
final String name; | ||
final String widgetUrl; | ||
final String didUri; | ||
|
||
Pfi({ | ||
required this.id, | ||
required this.name, | ||
required this.widgetUrl, | ||
required this.didUri, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'dart:convert'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:tbdex/tbdex.dart'; | ||
|
||
class SecureStorageKeyManager implements KeyManager { | ||
final FlutterSecureStorage _storage; | ||
SecureStorageKeyManager(this._storage); | ||
|
||
@override | ||
Future<String> generatePrivateKey(DsaName alg) async { | ||
final privateKeyJwk = await DsaAlgorithms.generatePrivateKey(alg); | ||
final thumbprint = privateKeyJwk.computeThumbprint(); | ||
await _storage.write(key: thumbprint, value: privateKeyJwk.toString()); | ||
return thumbprint; | ||
} | ||
|
||
@override | ||
Future<Jwk> getPublicKey(String keyAlias) async { | ||
final privateKeyJwkStr = await _storage.read(key: keyAlias); | ||
|
||
if (privateKeyJwkStr == null) { | ||
throw Exception('No key found with alias $keyAlias'); | ||
} | ||
|
||
final privateKeyJwk = Jwk.fromJson(json.decode(privateKeyJwkStr)); | ||
return DsaAlgorithms.computePublicKey(privateKeyJwk); | ||
} | ||
|
||
@override | ||
Future<Uint8List> sign(String keyAlias, Uint8List payload) async { | ||
final privateKeyJwkStr = await _storage.read(key: keyAlias); | ||
|
||
if (privateKeyJwkStr == null) { | ||
throw Exception('No key found with alias $keyAlias'); | ||
} | ||
|
||
final privateKeyJwk = Jwk.fromJson(json.decode(privateKeyJwkStr)); | ||
return DsaAlgorithms.sign(privateKeyJwk, payload); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters