@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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BasicMessage, IPackageManager } from '../types';
|
|
2
|
+
import { AuthMessageHandlerOptions } from './auth';
|
|
3
|
+
import { RevocationStatusMessageHandlerOptions } from './revocation-status';
|
|
4
|
+
import { ContractMessageHandlerOptions } from './contract-request';
|
|
5
|
+
/**
|
|
6
|
+
* iden3 Protocol message handler interface
|
|
7
|
+
*/
|
|
8
|
+
export interface IProtocolMessageHandler {
|
|
9
|
+
/**
|
|
10
|
+
* Handel message implementation
|
|
11
|
+
*
|
|
12
|
+
* @param {BasicMessage} message
|
|
13
|
+
* @param {{ [key: string]: unknown }} ctx context
|
|
14
|
+
* @returns {(Promise<BasicMessage | null>)}
|
|
15
|
+
* @memberof IProtocolMessageHandler
|
|
16
|
+
*/
|
|
17
|
+
handle(message: BasicMessage, ctx: {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}): Promise<BasicMessage | null>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Base implementation of protocol message handler
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
* @abstract
|
|
26
|
+
* @class AbstractMessageHandler
|
|
27
|
+
* @implements {IProtocolMessageHandler}
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class AbstractMessageHandler implements IProtocolMessageHandler {
|
|
30
|
+
nextMessageHandler?: AbstractMessageHandler;
|
|
31
|
+
setNext(messageHandler: AbstractMessageHandler): AbstractMessageHandler;
|
|
32
|
+
handle(message: BasicMessage, context: {
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}): Promise<BasicMessage | null>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Protocol message handler entry point
|
|
38
|
+
*/
|
|
39
|
+
export declare class MessageHandler {
|
|
40
|
+
private readonly _params;
|
|
41
|
+
private messageHandler?;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an instance of MessageHandler.
|
|
44
|
+
* @param {{
|
|
45
|
+
* messageHandlers: AbstractMessageHandler[];
|
|
46
|
+
* packageManager: IPackageManager;
|
|
47
|
+
* }} _params
|
|
48
|
+
* @memberof MessageHandler
|
|
49
|
+
*/
|
|
50
|
+
constructor(_params: {
|
|
51
|
+
messageHandlers: AbstractMessageHandler[];
|
|
52
|
+
packageManager: IPackageManager;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Registers a list of message handlers and sets up the chain of responsibility.
|
|
56
|
+
*
|
|
57
|
+
* This method takes an array of `AbstractMessageHandler` instances and sets up a chain of responsibility
|
|
58
|
+
* where each handler is linked to the next one in the array. The first handler in the array becomes the
|
|
59
|
+
* main message handler for the `MessageHandler` class.
|
|
60
|
+
*
|
|
61
|
+
* @param {AbstractMessageHandler[]} handlersList - An array of `AbstractMessageHandler` instances to be registered.
|
|
62
|
+
* @returns {void}
|
|
63
|
+
*/
|
|
64
|
+
registerHandlers(handlersList: AbstractMessageHandler[]): void;
|
|
65
|
+
/**
|
|
66
|
+
* Handles a message by unpacking it, passing it to the registered message handler, and packing the response.
|
|
67
|
+
*
|
|
68
|
+
* This method takes a Uint8Array of message bytes and a context object that contains information specific to the
|
|
69
|
+
* type of message being handled (e.g. AuthMessageHandlerOptions, ContractMessageHandlerOptions, etc.).
|
|
70
|
+
*
|
|
71
|
+
* The method first unpacks the message using the provided package manager, then passes the unpacked message and
|
|
72
|
+
* context to the registered message handler. If the message handler returns a response, the method packs the
|
|
73
|
+
* response using the package manager and returns it. If the message handler does not return a response, the
|
|
74
|
+
* method returns null.
|
|
75
|
+
*
|
|
76
|
+
* @param bytes - A Uint8Array of message bytes to be handled.
|
|
77
|
+
* @param context - An object containing information specific to the type of message being handled.
|
|
78
|
+
* @returns A Promise that resolves to a Uint8Array of the packed response, or null if no response was generated.
|
|
79
|
+
*/
|
|
80
|
+
handleMessage(bytes: Uint8Array, context: AuthMessageHandlerOptions | ContractMessageHandlerOptions | RevocationStatusMessageHandlerOptions | ContractMessageHandlerOptions | {
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}): Promise<Uint8Array | null>;
|
|
83
|
+
}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { MediaType } from '../constants';
|
|
2
|
-
import { IPackageManager, JWSPackerParams, RevocationStatusRequestMessage } from '../types';
|
|
2
|
+
import { BasicMessage, IPackageManager, JWSPackerParams, RevocationStatusRequestMessage } from '../types';
|
|
3
3
|
import { DID } from '@iden3/js-iden3-core';
|
|
4
4
|
import { TreeState } from '../../circuits';
|
|
5
5
|
import { IIdentityWallet } from '../../identity';
|
|
6
|
+
import { AbstractMessageHandler, IProtocolMessageHandler } from './message-handler';
|
|
7
|
+
/**
|
|
8
|
+
* Defines the options for a RevocationStatusMessageHandler.
|
|
9
|
+
* @property did - The DID (Decentralized Identifier) to be used.
|
|
10
|
+
* @property mediaType - The media type to be used.
|
|
11
|
+
* @property packerOptions - Optional parameters for the JWS packer.
|
|
12
|
+
* @property treeState - Optional tree state to be used.
|
|
13
|
+
*/
|
|
14
|
+
export type RevocationStatusMessageHandlerOptions = {
|
|
15
|
+
did: DID;
|
|
16
|
+
mediaType: MediaType;
|
|
17
|
+
packerOptions?: JWSPackerParams;
|
|
18
|
+
treeState?: TreeState;
|
|
19
|
+
};
|
|
6
20
|
/**
|
|
7
21
|
* Interface that allows the processing of the revocation status
|
|
8
22
|
*
|
|
@@ -38,7 +52,7 @@ export type RevocationStatusHandlerOptions = {
|
|
|
38
52
|
* @class RevocationStatusHandler
|
|
39
53
|
* @implements implements IRevocationStatusHandler interface
|
|
40
54
|
*/
|
|
41
|
-
export declare class RevocationStatusHandler implements IRevocationStatusHandler {
|
|
55
|
+
export declare class RevocationStatusHandler extends AbstractMessageHandler implements IRevocationStatusHandler, IProtocolMessageHandler {
|
|
42
56
|
private readonly _packerMgr;
|
|
43
57
|
private readonly _identityWallet;
|
|
44
58
|
/**
|
|
@@ -48,6 +62,8 @@ export declare class RevocationStatusHandler implements IRevocationStatusHandler
|
|
|
48
62
|
*
|
|
49
63
|
*/
|
|
50
64
|
constructor(_packerMgr: IPackageManager, _identityWallet: IIdentityWallet);
|
|
65
|
+
handle(message: BasicMessage, context: RevocationStatusMessageHandlerOptions): Promise<BasicMessage | null>;
|
|
66
|
+
private handleRevocationStatusRequestMessage;
|
|
51
67
|
/**
|
|
52
68
|
* @inheritdoc IRevocationStatusHandler#parseRevocationStatusRequest
|
|
53
69
|
*/
|
|
@@ -17,6 +17,16 @@ export declare class PackageManager implements IPackageManager {
|
|
|
17
17
|
registerPackers(packers: Array<IPacker>): void;
|
|
18
18
|
/** {@inheritDoc IPackageManager.pack} */
|
|
19
19
|
pack(mediaType: MediaType, payload: Uint8Array, params: PackerParams): Promise<Uint8Array>;
|
|
20
|
+
/**
|
|
21
|
+
* Packs a protocol message using the specified media type and packer parameters.
|
|
22
|
+
*
|
|
23
|
+
* @param mediaType - The media type to use for packing the message.
|
|
24
|
+
* @param protocolMessage - The protocol message to pack.
|
|
25
|
+
* @param params - The packer parameters.
|
|
26
|
+
* @returns A promise that resolves to the packed message as a Uint8Array.
|
|
27
|
+
* @throws An error if the packer for the specified media type is not found.
|
|
28
|
+
*/
|
|
29
|
+
packMessage(mediaType: MediaType, protocolMessage: BasicMessage, params: PackerParams): Promise<Uint8Array>;
|
|
20
30
|
/** {@inheritDoc IPackageManager.unpack} */
|
|
21
31
|
unpack(envelope: Uint8Array): Promise<{
|
|
22
32
|
unpackedMessage: BasicMessage;
|
|
@@ -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
|
|
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,
|
|
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 {
|
|
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
|
|
13
|
-
to
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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;
|