@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
|
@@ -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();
|
|
@@ -63348,6 +63379,7 @@ class AuthHandler {
|
|
|
63348
63379
|
}
|
|
63349
63380
|
const credWithRevStatus = groupedCredentialsCache.get(groupId);
|
|
63350
63381
|
const zkpRes = await this._proofService.generateProof(proofReq, did, {
|
|
63382
|
+
verifierDid: DID.parse(authRequest.from),
|
|
63351
63383
|
skipRevocation: Boolean(query.skipClaimRevocationCheck),
|
|
63352
63384
|
credential: credWithRevStatus?.cred,
|
|
63353
63385
|
credentialRevocationStatus: credWithRevStatus?.revStatus,
|
|
@@ -63380,7 +63412,7 @@ class AuthHandler {
|
|
|
63380
63412
|
*/
|
|
63381
63413
|
class FetchHandler {
|
|
63382
63414
|
/**
|
|
63383
|
-
* Creates an instance of
|
|
63415
|
+
* Creates an instance of FetchHandler.
|
|
63384
63416
|
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
63385
63417
|
*/
|
|
63386
63418
|
constructor(_packerMgr) {
|
|
@@ -63393,7 +63425,7 @@ class FetchHandler {
|
|
|
63393
63425
|
* offer: Uint8Array; offer - raw offer message
|
|
63394
63426
|
* opts
|
|
63395
63427
|
* }) options how to fetch credential
|
|
63396
|
-
* @returns `Promise<W3CCredential>`
|
|
63428
|
+
* @returns `Promise<W3CCredential[]>`
|
|
63397
63429
|
*/
|
|
63398
63430
|
async handleCredentialOffer(offer, opts) {
|
|
63399
63431
|
if (!opts) {
|
|
@@ -63549,5 +63581,70 @@ class ContractRequestHandler {
|
|
|
63549
63581
|
}
|
|
63550
63582
|
}
|
|
63551
63583
|
|
|
63552
|
-
|
|
63584
|
+
/**
|
|
63585
|
+
*
|
|
63586
|
+
* Allows to refresh credential from refresh service and return refreshed credential
|
|
63587
|
+
*
|
|
63588
|
+
* @public
|
|
63589
|
+
|
|
63590
|
+
* @class RefreshHandler
|
|
63591
|
+
* @implements implements RefreshHandler interface
|
|
63592
|
+
*/
|
|
63593
|
+
class RefreshHandler {
|
|
63594
|
+
/**
|
|
63595
|
+
* Creates an instance of RefreshHandler.
|
|
63596
|
+
* @param {RefreshHandlerOptions} _options - refresh handler options
|
|
63597
|
+
*/
|
|
63598
|
+
constructor(_options) {
|
|
63599
|
+
this._options = _options;
|
|
63600
|
+
}
|
|
63601
|
+
async refreshCredential(credential, opts) {
|
|
63602
|
+
if (!credential.refreshService) {
|
|
63603
|
+
throw new Error('refreshService not specified for W3CCredential');
|
|
63604
|
+
}
|
|
63605
|
+
if (credential.refreshService.type !== RefreshServiceType.Iden3RefreshService2023) {
|
|
63606
|
+
throw new Error(`refresh service type ${credential.refreshService.type} is not supported`);
|
|
63607
|
+
}
|
|
63608
|
+
const otherIdentifier = credential.credentialSubject.id;
|
|
63609
|
+
if (!otherIdentifier) {
|
|
63610
|
+
throw new Error('self credentials do not support refresh');
|
|
63611
|
+
}
|
|
63612
|
+
const senderDID = DID.parse(otherIdentifier);
|
|
63613
|
+
const zkpParams = {
|
|
63614
|
+
senderDID,
|
|
63615
|
+
provingMethodAlg: new ProvingMethodAlg(proving.provingMethodGroth16AuthV2Instance.methodAlg.alg, CircuitId.AuthV2)
|
|
63616
|
+
};
|
|
63617
|
+
const refreshMsg = {
|
|
63618
|
+
id: randomUUID$1(),
|
|
63619
|
+
typ: MediaType.ZKPMessage,
|
|
63620
|
+
type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE,
|
|
63621
|
+
thid: randomUUID$1(),
|
|
63622
|
+
body: {
|
|
63623
|
+
id: otherIdentifier,
|
|
63624
|
+
reason: opts?.reason ?? 'credential is expired'
|
|
63625
|
+
},
|
|
63626
|
+
from: otherIdentifier,
|
|
63627
|
+
to: credential.issuer
|
|
63628
|
+
};
|
|
63629
|
+
const msgBytes = byteEncoder.encode(JSON.stringify(refreshMsg));
|
|
63630
|
+
const jwzToken = await this._options.packageManager.pack(MediaType.ZKPMessage, msgBytes, zkpParams);
|
|
63631
|
+
const resp = await fetch(credential.refreshService.id, {
|
|
63632
|
+
method: 'post',
|
|
63633
|
+
headers: {
|
|
63634
|
+
'Content-Type': 'application/json'
|
|
63635
|
+
},
|
|
63636
|
+
body: jwzToken
|
|
63637
|
+
});
|
|
63638
|
+
if (resp.status !== 200) {
|
|
63639
|
+
throw new Error(`could not refresh W3C credential, return status ${resp.status}`);
|
|
63640
|
+
}
|
|
63641
|
+
const respBody = await resp.json();
|
|
63642
|
+
if (!respBody.body?.credential) {
|
|
63643
|
+
throw new Error('no credential in CredentialIssuanceMessage response');
|
|
63644
|
+
}
|
|
63645
|
+
return W3CCredential.fromJSON(respBody.body.credential);
|
|
63646
|
+
}
|
|
63647
|
+
}
|
|
63648
|
+
|
|
63649
|
+
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
63650
|
//# sourceMappingURL=index.js.map
|