@0xpolygonid/js-sdk 1.18.3 → 1.19.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 +2 -2
- package/dist/browser/esm/index.js +37 -24
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +37 -24
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/identity/common.js +14 -2
- package/dist/node/cjs/identity/identity-wallet.js +23 -22
- package/dist/node/esm/identity/common.js +14 -2
- package/dist/node/esm/identity/identity-wallet.js +23 -22
- 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 +12 -6
- 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/entities/identity.d.ts +1 -1
- package/package.json +1 -1
|
@@ -20577,14 +20577,26 @@ var PolygonIdSdk = (function (exports) {
|
|
|
20577
20577
|
* Returns profile DID based on did and profile nonce
|
|
20578
20578
|
*
|
|
20579
20579
|
* @param {DID} [did] - did from which profile will be derived
|
|
20580
|
-
* @param {number} [profileNonce] - profile nonce
|
|
20580
|
+
* @param {number | string} [profileNonce] - profile nonce
|
|
20581
20581
|
* @returns {DID}
|
|
20582
20582
|
*/
|
|
20583
20583
|
const generateProfileDID = (did, profileNonce) => {
|
|
20584
20584
|
const id = Z$2.idFromDID(did);
|
|
20585
|
-
|
|
20585
|
+
profileNonce = profileNonce ?? 0;
|
|
20586
|
+
if (!isBigInt(profileNonce)) {
|
|
20587
|
+
throw new Error('profile must be number or decimal string');
|
|
20588
|
+
}
|
|
20589
|
+
const profile = H$2.profileId(id, BigInt(profileNonce));
|
|
20586
20590
|
return Z$2.parseFromId(profile);
|
|
20587
20591
|
};
|
|
20592
|
+
const isBigInt = (x) => {
|
|
20593
|
+
try {
|
|
20594
|
+
return BigInt(x).toString() === x.toString();
|
|
20595
|
+
}
|
|
20596
|
+
catch {
|
|
20597
|
+
return false; // conversion to BigInt failed, surely it is not a BigInt
|
|
20598
|
+
}
|
|
20599
|
+
};
|
|
20588
20600
|
|
|
20589
20601
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
20590
20602
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
@@ -80698,12 +80710,20 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80698
80710
|
},
|
|
80699
80711
|
allowedIssuers: [did.string()]
|
|
80700
80712
|
});
|
|
80701
|
-
if
|
|
80713
|
+
// if credential exists with the same credential status type we return this credential
|
|
80714
|
+
if (credentials.length === 1 &&
|
|
80715
|
+
credentials[0].credentialStatus.type === opts.revocationOpts.type) {
|
|
80702
80716
|
return {
|
|
80703
80717
|
did,
|
|
80704
80718
|
credential: credentials[0]
|
|
80705
80719
|
};
|
|
80706
80720
|
}
|
|
80721
|
+
// otherwise something is already wrong with storage as it has more than 1 credential in it or credential status type of existing credential is different from what user provides - We should remove everything and create new credential.
|
|
80722
|
+
// in this way credential status of auth credential can be upgraded
|
|
80723
|
+
for (let i = 0; i < credentials.length; i++) {
|
|
80724
|
+
await this._credentialWallet.remove(credentials[i].id);
|
|
80725
|
+
}
|
|
80726
|
+
// otherwise we create a new credential
|
|
80707
80727
|
const credential = await this.createAuthBJJCredential(did, pubKey, authClaim, currentState, opts.revocationOpts);
|
|
80708
80728
|
const index = authClaim.hIndex();
|
|
80709
80729
|
const { proof } = await claimsTree.generateProof(index, ctr);
|
|
@@ -80721,10 +80741,13 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80721
80741
|
coreClaim: authClaim
|
|
80722
80742
|
});
|
|
80723
80743
|
credential.proof = [mtpProof];
|
|
80724
|
-
|
|
80725
|
-
|
|
80726
|
-
|
|
80727
|
-
|
|
80744
|
+
// only if user specified that genesis state publishing is not needed we won't do this.
|
|
80745
|
+
if (!opts.revocationOpts.genesisPublishingDisabled) {
|
|
80746
|
+
await this.publishRevocationInfoByCredentialStatusType(did, opts.revocationOpts.type, {
|
|
80747
|
+
rhsUrl: opts.revocationOpts.id,
|
|
80748
|
+
onChain: opts.revocationOpts.onChain
|
|
80749
|
+
});
|
|
80750
|
+
}
|
|
80728
80751
|
await this._credentialWallet.save(credential);
|
|
80729
80752
|
return {
|
|
80730
80753
|
did,
|
|
@@ -81087,23 +81110,13 @@ var PolygonIdSdk = (function (exports) {
|
|
|
81087
81110
|
throw new Error(`there is no registered publisher to save hash is not registered for ${credentialStatusType} is not registered`);
|
|
81088
81111
|
}
|
|
81089
81112
|
let nodes = [];
|
|
81090
|
-
|
|
81091
|
-
|
|
81092
|
-
|
|
81093
|
-
|
|
81094
|
-
|
|
81095
|
-
|
|
81096
|
-
|
|
81097
|
-
}
|
|
81098
|
-
else {
|
|
81099
|
-
const treeState = await this.getDIDTreeModel(issuerDID);
|
|
81100
|
-
nodes = await getNodesRepresentation(opts?.revokedNonces, {
|
|
81101
|
-
revocationTree: treeState.revocationTree,
|
|
81102
|
-
claimsTree: treeState.claimsTree,
|
|
81103
|
-
state: treeState.state,
|
|
81104
|
-
rootsTree: treeState.rootsTree
|
|
81105
|
-
}, treeState.state);
|
|
81106
|
-
}
|
|
81113
|
+
const tree = opts?.treeModel ?? (await this.getDIDTreeModel(issuerDID));
|
|
81114
|
+
nodes = await getNodesRepresentation(opts?.revokedNonces ?? [], {
|
|
81115
|
+
revocationTree: tree.revocationTree,
|
|
81116
|
+
claimsTree: tree.claimsTree,
|
|
81117
|
+
state: tree.state,
|
|
81118
|
+
rootsTree: tree.rootsTree
|
|
81119
|
+
}, tree.state);
|
|
81107
81120
|
if (!nodes.length) {
|
|
81108
81121
|
return;
|
|
81109
81122
|
}
|