@0xpolygonid/js-sdk 1.30.0 → 1.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8255,7 +8255,26 @@ const VerifiableConstants = Object.freeze({
8255
8255
  CONTEXT_TYPE_IS_EMPTY: 'ctxType is empty',
8256
8256
  // ErrStateNotFound issuer state is genesis state.
8257
8257
  IDENTITY_DOES_NOT_EXIST: 'Identity does not exist',
8258
- NO_AUTH_CRED_FOUND: 'no auth credentials found'
8258
+ NO_AUTH_CRED_FOUND: 'no auth credentials found',
8259
+ // identity wallet
8260
+ ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: 'no credential satisfied query',
8261
+ ID_WALLET_SIGNER_IS_REQUIRED: 'Ethereum signer is required to create Ethereum identities in order to transit state',
8262
+ ID_WALLET_PROVER_IS_REQUIRED: 'prover is required to generate proofs for non ethereum identities',
8263
+ ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: 'credential must have coreClaim representation in the signature proof',
8264
+ ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: 'credential must have coreClaim representation in proofs',
8265
+ ID_WALLET_CORE_CLAIM_MISMATCH: 'core claim representations is set in both proofs but they are not equal',
8266
+ ID_WALLET_CORE_CLAIM_IS_NOT_SET: 'core claim is not set in credential proofs',
8267
+ ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: 'profile or identity not found',
8268
+ ID_WALLET_PROFILE_ALREADY_EXISTS: 'profile with given nonce or verifier already exists',
8269
+ ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: 'issuer auth credential must have proof',
8270
+ ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: 'mtp is required for auth bjj key to issue new credentials',
8271
+ // proof service
8272
+ PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: 'no credentials belong to did or its profiles',
8273
+ PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: 'credential not found for query',
8274
+ PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: 'subject and auth profiles are not derived from the same did',
8275
+ PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: 'no queries in zkp request',
8276
+ // credential wallet
8277
+ CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: 'all claims are revoked'
8259
8278
  },
8260
8279
  CREDENTIAL_TYPE: {
8261
8280
  // VerifiableCredential is a W3C verifiable credential type
@@ -21245,12 +21264,12 @@ const createVerifiablePresentation = (context, tp, credential, queries) => {
21245
21264
  }
21246
21265
  const skeleton = {
21247
21266
  '@context': baseContext,
21248
- '@type': VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_PRESENTATION,
21267
+ type: VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_PRESENTATION,
21249
21268
  verifiableCredential: {
21250
21269
  '@context': ldContext,
21251
- '@type': vcTypes,
21270
+ type: vcTypes,
21252
21271
  credentialSubject: {
21253
- '@type': tp
21272
+ type: tp
21254
21273
  }
21255
21274
  }
21256
21275
  };
@@ -31682,6 +31701,7 @@ class JsonSchemaValidator {
31682
31701
  validator = ajv ?? defaultJSONSchemaValidator;
31683
31702
  if (validator.formats && !Object.keys(validator.formats).length) {
31684
31703
  addFormats(validator);
31704
+ addCustomFormats(validator);
31685
31705
  }
31686
31706
  const validate = (schema.$id ? validator.getSchema(schema.$id) : undefined) || validator.compile(schema);
31687
31707
  const valid = validate(data);
@@ -31692,6 +31712,16 @@ class JsonSchemaValidator {
31692
31712
  return true;
31693
31713
  }
31694
31714
  }
31715
+ function addCustomFormats(validator) {
31716
+ validator.addFormat('positive-integer', {
31717
+ type: 'string',
31718
+ validate: (positiveIntegerStr) => /^[1-9]\d*$/.test(positiveIntegerStr)
31719
+ });
31720
+ validator.addFormat('non-negative-integer', {
31721
+ type: 'string',
31722
+ validate: (nonNegativeIntegerStr) => /^(0|[1-9]\d*)$/.test(nonNegativeIntegerStr)
31723
+ });
31724
+ }
31695
31725
 
31696
31726
  /* eslint-disable @typescript-eslint/no-var-requires */
31697
31727
  /**
@@ -41047,6 +41077,82 @@ function dnsEncode(name, _maxLength) {
41047
41077
  }))) + "00";
41048
41078
  }
41049
41079
 
41080
+ const regexBytes = new RegExp("^bytes([0-9]+)$");
41081
+ const regexNumber = new RegExp("^(u?int)([0-9]*)$");
41082
+ const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
41083
+ function _pack(type, value, isArray) {
41084
+ switch (type) {
41085
+ case "address":
41086
+ if (isArray) {
41087
+ return getBytes(zeroPadValue(value, 32));
41088
+ }
41089
+ return getBytes(getAddress(value));
41090
+ case "string":
41091
+ return toUtf8Bytes(value);
41092
+ case "bytes":
41093
+ return getBytes(value);
41094
+ case "bool":
41095
+ value = (!!value ? "0x01" : "0x00");
41096
+ if (isArray) {
41097
+ return getBytes(zeroPadValue(value, 32));
41098
+ }
41099
+ return getBytes(value);
41100
+ }
41101
+ let match = type.match(regexNumber);
41102
+ if (match) {
41103
+ let signed = (match[1] === "int");
41104
+ let size = parseInt(match[2] || "256");
41105
+ assertArgument((!match[2] || match[2] === String(size)) && (size % 8 === 0) && size !== 0 && size <= 256, "invalid number type", "type", type);
41106
+ if (isArray) {
41107
+ size = 256;
41108
+ }
41109
+ if (signed) {
41110
+ value = toTwos(value, size);
41111
+ }
41112
+ return getBytes(zeroPadValue(toBeArray(value), size / 8));
41113
+ }
41114
+ match = type.match(regexBytes);
41115
+ if (match) {
41116
+ const size = parseInt(match[1]);
41117
+ assertArgument(String(size) === match[1] && size !== 0 && size <= 32, "invalid bytes type", "type", type);
41118
+ assertArgument(dataLength(value) === size, `invalid value for ${type}`, "value", value);
41119
+ if (isArray) {
41120
+ return getBytes(zeroPadBytes(value, 32));
41121
+ }
41122
+ return value;
41123
+ }
41124
+ match = type.match(regexArray);
41125
+ if (match && Array.isArray(value)) {
41126
+ const baseType = match[1];
41127
+ const count = parseInt(match[2] || String(value.length));
41128
+ assertArgument(count === value.length, `invalid array length for ${type}`, "value", value);
41129
+ const result = [];
41130
+ value.forEach(function (value) {
41131
+ result.push(_pack(baseType, value, true));
41132
+ });
41133
+ return getBytes(concat(result));
41134
+ }
41135
+ assertArgument(false, "invalid type", "type", type);
41136
+ }
41137
+ // @TODO: Array Enum
41138
+ /**
41139
+ * Computes the [[link-solc-packed]] representation of %%values%%
41140
+ * respectively to their %%types%%.
41141
+ *
41142
+ * @example:
41143
+ * addr = "0x8ba1f109551bd432803012645ac136ddd64dba72"
41144
+ * solidityPacked([ "address", "uint" ], [ addr, 45 ]);
41145
+ * //_result:
41146
+ */
41147
+ function solidityPacked(types, values) {
41148
+ assertArgument(types.length === values.length, "wrong number of values; expected ${ types.length }", "values", values);
41149
+ const tight = [];
41150
+ types.forEach(function (type, index) {
41151
+ tight.push(_pack(type, values[index]));
41152
+ });
41153
+ return hexlify(concat(tight));
41154
+ }
41155
+
41050
41156
  //import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer";
41051
41157
  const padding = new Uint8Array(32);
41052
41158
  padding.fill(0);
@@ -55368,34 +55474,60 @@ const processZeroKnowledgeProofRequests = async (to, requests, from, proofServic
55368
55474
  const groupedCredentialsCache = new Map();
55369
55475
  const zkpResponses = [];
55370
55476
  for (const proofReq of requestScope) {
55371
- if (!opts.supportedCircuits.includes(proofReq.circuitId)) {
55372
- throw new Error(`Circuit ${proofReq.circuitId} is not allowed`);
55373
- }
55374
- const query = proofReq.query;
55375
- const groupId = query.groupId;
55376
- const combinedQueryData = combinedQueries.get(groupId);
55377
- if (groupId) {
55378
- if (!combinedQueryData) {
55379
- throw new Error(`Invalid group id ${query.groupId}`);
55380
- }
55381
- const combinedQuery = combinedQueryData.query;
55382
- if (!groupedCredentialsCache.has(groupId)) {
55383
- const credWithRevStatus = await proofService.findCredentialByProofQuery(to, combinedQueryData.query);
55384
- if (!credWithRevStatus.cred) {
55385
- throw new Error(`Credential not found for query ${JSON.stringify(combinedQuery)}`);
55477
+ let zkpRes;
55478
+ try {
55479
+ const isCircuitSupported = opts.supportedCircuits.includes(proofReq.circuitId);
55480
+ if (!isCircuitSupported) {
55481
+ if (proofReq.optional) {
55482
+ continue;
55483
+ }
55484
+ throw new Error(`Circuit ${proofReq.circuitId} is not allowed`);
55485
+ }
55486
+ const query = proofReq.query;
55487
+ const groupId = query.groupId;
55488
+ const combinedQueryData = combinedQueries.get(groupId);
55489
+ if (groupId) {
55490
+ if (!combinedQueryData) {
55491
+ throw new Error(`Invalid group id ${query.groupId}`);
55492
+ }
55493
+ const combinedQuery = combinedQueryData.query;
55494
+ if (!groupedCredentialsCache.has(groupId)) {
55495
+ const credWithRevStatus = await proofService.findCredentialByProofQuery(to, combinedQueryData.query);
55496
+ if (!credWithRevStatus.cred) {
55497
+ if (proofReq.optional) {
55498
+ continue;
55499
+ }
55500
+ throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY +
55501
+ `${JSON.stringify(combinedQuery)}`);
55502
+ }
55503
+ groupedCredentialsCache.set(groupId, credWithRevStatus);
55386
55504
  }
55387
- groupedCredentialsCache.set(groupId, credWithRevStatus);
55388
55505
  }
55506
+ const credWithRevStatus = groupedCredentialsCache.get(groupId);
55507
+ zkpRes = await proofService.generateProof(proofReq, to, {
55508
+ verifierDid: from,
55509
+ challenge: opts.challenge,
55510
+ skipRevocation: Boolean(query.skipClaimRevocationCheck),
55511
+ credential: credWithRevStatus?.cred,
55512
+ credentialRevocationStatus: credWithRevStatus?.revStatus,
55513
+ linkNonce: combinedQueryData?.linkNonce ? BigInt(combinedQueryData.linkNonce) : undefined
55514
+ });
55515
+ }
55516
+ catch (error) {
55517
+ const expectedErrors = [
55518
+ VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE,
55519
+ VerifiableConstants.ERRORS.ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY,
55520
+ VerifiableConstants.ERRORS.CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED
55521
+ ];
55522
+ // handle only errors in case credential is not found and it is optional proof request - otherwise throw
55523
+ if (error instanceof Error &&
55524
+ (expectedErrors.includes(error.message) ||
55525
+ error.message.includes(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY)) &&
55526
+ proofReq.optional) {
55527
+ continue;
55528
+ }
55529
+ throw error;
55389
55530
  }
55390
- const credWithRevStatus = groupedCredentialsCache.get(groupId);
55391
- const zkpRes = await proofService.generateProof(proofReq, to, {
55392
- verifierDid: from,
55393
- challenge: opts.challenge,
55394
- skipRevocation: Boolean(query.skipClaimRevocationCheck),
55395
- credential: credWithRevStatus?.cred,
55396
- credentialRevocationStatus: credWithRevStatus?.revStatus,
55397
- linkNonce: combinedQueryData?.linkNonce ? BigInt(combinedQueryData.linkNonce) : undefined
55398
- });
55399
55531
  zkpResponses.push(zkpRes);
55400
55532
  }
55401
55533
  return zkpResponses;
@@ -57063,7 +57195,7 @@ class CredentialWallet {
57063
57195
  }
57064
57196
  return { cred, revStatus };
57065
57197
  }
57066
- throw new Error('all claims are revoked');
57198
+ throw new Error(VerifiableConstants.ERRORS.CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED);
57067
57199
  }
57068
57200
  }
57069
57201
 
@@ -65216,6 +65348,26 @@ const fieldValueFromVerifiablePresentation = async (fieldName, verifiablePresent
65216
65348
  }
65217
65349
  return await value.mtEntry();
65218
65350
  };
65351
+ function calculateGroupId(requestIds) {
65352
+ const types = Array(requestIds.length).fill('uint256');
65353
+ const groupID = BigInt(keccak256(solidityPacked(types, requestIds))) &
65354
+ // It should fit in a field number in the circuit (max 253 bits). With this we truncate to 252 bits for the group ID
65355
+ BigInt('0x0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
65356
+ return groupID;
65357
+ }
65358
+ function calculateRequestId(requestParams, creatorAddress) {
65359
+ // 0x0000000000000000FFFF...FF. Reserved first 8 bytes for the request Id type and future use
65360
+ // 0x00010000000000000000...00. First 2 bytes for the request Id type
65361
+ // - 0x0000... for old request Ids with uint64
65362
+ // - 0x0001... for new request Ids with uint256
65363
+ const requestId = (BigInt(keccak256(solidityPacked(['bytes', 'address'], [requestParams, creatorAddress]))) &
65364
+ BigInt('0x0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) +
65365
+ BigInt('0x0001000000000000000000000000000000000000000000000000000000000000');
65366
+ return requestId;
65367
+ }
65368
+ function calculateMultiRequestId(requestIds, groupIds, creatorAddress) {
65369
+ return BigInt(keccak256(solidityPacked(['uint256[]', 'uint256[]', 'address'], [requestIds, groupIds, creatorAddress])));
65370
+ }
65219
65371
 
65220
65372
  function calculateQueryHashV2(values, schema, slotIndex, operator, claimPathKey, claimPathNotExists) {
65221
65373
  const expValue = prepareCircuitArrayValues(values, 64);
@@ -65749,7 +65901,8 @@ class ProofService {
65749
65901
  credentialWithRevStatus = { cred: opts.credential, revStatus };
65750
65902
  }
65751
65903
  if (!credentialWithRevStatus.cred) {
65752
- throw new Error(`credential not found for query ${JSON.stringify(proofReq.query)}`);
65904
+ throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY +
65905
+ ` ${JSON.stringify(proofReq.query)}`);
65753
65906
  }
65754
65907
  const credentialCoreClaim = await this._identityWallet.getCoreClaimFromCredential(credentialWithRevStatus.cred);
65755
65908
  const { nonce: authProfileNonce, genesisDID } = await this._identityWallet.getGenesisDIDMetadata(identifier);
@@ -65761,11 +65914,11 @@ class ProofService {
65761
65914
  const subjectDID = DID.parse(preparedCredential.credential.credentialSubject['id']);
65762
65915
  const { nonce: credentialSubjectProfileNonce, genesisDID: subjectGenesisDID } = await this._identityWallet.getGenesisDIDMetadata(subjectDID);
65763
65916
  if (subjectGenesisDID.string() !== genesisDID.string()) {
65764
- throw new Error('subject and auth profiles are not derived from the same did');
65917
+ throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH);
65765
65918
  }
65766
65919
  const propertiesMetadata = parseCredentialSubject(proofReq.query.credentialSubject);
65767
65920
  if (!propertiesMetadata.length) {
65768
- throw new Error('no queries in zkp request');
65921
+ throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST);
65769
65922
  }
65770
65923
  const mtPosition = preparedCredential.credentialCoreClaim.getMerklizedPosition();
65771
65924
  let mk;
@@ -65949,7 +66102,7 @@ class ProofService {
65949
66102
  async findCredentialByProofQuery(did, query) {
65950
66103
  const credentials = await this._identityWallet.findOwnedCredentialsByDID(did, query);
65951
66104
  if (!credentials.length) {
65952
- throw new Error(`no credentials belong to did or its profiles`);
66105
+ throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE);
65953
66106
  }
65954
66107
  // For EQ / IN / NIN / LT / GT operations selective if credential satisfies query - we can get any.
65955
66108
  // TODO: choose credential for selective credentials
@@ -66148,7 +66301,7 @@ class IdentityWallet {
66148
66301
  let credential;
66149
66302
  const ethSigner = opts.ethSigner;
66150
66303
  if (opts.createBjjCredential && !ethSigner) {
66151
- throw new Error('Ethereum signer is required to create Ethereum identities in order to transit state');
66304
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_SIGNER_IS_REQUIRED);
66152
66305
  }
66153
66306
  const currentState = ZERO_HASH; // In Ethereum identities we don't have an initial state with the auth credential
66154
66307
  const didType = buildDIDType(opts.method || DidMethod.Iden3, opts.blockchain || Blockchain.Polygon, opts.networkId || NetworkId.Amoy);
@@ -66186,7 +66339,7 @@ class IdentityWallet {
66186
66339
  }
66187
66340
  const profile = await this._storage.identity.getProfileById(did.string());
66188
66341
  if (!profile) {
66189
- throw new Error('profile or identity not found');
66342
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND);
66190
66343
  }
66191
66344
  return { nonce: profile.nonce, genesisDID: DID.parse(profile.genesisIdentifier) };
66192
66345
  }
@@ -66196,7 +66349,7 @@ class IdentityWallet {
66196
66349
  const identityProfiles = await this._storage.identity.getProfilesByGenesisIdentifier(did.string());
66197
66350
  const existingProfile = identityProfiles.find((p) => p.nonce == nonce || p.verifier == verifier);
66198
66351
  if (existingProfile) {
66199
- throw new Error('profile with given nonce or verifier already exists');
66352
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROFILE_ALREADY_EXISTS);
66200
66353
  }
66201
66354
  await this._storage.identity.saveProfile({
66202
66355
  id: profileDID.string(),
@@ -66345,11 +66498,11 @@ class IdentityWallet {
66345
66498
  const coreClaimHash = poseidon.hash([hi, hv]);
66346
66499
  const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
66347
66500
  if (!issuerAuthBJJCredential.proof) {
66348
- throw new Error('issuer auth credential must have proof');
66501
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF);
66349
66502
  }
66350
66503
  const mtpAuthBJJProof = issuerAuthBJJCredential.getIden3SparseMerkleTreeProof();
66351
66504
  if (!mtpAuthBJJProof) {
66352
- throw new Error('mtp is required for auth bjj key to issue new credentials');
66505
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF);
66353
66506
  }
66354
66507
  const sigProof = new BJJSignatureProof2021({
66355
66508
  issuerData: {
@@ -66389,7 +66542,7 @@ class IdentityWallet {
66389
66542
  const issuerTree = await this.getDIDTreeModel(issuerDID);
66390
66543
  const coreClaim = await this.getCoreClaimFromCredential(credential);
66391
66544
  if (!coreClaim) {
66392
- throw new Error('credential must have coreClaim representation in proofs');
66545
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF);
66393
66546
  }
66394
66547
  const nonce = coreClaim.getRevocationNonce();
66395
66548
  await issuerTree.revocationTree.add(nonce, BigInt(0));
@@ -66412,7 +66565,7 @@ class IdentityWallet {
66412
66565
  // credential must have a bjj signature proof
66413
66566
  const coreClaim = credential.getCoreClaimFromProof(ProofType.BJJSignature);
66414
66567
  if (!coreClaim) {
66415
- throw new Error('credential must have coreClaim representation in the signature proof');
66568
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF);
66416
66569
  }
66417
66570
  await this._storage.mt.addToMerkleTree(issuerDID.string(), MerkleTreeType.Claims, coreClaim.hIndex(), coreClaim.hValue());
66418
66571
  }
@@ -66444,7 +66597,7 @@ class IdentityWallet {
66444
66597
  const coreClaim = credential.getCoreClaimFromProof(ProofType.BJJSignature) ||
66445
66598
  (await credential.toCoreClaim(opts));
66446
66599
  if (!coreClaim) {
66447
- throw new Error('credential must have coreClaim representation in the signature proof');
66600
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF);
66448
66601
  }
66449
66602
  const mtpWithProof = await this.generateCoreClaimMtp(issuerDID, coreClaim, treeState);
66450
66603
  const mtpProof = new Iden3SparseMerkleTreeProof({
@@ -66512,10 +66665,10 @@ class IdentityWallet {
66512
66665
  if (coreClaimFromMtpProof &&
66513
66666
  coreClaimFromSigProof &&
66514
66667
  coreClaimFromMtpProof.hex() !== coreClaimFromSigProof.hex()) {
66515
- throw new Error('core claim representations is set in both proofs but they are not equal');
66668
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_MISMATCH);
66516
66669
  }
66517
66670
  if (!coreClaimFromMtpProof && !coreClaimFromSigProof) {
66518
- throw new Error('core claim is not set in credential proofs');
66671
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_IS_NOT_SET);
66519
66672
  }
66520
66673
  //eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66521
66674
  const coreClaim = coreClaimFromMtpProof ?? coreClaimFromSigProof;
@@ -66524,7 +66677,7 @@ class IdentityWallet {
66524
66677
  async findOwnedCredentialsByDID(did, query) {
66525
66678
  const credentials = await this._credentialWallet.findByQuery(query);
66526
66679
  if (!credentials.length) {
66527
- throw new Error(`no credential satisfied query`);
66680
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY);
66528
66681
  }
66529
66682
  const { genesisDID } = await this.getGenesisDIDMetadata(did);
66530
66683
  const profiles = await this.getProfilesByDID(genesisDID);
@@ -66564,7 +66717,7 @@ class IdentityWallet {
66564
66717
  let txId;
66565
66718
  if (!isEthIdentity) {
66566
66719
  if (!prover) {
66567
- throw new Error('prover is required to generate proofs for non ethereum identities');
66720
+ throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROVER_IS_REQUIRED);
66568
66721
  }
66569
66722
  // generate the proof
66570
66723
  const authInfo = await this._inputsGenerator.prepareAuthBJJCredential(did, oldTreeState);
@@ -66680,5 +66833,5 @@ class IdentityWallet {
66680
66833
  }
66681
66834
  }
66682
66835
 
66683
- export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthMethod, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DiscoverFeatureQueryType, DiscoveryProtocolFeatureType, DiscoveryProtocolHandler, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedDataFormat, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calcChallengeAuthV2, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createDiscoveryFeatureDiscloseMessage, createDiscoveryFeatureQueryMessage, createPayment, createPaymentRequest, createProblemReportMessage, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, packEthIdentityProof, packMetadatas, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processProofAuth, processProofResponse, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, toTxDataArgs, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
66836
+ export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthMethod, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DiscoverFeatureQueryType, DiscoveryProtocolFeatureType, DiscoveryProtocolHandler, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedDataFormat, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calcChallengeAuthV2, calculateCoreSchemaHash, calculateGroupId, calculateMultiRequestId, calculateQueryHashV2, calculateQueryHashV3, calculateRequestId, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createDiscoveryFeatureDiscloseMessage, createDiscoveryFeatureQueryMessage, createPayment, createPaymentRequest, createProblemReportMessage, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, packEthIdentityProof, packMetadatas, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processProofAuth, processProofResponse, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, toTxDataArgs, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
66684
66837
  //# sourceMappingURL=index.js.map