diff --git a/.gitguardian.yml b/.gitguardian.yml new file mode 100644 index 00000000..bcdd953d --- /dev/null +++ b/.gitguardian.yml @@ -0,0 +1,7 @@ +version: 2 + +secret: + ignored_paths: + - 'lib/constants.dart' + - .gitignore + - '**/README.md' \ No newline at end of file diff --git a/lib/constants.dart b/lib/constants.dart index 40bf5bf4..d6691ac2 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,6 +1,7 @@ const AUTH_CLAIM_SCHEMA = "cca3371a6cb1b715004407e325bd993c"; const API_VERSION = 'v1'; const CHANNEL_NAME = 'technology.polygon.polygonid_flutter_sdk'; +const DEFAULT_AUTH_CLAIM_NONCE = '15930428023331155902'; /// Database const databaseName = "polygonIdSdk.db"; diff --git a/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart b/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart index ab75adde..40edaca9 100644 --- a/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart +++ b/lib/credential/data/data_sources/lib_pidcore_credential_data_source.dart @@ -17,13 +17,19 @@ class LibPolygonIdCoreCredentialDataSource { required String schema, required String nonce, required List publicKey, + Map additionalInputParam = const {}, }) { - String input = jsonEncode({ - "schema": schema, //"ca938857241db9451ea329256b9c06e5", - "nonce": nonce, //"15930428023331155902", + Map inputParam = { + "schema": schema, + "nonce": nonce, "indexSlotA": publicKey[0], "indexSlotB": publicKey[1], - }); + }; + + //merge additionInputParam with inputParam removing duplicates + Map inputMerged = {...inputParam, ...additionalInputParam}; + + String input = jsonEncode(inputMerged); String output = _polygonIdCoreCredential.createClaim(input); diff --git a/lib/credential/data/data_sources/local_claim_data_source.dart b/lib/credential/data/data_sources/local_claim_data_source.dart index e60e5f29..eb405756 100644 --- a/lib/credential/data/data_sources/local_claim_data_source.dart +++ b/lib/credential/data/data_sources/local_claim_data_source.dart @@ -8,9 +8,11 @@ class LocalClaimDataSource { LocalClaimDataSource(this._libPolygonIdCoreCredentialDataSource); - Future> getAuthClaim({required List publicKey}) { + Future> getAuthClaim({ + required List publicKey, + String authClaimNonce = DEFAULT_AUTH_CLAIM_NONCE, + }) { String authClaimSchema = AUTH_CLAIM_SCHEMA; - String authClaimNonce = "15930428023331155902"; String authClaim = _libPolygonIdCoreCredentialDataSource.issueClaim( schema: authClaimSchema, nonce: authClaimNonce, diff --git a/lib/credential/libs/polygonidcore/pidcore_credential.dart b/lib/credential/libs/polygonidcore/pidcore_credential.dart index 27952b87..764c652a 100644 --- a/lib/credential/libs/polygonidcore/pidcore_credential.dart +++ b/lib/credential/libs/polygonidcore/pidcore_credential.dart @@ -19,7 +19,11 @@ class PolygonIdCoreCredential extends PolygonIdCore { int res = PolygonIdCore.nativePolygonIdCoreLib .PLGNCreateClaim(response, in1, status); if (res == 0) { - consumeStatus(status, ""); + String? consumedStatus = consumeStatus(status, ""); + if (consumedStatus != null) { + malloc.free(status); + return consumedStatus; + } } String result = ""; ffi.Pointer jsonResponse = response.value; diff --git a/lib/iden3comm/authenticate.dart b/lib/iden3comm/authenticate.dart index 70e4bbb0..27291d35 100644 --- a/lib/iden3comm/authenticate.dart +++ b/lib/iden3comm/authenticate.dart @@ -120,6 +120,7 @@ class Authenticate { required String? pushToken, String? challenge, final Map? transactionData, + String authClaimNonce = DEFAULT_AUTH_CLAIM_NONCE, }) async { try { List proofs = []; @@ -187,6 +188,7 @@ class Authenticate { chain: chain, privateKey: privateKey, privateKeyBytes: privateKeyBytes, + authClaimNonce: authClaimNonce, ); // if there are proof requests and claims and they are the same length @@ -1198,6 +1200,7 @@ class Authenticate { required EnvEntity env, required ChainConfigEntity chain, required Uint8List privateKeyBytes, + required String authClaimNonce, }) async { List? authClaim; MTProofEntity? incProof; @@ -1211,7 +1214,6 @@ class Authenticate { List publicKey = BjjWallet(privateKeyBytes).publicKey; String authClaimSchema = AUTH_CLAIM_SCHEMA; - String authClaimNonce = "15930428023331155902"; String issuedAuthClaim = libPolygonIdCredential.issueClaim( schema: authClaimSchema, nonce: authClaimNonce, diff --git a/lib/sdk/di/injector.config.dart b/lib/sdk/di/injector.config.dart index 29ab5989..76189067 100644 --- a/lib/sdk/di/injector.config.dart +++ b/lib/sdk/di/injector.config.dart @@ -565,9 +565,9 @@ extension GetItInjectableX on _i1.GetIt { () => databaseModule.claimStore, instanceName: 'claimStore', ); - gh.factory<_i13.StoreRef>( - () => databaseModule.keyValueStore, - instanceName: 'keyValueStore', + gh.factory<_i13.StoreRef>>( + () => databaseModule.interactionStore, + instanceName: 'interactionStore', ); gh.factory<_i13.StoreRef>>( () => databaseModule.profileStore, @@ -581,9 +581,9 @@ extension GetItInjectableX on _i1.GetIt { () => databaseModule.identityStore, instanceName: 'identityStore', ); - gh.factory<_i13.StoreRef>>( - () => databaseModule.interactionStore, - instanceName: 'interactionStore', + gh.factory<_i13.StoreRef>( + () => databaseModule.keyValueStore, + instanceName: 'keyValueStore', ); gh.factory<_i66.TreeStateMapper>(() => _i66.TreeStateMapper()); gh.factory<_i67.TreeTypeMapper>(() => _i67.TreeTypeMapper());