@0xpolygonid/js-sdk 1.8.1 → 1.8.2
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 +44 -11
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +44 -11
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/credential-wallet.js +10 -0
- package/dist/node/cjs/identity/identity-wallet.js +31 -6
- package/dist/node/cjs/proof/provers/inputs-generator.js +3 -5
- package/dist/node/esm/credentials/credential-wallet.js +10 -0
- package/dist/node/esm/identity/identity-wallet.js +32 -7
- package/dist/node/esm/proof/provers/inputs-generator.js +3 -5
- package/dist/types/credentials/credential-wallet.d.ts +12 -1
- package/dist/types/iden3comm/types/protocol/auth.d.ts +5 -1
- package/dist/types/identity/identity-wallet.d.ts +24 -0
- package/package.json +1 -1
|
@@ -61582,6 +61582,16 @@ var PolygonIdSdk = (function (exports) {
|
|
|
61582
61582
|
}
|
|
61583
61583
|
throw new Error('all auth bjj credentials are revoked');
|
|
61584
61584
|
}
|
|
61585
|
+
/**
|
|
61586
|
+
* {@inheritDoc ICredentialWallet.getAllAuthBJJCredentials}
|
|
61587
|
+
*/
|
|
61588
|
+
async getAllAuthBJJCredentials(did) {
|
|
61589
|
+
return this._storage.credential.findCredentialsByQuery({
|
|
61590
|
+
context: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL,
|
|
61591
|
+
type: VerifiableConstants.AUTH.AUTH_BJJ_CREDENTIAL_TYPE,
|
|
61592
|
+
allowedIssuers: [did.string()]
|
|
61593
|
+
});
|
|
61594
|
+
}
|
|
61585
61595
|
/**
|
|
61586
61596
|
* {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
|
|
61587
61597
|
*/
|
|
@@ -61863,13 +61873,19 @@ var PolygonIdSdk = (function (exports) {
|
|
|
61863
61873
|
this._storage = _storage;
|
|
61864
61874
|
this._credentialWallet = _credentialWallet;
|
|
61865
61875
|
this._opts = _opts;
|
|
61876
|
+
this._credentialStatusPublisherRegistry = this.getCredentialStatusPublisherRegistry(_opts);
|
|
61877
|
+
}
|
|
61878
|
+
getCredentialStatusPublisherRegistry(_opts) {
|
|
61866
61879
|
if (!_opts?.credentialStatusPublisherRegistry) {
|
|
61867
|
-
|
|
61868
|
-
|
|
61880
|
+
const registry = new CredentialStatusPublisherRegistry();
|
|
61881
|
+
const emptyPublisher = { publish: () => Promise.resolve() };
|
|
61882
|
+
registry.register(exports.CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, new Iden3SmtRhsCredentialStatusPublisher());
|
|
61883
|
+
registry.register(exports.CredentialStatusType.SparseMerkleTreeProof, emptyPublisher);
|
|
61884
|
+
registry.register(exports.CredentialStatusType.Iden3commRevocationStatusV1, emptyPublisher);
|
|
61885
|
+
return registry;
|
|
61869
61886
|
}
|
|
61870
61887
|
else {
|
|
61871
|
-
|
|
61872
|
-
?.credentialStatusPublisherRegistry;
|
|
61888
|
+
return this._opts?.credentialStatusPublisherRegistry;
|
|
61873
61889
|
}
|
|
61874
61890
|
}
|
|
61875
61891
|
/**
|
|
@@ -62107,7 +62123,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
62107
62123
|
catch (e) {
|
|
62108
62124
|
throw new Error(`Error create w3c credential ${e.message}`);
|
|
62109
62125
|
}
|
|
62110
|
-
const issuerAuthBJJCredential = await this.
|
|
62126
|
+
const { authCredential: issuerAuthBJJCredential } = await this.getActualAuthCredential(issuerDID);
|
|
62111
62127
|
const coreClaimOpts = {
|
|
62112
62128
|
revNonce: req.revocationOpts.nonce,
|
|
62113
62129
|
subjectPosition: req.subjectPosition,
|
|
@@ -62116,7 +62132,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
62116
62132
|
version: 0,
|
|
62117
62133
|
merklizeOpts: { ...opts, documentLoader: loader }
|
|
62118
62134
|
};
|
|
62119
|
-
const coreClaim = await
|
|
62135
|
+
const coreClaim = await credential.toCoreClaim(coreClaimOpts);
|
|
62120
62136
|
const { hi, hv } = coreClaim.hiHv();
|
|
62121
62137
|
const coreClaimHash = $$2.hash([hi, hv]);
|
|
62122
62138
|
const signature = await this.signChallenge(coreClaimHash, issuerAuthBJJCredential);
|
|
@@ -62141,6 +62157,25 @@ var PolygonIdSdk = (function (exports) {
|
|
|
62141
62157
|
credential.proof = [sigProof];
|
|
62142
62158
|
return credential;
|
|
62143
62159
|
}
|
|
62160
|
+
/** {@inheritDoc IIdentityWallet.getActualAuthCredential} */
|
|
62161
|
+
async getActualAuthCredential(did, treeStateInfo) {
|
|
62162
|
+
const authCredentials = await this._credentialWallet.getAllAuthBJJCredentials(did);
|
|
62163
|
+
for (let i = 0; i < authCredentials.length; i++) {
|
|
62164
|
+
const incProof = await this.generateCredentialMtp(did, authCredentials[i], treeStateInfo);
|
|
62165
|
+
if (!incProof.proof.existence) {
|
|
62166
|
+
continue;
|
|
62167
|
+
}
|
|
62168
|
+
const nonRevProof = await this.generateNonRevocationMtp(did, authCredentials[i], treeStateInfo);
|
|
62169
|
+
if (!nonRevProof.proof.existence) {
|
|
62170
|
+
return {
|
|
62171
|
+
authCredential: authCredentials[i],
|
|
62172
|
+
incProof,
|
|
62173
|
+
nonRevProof
|
|
62174
|
+
};
|
|
62175
|
+
}
|
|
62176
|
+
}
|
|
62177
|
+
throw new Error('no auth credentials found');
|
|
62178
|
+
}
|
|
62144
62179
|
/** {@inheritDoc IIdentityWallet.revokeCredential} */
|
|
62145
62180
|
async revokeCredential(issuerDID, credential) {
|
|
62146
62181
|
const issuerTree = await this.getDIDTreeModel(issuerDID);
|
|
@@ -83816,8 +83851,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
83816
83851
|
circuitInputs.proofType = proofType;
|
|
83817
83852
|
circuitInputs.linkNonce = params.linkNonce ?? BigInt(0);
|
|
83818
83853
|
circuitInputs.verifierID = params.verifierDid ? W$2.idFromDID(params.verifierDid) : undefined;
|
|
83819
|
-
circuitInputs.nullifierSessionID = proofReq.params?.
|
|
83820
|
-
? BigInt(proofReq.params?.
|
|
83854
|
+
circuitInputs.nullifierSessionID = proofReq.params?.nullifierSessionId
|
|
83855
|
+
? BigInt(proofReq.params?.nullifierSessionId?.toString())
|
|
83821
83856
|
: BigInt(0);
|
|
83822
83857
|
let isEthIdentity = true;
|
|
83823
83858
|
try {
|
|
@@ -83926,9 +83961,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
83926
83961
|
return circuitClaim;
|
|
83927
83962
|
}
|
|
83928
83963
|
async prepareAuthBJJCredential(did, treeStateInfo) {
|
|
83929
|
-
const authCredential = await this.
|
|
83930
|
-
const incProof = await this._identityWallet.generateCredentialMtp(did, authCredential, treeStateInfo);
|
|
83931
|
-
const nonRevProof = await this._identityWallet.generateNonRevocationMtp(did, authCredential, treeStateInfo);
|
|
83964
|
+
const { authCredential, incProof, nonRevProof } = await this._identityWallet.getActualAuthCredential(did, treeStateInfo);
|
|
83932
83965
|
const authCoreClaim = authCredential.getCoreClaimFromProof(exports.ProofType.Iden3SparseMerkleTreeProof);
|
|
83933
83966
|
if (!authCoreClaim) {
|
|
83934
83967
|
throw new Error('auth core claim is not defined for auth bjj credential');
|