@calimero-network/mero-js 19.14.0 → 19.14.1
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/events/sse.js +45 -6
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +30 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +30 -4
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2052,6 +2052,13 @@ function isGroupMigrationEvent(event) {
|
|
|
2052
2052
|
|
|
2053
2053
|
// src/events/sse.ts
|
|
2054
2054
|
var TERMINAL_AUTH_ERRORS2 = /* @__PURE__ */ new Set(["token_reuse", "token_revoked"]);
|
|
2055
|
+
var TERMINAL_AUTH_STATUSES = /* @__PURE__ */ new Set([401, 403]);
|
|
2056
|
+
function isTerminalAuthFailure(response) {
|
|
2057
|
+
const authError = response.headers.get("x-auth-error");
|
|
2058
|
+
if (!authError) return null;
|
|
2059
|
+
if (!TERMINAL_AUTH_STATUSES.has(response.status)) return null;
|
|
2060
|
+
return TERMINAL_AUTH_ERRORS2.has(authError) ? authError : null;
|
|
2061
|
+
}
|
|
2055
2062
|
var SseClient = class {
|
|
2056
2063
|
constructor(opts) {
|
|
2057
2064
|
this.sessionId = null;
|
|
@@ -2138,11 +2145,11 @@ var SseClient = class {
|
|
|
2138
2145
|
signal: this.abortController.signal
|
|
2139
2146
|
});
|
|
2140
2147
|
if (!response.ok) {
|
|
2141
|
-
const
|
|
2148
|
+
const terminal = isTerminalAuthFailure(response);
|
|
2142
2149
|
const bodyText = await response.text().catch(() => void 0);
|
|
2143
|
-
if (
|
|
2150
|
+
if (terminal) {
|
|
2144
2151
|
throw new AuthRevokedError(
|
|
2145
|
-
|
|
2152
|
+
terminal,
|
|
2146
2153
|
response.status,
|
|
2147
2154
|
response.statusText,
|
|
2148
2155
|
url,
|
|
@@ -2171,6 +2178,7 @@ var SseClient = class {
|
|
|
2171
2178
|
if (this.closed) return;
|
|
2172
2179
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
2173
2180
|
this.emit("error", error);
|
|
2181
|
+
if (error instanceof AuthRevokedError) return;
|
|
2174
2182
|
this.scheduleReconnect();
|
|
2175
2183
|
}
|
|
2176
2184
|
}
|
|
@@ -2301,7 +2309,25 @@ var SseClient = class {
|
|
|
2301
2309
|
})
|
|
2302
2310
|
});
|
|
2303
2311
|
if (!response.ok) {
|
|
2304
|
-
|
|
2312
|
+
const terminal = isTerminalAuthFailure(response);
|
|
2313
|
+
const bodyText = await response.text().catch(() => void 0);
|
|
2314
|
+
this.emit(
|
|
2315
|
+
"error",
|
|
2316
|
+
terminal ? new AuthRevokedError(
|
|
2317
|
+
terminal,
|
|
2318
|
+
response.status,
|
|
2319
|
+
response.statusText,
|
|
2320
|
+
`${this.baseUrl}/sse/subscription`,
|
|
2321
|
+
response.headers,
|
|
2322
|
+
bodyText
|
|
2323
|
+
) : new HTTPError(
|
|
2324
|
+
response.status,
|
|
2325
|
+
response.statusText,
|
|
2326
|
+
`${this.baseUrl}/sse/subscription`,
|
|
2327
|
+
response.headers,
|
|
2328
|
+
bodyText
|
|
2329
|
+
)
|
|
2330
|
+
);
|
|
2305
2331
|
}
|
|
2306
2332
|
} catch (err) {
|
|
2307
2333
|
this.emit("error", err instanceof Error ? err : new Error(`SSE ${method} failed`));
|