@0xpolygonid/js-sdk 1.21.3 → 1.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/browser/esm/index.js +4378 -545
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +4388 -545
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/credentials/credential-wallet.js +11 -78
  6. package/dist/node/cjs/credentials/index.js +1 -0
  7. package/dist/node/cjs/credentials/status/did-resolver-revocation.js +21 -0
  8. package/dist/node/cjs/iden3comm/constants.js +25 -1
  9. package/dist/node/cjs/iden3comm/handlers/auth.js +52 -8
  10. package/dist/node/cjs/iden3comm/handlers/common.js +13 -1
  11. package/dist/node/cjs/iden3comm/handlers/contract-request.js +5 -1
  12. package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +14 -3
  13. package/dist/node/cjs/iden3comm/handlers/fetch.js +44 -2
  14. package/dist/node/cjs/iden3comm/handlers/message-handler.js +4 -0
  15. package/dist/node/cjs/iden3comm/handlers/payment.js +265 -28
  16. package/dist/node/cjs/iden3comm/handlers/revocation-status.js +4 -0
  17. package/dist/node/cjs/iden3comm/index.js +1 -0
  18. package/dist/node/cjs/iden3comm/packageManager.js +12 -0
  19. package/dist/node/cjs/iden3comm/packers/jws.js +21 -0
  20. package/dist/node/cjs/iden3comm/packers/plain.js +19 -0
  21. package/dist/node/cjs/iden3comm/packers/zkp.js +25 -0
  22. package/dist/node/cjs/iden3comm/types/index.js +1 -0
  23. package/dist/node/cjs/iden3comm/types/protocol/accept-profile.js +2 -0
  24. package/dist/node/cjs/iden3comm/utils/accept-profile.js +107 -0
  25. package/dist/node/cjs/iden3comm/utils/index.js +1 -0
  26. package/dist/node/cjs/storage/blockchain/abi/ERC20.json +1 -0
  27. package/dist/node/cjs/storage/blockchain/abi/ERC20Permit.json +1 -0
  28. package/dist/node/cjs/storage/blockchain/did-resolver-readonly-storage.js +72 -0
  29. package/dist/node/cjs/storage/blockchain/erc20-helper.js +59 -0
  30. package/dist/node/cjs/storage/blockchain/index.js +3 -0
  31. package/dist/node/cjs/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +245 -0
  32. package/dist/node/cjs/storage/blockchain/onchain-issuer.js +82 -0
  33. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +38 -34
  34. package/dist/node/cjs/storage/interfaces/index.js +1 -0
  35. package/dist/node/cjs/storage/interfaces/onchain-issuer.js +2 -0
  36. package/dist/node/cjs/utils/did-helper.js +3 -3
  37. package/dist/node/cjs/verifiable/constants.js +29 -11
  38. package/dist/node/cjs/verifiable/credential.js +86 -0
  39. package/dist/node/esm/credentials/credential-wallet.js +12 -79
  40. package/dist/node/esm/credentials/index.js +1 -0
  41. package/dist/node/esm/credentials/status/did-resolver-revocation.js +17 -0
  42. package/dist/node/esm/iden3comm/constants.js +24 -0
  43. package/dist/node/esm/iden3comm/handlers/auth.js +55 -11
  44. package/dist/node/esm/iden3comm/handlers/common.js +11 -0
  45. package/dist/node/esm/iden3comm/handlers/contract-request.js +7 -3
  46. package/dist/node/esm/iden3comm/handlers/credential-proposal.js +15 -4
  47. package/dist/node/esm/iden3comm/handlers/fetch.js +44 -2
  48. package/dist/node/esm/iden3comm/handlers/message-handler.js +4 -0
  49. package/dist/node/esm/iden3comm/handlers/payment.js +264 -29
  50. package/dist/node/esm/iden3comm/handlers/revocation-status.js +4 -0
  51. package/dist/node/esm/iden3comm/index.js +1 -0
  52. package/dist/node/esm/iden3comm/packageManager.js +12 -0
  53. package/dist/node/esm/iden3comm/packers/jws.js +22 -1
  54. package/dist/node/esm/iden3comm/packers/plain.js +19 -0
  55. package/dist/node/esm/iden3comm/packers/zkp.js +26 -1
  56. package/dist/node/esm/iden3comm/types/index.js +1 -0
  57. package/dist/node/esm/iden3comm/types/protocol/accept-profile.js +1 -0
  58. package/dist/node/esm/iden3comm/utils/accept-profile.js +102 -0
  59. package/dist/node/esm/iden3comm/utils/index.js +1 -0
  60. package/dist/node/esm/storage/blockchain/abi/ERC20.json +1 -0
  61. package/dist/node/esm/storage/blockchain/abi/ERC20Permit.json +1 -0
  62. package/dist/node/esm/storage/blockchain/did-resolver-readonly-storage.js +68 -0
  63. package/dist/node/esm/storage/blockchain/erc20-helper.js +51 -0
  64. package/dist/node/esm/storage/blockchain/index.js +3 -0
  65. package/dist/node/esm/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +241 -0
  66. package/dist/node/esm/storage/blockchain/onchain-issuer.js +78 -0
  67. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +38 -34
  68. package/dist/node/esm/storage/interfaces/index.js +1 -0
  69. package/dist/node/esm/storage/interfaces/onchain-issuer.js +1 -0
  70. package/dist/node/esm/utils/did-helper.js +3 -3
  71. package/dist/node/esm/verifiable/constants.js +28 -10
  72. package/dist/node/esm/verifiable/credential.js +88 -2
  73. package/dist/types/credentials/credential-wallet.d.ts +0 -6
  74. package/dist/types/credentials/index.d.ts +1 -0
  75. package/dist/types/credentials/models.d.ts +8 -0
  76. package/dist/types/credentials/status/did-resolver-revocation.d.ts +7 -0
  77. package/dist/types/iden3comm/constants.d.ts +16 -0
  78. package/dist/types/iden3comm/handlers/auth.d.ts +19 -7
  79. package/dist/types/iden3comm/handlers/common.d.ts +7 -1
  80. package/dist/types/iden3comm/handlers/contract-request.d.ts +2 -2
  81. package/dist/types/iden3comm/handlers/credential-proposal.d.ts +9 -4
  82. package/dist/types/iden3comm/handlers/fetch.d.ts +30 -6
  83. package/dist/types/iden3comm/handlers/message-handler.d.ts +6 -0
  84. package/dist/types/iden3comm/handlers/payment.d.ts +71 -10
  85. package/dist/types/iden3comm/handlers/revocation-status.d.ts +2 -2
  86. package/dist/types/iden3comm/index.d.ts +1 -0
  87. package/dist/types/iden3comm/packageManager.d.ts +4 -0
  88. package/dist/types/iden3comm/packers/jws.d.ts +5 -0
  89. package/dist/types/iden3comm/packers/plain.d.ts +4 -0
  90. package/dist/types/iden3comm/packers/zkp.d.ts +6 -0
  91. package/dist/types/iden3comm/types/index.d.ts +1 -0
  92. package/dist/types/iden3comm/types/packageManager.d.ts +14 -0
  93. package/dist/types/iden3comm/types/packer.d.ts +25 -0
  94. package/dist/types/iden3comm/types/protocol/accept-profile.d.ts +7 -0
  95. package/dist/types/iden3comm/types/protocol/auth.d.ts +1 -0
  96. package/dist/types/iden3comm/types/protocol/credentials.d.ts +6 -6
  97. package/dist/types/iden3comm/types/protocol/messages.d.ts +2 -2
  98. package/dist/types/iden3comm/types/protocol/payment.d.ts +87 -13
  99. package/dist/types/iden3comm/types/protocol/proof.d.ts +3 -3
  100. package/dist/types/iden3comm/types/protocol/revocation.d.ts +2 -2
  101. package/dist/types/iden3comm/utils/accept-profile.d.ts +3 -0
  102. package/dist/types/iden3comm/utils/index.d.ts +1 -0
  103. package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts +16 -0
  104. package/dist/types/storage/blockchain/erc20-helper.d.ts +19 -0
  105. package/dist/types/storage/blockchain/index.d.ts +3 -0
  106. package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts +66 -0
  107. package/dist/types/storage/blockchain/onchain-issuer.d.ts +40 -0
  108. package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +11 -12
  109. package/dist/types/storage/entities/state.d.ts +2 -0
  110. package/dist/types/storage/interfaces/index.d.ts +1 -0
  111. package/dist/types/storage/interfaces/onchain-issuer.d.ts +12 -0
  112. package/dist/types/verifiable/constants.d.ts +28 -11
  113. package/dist/types/verifiable/credential.d.ts +15 -2
  114. package/package.json +3 -2
@@ -2,7 +2,8 @@ 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
+ import { IOnchainIssuer } from '../../storage';
6
7
  /**
7
8
  *
8
9
  * Options to pass to fetch handler
@@ -10,13 +11,29 @@ import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handl
10
11
  * @public
11
12
  * @interface FetchHandlerOptions
12
13
  */
13
- export type FetchHandlerOptions = {
14
+ export type FetchHandlerOptions = BasicHandlerOptions & {
14
15
  mediaType: MediaType;
15
16
  packerOptions?: JWSPackerParams;
16
17
  headers?: {
17
18
  [key: string]: string;
18
19
  };
19
20
  };
21
+ /**
22
+ *
23
+ * Options to pass to fetch request handler
24
+ *
25
+ * @public
26
+ * @interface FetchRequestOptions
27
+ */
28
+ export type FetchRequestOptions = BasicHandlerOptions;
29
+ /**
30
+ *
31
+ * Options to pass to issuance response handler
32
+ *
33
+ * @public
34
+ * @interface IssuanceResponseOptions
35
+ */
36
+ export type IssuanceResponseOptions = BasicHandlerOptions;
20
37
  export type FetchMessageHandlerOptions = FetchHandlerOptions;
21
38
  /**
22
39
  * Interface that allows the processing of the credential offer in the raw format for given identifier
@@ -44,7 +61,7 @@ export interface IFetchHandler {
44
61
  * @returns A promise that resolves to the response message.
45
62
  * @throws An error if the request is invalid or if the credential is not found.
46
63
  */
47
- handleCredentialFetchRequest(basicMessage: Uint8Array): Promise<Uint8Array>;
64
+ handleCredentialFetchRequest(basicMessage: Uint8Array, opts?: FetchRequestOptions): Promise<Uint8Array>;
48
65
  /**
49
66
  * Handles the issuance response message.
50
67
  *
@@ -52,7 +69,7 @@ export interface IFetchHandler {
52
69
  * @returns A promise that resolves to a Uint8Array.
53
70
  * @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
71
  */
55
- handleIssuanceResponseMessage(basicMessage: Uint8Array): Promise<Uint8Array>;
72
+ handleIssuanceResponseMessage(basicMessage: Uint8Array, opts?: IssuanceResponseOptions): Promise<Uint8Array>;
56
73
  }
57
74
  /**
58
75
  *
@@ -75,8 +92,10 @@ export declare class FetchHandler extends AbstractMessageHandler implements IFet
75
92
  */
76
93
  constructor(_packerMgr: IPackageManager, opts?: {
77
94
  credentialWallet: ICredentialWallet;
95
+ onchainIssuer?: IOnchainIssuer | undefined;
78
96
  } | undefined);
79
97
  handle(message: BasicMessage, ctx: FetchMessageHandlerOptions): Promise<BasicMessage | null>;
98
+ private handleOnchainOfferMessage;
80
99
  private handleOfferMessage;
81
100
  /**
82
101
  * Handles only messages with credentials/1.0/offer type
@@ -88,16 +107,21 @@ export declare class FetchHandler extends AbstractMessageHandler implements IFet
88
107
  * @returns `Promise<W3CCredential[]>`
89
108
  */
90
109
  handleCredentialOffer(offer: Uint8Array, opts?: FetchHandlerOptions): Promise<W3CCredential[]>;
110
+ /**
111
+ * Handles only messages with credentials/1.0/onchain-offer type
112
+ * @beta
113
+ */
114
+ handleOnchainOffer(offer: Uint8Array): Promise<W3CCredential[]>;
91
115
  private handleFetchRequest;
92
116
  /**
93
117
  * @inheritdoc IFetchHandler#handleCredentialFetchRequest
94
118
  */
95
- handleCredentialFetchRequest(envelope: Uint8Array): Promise<Uint8Array>;
119
+ handleCredentialFetchRequest(envelope: Uint8Array, opts?: FetchRequestOptions): Promise<Uint8Array>;
96
120
  private handleIssuanceResponseMsg;
97
121
  /**
98
122
  * @inheritdoc IFetchHandler#handleIssuanceResponseMessage
99
123
  */
100
- handleIssuanceResponseMessage(envelop: Uint8Array): Promise<Uint8Array>;
124
+ handleIssuanceResponseMessage(envelop: Uint8Array, opts?: IssuanceResponseOptions): Promise<Uint8Array>;
101
125
  /**
102
126
  * @inheritdoc IFetchHandler#unpackMessage
103
127
  */
@@ -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 { PaymentInfo, PaymentMessage, PaymentRequestDataInfo, PaymentRequestInfo, PaymentRequestMessage } from '../types/protocol/payment';
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,43 @@ 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
+ export declare function convertPaymentAmount(amount: string, currency: SupportedCurrencies): Promise<bigint>;
28
+ /**
29
+ * @beta
30
+ * PaymentRailsInfo represents payment info for payment rails
31
+ */
32
+ export type PaymentRailsInfo = {
33
+ credentials: {
34
+ type: string;
35
+ context: string;
36
+ }[];
37
+ description?: string;
38
+ chains: PaymentRailsChainInfo[];
39
+ };
40
+ /**
41
+ * @beta
42
+ * PaymentRailsChainInfo represents chain info for payment rails
43
+ */
44
+ export type PaymentRailsChainInfo = {
45
+ nonce: bigint;
46
+ amount: string;
47
+ currency: SupportedCurrencies | string;
48
+ chainId: string;
49
+ expirationDate?: Date;
50
+ features?: PaymentFeatures[];
51
+ type: PaymentRequestDataType.Iden3PaymentRailsRequestV1 | PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1;
52
+ };
15
53
  /**
16
54
  * @beta
17
55
  * createPayment is a function to create protocol payment message
18
56
  * @param {DID} sender - sender did
19
57
  * @param {DID} receiver - receiver did
20
- * @param {PaymentInfo[]} payments - payments
58
+ * @param {PaymentMessageBody} body - payments
21
59
  * @returns `PaymentMessage`
22
60
  */
23
- export declare function createPayment(sender: DID, receiver: DID, payments: PaymentInfo[]): PaymentMessage;
61
+ export declare function createPayment(sender: DID, receiver: DID, payments: PaymentTypeUnion[], opts?: PaymentCreationOptions): PaymentMessage;
24
62
  /**
25
63
  * @beta
26
64
  * Interface that allows the processing of the payment-request and payment protocol messages
@@ -51,19 +89,35 @@ export interface IPaymentHandler {
51
89
  * @returns `Promise<void>`
52
90
  */
53
91
  handlePayment(payment: PaymentMessage, opts: PaymentHandlerOptions): Promise<void>;
92
+ /**
93
+ * @beta
94
+ * createPaymentRailsV1 is a function to create protocol payment message
95
+ * @param {DID} sender - sender did
96
+ * @param {DID} receiver - receiver did
97
+ * @param {string} agent - agent URL
98
+ * @param {Signer} signer - receiver did
99
+ * @param payments - payment options
100
+ * @returns {Promise<PaymentRequestMessage>}
101
+ */
102
+ createPaymentRailsV1(sender: DID, receiver: DID, agent: string, signer: Signer, payments: PaymentRailsInfo[]): Promise<PaymentRequestMessage>;
54
103
  }
55
104
  /** @beta PaymentRequestMessageHandlerOptions represents payment-request handler options */
56
- export type PaymentRequestMessageHandlerOptions = {
57
- paymentHandler: (data: PaymentRequestDataInfo) => Promise<string>;
105
+ export type PaymentRequestMessageHandlerOptions = BasicHandlerOptions & {
106
+ paymentHandler: (data: PaymentRequestTypeUnion) => Promise<string>;
107
+ nonce: string;
108
+ erc20TokenApproveHandler?: (data: Iden3PaymentRailsERC20RequestV1) => Promise<string>;
58
109
  };
59
110
  /** @beta PaymentHandlerOptions represents payment handler options */
60
- export type PaymentHandlerOptions = {
111
+ export type PaymentHandlerOptions = BasicHandlerOptions & {
61
112
  paymentRequest: PaymentRequestMessage;
62
- paymentValidationHandler: (txId: string, data: PaymentRequestDataInfo) => Promise<void>;
113
+ paymentValidationHandler: (txId: string, data: PaymentRequestTypeUnion) => Promise<void>;
63
114
  };
64
115
  /** @beta PaymentHandlerParams represents payment handler params */
65
116
  export type PaymentHandlerParams = {
66
117
  packerParams: PackerParams;
118
+ documentResolver: Resolvable;
119
+ multiChainPaymentConfig?: MultiChainPaymentConfig[];
120
+ allowedSigners?: string[];
67
121
  };
68
122
  /**
69
123
  *
@@ -95,6 +149,13 @@ export declare class PaymentHandler extends AbstractMessageHandler implements IP
95
149
  /**
96
150
  * @inheritdoc IPaymentHandler#handlePayment
97
151
  */
98
- handlePayment(payment: PaymentMessage, opts: PaymentHandlerOptions): Promise<void>;
152
+ handlePayment(payment: PaymentMessage, params: PaymentHandlerOptions): Promise<void>;
153
+ /**
154
+ * @inheritdoc IPaymentHandler#createPaymentRailsV1
155
+ */
156
+ createPaymentRailsV1(sender: DID, receiver: DID, agent: string, signer: Signer, payments: PaymentRailsInfo[]): Promise<PaymentRequestMessage>;
99
157
  private packMessage;
158
+ private handleIden3PaymentRequestCryptoV1;
159
+ private handleIden3PaymentRailsRequestV1;
160
+ private handleIden3PaymentRailsERC20RequestV1;
100
161
  }
@@ -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;
@@ -3,5 +3,6 @@ export * from './packers';
3
3
  export * from './types';
4
4
  export * from './handlers';
5
5
  export * from './utils/did';
6
+ export * from './utils/accept-profile';
6
7
  import * as PROTOCOL_CONSTANTS from './constants';
7
8
  export { PROTOCOL_CONSTANTS };
@@ -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 = {
@@ -1,6 +1,6 @@
1
1
  import { W3CCredential } from '../../../verifiable';
2
2
  import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
3
- import { BasicMessage, JsonDocumentObject } from '../packer';
3
+ import { BasicMessage, JsonDocumentObject, RequiredBasicMessage } from '../packer';
4
4
  import { ContractInvokeTransactionData } from './contract-request';
5
5
  /** CredentialIssuanceRequestMessageBody represents data for credential issuance request */
6
6
  export type CredentialIssuanceRequestMessageBody = {
@@ -9,12 +9,12 @@ export type CredentialIssuanceRequestMessageBody = {
9
9
  expiration: number;
10
10
  };
11
11
  /** CredentialIssuanceRequestMessage represent Iden3message for credential request */
12
- export type CredentialIssuanceRequestMessage = Required<BasicMessage> & {
12
+ export type CredentialIssuanceRequestMessage = RequiredBasicMessage & {
13
13
  body: CredentialIssuanceRequestMessageBody;
14
14
  type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE;
15
15
  };
16
16
  /** CredentialsOfferMessage represent Iden3message for credential offer */
17
- export type CredentialsOfferMessage = Required<BasicMessage> & {
17
+ export type CredentialsOfferMessage = RequiredBasicMessage & {
18
18
  body: CredentialsOfferMessageBody;
19
19
  type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_OFFER_MESSAGE_TYPE;
20
20
  };
@@ -24,7 +24,7 @@ export type CredentialsOfferMessageBody = {
24
24
  credentials: CredentialOffer[];
25
25
  };
26
26
  /** CredentialsOnchainOfferMessage represent Iden3message for credential onchain offer message */
27
- export type CredentialsOnchainOfferMessage = Required<BasicMessage> & {
27
+ export type CredentialsOnchainOfferMessage = RequiredBasicMessage & {
28
28
  body: CredentialsOnchainOfferMessageBody;
29
29
  type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE;
30
30
  };
@@ -46,7 +46,7 @@ export type CredentialOffer = {
46
46
  status?: CredentialOfferStatus;
47
47
  };
48
48
  /** CredentialIssuanceMessage represent Iden3message for credential issuance */
49
- export type CredentialIssuanceMessage = Required<BasicMessage> & {
49
+ export type CredentialIssuanceMessage = RequiredBasicMessage & {
50
50
  body: IssuanceMessageBody;
51
51
  type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE;
52
52
  };
@@ -70,7 +70,7 @@ export type Schema = {
70
70
  type: string;
71
71
  };
72
72
  /** CredentialRefreshMessage represent Iden3message for credential refresh request */
73
- export type CredentialRefreshMessage = Required<BasicMessage> & {
73
+ export type CredentialRefreshMessage = RequiredBasicMessage & {
74
74
  body: CredentialRefreshMessageBody;
75
75
  type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE;
76
76
  };
@@ -1,7 +1,7 @@
1
- import { BasicMessage } from '../';
1
+ import { RequiredBasicMessage } from '../';
2
2
  import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
3
3
  /** MessageFetchRequestMessage represent Iden3message for message fetch request. */
4
- export type MessageFetchRequestMessage = Required<BasicMessage> & {
4
+ export type MessageFetchRequestMessage = RequiredBasicMessage & {
5
5
  body: MessageFetchRequestMessageBody;
6
6
  type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE;
7
7
  };
@@ -1,5 +1,5 @@
1
1
  import { BasicMessage } from '../';
2
- import { PaymentRequestDataType, PaymentRequestType, PaymentType, SupportedCurrencies } from '../../../verifiable';
2
+ import { PaymentFeatures, PaymentRequestDataType, SupportedCurrencies, SupportedPaymentProofType } from '../../../verifiable';
3
3
  import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
4
4
  /** @beta PaymentRequestMessage is struct the represents payment-request message */
5
5
  export type PaymentRequestMessage = BasicMessage & {
@@ -17,20 +17,52 @@ export type PaymentRequestInfo = {
17
17
  type: string;
18
18
  context: string;
19
19
  }[];
20
- type: PaymentRequestType;
21
- data: PaymentRequestDataInfo;
22
- expiration?: string;
20
+ data: Iden3PaymentRequestCryptoV1 | (Iden3PaymentRequestCryptoV1 | Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1)[];
23
21
  description?: string;
24
22
  };
25
- /** @beta PaymentRequestDataInfo is struct the represents payment data info for payment-request */
26
- export type PaymentRequestDataInfo = {
27
- type: PaymentRequestDataType;
23
+ /** @beta Iden3PaymentRequestCryptoV1 is struct the represents payment data info for payment-request */
24
+ export type Iden3PaymentRequestCryptoV1 = {
25
+ type: PaymentRequestDataType.Iden3PaymentRequestCryptoV1;
26
+ '@context'?: string | (string | object)[];
28
27
  amount: string;
29
28
  id: string;
30
29
  chainId: string;
31
30
  address: string;
32
- currency: SupportedCurrencies;
33
- signature?: string;
31
+ currency: SupportedCurrencies | string;
32
+ expiration?: string;
33
+ };
34
+ export type Iden3PaymentRailsRequestV1 = {
35
+ type: PaymentRequestDataType.Iden3PaymentRailsRequestV1;
36
+ '@context': string | (string | object)[];
37
+ recipient: string;
38
+ amount: string;
39
+ currency: SupportedCurrencies | string;
40
+ expirationDate: string;
41
+ nonce: string;
42
+ metadata: string;
43
+ proof: EthereumEip712Signature2021 | EthereumEip712Signature2021[];
44
+ };
45
+ export type Iden3PaymentRailsERC20RequestV1 = Omit<Required<Iden3PaymentRailsRequestV1>, 'type'> & {
46
+ tokenAddress: string;
47
+ features?: PaymentFeatures[];
48
+ type: PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1;
49
+ };
50
+ export type EthereumEip712Signature2021 = {
51
+ type: SupportedPaymentProofType.EthereumEip712Signature2021;
52
+ proofPurpose: string;
53
+ proofValue: string;
54
+ verificationMethod: string;
55
+ created: string;
56
+ eip712: {
57
+ types: string;
58
+ primaryType: string;
59
+ domain: {
60
+ name: string;
61
+ version: string;
62
+ chainId: string;
63
+ verifyingContract: string;
64
+ };
65
+ };
34
66
  };
35
67
  /** @beta PaymentMessage is struct the represents payment message */
36
68
  export type PaymentMessage = BasicMessage & {
@@ -39,13 +71,55 @@ export type PaymentMessage = BasicMessage & {
39
71
  };
40
72
  /** @beta PaymentMessageBody is struct the represents body for payment message */
41
73
  export type PaymentMessageBody = {
42
- payments: PaymentInfo[];
74
+ payments: PaymentTypeUnion[];
43
75
  };
44
- /** @beta PaymentInfo is struct the represents payment info for payment */
45
- export type PaymentInfo = {
76
+ /** @beta Iden3PaymentCryptoV1 is struct the represents payment info for payment */
77
+ export type Iden3PaymentCryptoV1 = {
46
78
  id: string;
47
- type: PaymentType;
79
+ type: 'Iden3PaymentCryptoV1';
80
+ '@context'?: string | (string | object)[];
81
+ paymentData: {
82
+ txId: string;
83
+ };
84
+ };
85
+ /** @beta Iden3PaymentRailsV1 is struct the represents payment info for Iden3PaymentRailsRequestV1 */
86
+ export type Iden3PaymentRailsV1 = {
87
+ nonce: string;
88
+ type: 'Iden3PaymentRailsV1';
89
+ '@context': string | (string | object)[];
48
90
  paymentData: {
49
91
  txId: string;
92
+ chainId: string;
50
93
  };
51
94
  };
95
+ /** @beta Iden3PaymentRailsERC20V1 is struct the represents payment info for Iden3PaymentRailsERC20RequestV1 */
96
+ export type Iden3PaymentRailsERC20V1 = {
97
+ nonce: string;
98
+ type: 'Iden3PaymentRailsERC20V1';
99
+ '@context': string | (string | object)[];
100
+ paymentData: {
101
+ txId: string;
102
+ chainId: string;
103
+ tokenAddress: string;
104
+ };
105
+ };
106
+ /** @beta MultiChainPaymentConfig is struct that represents payments contracts information for different chains */
107
+ export type MultiChainPaymentConfig = {
108
+ chainId: string;
109
+ paymentContract: string;
110
+ recipient: string;
111
+ erc20TokenAddressArr: {
112
+ symbol: string;
113
+ address: string;
114
+ }[];
115
+ };
116
+ /**
117
+ * @beta
118
+ * PaymentRequestTypeUnion is a type of supported payment request types
119
+ */
120
+ export type PaymentRequestTypeUnion = Iden3PaymentRequestCryptoV1 | Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1;
121
+ /**
122
+ * @beta
123
+ * PaymentTypeUnion is a type of supported payment types
124
+ */
125
+ export type PaymentTypeUnion = Iden3PaymentCryptoV1 | Iden3PaymentRailsV1 | Iden3PaymentRailsERC20V1;
@@ -1,8 +1,8 @@
1
- import { BasicMessage } from '../';
1
+ import { RequiredBasicMessage } from '../';
2
2
  import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
3
3
  import { ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from './auth';
4
4
  /** ProofGenerationRequestMessage is struct the represents body for proof generation request */
5
- export type ProofGenerationRequestMessage = Required<BasicMessage> & {
5
+ export type ProofGenerationRequestMessage = RequiredBasicMessage & {
6
6
  body: ProofGenerationRequestMessageBody;
7
7
  type: typeof PROTOCOL_MESSAGE_TYPE.PROOF_GENERATION_REQUEST_MESSAGE_TYPE;
8
8
  };
@@ -11,7 +11,7 @@ export type ProofGenerationRequestMessageBody = {
11
11
  scope: Array<ZeroKnowledgeProofRequest>;
12
12
  };
13
13
  /** ProofGenerationResponseMessage is struct the represents body for proof generation request */
14
- export type ProofGenerationResponseMessage = Required<BasicMessage> & {
14
+ export type ProofGenerationResponseMessage = RequiredBasicMessage & {
15
15
  body: ResponseMessageBody;
16
16
  type: typeof PROTOCOL_MESSAGE_TYPE.PROOF_GENERATION_RESPONSE_MESSAGE_TYPE;
17
17
  };
@@ -1,4 +1,4 @@
1
- import { BasicMessage } from '../';
1
+ import { BasicMessage, RequiredBasicMessage } from '../';
2
2
  import { RevocationStatus } from '../../../verifiable';
3
3
  import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
4
4
  /** RevocationStatusRequestMessage is struct the represents body for proof generation request */
@@ -11,7 +11,7 @@ export type RevocationStatusRequestMessageBody = {
11
11
  revocation_nonce: number;
12
12
  };
13
13
  /** RevocationStatusResponseMessage is struct the represents body for proof generation request */
14
- export type RevocationStatusResponseMessage = Required<BasicMessage> & {
14
+ export type RevocationStatusResponseMessage = RequiredBasicMessage & {
15
15
  body: RevocationStatusResponseMessageBody;
16
16
  type: typeof PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE;
17
17
  };
@@ -0,0 +1,3 @@
1
+ import { AcceptProfile } from '../types';
2
+ export declare const buildAccept: (profiles: AcceptProfile[]) => string[];
3
+ export declare const parseAcceptProfile: (profile: string) => AcceptProfile;
@@ -1,3 +1,4 @@
1
1
  export * from './envelope';
2
2
  export * from './message';
3
3
  export * from './did';
4
+ export * from './accept-profile';
@@ -0,0 +1,16 @@
1
+ import { RootInfo, StateInfo, StateProof } from '../entities';
2
+ import { IStateStorage } from '../interfaces';
3
+ import { JsonRpcProvider } from 'ethers';
4
+ export declare class DidResolverStateReadonlyStorage implements IStateStorage {
5
+ private readonly resolverUrl;
6
+ constructor(resolverUrl: string);
7
+ getLatestStateById(id: bigint): Promise<StateInfo>;
8
+ getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo>;
9
+ getGISTProof(id: bigint): Promise<StateProof>;
10
+ getGISTRootInfo(root: bigint, userId: bigint): Promise<RootInfo>;
11
+ getRpcProvider(): JsonRpcProvider;
12
+ publishState(): Promise<string>;
13
+ publishStateGeneric(): Promise<string>;
14
+ private getStateInfo;
15
+ private getIden3StateInfo2023;
16
+ }