@darajs/core 1.26.13 → 1.27.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/api/core.js +2 -2
- package/dist/api/core.js.map +1 -1
- package/dist/api/http.d.ts +1 -4
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +1 -39
- package/dist/api/http.js.map +1 -1
- package/dist/api/websocket.d.ts +2 -1
- package/dist/api/websocket.d.ts.map +1 -1
- package/dist/api/websocket.js +15 -6
- package/dist/api/websocket.js.map +1 -1
- package/dist/auth/auth.d.ts +14 -5
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/auth/auth.js +34 -13
- package/dist/auth/auth.js.map +1 -1
- package/dist/auth/basic/basic-auth-login.js +3 -3
- package/dist/auth/basic/basic-auth-login.js.map +1 -1
- package/dist/auth/default/default-auth-login.js +3 -3
- package/dist/auth/default/default-auth-login.js.map +1 -1
- package/dist/auth/oidc/oidc-login.js +4 -4
- package/dist/auth/oidc/oidc-login.js.map +1 -1
- package/dist/auth/oidc/sso-callback.d.ts.map +1 -1
- package/dist/auth/oidc/sso-callback.js +3 -1
- package/dist/auth/oidc/sso-callback.js.map +1 -1
- package/dist/auth/session-state.d.ts +0 -19
- package/dist/auth/session-state.d.ts.map +1 -1
- package/dist/auth/session-state.js +0 -89
- package/dist/auth/session-state.js.map +1 -1
- package/dist/router/create-router.d.ts.map +1 -1
- package/dist/router/create-router.js +5 -1
- package/dist/router/create-router.js.map +1 -1
- package/dist/router/fetching.js +1 -1
- package/dist/router/fetching.js.map +1 -1
- package/dist/shared/interactivity/derived-variable.js +1 -1
- package/dist/shared/interactivity/derived-variable.js.map +1 -1
- package/dist/shared/interactivity/persistence.js +2 -2
- package/dist/shared/interactivity/persistence.js.map +1 -1
- package/dist/shared/interactivity/server-variable.js +1 -1
- package/dist/shared/interactivity/server-variable.js.map +1 -1
- package/dist/shared/interactivity/stream-variable.d.ts.map +1 -1
- package/dist/shared/interactivity/stream-variable.js +5 -0
- package/dist/shared/interactivity/stream-variable.js.map +1 -1
- package/dist/shared/interactivity/tabular-variable.js +2 -2
- package/dist/shared/interactivity/tabular-variable.js.map +1 -1
- package/dist/shared/interactivity/use-action.js +1 -1
- package/dist/shared/interactivity/use-action.js.map +1 -1
- package/dist/shared/interactivity/use-server-component.js +1 -1
- package/dist/shared/interactivity/use-server-component.js.map +1 -1
- package/dist/umd/dara.core.umd.cjs +159 -187
- package/package.json +9 -9
- package/dist/api/events.d.ts +0 -2
- package/dist/api/events.d.ts.map +0 -1
- package/dist/api/events.js +0 -2
- package/dist/api/events.js.map +0 -1
- package/dist/dara_core-1.26.13-py3-none-any.whl +0 -0
|
@@ -43108,122 +43108,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
43108
43108
|
}
|
|
43109
43109
|
var cloneDeepExports = requireCloneDeep();
|
|
43110
43110
|
const copy = /* @__PURE__ */ getDefaultExportFromCjs(cloneDeepExports);
|
|
43111
|
-
const SESSION_STATE_CHANNEL_NAME = "dara-session-state";
|
|
43112
|
-
const SESSION_REFRESH_LOCK_NAME = "dara-auth-refresh-lock";
|
|
43113
|
-
const SessionStateMessageSchema = discriminatedUnion("type", [
|
|
43114
|
-
object$3({
|
|
43115
|
-
type: literal("session_id"),
|
|
43116
|
-
value: string().nullable()
|
|
43117
|
-
}),
|
|
43118
|
-
object$3({
|
|
43119
|
-
type: literal("session_logged_out")
|
|
43120
|
-
})
|
|
43121
|
-
]);
|
|
43122
|
-
const sessionIdSubscribers = /* @__PURE__ */ new Set();
|
|
43123
|
-
let sessionIdentifier = null;
|
|
43124
|
-
let activeRefreshPromise = null;
|
|
43125
|
-
const channel = typeof BroadcastChannel !== "undefined" ? new BroadcastChannel(SESSION_STATE_CHANNEL_NAME) : null;
|
|
43126
|
-
const inTabLockTails = /* @__PURE__ */ new Map();
|
|
43127
|
-
function notifySessionIdSubscribers(value) {
|
|
43128
|
-
sessionIdSubscribers.forEach((cb) => cb(value));
|
|
43129
|
-
}
|
|
43130
|
-
function parseSessionStateMessage(value) {
|
|
43131
|
-
const parsed = SessionStateMessageSchema.safeParse(value);
|
|
43132
|
-
if (!parsed.success) {
|
|
43133
|
-
return null;
|
|
43134
|
-
}
|
|
43135
|
-
return parsed.data;
|
|
43136
|
-
}
|
|
43137
|
-
function setSessionIdentifierInternal(value, broadcast) {
|
|
43138
|
-
if (sessionIdentifier === value) {
|
|
43139
|
-
return;
|
|
43140
|
-
}
|
|
43141
|
-
sessionIdentifier = value;
|
|
43142
|
-
notifySessionIdSubscribers(value);
|
|
43143
|
-
if (broadcast && channel) {
|
|
43144
|
-
channel.postMessage({ type: "session_id", value });
|
|
43145
|
-
}
|
|
43146
|
-
}
|
|
43147
|
-
if (channel) {
|
|
43148
|
-
channel.addEventListener("message", (event) => {
|
|
43149
|
-
const message = parseSessionStateMessage(event.data);
|
|
43150
|
-
if (!message) {
|
|
43151
|
-
return;
|
|
43152
|
-
}
|
|
43153
|
-
if (message.type === "session_logged_out") {
|
|
43154
|
-
setSessionIdentifierInternal(null, false);
|
|
43155
|
-
return;
|
|
43156
|
-
}
|
|
43157
|
-
setSessionIdentifierInternal(message.value, false);
|
|
43158
|
-
});
|
|
43159
|
-
}
|
|
43160
|
-
function withInTabRefreshLock(callback) {
|
|
43161
|
-
const previousTail = inTabLockTails.get(SESSION_REFRESH_LOCK_NAME) ?? Promise.resolve();
|
|
43162
|
-
let releaseTail = () => void 0;
|
|
43163
|
-
const nextTail = new Promise((resolve) => {
|
|
43164
|
-
releaseTail = resolve;
|
|
43165
|
-
});
|
|
43166
|
-
inTabLockTails.set(
|
|
43167
|
-
SESSION_REFRESH_LOCK_NAME,
|
|
43168
|
-
previousTail.then(() => nextTail)
|
|
43169
|
-
);
|
|
43170
|
-
return previousTail.then(async () => {
|
|
43171
|
-
try {
|
|
43172
|
-
return await callback();
|
|
43173
|
-
} finally {
|
|
43174
|
-
releaseTail();
|
|
43175
|
-
if (inTabLockTails.get(SESSION_REFRESH_LOCK_NAME) === nextTail) {
|
|
43176
|
-
inTabLockTails.delete(SESSION_REFRESH_LOCK_NAME);
|
|
43177
|
-
}
|
|
43178
|
-
}
|
|
43179
|
-
});
|
|
43180
|
-
}
|
|
43181
|
-
function requestRefreshLock(callback) {
|
|
43182
|
-
if (typeof navigator !== "undefined" && navigator.locks?.request) {
|
|
43183
|
-
return navigator.locks.request(SESSION_REFRESH_LOCK_NAME, () => callback()).then((result) => Promise.resolve(result));
|
|
43184
|
-
}
|
|
43185
|
-
return withInTabRefreshLock(callback);
|
|
43186
|
-
}
|
|
43187
|
-
function notifySessionLoggedOut() {
|
|
43188
|
-
setSessionIdentifierInternal(null, true);
|
|
43189
|
-
if (channel) {
|
|
43190
|
-
channel.postMessage({ type: "session_logged_out" });
|
|
43191
|
-
}
|
|
43192
|
-
}
|
|
43193
|
-
function onSessionIdChange(cb) {
|
|
43194
|
-
sessionIdSubscribers.add(cb);
|
|
43195
|
-
return () => {
|
|
43196
|
-
sessionIdSubscribers.delete(cb);
|
|
43197
|
-
};
|
|
43198
|
-
}
|
|
43199
|
-
function getSessionIdentifier() {
|
|
43200
|
-
return sessionIdentifier;
|
|
43201
|
-
}
|
|
43202
|
-
function setSessionIdentifier(sessionId) {
|
|
43203
|
-
setSessionIdentifierInternal(sessionId, true);
|
|
43204
|
-
}
|
|
43205
|
-
function useSessionIdentifier() {
|
|
43206
|
-
return React__namespace.useSyncExternalStore(onSessionIdChange, getSessionIdentifier);
|
|
43207
|
-
}
|
|
43208
|
-
async function withSessionRefreshLock(callback) {
|
|
43209
|
-
return requestRefreshLock(callback);
|
|
43210
|
-
}
|
|
43211
|
-
async function waitForOngoingSessionRefresh() {
|
|
43212
|
-
await requestRefreshLock(() => void 0);
|
|
43213
|
-
}
|
|
43214
|
-
function runSessionRefresh(refreshFn) {
|
|
43215
|
-
if (activeRefreshPromise) {
|
|
43216
|
-
return activeRefreshPromise;
|
|
43217
|
-
}
|
|
43218
|
-
const refreshPromise = withSessionRefreshLock(refreshFn).finally(() => {
|
|
43219
|
-
if (activeRefreshPromise === refreshPromise) {
|
|
43220
|
-
activeRefreshPromise = null;
|
|
43221
|
-
}
|
|
43222
|
-
});
|
|
43223
|
-
activeRefreshPromise = refreshPromise;
|
|
43224
|
-
return refreshPromise;
|
|
43225
|
-
}
|
|
43226
|
-
const SESSION_REFRESHED_EVENT = "dara:session-refreshed";
|
|
43227
43111
|
class RequestExtrasSerializable {
|
|
43228
43112
|
constructor(extras) {
|
|
43229
43113
|
this.extras = extras;
|
|
@@ -43258,7 +43142,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
43258
43142
|
}
|
|
43259
43143
|
}
|
|
43260
43144
|
async function request(url, ...options) {
|
|
43261
|
-
await waitForOngoingSessionRefresh();
|
|
43262
43145
|
const mergedOptions = options.reduce((acc, opt) => ({ ...acc, ...opt }), {});
|
|
43263
43146
|
const { headers, credentials: mergedCredentials, ...other } = mergedOptions;
|
|
43264
43147
|
const credentials = mergedCredentials ?? "include";
|
|
@@ -43271,39 +43154,11 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
43271
43154
|
}
|
|
43272
43155
|
const baseUrl = window.dara?.base_url ?? "";
|
|
43273
43156
|
const urlString = url instanceof URL ? url.pathname + url.search : url;
|
|
43274
|
-
|
|
43157
|
+
return fetch(baseUrl + urlString, {
|
|
43275
43158
|
credentials,
|
|
43276
43159
|
headers: headersInterface,
|
|
43277
43160
|
...other
|
|
43278
43161
|
});
|
|
43279
|
-
if (response.status === 401) {
|
|
43280
|
-
try {
|
|
43281
|
-
await runSessionRefresh(async () => {
|
|
43282
|
-
const refreshHeaders = new Headers({ Accept: "application/json" });
|
|
43283
|
-
const refreshResponse = await fetch(`${baseUrl}/api/auth/refresh-token`, {
|
|
43284
|
-
credentials,
|
|
43285
|
-
headers: refreshHeaders,
|
|
43286
|
-
method: "POST"
|
|
43287
|
-
});
|
|
43288
|
-
if (refreshResponse.ok) {
|
|
43289
|
-
window.dispatchEvent(new Event(SESSION_REFRESHED_EVENT));
|
|
43290
|
-
return;
|
|
43291
|
-
}
|
|
43292
|
-
notifySessionLoggedOut();
|
|
43293
|
-
await validateResponse(refreshResponse, "Request auth error, failed to refresh the session token");
|
|
43294
|
-
throw new Error("Request auth error, failed to refresh the session token");
|
|
43295
|
-
});
|
|
43296
|
-
return fetch(baseUrl + urlString, {
|
|
43297
|
-
credentials,
|
|
43298
|
-
headers: headersInterface,
|
|
43299
|
-
...other
|
|
43300
|
-
});
|
|
43301
|
-
} catch (e2) {
|
|
43302
|
-
console.error("Failed to refresh token", e2);
|
|
43303
|
-
return response;
|
|
43304
|
-
}
|
|
43305
|
-
}
|
|
43306
|
-
return response;
|
|
43307
43162
|
}
|
|
43308
43163
|
const requestExtrasCtx = React$1.createContext({ options: {} });
|
|
43309
43164
|
function useRequestExtras() {
|
|
@@ -50401,6 +50256,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50401
50256
|
#visibilityResumeHandler;
|
|
50402
50257
|
#resumeListenersAttached;
|
|
50403
50258
|
#authVerificationPromise;
|
|
50259
|
+
#authVerificationReconnectUsed;
|
|
50404
50260
|
constructor(_socketUrl, _liveReload = false) {
|
|
50405
50261
|
this.liveReload = _liveReload;
|
|
50406
50262
|
this.messages$ = new Subject();
|
|
@@ -50415,6 +50271,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50415
50271
|
this.#visibilityResumeHandler = this.onVisibilityResumeSignal.bind(this);
|
|
50416
50272
|
this.#resumeListenersAttached = false;
|
|
50417
50273
|
this.#authVerificationPromise = null;
|
|
50274
|
+
this.#authVerificationReconnectUsed = false;
|
|
50418
50275
|
this.channel = Promise.resolve("");
|
|
50419
50276
|
this.socket = this.initialize();
|
|
50420
50277
|
}
|
|
@@ -50442,6 +50299,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50442
50299
|
receivedInit = true;
|
|
50443
50300
|
this.#reconnectCount = 0;
|
|
50444
50301
|
this.maxAttemptsReached = false;
|
|
50302
|
+
this.#authVerificationReconnectUsed = false;
|
|
50445
50303
|
this.removeReconnectResumeListeners();
|
|
50446
50304
|
this.messages$.next(msg);
|
|
50447
50305
|
socket.removeEventListener("message", handler);
|
|
@@ -50473,7 +50331,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50473
50331
|
});
|
|
50474
50332
|
if (!response.ok) {
|
|
50475
50333
|
await handleAuthErrors(response);
|
|
50334
|
+
return;
|
|
50476
50335
|
}
|
|
50336
|
+
this.resumeAfterSuccessfulAuthVerification();
|
|
50477
50337
|
} catch {
|
|
50478
50338
|
} finally {
|
|
50479
50339
|
this.#authVerificationPromise = null;
|
|
@@ -50481,6 +50341,12 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50481
50341
|
})();
|
|
50482
50342
|
return this.#authVerificationPromise;
|
|
50483
50343
|
}
|
|
50344
|
+
resumeAfterSuccessfulAuthVerification() {
|
|
50345
|
+
if (this.#authVerificationReconnectUsed) {
|
|
50346
|
+
return;
|
|
50347
|
+
}
|
|
50348
|
+
this.resumeReconnectBurst(true);
|
|
50349
|
+
}
|
|
50484
50350
|
addReconnectResumeListeners() {
|
|
50485
50351
|
if (this.#resumeListenersAttached) {
|
|
50486
50352
|
return;
|
|
@@ -50488,7 +50354,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50488
50354
|
document.addEventListener("visibilitychange", this.#visibilityResumeHandler);
|
|
50489
50355
|
window.addEventListener("focus", this.#resumeSignalHandler);
|
|
50490
50356
|
window.addEventListener("online", this.#resumeSignalHandler);
|
|
50491
|
-
window.addEventListener(SESSION_REFRESHED_EVENT, this.#resumeSignalHandler);
|
|
50492
50357
|
this.#resumeListenersAttached = true;
|
|
50493
50358
|
}
|
|
50494
50359
|
removeReconnectResumeListeners() {
|
|
@@ -50498,15 +50363,15 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50498
50363
|
document.removeEventListener("visibilitychange", this.#visibilityResumeHandler);
|
|
50499
50364
|
window.removeEventListener("focus", this.#resumeSignalHandler);
|
|
50500
50365
|
window.removeEventListener("online", this.#resumeSignalHandler);
|
|
50501
|
-
window.removeEventListener(SESSION_REFRESHED_EVENT, this.#resumeSignalHandler);
|
|
50502
50366
|
this.#resumeListenersAttached = false;
|
|
50503
50367
|
}
|
|
50504
|
-
resumeReconnectBurst() {
|
|
50368
|
+
resumeReconnectBurst(authVerificationReconnectUsed = false) {
|
|
50505
50369
|
if (!this.maxAttemptsReached) {
|
|
50506
50370
|
return;
|
|
50507
50371
|
}
|
|
50508
50372
|
this.#reconnectCount = 0;
|
|
50509
50373
|
this.maxAttemptsReached = false;
|
|
50374
|
+
this.#authVerificationReconnectUsed = authVerificationReconnectUsed;
|
|
50510
50375
|
this.removeReconnectResumeListeners();
|
|
50511
50376
|
this.socket = this.initialize(true);
|
|
50512
50377
|
}
|
|
@@ -50843,6 +50708,82 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50843
50708
|
function isCondition(value) {
|
|
50844
50709
|
return value && typeof value === "object" && value.__typename === "Condition";
|
|
50845
50710
|
}
|
|
50711
|
+
const SESSION_STATE_CHANNEL_NAME = "dara-session-state";
|
|
50712
|
+
const SessionStateMessageSchema = discriminatedUnion("type", [
|
|
50713
|
+
object$3({
|
|
50714
|
+
type: literal("session_id"),
|
|
50715
|
+
value: string().nullable()
|
|
50716
|
+
}),
|
|
50717
|
+
object$3({
|
|
50718
|
+
type: literal("session_logged_out")
|
|
50719
|
+
})
|
|
50720
|
+
]);
|
|
50721
|
+
const sessionIdSubscribers = /* @__PURE__ */ new Set();
|
|
50722
|
+
let sessionIdentifier = null;
|
|
50723
|
+
const channel = typeof BroadcastChannel !== "undefined" ? new BroadcastChannel(SESSION_STATE_CHANNEL_NAME) : null;
|
|
50724
|
+
function notifySessionIdSubscribers(value) {
|
|
50725
|
+
sessionIdSubscribers.forEach((cb) => cb(value));
|
|
50726
|
+
}
|
|
50727
|
+
function parseSessionStateMessage(value) {
|
|
50728
|
+
const parsed = SessionStateMessageSchema.safeParse(value);
|
|
50729
|
+
if (!parsed.success) {
|
|
50730
|
+
return null;
|
|
50731
|
+
}
|
|
50732
|
+
return parsed.data;
|
|
50733
|
+
}
|
|
50734
|
+
function setSessionIdentifierInternal(value, broadcast) {
|
|
50735
|
+
if (sessionIdentifier === value) {
|
|
50736
|
+
return;
|
|
50737
|
+
}
|
|
50738
|
+
sessionIdentifier = value;
|
|
50739
|
+
notifySessionIdSubscribers(value);
|
|
50740
|
+
if (broadcast && channel) {
|
|
50741
|
+
channel.postMessage({ type: "session_id", value });
|
|
50742
|
+
}
|
|
50743
|
+
}
|
|
50744
|
+
if (channel) {
|
|
50745
|
+
channel.addEventListener("message", (event) => {
|
|
50746
|
+
const message = parseSessionStateMessage(event.data);
|
|
50747
|
+
if (!message) {
|
|
50748
|
+
return;
|
|
50749
|
+
}
|
|
50750
|
+
if (message.type === "session_logged_out") {
|
|
50751
|
+
setSessionIdentifierInternal(null, false);
|
|
50752
|
+
return;
|
|
50753
|
+
}
|
|
50754
|
+
setSessionIdentifierInternal(message.value, false);
|
|
50755
|
+
});
|
|
50756
|
+
}
|
|
50757
|
+
function notifySessionLoggedOut() {
|
|
50758
|
+
setSessionIdentifierInternal(null, true);
|
|
50759
|
+
if (channel) {
|
|
50760
|
+
channel.postMessage({ type: "session_logged_out" });
|
|
50761
|
+
}
|
|
50762
|
+
}
|
|
50763
|
+
function onSessionIdChange(cb) {
|
|
50764
|
+
sessionIdSubscribers.add(cb);
|
|
50765
|
+
return () => {
|
|
50766
|
+
sessionIdSubscribers.delete(cb);
|
|
50767
|
+
};
|
|
50768
|
+
}
|
|
50769
|
+
function getSessionIdentifier() {
|
|
50770
|
+
return sessionIdentifier;
|
|
50771
|
+
}
|
|
50772
|
+
function setSessionIdentifier(sessionId) {
|
|
50773
|
+
setSessionIdentifierInternal(sessionId, true);
|
|
50774
|
+
}
|
|
50775
|
+
function useSessionIdentifier() {
|
|
50776
|
+
return React__namespace.useSyncExternalStore(onSessionIdChange, getSessionIdentifier);
|
|
50777
|
+
}
|
|
50778
|
+
var AuthenticationErrorReason = /* @__PURE__ */ ((AuthenticationErrorReason2) => {
|
|
50779
|
+
AuthenticationErrorReason2["BAD_REQUEST"] = "bad_request";
|
|
50780
|
+
AuthenticationErrorReason2["EXPIRED_TOKEN"] = "expired";
|
|
50781
|
+
AuthenticationErrorReason2["INVALID_CREDENTIALS"] = "invalid_credentials";
|
|
50782
|
+
AuthenticationErrorReason2["INVALID_TOKEN"] = "invalid_token";
|
|
50783
|
+
AuthenticationErrorReason2["OTHER"] = "other";
|
|
50784
|
+
AuthenticationErrorReason2["UNAUTHORIZED"] = "unauthorized";
|
|
50785
|
+
return AuthenticationErrorReason2;
|
|
50786
|
+
})(AuthenticationErrorReason || {});
|
|
50846
50787
|
const AuthenticationErrorSchema = object$3({
|
|
50847
50788
|
message: string(),
|
|
50848
50789
|
reason: _enum([
|
|
@@ -50863,9 +50804,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50863
50804
|
return parsed.data;
|
|
50864
50805
|
}
|
|
50865
50806
|
function shouldIgnoreError(message, ignoreErrors) {
|
|
50866
|
-
return ignoreErrors
|
|
50807
|
+
return ignoreErrors.includes(message.reason);
|
|
50867
50808
|
}
|
|
50868
|
-
function
|
|
50809
|
+
function isAuthenticationFailure(message) {
|
|
50869
50810
|
return [
|
|
50870
50811
|
"invalid_credentials",
|
|
50871
50812
|
"expired",
|
|
@@ -50873,6 +50814,12 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50873
50814
|
/* INVALID_TOKEN */
|
|
50874
50815
|
].includes(message.reason);
|
|
50875
50816
|
}
|
|
50817
|
+
function getAuthErrorRedirect(message, authenticationFailureRedirect) {
|
|
50818
|
+
if (isAuthenticationFailure(message)) {
|
|
50819
|
+
return authenticationFailureRedirect;
|
|
50820
|
+
}
|
|
50821
|
+
return "error";
|
|
50822
|
+
}
|
|
50876
50823
|
async function revokeSession() {
|
|
50877
50824
|
try {
|
|
50878
50825
|
const response = await request("/api/auth/revoke-session", {
|
|
@@ -50899,17 +50846,21 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50899
50846
|
}
|
|
50900
50847
|
return encodeURIComponent(strippedReferrer + window.location.search);
|
|
50901
50848
|
}
|
|
50902
|
-
async function handleAuthErrors(res,
|
|
50849
|
+
async function handleAuthErrors(res, options = {}) {
|
|
50850
|
+
const { authenticationFailureRedirect = "login", ignoreErrors = [] } = options;
|
|
50903
50851
|
if (res.status >= 500 || res.status < 400) {
|
|
50904
50852
|
return false;
|
|
50905
50853
|
}
|
|
50906
50854
|
const content = await res.clone().json();
|
|
50907
50855
|
const authError = parseAuthenticationError(content?.detail);
|
|
50908
|
-
if (authError && !shouldIgnoreError(authError, ignoreErrors
|
|
50909
|
-
notifySessionLoggedOut();
|
|
50856
|
+
if (authError && !shouldIgnoreError(authError, ignoreErrors)) {
|
|
50910
50857
|
const queryParams = new URLSearchParams(window.location.search);
|
|
50911
50858
|
const referrer = queryParams.get("referrer") ?? resolveReferrer();
|
|
50912
|
-
const
|
|
50859
|
+
const redirect2 = getAuthErrorRedirect(authError, authenticationFailureRedirect);
|
|
50860
|
+
const path = redirect2 === "login" ? `/login?referrer=${referrer}` : `/error?code=${res.status}`;
|
|
50861
|
+
if (redirect2 === "login") {
|
|
50862
|
+
notifySessionLoggedOut();
|
|
50863
|
+
}
|
|
50913
50864
|
window.location.href = `${window.dara.base_url}${path}`;
|
|
50914
50865
|
return true;
|
|
50915
50866
|
}
|
|
@@ -50933,10 +50884,12 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50933
50884
|
body: JSON.stringify(body),
|
|
50934
50885
|
method: HTTP_METHOD.POST
|
|
50935
50886
|
});
|
|
50936
|
-
const loggedOut = await handleAuthErrors(res,
|
|
50937
|
-
|
|
50938
|
-
|
|
50939
|
-
|
|
50887
|
+
const loggedOut = await handleAuthErrors(res, {
|
|
50888
|
+
ignoreErrors: [
|
|
50889
|
+
"invalid_credentials"
|
|
50890
|
+
/* INVALID_CREDENTIALS */
|
|
50891
|
+
]
|
|
50892
|
+
});
|
|
50940
50893
|
if (loggedOut) {
|
|
50941
50894
|
return false;
|
|
50942
50895
|
}
|
|
@@ -50957,8 +50910,19 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50957
50910
|
method: HTTP_METHOD.POST
|
|
50958
50911
|
});
|
|
50959
50912
|
if (!res.ok) {
|
|
50913
|
+
const handled = await handleAuthErrors(res, {
|
|
50914
|
+
ignoreErrors: [
|
|
50915
|
+
"expired",
|
|
50916
|
+
"invalid_credentials",
|
|
50917
|
+
"invalid_token"
|
|
50918
|
+
/* INVALID_TOKEN */
|
|
50919
|
+
]
|
|
50920
|
+
});
|
|
50921
|
+
if (handled) {
|
|
50922
|
+
return "handled_auth_error";
|
|
50923
|
+
}
|
|
50960
50924
|
setSessionIdentifier(null);
|
|
50961
|
-
return
|
|
50925
|
+
return "login_required";
|
|
50962
50926
|
}
|
|
50963
50927
|
try {
|
|
50964
50928
|
const sessionId = await res.json();
|
|
@@ -50966,11 +50930,11 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50966
50930
|
} catch {
|
|
50967
50931
|
setSessionIdentifier(null);
|
|
50968
50932
|
}
|
|
50969
|
-
return
|
|
50933
|
+
return "verified";
|
|
50970
50934
|
}
|
|
50971
50935
|
async function fetchTaskResult(taskId, extras) {
|
|
50972
50936
|
const res = await request(`/api/core/tasks/${taskId}`, { method: HTTP_METHOD.GET }, extras);
|
|
50973
|
-
await handleAuthErrors(res,
|
|
50937
|
+
await handleAuthErrors(res, { authenticationFailureRedirect: "login" });
|
|
50974
50938
|
if (res.status === 404) {
|
|
50975
50939
|
return { status: "not_found" };
|
|
50976
50940
|
}
|
|
@@ -50983,7 +50947,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50983
50947
|
}
|
|
50984
50948
|
async function cancelTask(taskId, extras) {
|
|
50985
50949
|
const res = await request(`/api/core/tasks/${taskId}`, { method: HTTP_METHOD.DELETE }, extras);
|
|
50986
|
-
await handleAuthErrors(res,
|
|
50950
|
+
await handleAuthErrors(res, { authenticationFailureRedirect: "login" });
|
|
50987
50951
|
await validateResponse(res, `Failed to cancel task with id: ${taskId}`);
|
|
50988
50952
|
return true;
|
|
50989
50953
|
}
|
|
@@ -64879,7 +64843,7 @@ ${String(error)}`;
|
|
|
64879
64843
|
ws_channel: await wsClient.getChannel()
|
|
64880
64844
|
};
|
|
64881
64845
|
const response = await request(url, { body: JSON.stringify(body), method: HTTP_METHOD.POST }, extras);
|
|
64882
|
-
await handleAuthErrors(response,
|
|
64846
|
+
await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
64883
64847
|
await validateTabularResponse(variable.uid, response);
|
|
64884
64848
|
await validateResponse(response, "Failed to fetch tabular data");
|
|
64885
64849
|
return response.json();
|
|
@@ -64907,7 +64871,7 @@ ${String(error)}`;
|
|
|
64907
64871
|
dv_values: normalizeRequest(cleanArgs(dvResult.values), variable.variables)
|
|
64908
64872
|
};
|
|
64909
64873
|
const response = await request(url, { body: JSON.stringify(body), method: HTTP_METHOD.POST }, extras);
|
|
64910
|
-
await handleAuthErrors(response,
|
|
64874
|
+
await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
64911
64875
|
await validateTabularResponse(variable.uid, response);
|
|
64912
64876
|
await validateResponse(response, "Failed to fetch tabular data");
|
|
64913
64877
|
const responseJson = await response.json();
|
|
@@ -69587,7 +69551,7 @@ ${String(error)}`;
|
|
|
69587
69551
|
`/api/core/server-variable/${itemKey}/sequence`,
|
|
69588
69552
|
serializableExtras?.extras ?? {}
|
|
69589
69553
|
);
|
|
69590
|
-
await handleAuthErrors(response,
|
|
69554
|
+
await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
69591
69555
|
await validateResponse(response, `Failed to fetch the sequence number for key: ${itemKey}`);
|
|
69592
69556
|
const { sequence_number } = await response.json();
|
|
69593
69557
|
return sequence_number;
|
|
@@ -69802,7 +69766,7 @@ ${String(error)}`;
|
|
|
69802
69766
|
},
|
|
69803
69767
|
extras
|
|
69804
69768
|
);
|
|
69805
|
-
await handleAuthErrors(res,
|
|
69769
|
+
await handleAuthErrors(res, { authenticationFailureRedirect: "login" });
|
|
69806
69770
|
await validateResponse(res, `Failed to fetch the derived variable with uid: ${variableUid}`);
|
|
69807
69771
|
return res.json();
|
|
69808
69772
|
}
|
|
@@ -71364,6 +71328,10 @@ ${String(error)}`;
|
|
|
71364
71328
|
retryCount = 0;
|
|
71365
71329
|
return;
|
|
71366
71330
|
}
|
|
71331
|
+
const handledAuthError = await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
71332
|
+
if (handledAuthError) {
|
|
71333
|
+
controller.abort();
|
|
71334
|
+
}
|
|
71367
71335
|
const error = new Error(`Stream request failed: ${response.status} ${response.statusText}`);
|
|
71368
71336
|
throw error;
|
|
71369
71337
|
},
|
|
@@ -73293,7 +73261,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
73293
73261
|
},
|
|
73294
73262
|
actionCtx.extras
|
|
73295
73263
|
);
|
|
73296
|
-
await handleAuthErrors(res,
|
|
73264
|
+
await handleAuthErrors(res, { authenticationFailureRedirect: "login" });
|
|
73297
73265
|
await validateResponse(res, `Failed to fetch the action value with uid: ${annotatedAction.uid}`);
|
|
73298
73266
|
const resContent = await res.json();
|
|
73299
73267
|
if ("task_id" in resContent) {
|
|
@@ -73639,7 +73607,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
73639
73607
|
},
|
|
73640
73608
|
extras
|
|
73641
73609
|
);
|
|
73642
|
-
await handleAuthErrors(res,
|
|
73610
|
+
await handleAuthErrors(res, { authenticationFailureRedirect: "login" });
|
|
73643
73611
|
await validateResponse(res, `Failed to fetch the component: ${component}`);
|
|
73644
73612
|
const result = await res.json();
|
|
73645
73613
|
return result;
|
|
@@ -75412,7 +75380,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
75412
75380
|
}),
|
|
75413
75381
|
signal
|
|
75414
75382
|
});
|
|
75415
|
-
await handleAuthErrors(response,
|
|
75383
|
+
await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
75416
75384
|
if (!response.ok) {
|
|
75417
75385
|
const error = await response.json();
|
|
75418
75386
|
throw new LoaderError(error.detail);
|
|
@@ -75530,7 +75498,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
75530
75498
|
const getStoreValue = React__namespace.useCallback(async (itemKey) => {
|
|
75531
75499
|
const serializableExtras = STORE_EXTRAS_MAP.get(itemKey);
|
|
75532
75500
|
const response = await request(`/api/core/store/${itemKey}`, {}, serializableExtras?.extras ?? {});
|
|
75533
|
-
await handleAuthErrors(response,
|
|
75501
|
+
await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
75534
75502
|
await validateResponse(response, `Failed to fetch the store value for key: ${itemKey}`);
|
|
75535
75503
|
const { value, sequence_number } = await response.json();
|
|
75536
75504
|
STORE_LATEST_VALUE_MAP.set(itemKey, value);
|
|
@@ -75562,7 +75530,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
75562
75530
|
},
|
|
75563
75531
|
serializableExtras.extras
|
|
75564
75532
|
);
|
|
75565
|
-
await handleAuthErrors(response,
|
|
75533
|
+
await handleAuthErrors(response, { authenticationFailureRedirect: "login" });
|
|
75566
75534
|
await validateResponse(response, `Failed to sync the store values`);
|
|
75567
75535
|
}
|
|
75568
75536
|
await Promise.allSettled(
|
|
@@ -76241,10 +76209,10 @@ Inferred class string: "${iconClasses}."`
|
|
|
76241
76209
|
setIsLoggingIn(false);
|
|
76242
76210
|
};
|
|
76243
76211
|
React$1.useEffect(() => {
|
|
76244
|
-
verifySessionToken().then((
|
|
76245
|
-
if (verified) {
|
|
76212
|
+
verifySessionToken().then((verificationResult) => {
|
|
76213
|
+
if (verificationResult === "verified") {
|
|
76246
76214
|
navigate(decodeURIComponent(previousLocation), { replace: true });
|
|
76247
|
-
} else {
|
|
76215
|
+
} else if (verificationResult === "login_required") {
|
|
76248
76216
|
setIsVerifyingToken(false);
|
|
76249
76217
|
}
|
|
76250
76218
|
});
|
|
@@ -76317,10 +76285,10 @@ Inferred class string: "${iconClasses}."`
|
|
|
76317
76285
|
}
|
|
76318
76286
|
}
|
|
76319
76287
|
React$1.useEffect(() => {
|
|
76320
|
-
verifySessionToken().then((
|
|
76321
|
-
if (verified) {
|
|
76288
|
+
verifySessionToken().then((verificationResult) => {
|
|
76289
|
+
if (verificationResult === "verified") {
|
|
76322
76290
|
navigate(decodeURIComponent(previousLocation), { replace: true });
|
|
76323
|
-
} else {
|
|
76291
|
+
} else if (verificationResult === "login_required") {
|
|
76324
76292
|
getNewToken();
|
|
76325
76293
|
}
|
|
76326
76294
|
});
|
|
@@ -76342,7 +76310,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
76342
76310
|
}),
|
|
76343
76311
|
method: HTTP_METHOD.POST
|
|
76344
76312
|
});
|
|
76345
|
-
const loggedOut = await handleAuthErrors(res
|
|
76313
|
+
const loggedOut = await handleAuthErrors(res);
|
|
76346
76314
|
if (loggedOut) {
|
|
76347
76315
|
return;
|
|
76348
76316
|
}
|
|
@@ -76352,10 +76320,10 @@ Inferred class string: "${iconClasses}."`
|
|
|
76352
76320
|
}
|
|
76353
76321
|
}, [previousLocation]);
|
|
76354
76322
|
React$1.useEffect(() => {
|
|
76355
|
-
verifySessionToken().then((
|
|
76356
|
-
if (verified) {
|
|
76323
|
+
verifySessionToken().then((verificationResult) => {
|
|
76324
|
+
if (verificationResult === "verified") {
|
|
76357
76325
|
navigate(decodeURIComponent(previousLocation), { replace: true });
|
|
76358
|
-
} else {
|
|
76326
|
+
} else if (verificationResult === "login_required") {
|
|
76359
76327
|
getNewToken();
|
|
76360
76328
|
}
|
|
76361
76329
|
});
|
|
@@ -76390,7 +76358,9 @@ Inferred class string: "${iconClasses}."`
|
|
|
76390
76358
|
}),
|
|
76391
76359
|
method: HTTP_METHOD.POST
|
|
76392
76360
|
});
|
|
76393
|
-
const shouldLogOut = await handleAuthErrors(res
|
|
76361
|
+
const shouldLogOut = await handleAuthErrors(res, {
|
|
76362
|
+
authenticationFailureRedirect: "error"
|
|
76363
|
+
});
|
|
76394
76364
|
if (shouldLogOut) {
|
|
76395
76365
|
return null;
|
|
76396
76366
|
}
|
|
@@ -76858,10 +76828,14 @@ body,
|
|
|
76858
76828
|
if (verifiedToken) {
|
|
76859
76829
|
return;
|
|
76860
76830
|
}
|
|
76861
|
-
|
|
76831
|
+
const verificationResult = await verifySessionToken();
|
|
76832
|
+
if (verificationResult === "verified") {
|
|
76862
76833
|
verifiedToken = true;
|
|
76863
76834
|
return;
|
|
76864
76835
|
}
|
|
76836
|
+
if (verificationResult === "handled_auth_error") {
|
|
76837
|
+
return;
|
|
76838
|
+
}
|
|
76865
76839
|
const referrer = resolveReferrer();
|
|
76866
76840
|
const baseUrl = window.dara?.base_url ?? "";
|
|
76867
76841
|
const redirectUrl = new URL(`${baseUrl}/login`, window.location.origin);
|
|
@@ -100944,6 +100918,7 @@ body,
|
|
|
100944
100918
|
}
|
|
100945
100919
|
exports.ActionImpl = ActionImpl;
|
|
100946
100920
|
exports.AuthenticatedRoot = AuthenticatedRoot;
|
|
100921
|
+
exports.AuthenticationErrorReason = AuthenticationErrorReason;
|
|
100947
100922
|
exports.BasicAuthLogin = BasicAuthLogin;
|
|
100948
100923
|
exports.BasicAuthLogout = BasicAuthLogout;
|
|
100949
100924
|
exports.Center = Center;
|
|
@@ -101079,7 +101054,6 @@ body,
|
|
|
101079
101054
|
exports.resolveTheme = resolveTheme;
|
|
101080
101055
|
exports.resolveValue = resolveValue;
|
|
101081
101056
|
exports.revokeSession = revokeSession;
|
|
101082
|
-
exports.runSessionRefresh = runSessionRefresh;
|
|
101083
101057
|
exports.selectorFamilyMembersRegistry = selectorFamilyMembersRegistry;
|
|
101084
101058
|
exports.selectorFamilyRegistry = selectorFamilyRegistry;
|
|
101085
101059
|
exports.selectorRegistry = selectorRegistry;
|
|
@@ -101116,7 +101090,5 @@ body,
|
|
|
101116
101090
|
exports.useVariableState = useVariableState;
|
|
101117
101091
|
exports.useWindowTitle = useWindowTitle;
|
|
101118
101092
|
exports.verifySessionToken = verifySessionToken;
|
|
101119
|
-
exports.waitForOngoingSessionRefresh = waitForOngoingSessionRefresh;
|
|
101120
|
-
exports.withSessionRefreshLock = withSessionRefreshLock;
|
|
101121
101093
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
101122
101094
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darajs/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "Dara Framework core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.0",
|
|
40
40
|
"@babel/preset-react": "^7.22.15",
|
|
41
41
|
"@babel/preset-typescript": "^7.23.0",
|
|
42
|
-
"@darajs/eslint-config": "1.
|
|
43
|
-
"@darajs/prettier-config": "1.
|
|
44
|
-
"@darajs/stylelint-config": "1.
|
|
42
|
+
"@darajs/eslint-config": "1.27.0",
|
|
43
|
+
"@darajs/prettier-config": "1.27.0",
|
|
44
|
+
"@darajs/stylelint-config": "1.27.0",
|
|
45
45
|
"@testing-library/dom": "^9.3.0",
|
|
46
46
|
"@testing-library/jest-dom": "^6.0.0",
|
|
47
47
|
"@testing-library/react": "^14.0.0",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"whatwg-fetch": "^3.6.20"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@darajs/styled-components": "1.
|
|
77
|
-
"@darajs/ui-components": "1.
|
|
78
|
-
"@darajs/ui-notifications": "1.
|
|
79
|
-
"@darajs/ui-utils": "1.
|
|
76
|
+
"@darajs/styled-components": "1.27.0",
|
|
77
|
+
"@darajs/ui-components": "1.27.0",
|
|
78
|
+
"@darajs/ui-notifications": "1.27.0",
|
|
79
|
+
"@darajs/ui-utils": "1.27.0",
|
|
80
80
|
"@fortawesome/fontawesome-free": "~6.4.0",
|
|
81
81
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
82
82
|
"@recoiljs/refine": "^0.1.1",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"engines": {
|
|
118
118
|
"node": ">=20.19.0"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "af4cea7fcc9e49a3a48ed474d84bd7d599af811f"
|
|
121
121
|
}
|
package/dist/api/events.d.ts
DELETED
package/dist/api/events.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../js/api/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,2BAA2B,CAAC"}
|
package/dist/api/events.js
DELETED
package/dist/api/events.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../js/api/events.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC"}
|
|
Binary file
|