@pafi-dev/issuer 0.12.5 → 0.12.7

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/index.cjs CHANGED
@@ -3909,6 +3909,12 @@ var BalanceAggregator = class {
3909
3909
 
3910
3910
  // src/pafi-backend/client.ts
3911
3911
  var import_core17 = require("@pafi-dev/core");
3912
+ function extractPafiErrorFields(json, status) {
3913
+ const inner = typeof json.error === "object" && json.error !== null ? json.error : null;
3914
+ const code = inner?.code ?? json.code ?? "INTERNAL_ERROR";
3915
+ const message = inner?.message ?? json.message ?? `HTTP ${status}`;
3916
+ return { code, message };
3917
+ }
3912
3918
  function serializeBigInt(_key, value) {
3913
3919
  return typeof value === "bigint" ? value.toString(10) : value;
3914
3920
  }
@@ -3984,8 +3990,7 @@ var PafiBackendClient = class {
3984
3990
  } catch {
3985
3991
  }
3986
3992
  if (!response.ok) {
3987
- const code = json.code ?? "INTERNAL_ERROR";
3988
- const message = json.message ?? `HTTP ${response.status}`;
3993
+ const { code, message } = extractPafiErrorFields(json, response.status);
3989
3994
  throw new PafiBackendError(code, message, response.status, json);
3990
3995
  }
3991
3996
  if (json.pending) return null;
@@ -4023,8 +4028,7 @@ var PafiBackendClient = class {
4023
4028
  } catch {
4024
4029
  }
4025
4030
  if (!response.ok) {
4026
- const code = json.code ?? "INTERNAL_ERROR";
4027
- const message = json.message ?? `HTTP ${response.status}`;
4031
+ const { code, message } = extractPafiErrorFields(json, response.status);
4028
4032
  throw new PafiBackendError(code, message, response.status, json);
4029
4033
  }
4030
4034
  return { userOpHash: json.userOpHash };
@@ -4058,10 +4062,10 @@ var PafiBackendClient = class {
4058
4062
  } catch {
4059
4063
  }
4060
4064
  if (!response.ok) {
4061
- const code = json.code ?? "INTERNAL_ERROR";
4062
- const message = json.message ?? `HTTP ${response.status}`;
4063
- const retryAfter = typeof json.retryAfter === "number" ? json.retryAfter : void 0;
4064
- const safeToRetry = typeof json.safeToRetry === "boolean" ? json.safeToRetry : void 0;
4065
+ const { code, message } = extractPafiErrorFields(json, response.status);
4066
+ const errInner = typeof json.error === "object" && json.error !== null ? json.error : json;
4067
+ const retryAfter = typeof errInner.retryAfter === "number" ? errInner.retryAfter : typeof json.retryAfter === "number" ? json.retryAfter : void 0;
4068
+ const safeToRetry = typeof errInner.safeToRetry === "boolean" ? errInner.safeToRetry : typeof json.safeToRetry === "boolean" ? json.safeToRetry : void 0;
4065
4069
  throw new PafiBackendError(code, message, response.status, json, {
4066
4070
  retryAfter,
4067
4071
  safeToRetry
@@ -4735,7 +4739,7 @@ var MemoryRedemptionHistoryStore = class {
4735
4739
  };
4736
4740
 
4737
4741
  // src/index.ts
4738
- var PAFI_ISSUER_SDK_VERSION = true ? "0.12.5" : "dev";
4742
+ var PAFI_ISSUER_SDK_VERSION = true ? "0.12.7" : "dev";
4739
4743
  // Annotate the CommonJS export names for ESM import in node:
4740
4744
  0 && (module.exports = {
4741
4745
  AdapterMisconfiguredError,