@0xpolygonid/js-sdk 1.33.1 → 1.34.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 +1322 -781
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.global.js +182 -59
- package/dist/browser/umd/index.global.js.map +1 -1
- package/dist/node/cjs/index.cjs +2059 -1495
- package/dist/node/cjs/index.cjs.map +1 -1
- package/dist/node/esm/index.js +1322 -781
- package/dist/node/esm/index.js.map +1 -1
- package/dist/types/circuits/auth-v3.d.ts +20 -0
- package/dist/types/circuits/auth-v3.d.ts.map +1 -0
- package/dist/types/circuits/index.d.ts +1 -0
- package/dist/types/circuits/index.d.ts.map +1 -1
- package/dist/types/circuits/models.d.ts +2 -0
- package/dist/types/circuits/models.d.ts.map +1 -1
- package/dist/types/iden3comm/constants.d.ts +2 -1
- package/dist/types/iden3comm/constants.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/auth.d.ts +4 -1
- package/dist/types/iden3comm/handlers/auth.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/contract-request.d.ts +1 -1
- package/dist/types/iden3comm/handlers/contract-request.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +2 -2
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/fetch.d.ts +2 -2
- package/dist/types/iden3comm/handlers/fetch.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/message-handler.d.ts +12 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/payment.d.ts +18 -6
- package/dist/types/iden3comm/handlers/payment.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/refresh.d.ts +4 -1
- package/dist/types/iden3comm/handlers/refresh.d.ts.map +1 -1
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +4 -4
- package/dist/types/iden3comm/handlers/revocation-status.d.ts.map +1 -1
- package/dist/types/iden3comm/packers/zkp.d.ts.map +1 -1
- package/dist/types/iden3comm/types/protocol/payment.d.ts +58 -9
- package/dist/types/iden3comm/types/protocol/payment.d.ts.map +1 -1
- package/dist/types/iden3comm/utils/accept-profile.d.ts +3 -0
- package/dist/types/iden3comm/utils/accept-profile.d.ts.map +1 -1
- package/dist/types/proof/proof-service.d.ts +13 -0
- package/dist/types/proof/proof-service.d.ts.map +1 -1
- package/dist/types/proof/provers/inputs-generator.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/payments/evm.d.ts +19 -0
- package/dist/types/utils/payments/evm.d.ts.map +1 -0
- package/dist/types/utils/payments/solana.d.ts +88 -0
- package/dist/types/utils/payments/solana.d.ts.map +1 -0
- package/dist/types/verifiable/constants.d.ts +16 -3
- package/dist/types/verifiable/constants.d.ts.map +1 -1
- package/package.json +7 -3
- package/src/circuits/auth-v3.ts +19 -0
- package/src/circuits/index.ts +1 -0
- package/src/circuits/models.ts +5 -1
- package/src/iden3comm/constants.ts +2 -1
- package/src/iden3comm/handlers/auth.ts +54 -11
- package/src/iden3comm/handlers/contract-request.ts +1 -1
- package/src/iden3comm/handlers/credential-proposal.ts +12 -6
- package/src/iden3comm/handlers/fetch.ts +29 -6
- package/src/iden3comm/handlers/message-handler.ts +28 -2
- package/src/iden3comm/handlers/payment.ts +190 -144
- package/src/iden3comm/handlers/refresh.ts +9 -13
- package/src/iden3comm/handlers/revocation-status.ts +9 -7
- package/src/iden3comm/packers/zkp.ts +18 -8
- package/src/iden3comm/types/protocol/payment.ts +79 -10
- package/src/iden3comm/utils/accept-profile.ts +24 -0
- package/src/proof/proof-service.ts +93 -25
- package/src/proof/provers/inputs-generator.ts +2 -0
- package/src/proof/provers/prover.ts +1 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/payments/evm.ts +152 -0
- package/src/utils/payments/solana.ts +360 -0
- package/src/verifiable/constants.ts +17 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proof-service.d.ts","sourceRoot":"","sources":["../../../src/proof/proof-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,GAAG,EAGJ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"proof-service.d.ts","sourceRoot":"","sources":["../../../src/proof/proof-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,GAAG,EAGJ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKL,SAAS,EAET,KAAK,EACL,SAAS,EAEV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAEL,UAAU,EACV,gBAAgB,EAEhB,aAAa,EACd,MAAM,eAAe,CAAC;AASvB,OAAO,EAAE,SAAS,EAAgB,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAa,OAAO,EAAqB,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,yBAAyB,EACzB,0BAA0B,EAI1B,8BAA8B,EAC/B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EACL,0BAA0B,EAE1B,sBAAsB,EAEvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;GAG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AAC,oCAAoC,CA4D1C;IAEF,OAAO,CAAC,2CAA2C,CA0FjD;IAEF,OAAO,CAAC,+BAA+B,CAsBrC;IAEF,OAAO,CAAC,wBAAwB;IAGhC,OAAO,CAAC,oBAAoB;CAQ7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
import { Iden3PaymentRailsERC20RequestV1, Iden3PaymentRailsRequestV1, MultiChainPaymentConfigOption } from '../../iden3comm';
|
|
3
|
+
import { Resolvable } from 'did-resolver';
|
|
4
|
+
/**
|
|
5
|
+
* @beta
|
|
6
|
+
* buildEvmPayment creates an EVM-based payment request and signs it using EIP-712.
|
|
7
|
+
* @param {Signer} signer - EIP-712 compatible signer
|
|
8
|
+
* @param {MultiChainPaymentConfigOption} option - payment option configuration
|
|
9
|
+
* @param {string} chainId - EVM chain ID
|
|
10
|
+
* @param {string} paymentRails - payment rails contract address
|
|
11
|
+
* @param {string} recipient - recipient address
|
|
12
|
+
* @param {bigint} amount - payment amount in smallest units
|
|
13
|
+
* @param {Date} expirationDateRequired - expiration date
|
|
14
|
+
* @param {bigint} nonce - unique nonce for the payment
|
|
15
|
+
* @returns {Promise<Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1>} payment request object
|
|
16
|
+
*/
|
|
17
|
+
export declare const buildEvmPayment: (signer: Signer, option: MultiChainPaymentConfigOption, chainId: string, paymentRails: string, recipient: string, amount: bigint, expirationDateRequired: Date, nonce: bigint) => Promise<Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1>;
|
|
18
|
+
export declare function verifyEIP712TypedData(data: Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1, resolver: Resolvable): Promise<string>;
|
|
19
|
+
//# sourceMappingURL=evm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../../src/utils/payments/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAEL,+BAA+B,EAC/B,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,EACd,QAAQ,6BAA6B,EACrC,SAAS,MAAM,EACf,cAAc,MAAM,EACpB,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,wBAAwB,IAAI,EAC5B,OAAO,MAAM,KACZ,OAAO,CAAC,0BAA0B,GAAG,+BAA+B,CAqEtE,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,0BAA0B,GAAG,+BAA+B,EAClE,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,MAAM,CAAC,CA4CjB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Schema } from 'borsh';
|
|
2
|
+
import { Iden3PaymentRailsSolanaRequestV1, Iden3PaymentRailsSolanaSPLRequestV1, MultiChainPaymentConfigOption } from '../../iden3comm';
|
|
3
|
+
import { Keypair } from '@solana/web3.js';
|
|
4
|
+
import { Resolvable } from 'did-resolver';
|
|
5
|
+
export declare class SolanaNativePaymentRequest {
|
|
6
|
+
version: Uint8Array;
|
|
7
|
+
chainId: bigint;
|
|
8
|
+
verifyingContract: Uint8Array;
|
|
9
|
+
recipient: Uint8Array;
|
|
10
|
+
amount: bigint;
|
|
11
|
+
expirationDate: bigint;
|
|
12
|
+
nonce: bigint;
|
|
13
|
+
metadata: Uint8Array;
|
|
14
|
+
constructor(fields: {
|
|
15
|
+
version: Uint8Array;
|
|
16
|
+
chainId: bigint;
|
|
17
|
+
verifyingContract: Uint8Array;
|
|
18
|
+
recipient: Uint8Array;
|
|
19
|
+
amount: bigint;
|
|
20
|
+
expirationDate: bigint;
|
|
21
|
+
nonce: bigint;
|
|
22
|
+
metadata: Uint8Array;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export declare class SolanaSplPaymentRequest {
|
|
26
|
+
version: Uint8Array;
|
|
27
|
+
chainId: bigint;
|
|
28
|
+
verifyingContract: Uint8Array;
|
|
29
|
+
tokenAddress: Uint8Array;
|
|
30
|
+
recipient: Uint8Array;
|
|
31
|
+
amount: bigint;
|
|
32
|
+
expirationDate: bigint;
|
|
33
|
+
nonce: bigint;
|
|
34
|
+
metadata: Uint8Array;
|
|
35
|
+
constructor(fields: {
|
|
36
|
+
version: Uint8Array;
|
|
37
|
+
chainId: bigint;
|
|
38
|
+
verifyingContract: Uint8Array;
|
|
39
|
+
tokenAddress: Uint8Array;
|
|
40
|
+
recipient: Uint8Array;
|
|
41
|
+
amount: bigint;
|
|
42
|
+
expirationDate: bigint;
|
|
43
|
+
nonce: bigint;
|
|
44
|
+
metadata: Uint8Array;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export declare const SolanaNativePaymentSchema: Map<typeof SolanaNativePaymentRequest, {
|
|
48
|
+
kind: string;
|
|
49
|
+
fields: (string | (string | number)[])[][];
|
|
50
|
+
}>;
|
|
51
|
+
export declare const SolanaSplPaymentSchema: Map<typeof SolanaSplPaymentRequest, {
|
|
52
|
+
kind: string;
|
|
53
|
+
fields: (string | (string | number)[])[][];
|
|
54
|
+
}>;
|
|
55
|
+
export declare class SolanaPaymentInstruction {
|
|
56
|
+
recipient: Uint8Array;
|
|
57
|
+
amount: bigint;
|
|
58
|
+
expiration_date: bigint;
|
|
59
|
+
nonce: bigint;
|
|
60
|
+
metadata: Uint8Array;
|
|
61
|
+
signature: Uint8Array;
|
|
62
|
+
constructor(fields: {
|
|
63
|
+
recipient: Uint8Array;
|
|
64
|
+
amount: bigint;
|
|
65
|
+
expiration_date: bigint;
|
|
66
|
+
nonce: bigint;
|
|
67
|
+
metadata: Uint8Array;
|
|
68
|
+
signature: Uint8Array;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export declare const SolanaPaymentInstructionSchema: Schema;
|
|
72
|
+
/**
|
|
73
|
+
* @beta
|
|
74
|
+
* buildSolanaPayment creates an Solana-based payment request and signs it using ed25519.
|
|
75
|
+
* @param {Keypair} solSigner - Keypair for signing the payment request
|
|
76
|
+
* @param {MultiChainPaymentConfigOption} option - payment option configuration
|
|
77
|
+
* @param {string} chainId - EVM chain ID
|
|
78
|
+
* @param {string} paymentRails - payment rails contract address
|
|
79
|
+
* @param {string} recipient - recipient address
|
|
80
|
+
* @param {bigint} amount - payment amount in smallest units
|
|
81
|
+
* @param {Date} expirationDateRequired - expiration date
|
|
82
|
+
* @param {bigint} nonce - unique nonce for the payment
|
|
83
|
+
* @returns {Promise<Iden3PaymentRailsSolanaRequestV1 | Iden3PaymentRailsSolanaSPLRequestV1>} payment request object
|
|
84
|
+
*/
|
|
85
|
+
export declare const buildSolanaPayment: (solSigner: Keypair, option: MultiChainPaymentConfigOption, chainId: string, paymentRails: string, recipient: string, amount: bigint, expirationDate: Date, nonce: bigint) => Promise<Iden3PaymentRailsSolanaRequestV1 | Iden3PaymentRailsSolanaSPLRequestV1>;
|
|
86
|
+
export declare const serializeSolanaPaymentInstruction: (data: Iden3PaymentRailsSolanaRequestV1 | Iden3PaymentRailsSolanaSPLRequestV1) => Uint8Array;
|
|
87
|
+
export declare const verifyIden3SolanaPaymentRequest: (data: Iden3PaymentRailsSolanaRequestV1 | Iden3PaymentRailsSolanaSPLRequestV1, resolver: Resolvable) => Promise<boolean>;
|
|
88
|
+
//# sourceMappingURL=solana.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../../src/utils/payments/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAa,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,gCAAgC,EAChC,mCAAmC,EAEnC,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAE,OAAO,EAAa,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,0BAA0B;IACrC,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,UAAU,CAAC;IAC9B,SAAS,EAAE,UAAU,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,CAAC;gBAET,MAAM,EAAE;QAClB,OAAO,EAAE,UAAU,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,UAAU,CAAC;QAC9B,SAAS,EAAE,UAAU,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,UAAU,CAAC;KACtB;CAUF;AAED,qBAAa,uBAAuB;IAClC,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,UAAU,CAAC;IAC9B,YAAY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gCAAgC,GAAG,mCAAmC,CAsFhF,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,MAAM,gCAAgC,GAAG,mCAAmC,KAC3E,UAkCF,CAAC;AACF,eAAO,MAAM,+BAA+B,GAC1C,MAAM,gCAAgC,GAAG,mCAAmC,EAC5E,UAAU,UAAU,KACnB,OAAO,CAAC,OAAO,CA6CjB,CAAC"}
|
|
@@ -119,7 +119,9 @@ export declare enum RefreshServiceType {
|
|
|
119
119
|
export declare enum PaymentRequestDataType {
|
|
120
120
|
Iden3PaymentRequestCryptoV1 = "Iden3PaymentRequestCryptoV1",
|
|
121
121
|
Iden3PaymentRailsRequestV1 = "Iden3PaymentRailsRequestV1",
|
|
122
|
-
Iden3PaymentRailsERC20RequestV1 = "Iden3PaymentRailsERC20RequestV1"
|
|
122
|
+
Iden3PaymentRailsERC20RequestV1 = "Iden3PaymentRailsERC20RequestV1",
|
|
123
|
+
Iden3PaymentRailsSolanaRequestV1 = "Iden3PaymentRailsSolanaRequestV1",
|
|
124
|
+
Iden3PaymentRailsSolanaSPLRequestV1 = "Iden3PaymentRailsSolanaSPLRequestV1"
|
|
123
125
|
}
|
|
124
126
|
/**
|
|
125
127
|
* PaymentType type for payment responses
|
|
@@ -129,7 +131,9 @@ export declare enum PaymentRequestDataType {
|
|
|
129
131
|
export declare enum PaymentType {
|
|
130
132
|
Iden3PaymentCryptoV1 = "Iden3PaymentCryptoV1",
|
|
131
133
|
Iden3PaymentRailsV1 = "Iden3PaymentRailsV1",
|
|
132
|
-
Iden3PaymentRailsERC20V1 = "Iden3PaymentRailsERC20V1"
|
|
134
|
+
Iden3PaymentRailsERC20V1 = "Iden3PaymentRailsERC20V1",
|
|
135
|
+
Iden3PaymentRailsSolanaV1 = "Iden3PaymentRailsSolanaV1",
|
|
136
|
+
Iden3PaymentRailsSolanaSPLV1 = "Iden3PaymentRailsSolanaSPLV1"
|
|
133
137
|
}
|
|
134
138
|
/**
|
|
135
139
|
* SupportedPaymentProofType type for payment proofs
|
|
@@ -137,7 +141,8 @@ export declare enum PaymentType {
|
|
|
137
141
|
* @enum {string}
|
|
138
142
|
*/
|
|
139
143
|
export declare enum SupportedPaymentProofType {
|
|
140
|
-
EthereumEip712Signature2021 = "EthereumEip712Signature2021"
|
|
144
|
+
EthereumEip712Signature2021 = "EthereumEip712Signature2021",
|
|
145
|
+
SolanaEd25519Signature2025 = "SolanaEd25519Signature2025"
|
|
141
146
|
}
|
|
142
147
|
/**
|
|
143
148
|
* Media types for Payment supported currencies
|
|
@@ -172,4 +177,12 @@ export declare enum DisplayMethodType {
|
|
|
172
177
|
* Default cache max size for in-memory cache
|
|
173
178
|
*/
|
|
174
179
|
export declare const DEFAULT_CACHE_MAX_SIZE = 10000;
|
|
180
|
+
/**
|
|
181
|
+
* Solana chain reference
|
|
182
|
+
*/
|
|
183
|
+
export declare const SOLANA_CHAIN_REF: Readonly<{
|
|
184
|
+
DEVNET: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
185
|
+
TESTNET: "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
|
|
186
|
+
MAINNET: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
187
|
+
}>;
|
|
175
188
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/verifiable/constants.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiF9B,CAAC;AAEH;;;;GAIG;AACH,oBAAY,SAAS;IAEnB,YAAY,qBAAqB;IAEjC,0BAA0B,+BAA+B;CAC1D;AAED;;;;GAIG;AACH,oBAAY,oBAAoB;IAE9B,qBAAqB,0BAA0B;IAE/C,iCAAiC,sCAAsC;IAEvE,2BAA2B,kCAAkC;IAE7D,qCAAqC,0CAA0C;CAChF;AAED;;;;GAIG;AACH,oBAAY,YAAY;IACtB,cAAc,mBAAmB;CAClC;AAED;;;;GAIG;AACH,oBAAY,qBAAqB;IAE/B,KAAK,UAAU;IAEf,KAAK,UAAU;IAEf,IAAI,KAAK;CACV;AAED;;;;GAIG;AACH,oBAAY,eAAe;IAEzB,IAAI,KAAK;IAET,KAAK,UAAU;IAEf,KAAK,UAAU;CAChB;AAED;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,uBAAuB,4BAA4B;CACpD;AAED;;;;GAIG;AACH,oBAAY,sBAAsB;IAChC,2BAA2B,gCAAgC;IAC3D,0BAA0B,+BAA+B;IACzD,+BAA+B,oCAAoC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/verifiable/constants.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiF9B,CAAC;AAEH;;;;GAIG;AACH,oBAAY,SAAS;IAEnB,YAAY,qBAAqB;IAEjC,0BAA0B,+BAA+B;CAC1D;AAED;;;;GAIG;AACH,oBAAY,oBAAoB;IAE9B,qBAAqB,0BAA0B;IAE/C,iCAAiC,sCAAsC;IAEvE,2BAA2B,kCAAkC;IAE7D,qCAAqC,0CAA0C;CAChF;AAED;;;;GAIG;AACH,oBAAY,YAAY;IACtB,cAAc,mBAAmB;CAClC;AAED;;;;GAIG;AACH,oBAAY,qBAAqB;IAE/B,KAAK,UAAU;IAEf,KAAK,UAAU;IAEf,IAAI,KAAK;CACV;AAED;;;;GAIG;AACH,oBAAY,eAAe;IAEzB,IAAI,KAAK;IAET,KAAK,UAAU;IAEf,KAAK,UAAU;CAChB;AAED;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,uBAAuB,4BAA4B;CACpD;AAED;;;;GAIG;AACH,oBAAY,sBAAsB;IAChC,2BAA2B,gCAAgC;IAC3D,0BAA0B,+BAA+B;IACzD,+BAA+B,oCAAoC;IACnE,gCAAgC,qCAAqC;IACrE,mCAAmC,wCAAwC;CAC5E;AAED;;;;GAIG;AACH,oBAAY,WAAW;IACrB,oBAAoB,yBAAyB;IAC7C,mBAAmB,wBAAwB;IAC3C,wBAAwB,6BAA6B;IACrD,yBAAyB,8BAA8B;IACvD,4BAA4B,iCAAiC;CAC9D;AAED;;;;GAIG;AACH,oBAAY,yBAAyB;IACnC,2BAA2B,gCAAgC;IAC3D,0BAA0B,+BAA+B;CAC1D;AAED;;;;;GAKG;AACH,oBAAY,mBAAmB;IAC7B,GAAG,QAAQ;IACX,OAAO,WAAW;IAClB,QAAQ,YAAY;IACpB,KAAK,UAAU;IACf,GAAG,QAAQ;CACZ;AAED;;;;GAIG;AACH,oBAAY,eAAe;IACzB,QAAQ,aAAa;CACtB;AAED;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,yBAAyB,8BAA8B;CACxD;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;EAI3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.0",
|
|
4
4
|
"description": "SDK to work with Polygon ID",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"@types/node": "^24.0.4",
|
|
50
50
|
"@types/pubsub-js": "^1.8.6",
|
|
51
51
|
"@types/uuid": "^10.0.0",
|
|
52
|
+
"bs58": "^6.0.0",
|
|
53
|
+
"@solana/spl-token": "^0.4.13",
|
|
52
54
|
"dotenv": "^17.0.1",
|
|
53
55
|
"nock": "^14.0.5",
|
|
54
56
|
"rimraf": "^6.0.1",
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
"@iden3/js-crypto": "^1.3.1",
|
|
62
64
|
"@iden3/js-iden3-core": "^1.7.0",
|
|
63
65
|
"@iden3/js-jsonld-merklization": "1.7.1",
|
|
64
|
-
"@iden3/js-jwz": "^1.
|
|
66
|
+
"@iden3/js-jwz": "^1.12.0",
|
|
65
67
|
"@iden3/js-merkletree": "^1.5.0",
|
|
66
68
|
"ffjavascript": "^0.3.1",
|
|
67
69
|
"rfc4648": "^1.5.4",
|
|
@@ -70,9 +72,11 @@
|
|
|
70
72
|
"dependencies": {
|
|
71
73
|
"@iden3/onchain-non-merklized-issuer-base-abi": "^0.0.3",
|
|
72
74
|
"@iden3/universal-verifier-v2-abi": "^2.0.2",
|
|
73
|
-
"@noble/curves": "
|
|
75
|
+
"@noble/curves": "1.9.2",
|
|
76
|
+
"@solana/web3.js": "^1.98.4",
|
|
74
77
|
"ajv": "8.17.1",
|
|
75
78
|
"ajv-formats": "3.0.1",
|
|
79
|
+
"borsh": "^0.7.0",
|
|
76
80
|
"did-jwt": "8.0.4",
|
|
77
81
|
"did-resolver": "4.1.0",
|
|
78
82
|
"ethers": "^6.13.1",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthV2Inputs, AuthV2PubSignals } from './auth-v2';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Auth v3 circuit representation
|
|
5
|
+
* Inputs and public signals declaration, marshalling and parsing
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @class AuthV3Inputs
|
|
9
|
+
* @extends {BaseConfig}
|
|
10
|
+
*/
|
|
11
|
+
export class AuthV3Inputs extends AuthV2Inputs {}
|
|
12
|
+
// AuthV3PubSignals auth.circom public signals
|
|
13
|
+
/**
|
|
14
|
+
* public signals
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
* @class AuthV3PubSignals
|
|
18
|
+
*/
|
|
19
|
+
export class AuthV3PubSignals extends AuthV2PubSignals {}
|
package/src/circuits/index.ts
CHANGED
package/src/circuits/models.ts
CHANGED
|
@@ -91,8 +91,12 @@ export class Query {
|
|
|
91
91
|
* @enum {number}
|
|
92
92
|
*/
|
|
93
93
|
export enum CircuitId {
|
|
94
|
-
//
|
|
94
|
+
// AuthV2 is a type that must be used for authV2.circom
|
|
95
95
|
AuthV2 = 'authV2',
|
|
96
|
+
// AuthV3 is a type that must be used for authV3.circom
|
|
97
|
+
AuthV3 = 'authV3',
|
|
98
|
+
// AuthV3_8_32 is a type that must be used for authV3-8-32.circom
|
|
99
|
+
AuthV3_8_32 = 'authV3-8-32',
|
|
96
100
|
// StateTransition is a type that must be used for stateTransition.circom
|
|
97
101
|
StateTransition = 'stateTransition',
|
|
98
102
|
// AtomicQueryMTPV2 is a type for credentialAtomicQueryMTPV2.circom
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
Attachment
|
|
15
15
|
} from '../types';
|
|
16
16
|
import { DID, getUnixTimestamp } from '@iden3/js-iden3-core';
|
|
17
|
-
import { proving } from '@iden3/js-jwz';
|
|
17
|
+
import { ProvingMethodAlg, proving } from '@iden3/js-jwz';
|
|
18
18
|
|
|
19
19
|
import * as uuid from 'uuid';
|
|
20
20
|
import { ProofQuery } from '../../verifiable';
|
|
@@ -24,9 +24,14 @@ import { CircuitId } from '../../circuits';
|
|
|
24
24
|
import {
|
|
25
25
|
AbstractMessageHandler,
|
|
26
26
|
BasicHandlerOptions,
|
|
27
|
-
IProtocolMessageHandler
|
|
27
|
+
IProtocolMessageHandler,
|
|
28
|
+
defaultProvingMethodAlg
|
|
28
29
|
} from './message-handler';
|
|
29
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
acceptHasProvingMethodAlg,
|
|
32
|
+
buildAcceptFromProvingMethodAlg,
|
|
33
|
+
parseAcceptProfile
|
|
34
|
+
} from '../utils';
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
37
|
* Options to pass to createAuthorizationRequest function
|
|
@@ -172,7 +177,7 @@ type AuthRespOptions = {
|
|
|
172
177
|
acceptedProofGenerationDelay?: number;
|
|
173
178
|
};
|
|
174
179
|
|
|
175
|
-
export type AuthMessageHandlerOptions = AuthReqOptions | AuthRespOptions;
|
|
180
|
+
export type AuthMessageHandlerOptions = BasicHandlerOptions & (AuthReqOptions | AuthRespOptions);
|
|
176
181
|
/**
|
|
177
182
|
*
|
|
178
183
|
* Options to pass to auth handler
|
|
@@ -183,6 +188,7 @@ export type AuthMessageHandlerOptions = AuthReqOptions | AuthRespOptions;
|
|
|
183
188
|
export type AuthHandlerOptions = BasicHandlerOptions & {
|
|
184
189
|
mediaType: MediaType;
|
|
185
190
|
packerOptions?: JWSPackerParams;
|
|
191
|
+
preferredAuthProvingMethod?: ProvingMethodAlg;
|
|
186
192
|
};
|
|
187
193
|
|
|
188
194
|
/**
|
|
@@ -263,11 +269,7 @@ export class AuthHandler
|
|
|
263
269
|
}
|
|
264
270
|
|
|
265
271
|
const responseType = PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE;
|
|
266
|
-
const mediaType = this.getSupportedMediaTypeByProfile(
|
|
267
|
-
ctx,
|
|
268
|
-
responseType,
|
|
269
|
-
authRequest.body.accept
|
|
270
|
-
);
|
|
272
|
+
const mediaType = this.getSupportedMediaTypeByProfile(ctx, authRequest.body.accept);
|
|
271
273
|
const from = DID.parse(authRequest.from);
|
|
272
274
|
|
|
273
275
|
const responseScope = await processZeroKnowledgeProofRequests(
|
|
@@ -329,7 +331,10 @@ export class AuthHandler
|
|
|
329
331
|
opts.mediaType === MediaType.SignedMessage
|
|
330
332
|
? opts.packerOptions
|
|
331
333
|
: {
|
|
332
|
-
provingMethodAlg:
|
|
334
|
+
provingMethodAlg: this.getDefaultProvingMethodAlg(
|
|
335
|
+
opts.preferredAuthProvingMethod,
|
|
336
|
+
authRequest.body.accept
|
|
337
|
+
)
|
|
333
338
|
};
|
|
334
339
|
|
|
335
340
|
const token = byteDecoder.decode(
|
|
@@ -490,7 +495,6 @@ export class AuthHandler
|
|
|
490
495
|
|
|
491
496
|
private getSupportedMediaTypeByProfile(
|
|
492
497
|
ctx: AuthReqOptions,
|
|
493
|
-
responseType: string,
|
|
494
498
|
profile?: string[] | undefined
|
|
495
499
|
): MediaType {
|
|
496
500
|
let mediaType: MediaType;
|
|
@@ -517,4 +521,43 @@ export class AuthHandler
|
|
|
517
521
|
}
|
|
518
522
|
return mediaType;
|
|
519
523
|
}
|
|
524
|
+
|
|
525
|
+
private getDefaultProvingMethodAlg(
|
|
526
|
+
preferredAuthProvingMethod?: ProvingMethodAlg,
|
|
527
|
+
accept?: string[]
|
|
528
|
+
): ProvingMethodAlg {
|
|
529
|
+
if (
|
|
530
|
+
preferredAuthProvingMethod &&
|
|
531
|
+
this._packerMgr.isProfileSupported(
|
|
532
|
+
MediaType.ZKPMessage,
|
|
533
|
+
buildAcceptFromProvingMethodAlg(preferredAuthProvingMethod)
|
|
534
|
+
) &&
|
|
535
|
+
(!accept?.length || acceptHasProvingMethodAlg(accept, preferredAuthProvingMethod))
|
|
536
|
+
) {
|
|
537
|
+
return preferredAuthProvingMethod;
|
|
538
|
+
}
|
|
539
|
+
if (accept?.length) {
|
|
540
|
+
const authV3_8_32 = proving.provingMethodGroth16AuthV3_8_32Instance.methodAlg;
|
|
541
|
+
if (
|
|
542
|
+
acceptHasProvingMethodAlg(accept, authV3_8_32) &&
|
|
543
|
+
this._packerMgr.isProfileSupported(
|
|
544
|
+
MediaType.ZKPMessage,
|
|
545
|
+
buildAcceptFromProvingMethodAlg(authV3_8_32)
|
|
546
|
+
)
|
|
547
|
+
) {
|
|
548
|
+
return authV3_8_32;
|
|
549
|
+
}
|
|
550
|
+
const authV3 = proving.provingMethodGroth16AuthV3Instance.methodAlg;
|
|
551
|
+
if (
|
|
552
|
+
acceptHasProvingMethodAlg(accept, authV3) &&
|
|
553
|
+
this._packerMgr.isProfileSupported(
|
|
554
|
+
MediaType.ZKPMessage,
|
|
555
|
+
buildAcceptFromProvingMethodAlg(authV3)
|
|
556
|
+
)
|
|
557
|
+
) {
|
|
558
|
+
return authV3;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return defaultProvingMethodAlg;
|
|
562
|
+
}
|
|
520
563
|
}
|
|
@@ -57,7 +57,7 @@ export type ContractInvokeHandlerOptions = BasicHandlerOptions & {
|
|
|
57
57
|
challenge?: bigint;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
export type ContractMessageHandlerOptions = {
|
|
60
|
+
export type ContractMessageHandlerOptions = BasicHandlerOptions & {
|
|
61
61
|
senderDid: DID;
|
|
62
62
|
ethSigner: Signer;
|
|
63
63
|
challenge?: bigint;
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
CredentialsOfferMessage,
|
|
7
7
|
DIDDocument,
|
|
8
8
|
IPackageManager,
|
|
9
|
-
|
|
9
|
+
JWSPackerParams,
|
|
10
|
+
ZKPPackerParams
|
|
10
11
|
} from '../types';
|
|
11
12
|
|
|
12
13
|
import { DID, getUnixTimestamp } from '@iden3/js-iden3-core';
|
|
13
14
|
import * as uuid from 'uuid';
|
|
14
|
-
import { proving } from '@iden3/js-jwz';
|
|
15
15
|
import {
|
|
16
16
|
Proposal,
|
|
17
17
|
ProposalRequestMessage,
|
|
@@ -24,7 +24,8 @@ import { W3CCredential } from '../../verifiable';
|
|
|
24
24
|
import {
|
|
25
25
|
AbstractMessageHandler,
|
|
26
26
|
BasicHandlerOptions,
|
|
27
|
-
IProtocolMessageHandler
|
|
27
|
+
IProtocolMessageHandler,
|
|
28
|
+
getProvingMethodAlgFromJWZ
|
|
28
29
|
} from './message-handler';
|
|
29
30
|
import { verifyExpiresTime } from './common';
|
|
30
31
|
|
|
@@ -62,7 +63,10 @@ export function createProposalRequest(
|
|
|
62
63
|
to: receiver.string(),
|
|
63
64
|
typ: MediaType.PlainMessage,
|
|
64
65
|
type: PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE,
|
|
65
|
-
body:
|
|
66
|
+
body: {
|
|
67
|
+
credentials: opts.credentials,
|
|
68
|
+
did_doc: opts.did_doc
|
|
69
|
+
},
|
|
66
70
|
created_time: getUnixTimestamp(new Date()),
|
|
67
71
|
expires_time: opts?.expires_time ? getUnixTimestamp(opts.expires_time) : undefined,
|
|
68
72
|
attachments: opts.attachments
|
|
@@ -161,7 +165,7 @@ export type CredentialProposalHandlerParams = {
|
|
|
161
165
|
type: string,
|
|
162
166
|
opts?: { msg?: BasicMessage }
|
|
163
167
|
) => Promise<Proposal>;
|
|
164
|
-
packerParams:
|
|
168
|
+
packerParams: JWSPackerParams | ZKPPackerParams;
|
|
165
169
|
};
|
|
166
170
|
|
|
167
171
|
/**
|
|
@@ -345,7 +349,9 @@ export class CredentialProposalHandler
|
|
|
345
349
|
this._params.packerParams.mediaType === MediaType.SignedMessage
|
|
346
350
|
? this._params.packerParams.packerOptions
|
|
347
351
|
: {
|
|
348
|
-
provingMethodAlg:
|
|
352
|
+
provingMethodAlg:
|
|
353
|
+
this._params.packerParams.provingMethodAlg ||
|
|
354
|
+
(await getProvingMethodAlgFromJWZ(request))
|
|
349
355
|
};
|
|
350
356
|
|
|
351
357
|
return this._packerMgr.pack(this._params.packerParams.mediaType, response, {
|
|
@@ -9,20 +9,22 @@ import {
|
|
|
9
9
|
CredentialsOnchainOfferMessage,
|
|
10
10
|
IPackageManager,
|
|
11
11
|
JWSPackerParams,
|
|
12
|
-
MessageFetchRequestMessage
|
|
12
|
+
MessageFetchRequestMessage,
|
|
13
|
+
ZKPPackerParams
|
|
13
14
|
} from '../types';
|
|
14
15
|
|
|
15
16
|
import { W3CCredential } from '../../verifiable';
|
|
16
17
|
import { ICredentialWallet, getUserDIDFromCredential } from '../../credentials';
|
|
17
18
|
|
|
18
19
|
import { byteDecoder, byteEncoder } from '../../utils';
|
|
19
|
-
import { proving } from '@iden3/js-jwz';
|
|
20
20
|
import { DID } from '@iden3/js-iden3-core';
|
|
21
21
|
import * as uuid from 'uuid';
|
|
22
22
|
import {
|
|
23
23
|
AbstractMessageHandler,
|
|
24
24
|
BasicHandlerOptions,
|
|
25
|
-
IProtocolMessageHandler
|
|
25
|
+
IProtocolMessageHandler,
|
|
26
|
+
defaultProvingMethodAlg,
|
|
27
|
+
getProvingMethodAlgFromJWZ
|
|
26
28
|
} from './message-handler';
|
|
27
29
|
import { verifyExpiresTime } from './common';
|
|
28
30
|
import { IOnchainIssuer } from '../../storage';
|
|
@@ -36,7 +38,7 @@ import { IOnchainIssuer } from '../../storage';
|
|
|
36
38
|
*/
|
|
37
39
|
export type FetchHandlerOptions = BasicHandlerOptions & {
|
|
38
40
|
mediaType: MediaType;
|
|
39
|
-
packerOptions?: JWSPackerParams;
|
|
41
|
+
packerOptions?: JWSPackerParams | ZKPPackerParams;
|
|
40
42
|
headers?: {
|
|
41
43
|
[key: string]: string;
|
|
42
44
|
};
|
|
@@ -197,7 +199,7 @@ export class FetchHandler
|
|
|
197
199
|
ctx: {
|
|
198
200
|
mediaType?: MediaType;
|
|
199
201
|
headers?: HeadersInit;
|
|
200
|
-
packerOptions?: JWSPackerParams;
|
|
202
|
+
packerOptions?: JWSPackerParams | ZKPPackerParams;
|
|
201
203
|
}
|
|
202
204
|
): Promise<W3CCredential[] | BasicMessage> {
|
|
203
205
|
if (!ctx.mediaType) {
|
|
@@ -226,7 +228,7 @@ export class FetchHandler
|
|
|
226
228
|
ctx.mediaType === MediaType.SignedMessage
|
|
227
229
|
? ctx.packerOptions
|
|
228
230
|
: {
|
|
229
|
-
provingMethodAlg:
|
|
231
|
+
provingMethodAlg: ctx?.packerOptions?.provingMethodAlg || defaultProvingMethodAlg
|
|
230
232
|
};
|
|
231
233
|
|
|
232
234
|
const senderDID = DID.parse(offerMessage.to);
|
|
@@ -297,6 +299,27 @@ export class FetchHandler
|
|
|
297
299
|
if (!opts?.allowExpiredMessages) {
|
|
298
300
|
verifyExpiresTime(offerMessage);
|
|
299
301
|
}
|
|
302
|
+
|
|
303
|
+
if (!opts?.packerOptions?.provingMethodAlg) {
|
|
304
|
+
const messageProvingMethodAlg =
|
|
305
|
+
opts?.messageProvingMethodAlg || (await getProvingMethodAlgFromJWZ(offer));
|
|
306
|
+
const zkpPackerOptions = {
|
|
307
|
+
provingMethodAlg: messageProvingMethodAlg,
|
|
308
|
+
senderDID: DID.parse(offerMessage.to)
|
|
309
|
+
};
|
|
310
|
+
if (!opts) {
|
|
311
|
+
opts = {
|
|
312
|
+
mediaType: MediaType.ZKPMessage,
|
|
313
|
+
packerOptions: zkpPackerOptions
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
if (!opts.packerOptions?.provingMethodAlg) {
|
|
317
|
+
opts.packerOptions = {
|
|
318
|
+
...opts.packerOptions,
|
|
319
|
+
...zkpPackerOptions
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
300
323
|
const result = await this.handleOfferMessage(offerMessage, {
|
|
301
324
|
mediaType: opts?.mediaType,
|
|
302
325
|
headers: opts?.headers,
|
|
@@ -4,15 +4,22 @@ import { RevocationStatusMessageHandlerOptions } from './revocation-status';
|
|
|
4
4
|
import { ContractMessageHandlerOptions } from './contract-request';
|
|
5
5
|
import { PaymentHandlerOptions, PaymentRequestMessageHandlerOptions } from './payment';
|
|
6
6
|
import { MediaType } from '../constants';
|
|
7
|
-
import { proving } from '@iden3/js-jwz';
|
|
7
|
+
import { ProvingMethodAlg, Token, proving } from '@iden3/js-jwz';
|
|
8
8
|
import { DID } from '@iden3/js-iden3-core';
|
|
9
9
|
import { verifyExpiresTime } from './common';
|
|
10
|
+
import { byteDecoder } from '../../utils';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default proving method algorithm for ZKP messages
|
|
14
|
+
*/
|
|
15
|
+
export const defaultProvingMethodAlg = proving.provingMethodGroth16AuthV2Instance.methodAlg;
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* iden3 Basic protocol message handler options
|
|
13
19
|
*/
|
|
14
20
|
export type BasicHandlerOptions = {
|
|
15
21
|
allowExpiredMessages?: boolean;
|
|
22
|
+
messageProvingMethodAlg?: ProvingMethodAlg;
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
/**
|
|
@@ -144,6 +151,10 @@ export class MessageHandler {
|
|
|
144
151
|
return Promise.reject(new Error('Message handler not provided'));
|
|
145
152
|
}
|
|
146
153
|
|
|
154
|
+
if (unpackedMediaType === MediaType.ZKPMessage) {
|
|
155
|
+
context.messageProvingMethodAlg = await getProvingMethodAlgFromJWZ(bytes);
|
|
156
|
+
}
|
|
157
|
+
|
|
147
158
|
const response = await this.messageHandler.handle(message, context);
|
|
148
159
|
|
|
149
160
|
if (!response) {
|
|
@@ -155,7 +166,7 @@ export class MessageHandler {
|
|
|
155
166
|
if (unpackedMediaType === MediaType.ZKPMessage && senderDid) {
|
|
156
167
|
packerParams = {
|
|
157
168
|
senderDID: senderDid,
|
|
158
|
-
provingMethodAlg:
|
|
169
|
+
provingMethodAlg: await getProvingMethodAlgFromJWZ(bytes)
|
|
159
170
|
};
|
|
160
171
|
return this._params.packageManager.packMessage(unpackedMediaType, response, packerParams);
|
|
161
172
|
}
|
|
@@ -163,3 +174,18 @@ export class MessageHandler {
|
|
|
163
174
|
return this._params.packageManager.packMessage(MediaType.PlainMessage, response, packerParams);
|
|
164
175
|
}
|
|
165
176
|
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Get proving method algorithm from JWZ bytes
|
|
180
|
+
* @param bytes - JWZ bytes
|
|
181
|
+
* @returns Proving method algorithm
|
|
182
|
+
**/
|
|
183
|
+
export async function getProvingMethodAlgFromJWZ(bytes: Uint8Array): Promise<ProvingMethodAlg> {
|
|
184
|
+
try {
|
|
185
|
+
const tokenString = byteDecoder.decode(bytes);
|
|
186
|
+
const token = await Token.parse(tokenString);
|
|
187
|
+
return token.method.methodAlg;
|
|
188
|
+
} catch (e) {
|
|
189
|
+
return defaultProvingMethodAlg;
|
|
190
|
+
}
|
|
191
|
+
}
|