@0xpolygonid/js-sdk 1.7.0 → 1.7.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 +102 -6
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +103 -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/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/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
|
@@ -9,6 +9,7 @@ import { Hash as Hash$1, Proof, ZERO_HASH, swapEndianness as swapEndianness$1, n
|
|
|
9
9
|
import { groth16 } from 'snarkjs';
|
|
10
10
|
import { getCurveFromName } from 'ffjavascript';
|
|
11
11
|
import { Token, Header, ProvingMethodAlg, proving } from '@iden3/js-jwz';
|
|
12
|
+
import { randomUUID as randomUUID$1 } from 'crypto';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Key management system class contains different key providers.
|
|
@@ -32150,6 +32151,15 @@ var SubjectPosition;
|
|
|
32150
32151
|
// Value save subject in value part of claim.
|
|
32151
32152
|
SubjectPosition["Value"] = "value";
|
|
32152
32153
|
})(SubjectPosition || (SubjectPosition = {}));
|
|
32154
|
+
/**
|
|
32155
|
+
* RefreshServiceType type for refreshService
|
|
32156
|
+
*
|
|
32157
|
+
* @enum {string}
|
|
32158
|
+
*/
|
|
32159
|
+
var RefreshServiceType;
|
|
32160
|
+
(function (RefreshServiceType) {
|
|
32161
|
+
RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
|
|
32162
|
+
})(RefreshServiceType || (RefreshServiceType = {}));
|
|
32153
32163
|
|
|
32154
32164
|
/**
|
|
32155
32165
|
* Checks if state is genesis state
|
|
@@ -32403,8 +32413,26 @@ const availableTypesOperators = new Map([
|
|
|
32403
32413
|
[XSDNS.Integer, allOperations],
|
|
32404
32414
|
[XSDNS.NonNegativeInteger, allOperations],
|
|
32405
32415
|
[XSDNS.PositiveInteger, allOperations],
|
|
32406
|
-
[
|
|
32407
|
-
|
|
32416
|
+
[
|
|
32417
|
+
XSDNS.Double,
|
|
32418
|
+
[
|
|
32419
|
+
QueryOperators.$eq,
|
|
32420
|
+
QueryOperators.$ne,
|
|
32421
|
+
QueryOperators.$in,
|
|
32422
|
+
QueryOperators.$nin,
|
|
32423
|
+
QueryOperators.$sd
|
|
32424
|
+
]
|
|
32425
|
+
],
|
|
32426
|
+
[
|
|
32427
|
+
XSDNS.String,
|
|
32428
|
+
[
|
|
32429
|
+
QueryOperators.$eq,
|
|
32430
|
+
QueryOperators.$ne,
|
|
32431
|
+
QueryOperators.$in,
|
|
32432
|
+
QueryOperators.$nin,
|
|
32433
|
+
QueryOperators.$sd
|
|
32434
|
+
]
|
|
32435
|
+
],
|
|
32408
32436
|
[XSDNS.DateTime, allOperations]
|
|
32409
32437
|
]);
|
|
32410
32438
|
/**
|
|
@@ -34991,7 +35019,7 @@ class LinkedMultiQueryInputs extends BaseConfig {
|
|
|
34991
35019
|
if (!this.query[i]) {
|
|
34992
35020
|
enabled.push(0);
|
|
34993
35021
|
claimPathNotExists.push(0);
|
|
34994
|
-
claimPathMtp.push(
|
|
35022
|
+
claimPathMtp.push(new Array(this.getMTLevelsClaim()).fill('0'));
|
|
34995
35023
|
claimPathMtpNoAux.push('0');
|
|
34996
35024
|
claimPathMtpAuxHi.push('0');
|
|
34997
35025
|
claimPathMtpAuxHv.push('0');
|
|
@@ -36737,6 +36765,8 @@ const PROTOCOL_MESSAGE_TYPE = Object.freeze({
|
|
|
36737
36765
|
CREDENTIAL_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/offer',
|
|
36738
36766
|
// CredentialIssuanceResponseMessageType is type for message with a credential issuance
|
|
36739
36767
|
CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/issuance-response',
|
|
36768
|
+
// CredentialRefreshMessageType is type for message with a credential issuance
|
|
36769
|
+
CREDENTIAL_REFRESH_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/refresh',
|
|
36740
36770
|
// DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
|
|
36741
36771
|
DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL + 'devices/1.0/registration',
|
|
36742
36772
|
// MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
|
|
@@ -37232,6 +37262,7 @@ class CredentialWallet {
|
|
|
37232
37262
|
cr['@context'] = context;
|
|
37233
37263
|
cr.type = credentialType;
|
|
37234
37264
|
cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
|
|
37265
|
+
cr.refreshService = request.refreshService;
|
|
37235
37266
|
cr.issuanceDate = new Date().toISOString();
|
|
37236
37267
|
cr.credentialSubject = credentialSubject;
|
|
37237
37268
|
cr.issuer = issuer.string();
|
|
@@ -63380,7 +63411,7 @@ class AuthHandler {
|
|
|
63380
63411
|
*/
|
|
63381
63412
|
class FetchHandler {
|
|
63382
63413
|
/**
|
|
63383
|
-
* Creates an instance of
|
|
63414
|
+
* Creates an instance of FetchHandler.
|
|
63384
63415
|
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
63385
63416
|
*/
|
|
63386
63417
|
constructor(_packerMgr) {
|
|
@@ -63393,7 +63424,7 @@ class FetchHandler {
|
|
|
63393
63424
|
* offer: Uint8Array; offer - raw offer message
|
|
63394
63425
|
* opts
|
|
63395
63426
|
* }) options how to fetch credential
|
|
63396
|
-
* @returns `Promise<W3CCredential>`
|
|
63427
|
+
* @returns `Promise<W3CCredential[]>`
|
|
63397
63428
|
*/
|
|
63398
63429
|
async handleCredentialOffer(offer, opts) {
|
|
63399
63430
|
if (!opts) {
|
|
@@ -63549,5 +63580,70 @@ class ContractRequestHandler {
|
|
|
63549
63580
|
}
|
|
63550
63581
|
}
|
|
63551
63582
|
|
|
63552
|
-
|
|
63583
|
+
/**
|
|
63584
|
+
*
|
|
63585
|
+
* Allows to refresh credential from refresh service and return refreshed credential
|
|
63586
|
+
*
|
|
63587
|
+
* @public
|
|
63588
|
+
|
|
63589
|
+
* @class RefreshHandler
|
|
63590
|
+
* @implements implements RefreshHandler interface
|
|
63591
|
+
*/
|
|
63592
|
+
class RefreshHandler {
|
|
63593
|
+
/**
|
|
63594
|
+
* Creates an instance of RefreshHandler.
|
|
63595
|
+
* @param {RefreshHandlerOptions} _options - refresh handler options
|
|
63596
|
+
*/
|
|
63597
|
+
constructor(_options) {
|
|
63598
|
+
this._options = _options;
|
|
63599
|
+
}
|
|
63600
|
+
async refreshCredential(credential, opts) {
|
|
63601
|
+
if (!credential.refreshService) {
|
|
63602
|
+
throw new Error('refreshService not specified for W3CCredential');
|
|
63603
|
+
}
|
|
63604
|
+
if (credential.refreshService.type !== RefreshServiceType.Iden3RefreshService2023) {
|
|
63605
|
+
throw new Error(`refresh service type ${credential.refreshService.type} is not supported`);
|
|
63606
|
+
}
|
|
63607
|
+
const otherIdentifier = credential.credentialSubject.id;
|
|
63608
|
+
if (!otherIdentifier) {
|
|
63609
|
+
throw new Error('self credentials do not support refresh');
|
|
63610
|
+
}
|
|
63611
|
+
const senderDID = DID.parse(otherIdentifier);
|
|
63612
|
+
const zkpParams = {
|
|
63613
|
+
senderDID,
|
|
63614
|
+
provingMethodAlg: new ProvingMethodAlg(proving.provingMethodGroth16AuthV2Instance.methodAlg.alg, CircuitId.AuthV2)
|
|
63615
|
+
};
|
|
63616
|
+
const refreshMsg = {
|
|
63617
|
+
id: randomUUID$1(),
|
|
63618
|
+
typ: MediaType.ZKPMessage,
|
|
63619
|
+
type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE,
|
|
63620
|
+
thid: randomUUID$1(),
|
|
63621
|
+
body: {
|
|
63622
|
+
id: otherIdentifier,
|
|
63623
|
+
reason: opts?.reason ?? 'credential is expired'
|
|
63624
|
+
},
|
|
63625
|
+
from: otherIdentifier,
|
|
63626
|
+
to: credential.issuer
|
|
63627
|
+
};
|
|
63628
|
+
const msgBytes = byteEncoder.encode(JSON.stringify(refreshMsg));
|
|
63629
|
+
const jwzToken = await this._options.packageManager.pack(MediaType.ZKPMessage, msgBytes, zkpParams);
|
|
63630
|
+
const resp = await fetch(credential.refreshService.id, {
|
|
63631
|
+
method: 'post',
|
|
63632
|
+
headers: {
|
|
63633
|
+
'Content-Type': 'application/json'
|
|
63634
|
+
},
|
|
63635
|
+
body: jwzToken
|
|
63636
|
+
});
|
|
63637
|
+
if (resp.status !== 200) {
|
|
63638
|
+
throw new Error(`could not refresh W3C credential, return status ${resp.status}`);
|
|
63639
|
+
}
|
|
63640
|
+
const respBody = await resp.json();
|
|
63641
|
+
if (!respBody.body?.credential) {
|
|
63642
|
+
throw new Error('no credential in CredentialIssuanceMessage response');
|
|
63643
|
+
}
|
|
63644
|
+
return W3CCredential.fromJSON(respBody.body.credential);
|
|
63645
|
+
}
|
|
63646
|
+
}
|
|
63647
|
+
|
|
63648
|
+
export { AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DataPrepareHandlerFunc, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LinkedNullifierInputs, LinkedNullifierPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants$1 as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes, base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58, bytesToBase64, bytesToBase64url, bytesToHex$1 as bytesToHex, cacheLoader, checkDataInField, comparatorOptions, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fillSlot, findValue, generateProfileDID, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getProperties, getUserDIDFromCredential, hexToBytes$1 as hexToBytes, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, prepareCircuitArrayValues, prepareSiblingsStr, pushHashesToRHS, resolveDIDDocumentAuth, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, validateDIDDocumentAuth, validateTreeState };
|
|
63553
63649
|
//# sourceMappingURL=index.js.map
|