@calimero-network/mero-js 26.0.0 → 26.1.0
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/account/join-with-node.d.ts +7 -12
- package/dist/account/join-with-node.js +7 -12
- package/dist/admin-api/redeem-invitation.d.ts +8 -1
- package/dist/admin-api/redeem-invitation.js +64 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +27 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1168,6 +1168,25 @@ function isSettled(outcome) {
|
|
|
1168
1168
|
function shouldRetain(outcome) {
|
|
1169
1169
|
return !isSettled(outcome);
|
|
1170
1170
|
}
|
|
1171
|
+
var REASON_FOR_CODE = {
|
|
1172
|
+
invitation_expired: "expired",
|
|
1173
|
+
invitation_invalid: "invalid",
|
|
1174
|
+
invitation_already_used: "already-used",
|
|
1175
|
+
removed_from_group: "removed",
|
|
1176
|
+
reentry_blocked: "refused"
|
|
1177
|
+
};
|
|
1178
|
+
function refusalCodeOf(err) {
|
|
1179
|
+
if (!err || typeof err !== "object") return void 0;
|
|
1180
|
+
const shaped = err;
|
|
1181
|
+
if (typeof shaped.response?.data?.code === "string") return shaped.response.data.code;
|
|
1182
|
+
if (typeof shaped.bodyText !== "string") return void 0;
|
|
1183
|
+
try {
|
|
1184
|
+
const body = JSON.parse(shaped.bodyText);
|
|
1185
|
+
return typeof body?.code === "string" ? body.code : void 0;
|
|
1186
|
+
} catch {
|
|
1187
|
+
return void 0;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1171
1190
|
function reasonFromMessage(message) {
|
|
1172
1191
|
const m = message.toLowerCase();
|
|
1173
1192
|
if (m.includes("invitation has expired") || m.includes("invitation expired") || // Core rc.56+ names the group between the words: "invitation for group
|
|
@@ -1178,11 +1197,19 @@ function reasonFromMessage(message) {
|
|
|
1178
1197
|
if (m.includes("malformed") || m.includes("does not match namespace_id") || m.includes("invalid invitation") || /\binvitation for group .+? is invalid:/.test(m)) {
|
|
1179
1198
|
return "invalid";
|
|
1180
1199
|
}
|
|
1200
|
+
if (m.includes("has already used this invitation")) return "already-used";
|
|
1201
|
+
if (/\bwas removed from group\b/.test(m)) return "removed";
|
|
1181
1202
|
return null;
|
|
1182
1203
|
}
|
|
1204
|
+
var FINAL_FROM_TEXT = /* @__PURE__ */ new Set(["already-used", "removed"]);
|
|
1183
1205
|
function classifyJoinFailure(err, message) {
|
|
1184
1206
|
const { kind, status } = classifyError(err);
|
|
1185
1207
|
const fromText = reasonFromMessage(message);
|
|
1208
|
+
const code = refusalCodeOf(err);
|
|
1209
|
+
const fromCode = code ? REASON_FOR_CODE[code] : void 0;
|
|
1210
|
+
if (fromCode) return { reason: fromCode, retryable: false };
|
|
1211
|
+
if (fromText && FINAL_FROM_TEXT.has(fromText)) return { reason: fromText, retryable: false };
|
|
1212
|
+
if (code === "join_refused_by_member") return { reason: "unknown", retryable: true };
|
|
1186
1213
|
if (status === 401) return { reason: "signed-out", retryable: true };
|
|
1187
1214
|
if (status === 400) return { reason: fromText ?? "invalid", retryable: false };
|
|
1188
1215
|
if (status === 410) return { reason: "expired", retryable: false };
|