@0xpolygonid/js-sdk 1.10.3 → 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.
- package/README.md +11 -0
- package/dist/browser/esm/index.js +8360 -17399
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +8381 -17415
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/blockchain/index.js +17 -0
- package/dist/node/cjs/blockchain/transaction-service.js +55 -0
- package/dist/node/cjs/credentials/credential-wallet.js +1 -1
- package/dist/node/cjs/credentials/status/reverse-sparse-merkle-tree.js +5 -1
- package/dist/node/cjs/iden3comm/handlers/auth.js +62 -27
- package/dist/node/cjs/iden3comm/handlers/common.js +4 -4
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +34 -15
- package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +33 -14
- package/dist/node/cjs/iden3comm/handlers/fetch.js +65 -34
- package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
- package/dist/node/cjs/iden3comm/handlers/message-handler.js +96 -0
- package/dist/node/cjs/iden3comm/handlers/revocation-status.js +58 -30
- package/dist/node/cjs/iden3comm/packageManager.js +16 -0
- package/dist/node/cjs/iden3comm/packers/jws.js +63 -49
- package/dist/node/cjs/iden3comm/packers/plain.js +13 -3
- package/dist/node/cjs/iden3comm/packers/zkp.js +9 -0
- package/dist/node/cjs/iden3comm/utils/did.js +11 -11
- package/dist/node/cjs/identity/identity-wallet.js +228 -43
- package/dist/node/cjs/index.js +1 -0
- package/dist/node/cjs/kms/key-providers/bjj-provider.js +9 -0
- package/dist/node/cjs/kms/key-providers/ed25519-provider.js +13 -1
- package/dist/node/cjs/kms/key-providers/index.js +1 -1
- package/dist/node/cjs/kms/key-providers/{sec256k1-provider.js → secp256k1-provider.js} +37 -26
- package/dist/node/cjs/kms/kms.js +15 -0
- package/dist/node/cjs/proof/proof-service.js +3 -33
- package/dist/node/cjs/proof/provers/inputs-generator.js +2 -7
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +4 -5
- package/dist/node/cjs/storage/blockchain/onchain-revocation.js +4 -12
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +3 -10
- package/dist/node/cjs/storage/blockchain/state.js +39 -10
- package/dist/node/cjs/utils/did-helper.js +36 -2
- package/dist/node/cjs/verifiable/constants.js +2 -1
- package/dist/node/esm/blockchain/index.js +1 -0
- package/dist/node/esm/blockchain/transaction-service.js +51 -0
- package/dist/node/esm/credentials/credential-wallet.js +1 -1
- package/dist/node/esm/credentials/status/reverse-sparse-merkle-tree.js +6 -2
- package/dist/node/esm/iden3comm/handlers/auth.js +62 -27
- package/dist/node/esm/iden3comm/handlers/common.js +4 -4
- package/dist/node/esm/iden3comm/handlers/contract-request.js +34 -15
- package/dist/node/esm/iden3comm/handlers/credential-proposal.js +33 -14
- package/dist/node/esm/iden3comm/handlers/fetch.js +65 -34
- package/dist/node/esm/iden3comm/handlers/index.js +1 -0
- package/dist/node/esm/iden3comm/handlers/message-handler.js +91 -0
- package/dist/node/esm/iden3comm/handlers/revocation-status.js +58 -30
- package/dist/node/esm/iden3comm/packageManager.js +16 -0
- package/dist/node/esm/iden3comm/packers/jws.js +63 -49
- package/dist/node/esm/iden3comm/packers/plain.js +13 -3
- package/dist/node/esm/iden3comm/packers/zkp.js +9 -0
- package/dist/node/esm/iden3comm/utils/did.js +11 -8
- package/dist/node/esm/identity/identity-wallet.js +230 -45
- package/dist/node/esm/index.js +1 -0
- package/dist/node/esm/kms/key-providers/bjj-provider.js +10 -1
- package/dist/node/esm/kms/key-providers/ed25519-provider.js +13 -1
- package/dist/node/esm/kms/key-providers/index.js +1 -1
- package/dist/node/esm/kms/key-providers/secp256k1-provider.js +85 -0
- package/dist/node/esm/kms/kms.js +15 -0
- package/dist/node/esm/proof/proof-service.js +4 -34
- package/dist/node/esm/proof/provers/inputs-generator.js +3 -8
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +4 -5
- package/dist/node/esm/storage/blockchain/onchain-revocation.js +4 -12
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +3 -10
- package/dist/node/esm/storage/blockchain/state.js +39 -10
- package/dist/node/esm/utils/did-helper.js +33 -1
- package/dist/node/esm/verifiable/constants.js +2 -1
- package/dist/types/blockchain/index.d.ts +1 -0
- package/dist/types/blockchain/transaction-service.d.ts +80 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +17 -2
- package/dist/types/iden3comm/handlers/common.d.ts +2 -2
- package/dist/types/iden3comm/handlers/contract-request.d.ts +10 -2
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +5 -2
- package/dist/types/iden3comm/handlers/fetch.d.ts +15 -6
- package/dist/types/iden3comm/handlers/index.d.ts +1 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts +83 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +18 -2
- package/dist/types/iden3comm/packageManager.d.ts +10 -0
- package/dist/types/iden3comm/packers/jws.d.ts +9 -0
- package/dist/types/iden3comm/packers/plain.d.ts +10 -2
- package/dist/types/iden3comm/packers/zkp.d.ts +7 -0
- package/dist/types/iden3comm/types/packageManager.d.ts +10 -0
- package/dist/types/iden3comm/types/packer.d.ts +24 -2
- package/dist/types/iden3comm/types/protocol/auth.d.ts +5 -15
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +2 -6
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +7 -44
- package/dist/types/iden3comm/types/protocol/messages.d.ts +2 -9
- package/dist/types/iden3comm/types/protocol/proof.d.ts +3 -16
- package/dist/types/iden3comm/types/protocol/revocation.d.ts +3 -16
- package/dist/types/identity/identity-wallet.d.ts +80 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts +1 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts +8 -0
- package/dist/types/kms/key-providers/index.d.ts +1 -1
- package/dist/types/kms/key-providers/{sec256k1-provider.d.ts → secp256k1-provider.d.ts} +15 -9
- package/dist/types/kms/kms.d.ts +18 -0
- package/dist/types/proof/proof-service.d.ts +2 -2
- package/dist/types/storage/blockchain/onchain-revocation.d.ts +1 -0
- package/dist/types/storage/blockchain/state.d.ts +7 -2
- package/dist/types/storage/interfaces/state.d.ts +26 -2
- package/dist/types/utils/did-helper.d.ts +9 -1
- package/dist/types/verifiable/constants.d.ts +1 -0
- package/package.json +10 -12
- package/LICENSE +0 -691
- package/dist/node/esm/kms/key-providers/sec256k1-provider.js +0 -71
|
@@ -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:
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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 };
|
|
@@ -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,9 +1,9 @@
|
|
|
1
1
|
import { IKeyProvider } from '../kms';
|
|
2
2
|
import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store';
|
|
3
3
|
/**
|
|
4
|
-
* Provider for
|
|
4
|
+
* Provider for Secp256k1
|
|
5
5
|
* @public
|
|
6
|
-
* @class
|
|
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
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param
|
|
40
|
-
* @
|
|
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
|
}
|
package/dist/types/kms/kms.d.ts
CHANGED
|
@@ -37,6 +37,15 @@ export interface IKeyProvider {
|
|
|
37
37
|
* @returns `Promise<KmsKeyId>`
|
|
38
38
|
*/
|
|
39
39
|
newPrivateKeyFromSeed(seed: Uint8Array): Promise<KmsKeyId>;
|
|
40
|
+
/**
|
|
41
|
+
* Verifies a message signature using the provided key ID.
|
|
42
|
+
*
|
|
43
|
+
* @param message - The message bytes to verify.
|
|
44
|
+
* @param signatureHex - The signature in hexadecimal format.
|
|
45
|
+
* @param keyId - The KMS key ID used to verify the signature.
|
|
46
|
+
* @returns A promise that resolves to a boolean indicating whether the signature is valid.
|
|
47
|
+
*/
|
|
48
|
+
verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean>;
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* Key management system class contains different key providers.
|
|
@@ -79,4 +88,13 @@ export declare class KMS {
|
|
|
79
88
|
sign(keyId: KmsKeyId, data: Uint8Array, opts?: {
|
|
80
89
|
[key: string]: unknown;
|
|
81
90
|
}): Promise<Uint8Array>;
|
|
91
|
+
/**
|
|
92
|
+
* Verifies a signature against the provided data and key ID.
|
|
93
|
+
*
|
|
94
|
+
* @param data - The data to verify the signature against.
|
|
95
|
+
* @param signatureHex - The signature to verify, in hexadecimal format.
|
|
96
|
+
* @param keyId - The key ID to use for verification.
|
|
97
|
+
* @returns A promise that resolves to a boolean indicating whether the signature is valid.
|
|
98
|
+
*/
|
|
99
|
+
verify(data: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean>;
|
|
82
100
|
}
|
|
@@ -90,7 +90,6 @@ export interface IProofService {
|
|
|
90
90
|
* @param {DID} did - identity that will transit state
|
|
91
91
|
* @param {TreeState} oldTreeState - previous tree state
|
|
92
92
|
* @param {boolean} isOldStateGenesis - is a transition state is done from genesis state
|
|
93
|
-
* @param {IStateStorage} stateStorage - storage of identity states (only eth based storage currently)
|
|
94
93
|
* @param {Signer} ethSigner - signer for transaction
|
|
95
94
|
* @returns `{Promise<string>}` - transaction hash is returned
|
|
96
95
|
*/
|
|
@@ -133,7 +132,8 @@ export declare class ProofService implements IProofService {
|
|
|
133
132
|
/** {@inheritdoc IProofService.generateProof} */
|
|
134
133
|
generateProof(proofReq: ZeroKnowledgeProofRequest, identifier: DID, opts?: ProofGenerationOptions): Promise<ZeroKnowledgeProofResponse>;
|
|
135
134
|
/** {@inheritdoc IProofService.transitState} */
|
|
136
|
-
transitState(did: DID, oldTreeState: TreeState, isOldStateGenesis: boolean, stateStorage: IStateStorage,
|
|
135
|
+
transitState(did: DID, oldTreeState: TreeState, isOldStateGenesis: boolean, stateStorage: IStateStorage, // for compatibility with previous versions we leave this parameter
|
|
136
|
+
ethSigner: Signer): Promise<string>;
|
|
137
137
|
private generateInputs;
|
|
138
138
|
private toCircuitsQuery;
|
|
139
139
|
private loadLdContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RootInfo, StateProof } from './../entities/state';
|
|
2
2
|
import { ZKProof } from '@iden3/js-jwz';
|
|
3
|
-
import { IStateStorage } from '../interfaces/state';
|
|
3
|
+
import { IStateStorage, UserStateTransitionInfo } from '../interfaces/state';
|
|
4
4
|
import { Contract, JsonRpcProvider, Signer } from 'ethers';
|
|
5
5
|
import { StateInfo } from '../entities/state';
|
|
6
6
|
/**
|
|
@@ -36,7 +36,8 @@ export declare const defaultEthConnectionConfig: EthConnectionConfig;
|
|
|
36
36
|
export declare class EthStateStorage implements IStateStorage {
|
|
37
37
|
private readonly ethConfig;
|
|
38
38
|
readonly stateContract: Contract;
|
|
39
|
-
readonly provider
|
|
39
|
+
private readonly provider;
|
|
40
|
+
private readonly _transactionService;
|
|
40
41
|
/**
|
|
41
42
|
* Creates an instance of EthStateStorage.
|
|
42
43
|
* @param {EthConnectionConfig} [ethConfig=defaultEthConnectionConfig]
|
|
@@ -48,10 +49,14 @@ export declare class EthStateStorage implements IStateStorage {
|
|
|
48
49
|
getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo>;
|
|
49
50
|
/** {@inheritdoc IStateStorage.publishState} */
|
|
50
51
|
publishState(proof: ZKProof, signer: Signer): Promise<string>;
|
|
52
|
+
/** {@inheritdoc IStateStorage.publishStateGeneric} */
|
|
53
|
+
publishStateGeneric(signer: Signer, userStateTransitionInfo: UserStateTransitionInfo): Promise<string>;
|
|
51
54
|
/** {@inheritdoc IStateStorage.getGISTProof} */
|
|
52
55
|
getGISTProof(id: bigint): Promise<StateProof>;
|
|
53
56
|
/** {@inheritdoc IStateStorage.getGISTRootInfo} */
|
|
54
57
|
getGISTRootInfo(root: bigint, id: bigint): Promise<RootInfo>;
|
|
58
|
+
/** {@inheritdoc IStateStorage.getRpcProvider} */
|
|
59
|
+
getRpcProvider(): JsonRpcProvider;
|
|
55
60
|
private getStateContractAndProviderForId;
|
|
56
61
|
private networkByChainId;
|
|
57
62
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { ZKProof } from '@iden3/js-jwz';
|
|
2
|
-
import { Signer } from 'ethers';
|
|
2
|
+
import { JsonRpcProvider, Signer } from 'ethers';
|
|
3
3
|
import { RootInfo, StateInfo, StateProof } from '../entities/state';
|
|
4
|
+
import { Id } from '@iden3/js-iden3-core';
|
|
5
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
6
|
+
export interface UserStateTransitionInfo {
|
|
7
|
+
userId: Id;
|
|
8
|
+
oldUserState: Hash;
|
|
9
|
+
newUserState: Hash;
|
|
10
|
+
isOldStateGenesis: boolean;
|
|
11
|
+
methodId: bigint;
|
|
12
|
+
methodParams: string;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* Interface that defines methods for state storage
|
|
6
16
|
*
|
|
@@ -30,7 +40,15 @@ export interface IStateStorage {
|
|
|
30
40
|
* @param {Signer} signer - signer of transaction
|
|
31
41
|
* @returns `Promise<string>` - transaction identifier
|
|
32
42
|
*/
|
|
33
|
-
publishState(proof: ZKProof, signer: Signer): Promise<string>;
|
|
43
|
+
publishState(proof: ZKProof | undefined, signer: Signer): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* method to publish state onchain
|
|
46
|
+
*
|
|
47
|
+
* @param {Signer} signer - signer of transaction
|
|
48
|
+
* @param {UserStateTransitionInfo} userStateTransitionInfo - user state transition information
|
|
49
|
+
* @returns `Promise<string>` - transaction identifier
|
|
50
|
+
*/
|
|
51
|
+
publishStateGeneric(signer: Signer, userStateTransitionInfo?: UserStateTransitionInfo): Promise<string>;
|
|
34
52
|
/**
|
|
35
53
|
* generates proof of inclusion / non-inclusion to global identity state for given identity
|
|
36
54
|
*
|
|
@@ -46,4 +64,10 @@ export interface IStateStorage {
|
|
|
46
64
|
* @returns `Promise<RootInfo>`
|
|
47
65
|
*/
|
|
48
66
|
getGISTRootInfo(root: bigint, userId: bigint): Promise<RootInfo>;
|
|
67
|
+
/**
|
|
68
|
+
* gets RPC provider
|
|
69
|
+
*
|
|
70
|
+
* @returns `Promise<JsonRpcProvider>`
|
|
71
|
+
*/
|
|
72
|
+
getRpcProvider(): JsonRpcProvider;
|
|
49
73
|
}
|
|
@@ -4,11 +4,18 @@ import { VerificationMethod } from 'did-resolver';
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks if state is genesis state
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {DID} did - did
|
|
8
8
|
* @param {bigint|string} state - hash on bigInt or hex string format
|
|
9
9
|
* @returns boolean
|
|
10
10
|
*/
|
|
11
11
|
export declare function isGenesisState(did: DID, state: bigint | string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if DID is an ethereum identity
|
|
14
|
+
*
|
|
15
|
+
* @param {DID} did - did
|
|
16
|
+
* @returns boolean
|
|
17
|
+
*/
|
|
18
|
+
export declare function isEthereumIdentity(did: DID): boolean;
|
|
12
19
|
export declare const buildVerifierId: (address: string, info: {
|
|
13
20
|
method: string;
|
|
14
21
|
blockchain: string;
|
|
@@ -16,3 +23,4 @@ export declare const buildVerifierId: (address: string, info: {
|
|
|
16
23
|
}) => Id;
|
|
17
24
|
export declare const validateDIDDocumentAuth: (did: DID, resolverURL: string, state: Hash) => Promise<void>;
|
|
18
25
|
export declare const resolveDIDDocumentAuth: (did: DID, resolveURL: string, state?: Hash) => Promise<VerificationMethod | undefined>;
|
|
26
|
+
export declare const buildDIDFromEthPubKey: (didType: Uint8Array, pubKeyEth: string) => DID;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "SDK to work with Polygon ID",
|
|
5
5
|
"main": "dist/node/cjs/index.js",
|
|
6
6
|
"module": "dist/node/esm/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "npm run clean && npm run build:node && npm run build:browser",
|
|
26
26
|
"build:node": "npm run build:tsc && npm run build:esm",
|
|
27
27
|
"build:esm": "tsc --outDir dist/node/esm --declaration --declarationDir dist/types",
|
|
28
|
-
"build:browser": "rollup -c rollup.config.mjs --failAfterWarnings",
|
|
28
|
+
"build:browser": "rollup -c rollup.config.mjs --failAfterWarnings --filterLogs \"/* @__PURE__ */\"",
|
|
29
29
|
"build:tsc": "tsc --module commonjs --outDir dist/node/cjs",
|
|
30
30
|
"doc:extract": "ts-node ./scripts/doc-extract.ts",
|
|
31
31
|
"doc:documenter": "ts-node ./scripts/doc-documenter.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"url": "https://github.com/0xPolygonID/js-sdk.git"
|
|
44
44
|
},
|
|
45
45
|
"author": "",
|
|
46
|
-
"license": "
|
|
46
|
+
"license": "MIT or Apache-2.0",
|
|
47
47
|
"bugs": {
|
|
48
48
|
"url": "https://github.com/0xPolygonID/js-sdk/issues"
|
|
49
49
|
},
|
|
@@ -53,18 +53,17 @@
|
|
|
53
53
|
"@iden3/eslint-config": "https://github.com/iden3/eslint-config",
|
|
54
54
|
"@microsoft/api-documenter": "^7.8.20",
|
|
55
55
|
"@microsoft/api-extractor": "^7.9.0",
|
|
56
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
57
|
-
"@rollup/plugin-json": "^6.0
|
|
58
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
59
|
-
"@rollup/plugin-replace": "^5.0.
|
|
56
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
57
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
58
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
59
|
+
"@rollup/plugin-replace": "^5.0.5",
|
|
60
60
|
"@rollup/plugin-terser": "^0.4.4",
|
|
61
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
61
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
62
62
|
"@rollup/plugin-virtual": "^3.0.2",
|
|
63
63
|
"@typechain/ethers-v6": "^0.5.1",
|
|
64
64
|
"@types/chai": "^4.3.9",
|
|
65
65
|
"@types/chai-as-promised": "^7.1.7",
|
|
66
66
|
"@types/chai-spies": "^1.0.5",
|
|
67
|
-
"@types/elliptic": "^6.4.16",
|
|
68
67
|
"@types/fs-extra": "^11.0.1",
|
|
69
68
|
"@types/jsonld": "^1.5.11",
|
|
70
69
|
"@types/mocha": "^10.0.3",
|
|
@@ -81,7 +80,7 @@
|
|
|
81
80
|
"mocha": "10.2.0",
|
|
82
81
|
"prettier": "^2.7.1",
|
|
83
82
|
"rimraf": "^5.0.5",
|
|
84
|
-
"rollup": "^4.
|
|
83
|
+
"rollup": "^4.14.3",
|
|
85
84
|
"ts-loader": "^9.4.1",
|
|
86
85
|
"ts-node": "^10.9.1",
|
|
87
86
|
"typescript": "^4.8.4"
|
|
@@ -100,9 +99,8 @@
|
|
|
100
99
|
"@noble/curves": "^1.4.0",
|
|
101
100
|
"ajv": "8.12.0",
|
|
102
101
|
"ajv-formats": "2.1.1",
|
|
103
|
-
"did-jwt": "
|
|
102
|
+
"did-jwt": "8.0.4",
|
|
104
103
|
"did-resolver": "4.1.0",
|
|
105
|
-
"elliptic": "6.5.4",
|
|
106
104
|
"ethers": "6.8.0",
|
|
107
105
|
"idb-keyval": "6.2.0",
|
|
108
106
|
"js-sha3": "0.9.3",
|