@0xpolygonid/js-sdk 1.9.3 → 1.10.0
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/README.md +10 -3
- package/dist/browser/esm/index.js +25 -17
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +198 -188
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/atomic-query-sig-v2-on-chain.js +4 -4
- package/dist/node/cjs/circuits/state-transition.js +2 -2
- package/dist/node/cjs/identity/identity-wallet.js +1 -1
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +4 -1
- package/dist/node/cjs/proof/verifiers/query.js +16 -9
- package/dist/node/esm/circuits/atomic-query-sig-v2-on-chain.js +4 -4
- package/dist/node/esm/circuits/state-transition.js +3 -3
- package/dist/node/esm/identity/identity-wallet.js +1 -1
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +5 -2
- package/dist/node/esm/proof/verifiers/query.js +14 -9
- package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts +1 -2
- package/dist/types/proof/verifiers/query.d.ts +2 -0
- package/package.json +13 -10
package/README.md
CHANGED
|
@@ -14,7 +14,13 @@ Installation:
|
|
|
14
14
|
npm install @0xpolygonid/js-sdk
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Circuits
|
|
18
|
+
|
|
19
|
+
And place actual circuits to `test/proofs/testdata`
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
curl -LO https://iden3-circuits-bucket.s3.eu-west-1.amazonaws.com/latest.zip
|
|
23
|
+
```
|
|
18
24
|
|
|
19
25
|
## Tests
|
|
20
26
|
|
|
@@ -35,10 +41,11 @@ export RHS_URL="..reverse hash service url"
|
|
|
35
41
|
export IPFS_URL="url for ipfs"
|
|
36
42
|
export STATE_CONTRACT_ADDRESS="state contract address"
|
|
37
43
|
export RHS_CONTRACT_ADDRESS="reverse hash service contract address"
|
|
38
|
-
|
|
39
44
|
```
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
Please see [examples](https://github.com/0xPolygonID/js-sdk-examples) for visit examples information.
|
|
42
49
|
|
|
43
50
|
## Documentation
|
|
44
51
|
|
|
@@ -5,7 +5,7 @@ import { Path, Merklizer, getDocumentLoader } from '@iden3/js-jsonld-merklizatio
|
|
|
5
5
|
import * as jsJsonldMerklization from '@iden3/js-jsonld-merklization';
|
|
6
6
|
export { jsJsonldMerklization as jsonLDMerklizer };
|
|
7
7
|
import { PrivateKey, Hex, base58ToBytes as base58ToBytes$2, base58FromBytes, Signature as Signature$5, PublicKey, poseidon, sha256 as sha256$3, getRandomBytes, Poseidon } from '@iden3/js-crypto';
|
|
8
|
-
import { Hash as Hash$2, Proof, verifyProof, rootFromProof, ZERO_HASH, swapEndianness as swapEndianness$1,
|
|
8
|
+
import { Hash as Hash$2, Proof, verifyProof, rootFromProof, ZERO_HASH, swapEndianness as swapEndianness$1, Merkletree, InMemoryDB, str2Bytes, LocalStorageDB, IndexedDBStorage, testBit, NodeLeaf, NODE_TYPE_LEAF, hashElems } from '@iden3/js-merkletree';
|
|
9
9
|
import { groth16 } from 'snarkjs';
|
|
10
10
|
import { getCurveFromName } from 'ffjavascript';
|
|
11
11
|
import { Token, Header, ProvingMethodAlg, proving } from '@iden3/js-jwz';
|
|
@@ -59183,7 +59183,7 @@ class AtomicQuerySigV2OnChainPubSignals extends BaseConfig {
|
|
|
59183
59183
|
this.circuitQueryHash = BigInt(sVals[fieldIdx]);
|
|
59184
59184
|
fieldIdx++;
|
|
59185
59185
|
// - issuerAuthState
|
|
59186
|
-
this.issuerAuthState =
|
|
59186
|
+
this.issuerAuthState = Hash$2.fromString(sVals[fieldIdx]);
|
|
59187
59187
|
fieldIdx++;
|
|
59188
59188
|
// - requestID
|
|
59189
59189
|
this.requestID = BigInt(sVals[fieldIdx]);
|
|
@@ -59192,7 +59192,7 @@ class AtomicQuerySigV2OnChainPubSignals extends BaseConfig {
|
|
|
59192
59192
|
this.challenge = BigInt(sVals[fieldIdx]);
|
|
59193
59193
|
fieldIdx++;
|
|
59194
59194
|
// - gistRoot
|
|
59195
|
-
this.gistRoot =
|
|
59195
|
+
this.gistRoot = Hash$2.fromString(sVals[fieldIdx]);
|
|
59196
59196
|
fieldIdx++;
|
|
59197
59197
|
// - issuerID
|
|
59198
59198
|
this.issuerID = Id.fromBigInt(BigInt(sVals[fieldIdx]));
|
|
@@ -59201,7 +59201,7 @@ class AtomicQuerySigV2OnChainPubSignals extends BaseConfig {
|
|
|
59201
59201
|
this.isRevocationChecked = parseInt(sVals[fieldIdx]);
|
|
59202
59202
|
fieldIdx++;
|
|
59203
59203
|
// - issuerClaimNonRevState
|
|
59204
|
-
this.issuerClaimNonRevState =
|
|
59204
|
+
this.issuerClaimNonRevState = Hash$2.fromString(sVals[fieldIdx]);
|
|
59205
59205
|
fieldIdx++;
|
|
59206
59206
|
// - timestamp
|
|
59207
59207
|
this.timestamp = parseInt(sVals[fieldIdx]);
|
|
@@ -59373,8 +59373,8 @@ class StateTransitionPubSignals {
|
|
|
59373
59373
|
throw new Error(`invalid number of Output values expected ${fieldLength} got ${sVals.length}`);
|
|
59374
59374
|
}
|
|
59375
59375
|
this.userId = Id.fromBigInt(BigInt(sVals[0]));
|
|
59376
|
-
this.oldUserState =
|
|
59377
|
-
this.newUserState =
|
|
59376
|
+
this.oldUserState = Hash$2.fromString(sVals[1]);
|
|
59377
|
+
this.newUserState = Hash$2.fromString(sVals[2]);
|
|
59378
59378
|
this.isOldStateGenesis = BigInt(sVals[3]) === BigInt(1);
|
|
59379
59379
|
return this;
|
|
59380
59380
|
}
|
|
@@ -63474,7 +63474,7 @@ class IdentityWallet {
|
|
|
63474
63474
|
const tmpIdentifier = opts.seed ? v5(Hex.encode(sha256$3(opts.seed)), nil) : v4();
|
|
63475
63475
|
opts.method = opts.method ?? DidMethod.Iden3;
|
|
63476
63476
|
opts.blockchain = opts.blockchain ?? Blockchain.Polygon;
|
|
63477
|
-
opts.networkId = opts.networkId ?? NetworkId.
|
|
63477
|
+
opts.networkId = opts.networkId ?? NetworkId.Amoy;
|
|
63478
63478
|
await this._storage.mt.createIdentityMerkleTrees(tmpIdentifier);
|
|
63479
63479
|
opts.seed = opts.seed ?? getRandomBytes(32);
|
|
63480
63480
|
const keyId = await this._kms.createKeyFromSeed(KmsKeyType.BabyJubJub, opts.seed);
|
|
@@ -64845,14 +64845,7 @@ async function checkQueryRequest(query, queriesMetadata, ldContext, outputs, cir
|
|
|
64845
64845
|
if (!query.skipClaimRevocationCheck && outputs.isRevocationChecked === 0) {
|
|
64846
64846
|
throw new Error(`check revocation is required`);
|
|
64847
64847
|
}
|
|
64848
|
-
|
|
64849
|
-
if (queriesMetadata.length > circuitValidationData.maxQueriesCount) {
|
|
64850
|
-
throw new Error(`circuit ${circuitId} supports only ${circuitValidator[circuitId].maxQueriesCount} queries`);
|
|
64851
|
-
}
|
|
64852
|
-
const notSupportedOpIndx = queriesMetadata.findIndex((i) => !circuitValidationData.supportedOperations.includes(i.operator));
|
|
64853
|
-
if (notSupportedOpIndx > -1) {
|
|
64854
|
-
throw new Error(`circuit ${circuitId} not support ${queriesMetadata[notSupportedOpIndx].operator} operator`);
|
|
64855
|
-
}
|
|
64848
|
+
checkCircuitQueriesLength(circuitId, queriesMetadata);
|
|
64856
64849
|
// verify timestamp
|
|
64857
64850
|
let acceptedProofGenerationDelay = defaultProofGenerationDelayOpts;
|
|
64858
64851
|
if (opts?.acceptedProofGenerationDelay) {
|
|
@@ -64864,6 +64857,18 @@ async function checkQueryRequest(query, queriesMetadata, ldContext, outputs, cir
|
|
|
64864
64857
|
}
|
|
64865
64858
|
return;
|
|
64866
64859
|
}
|
|
64860
|
+
function checkCircuitQueriesLength(circuitId, queriesMetadata) {
|
|
64861
|
+
const circuitValidationData = circuitValidator[circuitId];
|
|
64862
|
+
if (queriesMetadata.length > circuitValidationData.maxQueriesCount) {
|
|
64863
|
+
throw new Error(`circuit ${circuitId} supports only ${circuitValidator[circuitId].maxQueriesCount} queries`);
|
|
64864
|
+
}
|
|
64865
|
+
}
|
|
64866
|
+
function checkCircuitOperator(circuitId, operator) {
|
|
64867
|
+
const circuitValidationData = circuitValidator[circuitId];
|
|
64868
|
+
if (!circuitValidationData.supportedOperations.includes(operator)) {
|
|
64869
|
+
throw new Error(`circuit ${circuitId} not support ${getOperatorNameByValue(operator)} operator`);
|
|
64870
|
+
}
|
|
64871
|
+
}
|
|
64867
64872
|
function verifyFieldValueInclusionV2(outputs, metadata) {
|
|
64868
64873
|
if (outputs.operator == QueryOperators.$noop) {
|
|
64869
64874
|
return;
|
|
@@ -65162,8 +65167,10 @@ class PubSignalsVerifier {
|
|
|
65162
65167
|
const queriesMetadata = await parseQueriesMetadata(query.type, JSON.stringify(context), query.credentialSubject, {
|
|
65163
65168
|
documentLoader: loader
|
|
65164
65169
|
});
|
|
65165
|
-
|
|
65170
|
+
const circuitId = CircuitId.AtomicQueryV3;
|
|
65171
|
+
await checkQueryRequest(query, queriesMetadata, context, outs, circuitId, this._documentLoader, opts);
|
|
65166
65172
|
const queryMetadata = queriesMetadata[0]; // only one query is supported
|
|
65173
|
+
checkCircuitOperator(circuitId, outs.operator);
|
|
65167
65174
|
// validate selective disclosure
|
|
65168
65175
|
if (queryMetadata.operator === Operators.SD) {
|
|
65169
65176
|
try {
|
|
@@ -65383,6 +65390,7 @@ class PubSignalsVerifier {
|
|
|
65383
65390
|
});
|
|
65384
65391
|
await checkQueryRequest(query, queriesMetadata, context, outs, circuitId, this._documentLoader, opts);
|
|
65385
65392
|
const queryMetadata = queriesMetadata[0]; // only one query is supported
|
|
65393
|
+
checkCircuitOperator(circuitId, outs.operator);
|
|
65386
65394
|
// validate selective disclosure
|
|
65387
65395
|
if (queryMetadata.operator === Operators.SD) {
|
|
65388
65396
|
try {
|
|
@@ -66982,5 +66990,5 @@ class RevocationStatusHandler {
|
|
|
66982
66990
|
}
|
|
66983
66991
|
}
|
|
66984
66992
|
|
|
66985
|
-
export { AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DataPrepareHandlerFunc, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, 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, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$2 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, 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, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$2 as hexToBytes, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
|
|
66993
|
+
export { AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DataPrepareHandlerFunc, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, 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, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$2 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, 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, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$2 as hexToBytes, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
|
|
66986
66994
|
//# sourceMappingURL=index.js.map
|