@0xpolygonid/js-sdk 1.6.1 → 1.7.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.
- package/README.md +3 -1
- package/dist/browser/esm/index.js +837 -494
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +885 -536
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/comparer.js +21 -3
- package/dist/node/cjs/circuits/linked-multi-query.js +1 -1
- package/dist/node/cjs/credentials/credential-wallet.js +20 -2
- package/dist/node/cjs/credentials/index.js +1 -0
- package/dist/node/cjs/credentials/rhs.js +28 -15
- package/dist/node/cjs/credentials/status/credential-status-publisher.js +84 -0
- package/dist/node/cjs/credentials/utils.js +14 -1
- package/dist/node/cjs/iden3comm/constants.js +2 -0
- package/dist/node/cjs/iden3comm/handlers/fetch.js +2 -2
- package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
- package/dist/node/cjs/iden3comm/handlers/refresh.js +76 -0
- package/dist/node/cjs/identity/identity-wallet.js +57 -26
- package/dist/node/cjs/storage/blockchain/abi/CredentialStatusResolver.json +1 -1
- package/dist/node/cjs/storage/blockchain/index.js +1 -0
- package/dist/node/cjs/storage/blockchain/onchain-revocation.js +45 -5
- package/dist/node/cjs/verifiable/constants.js +10 -1
- package/dist/node/esm/circuits/comparer.js +21 -3
- package/dist/node/esm/circuits/linked-multi-query.js +1 -1
- package/dist/node/esm/credentials/credential-wallet.js +21 -3
- package/dist/node/esm/credentials/index.js +1 -0
- package/dist/node/esm/credentials/rhs.js +26 -14
- package/dist/node/esm/credentials/status/credential-status-publisher.js +78 -0
- package/dist/node/esm/credentials/utils.js +12 -0
- package/dist/node/esm/iden3comm/constants.js +2 -0
- package/dist/node/esm/iden3comm/handlers/fetch.js +2 -2
- package/dist/node/esm/iden3comm/handlers/index.js +1 -0
- package/dist/node/esm/iden3comm/handlers/refresh.js +72 -0
- package/dist/node/esm/identity/identity-wallet.js +52 -21
- package/dist/node/esm/storage/blockchain/abi/CredentialStatusResolver.json +1 -1
- package/dist/node/esm/storage/blockchain/index.js +1 -0
- package/dist/node/esm/storage/blockchain/onchain-revocation.js +45 -5
- package/dist/node/esm/verifiable/constants.js +9 -0
- package/dist/types/credentials/credential-wallet.d.ts +5 -1
- package/dist/types/credentials/index.d.ts +1 -0
- package/dist/types/credentials/rhs.d.ts +11 -0
- package/dist/types/credentials/status/credential-status-publisher.d.ts +70 -0
- package/dist/types/credentials/utils.d.ts +2 -0
- package/dist/types/iden3comm/constants.d.ts +1 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts +2 -2
- package/dist/types/iden3comm/handlers/index.d.ts +1 -0
- package/dist/types/iden3comm/handlers/refresh.d.ts +56 -0
- package/dist/types/iden3comm/types/packer.d.ts +2 -1
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +15 -0
- package/dist/types/identity/identity-wallet.d.ts +42 -13
- package/dist/types/storage/blockchain/index.d.ts +1 -0
- package/dist/types/storage/blockchain/onchain-revocation.d.ts +7 -3
- package/dist/types/verifiable/constants.d.ts +8 -0
- package/dist/types/verifiable/credential.d.ts +2 -1
- package/dist/types/verifiable/proof.d.ts +10 -1
- package/package.json +1 -1
|
@@ -16,9 +16,16 @@ export class OnChainRevocationStorage {
|
|
|
16
16
|
* @param {string} - onhcain contract address
|
|
17
17
|
* @param {string} - rpc url to connect to the blockchain
|
|
18
18
|
*/
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
19
|
+
constructor(_config, contractAddress, _signer) {
|
|
20
|
+
this._config = _config;
|
|
21
|
+
this._signer = _signer;
|
|
22
|
+
this._provider = new JsonRpcProvider(_config.url);
|
|
23
|
+
let contract = new Contract(contractAddress, abi, this._provider);
|
|
24
|
+
if (this._signer) {
|
|
25
|
+
this._signer = this._signer.connect(this._provider);
|
|
26
|
+
contract = contract.connect(this._signer);
|
|
27
|
+
}
|
|
28
|
+
this._contract = contract;
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
31
|
* Get revocation status by issuerId, issuerState and nonce from the onchain.
|
|
@@ -26,7 +33,7 @@ export class OnChainRevocationStorage {
|
|
|
26
33
|
* @returns Promise<RevocationStatus>
|
|
27
34
|
*/
|
|
28
35
|
async getRevocationStatusByIdAndState(issuerID, state, nonce) {
|
|
29
|
-
const response = await this.
|
|
36
|
+
const response = await this._contract.getRevocationStatusByIdAndState(issuerID, state, nonce);
|
|
30
37
|
const issuer = OnChainRevocationStorage.convertIssuerInfo(response.issuer);
|
|
31
38
|
const mtp = OnChainRevocationStorage.convertSmtProofToProof(response.mtp);
|
|
32
39
|
return {
|
|
@@ -40,7 +47,7 @@ export class OnChainRevocationStorage {
|
|
|
40
47
|
* @returns Promise<RevocationStatus>
|
|
41
48
|
*/
|
|
42
49
|
async getRevocationStatus(issuerID, nonce) {
|
|
43
|
-
const response = await this.
|
|
50
|
+
const response = await this._contract.getRevocationStatus(issuerID, nonce);
|
|
44
51
|
const issuer = OnChainRevocationStorage.convertIssuerInfo(response.issuer);
|
|
45
52
|
const mtp = OnChainRevocationStorage.convertSmtProofToProof(response.mtp);
|
|
46
53
|
return {
|
|
@@ -48,6 +55,39 @@ export class OnChainRevocationStorage {
|
|
|
48
55
|
mtp
|
|
49
56
|
};
|
|
50
57
|
}
|
|
58
|
+
async saveNodes(payload) {
|
|
59
|
+
if (!this._signer) {
|
|
60
|
+
throw new Error('No signer provided');
|
|
61
|
+
}
|
|
62
|
+
const feeData = await this._provider.getFeeData();
|
|
63
|
+
const maxFeePerGas = this._config.maxFeePerGas
|
|
64
|
+
? BigInt(this._config.maxFeePerGas)
|
|
65
|
+
: feeData.maxFeePerGas;
|
|
66
|
+
const maxPriorityFeePerGas = this._config.maxPriorityFeePerGas
|
|
67
|
+
? BigInt(this._config.maxPriorityFeePerGas)
|
|
68
|
+
: feeData.maxPriorityFeePerGas;
|
|
69
|
+
const gasLimit = await this._contract.saveNodes.estimateGas(payload);
|
|
70
|
+
const txData = await this._contract.saveNodes.populateTransaction(payload);
|
|
71
|
+
const request = {
|
|
72
|
+
to: txData.to,
|
|
73
|
+
data: txData.data,
|
|
74
|
+
gasLimit,
|
|
75
|
+
maxFeePerGas,
|
|
76
|
+
maxPriorityFeePerGas
|
|
77
|
+
};
|
|
78
|
+
const tx = await this._signer.sendTransaction(request);
|
|
79
|
+
return tx.wait().then((txReceipt) => {
|
|
80
|
+
if (!txReceipt) {
|
|
81
|
+
throw new Error(`transaction: ${tx.hash} failed to mine`);
|
|
82
|
+
}
|
|
83
|
+
const status = txReceipt.status;
|
|
84
|
+
const txnHash = txReceipt.hash;
|
|
85
|
+
if (!status) {
|
|
86
|
+
throw new Error(`transaction: ${txnHash} failed to mine`);
|
|
87
|
+
}
|
|
88
|
+
return txReceipt;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
51
91
|
static convertIssuerInfo(issuer) {
|
|
52
92
|
const [state, claimsTreeRoot, revocationTreeRoot, rootOfRoots] = issuer.map((i) => Hash.fromBigInt(i).hex());
|
|
53
93
|
return {
|
|
@@ -100,3 +100,12 @@ export var SubjectPosition;
|
|
|
100
100
|
// Value save subject in value part of claim.
|
|
101
101
|
SubjectPosition["Value"] = "value";
|
|
102
102
|
})(SubjectPosition || (SubjectPosition = {}));
|
|
103
|
+
/**
|
|
104
|
+
* RefreshServiceType type for refreshService
|
|
105
|
+
*
|
|
106
|
+
* @enum {string}
|
|
107
|
+
*/
|
|
108
|
+
export var RefreshServiceType;
|
|
109
|
+
(function (RefreshServiceType) {
|
|
110
|
+
RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
|
|
111
|
+
})(RefreshServiceType || (RefreshServiceType = {}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DID } from '@iden3/js-iden3-core';
|
|
2
2
|
import { IDataStorage } from '../storage/interfaces';
|
|
3
|
-
import { W3CCredential, ProofQuery, SubjectPosition, MerklizedRootPosition, CredentialStatus, RevocationStatus, CredentialStatusType } from './../verifiable';
|
|
3
|
+
import { W3CCredential, ProofQuery, SubjectPosition, MerklizedRootPosition, CredentialStatus, RevocationStatus, CredentialStatusType, RefreshService } from './../verifiable';
|
|
4
4
|
import { JSONSchema } from '../schema-processor';
|
|
5
5
|
import { CredentialStatusResolverRegistry } from './status/resolver';
|
|
6
6
|
import { CredentialStatusResolveOptions } from './status/resolver';
|
|
@@ -29,6 +29,10 @@ export interface CredentialRequest {
|
|
|
29
29
|
* expiration time
|
|
30
30
|
*/
|
|
31
31
|
expiration?: number;
|
|
32
|
+
/**
|
|
33
|
+
* refreshService
|
|
34
|
+
*/
|
|
35
|
+
refreshService?: RefreshService;
|
|
32
36
|
/**
|
|
33
37
|
* claim version
|
|
34
38
|
*/
|
|
@@ -3,6 +3,7 @@ export * from './status/reverse-sparse-merkle-tree';
|
|
|
3
3
|
export * from './status/sparse-merkle-tree';
|
|
4
4
|
export * from './status/resolver';
|
|
5
5
|
export * from './status/agent-revocation';
|
|
6
|
+
export * from './status/credential-status-publisher';
|
|
6
7
|
export * from './status/utils';
|
|
7
8
|
export * from './credential-wallet';
|
|
8
9
|
export * from './rhs';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hash, Merkletree } from '@iden3/js-merkletree';
|
|
2
|
+
import { ProofNode } from './status/reverse-sparse-merkle-tree';
|
|
2
3
|
/**
|
|
3
4
|
* Interface to unite contains three trees: claim, revocation and rootOfRoots
|
|
4
5
|
* Also contains the current state of identity
|
|
@@ -17,6 +18,7 @@ export interface TreesModel {
|
|
|
17
18
|
* A reverse hash service (RHS) is a centralized or decentralized service for storing publicly available data about identity.
|
|
18
19
|
* Such data are identity state and state of revocation tree and roots tree root tree.
|
|
19
20
|
*
|
|
21
|
+
* @deprecated Use `pushHashesToReverseHashService` instead.
|
|
20
22
|
* @param {Hash} state - current state of identity
|
|
21
23
|
* @param {TreesModel} trees - current trees of identity (claims, revocation, rootOfRoots )
|
|
22
24
|
* @param {string} rhsUrl - URL of service
|
|
@@ -24,3 +26,12 @@ export interface TreesModel {
|
|
|
24
26
|
* @returns void
|
|
25
27
|
*/
|
|
26
28
|
export declare function pushHashesToRHS(state: Hash, trees: TreesModel, rhsUrl: string, revokedNonces?: number[]): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the representation of nodes for generating a proof.
|
|
31
|
+
*
|
|
32
|
+
* @param revokedNonces - An array of revoked nonces.
|
|
33
|
+
* @param trees - The TreesModel object containing the necessary trees.
|
|
34
|
+
* @param state - The hash of the state.
|
|
35
|
+
* @returns A Promise that resolves to an array of ProofNode objects.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getNodesRepresentation(revokedNonces: number[] | undefined, trees: TreesModel, state: Hash): Promise<ProofNode[]>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TransactionReceipt } from 'ethers';
|
|
2
|
+
import { JSONObject } from '../../iden3comm';
|
|
3
|
+
import { OnChainRevocationStorage } from '../../storage';
|
|
4
|
+
import { CredentialStatusType } from '../../verifiable';
|
|
5
|
+
import { ProofNode } from './reverse-sparse-merkle-tree';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a credential status publisher.
|
|
8
|
+
*/
|
|
9
|
+
export interface ICredentialStatusPublisher {
|
|
10
|
+
/**
|
|
11
|
+
* Publishes the credential status.
|
|
12
|
+
* @param params - The parameters for publishing the status.
|
|
13
|
+
* @returns A promise that resolves when the status is published.
|
|
14
|
+
*/
|
|
15
|
+
publish(params: JSONObject): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Registry for managing credential status publishers.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CredentialStatusPublisherRegistry {
|
|
21
|
+
private _publishers;
|
|
22
|
+
/**
|
|
23
|
+
* Registers one or more credential status publishers for a given type.
|
|
24
|
+
* @param type - The credential status type.
|
|
25
|
+
* @param publisher - One or more credential status publishers.
|
|
26
|
+
*/
|
|
27
|
+
register(type: CredentialStatusType, ...publisher: ICredentialStatusPublisher[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the credential status publishers for a given type.
|
|
30
|
+
* @param type - The credential status type.
|
|
31
|
+
* @returns An array of credential status publishers or undefined if none are registered for the given type.
|
|
32
|
+
*/
|
|
33
|
+
get(type: CredentialStatusType): ICredentialStatusPublisher[] | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Implementation of the ICredentialStatusPublisher interface for publishing on-chain credential status.
|
|
37
|
+
*/
|
|
38
|
+
export declare class Iden3OnchainSmtCredentialStatusPublisher implements ICredentialStatusPublisher {
|
|
39
|
+
private readonly _storage;
|
|
40
|
+
constructor(_storage: OnChainRevocationStorage);
|
|
41
|
+
/**
|
|
42
|
+
* Publishes the credential status to the blockchain.
|
|
43
|
+
* @param params - The parameters for publishing the credential status.
|
|
44
|
+
*/
|
|
45
|
+
publish(params: {
|
|
46
|
+
nodes: ProofNode[];
|
|
47
|
+
credentialStatusType: CredentialStatusType;
|
|
48
|
+
onChain?: {
|
|
49
|
+
txCallback?: (tx: TransactionReceipt) => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Implementation of the ICredentialStatusPublisher interface for publishing off-chain credential status.
|
|
55
|
+
*/
|
|
56
|
+
export declare class Iden3SmtRhsCredentialStatusPublisher implements ICredentialStatusPublisher {
|
|
57
|
+
/**
|
|
58
|
+
* Publishes the credential status to a specified node URL.
|
|
59
|
+
* @param params - The parameters for publishing the credential status.
|
|
60
|
+
* @param params.nodes - The proof nodes to be published.
|
|
61
|
+
* @param params.rhsUrl - The URL of the node to publish the credential status to.
|
|
62
|
+
* @returns A promise that resolves when the credential status is successfully published.
|
|
63
|
+
* @throws An error if the publishing fails.
|
|
64
|
+
*/
|
|
65
|
+
publish(params: {
|
|
66
|
+
nodes: ProofNode[];
|
|
67
|
+
credentialStatusType: CredentialStatusType;
|
|
68
|
+
rhsUrl: string;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DID } from '@iden3/js-iden3-core';
|
|
2
2
|
import { W3CCredential } from '../verifiable';
|
|
3
|
+
import { KmsKeyId } from '../kms';
|
|
3
4
|
/**
|
|
4
5
|
* Retrieves the user DID from a given credential.
|
|
5
6
|
* If the credential does not have a credentialSubject.id property, the issuer DID is returned.
|
|
@@ -10,3 +11,4 @@ import { W3CCredential } from '../verifiable';
|
|
|
10
11
|
* @throws Error if the credentialSubject.id is not a string.
|
|
11
12
|
*/
|
|
12
13
|
export declare const getUserDIDFromCredential: (issuerDID: DID, credential: W3CCredential) => DID;
|
|
14
|
+
export declare const getKMSIdByAuthCredential: (credential: W3CCredential) => KmsKeyId;
|
|
@@ -8,6 +8,7 @@ export declare const PROTOCOL_MESSAGE_TYPE: Readonly<{
|
|
|
8
8
|
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: string;
|
|
9
9
|
CREDENTIAL_OFFER_MESSAGE_TYPE: string;
|
|
10
10
|
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: string;
|
|
11
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: string;
|
|
11
12
|
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: string;
|
|
12
13
|
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: string;
|
|
13
14
|
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: string;
|
|
@@ -47,7 +47,7 @@ export interface IFetchHandler {
|
|
|
47
47
|
export declare class FetchHandler implements IFetchHandler {
|
|
48
48
|
private readonly _packerMgr;
|
|
49
49
|
/**
|
|
50
|
-
* Creates an instance of
|
|
50
|
+
* Creates an instance of FetchHandler.
|
|
51
51
|
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
52
52
|
*/
|
|
53
53
|
constructor(_packerMgr: IPackageManager);
|
|
@@ -58,7 +58,7 @@ export declare class FetchHandler implements IFetchHandler {
|
|
|
58
58
|
* offer: Uint8Array; offer - raw offer message
|
|
59
59
|
* opts
|
|
60
60
|
* }) options how to fetch credential
|
|
61
|
-
* @returns `Promise<W3CCredential>`
|
|
61
|
+
* @returns `Promise<W3CCredential[]>`
|
|
62
62
|
*/
|
|
63
63
|
handleCredentialOffer(offer: Uint8Array, opts?: FetchHandlerOptions): Promise<W3CCredential[]>;
|
|
64
64
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IPackageManager } from '../types';
|
|
2
|
+
import { W3CCredential } from '../../verifiable';
|
|
3
|
+
import { ICredentialWallet } from '../../credentials';
|
|
4
|
+
/**
|
|
5
|
+
* RefreshHandlerOptions contains options for RefreshHandler
|
|
6
|
+
* @public
|
|
7
|
+
* @interface RefreshHandlerOptions
|
|
8
|
+
*/
|
|
9
|
+
export interface RefreshHandlerOptions {
|
|
10
|
+
packageManager: IPackageManager;
|
|
11
|
+
credentialWallet?: ICredentialWallet;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* RefreshOptions contains options for refreshCredential call
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @interface RefreshOptions
|
|
19
|
+
*/
|
|
20
|
+
export interface RefreshOptions {
|
|
21
|
+
reason?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface to work with credential refresh handler
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
* @interface IRefreshHandler
|
|
28
|
+
*/
|
|
29
|
+
export interface IRefreshHandler {
|
|
30
|
+
/**
|
|
31
|
+
* refresh credential
|
|
32
|
+
*
|
|
33
|
+
* @param {W3CCredential} credential - credential to refresh
|
|
34
|
+
* @param {RefreshOptions} opts - options
|
|
35
|
+
* @returns {Promise<W3CCredential>}
|
|
36
|
+
*/
|
|
37
|
+
refreshCredential(credential: W3CCredential, opts?: RefreshOptions): Promise<W3CCredential>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* Allows to refresh credential from refresh service and return refreshed credential
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
|
|
45
|
+
* @class RefreshHandler
|
|
46
|
+
* @implements implements RefreshHandler interface
|
|
47
|
+
*/
|
|
48
|
+
export declare class RefreshHandler implements IRefreshHandler {
|
|
49
|
+
private readonly _options;
|
|
50
|
+
/**
|
|
51
|
+
* Creates an instance of RefreshHandler.
|
|
52
|
+
* @param {RefreshHandlerOptions} _options - refresh handler options
|
|
53
|
+
*/
|
|
54
|
+
constructor(_options: RefreshHandlerOptions);
|
|
55
|
+
refreshCredential(credential: W3CCredential, opts?: RefreshOptions): Promise<W3CCredential>;
|
|
56
|
+
}
|
|
@@ -71,3 +71,18 @@ export type Schema = {
|
|
|
71
71
|
url: string;
|
|
72
72
|
type: string;
|
|
73
73
|
};
|
|
74
|
+
/** CredentialRefreshMessage represent Iden3message for credential refresh request */
|
|
75
|
+
export type CredentialRefreshMessage = {
|
|
76
|
+
id: string;
|
|
77
|
+
typ?: MediaType;
|
|
78
|
+
type: ProtocolMessage;
|
|
79
|
+
thid?: string;
|
|
80
|
+
body?: CredentialRefreshMessageBody;
|
|
81
|
+
from?: string;
|
|
82
|
+
to?: string;
|
|
83
|
+
};
|
|
84
|
+
/** CredentialRefreshMessageBody is msg body for refresh request */
|
|
85
|
+
export type CredentialRefreshMessageBody = {
|
|
86
|
+
id: string;
|
|
87
|
+
reason: string;
|
|
88
|
+
};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
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
|
-
import { IDataStorage } from '../storage
|
|
4
|
+
import { IDataStorage, Profile } from '../storage';
|
|
5
5
|
import { W3CCredential, MerkleTreeProofWithTreeState, CredentialStatusType, ProofQuery } from '../verifiable';
|
|
6
6
|
import { CredentialRequest, ICredentialWallet, TreesModel } from '../credentials';
|
|
7
7
|
import { TreeState } from '../circuits';
|
|
8
8
|
import { Options } from '@iden3/js-jsonld-merklization';
|
|
9
|
-
import {
|
|
9
|
+
import { TransactionReceipt } from 'ethers';
|
|
10
|
+
import { CredentialStatusPublisherRegistry } from '../credentials/status/credential-status-publisher';
|
|
10
11
|
/**
|
|
11
12
|
* DID creation options
|
|
12
|
-
* seed - seed to generate BJJ
|
|
13
|
+
* seed - seed to generate BJJ key pair
|
|
13
14
|
* revocationOpts -
|
|
14
15
|
|
|
15
|
-
* @
|
|
16
|
+
* @type IdentityCreationOptions
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
+
export type IdentityCreationOptions = {
|
|
18
19
|
method?: string;
|
|
19
20
|
blockchain?: string;
|
|
20
21
|
networkId?: string;
|
|
@@ -22,9 +23,23 @@ export interface IdentityCreationOptions {
|
|
|
22
23
|
id: string;
|
|
23
24
|
type: CredentialStatusType;
|
|
24
25
|
nonce?: number;
|
|
26
|
+
onChain?: {
|
|
27
|
+
txCallback?: (tx: TransactionReceipt) => Promise<void>;
|
|
28
|
+
};
|
|
25
29
|
};
|
|
26
30
|
seed?: Uint8Array;
|
|
27
|
-
}
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Options for RevocationInfoOptions.
|
|
34
|
+
*/
|
|
35
|
+
export type RevocationInfoOptions = {
|
|
36
|
+
revokedNonces?: number[];
|
|
37
|
+
treeModel?: TreesModel;
|
|
38
|
+
rhsUrl?: string;
|
|
39
|
+
onChain?: {
|
|
40
|
+
txCallback?: (tx: TransactionReceipt) => Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
28
43
|
/**
|
|
29
44
|
* Proof creation result
|
|
30
45
|
*
|
|
@@ -151,23 +166,32 @@ export interface IIdentityWallet {
|
|
|
151
166
|
*/
|
|
152
167
|
addCredentialsToMerkleTree(credentials: W3CCredential[], issuerDID: DID): Promise<Iden3ProofCreationResult>;
|
|
153
168
|
/**
|
|
169
|
+
* Publishes issuer state to the reverse hash service by given URL
|
|
154
170
|
*
|
|
155
|
-
*
|
|
171
|
+
* @deprecated use publishRevocationInfoByCredentialStatusType instead with the same arguments in opts
|
|
156
172
|
* @param {DID} issuerDID - issuer did
|
|
157
173
|
* @param {string} rhsURL - reverse hash service URL
|
|
158
174
|
* @param {number[]} [revokedNonces] - revoked nonces for the period from the last published
|
|
159
175
|
* @returns `Promise<void>`
|
|
160
176
|
*/
|
|
161
|
-
publishStateToRHS(issuerDID: DID, rhsURL: string, revokedNonces?: number[]): Promise<void>;
|
|
177
|
+
publishStateToRHS(issuerDID: DID, rhsURL: string, revokedNonces?: number[], opts?: object): Promise<void>;
|
|
162
178
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
179
|
+
* Publishes specific state to the reverse hash service by given URL
|
|
180
|
+
* @deprecated use publishRevocationInfoByCredentialStatusType instead with the same arguments in opts
|
|
165
181
|
* @param {TreesModel} treeModel - trees model to publish
|
|
166
182
|
* @param {string} rhsURL - reverse hash service URL
|
|
167
183
|
* @param {number[]} [revokedNonces] - revoked nonces for the period from the last published
|
|
168
184
|
* @returns `Promise<void>`
|
|
169
185
|
*/
|
|
170
|
-
publishSpecificStateToRHS(treeModel: TreesModel, rhsURL: string, revokedNonces?: number[]): Promise<void>;
|
|
186
|
+
publishSpecificStateToRHS(treeModel: TreesModel, rhsURL: string, revokedNonces?: number[], opts?: object): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Publishes revocation info by credential status predefined publishers
|
|
189
|
+
*
|
|
190
|
+
* @param {(RevocationInfoOptions)} opts
|
|
191
|
+
* @returns {Promise<void>}
|
|
192
|
+
* @memberof IIdentityWallet
|
|
193
|
+
*/
|
|
194
|
+
publishRevocationInfoByCredentialStatusType(issuerDID: DID, credentialStatusType: CredentialStatusType, opts?: RevocationInfoOptions): Promise<void>;
|
|
171
195
|
/**
|
|
172
196
|
* Extracts core claim from signature or merkle tree proof. If both proof persists core claim must be the same
|
|
173
197
|
*
|
|
@@ -237,6 +261,8 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
237
261
|
private readonly _kms;
|
|
238
262
|
private readonly _storage;
|
|
239
263
|
private readonly _credentialWallet;
|
|
264
|
+
private readonly _opts?;
|
|
265
|
+
private readonly _credentialStatusPublisherRegistry;
|
|
240
266
|
/**
|
|
241
267
|
* Constructs a new instance of the `IdentityWallet` class
|
|
242
268
|
*
|
|
@@ -245,7 +271,9 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
245
271
|
* @param {ICredentialWallet} _credentialWallet - credential wallet instance to quickly access credential CRUD functionality
|
|
246
272
|
* @public
|
|
247
273
|
*/
|
|
248
|
-
constructor(_kms: KMS, _storage: IDataStorage, _credentialWallet: ICredentialWallet
|
|
274
|
+
constructor(_kms: KMS, _storage: IDataStorage, _credentialWallet: ICredentialWallet, _opts?: {
|
|
275
|
+
credentialStatusPublisherRegistry?: CredentialStatusPublisherRegistry | undefined;
|
|
276
|
+
} | undefined);
|
|
249
277
|
/**
|
|
250
278
|
* {@inheritDoc IIdentityWallet.createIdentity}
|
|
251
279
|
*/
|
|
@@ -293,7 +321,8 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
293
321
|
publishSpecificStateToRHS(treeModel: TreesModel, rhsURL: string, revokedNonces?: number[]): Promise<void>;
|
|
294
322
|
/** {@inheritDoc IIdentityWallet.publishStateToRHS} */
|
|
295
323
|
publishStateToRHS(issuerDID: DID, rhsURL: string, revokedNonces?: number[]): Promise<void>;
|
|
296
|
-
|
|
324
|
+
/** {@inheritDoc IIdentityWallet.publishRevocationInfoByCredentialStatusType} */
|
|
325
|
+
publishRevocationInfoByCredentialStatusType(issuerDID: DID, credentialStatusType: CredentialStatusType, opts?: RevocationInfoOptions): Promise<void>;
|
|
297
326
|
getCoreClaimFromCredential(credential: W3CCredential): Promise<Claim>;
|
|
298
327
|
findOwnedCredentialsByDID(did: DID, query: ProofQuery): Promise<W3CCredential[]>;
|
|
299
328
|
/** {@inheritDoc IIdentityWallet.updateIdentityState} */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RevocationStatus } from '../../verifiable';
|
|
2
|
+
import { Signer, TransactionReceipt } from 'ethers';
|
|
2
3
|
import { EthConnectionConfig } from './state';
|
|
3
4
|
/**
|
|
4
5
|
* OnChainRevocationStore is a class that allows to interact with the onchain contract
|
|
@@ -8,8 +9,10 @@ import { EthConnectionConfig } from './state';
|
|
|
8
9
|
* @class OnChainIssuer
|
|
9
10
|
*/
|
|
10
11
|
export declare class OnChainRevocationStorage {
|
|
11
|
-
private readonly
|
|
12
|
-
private
|
|
12
|
+
private readonly _config;
|
|
13
|
+
private _signer?;
|
|
14
|
+
private readonly _contract;
|
|
15
|
+
private readonly _provider;
|
|
13
16
|
/**
|
|
14
17
|
*
|
|
15
18
|
* Creates an instance of OnChainIssuer.
|
|
@@ -17,7 +20,7 @@ export declare class OnChainRevocationStorage {
|
|
|
17
20
|
* @param {string} - onhcain contract address
|
|
18
21
|
* @param {string} - rpc url to connect to the blockchain
|
|
19
22
|
*/
|
|
20
|
-
constructor(
|
|
23
|
+
constructor(_config: EthConnectionConfig, contractAddress: string, _signer?: Signer | undefined);
|
|
21
24
|
/**
|
|
22
25
|
* Get revocation status by issuerId, issuerState and nonce from the onchain.
|
|
23
26
|
* @public
|
|
@@ -30,6 +33,7 @@ export declare class OnChainRevocationStorage {
|
|
|
30
33
|
* @returns Promise<RevocationStatus>
|
|
31
34
|
*/
|
|
32
35
|
getRevocationStatus(issuerID: bigint, nonce: number): Promise<RevocationStatus>;
|
|
36
|
+
saveNodes(payload: bigint[][]): Promise<TransactionReceipt>;
|
|
33
37
|
private static convertIssuerInfo;
|
|
34
38
|
private static convertSmtProofToProof;
|
|
35
39
|
}
|
|
@@ -76,3 +76,11 @@ export declare enum SubjectPosition {
|
|
|
76
76
|
Index = "index",
|
|
77
77
|
Value = "value"
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* RefreshServiceType type for refreshService
|
|
81
|
+
*
|
|
82
|
+
* @enum {string}
|
|
83
|
+
*/
|
|
84
|
+
export declare enum RefreshServiceType {
|
|
85
|
+
Iden3RefreshService2023 = "Iden3RefreshService2023"
|
|
86
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus } from './proof';
|
|
1
|
+
import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus, RefreshService } from './proof';
|
|
2
2
|
import { Claim } from '@iden3/js-iden3-core';
|
|
3
3
|
import { ProofType } from './constants';
|
|
4
4
|
import { Proof } from '@iden3/js-merkletree';
|
|
@@ -16,6 +16,7 @@ export declare class W3CCredential {
|
|
|
16
16
|
'@context': string[];
|
|
17
17
|
type: string[];
|
|
18
18
|
expirationDate?: string;
|
|
19
|
+
refreshService?: RefreshService;
|
|
19
20
|
issuanceDate?: string;
|
|
20
21
|
credentialSubject: {
|
|
21
22
|
[key: string]: object | string | number | boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hash, Proof } from '@iden3/js-merkletree';
|
|
2
|
-
import { ProofType, CredentialStatusType } from './constants';
|
|
2
|
+
import { ProofType, CredentialStatusType, RefreshServiceType } from './constants';
|
|
3
3
|
import { TreeState } from '../circuits';
|
|
4
4
|
import { Signature } from '@iden3/js-crypto';
|
|
5
5
|
import { Claim, DID } from '@iden3/js-iden3-core';
|
|
@@ -184,3 +184,12 @@ export interface CredentialStatus {
|
|
|
184
184
|
revocationNonce?: number;
|
|
185
185
|
statusIssuer?: CredentialStatus;
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* RefreshService contains type and id
|
|
189
|
+
* @public
|
|
190
|
+
* @interface RefreshService
|
|
191
|
+
*/
|
|
192
|
+
export interface RefreshService {
|
|
193
|
+
id: string;
|
|
194
|
+
type: RefreshServiceType | string;
|
|
195
|
+
}
|