@0xpolygonid/js-sdk 1.30.0 → 1.31.3
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.
- package/dist/browser/esm/index.js +972 -367
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +975 -365
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/credential-wallet.js +1 -1
- package/dist/node/cjs/credentials/status/on-chain-revocation.js +3 -10
- package/dist/node/cjs/iden3comm/handlers/common.js +51 -24
- package/dist/node/cjs/identity/identity-wallet.js +29 -16
- package/dist/node/cjs/proof/proof-service.js +5 -4
- package/dist/node/cjs/proof/verifiers/query.js +25 -1
- package/dist/node/cjs/schema-processor/json/validator.js +11 -0
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +0 -1
- package/dist/node/cjs/storage/blockchain/state.js +120 -3
- package/dist/node/cjs/storage/memory/cache-lru.js +25 -0
- package/dist/node/cjs/storage/memory/index.js +1 -0
- package/dist/node/cjs/storage/shared/identity-storage.js +7 -0
- package/dist/node/cjs/verifiable/constants.js +26 -2
- package/dist/node/cjs/verifiable/presentation.js +3 -3
- package/dist/node/esm/credentials/credential-wallet.js +1 -1
- package/dist/node/esm/credentials/status/on-chain-revocation.js +4 -11
- package/dist/node/esm/iden3comm/handlers/common.js +51 -24
- package/dist/node/esm/identity/identity-wallet.js +29 -16
- package/dist/node/esm/proof/proof-service.js +6 -5
- package/dist/node/esm/proof/verifiers/query.js +21 -0
- package/dist/node/esm/schema-processor/json/validator.js +11 -0
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +0 -1
- package/dist/node/esm/storage/blockchain/state.js +120 -3
- package/dist/node/esm/storage/memory/cache-lru.js +18 -0
- package/dist/node/esm/storage/memory/index.js +1 -0
- package/dist/node/esm/storage/shared/identity-storage.js +7 -0
- package/dist/node/esm/verifiable/constants.js +25 -1
- package/dist/node/esm/verifiable/presentation.js +3 -3
- package/dist/types/credentials/status/on-chain-revocation.d.ts +6 -2
- package/dist/types/iden3comm/types/protocol/auth.d.ts +2 -2
- package/dist/types/identity/identity-wallet.d.ts +18 -3
- package/dist/types/proof/verifiers/query.d.ts +3 -0
- package/dist/types/storage/blockchain/state.d.ts +65 -1
- package/dist/types/storage/entities/identity.d.ts +1 -0
- package/dist/types/storage/interfaces/identity.d.ts +8 -1
- package/dist/types/storage/memory/cache-lru.d.ts +10 -0
- package/dist/types/storage/memory/index.d.ts +1 -0
- package/dist/types/storage/shared/identity-storage.d.ts +5 -0
- package/dist/types/verifiable/constants.d.ts +21 -0
- package/package.json +3 -2
|
@@ -11388,7 +11388,27 @@ var PolygonIdSdk = (function (exports) {
|
|
|
11388
11388
|
CONTEXT_TYPE_IS_EMPTY: 'ctxType is empty',
|
|
11389
11389
|
// ErrStateNotFound issuer state is genesis state.
|
|
11390
11390
|
IDENTITY_DOES_NOT_EXIST: 'Identity does not exist',
|
|
11391
|
-
NO_AUTH_CRED_FOUND: 'no auth credentials found'
|
|
11391
|
+
NO_AUTH_CRED_FOUND: 'no auth credentials found',
|
|
11392
|
+
// identity wallet
|
|
11393
|
+
ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: 'no credential satisfied query',
|
|
11394
|
+
ID_WALLET_SIGNER_IS_REQUIRED: 'Ethereum signer is required to create Ethereum identities in order to transit state',
|
|
11395
|
+
ID_WALLET_PROVER_IS_REQUIRED: 'prover is required to generate proofs for non ethereum identities',
|
|
11396
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF: 'credential must have coreClaim representation in the signature proof',
|
|
11397
|
+
ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF: 'credential must have coreClaim representation in proofs',
|
|
11398
|
+
ID_WALLET_CORE_CLAIM_MISMATCH: 'core claim representations is set in both proofs but they are not equal',
|
|
11399
|
+
ID_WALLET_CORE_CLAIM_IS_NOT_SET: 'core claim is not set in credential proofs',
|
|
11400
|
+
ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND: 'profile or identity not found',
|
|
11401
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS: 'profile with given nonce or verifier already exists',
|
|
11402
|
+
ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS: 'profile with given verifier and tags already exists',
|
|
11403
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF: 'issuer auth credential must have proof',
|
|
11404
|
+
ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF: 'mtp is required for auth bjj key to issue new credentials',
|
|
11405
|
+
// proof service
|
|
11406
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE: 'no credentials belong to did or its profiles',
|
|
11407
|
+
PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY: 'credential not found for query',
|
|
11408
|
+
PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH: 'subject and auth profiles are not derived from the same did',
|
|
11409
|
+
PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST: 'no queries in zkp request',
|
|
11410
|
+
// credential wallet
|
|
11411
|
+
CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED: 'all claims are revoked'
|
|
11392
11412
|
},
|
|
11393
11413
|
CREDENTIAL_TYPE: {
|
|
11394
11414
|
// VerifiableCredential is a W3C verifiable credential type
|
|
@@ -11561,6 +11581,10 @@ var PolygonIdSdk = (function (exports) {
|
|
|
11561
11581
|
(function (DisplayMethodType) {
|
|
11562
11582
|
DisplayMethodType["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
|
|
11563
11583
|
})(exports.DisplayMethodType || (exports.DisplayMethodType = {}));
|
|
11584
|
+
/**
|
|
11585
|
+
* Default cache max size for in-memory cache
|
|
11586
|
+
*/
|
|
11587
|
+
const DEFAULT_CACHE_MAX_SIZE = 10000;
|
|
11564
11588
|
|
|
11565
11589
|
/**
|
|
11566
11590
|
* Iden3SparseMerkleProof is a iden3 protocol merkle tree proof
|
|
@@ -37772,12 +37796,12 @@ var PolygonIdSdk = (function (exports) {
|
|
|
37772
37796
|
}
|
|
37773
37797
|
const skeleton = {
|
|
37774
37798
|
'@context': baseContext,
|
|
37775
|
-
|
|
37799
|
+
type: VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_PRESENTATION,
|
|
37776
37800
|
verifiableCredential: {
|
|
37777
37801
|
'@context': ldContext,
|
|
37778
|
-
|
|
37802
|
+
type: vcTypes,
|
|
37779
37803
|
credentialSubject: {
|
|
37780
|
-
|
|
37804
|
+
type: tp
|
|
37781
37805
|
}
|
|
37782
37806
|
}
|
|
37783
37807
|
};
|
|
@@ -48209,6 +48233,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
48209
48233
|
validator = ajv ?? defaultJSONSchemaValidator;
|
|
48210
48234
|
if (validator.formats && !Object.keys(validator.formats).length) {
|
|
48211
48235
|
addFormats(validator);
|
|
48236
|
+
addCustomFormats(validator);
|
|
48212
48237
|
}
|
|
48213
48238
|
const validate = (schema.$id ? validator.getSchema(schema.$id) : undefined) || validator.compile(schema);
|
|
48214
48239
|
const valid = validate(data);
|
|
@@ -48219,6 +48244,16 @@ var PolygonIdSdk = (function (exports) {
|
|
|
48219
48244
|
return true;
|
|
48220
48245
|
}
|
|
48221
48246
|
}
|
|
48247
|
+
function addCustomFormats(validator) {
|
|
48248
|
+
validator.addFormat('positive-integer', {
|
|
48249
|
+
type: 'string',
|
|
48250
|
+
validate: (positiveIntegerStr) => /^[1-9]\d*$/.test(positiveIntegerStr)
|
|
48251
|
+
});
|
|
48252
|
+
validator.addFormat('non-negative-integer', {
|
|
48253
|
+
type: 'string',
|
|
48254
|
+
validate: (nonNegativeIntegerStr) => /^(0|[1-9]\d*)$/.test(nonNegativeIntegerStr)
|
|
48255
|
+
});
|
|
48256
|
+
}
|
|
48222
48257
|
|
|
48223
48258
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
48224
48259
|
/**
|
|
@@ -57574,6 +57609,82 @@ var PolygonIdSdk = (function (exports) {
|
|
|
57574
57609
|
}))) + "00";
|
|
57575
57610
|
}
|
|
57576
57611
|
|
|
57612
|
+
const regexBytes = new RegExp("^bytes([0-9]+)$");
|
|
57613
|
+
const regexNumber = new RegExp("^(u?int)([0-9]*)$");
|
|
57614
|
+
const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
|
|
57615
|
+
function _pack(type, value, isArray) {
|
|
57616
|
+
switch (type) {
|
|
57617
|
+
case "address":
|
|
57618
|
+
if (isArray) {
|
|
57619
|
+
return getBytes(zeroPadValue(value, 32));
|
|
57620
|
+
}
|
|
57621
|
+
return getBytes(getAddress(value));
|
|
57622
|
+
case "string":
|
|
57623
|
+
return toUtf8Bytes(value);
|
|
57624
|
+
case "bytes":
|
|
57625
|
+
return getBytes(value);
|
|
57626
|
+
case "bool":
|
|
57627
|
+
value = (!!value ? "0x01" : "0x00");
|
|
57628
|
+
if (isArray) {
|
|
57629
|
+
return getBytes(zeroPadValue(value, 32));
|
|
57630
|
+
}
|
|
57631
|
+
return getBytes(value);
|
|
57632
|
+
}
|
|
57633
|
+
let match = type.match(regexNumber);
|
|
57634
|
+
if (match) {
|
|
57635
|
+
let signed = (match[1] === "int");
|
|
57636
|
+
let size = parseInt(match[2] || "256");
|
|
57637
|
+
assertArgument((!match[2] || match[2] === String(size)) && (size % 8 === 0) && size !== 0 && size <= 256, "invalid number type", "type", type);
|
|
57638
|
+
if (isArray) {
|
|
57639
|
+
size = 256;
|
|
57640
|
+
}
|
|
57641
|
+
if (signed) {
|
|
57642
|
+
value = toTwos(value, size);
|
|
57643
|
+
}
|
|
57644
|
+
return getBytes(zeroPadValue(toBeArray(value), size / 8));
|
|
57645
|
+
}
|
|
57646
|
+
match = type.match(regexBytes);
|
|
57647
|
+
if (match) {
|
|
57648
|
+
const size = parseInt(match[1]);
|
|
57649
|
+
assertArgument(String(size) === match[1] && size !== 0 && size <= 32, "invalid bytes type", "type", type);
|
|
57650
|
+
assertArgument(dataLength(value) === size, `invalid value for ${type}`, "value", value);
|
|
57651
|
+
if (isArray) {
|
|
57652
|
+
return getBytes(zeroPadBytes(value, 32));
|
|
57653
|
+
}
|
|
57654
|
+
return value;
|
|
57655
|
+
}
|
|
57656
|
+
match = type.match(regexArray);
|
|
57657
|
+
if (match && Array.isArray(value)) {
|
|
57658
|
+
const baseType = match[1];
|
|
57659
|
+
const count = parseInt(match[2] || String(value.length));
|
|
57660
|
+
assertArgument(count === value.length, `invalid array length for ${type}`, "value", value);
|
|
57661
|
+
const result = [];
|
|
57662
|
+
value.forEach(function (value) {
|
|
57663
|
+
result.push(_pack(baseType, value, true));
|
|
57664
|
+
});
|
|
57665
|
+
return getBytes(concat(result));
|
|
57666
|
+
}
|
|
57667
|
+
assertArgument(false, "invalid type", "type", type);
|
|
57668
|
+
}
|
|
57669
|
+
// @TODO: Array Enum
|
|
57670
|
+
/**
|
|
57671
|
+
* Computes the [[link-solc-packed]] representation of %%values%%
|
|
57672
|
+
* respectively to their %%types%%.
|
|
57673
|
+
*
|
|
57674
|
+
* @example:
|
|
57675
|
+
* addr = "0x8ba1f109551bd432803012645ac136ddd64dba72"
|
|
57676
|
+
* solidityPacked([ "address", "uint" ], [ addr, 45 ]);
|
|
57677
|
+
* //_result:
|
|
57678
|
+
*/
|
|
57679
|
+
function solidityPacked(types, values) {
|
|
57680
|
+
assertArgument(types.length === values.length, "wrong number of values; expected ${ types.length }", "values", values);
|
|
57681
|
+
const tight = [];
|
|
57682
|
+
types.forEach(function (type, index) {
|
|
57683
|
+
tight.push(_pack(type, values[index]));
|
|
57684
|
+
});
|
|
57685
|
+
return hexlify(concat(tight));
|
|
57686
|
+
}
|
|
57687
|
+
|
|
57577
57688
|
//import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer";
|
|
57578
57689
|
const padding = new Uint8Array(32);
|
|
57579
57690
|
padding.fill(0);
|
|
@@ -70737,186 +70848,471 @@ var PolygonIdSdk = (function (exports) {
|
|
|
70737
70848
|
};
|
|
70738
70849
|
};
|
|
70739
70850
|
|
|
70740
|
-
|
|
70741
|
-
|
|
70742
|
-
|
|
70743
|
-
|
|
70744
|
-
|
|
70745
|
-
|
|
70746
|
-
|
|
70747
|
-
|
|
70748
|
-
|
|
70749
|
-
|
|
70750
|
-
|
|
70751
|
-
|
|
70851
|
+
/**
|
|
70852
|
+
* Type of MerkleTree
|
|
70853
|
+
*
|
|
70854
|
+
* @enum {number}
|
|
70855
|
+
*/
|
|
70856
|
+
exports.MerkleTreeType = void 0;
|
|
70857
|
+
(function (MerkleTreeType) {
|
|
70858
|
+
// Claims is merkle tree type for claims tree
|
|
70859
|
+
MerkleTreeType[MerkleTreeType["Claims"] = 0] = "Claims";
|
|
70860
|
+
// Revocations is merkle tree type for revocations tree
|
|
70861
|
+
MerkleTreeType[MerkleTreeType["Revocations"] = 1] = "Revocations";
|
|
70862
|
+
// Roots is merkle tree type for roots tree
|
|
70863
|
+
MerkleTreeType[MerkleTreeType["Roots"] = 2] = "Roots";
|
|
70864
|
+
})(exports.MerkleTreeType || (exports.MerkleTreeType = {}));
|
|
70865
|
+
|
|
70866
|
+
const MERKLE_TREE_TYPES = [
|
|
70867
|
+
exports.MerkleTreeType.Claims,
|
|
70868
|
+
exports.MerkleTreeType.Revocations,
|
|
70869
|
+
exports.MerkleTreeType.Roots
|
|
70870
|
+
];
|
|
70871
|
+
const createMerkleTreeMetaInfo = (identifier) => {
|
|
70872
|
+
const treesMeta = [];
|
|
70873
|
+
for (let index = 0; index < MERKLE_TREE_TYPES.length; index++) {
|
|
70874
|
+
const mType = MERKLE_TREE_TYPES[index];
|
|
70875
|
+
const treeId = `${identifier}+${mType}`;
|
|
70876
|
+
treesMeta.push({ treeId, identifier, type: mType });
|
|
70877
|
+
}
|
|
70878
|
+
return treesMeta;
|
|
70752
70879
|
};
|
|
70880
|
+
|
|
70753
70881
|
/**
|
|
70754
70882
|
*
|
|
70755
70883
|
*
|
|
70756
70884
|
* @public
|
|
70757
|
-
* @class
|
|
70758
|
-
* @implements implements
|
|
70885
|
+
* @class InMemoryMerkleTreeStorage
|
|
70886
|
+
* @implements implements IMerkleTreeStorage interface
|
|
70759
70887
|
*/
|
|
70760
|
-
class
|
|
70888
|
+
class InMemoryMerkleTreeStorage {
|
|
70761
70889
|
/**
|
|
70762
|
-
* Creates an instance of
|
|
70763
|
-
* @param {
|
|
70890
|
+
* Creates an instance of InMemoryMerkleTreeStorage.
|
|
70891
|
+
* @param {number} _mtDepth
|
|
70764
70892
|
*/
|
|
70765
|
-
constructor(
|
|
70766
|
-
this.
|
|
70767
|
-
|
|
70768
|
-
this.provider = new JsonRpcProvider(config.url);
|
|
70769
|
-
this.stateContract = new Contract(config.contractAddress, abi$3, this.provider);
|
|
70770
|
-
this._transactionService = new TransactionService(this.getRpcProvider());
|
|
70893
|
+
constructor(_mtDepth) {
|
|
70894
|
+
this.mtDepth = _mtDepth;
|
|
70895
|
+
this._data = {};
|
|
70771
70896
|
}
|
|
70772
|
-
/**
|
|
70773
|
-
async
|
|
70774
|
-
|
|
70775
|
-
|
|
70776
|
-
|
|
70777
|
-
|
|
70778
|
-
|
|
70779
|
-
|
|
70780
|
-
|
|
70781
|
-
|
|
70782
|
-
|
|
70783
|
-
|
|
70784
|
-
|
|
70785
|
-
|
|
70897
|
+
/** create trees in the memory*/
|
|
70898
|
+
async createIdentityMerkleTrees(identifier) {
|
|
70899
|
+
if (!identifier) {
|
|
70900
|
+
identifier = `${v4()}`;
|
|
70901
|
+
}
|
|
70902
|
+
if (this._data[identifier]) {
|
|
70903
|
+
throw new Error(`Present merkle tree meta information in the store for current identifier ${identifier}`);
|
|
70904
|
+
}
|
|
70905
|
+
this._data[identifier] = [];
|
|
70906
|
+
const treesMeta = [];
|
|
70907
|
+
MERKLE_TREE_TYPES.forEach((t) => {
|
|
70908
|
+
const treeId = identifier.concat('+' + t.toString());
|
|
70909
|
+
const tree = new Merkletree(new InMemoryDB(str2Bytes(treeId)), true, this.mtDepth);
|
|
70910
|
+
const metaInfo = { treeId, identifier: identifier, type: t };
|
|
70911
|
+
this._data[identifier].push({ tree, metaInfo });
|
|
70912
|
+
treesMeta.push(metaInfo);
|
|
70913
|
+
});
|
|
70914
|
+
return treesMeta;
|
|
70786
70915
|
}
|
|
70787
|
-
/**
|
|
70788
|
-
async
|
|
70789
|
-
|
|
70790
|
-
const rawData = await stateContract.getStateInfoByIdAndState(id, state);
|
|
70791
|
-
const stateInfo = {
|
|
70792
|
-
id: BigInt(rawData[0]),
|
|
70793
|
-
state: BigInt(rawData[1]),
|
|
70794
|
-
replacedByState: BigInt(rawData[2]),
|
|
70795
|
-
createdAtTimestamp: BigInt(rawData[3]),
|
|
70796
|
-
replacedAtTimestamp: BigInt(rawData[4]),
|
|
70797
|
-
createdAtBlock: BigInt(rawData[5]),
|
|
70798
|
-
replacedAtBlock: BigInt(rawData[6])
|
|
70799
|
-
};
|
|
70800
|
-
return stateInfo;
|
|
70916
|
+
/** get trees meta info from the memory */
|
|
70917
|
+
async getIdentityMerkleTreesInfo(identifier) {
|
|
70918
|
+
return this._data[identifier].map((treeWithInfo) => treeWithInfo.metaInfo);
|
|
70801
70919
|
}
|
|
70802
|
-
/**
|
|
70803
|
-
async
|
|
70804
|
-
const
|
|
70805
|
-
|
|
70806
|
-
|
|
70807
|
-
|
|
70808
|
-
|
|
70809
|
-
const preparedZkpProof = prepareZkpProof(proof.proof);
|
|
70810
|
-
const payload = [
|
|
70811
|
-
userId.bigInt().toString(),
|
|
70812
|
-
oldUserState.bigInt().toString(),
|
|
70813
|
-
newUserState.bigInt().toString(),
|
|
70814
|
-
isOldStateGenesis,
|
|
70815
|
-
preparedZkpProof.a,
|
|
70816
|
-
preparedZkpProof.b,
|
|
70817
|
-
preparedZkpProof.c
|
|
70818
|
-
];
|
|
70819
|
-
const feeData = await provider.getFeeData();
|
|
70820
|
-
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
70821
|
-
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
70822
|
-
: feeData.maxFeePerGas;
|
|
70823
|
-
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
70824
|
-
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
70825
|
-
: feeData.maxPriorityFeePerGas;
|
|
70826
|
-
const gasLimit = await contract.transitState.estimateGas(...payload);
|
|
70827
|
-
const txData = await contract.transitState.populateTransaction(...payload);
|
|
70828
|
-
const request = {
|
|
70829
|
-
to: txData.to,
|
|
70830
|
-
data: txData.data,
|
|
70831
|
-
gasLimit,
|
|
70832
|
-
maxFeePerGas,
|
|
70833
|
-
maxPriorityFeePerGas
|
|
70834
|
-
};
|
|
70835
|
-
const { txnHash } = await this._transactionService.sendTransactionRequest(signer, request);
|
|
70836
|
-
return txnHash;
|
|
70920
|
+
/** get merkle tree by identifier and type from memory */
|
|
70921
|
+
async getMerkleTreeByIdentifierAndType(identifier, mtType) {
|
|
70922
|
+
const treeWithMeta = this._data[identifier].find((treeWithInfo) => treeWithInfo.metaInfo.type == mtType);
|
|
70923
|
+
if (!treeWithMeta) {
|
|
70924
|
+
throw new Error(`Merkle tree not found for identifier ${identifier} and type ${mtType}`);
|
|
70925
|
+
}
|
|
70926
|
+
return treeWithMeta.tree;
|
|
70837
70927
|
}
|
|
70838
|
-
/**
|
|
70839
|
-
async
|
|
70840
|
-
|
|
70841
|
-
|
|
70842
|
-
|
|
70843
|
-
|
|
70844
|
-
|
|
70845
|
-
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
70846
|
-
: feeData.maxFeePerGas;
|
|
70847
|
-
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
70848
|
-
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
70849
|
-
: feeData.maxPriorityFeePerGas;
|
|
70850
|
-
const payload = [
|
|
70851
|
-
userId.bigInt().toString(),
|
|
70852
|
-
oldUserState.bigInt().toString(),
|
|
70853
|
-
newUserState.bigInt().toString(),
|
|
70854
|
-
isOldStateGenesis,
|
|
70855
|
-
methodId,
|
|
70856
|
-
methodParams //'0x'
|
|
70857
|
-
];
|
|
70858
|
-
const gasLimit = await contract.transitStateGeneric.estimateGas(...payload);
|
|
70859
|
-
const txData = await contract.transitStateGeneric.populateTransaction(...payload);
|
|
70860
|
-
const request = {
|
|
70861
|
-
to: txData.to,
|
|
70862
|
-
data: txData.data,
|
|
70863
|
-
gasLimit,
|
|
70864
|
-
maxFeePerGas,
|
|
70865
|
-
maxPriorityFeePerGas
|
|
70866
|
-
};
|
|
70867
|
-
const { txnHash } = await this._transactionService.sendTransactionRequest(signer, request);
|
|
70868
|
-
return txnHash;
|
|
70928
|
+
/** adds entry to merkle tree in the memory */
|
|
70929
|
+
async addToMerkleTree(identifier, mtType, hindex, hvalue) {
|
|
70930
|
+
for (let index = 0; index < this._data[identifier].length; index++) {
|
|
70931
|
+
if (this._data[identifier][index].metaInfo.type === mtType) {
|
|
70932
|
+
await this._data[identifier][index].tree.add(hindex, hvalue);
|
|
70933
|
+
}
|
|
70934
|
+
}
|
|
70869
70935
|
}
|
|
70870
|
-
/**
|
|
70871
|
-
async
|
|
70872
|
-
|
|
70873
|
-
|
|
70874
|
-
|
|
70875
|
-
|
|
70876
|
-
|
|
70877
|
-
siblings: data.siblings?.map((sibling) => BigInt(sibling.toString())),
|
|
70878
|
-
index: BigInt(data.index.toString()),
|
|
70879
|
-
value: BigInt(data.value.toString()),
|
|
70880
|
-
auxExistence: data.auxExistence,
|
|
70881
|
-
auxIndex: BigInt(data.auxIndex.toString()),
|
|
70882
|
-
auxValue: BigInt(data.auxValue.toString())
|
|
70883
|
-
};
|
|
70936
|
+
/** bind merkle tree identifier in memory */
|
|
70937
|
+
async bindMerkleTreeToNewIdentifier(oldIdentifier, newIdentifier) {
|
|
70938
|
+
this._data[newIdentifier] = [...this._data[oldIdentifier]];
|
|
70939
|
+
delete this._data[oldIdentifier];
|
|
70940
|
+
this._data[newIdentifier].forEach((treeWithMeta) => {
|
|
70941
|
+
treeWithMeta.metaInfo.identifier = newIdentifier;
|
|
70942
|
+
});
|
|
70884
70943
|
}
|
|
70885
|
-
|
|
70886
|
-
|
|
70887
|
-
|
|
70888
|
-
|
|
70889
|
-
|
|
70890
|
-
|
|
70891
|
-
|
|
70892
|
-
|
|
70893
|
-
|
|
70894
|
-
|
|
70895
|
-
|
|
70896
|
-
|
|
70944
|
+
}
|
|
70945
|
+
|
|
70946
|
+
/**
|
|
70947
|
+
* Storage Errors definition
|
|
70948
|
+
*
|
|
70949
|
+
* @enum {number}
|
|
70950
|
+
*/
|
|
70951
|
+
var StorageErrors;
|
|
70952
|
+
(function (StorageErrors) {
|
|
70953
|
+
StorageErrors["ItemNotFound"] = "item not found";
|
|
70954
|
+
})(StorageErrors || (StorageErrors = {}));
|
|
70955
|
+
|
|
70956
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
70957
|
+
/**
|
|
70958
|
+
* Generic Memory Data Source
|
|
70959
|
+
*
|
|
70960
|
+
* @public
|
|
70961
|
+
* @class InMemoryDataSource - class
|
|
70962
|
+
* @template Type
|
|
70963
|
+
*/
|
|
70964
|
+
class InMemoryDataSource {
|
|
70965
|
+
constructor() {
|
|
70966
|
+
this._data = [];
|
|
70897
70967
|
}
|
|
70898
|
-
/**
|
|
70899
|
-
|
|
70900
|
-
|
|
70968
|
+
/** saves in the memory */
|
|
70969
|
+
async save(key, value, keyName = 'id') {
|
|
70970
|
+
const itemIndex = this._data.findIndex((i) => i[keyName] === key);
|
|
70971
|
+
if (itemIndex === -1) {
|
|
70972
|
+
this._data.push(value);
|
|
70973
|
+
}
|
|
70974
|
+
else {
|
|
70975
|
+
this._data[itemIndex] = value;
|
|
70976
|
+
}
|
|
70901
70977
|
}
|
|
70902
|
-
|
|
70903
|
-
|
|
70904
|
-
|
|
70905
|
-
const config = this.networkByChainId(chainId);
|
|
70906
|
-
const provider = new JsonRpcProvider(config.url);
|
|
70907
|
-
const stateContract = new Contract(config.contractAddress, abi$3, provider);
|
|
70908
|
-
return { stateContract, provider };
|
|
70978
|
+
/** gets value from from the memory */
|
|
70979
|
+
async get(key, keyName = 'id') {
|
|
70980
|
+
return this._data.find((t) => t[keyName] === key);
|
|
70909
70981
|
}
|
|
70910
|
-
|
|
70911
|
-
|
|
70912
|
-
|
|
70913
|
-
|
|
70914
|
-
|
|
70982
|
+
/** loads from value from the memory */
|
|
70983
|
+
async load() {
|
|
70984
|
+
return this._data;
|
|
70985
|
+
}
|
|
70986
|
+
/** deletes from value from the memory */
|
|
70987
|
+
async delete(key, keyName = 'id') {
|
|
70988
|
+
const newData = this._data.filter((i) => i[keyName] !== key);
|
|
70989
|
+
if (newData.length === this._data.length) {
|
|
70990
|
+
throw new Error(`${StorageErrors.ItemNotFound} to delete: ${key}`);
|
|
70915
70991
|
}
|
|
70916
|
-
|
|
70992
|
+
this._data = newData;
|
|
70917
70993
|
}
|
|
70918
70994
|
}
|
|
70919
70995
|
|
|
70996
|
+
class QuickLRU extends Map {
|
|
70997
|
+
#size = 0;
|
|
70998
|
+
#cache = new Map();
|
|
70999
|
+
#oldCache = new Map();
|
|
71000
|
+
#maxSize;
|
|
71001
|
+
#maxAge;
|
|
71002
|
+
#onEviction;
|
|
71003
|
+
|
|
71004
|
+
constructor(options = {}) {
|
|
71005
|
+
super();
|
|
71006
|
+
|
|
71007
|
+
if (!(options.maxSize && options.maxSize > 0)) {
|
|
71008
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
71009
|
+
}
|
|
71010
|
+
|
|
71011
|
+
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
|
|
71012
|
+
throw new TypeError('`maxAge` must be a number greater than 0');
|
|
71013
|
+
}
|
|
71014
|
+
|
|
71015
|
+
this.#maxSize = options.maxSize;
|
|
71016
|
+
this.#maxAge = options.maxAge || Number.POSITIVE_INFINITY;
|
|
71017
|
+
this.#onEviction = options.onEviction;
|
|
71018
|
+
}
|
|
71019
|
+
|
|
71020
|
+
// For tests.
|
|
71021
|
+
get __oldCache() {
|
|
71022
|
+
return this.#oldCache;
|
|
71023
|
+
}
|
|
71024
|
+
|
|
71025
|
+
#emitEvictions(cache) {
|
|
71026
|
+
if (typeof this.#onEviction !== 'function') {
|
|
71027
|
+
return;
|
|
71028
|
+
}
|
|
71029
|
+
|
|
71030
|
+
for (const [key, item] of cache) {
|
|
71031
|
+
this.#onEviction(key, item.value);
|
|
71032
|
+
}
|
|
71033
|
+
}
|
|
71034
|
+
|
|
71035
|
+
#deleteIfExpired(key, item) {
|
|
71036
|
+
if (typeof item.expiry === 'number' && item.expiry <= Date.now()) {
|
|
71037
|
+
if (typeof this.#onEviction === 'function') {
|
|
71038
|
+
this.#onEviction(key, item.value);
|
|
71039
|
+
}
|
|
71040
|
+
|
|
71041
|
+
return this.delete(key);
|
|
71042
|
+
}
|
|
71043
|
+
|
|
71044
|
+
return false;
|
|
71045
|
+
}
|
|
71046
|
+
|
|
71047
|
+
#getOrDeleteIfExpired(key, item) {
|
|
71048
|
+
const deleted = this.#deleteIfExpired(key, item);
|
|
71049
|
+
if (deleted === false) {
|
|
71050
|
+
return item.value;
|
|
71051
|
+
}
|
|
71052
|
+
}
|
|
71053
|
+
|
|
71054
|
+
#getItemValue(key, item) {
|
|
71055
|
+
return item.expiry ? this.#getOrDeleteIfExpired(key, item) : item.value;
|
|
71056
|
+
}
|
|
71057
|
+
|
|
71058
|
+
#peek(key, cache) {
|
|
71059
|
+
const item = cache.get(key);
|
|
71060
|
+
|
|
71061
|
+
return this.#getItemValue(key, item);
|
|
71062
|
+
}
|
|
71063
|
+
|
|
71064
|
+
#set(key, value) {
|
|
71065
|
+
this.#cache.set(key, value);
|
|
71066
|
+
this.#size++;
|
|
71067
|
+
|
|
71068
|
+
if (this.#size >= this.#maxSize) {
|
|
71069
|
+
this.#size = 0;
|
|
71070
|
+
this.#emitEvictions(this.#oldCache);
|
|
71071
|
+
this.#oldCache = this.#cache;
|
|
71072
|
+
this.#cache = new Map();
|
|
71073
|
+
}
|
|
71074
|
+
}
|
|
71075
|
+
|
|
71076
|
+
#moveToRecent(key, item) {
|
|
71077
|
+
this.#oldCache.delete(key);
|
|
71078
|
+
this.#set(key, item);
|
|
71079
|
+
}
|
|
71080
|
+
|
|
71081
|
+
* #entriesAscending() {
|
|
71082
|
+
for (const item of this.#oldCache) {
|
|
71083
|
+
const [key, value] = item;
|
|
71084
|
+
if (!this.#cache.has(key)) {
|
|
71085
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
71086
|
+
if (deleted === false) {
|
|
71087
|
+
yield item;
|
|
71088
|
+
}
|
|
71089
|
+
}
|
|
71090
|
+
}
|
|
71091
|
+
|
|
71092
|
+
for (const item of this.#cache) {
|
|
71093
|
+
const [key, value] = item;
|
|
71094
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
71095
|
+
if (deleted === false) {
|
|
71096
|
+
yield item;
|
|
71097
|
+
}
|
|
71098
|
+
}
|
|
71099
|
+
}
|
|
71100
|
+
|
|
71101
|
+
get(key) {
|
|
71102
|
+
if (this.#cache.has(key)) {
|
|
71103
|
+
const item = this.#cache.get(key);
|
|
71104
|
+
return this.#getItemValue(key, item);
|
|
71105
|
+
}
|
|
71106
|
+
|
|
71107
|
+
if (this.#oldCache.has(key)) {
|
|
71108
|
+
const item = this.#oldCache.get(key);
|
|
71109
|
+
if (this.#deleteIfExpired(key, item) === false) {
|
|
71110
|
+
this.#moveToRecent(key, item);
|
|
71111
|
+
return item.value;
|
|
71112
|
+
}
|
|
71113
|
+
}
|
|
71114
|
+
}
|
|
71115
|
+
|
|
71116
|
+
set(key, value, {maxAge = this.#maxAge} = {}) {
|
|
71117
|
+
const expiry = typeof maxAge === 'number' && maxAge !== Number.POSITIVE_INFINITY
|
|
71118
|
+
? (Date.now() + maxAge)
|
|
71119
|
+
: undefined;
|
|
71120
|
+
|
|
71121
|
+
if (this.#cache.has(key)) {
|
|
71122
|
+
this.#cache.set(key, {
|
|
71123
|
+
value,
|
|
71124
|
+
expiry,
|
|
71125
|
+
});
|
|
71126
|
+
} else {
|
|
71127
|
+
this.#set(key, {value, expiry});
|
|
71128
|
+
}
|
|
71129
|
+
|
|
71130
|
+
return this;
|
|
71131
|
+
}
|
|
71132
|
+
|
|
71133
|
+
has(key) {
|
|
71134
|
+
if (this.#cache.has(key)) {
|
|
71135
|
+
return !this.#deleteIfExpired(key, this.#cache.get(key));
|
|
71136
|
+
}
|
|
71137
|
+
|
|
71138
|
+
if (this.#oldCache.has(key)) {
|
|
71139
|
+
return !this.#deleteIfExpired(key, this.#oldCache.get(key));
|
|
71140
|
+
}
|
|
71141
|
+
|
|
71142
|
+
return false;
|
|
71143
|
+
}
|
|
71144
|
+
|
|
71145
|
+
peek(key) {
|
|
71146
|
+
if (this.#cache.has(key)) {
|
|
71147
|
+
return this.#peek(key, this.#cache);
|
|
71148
|
+
}
|
|
71149
|
+
|
|
71150
|
+
if (this.#oldCache.has(key)) {
|
|
71151
|
+
return this.#peek(key, this.#oldCache);
|
|
71152
|
+
}
|
|
71153
|
+
}
|
|
71154
|
+
|
|
71155
|
+
delete(key) {
|
|
71156
|
+
const deleted = this.#cache.delete(key);
|
|
71157
|
+
if (deleted) {
|
|
71158
|
+
this.#size--;
|
|
71159
|
+
}
|
|
71160
|
+
|
|
71161
|
+
return this.#oldCache.delete(key) || deleted;
|
|
71162
|
+
}
|
|
71163
|
+
|
|
71164
|
+
clear() {
|
|
71165
|
+
this.#cache.clear();
|
|
71166
|
+
this.#oldCache.clear();
|
|
71167
|
+
this.#size = 0;
|
|
71168
|
+
}
|
|
71169
|
+
|
|
71170
|
+
resize(newSize) {
|
|
71171
|
+
if (!(newSize && newSize > 0)) {
|
|
71172
|
+
throw new TypeError('`maxSize` must be a number greater than 0');
|
|
71173
|
+
}
|
|
71174
|
+
|
|
71175
|
+
const items = [...this.#entriesAscending()];
|
|
71176
|
+
const removeCount = items.length - newSize;
|
|
71177
|
+
if (removeCount < 0) {
|
|
71178
|
+
this.#cache = new Map(items);
|
|
71179
|
+
this.#oldCache = new Map();
|
|
71180
|
+
this.#size = items.length;
|
|
71181
|
+
} else {
|
|
71182
|
+
if (removeCount > 0) {
|
|
71183
|
+
this.#emitEvictions(items.slice(0, removeCount));
|
|
71184
|
+
}
|
|
71185
|
+
|
|
71186
|
+
this.#oldCache = new Map(items.slice(removeCount));
|
|
71187
|
+
this.#cache = new Map();
|
|
71188
|
+
this.#size = 0;
|
|
71189
|
+
}
|
|
71190
|
+
|
|
71191
|
+
this.#maxSize = newSize;
|
|
71192
|
+
}
|
|
71193
|
+
|
|
71194
|
+
* keys() {
|
|
71195
|
+
for (const [key] of this) {
|
|
71196
|
+
yield key;
|
|
71197
|
+
}
|
|
71198
|
+
}
|
|
71199
|
+
|
|
71200
|
+
* values() {
|
|
71201
|
+
for (const [, value] of this) {
|
|
71202
|
+
yield value;
|
|
71203
|
+
}
|
|
71204
|
+
}
|
|
71205
|
+
|
|
71206
|
+
* [Symbol.iterator]() {
|
|
71207
|
+
for (const item of this.#cache) {
|
|
71208
|
+
const [key, value] = item;
|
|
71209
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
71210
|
+
if (deleted === false) {
|
|
71211
|
+
yield [key, value.value];
|
|
71212
|
+
}
|
|
71213
|
+
}
|
|
71214
|
+
|
|
71215
|
+
for (const item of this.#oldCache) {
|
|
71216
|
+
const [key, value] = item;
|
|
71217
|
+
if (!this.#cache.has(key)) {
|
|
71218
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
71219
|
+
if (deleted === false) {
|
|
71220
|
+
yield [key, value.value];
|
|
71221
|
+
}
|
|
71222
|
+
}
|
|
71223
|
+
}
|
|
71224
|
+
}
|
|
71225
|
+
|
|
71226
|
+
* entriesDescending() {
|
|
71227
|
+
let items = [...this.#cache];
|
|
71228
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
71229
|
+
const item = items[i];
|
|
71230
|
+
const [key, value] = item;
|
|
71231
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
71232
|
+
if (deleted === false) {
|
|
71233
|
+
yield [key, value.value];
|
|
71234
|
+
}
|
|
71235
|
+
}
|
|
71236
|
+
|
|
71237
|
+
items = [...this.#oldCache];
|
|
71238
|
+
for (let i = items.length - 1; i >= 0; --i) {
|
|
71239
|
+
const item = items[i];
|
|
71240
|
+
const [key, value] = item;
|
|
71241
|
+
if (!this.#cache.has(key)) {
|
|
71242
|
+
const deleted = this.#deleteIfExpired(key, value);
|
|
71243
|
+
if (deleted === false) {
|
|
71244
|
+
yield [key, value.value];
|
|
71245
|
+
}
|
|
71246
|
+
}
|
|
71247
|
+
}
|
|
71248
|
+
}
|
|
71249
|
+
|
|
71250
|
+
* entriesAscending() {
|
|
71251
|
+
for (const [key, value] of this.#entriesAscending()) {
|
|
71252
|
+
yield [key, value.value];
|
|
71253
|
+
}
|
|
71254
|
+
}
|
|
71255
|
+
|
|
71256
|
+
get size() {
|
|
71257
|
+
if (!this.#size) {
|
|
71258
|
+
return this.#oldCache.size;
|
|
71259
|
+
}
|
|
71260
|
+
|
|
71261
|
+
let oldCacheSize = 0;
|
|
71262
|
+
for (const key of this.#oldCache.keys()) {
|
|
71263
|
+
if (!this.#cache.has(key)) {
|
|
71264
|
+
oldCacheSize++;
|
|
71265
|
+
}
|
|
71266
|
+
}
|
|
71267
|
+
|
|
71268
|
+
return Math.min(this.#size + oldCacheSize, this.#maxSize);
|
|
71269
|
+
}
|
|
71270
|
+
|
|
71271
|
+
get maxSize() {
|
|
71272
|
+
return this.#maxSize;
|
|
71273
|
+
}
|
|
71274
|
+
|
|
71275
|
+
entries() {
|
|
71276
|
+
return this.entriesAscending();
|
|
71277
|
+
}
|
|
71278
|
+
|
|
71279
|
+
forEach(callbackFunction, thisArgument = this) {
|
|
71280
|
+
for (const [key, value] of this.entriesAscending()) {
|
|
71281
|
+
callbackFunction.call(thisArgument, value, key, this);
|
|
71282
|
+
}
|
|
71283
|
+
}
|
|
71284
|
+
|
|
71285
|
+
get [Symbol.toStringTag]() {
|
|
71286
|
+
return 'QuickLRU';
|
|
71287
|
+
}
|
|
71288
|
+
|
|
71289
|
+
toString() {
|
|
71290
|
+
return `QuickLRU(${this.size}/${this.maxSize})`;
|
|
71291
|
+
}
|
|
71292
|
+
|
|
71293
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
71294
|
+
return this.toString();
|
|
71295
|
+
}
|
|
71296
|
+
}
|
|
71297
|
+
|
|
71298
|
+
function createInMemoryCache(params) {
|
|
71299
|
+
const cache = new QuickLRU({ maxSize: params.maxSize, maxAge: params.ttl });
|
|
71300
|
+
return {
|
|
71301
|
+
get: async (key) => {
|
|
71302
|
+
return cache.get(key);
|
|
71303
|
+
},
|
|
71304
|
+
set: async (key, value, ttl) => {
|
|
71305
|
+
cache.set(key, value, { maxAge: ttl ?? params.ttl });
|
|
71306
|
+
},
|
|
71307
|
+
clear: async () => {
|
|
71308
|
+
cache.clear();
|
|
71309
|
+
},
|
|
71310
|
+
delete: async (key) => {
|
|
71311
|
+
cache.delete(key);
|
|
71312
|
+
}
|
|
71313
|
+
};
|
|
71314
|
+
}
|
|
71315
|
+
|
|
70920
71316
|
/**
|
|
70921
71317
|
* creates empty basic message
|
|
70922
71318
|
*
|
|
@@ -92676,34 +93072,60 @@ var PolygonIdSdk = (function (exports) {
|
|
|
92676
93072
|
const groupedCredentialsCache = new Map();
|
|
92677
93073
|
const zkpResponses = [];
|
|
92678
93074
|
for (const proofReq of requestScope) {
|
|
92679
|
-
|
|
92680
|
-
|
|
92681
|
-
|
|
92682
|
-
|
|
92683
|
-
|
|
92684
|
-
|
|
92685
|
-
|
|
92686
|
-
|
|
92687
|
-
|
|
92688
|
-
|
|
92689
|
-
const
|
|
92690
|
-
|
|
92691
|
-
|
|
92692
|
-
if (!
|
|
92693
|
-
throw new Error(`
|
|
93075
|
+
let zkpRes;
|
|
93076
|
+
try {
|
|
93077
|
+
const isCircuitSupported = opts.supportedCircuits.includes(proofReq.circuitId);
|
|
93078
|
+
if (!isCircuitSupported) {
|
|
93079
|
+
if (proofReq.optional) {
|
|
93080
|
+
continue;
|
|
93081
|
+
}
|
|
93082
|
+
throw new Error(`Circuit ${proofReq.circuitId} is not allowed`);
|
|
93083
|
+
}
|
|
93084
|
+
const query = proofReq.query;
|
|
93085
|
+
const groupId = query.groupId;
|
|
93086
|
+
const combinedQueryData = combinedQueries.get(groupId);
|
|
93087
|
+
if (groupId) {
|
|
93088
|
+
if (!combinedQueryData) {
|
|
93089
|
+
throw new Error(`Invalid group id ${query.groupId}`);
|
|
93090
|
+
}
|
|
93091
|
+
const combinedQuery = combinedQueryData.query;
|
|
93092
|
+
if (!groupedCredentialsCache.has(groupId)) {
|
|
93093
|
+
const credWithRevStatus = await proofService.findCredentialByProofQuery(to, combinedQueryData.query);
|
|
93094
|
+
if (!credWithRevStatus.cred) {
|
|
93095
|
+
if (proofReq.optional) {
|
|
93096
|
+
continue;
|
|
93097
|
+
}
|
|
93098
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY +
|
|
93099
|
+
`${JSON.stringify(combinedQuery)}`);
|
|
93100
|
+
}
|
|
93101
|
+
groupedCredentialsCache.set(groupId, credWithRevStatus);
|
|
92694
93102
|
}
|
|
92695
|
-
groupedCredentialsCache.set(groupId, credWithRevStatus);
|
|
92696
93103
|
}
|
|
93104
|
+
const credWithRevStatus = groupedCredentialsCache.get(groupId);
|
|
93105
|
+
zkpRes = await proofService.generateProof(proofReq, to, {
|
|
93106
|
+
verifierDid: from,
|
|
93107
|
+
challenge: opts.challenge,
|
|
93108
|
+
skipRevocation: Boolean(query.skipClaimRevocationCheck),
|
|
93109
|
+
credential: credWithRevStatus?.cred,
|
|
93110
|
+
credentialRevocationStatus: credWithRevStatus?.revStatus,
|
|
93111
|
+
linkNonce: combinedQueryData?.linkNonce ? BigInt(combinedQueryData.linkNonce) : undefined
|
|
93112
|
+
});
|
|
93113
|
+
}
|
|
93114
|
+
catch (error) {
|
|
93115
|
+
const expectedErrors = [
|
|
93116
|
+
VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE,
|
|
93117
|
+
VerifiableConstants.ERRORS.ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY,
|
|
93118
|
+
VerifiableConstants.ERRORS.CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED
|
|
93119
|
+
];
|
|
93120
|
+
// handle only errors in case credential is not found and it is optional proof request - otherwise throw
|
|
93121
|
+
if (error instanceof Error &&
|
|
93122
|
+
(expectedErrors.includes(error.message) ||
|
|
93123
|
+
error.message.includes(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY)) &&
|
|
93124
|
+
proofReq.optional) {
|
|
93125
|
+
continue;
|
|
93126
|
+
}
|
|
93127
|
+
throw error;
|
|
92697
93128
|
}
|
|
92698
|
-
const credWithRevStatus = groupedCredentialsCache.get(groupId);
|
|
92699
|
-
const zkpRes = await proofService.generateProof(proofReq, to, {
|
|
92700
|
-
verifierDid: from,
|
|
92701
|
-
challenge: opts.challenge,
|
|
92702
|
-
skipRevocation: Boolean(query.skipClaimRevocationCheck),
|
|
92703
|
-
credential: credWithRevStatus?.cred,
|
|
92704
|
-
credentialRevocationStatus: credWithRevStatus?.revStatus,
|
|
92705
|
-
linkNonce: combinedQueryData?.linkNonce ? BigInt(combinedQueryData.linkNonce) : undefined
|
|
92706
|
-
});
|
|
92707
93129
|
zkpResponses.push(zkpRes);
|
|
92708
93130
|
}
|
|
92709
93131
|
return zkpResponses;
|
|
@@ -93573,8 +93995,9 @@ var PolygonIdSdk = (function (exports) {
|
|
|
93573
93995
|
* @public
|
|
93574
93996
|
* @param {Array<EthConnectionConfig>} _configs - list of ethereum network connections
|
|
93575
93997
|
*/
|
|
93576
|
-
constructor(_configs) {
|
|
93998
|
+
constructor(_configs, _opts) {
|
|
93577
93999
|
this._configs = _configs;
|
|
94000
|
+
this._stateStorage = new EthStateStorage(_configs, _opts?.stateStorageOptions);
|
|
93578
94001
|
}
|
|
93579
94002
|
/**
|
|
93580
94003
|
* resolve is a method to resolve a credential status from the blockchain.
|
|
@@ -93605,8 +94028,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
93605
94028
|
const issuerId = DID.idFromDID(issuer);
|
|
93606
94029
|
let latestIssuerState;
|
|
93607
94030
|
try {
|
|
93608
|
-
const
|
|
93609
|
-
const latestStateInfo = await ethStorage.getLatestStateById(issuerId.bigInt());
|
|
94031
|
+
const latestStateInfo = await this._stateStorage.getLatestStateById(issuerId.bigInt());
|
|
93610
94032
|
if (!latestStateInfo.state) {
|
|
93611
94033
|
throw new Error('state contract returned empty state');
|
|
93612
94034
|
}
|
|
@@ -93672,13 +94094,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
93672
94094
|
}
|
|
93673
94095
|
return network;
|
|
93674
94096
|
}
|
|
93675
|
-
// TODO: is dirty hack for mock in tests.
|
|
93676
|
-
// need to pass to constructor list of state stores not list of network configs
|
|
93677
|
-
_getStateStorageForIssuer(issuerId) {
|
|
93678
|
-
const issuerChainId = getChainId(DID.blockchainFromId(issuerId), DID.networkIdFromId(issuerId));
|
|
93679
|
-
const ethStorage = new EthStateStorage(this.networkByChainId(issuerChainId));
|
|
93680
|
-
return ethStorage;
|
|
93681
|
-
}
|
|
93682
94097
|
_getOnChainRevocationStorageForIssuer(chainId, contractAddress) {
|
|
93683
94098
|
const networkConfig = this.networkByChainId(chainId);
|
|
93684
94099
|
const onChainCaller = new OnChainRevocationStorage(networkConfig, contractAddress);
|
|
@@ -94371,7 +94786,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
94371
94786
|
}
|
|
94372
94787
|
return { cred, revStatus };
|
|
94373
94788
|
}
|
|
94374
|
-
throw new Error(
|
|
94789
|
+
throw new Error(VerifiableConstants.ERRORS.CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED);
|
|
94375
94790
|
}
|
|
94376
94791
|
}
|
|
94377
94792
|
|
|
@@ -95950,6 +96365,300 @@ var PolygonIdSdk = (function (exports) {
|
|
|
95950
96365
|
};
|
|
95951
96366
|
}
|
|
95952
96367
|
|
|
96368
|
+
const defaultEthConnectionConfig = {
|
|
96369
|
+
url: 'http://localhost:8545',
|
|
96370
|
+
defaultGasLimit: 600000,
|
|
96371
|
+
minGasPrice: '0',
|
|
96372
|
+
maxGasPrice: '100000000000',
|
|
96373
|
+
confirmationBlockCount: 5,
|
|
96374
|
+
confirmationTimeout: 600000,
|
|
96375
|
+
contractAddress: '',
|
|
96376
|
+
receiptTimeout: 600000,
|
|
96377
|
+
rpcResponseTimeout: 5000,
|
|
96378
|
+
waitReceiptCycleTime: 30000,
|
|
96379
|
+
waitBlockCycleTime: 3000
|
|
96380
|
+
};
|
|
96381
|
+
/**
|
|
96382
|
+
*
|
|
96383
|
+
*
|
|
96384
|
+
* @public
|
|
96385
|
+
* @class EthStateStorage
|
|
96386
|
+
* @implements implements IStateStorage interface
|
|
96387
|
+
*/
|
|
96388
|
+
class EthStateStorage {
|
|
96389
|
+
/**
|
|
96390
|
+
* Creates an instance of EthStateStorage.
|
|
96391
|
+
* @param {EthConnectionConfig} [ethConfig=defaultEthConnectionConfig]
|
|
96392
|
+
*/
|
|
96393
|
+
constructor(ethConfig, options) {
|
|
96394
|
+
this.ethConfig = ethConfig;
|
|
96395
|
+
this._disableCache = false;
|
|
96396
|
+
const config = Array.isArray(ethConfig) ? ethConfig[0] : ethConfig;
|
|
96397
|
+
this.provider = new JsonRpcProvider(config.url);
|
|
96398
|
+
this.stateContract = new Contract(config.contractAddress, abi$3, this.provider);
|
|
96399
|
+
this._transactionService = new TransactionService(this.getRpcProvider());
|
|
96400
|
+
// Store cache options for later use
|
|
96401
|
+
this._latestStateCacheOptions = {
|
|
96402
|
+
ttl: options?.latestStateCacheOptions?.ttl ?? DEFAULT_PROOF_VERIFY_DELAY / 2,
|
|
96403
|
+
maxSize: options?.latestStateCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
96404
|
+
};
|
|
96405
|
+
this._stateCacheOptions = {
|
|
96406
|
+
notReplacedTtl: options?.stateCacheOptions?.notReplacedTtl ??
|
|
96407
|
+
DEFAULT_PROOF_VERIFY_DELAY / 2,
|
|
96408
|
+
replacedTtl: options?.stateCacheOptions?.replacedTtl ?? DEFAULT_PROOF_VERIFY_DELAY,
|
|
96409
|
+
maxSize: options?.stateCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
96410
|
+
};
|
|
96411
|
+
this._rootCacheOptions = {
|
|
96412
|
+
replacedTtl: options?.rootCacheOptions?.replacedTtl ?? DEFAULT_AUTH_VERIFY_DELAY,
|
|
96413
|
+
notReplacedTtl: options?.rootCacheOptions?.notReplacedTtl ??
|
|
96414
|
+
DEFAULT_AUTH_VERIFY_DELAY / 2,
|
|
96415
|
+
maxSize: options?.rootCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
96416
|
+
};
|
|
96417
|
+
this._gistProofCacheOptions = {
|
|
96418
|
+
ttl: DEFAULT_AUTH_VERIFY_DELAY / 2,
|
|
96419
|
+
maxSize: options?.gistProofCacheOptions?.maxSize ?? DEFAULT_CACHE_MAX_SIZE
|
|
96420
|
+
};
|
|
96421
|
+
// Initialize cache instances
|
|
96422
|
+
this._latestStateResolveCache =
|
|
96423
|
+
options?.latestStateCacheOptions?.cache ??
|
|
96424
|
+
createInMemoryCache({
|
|
96425
|
+
maxSize: this._latestStateCacheOptions.maxSize,
|
|
96426
|
+
ttl: this._latestStateCacheOptions.ttl
|
|
96427
|
+
});
|
|
96428
|
+
this._stateResolveCache =
|
|
96429
|
+
options?.stateCacheOptions?.cache ??
|
|
96430
|
+
createInMemoryCache({
|
|
96431
|
+
maxSize: this._stateCacheOptions.maxSize,
|
|
96432
|
+
ttl: this._stateCacheOptions.replacedTtl
|
|
96433
|
+
});
|
|
96434
|
+
this._rootResolveCache =
|
|
96435
|
+
options?.rootCacheOptions?.cache ??
|
|
96436
|
+
createInMemoryCache({
|
|
96437
|
+
maxSize: this._rootCacheOptions.maxSize,
|
|
96438
|
+
ttl: this._rootCacheOptions.replacedTtl
|
|
96439
|
+
});
|
|
96440
|
+
this._gistProofResolveCache =
|
|
96441
|
+
options?.gistProofCacheOptions?.cache ??
|
|
96442
|
+
createInMemoryCache({
|
|
96443
|
+
maxSize: this._gistProofCacheOptions.maxSize,
|
|
96444
|
+
ttl: this._gistProofCacheOptions.ttl
|
|
96445
|
+
});
|
|
96446
|
+
this._disableCache = options?.disableCache ?? false;
|
|
96447
|
+
}
|
|
96448
|
+
/** {@inheritdoc IStateStorage.getLatestStateById} */
|
|
96449
|
+
async getLatestStateById(id) {
|
|
96450
|
+
const cacheKey = this.getLatestStateCacheKey(id);
|
|
96451
|
+
if (!this._disableCache) {
|
|
96452
|
+
// Check cache first
|
|
96453
|
+
const cachedResult = await this._latestStateResolveCache?.get(cacheKey);
|
|
96454
|
+
if (cachedResult) {
|
|
96455
|
+
return cachedResult;
|
|
96456
|
+
}
|
|
96457
|
+
}
|
|
96458
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
96459
|
+
const rawData = await stateContract.getStateInfoById(id);
|
|
96460
|
+
const stateInfo = {
|
|
96461
|
+
id: BigInt(rawData[0]),
|
|
96462
|
+
state: BigInt(rawData[1]),
|
|
96463
|
+
replacedByState: BigInt(rawData[2]),
|
|
96464
|
+
createdAtTimestamp: BigInt(rawData[3]),
|
|
96465
|
+
replacedAtTimestamp: BigInt(rawData[4]),
|
|
96466
|
+
createdAtBlock: BigInt(rawData[5]),
|
|
96467
|
+
replacedAtBlock: BigInt(rawData[6])
|
|
96468
|
+
};
|
|
96469
|
+
!this._disableCache &&
|
|
96470
|
+
(await this._latestStateResolveCache?.set(cacheKey, stateInfo, this._latestStateCacheOptions.ttl));
|
|
96471
|
+
return stateInfo;
|
|
96472
|
+
}
|
|
96473
|
+
/** {@inheritdoc IStateStorage.getStateInfoByIdAndState} */
|
|
96474
|
+
async getStateInfoByIdAndState(id, state) {
|
|
96475
|
+
const cacheKey = this.getStateCacheKey(id, state);
|
|
96476
|
+
if (!this._disableCache) {
|
|
96477
|
+
// Check cache first
|
|
96478
|
+
const cachedResult = await this._stateResolveCache?.get(cacheKey);
|
|
96479
|
+
if (cachedResult) {
|
|
96480
|
+
return cachedResult;
|
|
96481
|
+
}
|
|
96482
|
+
}
|
|
96483
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
96484
|
+
const rawData = await stateContract.getStateInfoByIdAndState(id, state);
|
|
96485
|
+
const stateInfo = {
|
|
96486
|
+
id: BigInt(rawData[0]),
|
|
96487
|
+
state: BigInt(rawData[1]),
|
|
96488
|
+
replacedByState: BigInt(rawData[2]),
|
|
96489
|
+
createdAtTimestamp: BigInt(rawData[3]),
|
|
96490
|
+
replacedAtTimestamp: BigInt(rawData[4]),
|
|
96491
|
+
createdAtBlock: BigInt(rawData[5]),
|
|
96492
|
+
replacedAtBlock: BigInt(rawData[6])
|
|
96493
|
+
};
|
|
96494
|
+
const ttl = stateInfo.replacedAtTimestamp === 0n
|
|
96495
|
+
? this._stateCacheOptions.notReplacedTtl
|
|
96496
|
+
: this._stateCacheOptions.replacedTtl;
|
|
96497
|
+
!this._disableCache && (await this._stateResolveCache?.set(cacheKey, stateInfo, ttl));
|
|
96498
|
+
return stateInfo;
|
|
96499
|
+
}
|
|
96500
|
+
/** {@inheritdoc IStateStorage.publishState} */
|
|
96501
|
+
async publishState(proof, signer) {
|
|
96502
|
+
const stateTransitionPubSig = new StateTransitionPubSignals();
|
|
96503
|
+
stateTransitionPubSig.pubSignalsUnmarshal(byteEncoder$1.encode(JSON.stringify(proof.pub_signals)));
|
|
96504
|
+
const { userId, oldUserState, newUserState, isOldStateGenesis } = stateTransitionPubSig;
|
|
96505
|
+
const { stateContract, provider } = this.getStateContractAndProviderForId(userId.bigInt());
|
|
96506
|
+
const contract = stateContract.connect(signer);
|
|
96507
|
+
const preparedZkpProof = prepareZkpProof(proof.proof);
|
|
96508
|
+
const payload = [
|
|
96509
|
+
userId.bigInt().toString(),
|
|
96510
|
+
oldUserState.bigInt().toString(),
|
|
96511
|
+
newUserState.bigInt().toString(),
|
|
96512
|
+
isOldStateGenesis,
|
|
96513
|
+
preparedZkpProof.a,
|
|
96514
|
+
preparedZkpProof.b,
|
|
96515
|
+
preparedZkpProof.c
|
|
96516
|
+
];
|
|
96517
|
+
const feeData = await provider.getFeeData();
|
|
96518
|
+
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
96519
|
+
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
96520
|
+
: feeData.maxFeePerGas;
|
|
96521
|
+
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
96522
|
+
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
96523
|
+
: feeData.maxPriorityFeePerGas;
|
|
96524
|
+
const gasLimit = await contract.transitState.estimateGas(...payload);
|
|
96525
|
+
const txData = await contract.transitState.populateTransaction(...payload);
|
|
96526
|
+
const request = {
|
|
96527
|
+
to: txData.to,
|
|
96528
|
+
data: txData.data,
|
|
96529
|
+
gasLimit,
|
|
96530
|
+
maxFeePerGas,
|
|
96531
|
+
maxPriorityFeePerGas
|
|
96532
|
+
};
|
|
96533
|
+
const { txnHash } = await this._transactionService.sendTransactionRequest(signer, request);
|
|
96534
|
+
return txnHash;
|
|
96535
|
+
}
|
|
96536
|
+
/** {@inheritdoc IStateStorage.publishStateGeneric} */
|
|
96537
|
+
async publishStateGeneric(signer, userStateTransitionInfo) {
|
|
96538
|
+
const { userId, oldUserState, newUserState, isOldStateGenesis, methodId, methodParams } = userStateTransitionInfo;
|
|
96539
|
+
const { stateContract, provider } = this.getStateContractAndProviderForId(userId.bigInt());
|
|
96540
|
+
const contract = stateContract.connect(signer);
|
|
96541
|
+
const feeData = await provider.getFeeData();
|
|
96542
|
+
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
96543
|
+
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
96544
|
+
: feeData.maxFeePerGas;
|
|
96545
|
+
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
96546
|
+
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
96547
|
+
: feeData.maxPriorityFeePerGas;
|
|
96548
|
+
const payload = [
|
|
96549
|
+
userId.bigInt().toString(),
|
|
96550
|
+
oldUserState.bigInt().toString(),
|
|
96551
|
+
newUserState.bigInt().toString(),
|
|
96552
|
+
isOldStateGenesis,
|
|
96553
|
+
methodId,
|
|
96554
|
+
methodParams //'0x'
|
|
96555
|
+
];
|
|
96556
|
+
const gasLimit = await contract.transitStateGeneric.estimateGas(...payload);
|
|
96557
|
+
const txData = await contract.transitStateGeneric.populateTransaction(...payload);
|
|
96558
|
+
const request = {
|
|
96559
|
+
to: txData.to,
|
|
96560
|
+
data: txData.data,
|
|
96561
|
+
gasLimit,
|
|
96562
|
+
maxFeePerGas,
|
|
96563
|
+
maxPriorityFeePerGas
|
|
96564
|
+
};
|
|
96565
|
+
const { txnHash } = await this._transactionService.sendTransactionRequest(signer, request);
|
|
96566
|
+
return txnHash;
|
|
96567
|
+
}
|
|
96568
|
+
/** {@inheritdoc IStateStorage.getGISTProof} */
|
|
96569
|
+
async getGISTProof(id) {
|
|
96570
|
+
const cacheKey = this.getGistProofCacheKey(id);
|
|
96571
|
+
if (!this._disableCache) {
|
|
96572
|
+
// Check cache first
|
|
96573
|
+
const cachedResult = await this._gistProofResolveCache?.get(cacheKey);
|
|
96574
|
+
if (cachedResult) {
|
|
96575
|
+
return cachedResult;
|
|
96576
|
+
}
|
|
96577
|
+
}
|
|
96578
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
96579
|
+
const data = await stateContract.getGISTProof(id);
|
|
96580
|
+
const stateProof = {
|
|
96581
|
+
root: BigInt(data.root.toString()),
|
|
96582
|
+
existence: data.existence,
|
|
96583
|
+
siblings: data.siblings?.map((sibling) => BigInt(sibling.toString())),
|
|
96584
|
+
index: BigInt(data.index.toString()),
|
|
96585
|
+
value: BigInt(data.value.toString()),
|
|
96586
|
+
auxExistence: data.auxExistence,
|
|
96587
|
+
auxIndex: BigInt(data.auxIndex.toString()),
|
|
96588
|
+
auxValue: BigInt(data.auxValue.toString())
|
|
96589
|
+
};
|
|
96590
|
+
!this._disableCache &&
|
|
96591
|
+
(await this._gistProofResolveCache?.set(cacheKey, stateProof, this._gistProofCacheOptions.ttl));
|
|
96592
|
+
return stateProof;
|
|
96593
|
+
}
|
|
96594
|
+
/** {@inheritdoc IStateStorage.getGISTRootInfo} */
|
|
96595
|
+
async getGISTRootInfo(root, id) {
|
|
96596
|
+
const cacheKey = this.getRootCacheKey(root);
|
|
96597
|
+
if (!this._disableCache) {
|
|
96598
|
+
// Check cache first
|
|
96599
|
+
const cachedResult = await this._rootResolveCache?.get(cacheKey);
|
|
96600
|
+
if (cachedResult) {
|
|
96601
|
+
return cachedResult;
|
|
96602
|
+
}
|
|
96603
|
+
}
|
|
96604
|
+
const { stateContract } = this.getStateContractAndProviderForId(id);
|
|
96605
|
+
const data = await stateContract.getGISTRootInfo(root);
|
|
96606
|
+
const rootInfo = {
|
|
96607
|
+
root: BigInt(data.root.toString()),
|
|
96608
|
+
replacedByRoot: BigInt(data.replacedByRoot.toString()),
|
|
96609
|
+
createdAtTimestamp: BigInt(data.createdAtTimestamp.toString()),
|
|
96610
|
+
replacedAtTimestamp: BigInt(data.replacedAtTimestamp.toString()),
|
|
96611
|
+
createdAtBlock: BigInt(data.createdAtBlock.toString()),
|
|
96612
|
+
replacedAtBlock: BigInt(data.replacedAtBlock.toString())
|
|
96613
|
+
};
|
|
96614
|
+
const ttl = rootInfo.replacedAtTimestamp == 0n
|
|
96615
|
+
? this._rootCacheOptions.notReplacedTtl
|
|
96616
|
+
: this._rootCacheOptions.replacedTtl;
|
|
96617
|
+
!this._disableCache && (await this._rootResolveCache?.set(cacheKey, rootInfo, ttl));
|
|
96618
|
+
return rootInfo;
|
|
96619
|
+
}
|
|
96620
|
+
/** {@inheritdoc IStateStorage.getRpcProvider} */
|
|
96621
|
+
getRpcProvider() {
|
|
96622
|
+
return this.provider;
|
|
96623
|
+
}
|
|
96624
|
+
/** enable caching */
|
|
96625
|
+
enableCache() {
|
|
96626
|
+
this._disableCache = false;
|
|
96627
|
+
}
|
|
96628
|
+
/** disable caching */
|
|
96629
|
+
disableCache() {
|
|
96630
|
+
this._disableCache = true;
|
|
96631
|
+
}
|
|
96632
|
+
getStateContractAndProviderForId(id) {
|
|
96633
|
+
const idTyped = Id.fromBigInt(id);
|
|
96634
|
+
const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped));
|
|
96635
|
+
const config = this.networkByChainId(chainId);
|
|
96636
|
+
const provider = new JsonRpcProvider(config.url);
|
|
96637
|
+
const stateContract = new Contract(config.contractAddress, abi$3, provider);
|
|
96638
|
+
return { stateContract, provider };
|
|
96639
|
+
}
|
|
96640
|
+
networkByChainId(chainId) {
|
|
96641
|
+
const config = Array.isArray(this.ethConfig) ? this.ethConfig : [this.ethConfig];
|
|
96642
|
+
const network = config.find((c) => c.chainId === chainId);
|
|
96643
|
+
if (!network) {
|
|
96644
|
+
throw new Error(`chainId "${chainId}" not supported`);
|
|
96645
|
+
}
|
|
96646
|
+
return network;
|
|
96647
|
+
}
|
|
96648
|
+
getGistProofCacheKey(id) {
|
|
96649
|
+
return `gist-${id.toString()}`;
|
|
96650
|
+
}
|
|
96651
|
+
getLatestStateCacheKey(id) {
|
|
96652
|
+
return `latest-${id.toString()}`;
|
|
96653
|
+
}
|
|
96654
|
+
getStateCacheKey(id, state) {
|
|
96655
|
+
return `${id.toString()}-${state.toString()}`;
|
|
96656
|
+
}
|
|
96657
|
+
getRootCacheKey(root) {
|
|
96658
|
+
return root.toString();
|
|
96659
|
+
}
|
|
96660
|
+
}
|
|
96661
|
+
|
|
95953
96662
|
var abi$1 = [
|
|
95954
96663
|
{
|
|
95955
96664
|
inputs: [
|
|
@@ -97285,7 +97994,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
97285
97994
|
},
|
|
97286
97995
|
{
|
|
97287
97996
|
internalType: "address",
|
|
97288
|
-
name: "
|
|
97997
|
+
name: "creator",
|
|
97289
97998
|
type: "address"
|
|
97290
97999
|
}
|
|
97291
98000
|
],
|
|
@@ -100449,21 +101158,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
100449
101158
|
return erc20Contract.decimals();
|
|
100450
101159
|
}
|
|
100451
101160
|
|
|
100452
|
-
/**
|
|
100453
|
-
* Type of MerkleTree
|
|
100454
|
-
*
|
|
100455
|
-
* @enum {number}
|
|
100456
|
-
*/
|
|
100457
|
-
exports.MerkleTreeType = void 0;
|
|
100458
|
-
(function (MerkleTreeType) {
|
|
100459
|
-
// Claims is merkle tree type for claims tree
|
|
100460
|
-
MerkleTreeType[MerkleTreeType["Claims"] = 0] = "Claims";
|
|
100461
|
-
// Revocations is merkle tree type for revocations tree
|
|
100462
|
-
MerkleTreeType[MerkleTreeType["Revocations"] = 1] = "Revocations";
|
|
100463
|
-
// Roots is merkle tree type for roots tree
|
|
100464
|
-
MerkleTreeType[MerkleTreeType["Roots"] = 2] = "Roots";
|
|
100465
|
-
})(exports.MerkleTreeType || (exports.MerkleTreeType = {}));
|
|
100466
|
-
|
|
100467
101161
|
/**
|
|
100468
101162
|
* search errors
|
|
100469
101163
|
*
|
|
@@ -100734,136 +101428,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
100734
101428
|
? exports.SupportedDataFormat.Boolean
|
|
100735
101429
|
: exports.SupportedDataFormat.String;
|
|
100736
101430
|
|
|
100737
|
-
const MERKLE_TREE_TYPES = [
|
|
100738
|
-
exports.MerkleTreeType.Claims,
|
|
100739
|
-
exports.MerkleTreeType.Revocations,
|
|
100740
|
-
exports.MerkleTreeType.Roots
|
|
100741
|
-
];
|
|
100742
|
-
const createMerkleTreeMetaInfo = (identifier) => {
|
|
100743
|
-
const treesMeta = [];
|
|
100744
|
-
for (let index = 0; index < MERKLE_TREE_TYPES.length; index++) {
|
|
100745
|
-
const mType = MERKLE_TREE_TYPES[index];
|
|
100746
|
-
const treeId = `${identifier}+${mType}`;
|
|
100747
|
-
treesMeta.push({ treeId, identifier, type: mType });
|
|
100748
|
-
}
|
|
100749
|
-
return treesMeta;
|
|
100750
|
-
};
|
|
100751
|
-
|
|
100752
|
-
/**
|
|
100753
|
-
*
|
|
100754
|
-
*
|
|
100755
|
-
* @public
|
|
100756
|
-
* @class InMemoryMerkleTreeStorage
|
|
100757
|
-
* @implements implements IMerkleTreeStorage interface
|
|
100758
|
-
*/
|
|
100759
|
-
class InMemoryMerkleTreeStorage {
|
|
100760
|
-
/**
|
|
100761
|
-
* Creates an instance of InMemoryMerkleTreeStorage.
|
|
100762
|
-
* @param {number} _mtDepth
|
|
100763
|
-
*/
|
|
100764
|
-
constructor(_mtDepth) {
|
|
100765
|
-
this.mtDepth = _mtDepth;
|
|
100766
|
-
this._data = {};
|
|
100767
|
-
}
|
|
100768
|
-
/** create trees in the memory*/
|
|
100769
|
-
async createIdentityMerkleTrees(identifier) {
|
|
100770
|
-
if (!identifier) {
|
|
100771
|
-
identifier = `${v4()}`;
|
|
100772
|
-
}
|
|
100773
|
-
if (this._data[identifier]) {
|
|
100774
|
-
throw new Error(`Present merkle tree meta information in the store for current identifier ${identifier}`);
|
|
100775
|
-
}
|
|
100776
|
-
this._data[identifier] = [];
|
|
100777
|
-
const treesMeta = [];
|
|
100778
|
-
MERKLE_TREE_TYPES.forEach((t) => {
|
|
100779
|
-
const treeId = identifier.concat('+' + t.toString());
|
|
100780
|
-
const tree = new Merkletree(new InMemoryDB(str2Bytes(treeId)), true, this.mtDepth);
|
|
100781
|
-
const metaInfo = { treeId, identifier: identifier, type: t };
|
|
100782
|
-
this._data[identifier].push({ tree, metaInfo });
|
|
100783
|
-
treesMeta.push(metaInfo);
|
|
100784
|
-
});
|
|
100785
|
-
return treesMeta;
|
|
100786
|
-
}
|
|
100787
|
-
/** get trees meta info from the memory */
|
|
100788
|
-
async getIdentityMerkleTreesInfo(identifier) {
|
|
100789
|
-
return this._data[identifier].map((treeWithInfo) => treeWithInfo.metaInfo);
|
|
100790
|
-
}
|
|
100791
|
-
/** get merkle tree by identifier and type from memory */
|
|
100792
|
-
async getMerkleTreeByIdentifierAndType(identifier, mtType) {
|
|
100793
|
-
const treeWithMeta = this._data[identifier].find((treeWithInfo) => treeWithInfo.metaInfo.type == mtType);
|
|
100794
|
-
if (!treeWithMeta) {
|
|
100795
|
-
throw new Error(`Merkle tree not found for identifier ${identifier} and type ${mtType}`);
|
|
100796
|
-
}
|
|
100797
|
-
return treeWithMeta.tree;
|
|
100798
|
-
}
|
|
100799
|
-
/** adds entry to merkle tree in the memory */
|
|
100800
|
-
async addToMerkleTree(identifier, mtType, hindex, hvalue) {
|
|
100801
|
-
for (let index = 0; index < this._data[identifier].length; index++) {
|
|
100802
|
-
if (this._data[identifier][index].metaInfo.type === mtType) {
|
|
100803
|
-
await this._data[identifier][index].tree.add(hindex, hvalue);
|
|
100804
|
-
}
|
|
100805
|
-
}
|
|
100806
|
-
}
|
|
100807
|
-
/** bind merkle tree identifier in memory */
|
|
100808
|
-
async bindMerkleTreeToNewIdentifier(oldIdentifier, newIdentifier) {
|
|
100809
|
-
this._data[newIdentifier] = [...this._data[oldIdentifier]];
|
|
100810
|
-
delete this._data[oldIdentifier];
|
|
100811
|
-
this._data[newIdentifier].forEach((treeWithMeta) => {
|
|
100812
|
-
treeWithMeta.metaInfo.identifier = newIdentifier;
|
|
100813
|
-
});
|
|
100814
|
-
}
|
|
100815
|
-
}
|
|
100816
|
-
|
|
100817
|
-
/**
|
|
100818
|
-
* Storage Errors definition
|
|
100819
|
-
*
|
|
100820
|
-
* @enum {number}
|
|
100821
|
-
*/
|
|
100822
|
-
var StorageErrors;
|
|
100823
|
-
(function (StorageErrors) {
|
|
100824
|
-
StorageErrors["ItemNotFound"] = "item not found";
|
|
100825
|
-
})(StorageErrors || (StorageErrors = {}));
|
|
100826
|
-
|
|
100827
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
100828
|
-
/**
|
|
100829
|
-
* Generic Memory Data Source
|
|
100830
|
-
*
|
|
100831
|
-
* @public
|
|
100832
|
-
* @class InMemoryDataSource - class
|
|
100833
|
-
* @template Type
|
|
100834
|
-
*/
|
|
100835
|
-
class InMemoryDataSource {
|
|
100836
|
-
constructor() {
|
|
100837
|
-
this._data = [];
|
|
100838
|
-
}
|
|
100839
|
-
/** saves in the memory */
|
|
100840
|
-
async save(key, value, keyName = 'id') {
|
|
100841
|
-
const itemIndex = this._data.findIndex((i) => i[keyName] === key);
|
|
100842
|
-
if (itemIndex === -1) {
|
|
100843
|
-
this._data.push(value);
|
|
100844
|
-
}
|
|
100845
|
-
else {
|
|
100846
|
-
this._data[itemIndex] = value;
|
|
100847
|
-
}
|
|
100848
|
-
}
|
|
100849
|
-
/** gets value from from the memory */
|
|
100850
|
-
async get(key, keyName = 'id') {
|
|
100851
|
-
return this._data.find((t) => t[keyName] === key);
|
|
100852
|
-
}
|
|
100853
|
-
/** loads from value from the memory */
|
|
100854
|
-
async load() {
|
|
100855
|
-
return this._data;
|
|
100856
|
-
}
|
|
100857
|
-
/** deletes from value from the memory */
|
|
100858
|
-
async delete(key, keyName = 'id') {
|
|
100859
|
-
const newData = this._data.filter((i) => i[keyName] !== key);
|
|
100860
|
-
if (newData.length === this._data.length) {
|
|
100861
|
-
throw new Error(`${StorageErrors.ItemNotFound} to delete: ${key}`);
|
|
100862
|
-
}
|
|
100863
|
-
this._data = newData;
|
|
100864
|
-
}
|
|
100865
|
-
}
|
|
100866
|
-
|
|
100867
101431
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
100868
101432
|
/**
|
|
100869
101433
|
* Storage in the browser, uses local storage
|
|
@@ -101315,9 +101879,16 @@ var PolygonIdSdk = (function (exports) {
|
|
|
101315
101879
|
await this._profileDataSource.save(element.id, element);
|
|
101316
101880
|
}
|
|
101317
101881
|
}
|
|
101882
|
+
/**
|
|
101883
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
101884
|
+
* Use getProfilesByVerifier instead.
|
|
101885
|
+
*/
|
|
101318
101886
|
async getProfileByVerifier(verifier) {
|
|
101319
101887
|
return this._profileDataSource.get(verifier, 'verifier');
|
|
101320
101888
|
}
|
|
101889
|
+
async getProfilesByVerifier(verifier, tags) {
|
|
101890
|
+
return (await this._profileDataSource.load()).filter((p) => p.verifier === verifier && (!tags || tags.every((tag) => p.tags?.includes(tag))));
|
|
101891
|
+
}
|
|
101321
101892
|
async getProfileById(profileId) {
|
|
101322
101893
|
return this._profileDataSource.get(profileId);
|
|
101323
101894
|
}
|
|
@@ -102524,6 +103095,26 @@ var PolygonIdSdk = (function (exports) {
|
|
|
102524
103095
|
}
|
|
102525
103096
|
return await value.mtEntry();
|
|
102526
103097
|
};
|
|
103098
|
+
function calculateGroupId(requestIds) {
|
|
103099
|
+
const types = Array(requestIds.length).fill('uint256');
|
|
103100
|
+
const groupID = BigInt(keccak256(solidityPacked(types, requestIds))) &
|
|
103101
|
+
// It should fit in a field number in the circuit (max 253 bits). With this we truncate to 252 bits for the group ID
|
|
103102
|
+
BigInt('0x0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
|
|
103103
|
+
return groupID;
|
|
103104
|
+
}
|
|
103105
|
+
function calculateRequestId(requestParams, creatorAddress) {
|
|
103106
|
+
// 0x0000000000000000FFFF...FF. Reserved first 8 bytes for the request Id type and future use
|
|
103107
|
+
// 0x00010000000000000000...00. First 2 bytes for the request Id type
|
|
103108
|
+
// - 0x0000... for old request Ids with uint64
|
|
103109
|
+
// - 0x0001... for new request Ids with uint256
|
|
103110
|
+
const requestId = (BigInt(keccak256(solidityPacked(['bytes', 'address'], [requestParams, creatorAddress]))) &
|
|
103111
|
+
BigInt('0x0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) +
|
|
103112
|
+
BigInt('0x0001000000000000000000000000000000000000000000000000000000000000');
|
|
103113
|
+
return requestId;
|
|
103114
|
+
}
|
|
103115
|
+
function calculateMultiRequestId(requestIds, groupIds, creatorAddress) {
|
|
103116
|
+
return BigInt(keccak256(solidityPacked(['uint256[]', 'uint256[]', 'address'], [requestIds, groupIds, creatorAddress])));
|
|
103117
|
+
}
|
|
102527
103118
|
|
|
102528
103119
|
function calculateQueryHashV2(values, schema, slotIndex, operator, claimPathKey, claimPathNotExists) {
|
|
102529
103120
|
const expValue = prepareCircuitArrayValues(values, 64);
|
|
@@ -103057,7 +103648,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103057
103648
|
credentialWithRevStatus = { cred: opts.credential, revStatus };
|
|
103058
103649
|
}
|
|
103059
103650
|
if (!credentialWithRevStatus.cred) {
|
|
103060
|
-
throw new Error(
|
|
103651
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY +
|
|
103652
|
+
` ${JSON.stringify(proofReq.query)}`);
|
|
103061
103653
|
}
|
|
103062
103654
|
const credentialCoreClaim = await this._identityWallet.getCoreClaimFromCredential(credentialWithRevStatus.cred);
|
|
103063
103655
|
const { nonce: authProfileNonce, genesisDID } = await this._identityWallet.getGenesisDIDMetadata(identifier);
|
|
@@ -103069,11 +103661,11 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103069
103661
|
const subjectDID = DID.parse(preparedCredential.credential.credentialSubject['id']);
|
|
103070
103662
|
const { nonce: credentialSubjectProfileNonce, genesisDID: subjectGenesisDID } = await this._identityWallet.getGenesisDIDMetadata(subjectDID);
|
|
103071
103663
|
if (subjectGenesisDID.string() !== genesisDID.string()) {
|
|
103072
|
-
throw new Error(
|
|
103664
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH);
|
|
103073
103665
|
}
|
|
103074
103666
|
const propertiesMetadata = parseCredentialSubject(proofReq.query.credentialSubject);
|
|
103075
103667
|
if (!propertiesMetadata.length) {
|
|
103076
|
-
throw new Error(
|
|
103668
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST);
|
|
103077
103669
|
}
|
|
103078
103670
|
const mtPosition = preparedCredential.credentialCoreClaim.getMerklizedPosition();
|
|
103079
103671
|
let mk;
|
|
@@ -103257,7 +103849,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103257
103849
|
async findCredentialByProofQuery(did, query) {
|
|
103258
103850
|
const credentials = await this._identityWallet.findOwnedCredentialsByDID(did, query);
|
|
103259
103851
|
if (!credentials.length) {
|
|
103260
|
-
throw new Error(
|
|
103852
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE);
|
|
103261
103853
|
}
|
|
103262
103854
|
// For EQ / IN / NIN / LT / GT operations selective if credential satisfies query - we can get any.
|
|
103263
103855
|
// TODO: choose credential for selective credentials
|
|
@@ -103456,7 +104048,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103456
104048
|
let credential;
|
|
103457
104049
|
const ethSigner = opts.ethSigner;
|
|
103458
104050
|
if (opts.createBjjCredential && !ethSigner) {
|
|
103459
|
-
throw new Error(
|
|
104051
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_SIGNER_IS_REQUIRED);
|
|
103460
104052
|
}
|
|
103461
104053
|
const currentState = ZERO_HASH; // In Ethereum identities we don't have an initial state with the auth credential
|
|
103462
104054
|
const didType = buildDIDType(opts.method || DidMethod.Iden3, opts.blockchain || Blockchain.Polygon, opts.networkId || NetworkId.Amoy);
|
|
@@ -103494,23 +104086,28 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103494
104086
|
}
|
|
103495
104087
|
const profile = await this._storage.identity.getProfileById(did.string());
|
|
103496
104088
|
if (!profile) {
|
|
103497
|
-
throw new Error(
|
|
104089
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROFILE_OR_IDENTITY_NOT_FOUND);
|
|
103498
104090
|
}
|
|
103499
104091
|
return { nonce: profile.nonce, genesisDID: DID.parse(profile.genesisIdentifier) };
|
|
103500
104092
|
}
|
|
103501
104093
|
/** {@inheritDoc IIdentityWallet.createProfile} */
|
|
103502
|
-
async createProfile(did, nonce, verifier) {
|
|
104094
|
+
async createProfile(did, nonce, verifier, tags) {
|
|
103503
104095
|
const profileDID = generateProfileDID(did, nonce);
|
|
103504
104096
|
const identityProfiles = await this._storage.identity.getProfilesByGenesisIdentifier(did.string());
|
|
103505
|
-
const
|
|
103506
|
-
if (
|
|
103507
|
-
throw new Error(
|
|
104097
|
+
const profilesForTagAndVerifier = await this._storage.identity.getProfilesByVerifier(verifier, tags);
|
|
104098
|
+
if (profilesForTagAndVerifier.length) {
|
|
104099
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROFILE_ALREADY_EXISTS_VERIFIER_TAGS);
|
|
104100
|
+
}
|
|
104101
|
+
const existingProfileWithNonce = identityProfiles.find((p) => p.nonce == nonce);
|
|
104102
|
+
if (existingProfileWithNonce) {
|
|
104103
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROFILE_ALREADY_EXISTS);
|
|
103508
104104
|
}
|
|
103509
104105
|
await this._storage.identity.saveProfile({
|
|
103510
104106
|
id: profileDID.string(),
|
|
103511
104107
|
nonce,
|
|
103512
104108
|
genesisIdentifier: did.string(),
|
|
103513
|
-
verifier
|
|
104109
|
+
verifier,
|
|
104110
|
+
tags
|
|
103514
104111
|
});
|
|
103515
104112
|
return profileDID;
|
|
103516
104113
|
}
|
|
@@ -103529,9 +104126,17 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103529
104126
|
const key = await this._kms.createKeyFromSeed(keyType, N$2(32));
|
|
103530
104127
|
return key;
|
|
103531
104128
|
}
|
|
104129
|
+
/**
|
|
104130
|
+
* @deprecated The method should not be used. It returns only one profile per verifier, which can potentially restrict business use cases
|
|
104131
|
+
* {@inheritDoc IIdentityWallet.getProfileByVerifier}
|
|
104132
|
+
*/
|
|
103532
104133
|
async getProfileByVerifier(verifier) {
|
|
103533
104134
|
return this._storage.identity.getProfileByVerifier(verifier);
|
|
103534
104135
|
}
|
|
104136
|
+
/** {@inheritDoc IIdentityWallet.getProfilesByVerifier} */
|
|
104137
|
+
async getProfilesByVerifier(verifier, tags) {
|
|
104138
|
+
return this._storage.identity.getProfilesByVerifier(verifier, tags);
|
|
104139
|
+
}
|
|
103535
104140
|
/** {@inheritDoc IIdentityWallet.getDIDTreeModel} */
|
|
103536
104141
|
async getDIDTreeModel(did) {
|
|
103537
104142
|
const didStr = did.string();
|
|
@@ -103653,11 +104258,11 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103653
104258
|
const coreClaimHash = z$2.hash([hi, hv]);
|
|
103654
104259
|
const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
|
|
103655
104260
|
if (!issuerAuthBJJCredential.proof) {
|
|
103656
|
-
throw new Error(
|
|
104261
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_ANY_PROOF);
|
|
103657
104262
|
}
|
|
103658
104263
|
const mtpAuthBJJProof = issuerAuthBJJCredential.getIden3SparseMerkleTreeProof();
|
|
103659
104264
|
if (!mtpAuthBJJProof) {
|
|
103660
|
-
throw new Error(
|
|
104265
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_ISSUER_AUTH_BJJ_CRED_MUST_HAVE_MTP_PROOF);
|
|
103661
104266
|
}
|
|
103662
104267
|
const sigProof = new BJJSignatureProof2021({
|
|
103663
104268
|
issuerData: {
|
|
@@ -103697,7 +104302,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103697
104302
|
const issuerTree = await this.getDIDTreeModel(issuerDID);
|
|
103698
104303
|
const coreClaim = await this.getCoreClaimFromCredential(credential);
|
|
103699
104304
|
if (!coreClaim) {
|
|
103700
|
-
throw new Error(
|
|
104305
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_REQUIRED_IN_ANY_PROOF);
|
|
103701
104306
|
}
|
|
103702
104307
|
const nonce = coreClaim.getRevocationNonce();
|
|
103703
104308
|
await issuerTree.revocationTree.add(nonce, BigInt(0));
|
|
@@ -103720,7 +104325,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103720
104325
|
// credential must have a bjj signature proof
|
|
103721
104326
|
const coreClaim = credential.getCoreClaimFromProof(exports.ProofType.BJJSignature);
|
|
103722
104327
|
if (!coreClaim) {
|
|
103723
|
-
throw new Error(
|
|
104328
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF);
|
|
103724
104329
|
}
|
|
103725
104330
|
await this._storage.mt.addToMerkleTree(issuerDID.string(), exports.MerkleTreeType.Claims, coreClaim.hIndex(), coreClaim.hValue());
|
|
103726
104331
|
}
|
|
@@ -103752,7 +104357,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103752
104357
|
const coreClaim = credential.getCoreClaimFromProof(exports.ProofType.BJJSignature) ||
|
|
103753
104358
|
(await credential.toCoreClaim(opts));
|
|
103754
104359
|
if (!coreClaim) {
|
|
103755
|
-
throw new Error(
|
|
104360
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_REQUIRED_IN_SIG_PROOF);
|
|
103756
104361
|
}
|
|
103757
104362
|
const mtpWithProof = await this.generateCoreClaimMtp(issuerDID, coreClaim, treeState);
|
|
103758
104363
|
const mtpProof = new Iden3SparseMerkleTreeProof({
|
|
@@ -103820,10 +104425,10 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103820
104425
|
if (coreClaimFromMtpProof &&
|
|
103821
104426
|
coreClaimFromSigProof &&
|
|
103822
104427
|
coreClaimFromMtpProof.hex() !== coreClaimFromSigProof.hex()) {
|
|
103823
|
-
throw new Error(
|
|
104428
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_MISMATCH);
|
|
103824
104429
|
}
|
|
103825
104430
|
if (!coreClaimFromMtpProof && !coreClaimFromSigProof) {
|
|
103826
|
-
throw new Error(
|
|
104431
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_CORE_CLAIM_IS_NOT_SET);
|
|
103827
104432
|
}
|
|
103828
104433
|
//eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103829
104434
|
const coreClaim = coreClaimFromMtpProof ?? coreClaimFromSigProof;
|
|
@@ -103832,7 +104437,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103832
104437
|
async findOwnedCredentialsByDID(did, query) {
|
|
103833
104438
|
const credentials = await this._credentialWallet.findByQuery(query);
|
|
103834
104439
|
if (!credentials.length) {
|
|
103835
|
-
throw new Error(
|
|
104440
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY);
|
|
103836
104441
|
}
|
|
103837
104442
|
const { genesisDID } = await this.getGenesisDIDMetadata(did);
|
|
103838
104443
|
const profiles = await this.getProfilesByDID(genesisDID);
|
|
@@ -103872,7 +104477,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
103872
104477
|
let txId;
|
|
103873
104478
|
if (!isEthIdentity) {
|
|
103874
104479
|
if (!prover) {
|
|
103875
|
-
throw new Error(
|
|
104480
|
+
throw new Error(VerifiableConstants.ERRORS.ID_WALLET_PROVER_IS_REQUIRED);
|
|
103876
104481
|
}
|
|
103877
104482
|
// generate the proof
|
|
103878
104483
|
const authInfo = await this._inputsGenerator.prepareAuthBJJCredential(did, oldTreeState);
|
|
@@ -104019,6 +104624,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
104019
104624
|
exports.CredentialStatusResolverRegistry = CredentialStatusResolverRegistry;
|
|
104020
104625
|
exports.CredentialStorage = CredentialStorage;
|
|
104021
104626
|
exports.CredentialWallet = CredentialWallet;
|
|
104627
|
+
exports.DEFAULT_CACHE_MAX_SIZE = DEFAULT_CACHE_MAX_SIZE;
|
|
104022
104628
|
exports.DIDDocumentJSONSchema = DIDDocumentJSONSchema;
|
|
104023
104629
|
exports.DataPrepareHandlerFunc = DataPrepareHandlerFunc;
|
|
104024
104630
|
exports.DidDocumentCredentialStatusResolver = DidDocumentCredentialStatusResolver;
|
|
@@ -104113,8 +104719,11 @@ var PolygonIdSdk = (function (exports) {
|
|
|
104113
104719
|
exports.cacheLoader = cacheLoader;
|
|
104114
104720
|
exports.calcChallengeAuthV2 = calcChallengeAuthV2;
|
|
104115
104721
|
exports.calculateCoreSchemaHash = calculateCoreSchemaHash;
|
|
104722
|
+
exports.calculateGroupId = calculateGroupId;
|
|
104723
|
+
exports.calculateMultiRequestId = calculateMultiRequestId;
|
|
104116
104724
|
exports.calculateQueryHashV2 = calculateQueryHashV2;
|
|
104117
104725
|
exports.calculateQueryHashV3 = calculateQueryHashV3;
|
|
104726
|
+
exports.calculateRequestId = calculateRequestId;
|
|
104118
104727
|
exports.checkCircuitOperator = checkCircuitOperator;
|
|
104119
104728
|
exports.checkCircuitQueriesLength = checkCircuitQueriesLength;
|
|
104120
104729
|
exports.checkDataInField = checkDataInField;
|
|
@@ -104126,6 +104735,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
104126
104735
|
exports.createAuthorizationRequestWithMessage = createAuthorizationRequestWithMessage;
|
|
104127
104736
|
exports.createDiscoveryFeatureDiscloseMessage = createDiscoveryFeatureDiscloseMessage;
|
|
104128
104737
|
exports.createDiscoveryFeatureQueryMessage = createDiscoveryFeatureQueryMessage;
|
|
104738
|
+
exports.createInMemoryCache = createInMemoryCache;
|
|
104129
104739
|
exports.createPayment = createPayment;
|
|
104130
104740
|
exports.createPaymentRequest = createPaymentRequest;
|
|
104131
104741
|
exports.createProblemReportMessage = createProblemReportMessage;
|