@le-space/core 0.6.22 → 0.6.24

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.
Files changed (2) hide show
  1. package/index.js +17 -3
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -73,7 +73,7 @@ function validateRootfsManifest(manifest) {
73
73
  function normalizeStatus(status) {
74
74
  if (typeof status !== "string") return "unknown";
75
75
  const normalized = status.toLowerCase();
76
- if (normalized === "processed" || normalized === "pending" || normalized === "rejected") {
76
+ if (normalized === "processed" || normalized === "pending" || normalized === "rejected" || normalized === "removing" || normalized === "removed") {
77
77
  return normalized;
78
78
  }
79
79
  return "unknown";
@@ -98,6 +98,7 @@ function parseCidFromPayload(payload) {
98
98
  }
99
99
  function parseRejectionReason(payload) {
100
100
  const errorCode = typeof payload.error_code === "number" ? payload.error_code : null;
101
+ const reason = typeof payload.reason === "string" ? payload.reason.trim() : "";
101
102
  const details = payload.details && typeof payload.details === "object" ? payload.details : null;
102
103
  const rawErrors = Array.isArray(details?.errors) ? details.errors : [];
103
104
  const firstError = rawErrors[0] && typeof rawErrors[0] === "object" ? rawErrors[0] : null;
@@ -112,6 +113,18 @@ function parseRejectionReason(payload) {
112
113
  };
113
114
  }
114
115
  }
116
+ if (reason === "balance_insufficient") {
117
+ return {
118
+ rejectionErrorCode: errorCode,
119
+ rejectionReason: "The rootfs STORE is being removed because its publisher no longer has enough Aleph credits. Your connected MetaMask balance may be sufficient, but this manifest must point to a newly published, processed rootfs STORE."
120
+ };
121
+ }
122
+ if (reason) {
123
+ return {
124
+ rejectionErrorCode: errorCode,
125
+ rejectionReason: `Aleph marked the rootfs STORE as unavailable: ${reason.replaceAll("_", " ")}.`
126
+ };
127
+ }
115
128
  return {
116
129
  rejectionErrorCode: errorCode,
117
130
  rejectionReason: errorCode != null ? `Rejected by Aleph (error code ${errorCode}).` : null
@@ -162,14 +175,15 @@ async function resolveRootfsReference(itemHash, options) {
162
175
  const firstMessage = Array.isArray(payload.messages) && payload.messages[0] && typeof payload.messages[0] === "object" ? payload.messages[0] : null;
163
176
  const messageObject = payload.message && typeof payload.message === "object" ? payload.message : null;
164
177
  const cid = parseCidFromPayload(payload);
165
- const rejection = normalizeStatus(payload.status) === "rejected" ? parseRejectionReason(payload) : { rejectionErrorCode: null, rejectionReason: null };
178
+ const messageStatus = normalizeStatus(payload.status);
179
+ const rejection = messageStatus === "processed" || messageStatus === "pending" ? { rejectionErrorCode: null, rejectionReason: null } : parseRejectionReason(payload);
166
180
  const gateway = cid ? await probeRootfsGateway(cid, {
167
181
  gatewayBaseUrl: options.gatewayBaseUrl,
168
182
  fetch: options.fetch
169
183
  }) : { gatewayUrl: null, gatewayStatus: "unknown", gatewayError: null };
170
184
  return {
171
185
  itemHash,
172
- messageStatus: normalizeStatus(payload.status),
186
+ messageStatus,
173
187
  messageType: String(payload.type || messageObject?.type || firstMessage?.type || "").toUpperCase() || null,
174
188
  cid,
175
189
  receptionTime: typeof payload.reception_time === "string" ? payload.reception_time : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/core",
3
- "version": "0.6.22",
3
+ "version": "0.6.24",
4
4
  "description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/NiKrause/relay-button/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@le-space/aleph-bootstrap": "0.6.22",
28
- "@le-space/shared-types": "0.6.22"
27
+ "@le-space/aleph-bootstrap": "0.6.24",
28
+ "@le-space/shared-types": "0.6.24"
29
29
  }
30
30
  }