@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.mjs
CHANGED
|
@@ -1959,6 +1959,13 @@ function isGroupMigrationEvent(event) {
|
|
|
1959
1959
|
|
|
1960
1960
|
// src/events/sse.ts
|
|
1961
1961
|
var TERMINAL_AUTH_ERRORS2 = /* @__PURE__ */ new Set(["token_reuse", "token_revoked"]);
|
|
1962
|
+
var TERMINAL_AUTH_STATUSES = /* @__PURE__ */ new Set([401, 403]);
|
|
1963
|
+
function isTerminalAuthFailure(response) {
|
|
1964
|
+
const authError = response.headers.get("x-auth-error");
|
|
1965
|
+
if (!authError) return null;
|
|
1966
|
+
if (!TERMINAL_AUTH_STATUSES.has(response.status)) return null;
|
|
1967
|
+
return TERMINAL_AUTH_ERRORS2.has(authError) ? authError : null;
|
|
1968
|
+
}
|
|
1962
1969
|
var SseClient = class {
|
|
1963
1970
|
constructor(opts) {
|
|
1964
1971
|
this.sessionId = null;
|
|
@@ -2045,11 +2052,11 @@ var SseClient = class {
|
|
|
2045
2052
|
signal: this.abortController.signal
|
|
2046
2053
|
});
|
|
2047
2054
|
if (!response.ok) {
|
|
2048
|
-
const
|
|
2055
|
+
const terminal = isTerminalAuthFailure(response);
|
|
2049
2056
|
const bodyText = await response.text().catch(() => void 0);
|
|
2050
|
-
if (
|
|
2057
|
+
if (terminal) {
|
|
2051
2058
|
throw new AuthRevokedError(
|
|
2052
|
-
|
|
2059
|
+
terminal,
|
|
2053
2060
|
response.status,
|
|
2054
2061
|
response.statusText,
|
|
2055
2062
|
url,
|
|
@@ -2078,6 +2085,7 @@ var SseClient = class {
|
|
|
2078
2085
|
if (this.closed) return;
|
|
2079
2086
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
2080
2087
|
this.emit("error", error);
|
|
2088
|
+
if (error instanceof AuthRevokedError) return;
|
|
2081
2089
|
this.scheduleReconnect();
|
|
2082
2090
|
}
|
|
2083
2091
|
}
|
|
@@ -2208,7 +2216,25 @@ var SseClient = class {
|
|
|
2208
2216
|
})
|
|
2209
2217
|
});
|
|
2210
2218
|
if (!response.ok) {
|
|
2211
|
-
|
|
2219
|
+
const terminal = isTerminalAuthFailure(response);
|
|
2220
|
+
const bodyText = await response.text().catch(() => void 0);
|
|
2221
|
+
this.emit(
|
|
2222
|
+
"error",
|
|
2223
|
+
terminal ? new AuthRevokedError(
|
|
2224
|
+
terminal,
|
|
2225
|
+
response.status,
|
|
2226
|
+
response.statusText,
|
|
2227
|
+
`${this.baseUrl}/sse/subscription`,
|
|
2228
|
+
response.headers,
|
|
2229
|
+
bodyText
|
|
2230
|
+
) : new HTTPError(
|
|
2231
|
+
response.status,
|
|
2232
|
+
response.statusText,
|
|
2233
|
+
`${this.baseUrl}/sse/subscription`,
|
|
2234
|
+
response.headers,
|
|
2235
|
+
bodyText
|
|
2236
|
+
)
|
|
2237
|
+
);
|
|
2212
2238
|
}
|
|
2213
2239
|
} catch (err) {
|
|
2214
2240
|
this.emit("error", err instanceof Error ? err : new Error(`SSE ${method} failed`));
|