@0xpolygonid/js-sdk 1.7.0 → 1.7.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 +103 -6
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +104 -7
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/comparer.js +20 -2
- package/dist/node/cjs/circuits/linked-multi-query.js +1 -1
- package/dist/node/cjs/credentials/credential-wallet.js +1 -0
- package/dist/node/cjs/iden3comm/constants.js +2 -0
- package/dist/node/cjs/iden3comm/handlers/auth.js +1 -0
- package/dist/node/cjs/iden3comm/handlers/fetch.js +2 -2
- package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
- package/dist/node/cjs/iden3comm/handlers/refresh.js +76 -0
- package/dist/node/cjs/verifiable/constants.js +10 -1
- package/dist/node/esm/circuits/comparer.js +20 -2
- package/dist/node/esm/circuits/linked-multi-query.js +1 -1
- package/dist/node/esm/credentials/credential-wallet.js +1 -0
- package/dist/node/esm/iden3comm/constants.js +2 -0
- package/dist/node/esm/iden3comm/handlers/auth.js +1 -0
- package/dist/node/esm/iden3comm/handlers/fetch.js +2 -2
- package/dist/node/esm/iden3comm/handlers/index.js +1 -0
- package/dist/node/esm/iden3comm/handlers/refresh.js +72 -0
- package/dist/node/esm/verifiable/constants.js +9 -0
- package/dist/types/credentials/credential-wallet.d.ts +5 -1
- package/dist/types/iden3comm/constants.d.ts +1 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts +2 -2
- package/dist/types/iden3comm/handlers/index.d.ts +1 -0
- package/dist/types/iden3comm/handlers/refresh.d.ts +56 -0
- package/dist/types/iden3comm/types/packer.d.ts +2 -1
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +15 -0
- package/dist/types/verifiable/constants.d.ts +8 -0
- package/dist/types/verifiable/credential.d.ts +2 -1
- package/dist/types/verifiable/proof.d.ts +10 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var PolygonIdSdk = (function (exports) {
|
|
1
|
+
var PolygonIdSdk = (function (exports, crypto$4) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -32203,6 +32203,15 @@ var PolygonIdSdk = (function (exports) {
|
|
|
32203
32203
|
// Value save subject in value part of claim.
|
|
32204
32204
|
SubjectPosition["Value"] = "value";
|
|
32205
32205
|
})(exports.SubjectPosition || (exports.SubjectPosition = {}));
|
|
32206
|
+
/**
|
|
32207
|
+
* RefreshServiceType type for refreshService
|
|
32208
|
+
*
|
|
32209
|
+
* @enum {string}
|
|
32210
|
+
*/
|
|
32211
|
+
exports.RefreshServiceType = void 0;
|
|
32212
|
+
(function (RefreshServiceType) {
|
|
32213
|
+
RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
|
|
32214
|
+
})(exports.RefreshServiceType || (exports.RefreshServiceType = {}));
|
|
32206
32215
|
|
|
32207
32216
|
/**
|
|
32208
32217
|
* Checks if state is genesis state
|
|
@@ -32456,8 +32465,26 @@ var PolygonIdSdk = (function (exports) {
|
|
|
32456
32465
|
[exports.XSDNS.Integer, allOperations],
|
|
32457
32466
|
[exports.XSDNS.NonNegativeInteger, allOperations],
|
|
32458
32467
|
[exports.XSDNS.PositiveInteger, allOperations],
|
|
32459
|
-
[
|
|
32460
|
-
|
|
32468
|
+
[
|
|
32469
|
+
exports.XSDNS.Double,
|
|
32470
|
+
[
|
|
32471
|
+
QueryOperators.$eq,
|
|
32472
|
+
QueryOperators.$ne,
|
|
32473
|
+
QueryOperators.$in,
|
|
32474
|
+
QueryOperators.$nin,
|
|
32475
|
+
QueryOperators.$sd
|
|
32476
|
+
]
|
|
32477
|
+
],
|
|
32478
|
+
[
|
|
32479
|
+
exports.XSDNS.String,
|
|
32480
|
+
[
|
|
32481
|
+
QueryOperators.$eq,
|
|
32482
|
+
QueryOperators.$ne,
|
|
32483
|
+
QueryOperators.$in,
|
|
32484
|
+
QueryOperators.$nin,
|
|
32485
|
+
QueryOperators.$sd
|
|
32486
|
+
]
|
|
32487
|
+
],
|
|
32461
32488
|
[exports.XSDNS.DateTime, allOperations]
|
|
32462
32489
|
]);
|
|
32463
32490
|
/**
|
|
@@ -35130,7 +35157,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
35130
35157
|
if (!this.query[i]) {
|
|
35131
35158
|
enabled.push(0);
|
|
35132
35159
|
claimPathNotExists.push(0);
|
|
35133
|
-
claimPathMtp.push(
|
|
35160
|
+
claimPathMtp.push(new Array(this.getMTLevelsClaim()).fill('0'));
|
|
35134
35161
|
claimPathMtpNoAux.push('0');
|
|
35135
35162
|
claimPathMtpAuxHi.push('0');
|
|
35136
35163
|
claimPathMtpAuxHv.push('0');
|
|
@@ -36876,6 +36903,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
36876
36903
|
CREDENTIAL_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/offer',
|
|
36877
36904
|
// CredentialIssuanceResponseMessageType is type for message with a credential issuance
|
|
36878
36905
|
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/issuance-response',
|
|
36906
|
+
// CredentialRefreshMessageType is type for message with a credential issuance
|
|
36907
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/refresh',
|
|
36879
36908
|
// DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
|
|
36880
36909
|
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL + 'devices/1.0/registration',
|
|
36881
36910
|
// MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
|
|
@@ -37371,6 +37400,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
37371
37400
|
cr['@context'] = context;
|
|
37372
37401
|
cr.type = credentialType;
|
|
37373
37402
|
cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
|
|
37403
|
+
cr.refreshService = request.refreshService;
|
|
37374
37404
|
cr.issuanceDate = new Date().toISOString();
|
|
37375
37405
|
cr.credentialSubject = credentialSubject;
|
|
37376
37406
|
cr.issuer = issuer.string();
|
|
@@ -84249,6 +84279,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84249
84279
|
}
|
|
84250
84280
|
const credWithRevStatus = groupedCredentialsCache.get(groupId);
|
|
84251
84281
|
const zkpRes = await this._proofService.generateProof(proofReq, did, {
|
|
84282
|
+
verifierDid: W$2.parse(authRequest.from),
|
|
84252
84283
|
skipRevocation: Boolean(query.skipClaimRevocationCheck),
|
|
84253
84284
|
credential: credWithRevStatus?.cred,
|
|
84254
84285
|
credentialRevocationStatus: credWithRevStatus?.revStatus,
|
|
@@ -84281,7 +84312,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84281
84312
|
*/
|
|
84282
84313
|
class FetchHandler {
|
|
84283
84314
|
/**
|
|
84284
|
-
* Creates an instance of
|
|
84315
|
+
* Creates an instance of FetchHandler.
|
|
84285
84316
|
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
84286
84317
|
*/
|
|
84287
84318
|
constructor(_packerMgr) {
|
|
@@ -84294,7 +84325,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84294
84325
|
* offer: Uint8Array; offer - raw offer message
|
|
84295
84326
|
* opts
|
|
84296
84327
|
* }) options how to fetch credential
|
|
84297
|
-
* @returns `Promise<W3CCredential>`
|
|
84328
|
+
* @returns `Promise<W3CCredential[]>`
|
|
84298
84329
|
*/
|
|
84299
84330
|
async handleCredentialOffer(offer, opts) {
|
|
84300
84331
|
if (!opts) {
|
|
@@ -84450,6 +84481,71 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84450
84481
|
}
|
|
84451
84482
|
}
|
|
84452
84483
|
|
|
84484
|
+
/**
|
|
84485
|
+
*
|
|
84486
|
+
* Allows to refresh credential from refresh service and return refreshed credential
|
|
84487
|
+
*
|
|
84488
|
+
* @public
|
|
84489
|
+
|
|
84490
|
+
* @class RefreshHandler
|
|
84491
|
+
* @implements implements RefreshHandler interface
|
|
84492
|
+
*/
|
|
84493
|
+
class RefreshHandler {
|
|
84494
|
+
/**
|
|
84495
|
+
* Creates an instance of RefreshHandler.
|
|
84496
|
+
* @param {RefreshHandlerOptions} _options - refresh handler options
|
|
84497
|
+
*/
|
|
84498
|
+
constructor(_options) {
|
|
84499
|
+
this._options = _options;
|
|
84500
|
+
}
|
|
84501
|
+
async refreshCredential(credential, opts) {
|
|
84502
|
+
if (!credential.refreshService) {
|
|
84503
|
+
throw new Error('refreshService not specified for W3CCredential');
|
|
84504
|
+
}
|
|
84505
|
+
if (credential.refreshService.type !== exports.RefreshServiceType.Iden3RefreshService2023) {
|
|
84506
|
+
throw new Error(`refresh service type ${credential.refreshService.type} is not supported`);
|
|
84507
|
+
}
|
|
84508
|
+
const otherIdentifier = credential.credentialSubject.id;
|
|
84509
|
+
if (!otherIdentifier) {
|
|
84510
|
+
throw new Error('self credentials do not support refresh');
|
|
84511
|
+
}
|
|
84512
|
+
const senderDID = W$2.parse(otherIdentifier);
|
|
84513
|
+
const zkpParams = {
|
|
84514
|
+
senderDID,
|
|
84515
|
+
provingMethodAlg: new l(T.provingMethodGroth16AuthV2Instance.methodAlg.alg, exports.CircuitId.AuthV2)
|
|
84516
|
+
};
|
|
84517
|
+
const refreshMsg = {
|
|
84518
|
+
id: crypto$4.randomUUID(),
|
|
84519
|
+
typ: MediaType.ZKPMessage,
|
|
84520
|
+
type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE,
|
|
84521
|
+
thid: crypto$4.randomUUID(),
|
|
84522
|
+
body: {
|
|
84523
|
+
id: otherIdentifier,
|
|
84524
|
+
reason: opts?.reason ?? 'credential is expired'
|
|
84525
|
+
},
|
|
84526
|
+
from: otherIdentifier,
|
|
84527
|
+
to: credential.issuer
|
|
84528
|
+
};
|
|
84529
|
+
const msgBytes = byteEncoder.encode(JSON.stringify(refreshMsg));
|
|
84530
|
+
const jwzToken = await this._options.packageManager.pack(MediaType.ZKPMessage, msgBytes, zkpParams);
|
|
84531
|
+
const resp = await fetch(credential.refreshService.id, {
|
|
84532
|
+
method: 'post',
|
|
84533
|
+
headers: {
|
|
84534
|
+
'Content-Type': 'application/json'
|
|
84535
|
+
},
|
|
84536
|
+
body: jwzToken
|
|
84537
|
+
});
|
|
84538
|
+
if (resp.status !== 200) {
|
|
84539
|
+
throw new Error(`could not refresh W3C credential, return status ${resp.status}`);
|
|
84540
|
+
}
|
|
84541
|
+
const respBody = await resp.json();
|
|
84542
|
+
if (!respBody.body?.credential) {
|
|
84543
|
+
throw new Error('no credential in CredentialIssuanceMessage response');
|
|
84544
|
+
}
|
|
84545
|
+
return W3CCredential.fromJSON(respBody.body.credential);
|
|
84546
|
+
}
|
|
84547
|
+
}
|
|
84548
|
+
|
|
84453
84549
|
exports.AbstractPrivateKeyStore = AbstractPrivateKeyStore;
|
|
84454
84550
|
exports.AgentResolver = AgentResolver;
|
|
84455
84551
|
exports.AtomicQueryMTPV2Inputs = AtomicQueryMTPV2Inputs;
|
|
@@ -84530,6 +84626,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84530
84626
|
exports.Query = Query;
|
|
84531
84627
|
exports.QueryOperators = QueryOperators;
|
|
84532
84628
|
exports.RHSResolver = RHSResolver;
|
|
84629
|
+
exports.RefreshHandler = RefreshHandler;
|
|
84533
84630
|
exports.Scalar = Scalar$1;
|
|
84534
84631
|
exports.Sec256k1Provider = Sec256k1Provider;
|
|
84535
84632
|
exports.StandardJSONCredentialsQueryFilter = StandardJSONCredentialsQueryFilter;
|
|
@@ -84614,5 +84711,5 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84614
84711
|
|
|
84615
84712
|
return exports;
|
|
84616
84713
|
|
|
84617
|
-
})({});
|
|
84714
|
+
})({}, crypto$4);
|
|
84618
84715
|
//# sourceMappingURL=index.js.map
|