@0xpolygonid/js-sdk 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/esm/index.js +194 -11
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +196 -10
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/constants.js +5 -1
- package/dist/node/cjs/iden3comm/handlers/credential-proposal.js +213 -0
- package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
- package/dist/node/cjs/iden3comm/types/index.js +1 -0
- package/dist/node/cjs/iden3comm/types/protocol/proposal-request.js +2 -0
- package/dist/node/cjs/proof/proof-service.js +2 -1
- package/dist/node/cjs/proof/verifiers/pub-signals-verifier.js +5 -6
- package/dist/node/cjs/storage/blockchain/state.js +2 -2
- package/dist/node/esm/iden3comm/constants.js +5 -1
- package/dist/node/esm/iden3comm/handlers/credential-proposal.js +184 -0
- package/dist/node/esm/iden3comm/handlers/index.js +1 -0
- package/dist/node/esm/iden3comm/types/index.js +1 -0
- package/dist/node/esm/iden3comm/types/protocol/proposal-request.js +1 -0
- package/dist/node/esm/proof/proof-service.js +2 -1
- package/dist/node/esm/proof/verifiers/pub-signals-verifier.js +5 -6
- package/dist/node/esm/storage/blockchain/state.js +2 -2
- package/dist/types/iden3comm/constants.d.ts +2 -0
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +112 -0
- package/dist/types/iden3comm/handlers/index.d.ts +1 -0
- package/dist/types/iden3comm/types/index.d.ts +1 -0
- package/dist/types/iden3comm/types/protocol/proposal-request.d.ts +35 -0
- package/dist/types/proof/proof-service.d.ts +1 -1
- package/dist/types/storage/blockchain/state.d.ts +1 -1
- package/dist/types/storage/interfaces/state.d.ts +5 -4
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { IPackageManager, JSONObject, PackerParams } from '../types';
|
|
2
|
+
import { DID } from '@iden3/js-iden3-core';
|
|
3
|
+
import { Proposal, ProposalRequestCredential, ProposalRequestMessage, ProposalMessage } from '../types/protocol/proposal-request';
|
|
4
|
+
import { IIdentityWallet } from '../../identity';
|
|
5
|
+
/** @beta ProposalRequestCreationOptions represents proposal-request creation options */
|
|
6
|
+
export type ProposalRequestCreationOptions = {
|
|
7
|
+
credentials: ProposalRequestCredential[];
|
|
8
|
+
metadata?: {
|
|
9
|
+
type: string;
|
|
10
|
+
data?: JSONObject;
|
|
11
|
+
};
|
|
12
|
+
did_doc?: JSONObject;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @beta
|
|
16
|
+
* createProposalRequest is a function to create protocol proposal-request protocol message
|
|
17
|
+
* @param {DID} sender - sender did
|
|
18
|
+
* @param {DID} receiver - receiver did
|
|
19
|
+
* @param {ProposalRequestCreationOptions} opts - creation options
|
|
20
|
+
* @returns `Promise<ProposalRequestMessage>`
|
|
21
|
+
*/
|
|
22
|
+
export declare function createProposalRequest(sender: DID, receiver: DID, opts: ProposalRequestCreationOptions): ProposalRequestMessage;
|
|
23
|
+
/**
|
|
24
|
+
* @beta
|
|
25
|
+
* createProposal is a function to create protocol proposal protocol message
|
|
26
|
+
* @param {DID} sender - sender did
|
|
27
|
+
* @param {DID} receiver - receiver did
|
|
28
|
+
* @param {Proposal[]} proposals - proposals
|
|
29
|
+
* @returns `Promise<ProposalRequestMessage>`
|
|
30
|
+
*/
|
|
31
|
+
export declare function createProposal(sender: DID, receiver: DID, proposals?: Proposal[]): ProposalMessage;
|
|
32
|
+
/**
|
|
33
|
+
* @beta
|
|
34
|
+
* Interface that allows the processing of the proposal-request
|
|
35
|
+
*
|
|
36
|
+
* @interface ICredentialProposalHandler
|
|
37
|
+
*/
|
|
38
|
+
export interface ICredentialProposalHandler {
|
|
39
|
+
/**
|
|
40
|
+
* @beta
|
|
41
|
+
* unpacks proposal-request
|
|
42
|
+
* @param {Uint8Array} request - raw byte message
|
|
43
|
+
* @returns `Promise<ProposalRequestMessage>`
|
|
44
|
+
*/
|
|
45
|
+
parseProposalRequest(request: Uint8Array): Promise<ProposalRequestMessage>;
|
|
46
|
+
/**
|
|
47
|
+
* @beta
|
|
48
|
+
* handle proposal-request
|
|
49
|
+
* @param {Uint8Array} request - raw byte message
|
|
50
|
+
* @param {ProposalRequestHandlerOptions} opts - handler options
|
|
51
|
+
* @returns {Promise<Uint8Array>}` - proposal response message
|
|
52
|
+
*/
|
|
53
|
+
handleProposalRequest(request: Uint8Array, opts?: ProposalRequestHandlerOptions): Promise<Uint8Array>;
|
|
54
|
+
/**
|
|
55
|
+
* @beta
|
|
56
|
+
* handle proposal protocol message
|
|
57
|
+
* @param {ProposalMessage} proposal - proposal message
|
|
58
|
+
* @param {ProposalHandlerOptions} opts - options
|
|
59
|
+
* @returns `Promise<{
|
|
60
|
+
proposal: ProposalMessage;
|
|
61
|
+
}>`
|
|
62
|
+
*/
|
|
63
|
+
handleProposal(proposal: ProposalMessage, opts?: ProposalHandlerOptions): Promise<{
|
|
64
|
+
proposal: ProposalMessage;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
/** @beta ProposalRequestHandlerOptions represents proposal-request handler options */
|
|
68
|
+
export type ProposalRequestHandlerOptions = object;
|
|
69
|
+
/** @beta ProposalHandlerOptions represents proposal handler options */
|
|
70
|
+
export type ProposalHandlerOptions = {
|
|
71
|
+
proposalRequest?: ProposalRequestMessage;
|
|
72
|
+
};
|
|
73
|
+
/** @beta CredentialProposalHandlerParams represents credential proposal handler params */
|
|
74
|
+
export type CredentialProposalHandlerParams = {
|
|
75
|
+
agentUrl: string;
|
|
76
|
+
proposalResolverFn: (context: string, type: string) => Promise<Proposal>;
|
|
77
|
+
packerParams: PackerParams;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* Allows to process ProposalRequest protocol message
|
|
82
|
+
* @beta
|
|
83
|
+
* @class CredentialProposalHandler
|
|
84
|
+
* @implements implements ICredentialProposalHandler interface
|
|
85
|
+
*/
|
|
86
|
+
export declare class CredentialProposalHandler implements ICredentialProposalHandler {
|
|
87
|
+
private readonly _packerMgr;
|
|
88
|
+
private readonly _identityWallet;
|
|
89
|
+
private readonly _params;
|
|
90
|
+
/**
|
|
91
|
+
* @beta Creates an instance of CredentialProposalHandler.
|
|
92
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
93
|
+
* @param {IIdentityWallet} _identityWallet - identity wallet
|
|
94
|
+
* @param {CredentialProposalHandlerParams} _params - credential proposal handler params
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
constructor(_packerMgr: IPackageManager, _identityWallet: IIdentityWallet, _params: CredentialProposalHandlerParams);
|
|
98
|
+
/**
|
|
99
|
+
* @inheritdoc ICredentialProposalHandler#parseProposalRequest
|
|
100
|
+
*/
|
|
101
|
+
parseProposalRequest(request: Uint8Array): Promise<ProposalRequestMessage>;
|
|
102
|
+
/**
|
|
103
|
+
* @inheritdoc ICredentialProposalHandler#handleProposalRequest
|
|
104
|
+
*/
|
|
105
|
+
handleProposalRequest(request: Uint8Array, opts?: ProposalRequestHandlerOptions): Promise<Uint8Array>;
|
|
106
|
+
/**
|
|
107
|
+
* @inheritdoc ICredentialProposalHandler#handleProposal
|
|
108
|
+
*/
|
|
109
|
+
handleProposal(proposal: ProposalMessage, opts?: ProposalHandlerOptions): Promise<{
|
|
110
|
+
proposal: ProposalMessage;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BasicMessage, JSONObject } from '../';
|
|
2
|
+
/** @beta ProposalRequestMessage is struct the represents proposal-request message */
|
|
3
|
+
export type ProposalRequestMessage = BasicMessage & {
|
|
4
|
+
body?: ProposalRequestMessageBody;
|
|
5
|
+
};
|
|
6
|
+
/** @beta ProposalRequestMessageBody is struct the represents body for proposal-request */
|
|
7
|
+
export type ProposalRequestMessageBody = {
|
|
8
|
+
credentials: ProposalRequestCredential[];
|
|
9
|
+
metadata?: {
|
|
10
|
+
type: string;
|
|
11
|
+
data?: JSONObject;
|
|
12
|
+
};
|
|
13
|
+
did_doc?: JSONObject;
|
|
14
|
+
};
|
|
15
|
+
/** @beta ProposalMessage is struct the represents proposal message */
|
|
16
|
+
export type ProposalMessage = BasicMessage & {
|
|
17
|
+
body?: ProposalMessageBody;
|
|
18
|
+
};
|
|
19
|
+
/** @beta ProposalMessageBody is struct the represents body for proposal message */
|
|
20
|
+
export type ProposalMessageBody = {
|
|
21
|
+
proposals: Proposal[];
|
|
22
|
+
};
|
|
23
|
+
/** @beta ProposalRequestCredential is struct the represents proposal request credential */
|
|
24
|
+
export type ProposalRequestCredential = {
|
|
25
|
+
type: string;
|
|
26
|
+
context: string;
|
|
27
|
+
};
|
|
28
|
+
/** @beta Proposal is struct the represents proposal inside proposal protocol message */
|
|
29
|
+
export type Proposal = {
|
|
30
|
+
credentials?: ProposalRequestCredential[];
|
|
31
|
+
type: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
expiration?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
};
|
|
@@ -139,7 +139,7 @@ export declare class ProofService implements IProofService {
|
|
|
139
139
|
private loadLdContext;
|
|
140
140
|
/** {@inheritdoc IProofService.generateAuthV2Inputs} */
|
|
141
141
|
generateAuthV2Inputs(hash: Uint8Array, did: DID, circuitId: CircuitId): Promise<Uint8Array>;
|
|
142
|
-
verifyState(circuitId: string, pubSignals:
|
|
142
|
+
verifyState(circuitId: string, pubSignals: string[]): Promise<boolean>;
|
|
143
143
|
findCredentialByProofQuery(did: DID, query: ProofQuery): Promise<{
|
|
144
144
|
cred: W3CCredential;
|
|
145
145
|
revStatus: RevocationStatus | undefined;
|
|
@@ -51,7 +51,7 @@ export declare class EthStateStorage implements IStateStorage {
|
|
|
51
51
|
/** {@inheritdoc IStateStorage.getGISTProof} */
|
|
52
52
|
getGISTProof(id: bigint): Promise<StateProof>;
|
|
53
53
|
/** {@inheritdoc IStateStorage.getGISTRootInfo} */
|
|
54
|
-
getGISTRootInfo(id: bigint): Promise<RootInfo>;
|
|
54
|
+
getGISTRootInfo(root: bigint, id: bigint): Promise<RootInfo>;
|
|
55
55
|
private getStateContractAndProviderForId;
|
|
56
56
|
private networkByChainId;
|
|
57
57
|
}
|
|
@@ -39,10 +39,11 @@ export interface IStateStorage {
|
|
|
39
39
|
*/
|
|
40
40
|
getGISTProof(id: bigint): Promise<StateProof>;
|
|
41
41
|
/**
|
|
42
|
+
* gets root info of global identity state tree
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
-
* @param {bigint}
|
|
45
|
-
* @returns `
|
|
44
|
+
* @param {bigint} root - root to check
|
|
45
|
+
* @param {bigint} userId - user id
|
|
46
|
+
* @returns `Promise<RootInfo>`
|
|
46
47
|
*/
|
|
47
|
-
getGISTRootInfo(root: bigint): Promise<RootInfo>;
|
|
48
|
+
getGISTRootInfo(root: bigint, userId: bigint): Promise<RootInfo>;
|
|
48
49
|
}
|