-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: structure * feat: working project scoped token * feat: example * chore: revert import order change * chore: removed unused dotenv * fix: simplify Environment * fix: improve environment lookup * fix: make constructor private so only Environment class can make new instance * fix: revert environments as public * feat: dart consumer auth provider (#407) * fix: simplify Environment * fix: improve environment lookup * fix: make constructor private so only Environment class can make new instance * fix: revert environments as public * fix: env names and consumer url tests --------- Co-authored-by: Earl Grant Reyes <earl.r@affinidi.com> Co-authored-by: Carlos Rincon <“carlos.r@affinidi.com”> * fix: add consumerCisUrl * feat: iota and improved examples with dotenv * feat: token refresh * feat: add JS wallet service from Vault * fix: remove redundant Consumer base URL * feat: initial implementation of Consumer Auth Provider * feat: add temporary Token provider * feat: add fetchConsumerCisUrl test * fix: use seed instead of mnemonic * fix: updated implementation using encryptedSeed * fix: remove unused code * fix: update implementation to use encryptedSeed * fix: move wallet material to constructor * fix: rename environment types for consistency * fix: extract common endpoints * fix: rename package to affinidi_tdk_consumer_auth_provider * fix: rename package folder to consumer_auth_provider * fix: removed old file * fix: refactor * fix: rename packages correctly * feat: dart auth provider tests (#439) * feat: dart auth provider tests * feat: encrypted key tests * chore: test group name * chore: use mock vars * fix: type and var fixes --------- Co-authored-by: Carlos Rincon <“carlos.r@affinidi.com”> * fix: add check for existing token * chore: gitignored fvmrc * feat: add check for expiration * fix: env in integration test * fix: update integration test * feat: decrypt encrypted seed (#463) * fix: add test decryption * fix: add seed decryption * fix: use correct environment --------- Co-authored-by: Earl Grant Reyes <earl.r@affinidi.com> * chore: remove leftover file * feat: add script to generate dart code * fix: move decryptSeed into the CryptographyService * feat: move AesCbcEncryptionService to affinidi_cryptography_service * chore: dart integration tests (#468) * feat: integration tests * chore: consumer auth provider integration tests * fix: private vars * chore: ignore pubspec.lock * chore: ignore pubspec.lock * docs: updated readme --------- Co-authored-by: Carlos Rincon <“carlos.r@affinidi.com”> * fix: refresh token on all verification failures * feat: add dart docs * chore: remove API section * fix: fix Dart code generation * chore: test signed commit * feat: add consumer abstraction * chore: add VDM as example * feat: workspace (#488) Co-authored-by: Carlos Rincon <“carlos.r@affinidi.com”> * chore: change to TDK * chore: updated package descriptions * chore: move docs from base implementation * fix: initiate tokenProvider from constructor * feat: add CryptographyService abstraction * feat: add abstraction, docs, joined cryptography in one service --------- Co-authored-by: Carlos Rincon <“carlos.r@affinidi.com”> Co-authored-by: Earl Grant Reyes <earl.r@affinidi.com> Co-authored-by: hpelitebook745G2 <ambiguous.exe4585@gmail.com> Co-authored-by: hpelitebook745G2 <27658429+hpelitebook745G2@users.noreply.github.com>
- Loading branch information
1 parent
69d6bf0
commit b0287b3
Showing
73 changed files
with
3,420 additions
and
20 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.fvmrc |
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,10 @@ | ||
# Personal access token | ||
PROJECT_ID="" | ||
TOKEN_ID="" | ||
PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" | ||
PASSPHRASE="" # Optional. Required if private key is encrypted | ||
KEY_ID="" # Optional. Required if token's key id is different from token id | ||
|
||
# Iota (Websocket) | ||
IOTA_CONFIG_ID="" | ||
DID="" # Usually obtained at runtime from the registered user |
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,11 @@ | ||
# 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 | ||
|
||
# env files | ||
.env* | ||
!.env.example |
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,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
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,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. |
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,30 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
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,33 @@ | ||
import 'package:affinidi_tdk_auth_provider/affinidi_tdk_auth_provider.dart'; | ||
import 'package:dotenv/dotenv.dart'; | ||
|
||
void main() async { | ||
var env = DotEnv()..load(); | ||
if (!env.isEveryDefined( | ||
['PROJECT_ID', 'TOKEN_ID', 'PRIVATE_KEY', 'IOTA_CONFIG_ID', 'DID'])) { | ||
print( | ||
'Missing environment variables. Please provide PROJECT_ID, TOKEN_ID, PRIVATE_KEY, DID'); | ||
return; | ||
} | ||
// Workaround for dotenv multiline limitations | ||
final privateKey = env['PRIVATE_KEY']!.replaceAll('\\n', '\n'); | ||
|
||
final provider = AuthProvider( | ||
projectId: env['PROJECT_ID']!, | ||
tokenId: env['TOKEN_ID']!, | ||
privateKey: privateKey, | ||
// Optional parameters | ||
keyId: env['KEY_ID'], | ||
passphrase: env['PASSPHRASE'], | ||
); | ||
|
||
try { | ||
// Fetch iota token (websocket). Did is usually obtained at runtime from the registered user | ||
final iotaToken = provider.createIotaToken( | ||
iotaConfigId: env['IOTA_CONFIG_ID']!, did: env['DID']!); | ||
print('Successfully obtained iota token:'); | ||
print(iotaToken); | ||
} catch (e) { | ||
print('Error obtaining token: $e'); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/dart/auth_provider/example/project_scoped_token.dart
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,31 @@ | ||
import 'package:affinidi_tdk_auth_provider/affinidi_tdk_auth_provider.dart'; | ||
import 'package:dotenv/dotenv.dart'; | ||
|
||
void main() async { | ||
final env = DotEnv(includePlatformEnvironment: true)..load(); | ||
if (!env.isEveryDefined(['PROJECT_ID', 'TOKEN_ID', 'PRIVATE_KEY'])) { | ||
print( | ||
'Missing environment variables. Please provide PROJECT_ID, TOKEN_ID, PRIVATE_KEY'); | ||
return; | ||
} | ||
// Workaround for dotenv multiline limitations | ||
final privateKey = env['PRIVATE_KEY']!.replaceAll('\\n', '\n'); | ||
|
||
final provider = AuthProvider( | ||
projectId: env['PROJECT_ID']!, | ||
tokenId: env['TOKEN_ID']!, | ||
privateKey: privateKey, | ||
// Optional parameters | ||
keyId: env['KEY_ID'], | ||
passphrase: env['PASSPHRASE'], | ||
); | ||
|
||
try { | ||
// Fetch project scoped token | ||
final projectScopedToken = await provider.fetchProjectScopedToken(); | ||
print('Successfully obtained project scoped token:'); | ||
print(projectScopedToken); | ||
} catch (e) { | ||
print('Error obtaining token: $e'); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/dart/auth_provider/lib/affinidi_tdk_auth_provider.dart
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,8 @@ | ||
/// Support for doing something awesome. | ||
/// | ||
/// More dartdocs go here. | ||
library; | ||
|
||
export 'src/auth_provider.dart'; | ||
|
||
// TODO: Export any libraries intended for clients of this package. |
Oops, something went wrong.