@0xpolygonid/js-sdk 1.14.0 → 1.15.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 +0 -4
- package/dist/browser/esm/index.js +3484 -3456
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +3507 -3479
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/constants.js +3 -1
- package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +11 -8
- package/dist/node/cjs/iden3comm/handlers/message-handler.js +14 -3
- package/dist/node/cjs/iden3comm/handlers/payment.js +4 -4
- package/dist/node/cjs/iden3comm/packers/zkp.js +23 -16
- package/dist/node/cjs/iden3comm/types/index.js +1 -0
- package/dist/node/cjs/iden3comm/types/models.js +2 -0
- package/dist/node/cjs/identity/identity-wallet.js +3 -0
- package/dist/node/cjs/proof/proof-service.js +16 -12
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +4 -5
- package/dist/node/esm/iden3comm/constants.js +2 -0
- package/dist/node/esm/iden3comm/handlers/credential-proposal.js +7 -4
- package/dist/node/esm/iden3comm/handlers/message-handler.js +14 -3
- package/dist/node/esm/iden3comm/handlers/payment.js +4 -4
- package/dist/node/esm/iden3comm/packers/zkp.js +24 -17
- package/dist/node/esm/iden3comm/types/index.js +1 -0
- package/dist/node/esm/iden3comm/types/models.js +1 -0
- package/dist/node/esm/identity/identity-wallet.js +3 -0
- package/dist/node/esm/proof/proof-service.js +18 -14
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +4 -5
- package/dist/types/iden3comm/constants.d.ts +2 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +3 -5
- package/dist/types/iden3comm/handlers/message-handler.d.ts +2 -0
- package/dist/types/iden3comm/packers/zkp.d.ts +6 -5
- package/dist/types/iden3comm/types/index.d.ts +1 -0
- package/dist/types/iden3comm/types/models.d.ts +6 -0
- package/dist/types/iden3comm/types/packer.d.ts +2 -1
- package/dist/types/iden3comm/types/protocol/payment.d.ts +5 -5
- package/dist/types/identity/identity-wallet.d.ts +8 -0
- package/dist/types/proof/proof-service.d.ts +2 -2
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +1 -1
- package/package.json +1 -1
|
@@ -13,10 +13,9 @@ import { checkQueryRequest, fieldValueFromVerifiablePresentation, validateDisclo
|
|
|
13
13
|
import { parseQueriesMetadata } from '../common';
|
|
14
14
|
import { Operators } from '../../circuits';
|
|
15
15
|
import { calculateQueryHashV3 } from './query-hash';
|
|
16
|
+
import { PROTOCOL_CONSTANTS } from '../../iden3comm';
|
|
16
17
|
export const userStateError = new Error(`user state is not valid`);
|
|
17
18
|
const zeroInt = 0n;
|
|
18
|
-
const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour
|
|
19
|
-
const defaultAuthVerifyOpts = 5 * 60 * 1000; // 5 minutes
|
|
20
19
|
/**
|
|
21
20
|
* PubSignalsVerifier provides verify method
|
|
22
21
|
* @public
|
|
@@ -218,7 +217,7 @@ export class PubSignalsVerifier {
|
|
|
218
217
|
// no query verification
|
|
219
218
|
// verify state
|
|
220
219
|
const gist = await this.checkGlobalState(authV2PubSignals.GISTRoot, this.userId);
|
|
221
|
-
let acceptedStateTransitionDelay =
|
|
220
|
+
let acceptedStateTransitionDelay = PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY;
|
|
222
221
|
if (opts?.acceptedStateTransitionDelay) {
|
|
223
222
|
acceptedStateTransitionDelay = opts.acceptedStateTransitionDelay;
|
|
224
223
|
}
|
|
@@ -305,7 +304,7 @@ export class PubSignalsVerifier {
|
|
|
305
304
|
};
|
|
306
305
|
this.checkRevocationState = async (issuerID, issuerClaimNonRevState, opts) => {
|
|
307
306
|
const issuerNonRevStateResolved = await this.checkRevocationStateForId(issuerID, issuerClaimNonRevState);
|
|
308
|
-
const acceptedStateTransitionDelay = opts?.acceptedStateTransitionDelay ??
|
|
307
|
+
const acceptedStateTransitionDelay = opts?.acceptedStateTransitionDelay ?? PROTOCOL_CONSTANTS.DEFAULT_PROOF_VERIFY_DELAY;
|
|
309
308
|
if (!issuerNonRevStateResolved.latest) {
|
|
310
309
|
const timeDiff = Date.now() -
|
|
311
310
|
getDateFromUnixTimestamp(Number(issuerNonRevStateResolved.transitionTimestamp)).getTime();
|
|
@@ -389,7 +388,7 @@ export class PubSignalsVerifier {
|
|
|
389
388
|
catch (e) {
|
|
390
389
|
const stateNotExistErr = (e?.errorArgs ?? [])[0];
|
|
391
390
|
const errMsg = stateNotExistErr || e.message;
|
|
392
|
-
if (errMsg
|
|
391
|
+
if (errMsg.includes('State does not exist')) {
|
|
393
392
|
if (isGenesis) {
|
|
394
393
|
return {
|
|
395
394
|
latest: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MediaType } from '../constants';
|
|
2
2
|
import { IProofService } from '../../proof/proof-service';
|
|
3
|
-
import { AuthorizationRequestMessage, AuthorizationResponseMessage, BasicMessage, IPackageManager, JWSPackerParams } from '../types';
|
|
3
|
+
import { StateVerificationOpts, AuthorizationRequestMessage, AuthorizationResponseMessage, BasicMessage, IPackageManager, JWSPackerParams } from '../types';
|
|
4
4
|
import { DID } from '@iden3/js-iden3-core';
|
|
5
5
|
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
6
6
|
/**
|
|
@@ -25,12 +25,10 @@ export declare function createAuthorizationRequestWithMessage(reason: string, me
|
|
|
25
25
|
* Options to pass to auth response handler
|
|
26
26
|
*
|
|
27
27
|
* @public
|
|
28
|
-
* @interface AuthResponseHandlerOptions
|
|
29
28
|
*/
|
|
30
|
-
export
|
|
31
|
-
acceptedStateTransitionDelay?: number;
|
|
29
|
+
export type AuthResponseHandlerOptions = StateVerificationOpts & {
|
|
32
30
|
acceptedProofGenerationDelay?: number;
|
|
33
|
-
}
|
|
31
|
+
};
|
|
34
32
|
/**
|
|
35
33
|
* Interface that allows the processing of the authorization request in the raw format for given identifier
|
|
36
34
|
*
|
|
@@ -3,6 +3,7 @@ import { AuthMessageHandlerOptions } from './auth';
|
|
|
3
3
|
import { RevocationStatusMessageHandlerOptions } from './revocation-status';
|
|
4
4
|
import { ContractMessageHandlerOptions } from './contract-request';
|
|
5
5
|
import { PaymentHandlerOptions, PaymentRequestMessageHandlerOptions } from './payment';
|
|
6
|
+
import { DID } from '@iden3/js-iden3-core';
|
|
6
7
|
/**
|
|
7
8
|
* iden3 Protocol message handler interface
|
|
8
9
|
*/
|
|
@@ -79,6 +80,7 @@ export declare class MessageHandler {
|
|
|
79
80
|
* @returns A Promise that resolves to a Uint8Array of the packed response, or null if no response was generated.
|
|
80
81
|
*/
|
|
81
82
|
handleMessage(bytes: Uint8Array, context: AuthMessageHandlerOptions | ContractMessageHandlerOptions | RevocationStatusMessageHandlerOptions | PaymentRequestMessageHandlerOptions | PaymentHandlerOptions | {
|
|
83
|
+
senderDID?: DID;
|
|
82
84
|
[key: string]: unknown;
|
|
83
85
|
}): Promise<Uint8Array | null>;
|
|
84
86
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthDataPrepareFunc, BasicMessage, IPacker, ProvingParams, StateVerificationFunc, VerificationParams, ZKPPackerParams } from '../types';
|
|
1
|
+
import { StateVerificationOpts, AuthDataPrepareFunc, BasicMessage, IPacker, ProvingParams, StateVerificationFunc, VerificationParams, ZKPPackerParams } from '../types';
|
|
2
2
|
import { CircuitId } from '../../circuits/index';
|
|
3
3
|
import { DID } from '@iden3/js-iden3-core';
|
|
4
4
|
import { MediaType } from '../constants';
|
|
@@ -45,7 +45,7 @@ export declare class VerificationHandlerFunc {
|
|
|
45
45
|
* @param {Array<string>} pubSignals - signals that must contain user id and state
|
|
46
46
|
* @returns `Promise<boolean>`
|
|
47
47
|
*/
|
|
48
|
-
verify(id: string, pubSignals: Array<string
|
|
48
|
+
verify(id: string, pubSignals: Array<string>, opts?: StateVerificationOpts): Promise<boolean>;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Packer that can pack message to JWZ token,
|
|
@@ -55,14 +55,15 @@ export declare class VerificationHandlerFunc {
|
|
|
55
55
|
* @implements implements IPacker interface
|
|
56
56
|
*/
|
|
57
57
|
export declare class ZKPPacker implements IPacker {
|
|
58
|
-
provingParamsMap: Map<string, ProvingParams>;
|
|
59
|
-
verificationParamsMap: Map<string, VerificationParams>;
|
|
58
|
+
readonly provingParamsMap: Map<string, ProvingParams>;
|
|
59
|
+
readonly verificationParamsMap: Map<string, VerificationParams>;
|
|
60
|
+
private readonly _opts;
|
|
60
61
|
/**
|
|
61
62
|
* Creates an instance of ZKPPacker.
|
|
62
63
|
* @param {Map<string, ProvingParams>} provingParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
|
|
63
64
|
* @param {Map<string, VerificationParams>} verificationParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
|
|
64
65
|
*/
|
|
65
|
-
constructor(provingParamsMap: Map<string, ProvingParams>, verificationParamsMap: Map<string, VerificationParams
|
|
66
|
+
constructor(provingParamsMap: Map<string, ProvingParams>, verificationParamsMap: Map<string, VerificationParams>, _opts?: StateVerificationOpts);
|
|
66
67
|
/**
|
|
67
68
|
* Packs a basic message using the specified parameters.
|
|
68
69
|
* @param msg - The basic message to pack.
|
|
@@ -4,6 +4,7 @@ import { ProvingMethodAlg } from '@iden3/js-jwz';
|
|
|
4
4
|
import { CircuitId } from '../../circuits';
|
|
5
5
|
import { MediaType } from '../constants';
|
|
6
6
|
import { DIDDocument, VerificationMethod } from 'did-resolver';
|
|
7
|
+
import { StateVerificationOpts } from './models';
|
|
7
8
|
/**
|
|
8
9
|
* Protocol message type
|
|
9
10
|
*/
|
|
@@ -67,7 +68,7 @@ export type AuthDataPrepareFunc = (hash: Uint8Array, did: DID, circuitId: Circui
|
|
|
67
68
|
/**
|
|
68
69
|
* signature of state function verifier
|
|
69
70
|
*/
|
|
70
|
-
export type StateVerificationFunc = (id: string, pubSignals: Array<string
|
|
71
|
+
export type StateVerificationFunc = (id: string, pubSignals: Array<string>, opts?: StateVerificationOpts) => Promise<boolean>;
|
|
71
72
|
/**
|
|
72
73
|
* Defines method that must be implemented by any packer
|
|
73
74
|
*
|
|
@@ -2,7 +2,7 @@ import { BasicMessage } from '../';
|
|
|
2
2
|
import { PaymentRequestDataType, PaymentRequestType, PaymentType } from '../../../verifiable';
|
|
3
3
|
/** @beta PaymentRequestMessage is struct the represents payment-request message */
|
|
4
4
|
export type PaymentRequestMessage = BasicMessage & {
|
|
5
|
-
body
|
|
5
|
+
body: PaymentRequestMessageBody;
|
|
6
6
|
};
|
|
7
7
|
/** @beta PaymentRequestMessageBody is struct the represents body for payment-request */
|
|
8
8
|
export type PaymentRequestMessageBody = {
|
|
@@ -24,15 +24,15 @@ export type PaymentRequestInfo = {
|
|
|
24
24
|
export type PaymentRequestDataInfo = {
|
|
25
25
|
type: PaymentRequestDataType;
|
|
26
26
|
amount: string;
|
|
27
|
-
id:
|
|
28
|
-
chainId:
|
|
27
|
+
id: string;
|
|
28
|
+
chainId: string;
|
|
29
29
|
address: string;
|
|
30
30
|
currency: string;
|
|
31
31
|
signature?: string;
|
|
32
32
|
};
|
|
33
33
|
/** @beta PaymentMessage is struct the represents payment message */
|
|
34
34
|
export type PaymentMessage = BasicMessage & {
|
|
35
|
-
body
|
|
35
|
+
body: PaymentMessageBody;
|
|
36
36
|
};
|
|
37
37
|
/** @beta PaymentMessageBody is struct the represents body for payment message */
|
|
38
38
|
export type PaymentMessageBody = {
|
|
@@ -40,7 +40,7 @@ export type PaymentMessageBody = {
|
|
|
40
40
|
};
|
|
41
41
|
/** @beta PaymentInfo is struct the represents payment info for payment */
|
|
42
42
|
export type PaymentInfo = {
|
|
43
|
-
id:
|
|
43
|
+
id: string;
|
|
44
44
|
type: PaymentType;
|
|
45
45
|
paymentData: {
|
|
46
46
|
txId: string;
|
|
@@ -87,6 +87,13 @@ export interface IIdentityWallet {
|
|
|
87
87
|
did: DID;
|
|
88
88
|
credential: W3CCredential;
|
|
89
89
|
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Credential wallet getter
|
|
92
|
+
*
|
|
93
|
+
* @returns {ICredentialWallet}
|
|
94
|
+
* @memberof IIdentityWallet
|
|
95
|
+
*/
|
|
96
|
+
get credentialWallet(): ICredentialWallet;
|
|
90
97
|
/**
|
|
91
98
|
* Create Identity based in Ethereum address and it provides an identifier in DID form.
|
|
92
99
|
*
|
|
@@ -361,6 +368,7 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
361
368
|
constructor(_kms: KMS, _storage: IDataStorage, _credentialWallet: ICredentialWallet, _opts?: {
|
|
362
369
|
credentialStatusPublisherRegistry?: CredentialStatusPublisherRegistry | undefined;
|
|
363
370
|
} | undefined);
|
|
371
|
+
get credentialWallet(): ICredentialWallet;
|
|
364
372
|
private getCredentialStatusPublisherRegistry;
|
|
365
373
|
private createAuthCoreClaim;
|
|
366
374
|
private createAuthBJJCredential;
|
|
@@ -7,7 +7,7 @@ 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 { JSONObject, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../iden3comm';
|
|
10
|
+
import { StateVerificationOpts, JSONObject, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../iden3comm';
|
|
11
11
|
import { ICircuitStorage, IStateStorage } from '../storage';
|
|
12
12
|
import { ProofGenerationOptions } from './provers/inputs-generator';
|
|
13
13
|
import { VerifyOpts } from './verifiers';
|
|
@@ -139,7 +139,7 @@ export declare class ProofService implements IProofService {
|
|
|
139
139
|
private loadLdContext;
|
|
140
140
|
/** {@inheritdoc IProofService.generateAuthV2Inputs} */
|
|
141
141
|
generateAuthV2Inputs(hash: Uint8Array, did: DID, circuitId: CircuitId): Promise<Uint8Array>;
|
|
142
|
-
verifyState(circuitId: string, pubSignals: string[]): Promise<boolean>;
|
|
142
|
+
verifyState(circuitId: string, pubSignals: string[], opts?: StateVerificationOpts): Promise<boolean>;
|
|
143
143
|
findCredentialByProofQuery(did: DID, query: ProofQuery): Promise<{
|
|
144
144
|
cred: W3CCredential;
|
|
145
145
|
revStatus: RevocationStatus | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Id } from '@iden3/js-iden3-core';
|
|
2
2
|
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
|
|
3
|
-
import { JSONObject } from '../../iden3comm';
|
|
4
3
|
import { IStateStorage } from '../../storage';
|
|
5
4
|
import { ProofQuery } from '../../verifiable';
|
|
6
5
|
import { BaseConfig } from '../../circuits/common';
|
|
7
6
|
import { VerifyOpts } from './query';
|
|
7
|
+
import { JSONObject } from '../../iden3comm';
|
|
8
8
|
/**
|
|
9
9
|
* Verify Context - params for pub signal verification
|
|
10
10
|
* @type VerifyContext
|