@0xpolygonid/js-sdk 1.8.3 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/esm/index.js +420 -189
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +425 -189
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +8 -25
- package/dist/node/cjs/circuits/atomic-query-v3.js +6 -5
- package/dist/node/cjs/circuits/common.js +1 -1
- package/dist/node/cjs/circuits/comparer.js +24 -3
- package/dist/node/cjs/circuits/linked-multi-query.js +6 -17
- package/dist/node/cjs/circuits/models.js +47 -3
- package/dist/node/cjs/iden3comm/handlers/auth.js +14 -55
- package/dist/node/cjs/iden3comm/handlers/common.js +85 -0
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +6 -25
- package/dist/node/cjs/iden3comm/handlers/index.js +2 -0
- package/dist/node/cjs/iden3comm/handlers/revocation-status.js +119 -0
- package/dist/node/cjs/identity/identity-wallet.js +4 -0
- package/dist/node/cjs/proof/common.js +11 -5
- package/dist/node/cjs/proof/provers/inputs-generator.js +6 -10
- package/dist/node/cjs/proof/verifiers/index.js +1 -0
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +37 -22
- package/dist/node/cjs/proof/verifiers/query-hash.js +40 -0
- package/dist/node/cjs/proof/verifiers/query.js +24 -16
- package/dist/node/cjs/schema-processor/utils.js +2 -2
- package/dist/node/cjs/storage/filters/jsonQuery.js +28 -2
- package/dist/node/cjs/verifiable/core-utils.js +3 -3
- package/dist/node/cjs/verifiable/credential.js +1 -1
- package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +9 -26
- package/dist/node/esm/circuits/atomic-query-v3.js +7 -6
- package/dist/node/esm/circuits/common.js +1 -1
- package/dist/node/esm/circuits/comparer.js +24 -3
- package/dist/node/esm/circuits/linked-multi-query.js +7 -18
- package/dist/node/esm/circuits/models.js +48 -4
- package/dist/node/esm/iden3comm/handlers/auth.js +15 -56
- package/dist/node/esm/iden3comm/handlers/common.js +81 -0
- package/dist/node/esm/iden3comm/handlers/contract-request.js +7 -26
- package/dist/node/esm/iden3comm/handlers/index.js +2 -0
- package/dist/node/esm/iden3comm/handlers/revocation-status.js +92 -0
- package/dist/node/esm/identity/identity-wallet.js +4 -0
- package/dist/node/esm/proof/common.js +12 -6
- package/dist/node/esm/proof/provers/inputs-generator.js +7 -11
- package/dist/node/esm/proof/verifiers/index.js +1 -0
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +41 -26
- package/dist/node/esm/proof/verifiers/query-hash.js +35 -0
- package/dist/node/esm/proof/verifiers/query.js +23 -16
- package/dist/node/esm/schema-processor/utils.js +3 -3
- package/dist/node/esm/storage/filters/jsonQuery.js +28 -2
- package/dist/node/esm/verifiable/core-utils.js +1 -1
- package/dist/node/esm/verifiable/credential.js +2 -2
- package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +4 -8
- package/dist/types/circuits/atomic-query-v3.d.ts +2 -2
- package/dist/types/circuits/common.d.ts +1 -1
- package/dist/types/circuits/comparer.d.ts +4 -0
- package/dist/types/circuits/linked-multi-query.d.ts +0 -1
- package/dist/types/circuits/models.d.ts +7 -4
- package/dist/types/iden3comm/handlers/auth.d.ts +1 -0
- package/dist/types/iden3comm/handlers/common.d.ts +23 -0
- package/dist/types/iden3comm/handlers/contract-request.d.ts +1 -1
- package/dist/types/iden3comm/handlers/index.d.ts +2 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +59 -0
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +1 -0
- package/dist/types/identity/identity-wallet.d.ts +13 -1
- package/dist/types/proof/verifiers/index.d.ts +1 -0
- package/dist/types/proof/verifiers/query-hash.d.ts +3 -0
- package/dist/types/proof/verifiers/query.d.ts +1 -0
- package/dist/types/schema-processor/utils.d.ts +1 -1
- package/dist/types/storage/filters/jsonQuery.d.ts +1 -1
- package/dist/types/verifiable/core-utils.d.ts +1 -1
- package/dist/types/verifiable/credential.d.ts +1 -1
- package/dist/types/verifiable/proof.d.ts +5 -1
- package/package.json +1 -1
|
@@ -28,6 +28,8 @@ export declare enum Operators {
|
|
|
28
28
|
LTE = 7,
|
|
29
29
|
GTE = 8,
|
|
30
30
|
BETWEEN = 9,
|
|
31
|
+
NONBETWEEN = 10,
|
|
32
|
+
EXISTS = 11,
|
|
31
33
|
SD = 16,
|
|
32
34
|
NULLIFY = 17
|
|
33
35
|
}
|
|
@@ -43,6 +45,8 @@ export declare const QueryOperators: {
|
|
|
43
45
|
$lte: Operators;
|
|
44
46
|
$gte: Operators;
|
|
45
47
|
$between: Operators;
|
|
48
|
+
$nonbetween: Operators;
|
|
49
|
+
$exists: Operators;
|
|
46
50
|
$sd: Operators;
|
|
47
51
|
$nullify: Operators;
|
|
48
52
|
};
|
|
@@ -26,7 +26,6 @@ export declare class LinkedMultiQueryPubSignals {
|
|
|
26
26
|
merklized: number;
|
|
27
27
|
operatorOutput: bigint[];
|
|
28
28
|
circuitQueryHash: bigint[];
|
|
29
|
-
enabled: boolean[];
|
|
30
29
|
/**
|
|
31
30
|
* PubSignalsUnmarshal unmarshal linkedMultiQuery10.circom public inputs to LinkedMultiQueryPubSignals
|
|
32
31
|
*
|
|
@@ -40,6 +40,7 @@ export declare class Query {
|
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
42
|
validate(): void;
|
|
43
|
+
validateValueArraySize(maxArrSize: number): void;
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* CircuitID is alias for circuit identifier
|
|
@@ -56,15 +57,15 @@ export declare enum CircuitId {
|
|
|
56
57
|
/**
|
|
57
58
|
* @beta
|
|
58
59
|
*/
|
|
59
|
-
AtomicQueryV3 = "credentialAtomicQueryV3-beta.
|
|
60
|
+
AtomicQueryV3 = "credentialAtomicQueryV3-beta.1",
|
|
60
61
|
/**
|
|
61
62
|
* @beta
|
|
62
63
|
*/
|
|
63
|
-
AtomicQueryV3OnChain = "credentialAtomicQueryV3OnChain-beta.
|
|
64
|
+
AtomicQueryV3OnChain = "credentialAtomicQueryV3OnChain-beta.1",
|
|
64
65
|
/**
|
|
65
66
|
* @beta
|
|
66
67
|
*/
|
|
67
|
-
LinkedMultiQuery10 = "linkedMultiQuery10-beta.
|
|
68
|
+
LinkedMultiQuery10 = "linkedMultiQuery10-beta.1"
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* Claim structure for circuit inputs
|
|
@@ -161,7 +162,9 @@ export declare enum CircuitError {
|
|
|
161
162
|
EmptyGISTProof = "empty GIST merkle tree proof",
|
|
162
163
|
EmptyTreeState = "empty tree state",
|
|
163
164
|
EmptyRequestID = "empty request ID",
|
|
164
|
-
InvalidProofType = "invalid proof type"
|
|
165
|
+
InvalidProofType = "invalid proof type",
|
|
166
|
+
InvalidValuesArrSize = "invalid query Values array size",
|
|
167
|
+
InvalidOperationType = "invalid operation type"
|
|
165
168
|
}
|
|
166
169
|
/**
|
|
167
170
|
* ValueProof represents a Merkle Proof for a value stored as MT
|
|
@@ -99,6 +99,7 @@ export interface AuthHandlerOptions {
|
|
|
99
99
|
export declare class AuthHandler implements IAuthHandler {
|
|
100
100
|
private readonly _packerMgr;
|
|
101
101
|
private readonly _proofService;
|
|
102
|
+
private readonly _supportedCircuits;
|
|
102
103
|
/**
|
|
103
104
|
* Creates an instance of AuthHandler.
|
|
104
105
|
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { JWSPackerParams, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../types';
|
|
2
|
+
import { DID } from '@iden3/js-iden3-core';
|
|
3
|
+
import { IProofService } from '../../proof';
|
|
4
|
+
import { CircuitId } from '../../circuits';
|
|
5
|
+
import { MediaType } from '../constants';
|
|
6
|
+
import { Signer } from 'ethers';
|
|
7
|
+
/**
|
|
8
|
+
* Processes zero knowledge proof requests.
|
|
9
|
+
*
|
|
10
|
+
* @param senderIdentifier - The identifier of the sender.
|
|
11
|
+
* @param requests - An array of zero knowledge proof requests.
|
|
12
|
+
* @param from - The identifier of the sender.
|
|
13
|
+
* @param proofService - The proof service.
|
|
14
|
+
* @param opts - Additional options for processing the requests.
|
|
15
|
+
* @returns A promise that resolves to an array of zero knowledge proof responses.
|
|
16
|
+
*/
|
|
17
|
+
export declare const processZeroKnowledgeProofRequests: (senderIdentifier: DID, requests: ZeroKnowledgeProofRequest[] | undefined, from: DID | undefined, proofService: IProofService, opts: {
|
|
18
|
+
mediaType?: MediaType;
|
|
19
|
+
packerOptions?: JWSPackerParams;
|
|
20
|
+
supportedCircuits: CircuitId[];
|
|
21
|
+
ethSigner?: Signer;
|
|
22
|
+
challenge?: bigint;
|
|
23
|
+
}) => Promise<ZeroKnowledgeProofResponse[]>;
|
|
@@ -46,7 +46,7 @@ export declare class ContractRequestHandler implements IContractRequestHandler {
|
|
|
46
46
|
private readonly _packerMgr;
|
|
47
47
|
private readonly _proofService;
|
|
48
48
|
private readonly _zkpVerifier;
|
|
49
|
-
private readonly
|
|
49
|
+
private readonly _supportedCircuits;
|
|
50
50
|
/**
|
|
51
51
|
* Creates an instance of ContractRequestHandler.
|
|
52
52
|
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MediaType } from '../constants';
|
|
2
|
+
import { IPackageManager, JWSPackerParams, RevocationStatusRequestMessage } from '../types';
|
|
3
|
+
import { DID } from '@iden3/js-iden3-core';
|
|
4
|
+
import { TreeState } from '../../circuits';
|
|
5
|
+
import { IIdentityWallet } from '../../identity';
|
|
6
|
+
/**
|
|
7
|
+
* Interface that allows the processing of the revocation status
|
|
8
|
+
*
|
|
9
|
+
* @interface IRevocationStatusHandler
|
|
10
|
+
*/
|
|
11
|
+
export interface IRevocationStatusHandler {
|
|
12
|
+
/**
|
|
13
|
+
* unpacks revocation status request
|
|
14
|
+
* @param {Uint8Array} request - raw byte message
|
|
15
|
+
* @returns `Promise<RevocationStatusRequestMessage>`
|
|
16
|
+
*/
|
|
17
|
+
parseRevocationStatusRequest(request: Uint8Array): Promise<RevocationStatusRequestMessage>;
|
|
18
|
+
/**
|
|
19
|
+
* handle revocation status request
|
|
20
|
+
* @param {did} did - sender DID
|
|
21
|
+
* @param {Uint8Array} request - raw byte message
|
|
22
|
+
* @param {RevocationStatusHandlerOptions} opts - handler options
|
|
23
|
+
* @returns {Promise<Uint8Array>}` - revocation status response message
|
|
24
|
+
*/
|
|
25
|
+
handleRevocationStatusRequest(did: DID, request: Uint8Array, opts?: RevocationStatusHandlerOptions): Promise<Uint8Array>;
|
|
26
|
+
}
|
|
27
|
+
/** RevocationStatusHandlerOptions represents revocation status handler options */
|
|
28
|
+
export type RevocationStatusHandlerOptions = {
|
|
29
|
+
mediaType: MediaType;
|
|
30
|
+
packerOptions?: JWSPackerParams;
|
|
31
|
+
treeState?: TreeState;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* Allows to process RevocationStatusRequest protocol message
|
|
36
|
+
*
|
|
37
|
+
|
|
38
|
+
* @class RevocationStatusHandler
|
|
39
|
+
* @implements implements IRevocationStatusHandler interface
|
|
40
|
+
*/
|
|
41
|
+
export declare class RevocationStatusHandler implements IRevocationStatusHandler {
|
|
42
|
+
private readonly _packerMgr;
|
|
43
|
+
private readonly _identityWallet;
|
|
44
|
+
/**
|
|
45
|
+
* Creates an instance of RevocationStatusHandler.
|
|
46
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
47
|
+
* @param {IIdentityWallet} _identityWallet - identity wallet
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
constructor(_packerMgr: IPackageManager, _identityWallet: IIdentityWallet);
|
|
51
|
+
/**
|
|
52
|
+
* @inheritdoc IRevocationStatusHandler#parseRevocationStatusRequest
|
|
53
|
+
*/
|
|
54
|
+
parseRevocationStatusRequest(request: Uint8Array): Promise<RevocationStatusRequestMessage>;
|
|
55
|
+
/**
|
|
56
|
+
* @inheritdoc IRevocationStatusHandler#handleRevocationStatusRequest
|
|
57
|
+
*/
|
|
58
|
+
handleRevocationStatusRequest(did: DID, request: Uint8Array, opts?: RevocationStatusHandlerOptions): Promise<Uint8Array>;
|
|
59
|
+
}
|
|
@@ -6,6 +6,7 @@ export type ContractInvokeRequest = {
|
|
|
6
6
|
type: string;
|
|
7
7
|
thid: string;
|
|
8
8
|
body: ContractInvokeRequestBody;
|
|
9
|
+
from?: string;
|
|
9
10
|
};
|
|
10
11
|
/** ContractInvokeRequestBody represents structure of contract invoke request body object */
|
|
11
12
|
export type ContractInvokeRequestBody = {
|
|
@@ -114,7 +114,7 @@ export interface IIdentityWallet {
|
|
|
114
114
|
*/
|
|
115
115
|
generateCredentialMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
|
|
116
116
|
/**
|
|
117
|
-
* Generates proof of credential revocation nonce inclusion / non-inclusion to the given revocation tree
|
|
117
|
+
* Generates proof of credential revocation nonce (with credential as a param) inclusion / non-inclusion to the given revocation tree
|
|
118
118
|
* and its root or to the current root of the Revocation tree in the given Merkle tree storage.
|
|
119
119
|
*
|
|
120
120
|
* @param {DID} did
|
|
@@ -123,6 +123,16 @@ export interface IIdentityWallet {
|
|
|
123
123
|
* @returns `Promise<MerkleTreeProofWithTreeState>` - MerkleTreeProof and TreeState on which proof has been generated
|
|
124
124
|
*/
|
|
125
125
|
generateNonRevocationMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
|
|
126
|
+
/**
|
|
127
|
+
* Generates proof of credential revocation nonce (with revNonce as a param) inclusion / non-inclusion to the given revocation tree
|
|
128
|
+
* and its root or to the current root of the Revocation tree in the given Merkle tree storage.
|
|
129
|
+
*
|
|
130
|
+
* @param {DID} did
|
|
131
|
+
* @param {bigint} revNonce
|
|
132
|
+
* @param {TreeState} [treeState]
|
|
133
|
+
* @returns `Promise<MerkleTreeProofWithTreeState>` - MerkleTreeProof and TreeState on which proof has been generated
|
|
134
|
+
*/
|
|
135
|
+
generateNonRevocationMtpWithNonce(did: DID, revNonce: bigint, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
|
|
126
136
|
/**
|
|
127
137
|
* Signs a payload of arbitrary size with an Auth BJJ Credential that identifies a key for signing.
|
|
128
138
|
*
|
|
@@ -325,6 +335,8 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
325
335
|
generateCredentialMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
|
|
326
336
|
/** {@inheritDoc IIdentityWallet.generateNonRevocationMtp} */
|
|
327
337
|
generateNonRevocationMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
|
|
338
|
+
/** {@inheritDoc IIdentityWallet.generateNonRevocationMtpWithNonce} */
|
|
339
|
+
generateNonRevocationMtpWithNonce(did: DID, revNonce: bigint, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
|
|
328
340
|
/** {@inheritDoc IIdentityWallet.sign} */
|
|
329
341
|
sign(message: Uint8Array, credential: W3CCredential): Promise<Signature>;
|
|
330
342
|
/** {@inheritDoc IIdentityWallet.signChallenge} */
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SchemaHash } from '@iden3/js-iden3-core';
|
|
2
|
+
export declare function calculateQueryHashV2(values: bigint[], schema: SchemaHash, slotIndex: string | number, operator: string | number, claimPathKey: string | number, claimPathNotExists: string | number): bigint;
|
|
3
|
+
export declare function calculateQueryHashV3(values: bigint[], schema: SchemaHash, slotIndex: string | number, operator: string | number, claimPathKey: string | number, valueArraySize: string | number, merklized: string | number, isRevocationChecked: string | number, verifierID: string | number, nullifierSessionID: string | number): bigint;
|
|
@@ -23,3 +23,4 @@ export interface ClaimOutputs {
|
|
|
23
23
|
isRevocationChecked: number;
|
|
24
24
|
}
|
|
25
25
|
export declare function checkQueryRequest(query: ProofQuery, outputs: ClaimOutputs, circuitId: CircuitId, schemaLoader?: DocumentLoader, verifiablePresentation?: JSON, opts?: VerifyOpts): Promise<void>;
|
|
26
|
+
export declare const fieldValueFromVerifiablePresentation: (fieldName: string, verifiablePresentation?: JSON, ldLoader?: DocumentLoader) => Promise<bigint>;
|
|
@@ -32,7 +32,7 @@ export declare function dataFillsSlot(slot: Uint8Array, newData: Uint8Array): bo
|
|
|
32
32
|
export declare function checkDataInField(data: Uint8Array): boolean;
|
|
33
33
|
/**
|
|
34
34
|
*
|
|
35
|
-
* @deprecated The method should not be used. Use
|
|
35
|
+
* @deprecated The method should not be used. Use calculateCoreSchemaHash from verifiable.
|
|
36
36
|
* Calculates schema hash
|
|
37
37
|
*
|
|
38
38
|
* @param {Uint8Array} schemaId
|
|
@@ -9,7 +9,7 @@ export declare enum SearchError {
|
|
|
9
9
|
NotDefinedComparator = "not defined comparator"
|
|
10
10
|
}
|
|
11
11
|
/** allowed operators to search */
|
|
12
|
-
export type FilterOperatorMethod = '$noop' | '$eq' | '$in' | '$nin' | '$gt' | '$lt' | '$ne' | '$gte' | '$lte' | '$sd';
|
|
12
|
+
export type FilterOperatorMethod = '$noop' | '$eq' | '$in' | '$nin' | '$gt' | '$lt' | '$ne' | '$gte' | '$lte' | '$sd' | '$exists' | '$between' | '$nonbetween';
|
|
13
13
|
/** filter function type */
|
|
14
14
|
export type FilterOperatorFunction = (a: any, b: any) => boolean;
|
|
15
15
|
/**
|
|
@@ -81,4 +81,4 @@ export declare const parseCoreClaimSlots: (ldCtx: {
|
|
|
81
81
|
* @param {Uint8Array} schemaId
|
|
82
82
|
* @returns {*} {SchemaHash}
|
|
83
83
|
*/
|
|
84
|
-
export declare const
|
|
84
|
+
export declare const calculateCoreSchemaHash: (schemaId: Uint8Array) => SchemaHash;
|
|
@@ -186,7 +186,11 @@ export interface CredentialStatus {
|
|
|
186
186
|
id: string;
|
|
187
187
|
type: CredentialStatusType;
|
|
188
188
|
revocationNonce?: number;
|
|
189
|
-
statusIssuer?:
|
|
189
|
+
statusIssuer?: {
|
|
190
|
+
id: string;
|
|
191
|
+
type: CredentialStatusType;
|
|
192
|
+
revocationNonce?: number;
|
|
193
|
+
};
|
|
190
194
|
}
|
|
191
195
|
/**
|
|
192
196
|
* RefreshService contains type and id
|