@0xpolygonid/js-sdk 1.32.3 → 1.32.4
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 +37 -8
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.global.js +22 -22
- package/dist/browser/umd/index.global.js.map +1 -1
- package/dist/node/cjs/index.cjs +290 -10
- package/dist/node/cjs/index.cjs.map +1 -1
- package/dist/node/esm/index.js +37 -8
- package/dist/node/esm/index.js.map +1 -1
- package/dist/types/credentials/status/on-chain-revocation.d.ts.map +1 -1
- package/dist/types/credentials/status/reverse-sparse-merkle-tree.d.ts.map +1 -1
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts.map +1 -1
- package/dist/types/storage/blockchain/errors.d.ts +4 -0
- package/dist/types/storage/blockchain/errors.d.ts.map +1 -0
- package/dist/types/storage/blockchain/index.d.ts +1 -0
- package/dist/types/storage/blockchain/index.d.ts.map +1 -1
- package/dist/types/verifiable/constants.d.ts +5 -0
- package/dist/types/verifiable/constants.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credentials/status/on-chain-revocation.ts +2 -3
- package/src/credentials/status/reverse-sparse-merkle-tree.ts +3 -3
- package/src/proof/verifiers/pub-signals-verifier.ts +3 -4
- package/src/storage/blockchain/errors.ts +46 -0
- package/src/storage/blockchain/index.ts +1 -0
- package/src/verifiable/constants.ts +5 -0
package/dist/node/esm/index.js
CHANGED
|
@@ -789,7 +789,12 @@ var VerifiableConstants = Object.freeze({
|
|
|
789
789
|
CONTEXT_TYPE_IS_EMPTY: "ctxType is empty",
|
|
790
790
|
// ErrStateNotFound issuer state is genesis state.
|
|
791
791
|
IDENTITY_DOES_NOT_EXIST: "Identity does not exist",
|
|
792
|
+
IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR: "IdentityDoesNotExist",
|
|
792
793
|
NO_AUTH_CRED_FOUND: "no auth credentials found",
|
|
794
|
+
STATE_DOES_NOT_EXIST: "State does not exist",
|
|
795
|
+
STATE_DOES_NOT_EXIST_CUSTOM_ERROR: "StateDoesNotExist",
|
|
796
|
+
ROOT_DOES_NOT_EXIST: "Root does not exist",
|
|
797
|
+
ROOT_DOES_NOT_EXIST_CUSTOM_ERROR: "RootDoesNotExist",
|
|
793
798
|
// identity wallet
|
|
794
799
|
ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY: "no credential satisfied query",
|
|
795
800
|
ID_WALLET_SIGNER_IS_REQUIRED: "Ethereum signer is required to create Ethereum identities in order to transit state",
|
|
@@ -6244,6 +6249,31 @@ var OnChainRevocationStorage = class _OnChainRevocationStorage {
|
|
|
6244
6249
|
// src/credentials/status/on-chain-revocation.ts
|
|
6245
6250
|
import { DID as DID9 } from "@iden3/js-iden3-core";
|
|
6246
6251
|
import { Hash as Hash15 } from "@iden3/js-merkletree";
|
|
6252
|
+
|
|
6253
|
+
// src/storage/blockchain/errors.ts
|
|
6254
|
+
function isErrorWithArgs(error) {
|
|
6255
|
+
return typeof error === "object" && error !== null && "errorArgs" in error && Array.isArray(error.errorArgs);
|
|
6256
|
+
}
|
|
6257
|
+
function extractErrorMessage(error) {
|
|
6258
|
+
const errorArgs = isErrorWithArgs(error) ? error.errorArgs[0] : void 0;
|
|
6259
|
+
const errMsg = errorArgs || (error instanceof Error ? error.message : "");
|
|
6260
|
+
return errMsg;
|
|
6261
|
+
}
|
|
6262
|
+
function isError(error, errorMsg) {
|
|
6263
|
+
const errMsg = extractErrorMessage(error);
|
|
6264
|
+
return errMsg.includes(errorMsg);
|
|
6265
|
+
}
|
|
6266
|
+
function isIdentityDoesNotExistError(error) {
|
|
6267
|
+
return isError(error, VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST) || isError(error, VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST_CUSTOM_ERROR);
|
|
6268
|
+
}
|
|
6269
|
+
function isStateDoesNotExistError(error) {
|
|
6270
|
+
return isError(error, VerifiableConstants.ERRORS.STATE_DOES_NOT_EXIST) || isError(error, VerifiableConstants.ERRORS.STATE_DOES_NOT_EXIST_CUSTOM_ERROR);
|
|
6271
|
+
}
|
|
6272
|
+
function isRootDoesNotExistError(error) {
|
|
6273
|
+
return isError(error, VerifiableConstants.ERRORS.ROOT_DOES_NOT_EXIST) || isError(error, VerifiableConstants.ERRORS.ROOT_DOES_NOT_EXIST_CUSTOM_ERROR);
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6276
|
+
// src/credentials/status/on-chain-revocation.ts
|
|
6247
6277
|
var OnChainResolver = class {
|
|
6248
6278
|
/**
|
|
6249
6279
|
*
|
|
@@ -6291,8 +6321,7 @@ var OnChainResolver = class {
|
|
|
6291
6321
|
}
|
|
6292
6322
|
latestIssuerState = latestStateInfo.state;
|
|
6293
6323
|
} catch (e) {
|
|
6294
|
-
|
|
6295
|
-
if (!errMsg.includes(VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST)) {
|
|
6324
|
+
if (!isIdentityDoesNotExistError(e)) {
|
|
6296
6325
|
throw e;
|
|
6297
6326
|
}
|
|
6298
6327
|
if (!stateHex) {
|
|
@@ -6500,8 +6529,7 @@ var RHSResolver = class {
|
|
|
6500
6529
|
}
|
|
6501
6530
|
latestState = latestStateInfo.state;
|
|
6502
6531
|
} catch (e) {
|
|
6503
|
-
|
|
6504
|
-
if (!errMsg.includes(VerifiableConstants.ERRORS.IDENTITY_DOES_NOT_EXIST)) {
|
|
6532
|
+
if (!isIdentityDoesNotExistError(e)) {
|
|
6505
6533
|
throw e;
|
|
6506
6534
|
}
|
|
6507
6535
|
const stateHex = this.extractState(credentialStatus.id);
|
|
@@ -13013,9 +13041,7 @@ var PubSignalsVerifier = class {
|
|
|
13013
13041
|
try {
|
|
13014
13042
|
contractState = await this._stateStorage.getStateInfoByIdAndState(idBigInt, state);
|
|
13015
13043
|
} catch (e) {
|
|
13016
|
-
|
|
13017
|
-
const errMsg = stateNotExistErr || e.message;
|
|
13018
|
-
if (errMsg.includes("State does not exist")) {
|
|
13044
|
+
if (isStateDoesNotExistError(e)) {
|
|
13019
13045
|
if (isGenesis) {
|
|
13020
13046
|
return {
|
|
13021
13047
|
latest: true,
|
|
@@ -13048,7 +13074,7 @@ var PubSignalsVerifier = class {
|
|
|
13048
13074
|
try {
|
|
13049
13075
|
globalStateInfo = await this._stateStorage.getGISTRootInfo(state, id);
|
|
13050
13076
|
} catch (e) {
|
|
13051
|
-
if (e
|
|
13077
|
+
if (isRootDoesNotExistError(e)) {
|
|
13052
13078
|
throw new Error("GIST root does not exist in the smart contract");
|
|
13053
13079
|
}
|
|
13054
13080
|
throw e;
|
|
@@ -14418,7 +14444,10 @@ export {
|
|
|
14418
14444
|
isEthereumIdentity,
|
|
14419
14445
|
isGenesisState,
|
|
14420
14446
|
isGenesisStateId,
|
|
14447
|
+
isIdentityDoesNotExistError,
|
|
14421
14448
|
isIssuerGenesis,
|
|
14449
|
+
isRootDoesNotExistError,
|
|
14450
|
+
isStateDoesNotExistError,
|
|
14422
14451
|
isValidOperation,
|
|
14423
14452
|
jsonLDMerklizer,
|
|
14424
14453
|
keyPath,
|