@0xpolygonid/js-sdk 1.32.1 → 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.
@@ -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
- const errMsg = e?.reason ?? e.message ?? e;
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
- const errMsg = e?.reason ?? e.message ?? e;
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);
@@ -12193,7 +12221,6 @@ var InputGenerator = class {
12193
12221
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
12194
12222
  const query = circuitQueries[0];
12195
12223
  query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
12196
- query.valueProof = query.operator === 0 /* NOOP */ ? new ValueProof() : query.valueProof;
12197
12224
  circuitInputs.query = query;
12198
12225
  circuitInputs.currentTimeStamp = getUnixTimestamp7(/* @__PURE__ */ new Date());
12199
12226
  circuitInputs.proofType = proofType;
@@ -12246,7 +12273,6 @@ var InputGenerator = class {
12246
12273
  circuitInputs.skipClaimRevocationCheck = params.skipRevocation;
12247
12274
  const query = circuitQueries[0];
12248
12275
  query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
12249
- query.valueProof = query.operator === 0 /* NOOP */ ? new ValueProof() : query.valueProof;
12250
12276
  circuitInputs.query = query;
12251
12277
  circuitInputs.currentTimeStamp = getUnixTimestamp7(/* @__PURE__ */ new Date());
12252
12278
  circuitInputs.proofType = proofType;
@@ -12295,7 +12321,6 @@ var InputGenerator = class {
12295
12321
  });
12296
12322
  circuitQueries.forEach((query) => {
12297
12323
  query.values = [16 /* SD */, 0 /* NOOP */].includes(query.operator) ? [] : query.values;
12298
- query.valueProof = query.operator === 0 /* NOOP */ ? new ValueProof() : query.valueProof;
12299
12324
  });
12300
12325
  return circuitInputs.inputsMarshal();
12301
12326
  };
@@ -13016,9 +13041,7 @@ var PubSignalsVerifier = class {
13016
13041
  try {
13017
13042
  contractState = await this._stateStorage.getStateInfoByIdAndState(idBigInt, state);
13018
13043
  } catch (e) {
13019
- const stateNotExistErr = (e?.errorArgs ?? [])[0];
13020
- const errMsg = stateNotExistErr || e.message;
13021
- if (errMsg.includes("State does not exist")) {
13044
+ if (isStateDoesNotExistError(e)) {
13022
13045
  if (isGenesis) {
13023
13046
  return {
13024
13047
  latest: true,
@@ -13051,7 +13074,7 @@ var PubSignalsVerifier = class {
13051
13074
  try {
13052
13075
  globalStateInfo = await this._stateStorage.getGISTRootInfo(state, id);
13053
13076
  } catch (e) {
13054
- if (e.errorArgs[0] === "Root does not exist") {
13077
+ if (isRootDoesNotExistError(e)) {
13055
13078
  throw new Error("GIST root does not exist in the smart contract");
13056
13079
  }
13057
13080
  throw e;
@@ -14421,7 +14444,10 @@ export {
14421
14444
  isEthereumIdentity,
14422
14445
  isGenesisState,
14423
14446
  isGenesisStateId,
14447
+ isIdentityDoesNotExistError,
14424
14448
  isIssuerGenesis,
14449
+ isRootDoesNotExistError,
14450
+ isStateDoesNotExistError,
14425
14451
  isValidOperation,
14426
14452
  jsonLDMerklizer,
14427
14453
  keyPath,