@0xpolygonid/js-sdk 1.4.2 → 1.5.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/dist/browser/esm/index.js +368 -474
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +488 -593
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/status/on-chain-revocation.js +1 -2
- package/dist/node/cjs/storage/blockchain/index.js +0 -1
- package/dist/node/esm/credentials/status/on-chain-revocation.js +1 -2
- package/dist/node/esm/storage/blockchain/index.js +0 -1
- package/dist/types/identity/identity-wallet.d.ts +4 -4
- package/dist/types/storage/blockchain/index.d.ts +0 -1
- package/package.json +3 -3
- package/dist/node/cjs/storage/blockchain/chainid.js +0 -113
- package/dist/node/esm/storage/blockchain/chainid.js +0 -105
- package/dist/types/storage/blockchain/chainid.d.ts +0 -68
|
@@ -6,7 +6,6 @@ const js_iden3_core_1 = require("@iden3/js-iden3-core");
|
|
|
6
6
|
const constants_1 = require("../../verifiable/constants");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const state_1 = require("../../storage/blockchain/state");
|
|
9
|
-
const blockchain_1 = require("../../storage/blockchain");
|
|
10
9
|
const js_merkletree_1 = require("@iden3/js-merkletree");
|
|
11
10
|
/**
|
|
12
11
|
* OnChainIssuer is a class that allows to interact with the onchain contract
|
|
@@ -124,7 +123,7 @@ class OnChainResolver {
|
|
|
124
123
|
// TODO (illia-korotia): is dirty hack for mock in tests.
|
|
125
124
|
// need to pass to constructor list of state stores not list of network configs
|
|
126
125
|
_getStateStorageForIssuer(issuerId) {
|
|
127
|
-
const issuerChainId = (0,
|
|
126
|
+
const issuerChainId = (0, js_iden3_core_1.getChainId)(js_iden3_core_1.DID.blockchainFromId(issuerId), js_iden3_core_1.DID.networkIdFromId(issuerId));
|
|
128
127
|
const ethStorage = new state_1.EthStateStorage(this.networkByChainId(issuerChainId));
|
|
129
128
|
return ethStorage;
|
|
130
129
|
}
|
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./state"), exports);
|
|
18
|
-
__exportStar(require("./chainid"), exports);
|
|
19
18
|
__exportStar(require("./onchain-zkp-verifier"), exports);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { OnChainRevocationStorage } from '../../storage/blockchain/onchain-revocation';
|
|
2
|
-
import { DID } from '@iden3/js-iden3-core';
|
|
2
|
+
import { DID, getChainId } from '@iden3/js-iden3-core';
|
|
3
3
|
import { VerifiableConstants } from '../../verifiable/constants';
|
|
4
4
|
import { isGenesisState } from './utils';
|
|
5
5
|
import { EthStateStorage } from '../../storage/blockchain/state';
|
|
6
|
-
import { getChainId } from '../../storage/blockchain';
|
|
7
6
|
import { Hash } from '@iden3/js-merkletree';
|
|
8
7
|
/**
|
|
9
8
|
* OnChainIssuer is a class that allows to interact with the onchain contract
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KMS, KmsKeyId, KmsKeyType } from '../kms';
|
|
2
|
-
import {
|
|
2
|
+
import { Claim, DID } from '@iden3/js-iden3-core';
|
|
3
3
|
import { Signature } from '@iden3/js-crypto';
|
|
4
4
|
import { IDataStorage } from '../storage/interfaces/data-storage';
|
|
5
5
|
import { W3CCredential, MerkleTreeProofWithTreeState, CredentialStatusType, ProofQuery } from '../verifiable';
|
|
@@ -15,9 +15,9 @@ import { Profile } from '../storage';
|
|
|
15
15
|
* @interface IdentityCreationOptions
|
|
16
16
|
*/
|
|
17
17
|
export interface IdentityCreationOptions {
|
|
18
|
-
method?:
|
|
19
|
-
blockchain?:
|
|
20
|
-
networkId?:
|
|
18
|
+
method?: string;
|
|
19
|
+
blockchain?: string;
|
|
20
|
+
networkId?: string;
|
|
21
21
|
revocationOpts: {
|
|
22
22
|
id: string;
|
|
23
23
|
type: CredentialStatusType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@iden3/js-crypto": "1.0.3",
|
|
89
|
-
"@iden3/js-iden3-core": "1.1
|
|
89
|
+
"@iden3/js-iden3-core": "1.2.1",
|
|
90
90
|
"@iden3/js-jsonld-merklization": "1.1.2",
|
|
91
|
-
"@iden3/js-jwz": "1.1
|
|
91
|
+
"@iden3/js-jwz": "1.2.1",
|
|
92
92
|
"@iden3/js-merkletree": "1.1.2",
|
|
93
93
|
"ffjavascript": "0.2.62",
|
|
94
94
|
"snarkjs": "0.7.2",
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChainIdByDIDsParts = exports.getDefaultNetworkForMethodId = exports.registerDefaultNetworkForMethodId = exports.getChainId = exports.registerChainId = exports.DEFAULT_NETWORKS = exports.CHAIN_IDS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Object containing chain IDs for various blockchains and networks.
|
|
6
|
-
* @type { [key: string]: number }
|
|
7
|
-
*/
|
|
8
|
-
exports.CHAIN_IDS = {
|
|
9
|
-
eth: 1,
|
|
10
|
-
'eth:main': 1,
|
|
11
|
-
'eth:goerli': 5,
|
|
12
|
-
'eth:sepolia': 11155111,
|
|
13
|
-
polygon: 137,
|
|
14
|
-
'polygon:main': 137,
|
|
15
|
-
'polygon:mumbai': 80001,
|
|
16
|
-
zkevm: 1101,
|
|
17
|
-
'zkevm:main': 1101,
|
|
18
|
-
'zkevm:test': 1442
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Object containing default networks for DIDs.
|
|
22
|
-
* @type { [key: string]: number }
|
|
23
|
-
*/
|
|
24
|
-
exports.DEFAULT_NETWORKS = {
|
|
25
|
-
ethr: 1,
|
|
26
|
-
polygonid: 137
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Registers a new chain ID for a blockchain and network combination.
|
|
30
|
-
* @param {string} blockchain - The blockchain name.
|
|
31
|
-
* @param {number} chainId - The chain ID to be registered.
|
|
32
|
-
* @param {string} network - The network name.
|
|
33
|
-
* @beta This API will change in the future.
|
|
34
|
-
* @example
|
|
35
|
-
* registerChainId('eth', 3, 'ropsten');
|
|
36
|
-
*/
|
|
37
|
-
const registerChainId = (blockchain, chainId, network) => {
|
|
38
|
-
if (network) {
|
|
39
|
-
blockchain += `:${network}`;
|
|
40
|
-
}
|
|
41
|
-
exports.CHAIN_IDS[blockchain] = chainId;
|
|
42
|
-
};
|
|
43
|
-
exports.registerChainId = registerChainId;
|
|
44
|
-
/**
|
|
45
|
-
* Gets the chain ID for a given blockchain and network combination.
|
|
46
|
-
* If the chain ID is not found, 0 will be returned.
|
|
47
|
-
* @param {string} blockchain - The blockchain name.
|
|
48
|
-
* @param {string} network - The network name.
|
|
49
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
50
|
-
* @throws {Error} Throws an error if the chainId not found.
|
|
51
|
-
* @beta This API will change in the future.
|
|
52
|
-
* @example
|
|
53
|
-
* const chainId = getChainId('ethr', eth', 'main');
|
|
54
|
-
* // chainId will be 1
|
|
55
|
-
*/
|
|
56
|
-
const getChainId = (blockchain, network) => {
|
|
57
|
-
if (network) {
|
|
58
|
-
blockchain += `:${network}`;
|
|
59
|
-
}
|
|
60
|
-
const chainId = exports.CHAIN_IDS[blockchain];
|
|
61
|
-
if (!chainId) {
|
|
62
|
-
throw new Error(`chainId not found for ${blockchain}`);
|
|
63
|
-
}
|
|
64
|
-
return chainId;
|
|
65
|
-
};
|
|
66
|
-
exports.getChainId = getChainId;
|
|
67
|
-
/**
|
|
68
|
-
* Registers a default chain ID for methodId.
|
|
69
|
-
* @param {string} blockchain - The blockchain name.
|
|
70
|
-
* @param {number} chainId - The chain ID to be registered.
|
|
71
|
-
* @param {string} network - The network name.
|
|
72
|
-
* @beta This API will change in the future.
|
|
73
|
-
* @example
|
|
74
|
-
* registerChainId('polygonid', 137);
|
|
75
|
-
*/
|
|
76
|
-
const registerDefaultNetworkForMethodId = (methodId, chainId) => {
|
|
77
|
-
exports.DEFAULT_NETWORKS[methodId] = chainId;
|
|
78
|
-
};
|
|
79
|
-
exports.registerDefaultNetworkForMethodId = registerDefaultNetworkForMethodId;
|
|
80
|
-
/**
|
|
81
|
-
* Gets the chain ID for a given methodId.
|
|
82
|
-
* If the chain ID is not found, 0 will be returned.
|
|
83
|
-
* @param {string} methodId - The blockchain name.
|
|
84
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
85
|
-
* @throws {Error} Throws an error if the chainId not found.
|
|
86
|
-
* @beta This API will change in the future.
|
|
87
|
-
* @example
|
|
88
|
-
* const chainId = getChainId('polygonid');
|
|
89
|
-
* // chainId will be 137
|
|
90
|
-
*/
|
|
91
|
-
const getDefaultNetworkForMethodId = (methodId) => {
|
|
92
|
-
const chainId = exports.DEFAULT_NETWORKS[methodId];
|
|
93
|
-
if (!chainId) {
|
|
94
|
-
throw new Error(`chainId not found for ${methodId}`);
|
|
95
|
-
}
|
|
96
|
-
return chainId;
|
|
97
|
-
};
|
|
98
|
-
exports.getDefaultNetworkForMethodId = getDefaultNetworkForMethodId;
|
|
99
|
-
/**
|
|
100
|
-
* Gets the chain ID for a given methodId, blockchain and network combination.
|
|
101
|
-
* @param {string} methodId - The blockchain name.
|
|
102
|
-
* @param {string} blockchain - The blockchain name.
|
|
103
|
-
* @param {string} network - The network name.
|
|
104
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
105
|
-
* @beta This API will change in the future.
|
|
106
|
-
*/
|
|
107
|
-
const getChainIdByDIDsParts = (methodId, blockchain, network) => {
|
|
108
|
-
if (!blockchain) {
|
|
109
|
-
return (0, exports.getDefaultNetworkForMethodId)(methodId);
|
|
110
|
-
}
|
|
111
|
-
return (0, exports.getChainId)(blockchain, network);
|
|
112
|
-
};
|
|
113
|
-
exports.getChainIdByDIDsParts = getChainIdByDIDsParts;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object containing chain IDs for various blockchains and networks.
|
|
3
|
-
* @type { [key: string]: number }
|
|
4
|
-
*/
|
|
5
|
-
export const CHAIN_IDS = {
|
|
6
|
-
eth: 1,
|
|
7
|
-
'eth:main': 1,
|
|
8
|
-
'eth:goerli': 5,
|
|
9
|
-
'eth:sepolia': 11155111,
|
|
10
|
-
polygon: 137,
|
|
11
|
-
'polygon:main': 137,
|
|
12
|
-
'polygon:mumbai': 80001,
|
|
13
|
-
zkevm: 1101,
|
|
14
|
-
'zkevm:main': 1101,
|
|
15
|
-
'zkevm:test': 1442
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Object containing default networks for DIDs.
|
|
19
|
-
* @type { [key: string]: number }
|
|
20
|
-
*/
|
|
21
|
-
export const DEFAULT_NETWORKS = {
|
|
22
|
-
ethr: 1,
|
|
23
|
-
polygonid: 137
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Registers a new chain ID for a blockchain and network combination.
|
|
27
|
-
* @param {string} blockchain - The blockchain name.
|
|
28
|
-
* @param {number} chainId - The chain ID to be registered.
|
|
29
|
-
* @param {string} network - The network name.
|
|
30
|
-
* @beta This API will change in the future.
|
|
31
|
-
* @example
|
|
32
|
-
* registerChainId('eth', 3, 'ropsten');
|
|
33
|
-
*/
|
|
34
|
-
export const registerChainId = (blockchain, chainId, network) => {
|
|
35
|
-
if (network) {
|
|
36
|
-
blockchain += `:${network}`;
|
|
37
|
-
}
|
|
38
|
-
CHAIN_IDS[blockchain] = chainId;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Gets the chain ID for a given blockchain and network combination.
|
|
42
|
-
* If the chain ID is not found, 0 will be returned.
|
|
43
|
-
* @param {string} blockchain - The blockchain name.
|
|
44
|
-
* @param {string} network - The network name.
|
|
45
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
46
|
-
* @throws {Error} Throws an error if the chainId not found.
|
|
47
|
-
* @beta This API will change in the future.
|
|
48
|
-
* @example
|
|
49
|
-
* const chainId = getChainId('ethr', eth', 'main');
|
|
50
|
-
* // chainId will be 1
|
|
51
|
-
*/
|
|
52
|
-
export const getChainId = (blockchain, network) => {
|
|
53
|
-
if (network) {
|
|
54
|
-
blockchain += `:${network}`;
|
|
55
|
-
}
|
|
56
|
-
const chainId = CHAIN_IDS[blockchain];
|
|
57
|
-
if (!chainId) {
|
|
58
|
-
throw new Error(`chainId not found for ${blockchain}`);
|
|
59
|
-
}
|
|
60
|
-
return chainId;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Registers a default chain ID for methodId.
|
|
64
|
-
* @param {string} blockchain - The blockchain name.
|
|
65
|
-
* @param {number} chainId - The chain ID to be registered.
|
|
66
|
-
* @param {string} network - The network name.
|
|
67
|
-
* @beta This API will change in the future.
|
|
68
|
-
* @example
|
|
69
|
-
* registerChainId('polygonid', 137);
|
|
70
|
-
*/
|
|
71
|
-
export const registerDefaultNetworkForMethodId = (methodId, chainId) => {
|
|
72
|
-
DEFAULT_NETWORKS[methodId] = chainId;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Gets the chain ID for a given methodId.
|
|
76
|
-
* If the chain ID is not found, 0 will be returned.
|
|
77
|
-
* @param {string} methodId - The blockchain name.
|
|
78
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
79
|
-
* @throws {Error} Throws an error if the chainId not found.
|
|
80
|
-
* @beta This API will change in the future.
|
|
81
|
-
* @example
|
|
82
|
-
* const chainId = getChainId('polygonid');
|
|
83
|
-
* // chainId will be 137
|
|
84
|
-
*/
|
|
85
|
-
export const getDefaultNetworkForMethodId = (methodId) => {
|
|
86
|
-
const chainId = DEFAULT_NETWORKS[methodId];
|
|
87
|
-
if (!chainId) {
|
|
88
|
-
throw new Error(`chainId not found for ${methodId}`);
|
|
89
|
-
}
|
|
90
|
-
return chainId;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Gets the chain ID for a given methodId, blockchain and network combination.
|
|
94
|
-
* @param {string} methodId - The blockchain name.
|
|
95
|
-
* @param {string} blockchain - The blockchain name.
|
|
96
|
-
* @param {string} network - The network name.
|
|
97
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
98
|
-
* @beta This API will change in the future.
|
|
99
|
-
*/
|
|
100
|
-
export const getChainIdByDIDsParts = (methodId, blockchain, network) => {
|
|
101
|
-
if (!blockchain) {
|
|
102
|
-
return getDefaultNetworkForMethodId(methodId);
|
|
103
|
-
}
|
|
104
|
-
return getChainId(blockchain, network);
|
|
105
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object containing chain IDs for various blockchains and networks.
|
|
3
|
-
* @type { [key: string]: number }
|
|
4
|
-
*/
|
|
5
|
-
export declare const CHAIN_IDS: {
|
|
6
|
-
[key: string]: number;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Object containing default networks for DIDs.
|
|
10
|
-
* @type { [key: string]: number }
|
|
11
|
-
*/
|
|
12
|
-
export declare const DEFAULT_NETWORKS: {
|
|
13
|
-
[key: string]: number;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Registers a new chain ID for a blockchain and network combination.
|
|
17
|
-
* @param {string} blockchain - The blockchain name.
|
|
18
|
-
* @param {number} chainId - The chain ID to be registered.
|
|
19
|
-
* @param {string} network - The network name.
|
|
20
|
-
* @beta This API will change in the future.
|
|
21
|
-
* @example
|
|
22
|
-
* registerChainId('eth', 3, 'ropsten');
|
|
23
|
-
*/
|
|
24
|
-
export declare const registerChainId: (blockchain: string, chainId: number, network?: string) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Gets the chain ID for a given blockchain and network combination.
|
|
27
|
-
* If the chain ID is not found, 0 will be returned.
|
|
28
|
-
* @param {string} blockchain - The blockchain name.
|
|
29
|
-
* @param {string} network - The network name.
|
|
30
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
31
|
-
* @throws {Error} Throws an error if the chainId not found.
|
|
32
|
-
* @beta This API will change in the future.
|
|
33
|
-
* @example
|
|
34
|
-
* const chainId = getChainId('ethr', eth', 'main');
|
|
35
|
-
* // chainId will be 1
|
|
36
|
-
*/
|
|
37
|
-
export declare const getChainId: (blockchain: string, network?: string) => number;
|
|
38
|
-
/**
|
|
39
|
-
* Registers a default chain ID for methodId.
|
|
40
|
-
* @param {string} blockchain - The blockchain name.
|
|
41
|
-
* @param {number} chainId - The chain ID to be registered.
|
|
42
|
-
* @param {string} network - The network name.
|
|
43
|
-
* @beta This API will change in the future.
|
|
44
|
-
* @example
|
|
45
|
-
* registerChainId('polygonid', 137);
|
|
46
|
-
*/
|
|
47
|
-
export declare const registerDefaultNetworkForMethodId: (methodId: string, chainId: number) => void;
|
|
48
|
-
/**
|
|
49
|
-
* Gets the chain ID for a given methodId.
|
|
50
|
-
* If the chain ID is not found, 0 will be returned.
|
|
51
|
-
* @param {string} methodId - The blockchain name.
|
|
52
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
53
|
-
* @throws {Error} Throws an error if the chainId not found.
|
|
54
|
-
* @beta This API will change in the future.
|
|
55
|
-
* @example
|
|
56
|
-
* const chainId = getChainId('polygonid');
|
|
57
|
-
* // chainId will be 137
|
|
58
|
-
*/
|
|
59
|
-
export declare const getDefaultNetworkForMethodId: (methodId: string) => number;
|
|
60
|
-
/**
|
|
61
|
-
* Gets the chain ID for a given methodId, blockchain and network combination.
|
|
62
|
-
* @param {string} methodId - The blockchain name.
|
|
63
|
-
* @param {string} blockchain - The blockchain name.
|
|
64
|
-
* @param {string} network - The network name.
|
|
65
|
-
* @returns {number} The chain ID for the specified blockchain and network.
|
|
66
|
-
* @beta This API will change in the future.
|
|
67
|
-
*/
|
|
68
|
-
export declare const getChainIdByDIDsParts: (methodId: string, blockchain?: string, network?: string) => number;
|