@0xpolygonid/js-sdk 1.10.4 → 1.11.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.
Files changed (105) hide show
  1. package/README.md +11 -0
  2. package/dist/browser/esm/index.js +8360 -17398
  3. package/dist/browser/esm/index.js.map +1 -1
  4. package/dist/browser/umd/index.js +8381 -17414
  5. package/dist/browser/umd/index.js.map +1 -1
  6. package/dist/node/cjs/blockchain/index.js +17 -0
  7. package/dist/node/cjs/blockchain/transaction-service.js +55 -0
  8. package/dist/node/cjs/credentials/credential-wallet.js +1 -1
  9. package/dist/node/cjs/credentials/status/reverse-sparse-merkle-tree.js +5 -1
  10. package/dist/node/cjs/iden3comm/handlers/auth.js +62 -27
  11. package/dist/node/cjs/iden3comm/handlers/common.js +4 -4
  12. package/dist/node/cjs/iden3comm/handlers/contract-request.js +34 -15
  13. package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +33 -14
  14. package/dist/node/cjs/iden3comm/handlers/fetch.js +65 -34
  15. package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
  16. package/dist/node/cjs/iden3comm/handlers/message-handler.js +96 -0
  17. package/dist/node/cjs/iden3comm/handlers/revocation-status.js +58 -30
  18. package/dist/node/cjs/iden3comm/packageManager.js +16 -0
  19. package/dist/node/cjs/iden3comm/packers/jws.js +63 -49
  20. package/dist/node/cjs/iden3comm/packers/plain.js +13 -3
  21. package/dist/node/cjs/iden3comm/packers/zkp.js +9 -0
  22. package/dist/node/cjs/iden3comm/utils/did.js +11 -11
  23. package/dist/node/cjs/identity/identity-wallet.js +228 -43
  24. package/dist/node/cjs/index.js +1 -0
  25. package/dist/node/cjs/kms/key-providers/bjj-provider.js +9 -0
  26. package/dist/node/cjs/kms/key-providers/ed25519-provider.js +13 -1
  27. package/dist/node/cjs/kms/key-providers/index.js +1 -1
  28. package/dist/node/cjs/kms/key-providers/{sec256k1-provider.js → secp256k1-provider.js} +37 -26
  29. package/dist/node/cjs/kms/kms.js +15 -0
  30. package/dist/node/cjs/proof/proof-service.js +3 -33
  31. package/dist/node/cjs/proof/provers/inputs-generator.js +2 -7
  32. package/dist/node/cjs/storage/blockchain/onchain-revocation.js +4 -12
  33. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +3 -10
  34. package/dist/node/cjs/storage/blockchain/state.js +39 -10
  35. package/dist/node/cjs/utils/did-helper.js +36 -2
  36. package/dist/node/cjs/verifiable/constants.js +2 -1
  37. package/dist/node/esm/blockchain/index.js +1 -0
  38. package/dist/node/esm/blockchain/transaction-service.js +51 -0
  39. package/dist/node/esm/credentials/credential-wallet.js +1 -1
  40. package/dist/node/esm/credentials/status/reverse-sparse-merkle-tree.js +6 -2
  41. package/dist/node/esm/iden3comm/handlers/auth.js +62 -27
  42. package/dist/node/esm/iden3comm/handlers/common.js +4 -4
  43. package/dist/node/esm/iden3comm/handlers/contract-request.js +34 -15
  44. package/dist/node/esm/iden3comm/handlers/credential-proposal.js +33 -14
  45. package/dist/node/esm/iden3comm/handlers/fetch.js +65 -34
  46. package/dist/node/esm/iden3comm/handlers/index.js +1 -0
  47. package/dist/node/esm/iden3comm/handlers/message-handler.js +91 -0
  48. package/dist/node/esm/iden3comm/handlers/revocation-status.js +58 -30
  49. package/dist/node/esm/iden3comm/packageManager.js +16 -0
  50. package/dist/node/esm/iden3comm/packers/jws.js +63 -49
  51. package/dist/node/esm/iden3comm/packers/plain.js +13 -3
  52. package/dist/node/esm/iden3comm/packers/zkp.js +9 -0
  53. package/dist/node/esm/iden3comm/utils/did.js +11 -8
  54. package/dist/node/esm/identity/identity-wallet.js +230 -45
  55. package/dist/node/esm/index.js +1 -0
  56. package/dist/node/esm/kms/key-providers/bjj-provider.js +10 -1
  57. package/dist/node/esm/kms/key-providers/ed25519-provider.js +13 -1
  58. package/dist/node/esm/kms/key-providers/index.js +1 -1
  59. package/dist/node/esm/kms/key-providers/secp256k1-provider.js +85 -0
  60. package/dist/node/esm/kms/kms.js +15 -0
  61. package/dist/node/esm/proof/proof-service.js +4 -34
  62. package/dist/node/esm/proof/provers/inputs-generator.js +3 -8
  63. package/dist/node/esm/storage/blockchain/onchain-revocation.js +4 -12
  64. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +3 -10
  65. package/dist/node/esm/storage/blockchain/state.js +39 -10
  66. package/dist/node/esm/utils/did-helper.js +33 -1
  67. package/dist/node/esm/verifiable/constants.js +2 -1
  68. package/dist/types/blockchain/index.d.ts +1 -0
  69. package/dist/types/blockchain/transaction-service.d.ts +80 -0
  70. package/dist/types/iden3comm/handlers/auth.d.ts +17 -2
  71. package/dist/types/iden3comm/handlers/common.d.ts +2 -2
  72. package/dist/types/iden3comm/handlers/contract-request.d.ts +10 -2
  73. package/dist/types/iden3comm/handlers/credential-proposal.d.ts +5 -2
  74. package/dist/types/iden3comm/handlers/fetch.d.ts +15 -6
  75. package/dist/types/iden3comm/handlers/index.d.ts +1 -0
  76. package/dist/types/iden3comm/handlers/message-handler.d.ts +83 -0
  77. package/dist/types/iden3comm/handlers/revocation-status.d.ts +18 -2
  78. package/dist/types/iden3comm/packageManager.d.ts +10 -0
  79. package/dist/types/iden3comm/packers/jws.d.ts +9 -0
  80. package/dist/types/iden3comm/packers/plain.d.ts +10 -2
  81. package/dist/types/iden3comm/packers/zkp.d.ts +7 -0
  82. package/dist/types/iden3comm/types/packageManager.d.ts +10 -0
  83. package/dist/types/iden3comm/types/packer.d.ts +24 -2
  84. package/dist/types/iden3comm/types/protocol/auth.d.ts +5 -15
  85. package/dist/types/iden3comm/types/protocol/contract-request.d.ts +2 -6
  86. package/dist/types/iden3comm/types/protocol/credentials.d.ts +7 -44
  87. package/dist/types/iden3comm/types/protocol/messages.d.ts +2 -9
  88. package/dist/types/iden3comm/types/protocol/proof.d.ts +3 -16
  89. package/dist/types/iden3comm/types/protocol/revocation.d.ts +3 -16
  90. package/dist/types/identity/identity-wallet.d.ts +80 -7
  91. package/dist/types/index.d.ts +1 -0
  92. package/dist/types/kms/key-providers/bjj-provider.d.ts +1 -0
  93. package/dist/types/kms/key-providers/ed25519-provider.d.ts +8 -0
  94. package/dist/types/kms/key-providers/index.d.ts +1 -1
  95. package/dist/types/kms/key-providers/{sec256k1-provider.d.ts → secp256k1-provider.d.ts} +15 -9
  96. package/dist/types/kms/kms.d.ts +18 -0
  97. package/dist/types/proof/proof-service.d.ts +2 -2
  98. package/dist/types/storage/blockchain/onchain-revocation.d.ts +1 -0
  99. package/dist/types/storage/blockchain/state.d.ts +7 -2
  100. package/dist/types/storage/interfaces/state.d.ts +26 -2
  101. package/dist/types/utils/did-helper.d.ts +9 -1
  102. package/dist/types/verifiable/constants.d.ts +1 -0
  103. package/package.json +10 -12
  104. package/LICENSE +0 -691
  105. package/dist/node/esm/kms/key-providers/sec256k1-provider.js +0 -71
@@ -20,6 +20,14 @@ export declare class JWSPacker implements IPacker {
20
20
  * @memberof JWSPacker
21
21
  */
22
22
  constructor(_kms: KMS, _documentResolver: Resolvable);
23
+ /**
24
+ * Packs the given payload and returns a promise that resolves to the packed data.
25
+ *
26
+ * @param {Uint8Array} payload - The payload to be packed.
27
+ * @param {PackerParams} param - The packing parameters.
28
+ * @returns `Promise<Uint8Array>`
29
+ */
30
+ packMessage(msg: BasicMessage, param: JWSPackerParams): Promise<Uint8Array>;
23
31
  /**
24
32
  * creates JSON Web Signature token
25
33
  *
@@ -37,4 +45,5 @@ export declare class JWSPacker implements IPacker {
37
45
  unpack(envelope: Uint8Array): Promise<BasicMessage>;
38
46
  mediaType(): MediaType;
39
47
  private resolveDidDoc;
48
+ private packInternal;
40
49
  }
@@ -1,4 +1,3 @@
1
- import { PlainPackerParams } from './../types/packer';
2
1
  import { BasicMessage, IPacker } from '../types';
3
2
  import { MediaType } from '../constants';
4
3
  /**
@@ -9,6 +8,15 @@ import { MediaType } from '../constants';
9
8
  * @implements implements IPacker interface
10
9
  */
11
10
  export declare class PlainPacker implements IPacker {
11
+ /**
12
+ * Packs a basic message using the specified parameters.
13
+ *
14
+ * @param msg - The basic message to pack.
15
+ * @param param - The packer parameters.
16
+ * @returns A promise that resolves to a Uint8Array representing the packed message.
17
+ * @throws An error if the method is not implemented.
18
+ */
19
+ packMessage(msg: BasicMessage): Promise<Uint8Array>;
12
20
  /**
13
21
  * Pack returns packed message to transport envelope
14
22
  *
@@ -16,7 +24,7 @@ export declare class PlainPacker implements IPacker {
16
24
  * @param {PlainPackerParams} _params - not used here
17
25
  * @returns `Promise<Uint8Array>`
18
26
  */
19
- pack(payload: Uint8Array, _params: PlainPackerParams): Promise<Uint8Array>;
27
+ pack(payload: Uint8Array): Promise<Uint8Array>;
20
28
  /**
21
29
  * Unpack returns unpacked message from transport envelope
22
30
  *
@@ -63,6 +63,13 @@ export declare class ZKPPacker implements IPacker {
63
63
  * @param {Map<string, VerificationParams>} verificationParamsMap - string is derived by JSON.parse(ProvingMethodAlg)
64
64
  */
65
65
  constructor(provingParamsMap: Map<string, ProvingParams>, verificationParamsMap: Map<string, VerificationParams>);
66
+ /**
67
+ * Packs a basic message using the specified parameters.
68
+ * @param msg - The basic message to pack.
69
+ * @param param - The parameters for the ZKPPacker.
70
+ * @returns A promise that resolves to a Uint8Array representing the packed message.
71
+ */
72
+ packMessage(msg: BasicMessage, param: ZKPPackerParams): Promise<Uint8Array>;
66
73
  /**
67
74
  * creates JSON Web Zeroknowledge token
68
75
  *
@@ -29,6 +29,16 @@ export interface IPackageManager {
29
29
  * @returns `Promise<Uint8Array>`
30
30
  */
31
31
  pack(mediaType: MediaType, payload: Uint8Array, params: PackerParams): Promise<Uint8Array>;
32
+ /**
33
+ * packs payload with a packer that is assigned to media type
34
+ * forwards packer params to implementation
35
+ *
36
+ * @param {MediaType} mediaType
37
+ * @param {BasicMessage} protocolMessage
38
+ * @param {PackerParams} params
39
+ * @returns `Promise<Uint8Array>`
40
+ */
41
+ packMessage(mediaType: MediaType, protocolMessage: BasicMessage, params: PackerParams): Promise<Uint8Array>;
32
42
  /**
33
43
  * unpacks packed envelope to basic protocol message and returns media type of the envelope
34
44
  *
@@ -4,7 +4,6 @@ import { ProvingMethodAlg } from '@iden3/js-jwz';
4
4
  import { CircuitId } from '../../circuits';
5
5
  import { MediaType } from '../constants';
6
6
  import { DIDDocument, VerificationMethod } from 'did-resolver';
7
- import { Signer } from 'did-jwt';
8
7
  /**
9
8
  * Protocol message type
10
9
  */
@@ -45,8 +44,9 @@ export type ZKPPackerParams = PackerParams & {
45
44
  };
46
45
  /**
47
46
  * SignerFn Is function to sign data with a verification method
47
+ * @returns Promise of signature bytes;
48
48
  */
49
- export type SignerFn = (vm: VerificationMethod, data: Uint8Array) => Signer;
49
+ export type SignerFn = (vm: VerificationMethod, dataToSign: Uint8Array) => Promise<Uint8Array>;
50
50
  /**
51
51
  * JWSPackerParams are parameters for JWS packer
52
52
  */
@@ -75,8 +75,30 @@ export type StateVerificationFunc = (id: string, pubSignals: Array<string>) => P
75
75
  * @interface IPacker
76
76
  */
77
77
  export interface IPacker {
78
+ /**
79
+ * Packs the given payload and returns a promise that resolves to the packed data.
80
+ * @param payload - The payload to be packed.
81
+ * @param param - The packing parameters.
82
+ * @returns A promise that resolves to the packed data as a Uint8Array.
83
+ */
78
84
  pack(payload: Uint8Array, param: PackerParams): Promise<Uint8Array>;
85
+ /**
86
+ * Packs the given message and returns a promise that resolves to the packed data.
87
+ * @param msg - The message to be packed.
88
+ * @param param - The packing parameters.
89
+ * @returns A promise that resolves to the packed data as a Uint8Array.
90
+ */
91
+ packMessage(msg: BasicMessage, param: PackerParams): Promise<Uint8Array>;
92
+ /**
93
+ * Unpacks the given envelope and returns a promise that resolves to the unpacked message.
94
+ * @param envelope - The envelope to be unpacked.
95
+ * @returns A promise that resolves to the unpacked message as a BasicMessage.
96
+ */
79
97
  unpack(envelope: Uint8Array): Promise<BasicMessage>;
98
+ /**
99
+ * Returns the media type associated with the packer.
100
+ * @returns The media type as a MediaType.
101
+ */
80
102
  mediaType(): MediaType;
81
103
  }
82
104
  /**
@@ -1,16 +1,11 @@
1
1
  import { ZKProof } from '@iden3/js-jwz';
2
- import { MediaType } from '../../constants';
3
- import { JSONObject, ProtocolMessage } from '../packer';
2
+ import { BasicMessage, JSONObject } from '../packer';
4
3
  import { DID } from '@iden3/js-iden3-core';
5
4
  /** AuthorizationResponseMessage is struct the represents iden3message authorization response */
6
- export type AuthorizationResponseMessage = {
7
- id: string;
8
- typ?: MediaType;
9
- type: ProtocolMessage;
10
- thid?: string;
5
+ export type AuthorizationResponseMessage = BasicMessage & {
11
6
  body: AuthorizationMessageResponseBody;
12
- from?: string;
13
- to?: string;
7
+ from: string;
8
+ to: string;
14
9
  };
15
10
  /** AuthorizationMessageResponseBody is struct the represents authorization response data */
16
11
  export type AuthorizationMessageResponseBody = {
@@ -19,14 +14,9 @@ export type AuthorizationMessageResponseBody = {
19
14
  scope: Array<ZeroKnowledgeProofResponse>;
20
15
  };
21
16
  /** AuthorizationRequestMessage is struct the represents iden3message authorization request */
22
- export type AuthorizationRequestMessage = {
23
- id: string;
24
- typ: MediaType;
25
- type: ProtocolMessage;
26
- thid?: string;
17
+ export type AuthorizationRequestMessage = BasicMessage & {
27
18
  body: AuthorizationRequestMessageBody;
28
19
  from: string;
29
- to?: string;
30
20
  };
31
21
  /** AuthorizationRequestMessageBody is body for authorization request */
32
22
  export type AuthorizationRequestMessageBody = {
@@ -1,12 +1,8 @@
1
+ import { BasicMessage } from '../packer';
1
2
  import { ZeroKnowledgeProofRequest } from './auth';
2
3
  /** ContractInvokeRequest represents structure of contract invoke request object */
3
- export type ContractInvokeRequest = {
4
- id: string;
5
- typ: string;
6
- type: string;
7
- thid: string;
4
+ export type ContractInvokeRequest = BasicMessage & {
8
5
  body: ContractInvokeRequestBody;
9
- from?: string;
10
6
  };
11
7
  /** ContractInvokeRequestBody represents structure of contract invoke request body object */
12
8
  export type ContractInvokeRequestBody = {
@@ -1,6 +1,5 @@
1
1
  import { W3CCredential } from '../../../verifiable';
2
- import { MediaType } from '../../constants';
3
- import { JSONObject, ProtocolMessage } from '../packer';
2
+ import { BasicMessage, JSONObject } from '../packer';
4
3
  import { ContractInvokeTransactionData } from './contract-request';
5
4
  /** CredentialIssuanceRequestMessageBody represents data for credential issuance request */
6
5
  export type CredentialIssuanceRequestMessageBody = {
@@ -9,24 +8,12 @@ export type CredentialIssuanceRequestMessageBody = {
9
8
  expiration: number;
10
9
  };
11
10
  /** CredentialIssuanceRequestMessage represent Iden3message for credential request */
12
- export type CredentialIssuanceRequestMessage = {
13
- id: string;
14
- typ: MediaType;
15
- type: ProtocolMessage;
16
- thid?: string;
11
+ export type CredentialIssuanceRequestMessage = Required<BasicMessage> & {
17
12
  body: CredentialIssuanceRequestMessageBody;
18
- from: string;
19
- to: string;
20
13
  };
21
14
  /** CredentialsOfferMessage represent Iden3message for credential offer */
22
- export type CredentialsOfferMessage = {
23
- id: string;
24
- typ: MediaType;
25
- type: ProtocolMessage;
26
- thid?: string;
15
+ export type CredentialsOfferMessage = Required<BasicMessage> & {
27
16
  body: CredentialsOfferMessageBody;
28
- from: string;
29
- to: string;
30
17
  };
31
18
  /** CredentialsOfferMessageBody is struct the represents offer message */
32
19
  export type CredentialsOfferMessageBody = {
@@ -34,14 +21,8 @@ export type CredentialsOfferMessageBody = {
34
21
  credentials: Array<CredentialOffer>;
35
22
  };
36
23
  /** CredentialsOnchainOfferMessage represent Iden3message for credential onhcain offer message */
37
- export type CredentialsOnchainOfferMessage = {
38
- id: string;
39
- typ: MediaType;
40
- type: ProtocolMessage;
41
- thid?: string;
24
+ export type CredentialsOnchainOfferMessage = Required<BasicMessage> & {
42
25
  body: CredentialsOnchainOfferMessageBody;
43
- from: string;
44
- to: string;
45
26
  };
46
27
  /** CredentialsOnchainOfferMessageBody is struct the represents onchain offer message body */
47
28
  export type CredentialsOnchainOfferMessageBody = {
@@ -54,28 +35,16 @@ export type CredentialOffer = {
54
35
  description: string;
55
36
  };
56
37
  /** CredentialIssuanceMessage represent Iden3message for credential issuance */
57
- export type CredentialIssuanceMessage = {
58
- id: string;
59
- typ?: MediaType;
60
- type: ProtocolMessage;
61
- threadID?: string;
38
+ export type CredentialIssuanceMessage = Required<BasicMessage> & {
62
39
  body?: IssuanceMessageBody;
63
- from?: string;
64
- to?: string;
65
40
  };
66
41
  /** IssuanceMessageBody is struct the represents message when credential is issued */
67
42
  export type IssuanceMessageBody = {
68
43
  credential: W3CCredential;
69
44
  };
70
45
  /** CredentialFetchRequestMessage represent Iden3message for credential fetch request */
71
- export type CredentialFetchRequestMessage = {
72
- id: string;
73
- typ?: MediaType;
74
- type: ProtocolMessage;
75
- thid?: string;
46
+ export type CredentialFetchRequestMessage = BasicMessage & {
76
47
  body?: CredentialFetchRequestMessageBody;
77
- from?: string;
78
- to?: string;
79
48
  };
80
49
  /** CredentialFetchRequestMessageBody is msg body for fetch request */
81
50
  export type CredentialFetchRequestMessageBody = {
@@ -88,14 +57,8 @@ export type Schema = {
88
57
  type: string;
89
58
  };
90
59
  /** CredentialRefreshMessage represent Iden3message for credential refresh request */
91
- export type CredentialRefreshMessage = {
92
- id: string;
93
- typ?: MediaType;
94
- type: ProtocolMessage;
95
- thid?: string;
60
+ export type CredentialRefreshMessage = Required<BasicMessage> & {
96
61
  body?: CredentialRefreshMessageBody;
97
- from?: string;
98
- to?: string;
99
62
  };
100
63
  /** CredentialRefreshMessageBody is msg body for refresh request */
101
64
  export type CredentialRefreshMessageBody = {
@@ -1,14 +1,7 @@
1
- import { ProtocolMessage } from '../';
2
- import { MediaType } from '../../constants';
1
+ import { BasicMessage } from '../';
3
2
  /** MessageFetchRequestMessage represent Iden3message for message fetch request. */
4
- export type MessageFetchRequestMessage = {
5
- id: string;
6
- typ?: MediaType;
7
- type: ProtocolMessage;
8
- thid?: string;
3
+ export type MessageFetchRequestMessage = Required<BasicMessage> & {
9
4
  body?: MessageFetchRequestMessageBody;
10
- from?: string;
11
- to?: string;
12
5
  };
13
6
  /** MessageFetchRequestMessageBody is struct the represents body for message fetch request. */
14
7
  export type MessageFetchRequestMessageBody = {
@@ -1,29 +1,16 @@
1
- import { ProtocolMessage } from '../';
2
- import { MediaType } from '../../constants';
1
+ import { BasicMessage } from '../';
3
2
  import { ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from './auth';
4
3
  /** ProofGenerationRequestMessage is struct the represents body for proof generation request */
5
- export type ProofGenerationRequestMessage = {
6
- id: string;
7
- typ?: MediaType;
8
- type: ProtocolMessage;
9
- thid?: string;
4
+ export type ProofGenerationRequestMessage = Required<BasicMessage> & {
10
5
  body?: ProofGenerationRequestMessageBody;
11
- from?: string;
12
- to?: string;
13
6
  };
14
7
  /** ProofGenerationRequestMessageBody is struct the represents body for proof generation request */
15
8
  export type ProofGenerationRequestMessageBody = {
16
9
  scope: Array<ZeroKnowledgeProofRequest>;
17
10
  };
18
11
  /** ProofGenerationResponseMessage is struct the represents body for proof generation request */
19
- export type ProofGenerationResponseMessage = {
20
- id: string;
21
- typ?: MediaType;
22
- type: ProtocolMessage;
23
- thid?: string;
12
+ export type ProofGenerationResponseMessage = Required<BasicMessage> & {
24
13
  body?: ResponseMessageBody;
25
- from?: string;
26
- to?: string;
27
14
  };
28
15
  /** ResponseMessageBody is struct the represents request for revocation status */
29
16
  export type ResponseMessageBody = {
@@ -1,29 +1,16 @@
1
- import { ProtocolMessage } from '../';
1
+ import { BasicMessage } from '../';
2
2
  import { RevocationStatus } from '../../../verifiable';
3
- import { MediaType } from '../../constants';
4
3
  /** RevocationStatusRequestMessage is struct the represents body for proof generation request */
5
- export type RevocationStatusRequestMessage = {
6
- id: string;
7
- typ?: MediaType;
8
- type: ProtocolMessage;
9
- thid?: string;
4
+ export type RevocationStatusRequestMessage = BasicMessage & {
10
5
  body?: RevocationStatusRequestMessageBody;
11
- from?: string;
12
- to?: string;
13
6
  };
14
7
  /** RevocationStatusRequestMessageBody is struct the represents request for revocation status */
15
8
  export type RevocationStatusRequestMessageBody = {
16
9
  revocation_nonce: number;
17
10
  };
18
11
  /** RevocationStatusResponseMessage is struct the represents body for proof generation request */
19
- export type RevocationStatusResponseMessage = {
20
- id: string;
21
- typ?: MediaType;
22
- type: ProtocolMessage;
23
- thid?: string;
12
+ export type RevocationStatusResponseMessage = Required<BasicMessage> & {
24
13
  body?: RevocationStatusResponseMessageBody;
25
- from?: string;
26
- to?: string;
27
14
  };
28
15
  /** RevocationStatusResponseMessageBody is struct the represents request for revocation status */
29
16
  export type RevocationStatusResponseMessageBody = RevocationStatus;
@@ -2,12 +2,13 @@ import { KMS, KmsKeyId, KmsKeyType } from '../kms';
2
2
  import { Claim, DID } from '@iden3/js-iden3-core';
3
3
  import { Signature } from '@iden3/js-crypto';
4
4
  import { IDataStorage, Profile } from '../storage';
5
- import { W3CCredential, MerkleTreeProofWithTreeState, CredentialStatusType, ProofQuery } from '../verifiable';
5
+ import { W3CCredential, MerkleTreeProofWithTreeState, CredentialStatusType, ProofQuery, CoreClaimCreationOptions } from '../verifiable';
6
6
  import { CredentialRequest, ICredentialWallet, PublishMode, TreesModel } from '../credentials';
7
7
  import { TreeState } from '../circuits';
8
8
  import { Options } from '@iden3/js-jsonld-merklization';
9
- import { TransactionReceipt } from 'ethers';
9
+ import { Signer, TransactionReceipt } from 'ethers';
10
10
  import { CredentialStatusPublisherRegistry } from '../credentials/status/credential-status-publisher';
11
+ import { IZKProver } from '../proof';
11
12
  /**
12
13
  * DID creation options
13
14
  * seed - seed to generate BJJ key pair
@@ -19,6 +20,13 @@ export type IdentityCreationOptions = {
19
20
  method?: string;
20
21
  blockchain?: string;
21
22
  networkId?: string;
23
+ } & AuthBJJCredentialCreationOptions;
24
+ /**
25
+ * Options for creating Auth BJJ credential
26
+ * seed - seed to generate BJJ key pair
27
+ * revocationOpts -
28
+ */
29
+ export type AuthBJJCredentialCreationOptions = {
22
30
  revocationOpts: {
23
31
  id: string;
24
32
  type: CredentialStatusType;
@@ -30,6 +38,13 @@ export type IdentityCreationOptions = {
30
38
  };
31
39
  seed?: Uint8Array;
32
40
  };
41
+ /**
42
+ * Options for creating Ethereum based identity
43
+ */
44
+ export type EthereumBasedIdentityCreationOptions = IdentityCreationOptions & {
45
+ ethSigner?: Signer;
46
+ createBjjCredential?: boolean;
47
+ };
33
48
  /**
34
49
  * Options for RevocationInfoOptions.
35
50
  */
@@ -64,7 +79,7 @@ export interface IIdentityWallet {
64
79
  * adds auth BJJ credential to claims tree and generates mtp of inclusion
65
80
  * based on the resulting state it provides an identifier in DID form.
66
81
  *
67
- * @param {IdentityCreationOptions} opts - default is did:iden3:polygon:mumbai** with generated key.
82
+ * @param {IdentityCreationOptions} opts - default is did:iden3:polygon:amoy** with generated key.
68
83
  * @returns `Promise<{ did: DID; credential: W3CCredential }>` - returns did and Auth BJJ credential
69
84
  * @public
70
85
  */
@@ -72,6 +87,17 @@ export interface IIdentityWallet {
72
87
  did: DID;
73
88
  credential: W3CCredential;
74
89
  }>;
90
+ /**
91
+ * Create Identity based in Ethereum address and it provides an identifier in DID form.
92
+ *
93
+ * @param {IdentityCreationOptions} opts - default is did:iden3:polygon:amoy** with generated key.
94
+ * @returns `Promise<{ did: DID; credential: W3CCredential | undefined }>` - returns did and Auth BJJ credential
95
+ * @public
96
+ */
97
+ createEthereumBasedIdentity(opts: EthereumBasedIdentityCreationOptions): Promise<{
98
+ did: DID;
99
+ credential: W3CCredential | undefined;
100
+ }>;
75
101
  /**
76
102
  * Creates profile based on genesis identifier
77
103
  *
@@ -113,6 +139,16 @@ export interface IIdentityWallet {
113
139
  * @returns `Promise<MerkleTreeProofWithTreeState>` - MerkleTreeProof and TreeState on which proof has been generated
114
140
  */
115
141
  generateCredentialMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
142
+ /**
143
+ * Generates proof of core claim inclusion / non-inclusion to the given claims tree
144
+ * and its root or to the current root of the Claims tree in the given Merkle tree storage.
145
+ *
146
+ * @param {DID} did - issuer did
147
+ * @param {core.Claim} core - core claim to generate mtp
148
+ * @param {TreeState} [treeState] - tree state when to generate a proof
149
+ * @returns `Promise<MerkleTreeProofWithTreeState>` - MerkleTreeProof and TreeState on which proof has been generated
150
+ */
151
+ generateCoreClaimMtp(did: DID, coreClaim: Claim, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
116
152
  /**
117
153
  * Generates proof of credential revocation nonce (with credential as a param) inclusion / non-inclusion to the given revocation tree
118
154
  * and its root or to the current root of the Revocation tree in the given Merkle tree storage.
@@ -216,7 +252,7 @@ export interface IIdentityWallet {
216
252
  *
217
253
  * gets profile identity by genesis identifiers
218
254
  *
219
- * @param {string} did - genesis identifier from which profile has been derived
255
+ * @param {DID} did - genesis identifier from which profile has been derived
220
256
  * @returns `{Promise<Profile[]>}`
221
257
  */
222
258
  getProfilesByDID(did: DID): Promise<Profile[]>;
@@ -224,7 +260,7 @@ export interface IIdentityWallet {
224
260
  *
225
261
  * gets profile nonce by it's id. if profile is genesis identifier - 0 is returned
226
262
  *
227
- * @param {string} did - profile that has been derived or genesis identity
263
+ * @param {DID} did - profile that has been derived or genesis identity
228
264
  * @returns `{Promise<{nonce:number, genesisIdentifier: DID}>}`
229
265
  */
230
266
  getGenesisDIDMetadata(did: DID): Promise<{
@@ -235,7 +271,7 @@ export interface IIdentityWallet {
235
271
  *
236
272
  * find all credentials that belong to any profile or genesis identity for the given did
237
273
  *
238
- * @param {string} did - profile that has been derived or genesis identity
274
+ * @param {DID} did - profile that has been derived or genesis identity
239
275
  * @returns `{Promise<W3CCredential[]>}`
240
276
  */
241
277
  findOwnedCredentialsByDID(did: DID, query: ProofQuery): Promise<W3CCredential[]>;
@@ -274,6 +310,26 @@ export interface IIdentityWallet {
274
310
  incProof: MerkleTreeProofWithTreeState;
275
311
  nonRevProof: MerkleTreeProofWithTreeState;
276
312
  }>;
313
+ /**
314
+ * Transit state for the identity with the given DID
315
+ *
316
+ * @param {DID} did - identifier of the user
317
+ * @param {TreeState} oldTreeState - old state of the user
318
+ * @param {boolean} isOldStateGenesis - if the old state is genesis
319
+ * @param {IStateStorage} stateStorage - storage to save the new state
320
+ * @param {Signer} ethSigner - signer to sign the transaction
321
+ */
322
+ transitState(did: DID, oldTreeState: TreeState, isOldStateGenesis: boolean, ethSigner: Signer, prover?: IZKProver): Promise<string>;
323
+ /**
324
+ * Add BJJ credential and transit state
325
+ *
326
+ * @param {DID} did - identifier of the user
327
+ * @param {TreeState} oldTreeState - old tree state of the user
328
+ * @param {boolean} isOldTreeState - if the old state is genesis
329
+ * @param {Signer} ethSigner - signer to sign the transaction
330
+ * @param {AuthBJJCredentialCreationOptions} opts - additional options
331
+ */
332
+ addBJJAuthCredential(did: DID, oldTreeState: TreeState, isOldTreeStateGenesis: boolean, ethSigner: Signer, opts?: AuthBJJCredentialCreationOptions): Promise<W3CCredential>;
277
333
  }
278
334
  /**
279
335
  * @public
@@ -292,6 +348,8 @@ export declare class IdentityWallet implements IIdentityWallet {
292
348
  private readonly _credentialWallet;
293
349
  private readonly _opts?;
294
350
  private readonly _credentialStatusPublisherRegistry;
351
+ private readonly _inputsGenerator;
352
+ private readonly _transactionService;
295
353
  /**
296
354
  * Constructs a new instance of the `IdentityWallet` class
297
355
  *
@@ -304,6 +362,8 @@ export declare class IdentityWallet implements IIdentityWallet {
304
362
  credentialStatusPublisherRegistry?: CredentialStatusPublisherRegistry | undefined;
305
363
  } | undefined);
306
364
  private getCredentialStatusPublisherRegistry;
365
+ private createAuthCoreClaim;
366
+ private createAuthBJJCredential;
307
367
  /**
308
368
  * {@inheritDoc IIdentityWallet.createIdentity}
309
369
  */
@@ -311,6 +371,13 @@ export declare class IdentityWallet implements IIdentityWallet {
311
371
  did: DID;
312
372
  credential: W3CCredential;
313
373
  }>;
374
+ /**
375
+ * {@inheritDoc IIdentityWallet.createEthereumBasedIdentity}
376
+ */
377
+ createEthereumBasedIdentity(opts: EthereumBasedIdentityCreationOptions): Promise<{
378
+ did: DID;
379
+ credential: W3CCredential | undefined;
380
+ }>;
314
381
  /** {@inheritDoc IIdentityWallet.getGenesisDIDMetadata} */
315
382
  getGenesisDIDMetadata(did: DID): Promise<{
316
383
  nonce: number;
@@ -333,6 +400,8 @@ export declare class IdentityWallet implements IIdentityWallet {
333
400
  getDIDTreeModel(did: DID): Promise<TreesModel>;
334
401
  /** {@inheritDoc IIdentityWallet.generateClaimMtp} */
335
402
  generateCredentialMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
403
+ /** {@inheritDoc IIdentityWallet.generateClaimMtp} */
404
+ generateCoreClaimMtp(did: DID, coreClaim: Claim, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
336
405
  /** {@inheritDoc IIdentityWallet.generateNonRevocationMtp} */
337
406
  generateNonRevocationMtp(did: DID, credential: W3CCredential, treeState?: TreeState): Promise<MerkleTreeProofWithTreeState>;
338
407
  /** {@inheritDoc IIdentityWallet.generateNonRevocationMtpWithNonce} */
@@ -354,7 +423,7 @@ export declare class IdentityWallet implements IIdentityWallet {
354
423
  /** {@inheritDoc IIdentityWallet.addCredentialsToMerkleTree} */
355
424
  addCredentialsToMerkleTree(credentials: W3CCredential[], issuerDID: DID): Promise<Iden3ProofCreationResult>;
356
425
  /** {@inheritDoc IIdentityWallet.generateIden3SparseMerkleTreeProof} */
357
- generateIden3SparseMerkleTreeProof(issuerDID: DID, credentials: W3CCredential[], txId: string, blockNumber?: number, blockTimestamp?: number, treeState?: TreeState): Promise<W3CCredential[]>;
426
+ generateIden3SparseMerkleTreeProof(issuerDID: DID, credentials: W3CCredential[], txId: string, blockNumber?: number, blockTimestamp?: number, treeState?: TreeState, opts?: CoreClaimCreationOptions): Promise<W3CCredential[]>;
358
427
  /** {@inheritDoc IIdentityWallet.publishSpecificStateToRHS} */
359
428
  publishSpecificStateToRHS(treeModel: TreesModel, rhsURL: string, revokedNonces?: number[]): Promise<void>;
360
429
  /** {@inheritDoc IIdentityWallet.publishStateToRHS} */
@@ -365,4 +434,8 @@ export declare class IdentityWallet implements IIdentityWallet {
365
434
  findOwnedCredentialsByDID(did: DID, query: ProofQuery): Promise<W3CCredential[]>;
366
435
  /** {@inheritDoc IIdentityWallet.updateIdentityState} */
367
436
  updateIdentityState(issuerDID: DID, published: boolean, treeState?: TreeState): Promise<void>;
437
+ /** {@inheritdoc IIdentityWallet.transitState} */
438
+ transitState(did: DID, oldTreeState: TreeState, isOldStateGenesis: boolean, ethSigner: Signer, prover?: IZKProver): Promise<string>;
439
+ /** {@inheritdoc IIdentityWallet.addBJJAuthCredential} */
440
+ addBJJAuthCredential(did: DID, oldTreeState: TreeState, isOldStateGenesis: boolean, ethSigner: Signer, opts: AuthBJJCredentialCreationOptions, prover?: IZKProver): Promise<W3CCredential>;
368
441
  }
@@ -9,6 +9,7 @@ export * from './iden3comm';
9
9
  export * from './circuits';
10
10
  export * from './iden3comm';
11
11
  export * from './utils';
12
+ export * from './blockchain';
12
13
  import * as core from '@iden3/js-iden3-core';
13
14
  import * as jsonLDMerklizer from '@iden3/js-jsonld-merklization';
14
15
  export { core };
@@ -41,4 +41,5 @@ export declare class BjjProvider implements IKeyProvider {
41
41
  */
42
42
  sign(keyId: KmsKeyId, data: Uint8Array): Promise<Uint8Array>;
43
43
  private privateKey;
44
+ verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean>;
44
45
  }
@@ -35,6 +35,14 @@ export declare class Ed25519Provider implements IKeyProvider {
35
35
  * @returns {Promise<Uint8Array>} signature
36
36
  */
37
37
  sign(keyId: KmsKeyId, data: Uint8Array): Promise<Uint8Array>;
38
+ /**
39
+ * Verifies a signature for the given message and key identifier.
40
+ * @param message - The message to verify the signature against.
41
+ * @param signatureHex - The signature to verify, as a hexadecimal string.
42
+ * @param keyId - The key identifier to use for verification.
43
+ * @returns A Promise that resolves to a boolean indicating whether the signature is valid.
44
+ */
45
+ verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean>;
38
46
  /**
39
47
  * Retrieves the private key for a given keyId from the key store.
40
48
  * @param {KmsKeyId} keyId - The identifier of the key to retrieve.
@@ -1,3 +1,3 @@
1
1
  export * from './bjj-provider';
2
2
  export * from './ed25519-provider';
3
- export * from './sec256k1-provider';
3
+ export * from './secp256k1-provider';
@@ -1,9 +1,9 @@
1
1
  import { IKeyProvider } from '../kms';
2
2
  import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store';
3
3
  /**
4
- * Provider for Sec256p1 keys256p1
4
+ * Provider for Secp256k1
5
5
  * @public
6
- * @class Sec256p1Provider
6
+ * @class Secp256k1Provider
7
7
  * @implements implements IKeyProvider interface
8
8
  */
9
9
  export declare class Sec256k1Provider implements IKeyProvider {
@@ -13,7 +13,6 @@ export declare class Sec256k1Provider implements IKeyProvider {
13
13
  */
14
14
  keyType: KmsKeyType;
15
15
  private _keyStore;
16
- private readonly _ec;
17
16
  /**
18
17
  * Creates an instance of BjjProvider.
19
18
  * @param {KmsKeyType} keyType - kms key type
@@ -33,15 +32,22 @@ export declare class Sec256k1Provider implements IKeyProvider {
33
32
  */
34
33
  publicKey(keyId: KmsKeyId): Promise<string>;
35
34
  /**
36
- * signs prepared payload of size,
37
- * with a key id
38
- *
39
- * @param {KmsKeyId} keyId - key identifier
40
- * @param {Uint8Array} data - data to sign (32 bytes)
41
- * @returns Uint8Array signature
35
+ * Signs the given data using the private key associated with the specified key identifier.
36
+ * @param keyId - The key identifier to use for signing.
37
+ * @param data - The data to sign.
38
+ * @param opts - Signing options, such as the algorithm to use.
39
+ * @returns A Promise that resolves to the signature as a Uint8Array.
42
40
  */
43
41
  sign(keyId: KmsKeyId, data: Uint8Array, opts?: {
44
42
  [key: string]: unknown;
45
43
  }): Promise<Uint8Array>;
44
+ /**
45
+ * Verifies a signature for the given message and key identifier.
46
+ * @param message - The message to verify the signature against.
47
+ * @param signatureHex - The signature to verify, as a hexadecimal string.
48
+ * @param keyId - The key identifier to use for verification.
49
+ * @returns A Promise that resolves to a boolean indicating whether the signature is valid.
50
+ */
51
+ verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean>;
46
52
  private privateKey;
47
53
  }