@0xpolygonid/js-sdk 1.18.4 → 1.20.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/dist/browser/esm/index.js +200 -55
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +321 -176
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/status/on-chain-revocation.js +1 -1
- package/dist/node/cjs/identity/common.js +14 -2
- package/dist/node/cjs/proof/provers/witness_calculator.js +4 -4
- package/dist/node/cjs/storage/blockchain/onchain-revocation.js +1 -1
- package/dist/node/cjs/verifiable/constants.js +2 -2
- package/dist/node/cjs/verifiable/credential.js +1 -1
- package/dist/node/esm/credentials/status/on-chain-revocation.js +1 -1
- package/dist/node/esm/identity/common.js +14 -2
- package/dist/node/esm/proof/provers/witness_calculator.js +4 -4
- package/dist/node/esm/storage/blockchain/onchain-revocation.js +1 -1
- package/dist/node/esm/verifiable/constants.js +2 -2
- package/dist/node/esm/verifiable/credential.js +1 -1
- package/dist/types/credentials/status/resolver.d.ts +1 -1
- package/dist/types/iden3comm/types/packer.d.ts +1 -1
- package/dist/types/identity/common.d.ts +2 -2
- package/dist/types/identity/identity-wallet.d.ts +5 -5
- package/dist/types/proof/proof-service.d.ts +0 -1
- package/dist/types/proof/provers/inputs-generator.d.ts +2 -2
- package/dist/types/storage/blockchain/onchain-revocation.d.ts +1 -1
- package/dist/types/storage/entities/identity.d.ts +1 -1
- package/dist/types/verifiable/constants.d.ts +1 -1
- package/package.json +4 -3
|
@@ -120,7 +120,7 @@ class OnChainResolver {
|
|
|
120
120
|
}
|
|
121
121
|
return network;
|
|
122
122
|
}
|
|
123
|
-
// TODO
|
|
123
|
+
// TODO: is dirty hack for mock in tests.
|
|
124
124
|
// need to pass to constructor list of state stores not list of network configs
|
|
125
125
|
_getStateStorageForIssuer(issuerId) {
|
|
126
126
|
const issuerChainId = (0, js_iden3_core_1.getChainId)(js_iden3_core_1.DID.blockchainFromId(issuerId), js_iden3_core_1.DID.networkIdFromId(issuerId));
|
|
@@ -41,12 +41,24 @@ exports.defineMerklizedRootPosition = defineMerklizedRootPosition;
|
|
|
41
41
|
* Returns profile DID based on did and profile nonce
|
|
42
42
|
*
|
|
43
43
|
* @param {DID} [did] - did from which profile will be derived
|
|
44
|
-
* @param {number} [profileNonce] - profile nonce
|
|
44
|
+
* @param {number | string} [profileNonce] - profile nonce
|
|
45
45
|
* @returns {DID}
|
|
46
46
|
*/
|
|
47
47
|
const generateProfileDID = (did, profileNonce) => {
|
|
48
48
|
const id = js_iden3_core_1.DID.idFromDID(did);
|
|
49
|
-
|
|
49
|
+
profileNonce = profileNonce ?? 0;
|
|
50
|
+
if (!isBigInt(profileNonce)) {
|
|
51
|
+
throw new Error('profile must be number or decimal string');
|
|
52
|
+
}
|
|
53
|
+
const profile = js_iden3_core_1.Id.profileId(id, BigInt(profileNonce));
|
|
50
54
|
return js_iden3_core_1.DID.parseFromId(profile);
|
|
51
55
|
};
|
|
52
56
|
exports.generateProfileDID = generateProfileDID;
|
|
57
|
+
const isBigInt = (x) => {
|
|
58
|
+
try {
|
|
59
|
+
return BigInt(x).toString() === x.toString();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false; // conversion to BigInt failed, surely it is not a BigInt
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -274,8 +274,8 @@ function fnvHash(str) {
|
|
|
274
274
|
hash *= BigInt(0x100000001b3);
|
|
275
275
|
hash %= uint64_max;
|
|
276
276
|
}
|
|
277
|
-
let
|
|
278
|
-
const n = 16 -
|
|
279
|
-
|
|
280
|
-
return
|
|
277
|
+
let hashHex = hash.toString(16);
|
|
278
|
+
const n = 16 - hashHex.length;
|
|
279
|
+
hashHex = '0'.repeat(n).concat(hashHex);
|
|
280
|
+
return hashHex;
|
|
281
281
|
}
|
|
@@ -20,7 +20,7 @@ class OnChainRevocationStorage {
|
|
|
20
20
|
*
|
|
21
21
|
* Creates an instance of OnChainIssuer.
|
|
22
22
|
* @public
|
|
23
|
-
* @param {string} -
|
|
23
|
+
* @param {string} - onchain contract address
|
|
24
24
|
* @param {string} - rpc url to connect to the blockchain
|
|
25
25
|
*/
|
|
26
26
|
constructor(_config, contractAddress, _signer) {
|
|
@@ -34,7 +34,7 @@ exports.VerifiableConstants = Object.freeze({
|
|
|
34
34
|
PUSH_NOTIFICATION: 'push-notification'
|
|
35
35
|
},
|
|
36
36
|
AUTH: {
|
|
37
|
-
|
|
37
|
+
AUTH_BJJ_CREDENTIAL_HASH: '013fd3f623559d850fb5b02ff012d0e2',
|
|
38
38
|
AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: 'https://schema.iden3.io/core/json/auth.json',
|
|
39
39
|
AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: 'https://schema.iden3.io/core/jsonld/auth.jsonld',
|
|
40
40
|
AUTH_BJJ_CREDENTIAL_TYPE: 'AuthBJJCredential',
|
|
@@ -66,7 +66,7 @@ var CredentialStatusType;
|
|
|
66
66
|
CredentialStatusType["Iden3ReverseSparseMerkleTreeProof"] = "Iden3ReverseSparseMerkleTreeProof";
|
|
67
67
|
// Iden3commRevocationStatusV1 is CredentialStatusType for iden3comm revocation status
|
|
68
68
|
CredentialStatusType["Iden3commRevocationStatusV1"] = "Iden3commRevocationStatusV1.0";
|
|
69
|
-
//
|
|
69
|
+
// Iden3OnchainSparseMerkleTreeProof2023 is a proof type for MTP proofs with iden3 metadata from blockchain
|
|
70
70
|
CredentialStatusType["Iden3OnchainSparseMerkleTreeProof2023"] = "Iden3OnchainSparseMerkleTreeProof2023";
|
|
71
71
|
})(CredentialStatusType = exports.CredentialStatusType || (exports.CredentialStatusType = {}));
|
|
72
72
|
/**
|
|
@@ -323,7 +323,7 @@ class W3CCredential {
|
|
|
323
323
|
}
|
|
324
324
|
async verifyIden3SparseMerkleTreeProof(proof, coreClaim, resolverURL) {
|
|
325
325
|
await (0, utils_2.validateDIDDocumentAuth)(proof.issuerData.id, resolverURL, proof.issuerData.state.value);
|
|
326
|
-
// root from proof == issuerData.state
|
|
326
|
+
// root from proof == issuerData.state.claimsTreeRoot
|
|
327
327
|
const { hi, hv } = coreClaim.hiHv();
|
|
328
328
|
const rootFromProofValue = await (0, js_merkletree_1.rootFromProof)(proof.mtp, hi, hv);
|
|
329
329
|
if (!rootFromProofValue.equals(proof.issuerData.state.claimsTreeRoot)) {
|
|
@@ -117,7 +117,7 @@ export class OnChainResolver {
|
|
|
117
117
|
}
|
|
118
118
|
return network;
|
|
119
119
|
}
|
|
120
|
-
// TODO
|
|
120
|
+
// TODO: is dirty hack for mock in tests.
|
|
121
121
|
// need to pass to constructor list of state stores not list of network configs
|
|
122
122
|
_getStateStorageForIssuer(issuerId) {
|
|
123
123
|
const issuerChainId = getChainId(DID.blockchainFromId(issuerId), DID.networkIdFromId(issuerId));
|
|
@@ -36,11 +36,23 @@ export const defineMerklizedRootPosition = (metadata, position) => {
|
|
|
36
36
|
* Returns profile DID based on did and profile nonce
|
|
37
37
|
*
|
|
38
38
|
* @param {DID} [did] - did from which profile will be derived
|
|
39
|
-
* @param {number} [profileNonce] - profile nonce
|
|
39
|
+
* @param {number | string} [profileNonce] - profile nonce
|
|
40
40
|
* @returns {DID}
|
|
41
41
|
*/
|
|
42
42
|
export const generateProfileDID = (did, profileNonce) => {
|
|
43
43
|
const id = DID.idFromDID(did);
|
|
44
|
-
|
|
44
|
+
profileNonce = profileNonce ?? 0;
|
|
45
|
+
if (!isBigInt(profileNonce)) {
|
|
46
|
+
throw new Error('profile must be number or decimal string');
|
|
47
|
+
}
|
|
48
|
+
const profile = Id.profileId(id, BigInt(profileNonce));
|
|
45
49
|
return DID.parseFromId(profile);
|
|
46
50
|
};
|
|
51
|
+
const isBigInt = (x) => {
|
|
52
|
+
try {
|
|
53
|
+
return BigInt(x).toString() === x.toString();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false; // conversion to BigInt failed, surely it is not a BigInt
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -270,8 +270,8 @@ function fnvHash(str) {
|
|
|
270
270
|
hash *= BigInt(0x100000001b3);
|
|
271
271
|
hash %= uint64_max;
|
|
272
272
|
}
|
|
273
|
-
let
|
|
274
|
-
const n = 16 -
|
|
275
|
-
|
|
276
|
-
return
|
|
273
|
+
let hashHex = hash.toString(16);
|
|
274
|
+
const n = 16 - hashHex.length;
|
|
275
|
+
hashHex = '0'.repeat(n).concat(hashHex);
|
|
276
|
+
return hashHex;
|
|
277
277
|
}
|
|
@@ -14,7 +14,7 @@ export class OnChainRevocationStorage {
|
|
|
14
14
|
*
|
|
15
15
|
* Creates an instance of OnChainIssuer.
|
|
16
16
|
* @public
|
|
17
|
-
* @param {string} -
|
|
17
|
+
* @param {string} - onchain contract address
|
|
18
18
|
* @param {string} - rpc url to connect to the blockchain
|
|
19
19
|
*/
|
|
20
20
|
constructor(_config, contractAddress, _signer) {
|
|
@@ -31,7 +31,7 @@ export const VerifiableConstants = Object.freeze({
|
|
|
31
31
|
PUSH_NOTIFICATION: 'push-notification'
|
|
32
32
|
},
|
|
33
33
|
AUTH: {
|
|
34
|
-
|
|
34
|
+
AUTH_BJJ_CREDENTIAL_HASH: '013fd3f623559d850fb5b02ff012d0e2',
|
|
35
35
|
AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: 'https://schema.iden3.io/core/json/auth.json',
|
|
36
36
|
AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: 'https://schema.iden3.io/core/jsonld/auth.jsonld',
|
|
37
37
|
AUTH_BJJ_CREDENTIAL_TYPE: 'AuthBJJCredential',
|
|
@@ -63,7 +63,7 @@ export var CredentialStatusType;
|
|
|
63
63
|
CredentialStatusType["Iden3ReverseSparseMerkleTreeProof"] = "Iden3ReverseSparseMerkleTreeProof";
|
|
64
64
|
// Iden3commRevocationStatusV1 is CredentialStatusType for iden3comm revocation status
|
|
65
65
|
CredentialStatusType["Iden3commRevocationStatusV1"] = "Iden3commRevocationStatusV1.0";
|
|
66
|
-
//
|
|
66
|
+
// Iden3OnchainSparseMerkleTreeProof2023 is a proof type for MTP proofs with iden3 metadata from blockchain
|
|
67
67
|
CredentialStatusType["Iden3OnchainSparseMerkleTreeProof2023"] = "Iden3OnchainSparseMerkleTreeProof2023";
|
|
68
68
|
})(CredentialStatusType || (CredentialStatusType = {}));
|
|
69
69
|
/**
|
|
@@ -297,7 +297,7 @@ export class W3CCredential {
|
|
|
297
297
|
}
|
|
298
298
|
async verifyIden3SparseMerkleTreeProof(proof, coreClaim, resolverURL) {
|
|
299
299
|
await validateDIDDocumentAuth(proof.issuerData.id, resolverURL, proof.issuerData.state.value);
|
|
300
|
-
// root from proof == issuerData.state
|
|
300
|
+
// root from proof == issuerData.state.claimsTreeRoot
|
|
301
301
|
const { hi, hv } = coreClaim.hiHv();
|
|
302
302
|
const rootFromProofValue = await rootFromProof(proof.mtp, hi, hv);
|
|
303
303
|
if (!rootFromProofValue.equals(proof.issuerData.state.claimsTreeRoot)) {
|
|
@@ -23,7 +23,7 @@ export interface CredentialStatusResolveOptions {
|
|
|
23
23
|
userDID?: DID;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* CredentialStatusResolver is an interface that allows to interact with
|
|
26
|
+
* CredentialStatusResolver is an interface that allows to interact with different types of credential status
|
|
27
27
|
* to resolve revocation status
|
|
28
28
|
*
|
|
29
29
|
* @public
|
|
@@ -20,7 +20,7 @@ export declare const defineMerklizedRootPosition: (metadata?: SchemaMetadata, po
|
|
|
20
20
|
* Returns profile DID based on did and profile nonce
|
|
21
21
|
*
|
|
22
22
|
* @param {DID} [did] - did from which profile will be derived
|
|
23
|
-
* @param {number} [profileNonce] - profile nonce
|
|
23
|
+
* @param {number | string} [profileNonce] - profile nonce
|
|
24
24
|
* @returns {DID}
|
|
25
25
|
*/
|
|
26
|
-
export declare const generateProfileDID: (did: DID, profileNonce?: number) => DID;
|
|
26
|
+
export declare const generateProfileDID: (did: DID, profileNonce?: number | string) => DID;
|
|
@@ -115,11 +115,11 @@ export interface IIdentityWallet {
|
|
|
115
115
|
* Creates profile based on genesis identifier
|
|
116
116
|
*
|
|
117
117
|
* @param {DID} did - identity to derive profile from
|
|
118
|
-
* @param {number} nonce - unique integer number to generate a profile
|
|
118
|
+
* @param {number |string} nonce - unique integer number to generate a profile
|
|
119
119
|
* @param {string} verifier - verifier identity/alias in a string from
|
|
120
120
|
* @returns `Promise<DID>` - profile did
|
|
121
121
|
*/
|
|
122
|
-
createProfile(did: DID, nonce: number, verifier: string): Promise<DID>;
|
|
122
|
+
createProfile(did: DID, nonce: number | string, verifier: string): Promise<DID>;
|
|
123
123
|
/**
|
|
124
124
|
* Generates a new key
|
|
125
125
|
*
|
|
@@ -277,7 +277,7 @@ export interface IIdentityWallet {
|
|
|
277
277
|
* @returns `{Promise<{nonce:number, genesisIdentifier: DID}>}`
|
|
278
278
|
*/
|
|
279
279
|
getGenesisDIDMetadata(did: DID): Promise<{
|
|
280
|
-
nonce: number;
|
|
280
|
+
nonce: number | string;
|
|
281
281
|
genesisDID: DID;
|
|
282
282
|
}>;
|
|
283
283
|
/**
|
|
@@ -394,11 +394,11 @@ export declare class IdentityWallet implements IIdentityWallet {
|
|
|
394
394
|
}>;
|
|
395
395
|
/** {@inheritDoc IIdentityWallet.getGenesisDIDMetadata} */
|
|
396
396
|
getGenesisDIDMetadata(did: DID): Promise<{
|
|
397
|
-
nonce: number;
|
|
397
|
+
nonce: number | string;
|
|
398
398
|
genesisDID: DID;
|
|
399
399
|
}>;
|
|
400
400
|
/** {@inheritDoc IIdentityWallet.createProfile} */
|
|
401
|
-
createProfile(did: DID, nonce: number, verifier: string): Promise<DID>;
|
|
401
|
+
createProfile(did: DID, nonce: number | string, verifier: string): Promise<DID>;
|
|
402
402
|
/**
|
|
403
403
|
*
|
|
404
404
|
* gets profile identity by genesis identifiers
|
|
@@ -69,7 +69,6 @@ export interface IProofService {
|
|
|
69
69
|
*
|
|
70
70
|
* @param {Uint8Array} hash - challenge that will be signed
|
|
71
71
|
* @param {DID} did - identity that will generate a proof
|
|
72
|
-
* @param {Number} profileNonce - identity that will generate a proof
|
|
73
72
|
* @param {CircuitId} circuitId - circuit id for authentication
|
|
74
73
|
* @returns `Promise<Uint8Array>`
|
|
75
74
|
*/
|
|
@@ -7,8 +7,8 @@ import { IIdentityWallet } from '../../identity';
|
|
|
7
7
|
import { IStateStorage } from '../../storage';
|
|
8
8
|
import { ICredentialWallet } from '../../credentials';
|
|
9
9
|
export type DIDProfileMetadata = {
|
|
10
|
-
authProfileNonce: number;
|
|
11
|
-
credentialSubjectProfileNonce: number;
|
|
10
|
+
authProfileNonce: number | string;
|
|
11
|
+
credentialSubjectProfileNonce: number | string;
|
|
12
12
|
};
|
|
13
13
|
export type ProofGenerationOptions = {
|
|
14
14
|
skipRevocation: boolean;
|
|
@@ -18,7 +18,7 @@ export declare class OnChainRevocationStorage {
|
|
|
18
18
|
*
|
|
19
19
|
* Creates an instance of OnChainIssuer.
|
|
20
20
|
* @public
|
|
21
|
-
* @param {string} -
|
|
21
|
+
* @param {string} - onchain contract address
|
|
22
22
|
* @param {string} - rpc url to connect to the blockchain
|
|
23
23
|
*/
|
|
24
24
|
constructor(_config: EthConnectionConfig, contractAddress: string, _signer?: Signer | undefined);
|
|
@@ -23,7 +23,7 @@ export declare const VerifiableConstants: Readonly<{
|
|
|
23
23
|
PUSH_NOTIFICATION: string;
|
|
24
24
|
};
|
|
25
25
|
AUTH: {
|
|
26
|
-
|
|
26
|
+
AUTH_BJJ_CREDENTIAL_HASH: string;
|
|
27
27
|
AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: string;
|
|
28
28
|
AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: string;
|
|
29
29
|
AUTH_BJJ_CREDENTIAL_TYPE: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xpolygonid/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
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",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/0xPolygonID/js-sdk#readme",
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@cspell/eslint-plugin": "^8.14.2",
|
|
53
54
|
"@gr2m/fetch-mock": "9.11.0-pull-request-644.1",
|
|
54
55
|
"@iden3/eslint-config": "https://github.com/iden3/eslint-config",
|
|
55
56
|
"@microsoft/api-documenter": "^7.8.20",
|
|
@@ -88,9 +89,9 @@
|
|
|
88
89
|
},
|
|
89
90
|
"peerDependencies": {
|
|
90
91
|
"@iden3/js-crypto": "1.1.0",
|
|
91
|
-
"@iden3/js-iden3-core": "1.4.
|
|
92
|
+
"@iden3/js-iden3-core": "1.4.1",
|
|
92
93
|
"@iden3/js-jsonld-merklization": "1.4.1",
|
|
93
|
-
"@iden3/js-jwz": "1.
|
|
94
|
+
"@iden3/js-jwz": "1.8.0",
|
|
94
95
|
"@iden3/js-merkletree": "1.3.1",
|
|
95
96
|
"ffjavascript": "0.3.0",
|
|
96
97
|
"rfc4648": "1.5.3",
|