@0xpolygonid/js-sdk 1.17.2 → 1.17.4
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 +24 -32
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +24 -32
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/constants.js +19 -19
- package/dist/node/cjs/storage/blockchain/state.js +5 -13
- package/dist/node/esm/iden3comm/constants.js +19 -19
- package/dist/node/esm/storage/blockchain/state.js +5 -13
- package/dist/types/iden3comm/constants.d.ts +19 -19
- package/dist/types/iden3comm/types/packer.d.ts +2 -2
- package/dist/types/iden3comm/types/protocol/auth.d.ts +3 -0
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +2 -0
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +10 -3
- package/dist/types/iden3comm/types/protocol/messages.d.ts +3 -1
- package/dist/types/iden3comm/types/protocol/payment.d.ts +3 -0
- package/dist/types/iden3comm/types/protocol/proof.d.ts +5 -2
- package/dist/types/iden3comm/types/protocol/proposal-request.d.ts +6 -3
- package/dist/types/iden3comm/types/protocol/revocation.d.ts +5 -2
- package/package.json +3 -2
|
@@ -7,43 +7,43 @@ const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
|
|
|
7
7
|
*/
|
|
8
8
|
exports.PROTOCOL_MESSAGE_TYPE = Object.freeze({
|
|
9
9
|
// AuthorizationV2RequestMessageType defines auth request type of the communication protocol
|
|
10
|
-
AUTHORIZATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
10
|
+
AUTHORIZATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/request`,
|
|
11
11
|
// AuthorizationResponseMessageType defines auth response type of the communication protocol
|
|
12
|
-
AUTHORIZATION_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
12
|
+
AUTHORIZATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/response`,
|
|
13
13
|
// CredentialIssuanceRequestMessageType accepts request for credential creation
|
|
14
|
-
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
14
|
+
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-request`,
|
|
15
15
|
// CredentialFetchRequestMessageType is type for request of credential generation
|
|
16
|
-
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
16
|
+
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/fetch-request`,
|
|
17
17
|
// CredentialOfferMessageType is type of message with credential offering
|
|
18
|
-
CREDENTIAL_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
18
|
+
CREDENTIAL_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/offer`,
|
|
19
19
|
// CredentialIssuanceResponseMessageType is type for message with a credential issuance
|
|
20
|
-
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
20
|
+
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-response`,
|
|
21
21
|
// CredentialRefreshMessageType is type for message with a credential issuance
|
|
22
|
-
CREDENTIAL_REFRESH_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
22
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/refresh`,
|
|
23
23
|
// DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
|
|
24
|
-
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
24
|
+
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}devices/1.0/registration`,
|
|
25
25
|
// MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
|
|
26
|
-
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
26
|
+
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}messages/1.0/fetch`,
|
|
27
27
|
// ProofGenerationRequestMessageType is type for request of proof generation
|
|
28
|
-
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
28
|
+
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/request`,
|
|
29
29
|
// ProofGenerationResponseMessageType is type for response of proof generation
|
|
30
|
-
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
30
|
+
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/response`,
|
|
31
31
|
// RevocationStatusRequestMessageType is type for request of revocation status
|
|
32
|
-
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
32
|
+
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/request-status`,
|
|
33
33
|
// RevocationStatusResponseMessageType is type for response with a revocation status
|
|
34
|
-
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
34
|
+
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/status`,
|
|
35
35
|
// ContractInvokeRequestMessageType is type for request of contract invoke request
|
|
36
|
-
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
36
|
+
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-request`,
|
|
37
37
|
// CredentialOnchainOfferMessageType is type of message with credential onchain offering
|
|
38
|
-
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
38
|
+
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/onchain-offer`,
|
|
39
39
|
// ProposalRequestMessageType is type for proposal-request message
|
|
40
|
-
PROPOSAL_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
40
|
+
PROPOSAL_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal-request`,
|
|
41
41
|
// ProposalMessageType is type for proposal message
|
|
42
|
-
PROPOSAL_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
42
|
+
PROPOSAL_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal`,
|
|
43
43
|
// PaymentRequestMessageType is type for payment-request message
|
|
44
|
-
PAYMENT_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
44
|
+
PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request`,
|
|
45
45
|
// PaymentMessageType is type for payment message
|
|
46
|
-
PAYMENT_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
46
|
+
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment`
|
|
47
47
|
});
|
|
48
48
|
/**
|
|
49
49
|
* Media types for iden3 comm communication protocol
|
|
@@ -176,12 +176,6 @@ class EthStateStorage {
|
|
|
176
176
|
}
|
|
177
177
|
getStateContractAndProviderForId(id) {
|
|
178
178
|
const idTyped = js_iden3_core_1.Id.fromBigInt(id);
|
|
179
|
-
if (!Array.isArray(this.ethConfig)) {
|
|
180
|
-
return {
|
|
181
|
-
stateContract: this.stateContract,
|
|
182
|
-
provider: this.provider
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
179
|
const chainId = (0, js_iden3_core_1.getChainId)(js_iden3_core_1.DID.blockchainFromId(idTyped), js_iden3_core_1.DID.networkIdFromId(idTyped));
|
|
186
180
|
const config = this.networkByChainId(chainId);
|
|
187
181
|
const provider = new ethers_1.JsonRpcProvider(config.url);
|
|
@@ -189,14 +183,12 @@ class EthStateStorage {
|
|
|
189
183
|
return { stateContract, provider };
|
|
190
184
|
}
|
|
191
185
|
networkByChainId(chainId) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
return network;
|
|
186
|
+
const config = Array.isArray(this.ethConfig) ? this.ethConfig : [this.ethConfig];
|
|
187
|
+
const network = config.find((c) => c.chainId === chainId);
|
|
188
|
+
if (!network) {
|
|
189
|
+
throw new Error(`chainId "${chainId}" not supported`);
|
|
198
190
|
}
|
|
199
|
-
return
|
|
191
|
+
return network;
|
|
200
192
|
}
|
|
201
193
|
}
|
|
202
194
|
exports.EthStateStorage = EthStateStorage;
|
|
@@ -4,43 +4,43 @@ const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
|
|
|
4
4
|
*/
|
|
5
5
|
export const PROTOCOL_MESSAGE_TYPE = Object.freeze({
|
|
6
6
|
// AuthorizationV2RequestMessageType defines auth request type of the communication protocol
|
|
7
|
-
AUTHORIZATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
7
|
+
AUTHORIZATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/request`,
|
|
8
8
|
// AuthorizationResponseMessageType defines auth response type of the communication protocol
|
|
9
|
-
AUTHORIZATION_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
9
|
+
AUTHORIZATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}authorization/1.0/response`,
|
|
10
10
|
// CredentialIssuanceRequestMessageType accepts request for credential creation
|
|
11
|
-
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
11
|
+
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-request`,
|
|
12
12
|
// CredentialFetchRequestMessageType is type for request of credential generation
|
|
13
|
-
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
13
|
+
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/fetch-request`,
|
|
14
14
|
// CredentialOfferMessageType is type of message with credential offering
|
|
15
|
-
CREDENTIAL_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
15
|
+
CREDENTIAL_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/offer`,
|
|
16
16
|
// CredentialIssuanceResponseMessageType is type for message with a credential issuance
|
|
17
|
-
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
17
|
+
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/issuance-response`,
|
|
18
18
|
// CredentialRefreshMessageType is type for message with a credential issuance
|
|
19
|
-
CREDENTIAL_REFRESH_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
19
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/refresh`,
|
|
20
20
|
// DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
|
|
21
|
-
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
21
|
+
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}devices/1.0/registration`,
|
|
22
22
|
// MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
|
|
23
|
-
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
23
|
+
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}messages/1.0/fetch`,
|
|
24
24
|
// ProofGenerationRequestMessageType is type for request of proof generation
|
|
25
|
-
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
25
|
+
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/request`,
|
|
26
26
|
// ProofGenerationResponseMessageType is type for response of proof generation
|
|
27
|
-
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
27
|
+
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/response`,
|
|
28
28
|
// RevocationStatusRequestMessageType is type for request of revocation status
|
|
29
|
-
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
29
|
+
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/request-status`,
|
|
30
30
|
// RevocationStatusResponseMessageType is type for response with a revocation status
|
|
31
|
-
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
31
|
+
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: `${IDEN3_PROTOCOL}revocation/1.0/status`,
|
|
32
32
|
// ContractInvokeRequestMessageType is type for request of contract invoke request
|
|
33
|
-
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
33
|
+
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}proofs/1.0/contract-invoke-request`,
|
|
34
34
|
// CredentialOnchainOfferMessageType is type of message with credential onchain offering
|
|
35
|
-
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
35
|
+
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/1.0/onchain-offer`,
|
|
36
36
|
// ProposalRequestMessageType is type for proposal-request message
|
|
37
|
-
PROPOSAL_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
37
|
+
PROPOSAL_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal-request`,
|
|
38
38
|
// ProposalMessageType is type for proposal message
|
|
39
|
-
PROPOSAL_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
39
|
+
PROPOSAL_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/proposal`,
|
|
40
40
|
// PaymentRequestMessageType is type for payment-request message
|
|
41
|
-
PAYMENT_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
41
|
+
PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request`,
|
|
42
42
|
// PaymentMessageType is type for payment message
|
|
43
|
-
PAYMENT_MESSAGE_TYPE: IDEN3_PROTOCOL
|
|
43
|
+
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment`
|
|
44
44
|
});
|
|
45
45
|
/**
|
|
46
46
|
* Media types for iden3 comm communication protocol
|
|
@@ -170,12 +170,6 @@ export class EthStateStorage {
|
|
|
170
170
|
}
|
|
171
171
|
getStateContractAndProviderForId(id) {
|
|
172
172
|
const idTyped = Id.fromBigInt(id);
|
|
173
|
-
if (!Array.isArray(this.ethConfig)) {
|
|
174
|
-
return {
|
|
175
|
-
stateContract: this.stateContract,
|
|
176
|
-
provider: this.provider
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
173
|
const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped));
|
|
180
174
|
const config = this.networkByChainId(chainId);
|
|
181
175
|
const provider = new JsonRpcProvider(config.url);
|
|
@@ -183,13 +177,11 @@ export class EthStateStorage {
|
|
|
183
177
|
return { stateContract, provider };
|
|
184
178
|
}
|
|
185
179
|
networkByChainId(chainId) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
return network;
|
|
180
|
+
const config = Array.isArray(this.ethConfig) ? this.ethConfig : [this.ethConfig];
|
|
181
|
+
const network = config.find((c) => c.chainId === chainId);
|
|
182
|
+
if (!network) {
|
|
183
|
+
throw new Error(`chainId "${chainId}" not supported`);
|
|
192
184
|
}
|
|
193
|
-
return
|
|
185
|
+
return network;
|
|
194
186
|
}
|
|
195
187
|
}
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
* Constants for Iden3 protocol
|
|
3
3
|
*/
|
|
4
4
|
export declare const PROTOCOL_MESSAGE_TYPE: Readonly<{
|
|
5
|
-
AUTHORIZATION_REQUEST_MESSAGE_TYPE:
|
|
6
|
-
AUTHORIZATION_RESPONSE_MESSAGE_TYPE:
|
|
7
|
-
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE:
|
|
8
|
-
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE:
|
|
9
|
-
CREDENTIAL_OFFER_MESSAGE_TYPE:
|
|
10
|
-
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE:
|
|
11
|
-
CREDENTIAL_REFRESH_MESSAGE_TYPE:
|
|
12
|
-
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE:
|
|
13
|
-
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE:
|
|
14
|
-
PROOF_GENERATION_REQUEST_MESSAGE_TYPE:
|
|
15
|
-
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE:
|
|
16
|
-
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE:
|
|
17
|
-
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE:
|
|
18
|
-
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE:
|
|
19
|
-
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE:
|
|
20
|
-
PROPOSAL_REQUEST_MESSAGE_TYPE:
|
|
21
|
-
PROPOSAL_MESSAGE_TYPE:
|
|
22
|
-
PAYMENT_REQUEST_MESSAGE_TYPE:
|
|
23
|
-
PAYMENT_MESSAGE_TYPE:
|
|
5
|
+
AUTHORIZATION_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/authorization/1.0/request";
|
|
6
|
+
AUTHORIZATION_RESPONSE_MESSAGE_TYPE: "https://iden3-communication.io/authorization/1.0/response";
|
|
7
|
+
CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/credentials/1.0/issuance-request";
|
|
8
|
+
CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/credentials/1.0/fetch-request";
|
|
9
|
+
CREDENTIAL_OFFER_MESSAGE_TYPE: "https://iden3-communication.io/credentials/1.0/offer";
|
|
10
|
+
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: "https://iden3-communication.io/credentials/1.0/issuance-response";
|
|
11
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: "https://iden3-communication.io/credentials/1.0/refresh";
|
|
12
|
+
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/devices/1.0/registration";
|
|
13
|
+
MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/messages/1.0/fetch";
|
|
14
|
+
PROOF_GENERATION_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/proofs/1.0/request";
|
|
15
|
+
PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: "https://iden3-communication.io/proofs/1.0/response";
|
|
16
|
+
REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/revocation/1.0/request-status";
|
|
17
|
+
REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: "https://iden3-communication.io/revocation/1.0/status";
|
|
18
|
+
CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/proofs/1.0/contract-invoke-request";
|
|
19
|
+
CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: "https://iden3-communication.io/credentials/1.0/onchain-offer";
|
|
20
|
+
PROPOSAL_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/credentials/0.1/proposal-request";
|
|
21
|
+
PROPOSAL_MESSAGE_TYPE: "https://iden3-communication.io/credentials/0.1/proposal";
|
|
22
|
+
PAYMENT_REQUEST_MESSAGE_TYPE: "https://iden3-communication.io/credentials/0.1/payment-request";
|
|
23
|
+
PAYMENT_MESSAGE_TYPE: "https://iden3-communication.io/credentials/0.1/payment";
|
|
24
24
|
}>;
|
|
25
25
|
/**
|
|
26
26
|
* Media types for iden3 comm communication protocol
|
|
@@ -2,13 +2,13 @@ import { DID } from '@iden3/js-iden3-core';
|
|
|
2
2
|
import { DataPrepareHandlerFunc, VerificationHandlerFunc } from '../packers';
|
|
3
3
|
import { ProvingMethodAlg } from '@iden3/js-jwz';
|
|
4
4
|
import { CircuitId } from '../../circuits';
|
|
5
|
-
import { MediaType } from '../constants';
|
|
5
|
+
import { MediaType, PROTOCOL_MESSAGE_TYPE } from '../constants';
|
|
6
6
|
import { DIDDocument, VerificationMethod } from 'did-resolver';
|
|
7
7
|
import { StateVerificationOpts } from './models';
|
|
8
8
|
/**
|
|
9
9
|
* Protocol message type
|
|
10
10
|
*/
|
|
11
|
-
export type ProtocolMessage =
|
|
11
|
+
export type ProtocolMessage = (typeof PROTOCOL_MESSAGE_TYPE)[keyof typeof PROTOCOL_MESSAGE_TYPE];
|
|
12
12
|
/**
|
|
13
13
|
* JSONValue
|
|
14
14
|
*/
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ZKProof } from '@iden3/js-jwz';
|
|
2
2
|
import { BasicMessage, JSONObject } from '../packer';
|
|
3
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
3
4
|
/** AuthorizationResponseMessage is struct the represents iden3message authorization response */
|
|
4
5
|
export type AuthorizationResponseMessage = BasicMessage & {
|
|
5
6
|
body: AuthorizationMessageResponseBody;
|
|
6
7
|
from: string;
|
|
7
8
|
to: string;
|
|
9
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_RESPONSE_MESSAGE_TYPE;
|
|
8
10
|
};
|
|
9
11
|
/** AuthorizationMessageResponseBody is struct the represents authorization response data */
|
|
10
12
|
export type AuthorizationMessageResponseBody = {
|
|
@@ -16,6 +18,7 @@ export type AuthorizationMessageResponseBody = {
|
|
|
16
18
|
export type AuthorizationRequestMessage = BasicMessage & {
|
|
17
19
|
body: AuthorizationRequestMessageBody;
|
|
18
20
|
from: string;
|
|
21
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE;
|
|
19
22
|
};
|
|
20
23
|
/** AuthorizationRequestMessageBody is body for authorization request */
|
|
21
24
|
export type AuthorizationRequestMessageBody = {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
1
2
|
import { BasicMessage } from '../packer';
|
|
2
3
|
import { ZeroKnowledgeProofRequest } from './auth';
|
|
3
4
|
/** ContractInvokeRequest represents structure of contract invoke request object */
|
|
4
5
|
export type ContractInvokeRequest = BasicMessage & {
|
|
5
6
|
body: ContractInvokeRequestBody;
|
|
7
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE;
|
|
6
8
|
};
|
|
7
9
|
/** ContractInvokeRequestBody represents structure of contract invoke request body object */
|
|
8
10
|
export type ContractInvokeRequestBody = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { W3CCredential } from '../../../verifiable';
|
|
2
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
2
3
|
import { BasicMessage, JSONObject } from '../packer';
|
|
3
4
|
import { ContractInvokeTransactionData } from './contract-request';
|
|
4
5
|
/** CredentialIssuanceRequestMessageBody represents data for credential issuance request */
|
|
@@ -10,19 +11,22 @@ export type CredentialIssuanceRequestMessageBody = {
|
|
|
10
11
|
/** CredentialIssuanceRequestMessage represent Iden3message for credential request */
|
|
11
12
|
export type CredentialIssuanceRequestMessage = Required<BasicMessage> & {
|
|
12
13
|
body: CredentialIssuanceRequestMessageBody;
|
|
14
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE;
|
|
13
15
|
};
|
|
14
16
|
/** CredentialsOfferMessage represent Iden3message for credential offer */
|
|
15
17
|
export type CredentialsOfferMessage = Required<BasicMessage> & {
|
|
16
18
|
body: CredentialsOfferMessageBody;
|
|
19
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_OFFER_MESSAGE_TYPE;
|
|
17
20
|
};
|
|
18
21
|
/** CredentialsOfferMessageBody is struct the represents offer message */
|
|
19
22
|
export type CredentialsOfferMessageBody = {
|
|
20
23
|
url: string;
|
|
21
24
|
credentials: CredentialOffer[];
|
|
22
25
|
};
|
|
23
|
-
/** CredentialsOnchainOfferMessage represent Iden3message for credential
|
|
26
|
+
/** CredentialsOnchainOfferMessage represent Iden3message for credential onchain offer message */
|
|
24
27
|
export type CredentialsOnchainOfferMessage = Required<BasicMessage> & {
|
|
25
28
|
body: CredentialsOnchainOfferMessageBody;
|
|
29
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE;
|
|
26
30
|
};
|
|
27
31
|
/** CredentialsOnchainOfferMessageBody is struct the represents onchain offer message body */
|
|
28
32
|
export type CredentialsOnchainOfferMessageBody = {
|
|
@@ -44,6 +48,7 @@ export type CredentialOffer = {
|
|
|
44
48
|
/** CredentialIssuanceMessage represent Iden3message for credential issuance */
|
|
45
49
|
export type CredentialIssuanceMessage = Required<BasicMessage> & {
|
|
46
50
|
body: IssuanceMessageBody;
|
|
51
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE;
|
|
47
52
|
};
|
|
48
53
|
/** IssuanceMessageBody is struct the represents message when credential is issued */
|
|
49
54
|
export type IssuanceMessageBody = {
|
|
@@ -51,7 +56,8 @@ export type IssuanceMessageBody = {
|
|
|
51
56
|
};
|
|
52
57
|
/** CredentialFetchRequestMessage represent Iden3message for credential fetch request */
|
|
53
58
|
export type CredentialFetchRequestMessage = BasicMessage & {
|
|
54
|
-
body
|
|
59
|
+
body: CredentialFetchRequestMessageBody;
|
|
60
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE;
|
|
55
61
|
};
|
|
56
62
|
/** CredentialFetchRequestMessageBody is msg body for fetch request */
|
|
57
63
|
export type CredentialFetchRequestMessageBody = {
|
|
@@ -65,7 +71,8 @@ export type Schema = {
|
|
|
65
71
|
};
|
|
66
72
|
/** CredentialRefreshMessage represent Iden3message for credential refresh request */
|
|
67
73
|
export type CredentialRefreshMessage = Required<BasicMessage> & {
|
|
68
|
-
body
|
|
74
|
+
body: CredentialRefreshMessageBody;
|
|
75
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE;
|
|
69
76
|
};
|
|
70
77
|
/** CredentialRefreshMessageBody is msg body for refresh request */
|
|
71
78
|
export type CredentialRefreshMessageBody = {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BasicMessage } from '../';
|
|
2
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
2
3
|
/** MessageFetchRequestMessage represent Iden3message for message fetch request. */
|
|
3
4
|
export type MessageFetchRequestMessage = Required<BasicMessage> & {
|
|
4
|
-
body
|
|
5
|
+
body: MessageFetchRequestMessageBody;
|
|
6
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE;
|
|
5
7
|
};
|
|
6
8
|
/** MessageFetchRequestMessageBody is struct the represents body for message fetch request. */
|
|
7
9
|
export type MessageFetchRequestMessageBody = {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { BasicMessage } from '../';
|
|
2
2
|
import { PaymentRequestDataType, PaymentRequestType, PaymentType } from '../../../verifiable';
|
|
3
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
3
4
|
/** @beta PaymentRequestMessage is struct the represents payment-request message */
|
|
4
5
|
export type PaymentRequestMessage = BasicMessage & {
|
|
5
6
|
body: PaymentRequestMessageBody;
|
|
7
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.PAYMENT_REQUEST_MESSAGE_TYPE;
|
|
6
8
|
};
|
|
7
9
|
/** @beta PaymentRequestMessageBody is struct the represents body for payment-request */
|
|
8
10
|
export type PaymentRequestMessageBody = {
|
|
@@ -33,6 +35,7 @@ export type PaymentRequestDataInfo = {
|
|
|
33
35
|
/** @beta PaymentMessage is struct the represents payment message */
|
|
34
36
|
export type PaymentMessage = BasicMessage & {
|
|
35
37
|
body: PaymentMessageBody;
|
|
38
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.PAYMENT_MESSAGE_TYPE;
|
|
36
39
|
};
|
|
37
40
|
/** @beta PaymentMessageBody is struct the represents body for payment message */
|
|
38
41
|
export type PaymentMessageBody = {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { BasicMessage } from '../';
|
|
2
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
2
3
|
import { ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from './auth';
|
|
3
4
|
/** ProofGenerationRequestMessage is struct the represents body for proof generation request */
|
|
4
5
|
export type ProofGenerationRequestMessage = Required<BasicMessage> & {
|
|
5
|
-
body
|
|
6
|
+
body: ProofGenerationRequestMessageBody;
|
|
7
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.PROOF_GENERATION_REQUEST_MESSAGE_TYPE;
|
|
6
8
|
};
|
|
7
9
|
/** ProofGenerationRequestMessageBody is struct the represents body for proof generation request */
|
|
8
10
|
export type ProofGenerationRequestMessageBody = {
|
|
@@ -10,7 +12,8 @@ export type ProofGenerationRequestMessageBody = {
|
|
|
10
12
|
};
|
|
11
13
|
/** ProofGenerationResponseMessage is struct the represents body for proof generation request */
|
|
12
14
|
export type ProofGenerationResponseMessage = Required<BasicMessage> & {
|
|
13
|
-
body
|
|
15
|
+
body: ResponseMessageBody;
|
|
16
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.PROOF_GENERATION_RESPONSE_MESSAGE_TYPE;
|
|
14
17
|
};
|
|
15
18
|
/** ResponseMessageBody is struct the represents request for revocation status */
|
|
16
19
|
export type ResponseMessageBody = {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BasicMessage, JSONObject } from '../';
|
|
2
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
2
3
|
/** @beta ProposalRequestMessage is struct the represents proposal-request message */
|
|
3
4
|
export type ProposalRequestMessage = BasicMessage & {
|
|
4
|
-
body
|
|
5
|
+
body: ProposalRequestMessageBody;
|
|
6
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.PROPOSAL_REQUEST_MESSAGE_TYPE;
|
|
5
7
|
};
|
|
6
8
|
/** @beta ProposalRequestMessageBody is struct the represents body for proposal-request */
|
|
7
9
|
export type ProposalRequestMessageBody = {
|
|
@@ -14,7 +16,8 @@ export type ProposalRequestMessageBody = {
|
|
|
14
16
|
};
|
|
15
17
|
/** @beta ProposalMessage is struct the represents proposal message */
|
|
16
18
|
export type ProposalMessage = BasicMessage & {
|
|
17
|
-
body
|
|
19
|
+
body: ProposalMessageBody;
|
|
20
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.PROPOSAL_MESSAGE_TYPE;
|
|
18
21
|
};
|
|
19
22
|
/** @beta ProposalMessageBody is struct the represents body for proposal message */
|
|
20
23
|
export type ProposalMessageBody = {
|
|
@@ -27,7 +30,7 @@ export type ProposalRequestCredential = {
|
|
|
27
30
|
};
|
|
28
31
|
/** @beta Proposal is struct the represents proposal inside proposal protocol message */
|
|
29
32
|
export type Proposal = {
|
|
30
|
-
credentials
|
|
33
|
+
credentials: ProposalRequestCredential[];
|
|
31
34
|
type: string;
|
|
32
35
|
url?: string;
|
|
33
36
|
expiration?: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { BasicMessage } from '../';
|
|
2
2
|
import { RevocationStatus } from '../../../verifiable';
|
|
3
|
+
import { PROTOCOL_MESSAGE_TYPE } from '../../constants';
|
|
3
4
|
/** RevocationStatusRequestMessage is struct the represents body for proof generation request */
|
|
4
5
|
export type RevocationStatusRequestMessage = BasicMessage & {
|
|
5
|
-
body
|
|
6
|
+
body: RevocationStatusRequestMessageBody;
|
|
7
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_REQUEST_MESSAGE_TYPE;
|
|
6
8
|
};
|
|
7
9
|
/** RevocationStatusRequestMessageBody is struct the represents request for revocation status */
|
|
8
10
|
export type RevocationStatusRequestMessageBody = {
|
|
@@ -10,7 +12,8 @@ export type RevocationStatusRequestMessageBody = {
|
|
|
10
12
|
};
|
|
11
13
|
/** RevocationStatusResponseMessage is struct the represents body for proof generation request */
|
|
12
14
|
export type RevocationStatusResponseMessage = Required<BasicMessage> & {
|
|
13
|
-
body
|
|
15
|
+
body: RevocationStatusResponseMessageBody;
|
|
16
|
+
type: typeof PROTOCOL_MESSAGE_TYPE.REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE;
|
|
14
17
|
};
|
|
15
18
|
/** RevocationStatusResponseMessageBody is struct the represents request for revocation status */
|
|
16
19
|
export type RevocationStatusResponseMessageBody = RevocationStatus;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
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",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"lint": "eslint --fix --ext .ts src/** tests/**",
|
|
37
37
|
"lint:check": "eslint --ext .ts src/** tests/**",
|
|
38
38
|
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
39
|
-
"format:check": "prettier \"src/**/*.ts\" \"tests/**/*.ts\" --check"
|
|
39
|
+
"format:check": "prettier \"src/**/*.ts\" \"tests/**/*.ts\" --check",
|
|
40
|
+
"watch": "tsc --watch"
|
|
40
41
|
},
|
|
41
42
|
"repository": {
|
|
42
43
|
"type": "git",
|