@0xpolygonid/js-sdk 1.21.3 → 1.23.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 +1358 -270
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +1363 -270
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/constants.js +25 -1
- package/dist/node/cjs/iden3comm/handlers/auth.js +52 -8
- package/dist/node/cjs/iden3comm/handlers/common.js +13 -1
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +5 -1
- package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +14 -3
- package/dist/node/cjs/iden3comm/handlers/fetch.js +12 -2
- package/dist/node/cjs/iden3comm/handlers/message-handler.js +4 -0
- package/dist/node/cjs/iden3comm/handlers/payment.js +240 -28
- package/dist/node/cjs/iden3comm/handlers/revocation-status.js +4 -0
- package/dist/node/cjs/iden3comm/index.js +1 -0
- package/dist/node/cjs/iden3comm/packageManager.js +12 -0
- package/dist/node/cjs/iden3comm/packers/jws.js +21 -0
- package/dist/node/cjs/iden3comm/packers/plain.js +19 -0
- package/dist/node/cjs/iden3comm/packers/zkp.js +25 -0
- package/dist/node/cjs/iden3comm/types/index.js +1 -0
- package/dist/node/cjs/iden3comm/types/protocol/accept-profile.js +2 -0
- package/dist/node/cjs/iden3comm/utils/accept-profile.js +107 -0
- package/dist/node/cjs/iden3comm/utils/index.js +1 -0
- package/dist/node/cjs/storage/blockchain/abi/ERC20Permit.json +1 -0
- package/dist/node/cjs/storage/blockchain/erc20-permit-sig.js +46 -0
- package/dist/node/cjs/storage/blockchain/index.js +1 -0
- package/dist/node/cjs/verifiable/constants.js +28 -11
- package/dist/node/esm/iden3comm/constants.js +24 -0
- package/dist/node/esm/iden3comm/handlers/auth.js +55 -11
- package/dist/node/esm/iden3comm/handlers/common.js +11 -0
- package/dist/node/esm/iden3comm/handlers/contract-request.js +7 -3
- package/dist/node/esm/iden3comm/handlers/credential-proposal.js +15 -4
- package/dist/node/esm/iden3comm/handlers/fetch.js +12 -2
- package/dist/node/esm/iden3comm/handlers/message-handler.js +4 -0
- package/dist/node/esm/iden3comm/handlers/payment.js +240 -29
- package/dist/node/esm/iden3comm/handlers/revocation-status.js +4 -0
- package/dist/node/esm/iden3comm/index.js +1 -0
- package/dist/node/esm/iden3comm/packageManager.js +12 -0
- package/dist/node/esm/iden3comm/packers/jws.js +22 -1
- package/dist/node/esm/iden3comm/packers/plain.js +19 -0
- package/dist/node/esm/iden3comm/packers/zkp.js +26 -1
- package/dist/node/esm/iden3comm/types/index.js +1 -0
- package/dist/node/esm/iden3comm/types/protocol/accept-profile.js +1 -0
- package/dist/node/esm/iden3comm/utils/accept-profile.js +102 -0
- package/dist/node/esm/iden3comm/utils/index.js +1 -0
- package/dist/node/esm/storage/blockchain/abi/ERC20Permit.json +1 -0
- package/dist/node/esm/storage/blockchain/erc20-permit-sig.js +39 -0
- package/dist/node/esm/storage/blockchain/index.js +1 -0
- package/dist/node/esm/verifiable/constants.js +27 -10
- package/dist/types/iden3comm/constants.d.ts +16 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +19 -7
- package/dist/types/iden3comm/handlers/common.d.ts +7 -1
- package/dist/types/iden3comm/handlers/contract-request.d.ts +2 -2
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +9 -4
- package/dist/types/iden3comm/handlers/fetch.d.ts +22 -6
- package/dist/types/iden3comm/handlers/message-handler.d.ts +6 -0
- package/dist/types/iden3comm/handlers/payment.d.ts +70 -10
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +2 -2
- package/dist/types/iden3comm/index.d.ts +1 -0
- package/dist/types/iden3comm/packageManager.d.ts +4 -0
- package/dist/types/iden3comm/packers/jws.d.ts +5 -0
- package/dist/types/iden3comm/packers/plain.d.ts +4 -0
- package/dist/types/iden3comm/packers/zkp.d.ts +6 -0
- package/dist/types/iden3comm/types/index.d.ts +1 -0
- package/dist/types/iden3comm/types/packageManager.d.ts +14 -0
- package/dist/types/iden3comm/types/packer.d.ts +25 -0
- package/dist/types/iden3comm/types/protocol/accept-profile.d.ts +7 -0
- package/dist/types/iden3comm/types/protocol/auth.d.ts +1 -0
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +6 -6
- package/dist/types/iden3comm/types/protocol/messages.d.ts +2 -2
- package/dist/types/iden3comm/types/protocol/payment.d.ts +87 -13
- package/dist/types/iden3comm/types/protocol/proof.d.ts +3 -3
- package/dist/types/iden3comm/types/protocol/revocation.d.ts +2 -2
- package/dist/types/iden3comm/utils/accept-profile.d.ts +3 -0
- package/dist/types/iden3comm/utils/index.d.ts +1 -0
- package/dist/types/storage/blockchain/erc20-permit-sig.d.ts +12 -0
- package/dist/types/storage/blockchain/index.d.ts +1 -0
- package/dist/types/verifiable/constants.d.ts +27 -11
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import abi from './abi/ERC20Permit.json';
|
|
3
|
+
/**
|
|
4
|
+
* @beta
|
|
5
|
+
* getPermitSignature is a function to create EIP712 Permit signature
|
|
6
|
+
* @param {Signer} signer - User who owns the tokens
|
|
7
|
+
* @param {string} tokenAddress - EIP-2612 contract address
|
|
8
|
+
* @param {string} spender - The contract address that will spend tokens
|
|
9
|
+
* @param {bigint} value - Amount of tokens to approve
|
|
10
|
+
* @param {number} deadline - Timestamp when the permit expires
|
|
11
|
+
* @returns {Promise<PaymentRequestMessage>}
|
|
12
|
+
*/
|
|
13
|
+
export async function getPermitSignature(signer, tokenAddress, spender, value, deadline) {
|
|
14
|
+
const erc20PermitContract = new Contract(tokenAddress, abi, signer);
|
|
15
|
+
const nonce = await erc20PermitContract.nonces(await signer.getAddress());
|
|
16
|
+
const domainData = await erc20PermitContract.eip712Domain();
|
|
17
|
+
const domain = {
|
|
18
|
+
version: domainData[2],
|
|
19
|
+
chainId: domainData[3],
|
|
20
|
+
verifyingContract: tokenAddress
|
|
21
|
+
};
|
|
22
|
+
const types = {
|
|
23
|
+
Permit: [
|
|
24
|
+
{ name: 'owner', type: 'address' },
|
|
25
|
+
{ name: 'spender', type: 'address' },
|
|
26
|
+
{ name: 'value', type: 'uint256' },
|
|
27
|
+
{ name: 'nonce', type: 'uint256' },
|
|
28
|
+
{ name: 'deadline', type: 'uint256' }
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
const message = {
|
|
32
|
+
owner: await signer.getAddress(),
|
|
33
|
+
spender: spender,
|
|
34
|
+
value: value,
|
|
35
|
+
nonce: nonce,
|
|
36
|
+
deadline: deadline
|
|
37
|
+
};
|
|
38
|
+
return signer.signTypedData(domain, types, message);
|
|
39
|
+
}
|
|
@@ -112,15 +112,6 @@ export var RefreshServiceType;
|
|
|
112
112
|
(function (RefreshServiceType) {
|
|
113
113
|
RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
|
|
114
114
|
})(RefreshServiceType || (RefreshServiceType = {}));
|
|
115
|
-
/**
|
|
116
|
-
* PaymentRequestType type for payment requests
|
|
117
|
-
* @beta
|
|
118
|
-
* @enum {string}
|
|
119
|
-
*/
|
|
120
|
-
export var PaymentRequestType;
|
|
121
|
-
(function (PaymentRequestType) {
|
|
122
|
-
PaymentRequestType["PaymentRequest"] = "PaymentRequest";
|
|
123
|
-
})(PaymentRequestType || (PaymentRequestType = {}));
|
|
124
115
|
/**
|
|
125
116
|
* PaymentRequestDataType type for payment requests
|
|
126
117
|
* @beta
|
|
@@ -129,6 +120,8 @@ export var PaymentRequestType;
|
|
|
129
120
|
export var PaymentRequestDataType;
|
|
130
121
|
(function (PaymentRequestDataType) {
|
|
131
122
|
PaymentRequestDataType["Iden3PaymentRequestCryptoV1"] = "Iden3PaymentRequestCryptoV1";
|
|
123
|
+
PaymentRequestDataType["Iden3PaymentRailsRequestV1"] = "Iden3PaymentRailsRequestV1";
|
|
124
|
+
PaymentRequestDataType["Iden3PaymentRailsERC20RequestV1"] = "Iden3PaymentRailsERC20RequestV1";
|
|
132
125
|
})(PaymentRequestDataType || (PaymentRequestDataType = {}));
|
|
133
126
|
/**
|
|
134
127
|
* PaymentType type for payment responses
|
|
@@ -138,17 +131,41 @@ export var PaymentRequestDataType;
|
|
|
138
131
|
export var PaymentType;
|
|
139
132
|
(function (PaymentType) {
|
|
140
133
|
PaymentType["Iden3PaymentCryptoV1"] = "Iden3PaymentCryptoV1";
|
|
134
|
+
PaymentType["Iden3PaymentRailsV1"] = "Iden3PaymentRailsV1";
|
|
135
|
+
PaymentType["Iden3PaymentRailsERC20V1"] = "Iden3PaymentRailsERC20V1";
|
|
141
136
|
})(PaymentType || (PaymentType = {}));
|
|
137
|
+
/**
|
|
138
|
+
* SupportedPaymentProofType type for payment proofs
|
|
139
|
+
* @beta
|
|
140
|
+
* @enum {string}
|
|
141
|
+
*/
|
|
142
|
+
export var SupportedPaymentProofType;
|
|
143
|
+
(function (SupportedPaymentProofType) {
|
|
144
|
+
SupportedPaymentProofType["EthereumEip712Signature2021"] = "EthereumEip712Signature2021";
|
|
145
|
+
})(SupportedPaymentProofType || (SupportedPaymentProofType = {}));
|
|
142
146
|
/**
|
|
143
147
|
* Media types for Payment supported currencies
|
|
144
148
|
* @beta
|
|
145
|
-
* @enum {
|
|
149
|
+
* @enum {string}
|
|
146
150
|
*/
|
|
147
151
|
export var SupportedCurrencies;
|
|
148
152
|
(function (SupportedCurrencies) {
|
|
149
153
|
SupportedCurrencies["ETH"] = "ETH";
|
|
154
|
+
SupportedCurrencies["ETH_WEI"] = "ETHWEI";
|
|
155
|
+
SupportedCurrencies["ETH_GWEI"] = "ETHGWEI";
|
|
150
156
|
SupportedCurrencies["MATIC"] = "MATIC";
|
|
157
|
+
SupportedCurrencies["USDT"] = "USDT";
|
|
158
|
+
SupportedCurrencies["USDC"] = "USDC";
|
|
151
159
|
})(SupportedCurrencies || (SupportedCurrencies = {}));
|
|
160
|
+
/**
|
|
161
|
+
* Supported features for payment-request
|
|
162
|
+
* @beta
|
|
163
|
+
* @enum {string}
|
|
164
|
+
*/
|
|
165
|
+
export var PaymentFeatures;
|
|
166
|
+
(function (PaymentFeatures) {
|
|
167
|
+
PaymentFeatures["EIP_2612"] = "EIP-2612";
|
|
168
|
+
})(PaymentFeatures || (PaymentFeatures = {}));
|
|
152
169
|
/**
|
|
153
170
|
* DisplayMethodType type for display method
|
|
154
171
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AcceptProfile } from './types';
|
|
1
2
|
/**
|
|
2
3
|
* Constants for Iden3 protocol
|
|
3
4
|
*/
|
|
@@ -37,5 +38,20 @@ export declare const SUPPORTED_PUBLIC_KEY_TYPES: {
|
|
|
37
38
|
ES256K: string[];
|
|
38
39
|
'ES256K-R': string[];
|
|
39
40
|
};
|
|
41
|
+
export declare enum ProtocolVersion {
|
|
42
|
+
V1 = "iden3comm/v1"
|
|
43
|
+
}
|
|
44
|
+
export declare enum AcceptAuthCircuits {
|
|
45
|
+
AuthV2 = "authV2",
|
|
46
|
+
AuthV3 = "authV3"
|
|
47
|
+
}
|
|
48
|
+
export declare enum AcceptJwzAlgorithms {
|
|
49
|
+
Groth16 = "groth16"
|
|
50
|
+
}
|
|
51
|
+
export declare enum AcceptJwsAlgorithms {
|
|
52
|
+
ES256K = "ES256K",
|
|
53
|
+
ES256KR = "ES256K-R"
|
|
54
|
+
}
|
|
55
|
+
export declare const defaultAcceptProfile: AcceptProfile;
|
|
40
56
|
export declare const DEFAULT_PROOF_VERIFY_DELAY: number;
|
|
41
57
|
export declare const DEFAULT_AUTH_VERIFY_DELAY: number;
|
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import { MediaType } from '../constants';
|
|
2
2
|
import { IProofService } from '../../proof/proof-service';
|
|
3
|
-
import { StateVerificationOpts, AuthorizationRequestMessage, AuthorizationResponseMessage, BasicMessage, IPackageManager, JWSPackerParams } from '../types';
|
|
3
|
+
import { StateVerificationOpts, AuthorizationRequestMessage, AuthorizationResponseMessage, BasicMessage, IPackageManager, JWSPackerParams, ZeroKnowledgeProofRequest } from '../types';
|
|
4
4
|
import { DID } from '@iden3/js-iden3-core';
|
|
5
|
-
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
5
|
+
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
6
|
+
/**
|
|
7
|
+
* Options to pass to createAuthorizationRequest function
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type AuthorizationRequestCreateOptions = {
|
|
11
|
+
accept?: string[];
|
|
12
|
+
scope?: ZeroKnowledgeProofRequest[];
|
|
13
|
+
expires_time?: Date;
|
|
14
|
+
};
|
|
6
15
|
/**
|
|
7
16
|
* createAuthorizationRequest is a function to create protocol authorization request
|
|
8
17
|
* @param {string} reason - reason to request proof
|
|
9
18
|
* @param {string} sender - sender did
|
|
10
19
|
* @param {string} callbackUrl - callback that user should use to send response
|
|
20
|
+
* @param {AuthorizationRequestCreateOptions} opts - authorization request options
|
|
11
21
|
* @returns `Promise<AuthorizationRequestMessage>`
|
|
12
22
|
*/
|
|
13
|
-
export declare function createAuthorizationRequest(reason: string, sender: string, callbackUrl: string): AuthorizationRequestMessage;
|
|
23
|
+
export declare function createAuthorizationRequest(reason: string, sender: string, callbackUrl: string, opts?: AuthorizationRequestCreateOptions): AuthorizationRequestMessage;
|
|
14
24
|
/**
|
|
15
25
|
* createAuthorizationRequestWithMessage is a function to create protocol authorization request with explicit message to sign
|
|
16
26
|
* @param {string} reason - reason to request proof
|
|
17
27
|
* @param {string} message - message to sign in the response
|
|
18
28
|
* @param {string} sender - sender did
|
|
19
29
|
* @param {string} callbackUrl - callback that user should use to send response
|
|
30
|
+
* @param {AuthorizationRequestCreateOptions} opts - authorization request options
|
|
20
31
|
* @returns `Promise<AuthorizationRequestMessage>`
|
|
21
32
|
*/
|
|
22
|
-
export declare function createAuthorizationRequestWithMessage(reason: string, message: string, sender: string, callbackUrl: string): AuthorizationRequestMessage;
|
|
33
|
+
export declare function createAuthorizationRequestWithMessage(reason: string, message: string, sender: string, callbackUrl: string, opts?: AuthorizationRequestCreateOptions): AuthorizationRequestMessage;
|
|
23
34
|
/**
|
|
24
35
|
*
|
|
25
36
|
* Options to pass to auth response handler
|
|
26
37
|
*
|
|
27
38
|
* @public
|
|
28
39
|
*/
|
|
29
|
-
export type AuthResponseHandlerOptions = StateVerificationOpts & {
|
|
40
|
+
export type AuthResponseHandlerOptions = StateVerificationOpts & BasicHandlerOptions & {
|
|
30
41
|
acceptedProofGenerationDelay?: number;
|
|
31
42
|
};
|
|
32
43
|
/**
|
|
@@ -92,10 +103,10 @@ export type AuthMessageHandlerOptions = AuthReqOptions | AuthRespOptions;
|
|
|
92
103
|
* @public
|
|
93
104
|
* @interface AuthHandlerOptions
|
|
94
105
|
*/
|
|
95
|
-
export
|
|
106
|
+
export type AuthHandlerOptions = BasicHandlerOptions & {
|
|
96
107
|
mediaType: MediaType;
|
|
97
108
|
packerOptions?: JWSPackerParams;
|
|
98
|
-
}
|
|
109
|
+
};
|
|
99
110
|
/**
|
|
100
111
|
*
|
|
101
112
|
* Allows to process AuthorizationRequest protocol message and produce JWZ response.
|
|
@@ -139,5 +150,6 @@ export declare class AuthHandler extends AbstractMessageHandler implements IAuth
|
|
|
139
150
|
response: AuthorizationResponseMessage;
|
|
140
151
|
}>;
|
|
141
152
|
private verifyAuthRequest;
|
|
153
|
+
private getSupportedMediaTypeByProfile;
|
|
142
154
|
}
|
|
143
155
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JWSPackerParams, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../types';
|
|
1
|
+
import { BasicMessage, JWSPackerParams, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../types';
|
|
2
2
|
import { DID } from '@iden3/js-iden3-core';
|
|
3
3
|
import { IProofService } from '../../proof';
|
|
4
4
|
import { CircuitId } from '../../circuits';
|
|
@@ -21,3 +21,9 @@ export declare const processZeroKnowledgeProofRequests: (to: DID, requests: Zero
|
|
|
21
21
|
ethSigner?: Signer;
|
|
22
22
|
challenge?: bigint;
|
|
23
23
|
}) => Promise<ZeroKnowledgeProofResponse[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Verifies that the expires_time field of a message is not in the past. Throws an error if it is.
|
|
26
|
+
*
|
|
27
|
+
* @param message - Basic message to verify.
|
|
28
|
+
*/
|
|
29
|
+
export declare const verifyExpiresTime: (message: BasicMessage) => void;
|
|
@@ -4,7 +4,7 @@ import { ContractInvokeRequest } from '../types/protocol/contract-request';
|
|
|
4
4
|
import { DID } from '@iden3/js-iden3-core';
|
|
5
5
|
import { IOnChainZKPVerifier } from '../../storage';
|
|
6
6
|
import { Signer } from 'ethers';
|
|
7
|
-
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
7
|
+
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
8
8
|
/**
|
|
9
9
|
* Interface that allows the processing of the contract request
|
|
10
10
|
*
|
|
@@ -30,7 +30,7 @@ export interface IContractRequestHandler {
|
|
|
30
30
|
handleContractInvokeRequest(did: DID, request: Uint8Array, opts?: ContractInvokeHandlerOptions): Promise<Map<string, ZeroKnowledgeProofResponse>>;
|
|
31
31
|
}
|
|
32
32
|
/** ContractInvokeHandlerOptions represents contract invoke handler options */
|
|
33
|
-
export type ContractInvokeHandlerOptions = {
|
|
33
|
+
export type ContractInvokeHandlerOptions = BasicHandlerOptions & {
|
|
34
34
|
ethSigner: Signer;
|
|
35
35
|
challenge?: bigint;
|
|
36
36
|
};
|
|
@@ -2,7 +2,7 @@ import { BasicMessage, DIDDocument, IPackageManager, JsonDocumentObject, PackerP
|
|
|
2
2
|
import { DID } from '@iden3/js-iden3-core';
|
|
3
3
|
import { Proposal, ProposalRequestCredential, ProposalRequestMessage, ProposalMessage } from '../types/protocol/proposal-request';
|
|
4
4
|
import { IIdentityWallet } from '../../identity';
|
|
5
|
-
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
5
|
+
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
6
6
|
/** @beta ProposalRequestCreationOptions represents proposal-request creation options */
|
|
7
7
|
export type ProposalRequestCreationOptions = {
|
|
8
8
|
credentials: ProposalRequestCredential[];
|
|
@@ -11,6 +11,11 @@ export type ProposalRequestCreationOptions = {
|
|
|
11
11
|
data?: JsonDocumentObject;
|
|
12
12
|
};
|
|
13
13
|
did_doc?: DIDDocument;
|
|
14
|
+
expires_time?: Date;
|
|
15
|
+
};
|
|
16
|
+
/** @beta ProposalCreationOptions represents proposal creation options */
|
|
17
|
+
export type ProposalCreationOptions = {
|
|
18
|
+
expires_time?: Date;
|
|
14
19
|
};
|
|
15
20
|
/**
|
|
16
21
|
* @beta
|
|
@@ -29,7 +34,7 @@ export declare function createProposalRequest(sender: DID, receiver: DID, opts:
|
|
|
29
34
|
* @param {Proposal[]} proposals - proposals
|
|
30
35
|
* @returns `Promise<ProposalRequestMessage>`
|
|
31
36
|
*/
|
|
32
|
-
export declare function createProposal(sender: DID, receiver: DID, proposals?: Proposal[]): ProposalMessage;
|
|
37
|
+
export declare function createProposal(sender: DID, receiver: DID, proposals?: Proposal[], opts?: ProposalCreationOptions): ProposalMessage;
|
|
33
38
|
/**
|
|
34
39
|
* @beta
|
|
35
40
|
* Interface that allows the processing of the proposal-request
|
|
@@ -66,9 +71,9 @@ export interface ICredentialProposalHandler {
|
|
|
66
71
|
}>;
|
|
67
72
|
}
|
|
68
73
|
/** @beta ProposalRequestHandlerOptions represents proposal-request handler options */
|
|
69
|
-
export type ProposalRequestHandlerOptions =
|
|
74
|
+
export type ProposalRequestHandlerOptions = BasicHandlerOptions;
|
|
70
75
|
/** @beta ProposalHandlerOptions represents proposal handler options */
|
|
71
|
-
export type ProposalHandlerOptions = {
|
|
76
|
+
export type ProposalHandlerOptions = BasicHandlerOptions & {
|
|
72
77
|
proposalRequest?: ProposalRequestMessage;
|
|
73
78
|
};
|
|
74
79
|
/** @beta CredentialProposalHandlerParams represents credential proposal handler params */
|
|
@@ -2,7 +2,7 @@ import { MediaType } from '../constants';
|
|
|
2
2
|
import { BasicMessage, IPackageManager, JWSPackerParams } from '../types';
|
|
3
3
|
import { W3CCredential } from '../../verifiable';
|
|
4
4
|
import { ICredentialWallet } from '../../credentials';
|
|
5
|
-
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
5
|
+
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* Options to pass to fetch handler
|
|
@@ -10,13 +10,29 @@ import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handl
|
|
|
10
10
|
* @public
|
|
11
11
|
* @interface FetchHandlerOptions
|
|
12
12
|
*/
|
|
13
|
-
export type FetchHandlerOptions = {
|
|
13
|
+
export type FetchHandlerOptions = BasicHandlerOptions & {
|
|
14
14
|
mediaType: MediaType;
|
|
15
15
|
packerOptions?: JWSPackerParams;
|
|
16
16
|
headers?: {
|
|
17
17
|
[key: string]: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* Options to pass to fetch request handler
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
* @interface FetchRequestOptions
|
|
26
|
+
*/
|
|
27
|
+
export type FetchRequestOptions = BasicHandlerOptions;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* Options to pass to issuance response handler
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @interface IssuanceResponseOptions
|
|
34
|
+
*/
|
|
35
|
+
export type IssuanceResponseOptions = BasicHandlerOptions;
|
|
20
36
|
export type FetchMessageHandlerOptions = FetchHandlerOptions;
|
|
21
37
|
/**
|
|
22
38
|
* Interface that allows the processing of the credential offer in the raw format for given identifier
|
|
@@ -44,7 +60,7 @@ export interface IFetchHandler {
|
|
|
44
60
|
* @returns A promise that resolves to the response message.
|
|
45
61
|
* @throws An error if the request is invalid or if the credential is not found.
|
|
46
62
|
*/
|
|
47
|
-
handleCredentialFetchRequest(basicMessage: Uint8Array): Promise<Uint8Array>;
|
|
63
|
+
handleCredentialFetchRequest(basicMessage: Uint8Array, opts?: FetchRequestOptions): Promise<Uint8Array>;
|
|
48
64
|
/**
|
|
49
65
|
* Handles the issuance response message.
|
|
50
66
|
*
|
|
@@ -52,7 +68,7 @@ export interface IFetchHandler {
|
|
|
52
68
|
* @returns A promise that resolves to a Uint8Array.
|
|
53
69
|
* @throws An error if the credential wallet is not provided in the options or if the credential is missing in the issuance response message.
|
|
54
70
|
*/
|
|
55
|
-
handleIssuanceResponseMessage(basicMessage: Uint8Array): Promise<Uint8Array>;
|
|
71
|
+
handleIssuanceResponseMessage(basicMessage: Uint8Array, opts?: IssuanceResponseOptions): Promise<Uint8Array>;
|
|
56
72
|
}
|
|
57
73
|
/**
|
|
58
74
|
*
|
|
@@ -92,12 +108,12 @@ export declare class FetchHandler extends AbstractMessageHandler implements IFet
|
|
|
92
108
|
/**
|
|
93
109
|
* @inheritdoc IFetchHandler#handleCredentialFetchRequest
|
|
94
110
|
*/
|
|
95
|
-
handleCredentialFetchRequest(envelope: Uint8Array): Promise<Uint8Array>;
|
|
111
|
+
handleCredentialFetchRequest(envelope: Uint8Array, opts?: FetchRequestOptions): Promise<Uint8Array>;
|
|
96
112
|
private handleIssuanceResponseMsg;
|
|
97
113
|
/**
|
|
98
114
|
* @inheritdoc IFetchHandler#handleIssuanceResponseMessage
|
|
99
115
|
*/
|
|
100
|
-
handleIssuanceResponseMessage(envelop: Uint8Array): Promise<Uint8Array>;
|
|
116
|
+
handleIssuanceResponseMessage(envelop: Uint8Array, opts?: IssuanceResponseOptions): Promise<Uint8Array>;
|
|
101
117
|
/**
|
|
102
118
|
* @inheritdoc IFetchHandler#unpackMessage
|
|
103
119
|
*/
|
|
@@ -4,6 +4,12 @@ import { RevocationStatusMessageHandlerOptions } from './revocation-status';
|
|
|
4
4
|
import { ContractMessageHandlerOptions } from './contract-request';
|
|
5
5
|
import { PaymentHandlerOptions, PaymentRequestMessageHandlerOptions } from './payment';
|
|
6
6
|
import { DID } from '@iden3/js-iden3-core';
|
|
7
|
+
/**
|
|
8
|
+
* iden3 Basic protocol message handler options
|
|
9
|
+
*/
|
|
10
|
+
export type BasicHandlerOptions = {
|
|
11
|
+
allowExpiredMessages?: boolean;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* iden3 Protocol message handler interface
|
|
9
15
|
*/
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { BasicMessage, IPackageManager, PackerParams } from '../types';
|
|
2
2
|
import { DID } from '@iden3/js-iden3-core';
|
|
3
|
-
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
4
|
-
import {
|
|
3
|
+
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
4
|
+
import { Iden3PaymentRailsERC20RequestV1, Iden3PaymentRailsRequestV1, MultiChainPaymentConfig, PaymentMessage, PaymentRequestInfo, PaymentRequestMessage, PaymentRequestTypeUnion, PaymentTypeUnion } from '../types/protocol/payment';
|
|
5
|
+
import { PaymentFeatures, PaymentRequestDataType, SupportedCurrencies } from '../../verifiable';
|
|
6
|
+
import { Signer } from 'ethers';
|
|
7
|
+
import { Resolvable } from 'did-resolver';
|
|
8
|
+
/** @beta PaymentRequestCreationOptions represents payment-request creation options */
|
|
9
|
+
export type PaymentRequestCreationOptions = {
|
|
10
|
+
expires_time?: Date;
|
|
11
|
+
};
|
|
12
|
+
/** @beta PaymentCreationOptions represents payment creation options */
|
|
13
|
+
export type PaymentCreationOptions = {
|
|
14
|
+
expires_time?: Date;
|
|
15
|
+
};
|
|
5
16
|
/**
|
|
6
17
|
* @beta
|
|
7
18
|
* createPaymentRequest is a function to create protocol payment-request message
|
|
@@ -11,16 +22,42 @@ import { PaymentInfo, PaymentMessage, PaymentRequestDataInfo, PaymentRequestInfo
|
|
|
11
22
|
* @param {PaymentRequestInfo[]} payments - payments
|
|
12
23
|
* @returns `PaymentRequestMessage`
|
|
13
24
|
*/
|
|
14
|
-
export declare function createPaymentRequest(sender: DID, receiver: DID, agent: string, payments: PaymentRequestInfo[]): PaymentRequestMessage;
|
|
25
|
+
export declare function createPaymentRequest(sender: DID, receiver: DID, agent: string, payments: PaymentRequestInfo[], opts?: PaymentRequestCreationOptions): PaymentRequestMessage;
|
|
26
|
+
export declare function verifyEIP712TypedData(data: Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1, resolver: Resolvable): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* @beta
|
|
29
|
+
* PaymentRailsInfo represents payment info for payment rails
|
|
30
|
+
*/
|
|
31
|
+
export type PaymentRailsInfo = {
|
|
32
|
+
credentials: {
|
|
33
|
+
type: string;
|
|
34
|
+
context: string;
|
|
35
|
+
}[];
|
|
36
|
+
description?: string;
|
|
37
|
+
chains: PaymentRailsChainInfo[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @beta
|
|
41
|
+
* PaymentRailsChainInfo represents chain info for payment rails
|
|
42
|
+
*/
|
|
43
|
+
export type PaymentRailsChainInfo = {
|
|
44
|
+
nonce: bigint;
|
|
45
|
+
amount: bigint;
|
|
46
|
+
currency: SupportedCurrencies | string;
|
|
47
|
+
chainId: string;
|
|
48
|
+
expirationDate?: string;
|
|
49
|
+
features?: PaymentFeatures[];
|
|
50
|
+
type: PaymentRequestDataType.Iden3PaymentRailsRequestV1 | PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1;
|
|
51
|
+
};
|
|
15
52
|
/**
|
|
16
53
|
* @beta
|
|
17
54
|
* createPayment is a function to create protocol payment message
|
|
18
55
|
* @param {DID} sender - sender did
|
|
19
56
|
* @param {DID} receiver - receiver did
|
|
20
|
-
* @param {
|
|
57
|
+
* @param {PaymentMessageBody} body - payments
|
|
21
58
|
* @returns `PaymentMessage`
|
|
22
59
|
*/
|
|
23
|
-
export declare function createPayment(sender: DID, receiver: DID, payments:
|
|
60
|
+
export declare function createPayment(sender: DID, receiver: DID, payments: PaymentTypeUnion[], opts?: PaymentCreationOptions): PaymentMessage;
|
|
24
61
|
/**
|
|
25
62
|
* @beta
|
|
26
63
|
* Interface that allows the processing of the payment-request and payment protocol messages
|
|
@@ -51,19 +88,35 @@ export interface IPaymentHandler {
|
|
|
51
88
|
* @returns `Promise<void>`
|
|
52
89
|
*/
|
|
53
90
|
handlePayment(payment: PaymentMessage, opts: PaymentHandlerOptions): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* @beta
|
|
93
|
+
* createPaymentRailsV1 is a function to create protocol payment message
|
|
94
|
+
* @param {DID} sender - sender did
|
|
95
|
+
* @param {DID} receiver - receiver did
|
|
96
|
+
* @param {string} agent - agent URL
|
|
97
|
+
* @param {Signer} signer - receiver did
|
|
98
|
+
* @param payments - payment options
|
|
99
|
+
* @returns {Promise<PaymentRequestMessage>}
|
|
100
|
+
*/
|
|
101
|
+
createPaymentRailsV1(sender: DID, receiver: DID, agent: string, signer: Signer, payments: PaymentRailsInfo[]): Promise<PaymentRequestMessage>;
|
|
54
102
|
}
|
|
55
103
|
/** @beta PaymentRequestMessageHandlerOptions represents payment-request handler options */
|
|
56
|
-
export type PaymentRequestMessageHandlerOptions = {
|
|
57
|
-
paymentHandler: (data:
|
|
104
|
+
export type PaymentRequestMessageHandlerOptions = BasicHandlerOptions & {
|
|
105
|
+
paymentHandler: (data: PaymentRequestTypeUnion) => Promise<string>;
|
|
106
|
+
nonce: string;
|
|
107
|
+
erc20TokenApproveHandler?: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>;
|
|
58
108
|
};
|
|
59
109
|
/** @beta PaymentHandlerOptions represents payment handler options */
|
|
60
|
-
export type PaymentHandlerOptions = {
|
|
110
|
+
export type PaymentHandlerOptions = BasicHandlerOptions & {
|
|
61
111
|
paymentRequest: PaymentRequestMessage;
|
|
62
|
-
paymentValidationHandler: (txId: string, data:
|
|
112
|
+
paymentValidationHandler: (txId: string, data: PaymentRequestTypeUnion) => Promise<void>;
|
|
63
113
|
};
|
|
64
114
|
/** @beta PaymentHandlerParams represents payment handler params */
|
|
65
115
|
export type PaymentHandlerParams = {
|
|
66
116
|
packerParams: PackerParams;
|
|
117
|
+
documentResolver: Resolvable;
|
|
118
|
+
multiChainPaymentConfig?: MultiChainPaymentConfig[];
|
|
119
|
+
allowedSigners?: string[];
|
|
67
120
|
};
|
|
68
121
|
/**
|
|
69
122
|
*
|
|
@@ -95,6 +148,13 @@ export declare class PaymentHandler extends AbstractMessageHandler implements IP
|
|
|
95
148
|
/**
|
|
96
149
|
* @inheritdoc IPaymentHandler#handlePayment
|
|
97
150
|
*/
|
|
98
|
-
handlePayment(payment: PaymentMessage,
|
|
151
|
+
handlePayment(payment: PaymentMessage, params: PaymentHandlerOptions): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* @inheritdoc IPaymentHandler#createPaymentRailsV1
|
|
154
|
+
*/
|
|
155
|
+
createPaymentRailsV1(sender: DID, receiver: DID, agent: string, signer: Signer, payments: PaymentRailsInfo[]): Promise<PaymentRequestMessage>;
|
|
99
156
|
private packMessage;
|
|
157
|
+
private handleIden3PaymentRequestCryptoV1;
|
|
158
|
+
private handleIden3PaymentRailsRequestV1;
|
|
159
|
+
private handleIden3PaymentRailsERC20RequestV1;
|
|
100
160
|
}
|
|
@@ -3,7 +3,7 @@ import { BasicMessage, IPackageManager, JWSPackerParams, RevocationStatusRequest
|
|
|
3
3
|
import { DID } from '@iden3/js-iden3-core';
|
|
4
4
|
import { TreeState } from '../../circuits';
|
|
5
5
|
import { IIdentityWallet } from '../../identity';
|
|
6
|
-
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
6
|
+
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
7
7
|
/**
|
|
8
8
|
* Defines the options for a RevocationStatusMessageHandler.
|
|
9
9
|
* @property senderDid - The DID (Decentralized Identifier) to be used.
|
|
@@ -39,7 +39,7 @@ export interface IRevocationStatusHandler {
|
|
|
39
39
|
handleRevocationStatusRequest(did: DID, request: Uint8Array, opts?: RevocationStatusHandlerOptions): Promise<Uint8Array>;
|
|
40
40
|
}
|
|
41
41
|
/** RevocationStatusHandlerOptions represents revocation status handler options */
|
|
42
|
-
export type RevocationStatusHandlerOptions = {
|
|
42
|
+
export type RevocationStatusHandlerOptions = BasicHandlerOptions & {
|
|
43
43
|
mediaType: MediaType;
|
|
44
44
|
packerOptions?: JWSPackerParams;
|
|
45
45
|
treeState?: TreeState;
|
|
@@ -13,6 +13,10 @@ export declare class PackageManager implements IPackageManager {
|
|
|
13
13
|
* Creates an instance of PackageManager.
|
|
14
14
|
*/
|
|
15
15
|
constructor();
|
|
16
|
+
/** {@inheritDoc IPackageManager.isProfileSupported} */
|
|
17
|
+
isProfileSupported(mediaType: MediaType, profile: string): boolean;
|
|
18
|
+
/** {@inheritDoc IPackageManager.getSupportedMediaTypes} */
|
|
19
|
+
getSupportedMediaTypes(): MediaType[];
|
|
16
20
|
/** {@inheritDoc IPackageManager.registerPackers} */
|
|
17
21
|
registerPackers(packers: Array<IPacker>): void;
|
|
18
22
|
/** {@inheritDoc IPackageManager.pack} */
|
|
@@ -44,6 +44,11 @@ export declare class JWSPacker implements IPacker {
|
|
|
44
44
|
*/
|
|
45
45
|
unpack(envelope: Uint8Array): Promise<BasicMessage>;
|
|
46
46
|
mediaType(): MediaType;
|
|
47
|
+
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
48
|
+
getSupportedProfiles(): string[];
|
|
49
|
+
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
50
|
+
isProfileSupported(profile: string): boolean;
|
|
51
|
+
private getSupportedAlgorithms;
|
|
47
52
|
private resolveDidDoc;
|
|
48
53
|
private packInternal;
|
|
49
54
|
}
|
|
@@ -38,4 +38,8 @@ export declare class PlainPacker implements IPacker {
|
|
|
38
38
|
* @returns MediaType
|
|
39
39
|
*/
|
|
40
40
|
mediaType(): MediaType;
|
|
41
|
+
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
42
|
+
getSupportedProfiles(): string[];
|
|
43
|
+
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
44
|
+
isProfileSupported(profile: string): boolean;
|
|
41
45
|
}
|
|
@@ -87,4 +87,10 @@ export declare class ZKPPacker implements IPacker {
|
|
|
87
87
|
*/
|
|
88
88
|
unpack(envelope: Uint8Array): Promise<BasicMessage>;
|
|
89
89
|
mediaType(): MediaType;
|
|
90
|
+
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
91
|
+
getSupportedProfiles(): string[];
|
|
92
|
+
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
93
|
+
isProfileSupported(profile: string): boolean;
|
|
94
|
+
private getSupportedAlgorithms;
|
|
95
|
+
private getSupportedCircuitIds;
|
|
90
96
|
}
|
|
@@ -6,6 +6,7 @@ export * from './protocol/revocation';
|
|
|
6
6
|
export * from './protocol/contract-request';
|
|
7
7
|
export * from './protocol/proposal-request';
|
|
8
8
|
export * from './protocol/payment';
|
|
9
|
+
export * from './protocol/accept-profile';
|
|
9
10
|
export * from './packer';
|
|
10
11
|
export * from './models';
|
|
11
12
|
export * from './packageManager';
|
|
@@ -64,6 +64,20 @@ export interface IPackageManager {
|
|
|
64
64
|
* @returns MediaType
|
|
65
65
|
*/
|
|
66
66
|
getMediaType(envelope: string): MediaType;
|
|
67
|
+
/**
|
|
68
|
+
* gets supported media types by packer manager
|
|
69
|
+
*
|
|
70
|
+
* @returns MediaType[]
|
|
71
|
+
*/
|
|
72
|
+
getSupportedMediaTypes(): MediaType[];
|
|
73
|
+
/**
|
|
74
|
+
* returns true if media type and algorithms supported by packer manager
|
|
75
|
+
*
|
|
76
|
+
* @param {MediaType} mediaType
|
|
77
|
+
* @param {string} profile
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
isProfileSupported(mediaType: MediaType, profile: string): boolean;
|
|
67
81
|
}
|
|
68
82
|
/**
|
|
69
83
|
* EnvelopeStub is used to stub the jwt based envelops
|
|
@@ -29,6 +29,9 @@ export type JsonDocumentObject = {
|
|
|
29
29
|
* JSON document object allowed values
|
|
30
30
|
*/
|
|
31
31
|
export type JsonDocumentObjectValue = string | number | boolean | JsonDocumentObject | JsonDocumentObjectValue[];
|
|
32
|
+
/**
|
|
33
|
+
* Basic message with all possible fields optional
|
|
34
|
+
*/
|
|
32
35
|
export type BasicMessage = {
|
|
33
36
|
id: string;
|
|
34
37
|
typ?: MediaType;
|
|
@@ -37,6 +40,15 @@ export type BasicMessage = {
|
|
|
37
40
|
body?: unknown;
|
|
38
41
|
from?: string;
|
|
39
42
|
to?: string;
|
|
43
|
+
created_time?: number;
|
|
44
|
+
expires_time?: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Basic message with all possible fields required
|
|
48
|
+
*/
|
|
49
|
+
export type RequiredBasicMessage = Omit<Required<BasicMessage>, 'created_time' | 'expires_time'> & {
|
|
50
|
+
created_time?: number;
|
|
51
|
+
expires_time?: number;
|
|
40
52
|
};
|
|
41
53
|
/**
|
|
42
54
|
* parameters for any packer
|
|
@@ -111,6 +123,19 @@ export interface IPacker {
|
|
|
111
123
|
* @returns The media type as a MediaType.
|
|
112
124
|
*/
|
|
113
125
|
mediaType(): MediaType;
|
|
126
|
+
/**
|
|
127
|
+
* gets packer envelope (supported profiles) with options
|
|
128
|
+
*
|
|
129
|
+
* @returns {string}
|
|
130
|
+
*/
|
|
131
|
+
getSupportedProfiles(): string[];
|
|
132
|
+
/**
|
|
133
|
+
* returns true if profile is supported by packer
|
|
134
|
+
*
|
|
135
|
+
* @param {string} profile
|
|
136
|
+
* @returns {boolean}
|
|
137
|
+
*/
|
|
138
|
+
isProfileSupported(profile: string): boolean;
|
|
114
139
|
}
|
|
115
140
|
/**
|
|
116
141
|
* Params for verification of auth circuit public signals
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AcceptAuthCircuits, AcceptJwsAlgorithms, AcceptJwzAlgorithms, MediaType, ProtocolVersion } from '../../constants';
|
|
2
|
+
export type AcceptProfile = {
|
|
3
|
+
protocolVersion: ProtocolVersion;
|
|
4
|
+
env: MediaType;
|
|
5
|
+
circuits?: AcceptAuthCircuits[];
|
|
6
|
+
alg?: AcceptJwsAlgorithms[] | AcceptJwzAlgorithms[];
|
|
7
|
+
};
|
|
@@ -31,6 +31,7 @@ export type AuthorizationRequestMessageBody = {
|
|
|
31
31
|
message?: string;
|
|
32
32
|
did_doc?: DIDDocument;
|
|
33
33
|
scope: Array<ZeroKnowledgeProofRequest>;
|
|
34
|
+
accept?: string[];
|
|
34
35
|
};
|
|
35
36
|
/** ZeroKnowledgeProofRequest represents structure of zkp request object */
|
|
36
37
|
export type ZeroKnowledgeProofRequest = {
|