@0xpolygonid/js-sdk 1.7.4 → 1.8.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/dist/browser/esm/index.js +13086 -11852
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +13115 -11861
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/atomic-query-mtp-v2.js +3 -3
- package/dist/node/cjs/circuits/atomic-query-sig-v2.js +3 -3
- package/dist/node/cjs/circuits/atomic-query-v3.js +18 -13
- package/dist/node/cjs/circuits/auth-v2.js +1 -1
- package/dist/node/cjs/circuits/index.js +0 -1
- package/dist/node/cjs/circuits/linked-multi-query.js +16 -6
- package/dist/node/cjs/circuits/models.js +0 -5
- package/dist/node/cjs/credentials/credential-wallet.js +1 -3
- package/dist/node/cjs/credentials/index.js +1 -0
- package/dist/node/cjs/credentials/models.js +2 -0
- package/dist/node/cjs/credentials/status/credential-status-publisher.js +23 -4
- package/dist/node/cjs/iden3comm/constants.js +3 -1
- package/dist/node/cjs/iden3comm/handlers/auth.js +119 -14
- package/dist/node/cjs/kms/key-providers/sec256k1-provider.js +5 -2
- package/dist/node/cjs/proof/common.js +3 -4
- package/dist/node/cjs/proof/index.js +2 -1
- package/dist/node/cjs/proof/proof-service.js +22 -2
- package/dist/node/cjs/proof/provers/index.js +19 -0
- package/dist/node/cjs/proof/{inputs-generator.js → provers/inputs-generator.js} +43 -40
- package/dist/node/cjs/proof/{prover.js → provers/prover.js} +1 -1
- package/dist/node/cjs/proof/verifiers/index.js +18 -0
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +344 -0
- package/dist/node/cjs/proof/verifiers/query.js +190 -0
- package/dist/node/cjs/schema-processor/json/parser.js +39 -198
- package/dist/node/cjs/schema-processor/utils.js +13 -26
- package/dist/node/cjs/storage/blockchain/state.js +53 -8
- package/dist/node/cjs/storage/filters/jsonQuery.js +2 -2
- package/dist/node/cjs/utils/compare-func.js +11 -0
- package/dist/node/cjs/utils/index.js +2 -0
- package/dist/node/cjs/utils/message-bus.js +73 -0
- package/dist/node/cjs/verifiable/core-utils.js +234 -0
- package/dist/node/cjs/verifiable/credential.js +139 -1
- package/dist/node/cjs/verifiable/index.js +1 -0
- package/dist/node/esm/circuits/atomic-query-mtp-v2.js +3 -3
- package/dist/node/esm/circuits/atomic-query-sig-v2.js +3 -3
- package/dist/node/esm/circuits/atomic-query-v3.js +18 -13
- package/dist/node/esm/circuits/auth-v2.js +2 -2
- package/dist/node/esm/circuits/index.js +0 -1
- package/dist/node/esm/circuits/linked-multi-query.js +16 -6
- package/dist/node/esm/circuits/models.js +0 -5
- package/dist/node/esm/credentials/credential-wallet.js +1 -3
- package/dist/node/esm/credentials/index.js +1 -0
- package/dist/node/esm/credentials/models.js +1 -0
- package/dist/node/esm/credentials/status/credential-status-publisher.js +23 -4
- package/dist/node/esm/iden3comm/constants.js +3 -1
- package/dist/node/esm/iden3comm/handlers/auth.js +116 -13
- package/dist/node/esm/kms/key-providers/sec256k1-provider.js +5 -2
- package/dist/node/esm/proof/common.js +4 -5
- package/dist/node/esm/proof/index.js +2 -1
- package/dist/node/esm/proof/proof-service.js +22 -2
- package/dist/node/esm/proof/provers/index.js +3 -0
- package/dist/node/esm/proof/{inputs-generator.js → provers/inputs-generator.js} +40 -37
- package/dist/node/esm/proof/{prover.js → provers/prover.js} +1 -1
- package/dist/node/esm/proof/verifiers/index.js +2 -0
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +340 -0
- package/dist/node/esm/proof/verifiers/query.js +186 -0
- package/dist/node/esm/schema-processor/json/parser.js +40 -199
- package/dist/node/esm/schema-processor/utils.js +13 -26
- package/dist/node/esm/storage/blockchain/state.js +53 -8
- package/dist/node/esm/storage/filters/jsonQuery.js +2 -2
- package/dist/node/esm/utils/compare-func.js +7 -0
- package/dist/node/esm/utils/index.js +2 -0
- package/dist/node/esm/utils/message-bus.js +66 -0
- package/dist/node/esm/verifiable/core-utils.js +200 -0
- package/dist/node/esm/verifiable/credential.js +118 -3
- package/dist/node/esm/verifiable/index.js +1 -0
- package/dist/types/circuits/index.d.ts +0 -1
- package/dist/types/circuits/linked-multi-query.d.ts +3 -3
- package/dist/types/circuits/models.d.ts +0 -4
- package/dist/types/credentials/credential-wallet.d.ts +2 -60
- package/dist/types/credentials/index.d.ts +1 -0
- package/dist/types/credentials/models.d.ts +68 -0
- package/dist/types/credentials/status/credential-status-publisher.d.ts +2 -0
- package/dist/types/iden3comm/constants.d.ts +1 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +53 -13
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +16 -0
- package/dist/types/identity/identity-wallet.d.ts +3 -1
- package/dist/types/kms/key-providers/sec256k1-provider.d.ts +1 -1
- package/dist/types/proof/index.d.ts +2 -1
- package/dist/types/proof/proof-service.d.ts +28 -3
- package/dist/types/proof/provers/index.d.ts +3 -0
- package/dist/types/proof/{inputs-generator.d.ts → provers/inputs-generator.d.ts} +15 -9
- package/dist/types/proof/{prover.d.ts → provers/prover.d.ts} +2 -2
- package/dist/types/proof/verifiers/index.d.ts +2 -0
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +58 -0
- package/dist/types/proof/verifiers/query.d.ts +25 -0
- package/dist/types/schema-processor/json/parser.d.ts +47 -28
- package/dist/types/schema-processor/utils.d.ts +9 -4
- package/dist/types/storage/blockchain/state.d.ts +5 -1
- package/dist/types/storage/interfaces/state.d.ts +8 -0
- package/dist/types/utils/compare-func.d.ts +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/message-bus.d.ts +62 -0
- package/dist/types/verifiable/core-utils.d.ts +84 -0
- package/dist/types/verifiable/credential.d.ts +11 -1
- package/dist/types/verifiable/index.d.ts +1 -0
- package/dist/types/verifiable/proof.d.ts +4 -0
- package/package.json +10 -10
- package/dist/node/cjs/circuits/linked-nullifier.js +0 -57
- package/dist/node/esm/circuits/linked-nullifier.js +0 -52
- package/dist/types/circuits/linked-nullifier.d.ts +0 -37
- /package/dist/node/cjs/proof/{witness_calculator.js → provers/witness_calculator.js} +0 -0
- /package/dist/node/esm/proof/{witness_calculator.js → provers/witness_calculator.js} +0 -0
- /package/dist/types/proof/{witness_calculator.d.ts → provers/witness_calculator.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { W3CCredential } from '../../../verifiable';
|
|
2
2
|
import { MediaType } from '../../constants';
|
|
3
3
|
import { JSONObject, ProtocolMessage } from '../packer';
|
|
4
|
+
import { ContractInvokeTransactionData } from './contract-request';
|
|
4
5
|
/** CredentialIssuanceRequestMessageBody represents data for credential issuance request */
|
|
5
6
|
export type CredentialIssuanceRequestMessageBody = {
|
|
6
7
|
schema: Schema;
|
|
@@ -32,6 +33,21 @@ export type CredentialsOfferMessageBody = {
|
|
|
32
33
|
url: string;
|
|
33
34
|
credentials: Array<CredentialOffer>;
|
|
34
35
|
};
|
|
36
|
+
/** CredentialsOnchainOfferMessage represent Iden3message for credential onhcain offer message */
|
|
37
|
+
export type CredentialsOnchainOfferMessage = {
|
|
38
|
+
id: string;
|
|
39
|
+
typ: MediaType;
|
|
40
|
+
type: ProtocolMessage;
|
|
41
|
+
thid?: string;
|
|
42
|
+
body: CredentialsOnchainOfferMessageBody;
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
};
|
|
46
|
+
/** CredentialsOnchainOfferMessageBody is struct the represents onchain offer message body */
|
|
47
|
+
export type CredentialsOnchainOfferMessageBody = {
|
|
48
|
+
credentials: Array<CredentialOffer>;
|
|
49
|
+
transaction_data: ContractInvokeTransactionData;
|
|
50
|
+
};
|
|
35
51
|
/** CredentialOffer is structure to fetch credential */
|
|
36
52
|
export type CredentialOffer = {
|
|
37
53
|
id: string;
|
|
@@ -3,7 +3,7 @@ import { Claim, DID } from '@iden3/js-iden3-core';
|
|
|
3
3
|
import { Signature } from '@iden3/js-crypto';
|
|
4
4
|
import { IDataStorage, Profile } from '../storage';
|
|
5
5
|
import { W3CCredential, MerkleTreeProofWithTreeState, CredentialStatusType, ProofQuery } from '../verifiable';
|
|
6
|
-
import { CredentialRequest, ICredentialWallet, TreesModel } from '../credentials';
|
|
6
|
+
import { CredentialRequest, ICredentialWallet, PublishMode, TreesModel } from '../credentials';
|
|
7
7
|
import { TreeState } from '../circuits';
|
|
8
8
|
import { Options } from '@iden3/js-jsonld-merklization';
|
|
9
9
|
import { TransactionReceipt } from 'ethers';
|
|
@@ -25,6 +25,7 @@ export type IdentityCreationOptions = {
|
|
|
25
25
|
nonce?: number;
|
|
26
26
|
onChain?: {
|
|
27
27
|
txCallback?: (tx: TransactionReceipt) => Promise<void>;
|
|
28
|
+
publishMode?: PublishMode;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
seed?: Uint8Array;
|
|
@@ -38,6 +39,7 @@ export type RevocationInfoOptions = {
|
|
|
38
39
|
rhsUrl?: string;
|
|
39
40
|
onChain?: {
|
|
40
41
|
txCallback?: (tx: TransactionReceipt) => Promise<void>;
|
|
42
|
+
publishMode?: PublishMode;
|
|
41
43
|
};
|
|
42
44
|
};
|
|
43
45
|
/**
|
|
@@ -25,7 +25,7 @@ export declare class Sec256k1Provider implements IKeyProvider {
|
|
|
25
25
|
* @param {Uint8Array} seed - byte array seed
|
|
26
26
|
* @returns kms key identifier
|
|
27
27
|
*/
|
|
28
|
-
newPrivateKeyFromSeed(): Promise<KmsKeyId>;
|
|
28
|
+
newPrivateKeyFromSeed(seed: Uint8Array): Promise<KmsKeyId>;
|
|
29
29
|
/**
|
|
30
30
|
* Gets public key by kmsKeyId
|
|
31
31
|
*
|
|
@@ -3,25 +3,39 @@ import { CircuitId, Query, TreeState } from '../circuits';
|
|
|
3
3
|
import { ICredentialWallet } from '../credentials';
|
|
4
4
|
import { IIdentityWallet } from '../identity';
|
|
5
5
|
import { ProofQuery, RevocationStatus, W3CCredential } from '../verifiable';
|
|
6
|
-
import { IZKProver } from './prover';
|
|
6
|
+
import { IZKProver } from './provers/prover';
|
|
7
7
|
import { Options } from '@iden3/js-jsonld-merklization';
|
|
8
8
|
import { ZKProof } from '@iden3/js-jwz';
|
|
9
9
|
import { Signer } from 'ethers';
|
|
10
|
-
import { ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../iden3comm';
|
|
10
|
+
import { JSONObject, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../iden3comm';
|
|
11
11
|
import { ICircuitStorage, IStateStorage } from '../storage';
|
|
12
|
-
import { ProofGenerationOptions } from './inputs-generator';
|
|
12
|
+
import { ProofGenerationOptions } from './provers/inputs-generator';
|
|
13
|
+
import { VerifyOpts } from './verifiers';
|
|
13
14
|
export interface QueryWithFieldName {
|
|
14
15
|
query: Query;
|
|
15
16
|
fieldName: string;
|
|
16
17
|
rawValue?: unknown;
|
|
17
18
|
isSelectiveDisclosure?: boolean;
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Metadata that returns on verification
|
|
22
|
+
* @type VerificationResultMetadata
|
|
23
|
+
*/
|
|
24
|
+
export type VerificationResultMetadata = {
|
|
25
|
+
linkID?: number;
|
|
26
|
+
};
|
|
19
27
|
/**
|
|
20
28
|
* List of options to customize ProofService
|
|
21
29
|
*/
|
|
22
30
|
export type ProofServiceOptions = Options & {
|
|
23
31
|
prover?: IZKProver;
|
|
24
32
|
};
|
|
33
|
+
export interface ProofVerifyOpts {
|
|
34
|
+
query: ProofQuery;
|
|
35
|
+
sender: string;
|
|
36
|
+
opts?: VerifyOpts;
|
|
37
|
+
params?: JSONObject;
|
|
38
|
+
}
|
|
25
39
|
export interface IProofService {
|
|
26
40
|
/**
|
|
27
41
|
* Verification of zkp proof for given circuit id
|
|
@@ -31,6 +45,14 @@ export interface IProofService {
|
|
|
31
45
|
* @returns `{Promise<boolean>}`
|
|
32
46
|
*/
|
|
33
47
|
verifyProof(zkp: ZKProof, circuitName: CircuitId): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Verification of zkp proof and pub signals for given circuit id
|
|
50
|
+
*
|
|
51
|
+
* @param {ZeroKnowledgeProofResponse} response - zero knowledge proof response
|
|
52
|
+
* @param {ProofVerifyOpts} opts - proof verification options
|
|
53
|
+
* @returns `{Promise<VerificationResultMetadata>}`
|
|
54
|
+
*/
|
|
55
|
+
verifyZKPResponse(proofResp: ZeroKnowledgeProofResponse, opts: ProofVerifyOpts): Promise<VerificationResultMetadata>;
|
|
34
56
|
/**
|
|
35
57
|
* Generate proof from given identity and credential for protocol proof request
|
|
36
58
|
*
|
|
@@ -95,6 +117,7 @@ export declare class ProofService implements IProofService {
|
|
|
95
117
|
private readonly _prover;
|
|
96
118
|
private readonly _ldOptions;
|
|
97
119
|
private readonly _inputsGenerator;
|
|
120
|
+
private readonly _pubSignalsVerifier;
|
|
98
121
|
/**
|
|
99
122
|
* Creates an instance of ProofService.
|
|
100
123
|
* @param {IIdentityWallet} _identityWallet - identity wallet
|
|
@@ -105,6 +128,8 @@ export declare class ProofService implements IProofService {
|
|
|
105
128
|
constructor(_identityWallet: IIdentityWallet, _credentialWallet: ICredentialWallet, _circuitStorage: ICircuitStorage, _stateStorage: IStateStorage, opts?: ProofServiceOptions);
|
|
106
129
|
/** {@inheritdoc IProofService.verifyProof} */
|
|
107
130
|
verifyProof(zkp: ZKProof, circuitId: CircuitId): Promise<boolean>;
|
|
131
|
+
/** {@inheritdoc IProofService.verify} */
|
|
132
|
+
verifyZKPResponse(proofResp: ZeroKnowledgeProofResponse, opts: ProofVerifyOpts): Promise<VerificationResultMetadata>;
|
|
108
133
|
/** {@inheritdoc IProofService.generateProof} */
|
|
109
134
|
generateProof(proofReq: ZeroKnowledgeProofRequest, identifier: DID, opts?: ProofGenerationOptions): Promise<ZeroKnowledgeProofResponse>;
|
|
110
135
|
/** {@inheritdoc IProofService.transitState} */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DID } from '@iden3/js-iden3-core';
|
|
2
|
-
import { RevocationStatus, W3CCredential } from '
|
|
3
|
-
import { ZeroKnowledgeProofRequest } from '
|
|
4
|
-
import { CircuitClaim, Query, TreeState } from '
|
|
5
|
-
import { PreparedAuthBJJCredential, PreparedCredential } from '
|
|
6
|
-
import { IIdentityWallet } from '
|
|
7
|
-
import { IStateStorage } from '
|
|
8
|
-
import { ICredentialWallet } from '
|
|
2
|
+
import { RevocationStatus, W3CCredential } from '../../verifiable';
|
|
3
|
+
import { ZeroKnowledgeProofRequest } from '../../iden3comm';
|
|
4
|
+
import { CircuitClaim, CircuitId, Operators, Query, TreeState } from '../../circuits';
|
|
5
|
+
import { PreparedAuthBJJCredential, PreparedCredential } from '../common';
|
|
6
|
+
import { IIdentityWallet } from '../../identity';
|
|
7
|
+
import { IStateStorage } from '../../storage';
|
|
8
|
+
import { ICredentialWallet } from '../../credentials';
|
|
9
9
|
export type DIDProfileMetadata = {
|
|
10
10
|
authProfileNonce: number;
|
|
11
11
|
credentialSubjectProfileNonce: number;
|
|
@@ -26,6 +26,12 @@ type InputContext = {
|
|
|
26
26
|
params: ProofInputsParams;
|
|
27
27
|
circuitQueries: Query[];
|
|
28
28
|
};
|
|
29
|
+
export declare const circuitValidator: {
|
|
30
|
+
[k in CircuitId]: {
|
|
31
|
+
maxQueriesCount: number;
|
|
32
|
+
supportedOperations: Operators[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
29
35
|
export declare class InputGenerator {
|
|
30
36
|
private readonly _identityWallet;
|
|
31
37
|
private readonly _credentialWallet;
|
|
@@ -40,7 +46,7 @@ export declare class InputGenerator {
|
|
|
40
46
|
private credentialAtomicQuerySigV2OnChainPrepareInputs;
|
|
41
47
|
private credentialAtomicQueryV3PrepareInputs;
|
|
42
48
|
private credentialAtomicQueryV3OnChainPrepareInputs;
|
|
43
|
-
private
|
|
44
|
-
|
|
49
|
+
private linkedMultiQuery10PrepareInputs;
|
|
50
|
+
private transformV2QueryOperator;
|
|
45
51
|
}
|
|
46
52
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZKProof } from '@iden3/js-jwz';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ICircuitStorage } from '../../storage';
|
|
3
|
+
import { CircuitId } from '../../circuits';
|
|
4
4
|
/**
|
|
5
5
|
* ZKProver is responsible for proof generation and verification
|
|
6
6
|
*
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Id } from '@iden3/js-iden3-core';
|
|
2
|
+
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
|
|
3
|
+
import { JSONObject } from '../../iden3comm';
|
|
4
|
+
import { IStateStorage } from '../../storage';
|
|
5
|
+
import { ProofQuery } from '../../verifiable';
|
|
6
|
+
import { BaseConfig } from '../../circuits/common';
|
|
7
|
+
import { VerifyOpts } from './query';
|
|
8
|
+
/**
|
|
9
|
+
* Verify Context - params for pub signal verification
|
|
10
|
+
* @type VerifyContext
|
|
11
|
+
*/
|
|
12
|
+
export type VerifyContext = {
|
|
13
|
+
pubSignals: string[];
|
|
14
|
+
query: ProofQuery;
|
|
15
|
+
verifiablePresentation?: JSON;
|
|
16
|
+
sender: string;
|
|
17
|
+
challenge: bigint;
|
|
18
|
+
opts?: VerifyOpts;
|
|
19
|
+
params?: JSONObject;
|
|
20
|
+
};
|
|
21
|
+
export declare const userStateError: Error;
|
|
22
|
+
/**
|
|
23
|
+
* PubSignalsVerifier provides verify method
|
|
24
|
+
* @public
|
|
25
|
+
* @class PubSignalsVerifier
|
|
26
|
+
*/
|
|
27
|
+
export declare class PubSignalsVerifier {
|
|
28
|
+
private readonly _documentLoader;
|
|
29
|
+
private readonly _stateStorage;
|
|
30
|
+
userId: Id;
|
|
31
|
+
challenge: bigint;
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instance of PubSignalsVerifier.
|
|
34
|
+
* @param {DocumentLoader} _documentLoader document loader
|
|
35
|
+
* @param {IStateStorage} _stateStorage state storage
|
|
36
|
+
*/
|
|
37
|
+
constructor(_documentLoader: DocumentLoader, _stateStorage: IStateStorage);
|
|
38
|
+
/**
|
|
39
|
+
* verify public signals
|
|
40
|
+
*
|
|
41
|
+
* @param {string} circuitId circuit id
|
|
42
|
+
* @param {VerifyContext} ctx verification parameters
|
|
43
|
+
* @returns `Promise<BaseConfig>`
|
|
44
|
+
*/
|
|
45
|
+
verify(circuitId: string, ctx: VerifyContext): Promise<BaseConfig>;
|
|
46
|
+
private credentialAtomicQueryMTPV2Verify;
|
|
47
|
+
private credentialAtomicQuerySigV2Verify;
|
|
48
|
+
private credentialAtomicQueryV3Verify;
|
|
49
|
+
private authV2Verify;
|
|
50
|
+
private linkedMultiQuery10Verify;
|
|
51
|
+
private verifyIdOwnership;
|
|
52
|
+
private resolve;
|
|
53
|
+
private rootResolve;
|
|
54
|
+
private checkStateExistenceForId;
|
|
55
|
+
private checkGlobalState;
|
|
56
|
+
private checkRevocationStateForId;
|
|
57
|
+
private checkRevocationState;
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Id, SchemaHash } from '@iden3/js-iden3-core';
|
|
2
|
+
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
|
|
3
|
+
import { CircuitId } from '../../circuits/models';
|
|
4
|
+
import { ProofQuery } from '../../verifiable';
|
|
5
|
+
/**
|
|
6
|
+
* Options to verify state
|
|
7
|
+
*/
|
|
8
|
+
export type VerifyOpts = {
|
|
9
|
+
acceptedStateTransitionDelay?: number;
|
|
10
|
+
acceptedProofGenerationDelay?: number;
|
|
11
|
+
};
|
|
12
|
+
export interface ClaimOutputs {
|
|
13
|
+
issuerId: Id;
|
|
14
|
+
schemaHash: SchemaHash;
|
|
15
|
+
slotIndex?: number;
|
|
16
|
+
operator: number;
|
|
17
|
+
value: bigint[];
|
|
18
|
+
timestamp: number;
|
|
19
|
+
merklized: number;
|
|
20
|
+
claimPathKey?: bigint;
|
|
21
|
+
claimPathNotExists?: number;
|
|
22
|
+
valueArraySize: number;
|
|
23
|
+
isRevocationChecked: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function checkQueryRequest(query: ProofQuery, outputs: ClaimOutputs, circuitId: CircuitId, schemaLoader?: DocumentLoader, verifiablePresentation?: JSON, opts?: VerifyOpts): Promise<void>;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { W3CCredential } from '../../verifiable';
|
|
1
|
+
import { W3CCredential, CoreClaimCreationOptions, CoreClaimParsedSlots, CoreClaimSlotsPaths } from '../../verifiable';
|
|
2
2
|
import { Claim as CoreClaim } from '@iden3/js-iden3-core';
|
|
3
3
|
import { Merklizer, Options } from '@iden3/js-jsonld-merklization';
|
|
4
4
|
/**
|
|
5
|
+
*
|
|
6
|
+
* @deprecated The interface should not be used. Use CoreClaimParsingOptions from verifiable package instead.
|
|
7
|
+
* CoreClaimOptions is params for core claim parsing
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @interface CoreClaimOptions
|
|
11
|
+
*/
|
|
12
|
+
export type CoreClaimOptions = CoreClaimCreationOptions;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated The interface should not be used. Use CoreClaimParsedSlots from verifiable package instead.
|
|
5
15
|
* Parsed slots of core.Claim
|
|
6
16
|
*
|
|
7
17
|
* @public
|
|
8
18
|
* @interface ParsedSlots
|
|
9
19
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
interface SlotsPaths {
|
|
17
|
-
indexAPath: string;
|
|
18
|
-
indexBPath: string;
|
|
19
|
-
valueAPath: string;
|
|
20
|
-
valueBPath: string;
|
|
21
|
-
}
|
|
20
|
+
export type ParsedSlots = CoreClaimParsedSlots;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated The interface should not be used. Use CoreClaimSlotsPaths from verifiable package instead.
|
|
23
|
+
*/
|
|
24
|
+
export type SlotsPaths = CoreClaimSlotsPaths;
|
|
22
25
|
/**
|
|
23
26
|
* Serialization of data slots for the fields non-merklized claims
|
|
24
27
|
*
|
|
@@ -54,20 +57,6 @@ export interface JSONSchema {
|
|
|
54
57
|
$schema: string;
|
|
55
58
|
type: string;
|
|
56
59
|
}
|
|
57
|
-
/**
|
|
58
|
-
* CoreClaimOptions is params for core claim parsing
|
|
59
|
-
*
|
|
60
|
-
* @public
|
|
61
|
-
* @interface CoreClaimOptions
|
|
62
|
-
*/
|
|
63
|
-
export interface CoreClaimOptions {
|
|
64
|
-
revNonce: number;
|
|
65
|
-
version: number;
|
|
66
|
-
subjectPosition: string;
|
|
67
|
-
merklizedRootPosition: string;
|
|
68
|
-
updatable: boolean;
|
|
69
|
-
merklizeOpts?: Options;
|
|
70
|
-
}
|
|
71
60
|
/**
|
|
72
61
|
* Parser can parse claim and schema data according to specification
|
|
73
62
|
*
|
|
@@ -76,6 +65,7 @@ export interface CoreClaimOptions {
|
|
|
76
65
|
*/
|
|
77
66
|
export declare class Parser {
|
|
78
67
|
/**
|
|
68
|
+
* @deprecated The method should not be used. Use credential.toCoreClaim instead.
|
|
79
69
|
* ParseClaim creates core.Claim object from W3CCredential
|
|
80
70
|
*
|
|
81
71
|
* @param {W3CCredential} credential - Verifiable Credential
|
|
@@ -83,14 +73,42 @@ export declare class Parser {
|
|
|
83
73
|
* @returns `Promise<CoreClaim>`
|
|
84
74
|
*/
|
|
85
75
|
static parseClaim(credential: W3CCredential, opts?: CoreClaimOptions): Promise<CoreClaim>;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated The method should not be used. Use findCredentialType from verifiable.
|
|
78
|
+
*/
|
|
86
79
|
static findCredentialType(mz: Merklizer): string;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated The method should not be used. Use credential.getSerializationAttr instead.
|
|
82
|
+
*
|
|
83
|
+
* Get `iden3_serialization` attr definition from context document either using
|
|
84
|
+
* type name like DeliverAddressMultiTestForked or by type id like
|
|
85
|
+
* urn:uuid:ac2ede19-b3b9-454d-b1a9-a7b3d5763100.
|
|
86
|
+
* */
|
|
87
87
|
static getSerializationAttr(credential: W3CCredential, opts: Options, tp: string): Promise<string>;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated The method should not be used. Use getSerializationAttrFromContext from verifiable.
|
|
90
|
+
*
|
|
91
|
+
* Get `iden3_serialization` attr definition from context document either using
|
|
92
|
+
* type name like DeliverAddressMultiTestForked or by type id like
|
|
93
|
+
* urn:uuid:ac2ede19-b3b9-454d-b1a9-a7b3d5763100.
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
88
96
|
static getSerializationAttrFromContext(context: object, opts: Options, tp: string): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated The method should not be used. Use getSerializationAttrFromParsedContext from verifiable.
|
|
99
|
+
*
|
|
100
|
+
* */
|
|
89
101
|
static getSerializationAttrFromParsedContext(ldCtx: {
|
|
90
102
|
mappings: Map<string, Record<string, unknown>>;
|
|
91
103
|
}, tp: string): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated The method should not be used. Use parseSerializationAttr from verifiable.
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
92
108
|
static parseSerializationAttr(serAttr: string): SlotsPaths;
|
|
93
109
|
/**
|
|
110
|
+
*
|
|
111
|
+
* @deprecated The method should not be used. Use credential.parseSlots instead.
|
|
94
112
|
* ParseSlots converts payload to claim slots using provided schema
|
|
95
113
|
*
|
|
96
114
|
* @param {Merklizer} mz - Merklizer
|
|
@@ -103,6 +121,8 @@ export declare class Parser {
|
|
|
103
121
|
nonMerklized: boolean;
|
|
104
122
|
}>;
|
|
105
123
|
/**
|
|
124
|
+
* @deprecated The method should not be used. Use getFieldSlotIndex from verifiable.
|
|
125
|
+
*
|
|
106
126
|
* GetFieldSlotIndex return index of slot from 0 to 7 (each claim has by default 8 slots) for non-merklized claims
|
|
107
127
|
*
|
|
108
128
|
* @param {string} field - field name
|
|
@@ -118,4 +138,3 @@ export declare class Parser {
|
|
|
118
138
|
*/
|
|
119
139
|
static extractCredentialSubjectProperties(schema: string): Promise<Array<string>>;
|
|
120
140
|
}
|
|
121
|
-
export {};
|
|
@@ -31,18 +31,23 @@ export declare function dataFillsSlot(slot: Uint8Array, newData: Uint8Array): bo
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function checkDataInField(data: Uint8Array): boolean;
|
|
33
33
|
/**
|
|
34
|
+
*
|
|
35
|
+
* @deprecated The method should not be used. Use caclulateCoreSchemaHash from verifiable.
|
|
34
36
|
* Calculates schema hash
|
|
35
37
|
*
|
|
36
38
|
* @param {Uint8Array} schemaId
|
|
37
39
|
* @returns {*} {SchemaHash}
|
|
38
40
|
*/
|
|
39
41
|
export declare const createSchemaHash: (schemaId: Uint8Array) => SchemaHash;
|
|
40
|
-
export declare const credentialSubjectKey = "credentialSubject";
|
|
41
42
|
/**
|
|
43
|
+
*
|
|
44
|
+
* @deprecated The method should not be used. Use fillCoreClaimSlot from verifiable.
|
|
42
45
|
* checks if data can fill the slot
|
|
43
46
|
*
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
46
|
-
* @
|
|
47
|
+
* @param {Uint8Array} slotData - slot data
|
|
48
|
+
* @param {Merklizer} mz - merklizer
|
|
49
|
+
* @param {string} path - path
|
|
50
|
+
* @returns {void}
|
|
47
51
|
*/
|
|
48
52
|
export declare const fillSlot: (slotData: Uint8Array, mz: Merklizer, path: string) => Promise<void>;
|
|
53
|
+
export declare const credentialSubjectKey = "credentialSubject";
|
|
@@ -41,13 +41,17 @@ export declare class EthStateStorage implements IStateStorage {
|
|
|
41
41
|
* Creates an instance of EthStateStorage.
|
|
42
42
|
* @param {EthConnectionConfig} [ethConfig=defaultEthConnectionConfig]
|
|
43
43
|
*/
|
|
44
|
-
constructor(ethConfig
|
|
44
|
+
constructor(ethConfig: EthConnectionConfig | EthConnectionConfig[]);
|
|
45
45
|
/** {@inheritdoc IStateStorage.getLatestStateById} */
|
|
46
46
|
getLatestStateById(id: bigint): Promise<StateInfo>;
|
|
47
|
+
/** {@inheritdoc IStateStorage.getStateInfoByIdAndState} */
|
|
48
|
+
getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo>;
|
|
47
49
|
/** {@inheritdoc IStateStorage.publishState} */
|
|
48
50
|
publishState(proof: ZKProof, signer: Signer): Promise<string>;
|
|
49
51
|
/** {@inheritdoc IStateStorage.getGISTProof} */
|
|
50
52
|
getGISTProof(id: bigint): Promise<StateProof>;
|
|
51
53
|
/** {@inheritdoc IStateStorage.getGISTRootInfo} */
|
|
52
54
|
getGISTRootInfo(id: bigint): Promise<RootInfo>;
|
|
55
|
+
private getStateContractAndProviderForId;
|
|
56
|
+
private networkByChainId;
|
|
53
57
|
}
|
|
@@ -15,6 +15,14 @@ export interface IStateStorage {
|
|
|
15
15
|
* @returns `Promise<StateInfo>`
|
|
16
16
|
*/
|
|
17
17
|
getLatestStateById(id: bigint): Promise<StateInfo>;
|
|
18
|
+
/**
|
|
19
|
+
* gets state info of identity by id and state
|
|
20
|
+
*
|
|
21
|
+
* @param {bigint} id - id to check
|
|
22
|
+
* @param {bigint} state - state to check
|
|
23
|
+
* @returns `Promise<StateInfo>`
|
|
24
|
+
*/
|
|
25
|
+
getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo>;
|
|
18
26
|
/**
|
|
19
27
|
* method to publish state onchain
|
|
20
28
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const bigIntCompare: (a: bigint, b: bigint) => number;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an event in the SDK.
|
|
3
|
+
*/
|
|
4
|
+
type SdkEvent = string;
|
|
5
|
+
export declare const SDK_EVENTS: {
|
|
6
|
+
[k: SdkEvent]: SdkEvent;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Represents a topic in the SDK message bus.
|
|
10
|
+
*/
|
|
11
|
+
export type SdkTopic = keyof typeof SDK_EVENTS;
|
|
12
|
+
/**
|
|
13
|
+
* Represents a message bus that allows publishing and subscribing to topics.
|
|
14
|
+
*/
|
|
15
|
+
export declare class MessageBus {
|
|
16
|
+
/**
|
|
17
|
+
* The singleton instance of the MessageBus class.
|
|
18
|
+
*/
|
|
19
|
+
private static instance;
|
|
20
|
+
/**
|
|
21
|
+
* Private constructor for the MessageBus class.
|
|
22
|
+
*/
|
|
23
|
+
private constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Returns the singleton instance of the MessageBus class.
|
|
26
|
+
* If the instance doesn't exist, it creates a new one.
|
|
27
|
+
* @returns The singleton instance of the MessageBus class.
|
|
28
|
+
*/
|
|
29
|
+
static getInstance(): MessageBus;
|
|
30
|
+
/**
|
|
31
|
+
* Publishes a message to the specified topic.
|
|
32
|
+
*
|
|
33
|
+
* @template T - The type of data being published.
|
|
34
|
+
* @param {SdkTopic} topic - The topic to publish the message to.
|
|
35
|
+
* @param {T} data - The data to be published.
|
|
36
|
+
* @returns {boolean} - Returns true if the message was successfully published, false otherwise.
|
|
37
|
+
*/
|
|
38
|
+
publish<T>(topic: SdkTopic, data: T): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Subscribes to a specific topic and registers a callback function to be executed when a message is published.
|
|
41
|
+
*
|
|
42
|
+
* @param topic - The topic to subscribe to.
|
|
43
|
+
* @param callback - The callback function to be executed when a message is published.
|
|
44
|
+
*/
|
|
45
|
+
subscribe<T>(topic: SdkTopic, callback: (data: T) => void): string;
|
|
46
|
+
/**
|
|
47
|
+
* Subscribes to a specific topic and registers a callback function to be executed when a message is published.
|
|
48
|
+
* The callback function is executed only once.
|
|
49
|
+
*
|
|
50
|
+
* @param topic - The topic to subscribe to.
|
|
51
|
+
* @param callback - The callback function to be executed when a message is published.
|
|
52
|
+
*/
|
|
53
|
+
subscribeOnce<T>(topic: SdkTopic, callback: (data: T) => void): void;
|
|
54
|
+
/**
|
|
55
|
+
* Unsubscribes from a specific topic in the message bus.
|
|
56
|
+
*
|
|
57
|
+
* @param topic - The topic to unsubscribe from.
|
|
58
|
+
* @returns A string or boolean indicating the success of the unsubscribe operation.
|
|
59
|
+
*/
|
|
60
|
+
unsubscribe(topic: SdkTopic): string | boolean;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { SchemaHash } from '@iden3/js-iden3-core';
|
|
2
|
+
import { Merklizer, Options } from '@iden3/js-jsonld-merklization';
|
|
3
|
+
/**
|
|
4
|
+
* CoreClaimCreationOptions is params for core claim creation
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @interface CoreClaimCreationOptions
|
|
8
|
+
*/
|
|
9
|
+
export interface CoreClaimCreationOptions {
|
|
10
|
+
revNonce: number;
|
|
11
|
+
version: number;
|
|
12
|
+
subjectPosition: string;
|
|
13
|
+
merklizedRootPosition: string;
|
|
14
|
+
updatable: boolean;
|
|
15
|
+
merklizeOpts?: Options;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parsed slots of core.Claim
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @interface CoreClaimParsedSlots
|
|
22
|
+
*/
|
|
23
|
+
export interface CoreClaimParsedSlots {
|
|
24
|
+
indexA: Uint8Array;
|
|
25
|
+
indexB: Uint8Array;
|
|
26
|
+
valueA: Uint8Array;
|
|
27
|
+
valueB: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Slots paths of core.Claim
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @interface CoreClaimSlotsPaths
|
|
34
|
+
*/
|
|
35
|
+
export interface CoreClaimSlotsPaths {
|
|
36
|
+
indexAPath: string;
|
|
37
|
+
indexBPath: string;
|
|
38
|
+
valueAPath: string;
|
|
39
|
+
valueBPath: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* GetFieldSlotIndex return index of slot from 0 to 7 (each claim has by default 8 slots) for non-merklized claims
|
|
43
|
+
*
|
|
44
|
+
* @param {string} field - field name
|
|
45
|
+
* @param {Uint8Array} schemaBytes -json schema bytes
|
|
46
|
+
* @returns `number`
|
|
47
|
+
*/
|
|
48
|
+
export declare const getFieldSlotIndex: (field: string, typeName: string, schemaBytes: Uint8Array) => Promise<number>;
|
|
49
|
+
/**
|
|
50
|
+
* checks if data can fill the slot
|
|
51
|
+
*
|
|
52
|
+
* @param {Uint8Array} slotData - slot data
|
|
53
|
+
* @param {Merklizer} mz - merklizer
|
|
54
|
+
* @param {string} path - path
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
export declare const fillCoreClaimSlot: (slotData: Uint8Array, mz: Merklizer, path: string) => Promise<void>;
|
|
58
|
+
export declare const getSerializationAttrFromContext: (context: object, opts: Options, tp: string) => Promise<string>;
|
|
59
|
+
export declare const getSerializationAttrFromParsedContext: (ldCtx: {
|
|
60
|
+
mappings: Map<string, Record<string, unknown>>;
|
|
61
|
+
}, tp: string) => Promise<string>;
|
|
62
|
+
export declare const parseSerializationAttr: (serAttr: string) => CoreClaimSlotsPaths;
|
|
63
|
+
export declare const findCredentialType: (mz: Merklizer) => string;
|
|
64
|
+
/**
|
|
65
|
+
* parseCoreClaimSlots converts payload to claim slots using provided schema
|
|
66
|
+
*
|
|
67
|
+
* @param { { mappings: Map<string, Record<string, unknown>> } } ldCtx - ldCtx
|
|
68
|
+
* @param {Merklizer} mz - Merklizer
|
|
69
|
+
* @param {string} credentialType - credential type
|
|
70
|
+
* @returns `Promise<{ slots: ParsedSlots; nonMerklized: boolean }>`
|
|
71
|
+
*/
|
|
72
|
+
export declare const parseCoreClaimSlots: (ldCtx: {
|
|
73
|
+
mappings: Map<string, Record<string, unknown>>;
|
|
74
|
+
}, mz: Merklizer, credentialType: string) => Promise<{
|
|
75
|
+
slots: CoreClaimParsedSlots;
|
|
76
|
+
nonMerklized: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Calculates core schema hash
|
|
80
|
+
*
|
|
81
|
+
* @param {Uint8Array} schemaId
|
|
82
|
+
* @returns {*} {SchemaHash}
|
|
83
|
+
*/
|
|
84
|
+
export declare const caclulateCoreSchemaHash: (schemaId: Uint8Array) => SchemaHash;
|