@burdenoff/fe-libs 2026.1010.3 → 2026.1011.2
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/chrome/ContextSwitcher.js +102 -101
- package/dist/chrome/contextSwitcher/OrganizationList.js +36 -25
- package/dist/chrome/contextSwitcher/organizationLabel.d.ts +4 -0
- package/dist/chrome/contextSwitcher/organizationLabel.js +13 -0
- package/dist/shared/graphql/fetch.d.ts +6 -0
- package/dist/shared/graphql/fetch.js +114 -104
- package/dist/shared/graphql/index.d.ts +1 -0
- package/dist/shared/graphql/prepareWorkspaceRequest.d.ts +15 -0
- package/dist/shared/graphql/prepareWorkspaceRequest.js +56 -0
- package/dist/shared/graphql/workspaceToken.d.ts +1 -0
- package/dist/shared/graphql/workspaceToken.js +1 -0
- package/dist/shared-graphql.js +4 -3
- package/dist/shared.js +112 -111
- package/package.json +2 -2
|
@@ -35,7 +35,7 @@ function x() {
|
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function S() {
|
|
39
39
|
try {
|
|
40
40
|
let e = sessionStorage.getItem("bf-active-profile");
|
|
41
41
|
if (!e) return !1;
|
|
@@ -45,7 +45,7 @@ function ee() {
|
|
|
45
45
|
return !1;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function C(e) {
|
|
49
49
|
try {
|
|
50
50
|
let [, t] = e.split(".");
|
|
51
51
|
if (!t || typeof globalThis.atob != "function") return null;
|
|
@@ -55,11 +55,11 @@ function S(e) {
|
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
let t =
|
|
58
|
+
function ee(e) {
|
|
59
|
+
let t = C(e)?.exp;
|
|
60
60
|
return typeof t == "number" ? t * 1e3 <= Date.now() + 3e4 : !1;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function te() {
|
|
63
63
|
try {
|
|
64
64
|
let e = sessionStorage.getItem("bf-active-profile");
|
|
65
65
|
if (e) {
|
|
@@ -72,7 +72,7 @@ function w() {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function w() {
|
|
76
76
|
try {
|
|
77
77
|
let e = sessionStorage.getItem("bf-active-profile");
|
|
78
78
|
if (e) {
|
|
@@ -84,41 +84,41 @@ function T() {
|
|
|
84
84
|
return "en";
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function T() {
|
|
88
88
|
return s("workspace");
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function E() {
|
|
91
91
|
return s("organization");
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function D() {
|
|
94
94
|
return s("tenant");
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function O() {
|
|
97
97
|
return s("project");
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function k() {
|
|
100
100
|
try {
|
|
101
101
|
return typeof window > "u" ? null : new URLSearchParams(window.location.search).get("org");
|
|
102
102
|
} catch {
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function A(e) {
|
|
107
107
|
return {
|
|
108
|
-
workspaceId: typeof e.workspaceId == "string" ? e.workspaceId :
|
|
109
|
-
organizationId: typeof e.organizationId == "string" ? e.organizationId :
|
|
110
|
-
tenantId: typeof e.tenantId == "string" ? e.tenantId :
|
|
111
|
-
projectId: typeof e.projectId == "string" ? e.projectId :
|
|
108
|
+
workspaceId: typeof e.workspaceId == "string" ? e.workspaceId : T() || void 0,
|
|
109
|
+
organizationId: typeof e.organizationId == "string" ? e.organizationId : E() || k() || void 0,
|
|
110
|
+
tenantId: typeof e.tenantId == "string" ? e.tenantId : D() || void 0,
|
|
111
|
+
projectId: typeof e.projectId == "string" ? e.projectId : O() || void 0
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function j(e, t, n) {
|
|
115
115
|
try {
|
|
116
116
|
let r = a() ?? x();
|
|
117
117
|
if (!r) return;
|
|
118
118
|
o(r, t), sessionStorage.setItem("burdenoff-active-context-workspace", e), n && sessionStorage.setItem("burdenoff-active-context-organization", n);
|
|
119
119
|
} catch {}
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function M(e, t, n) {
|
|
122
122
|
return t ? t.aborted ? Promise.resolve(n) : new Promise((r) => {
|
|
123
123
|
let i = () => r(n);
|
|
124
124
|
t.addEventListener("abort", i, { once: !0 }), e.then(r, () => r(n)).finally(() => {
|
|
@@ -126,20 +126,29 @@ function N(e, t, n) {
|
|
|
126
126
|
});
|
|
127
127
|
}) : e;
|
|
128
128
|
}
|
|
129
|
-
async function
|
|
130
|
-
let { url: t, authToken: n, workspaceId: r, organizationId: i, projectId: a, locale: o, signal: s, currentQuery: c } = e;
|
|
131
|
-
if (!n || c.includes("issueWorkspaceToken")) return null;
|
|
132
|
-
let
|
|
133
|
-
if (!
|
|
134
|
-
let
|
|
135
|
-
if (
|
|
136
|
-
workspaceId:
|
|
137
|
-
organizationId:
|
|
129
|
+
async function N(e) {
|
|
130
|
+
let { url: t, authToken: n, workspaceId: r, organizationId: i, projectId: a, locale: o, signal: s, currentQuery: c, issuanceGuard: l } = e;
|
|
131
|
+
if (!n || c.includes("issueWorkspaceToken") || l && !l.isCurrent()) return null;
|
|
132
|
+
let u = r || T();
|
|
133
|
+
if (!u) return null;
|
|
134
|
+
let d = b(), p = T(), m = i || E() || k();
|
|
135
|
+
if (d && p === u && f(d, {
|
|
136
|
+
workspaceId: u,
|
|
137
|
+
organizationId: m,
|
|
138
138
|
projectId: a
|
|
139
|
-
})) return
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
}) && (!l || l.accepts(d, u))) return d;
|
|
140
|
+
let h = JSON.stringify([
|
|
141
|
+
m ?? "",
|
|
142
|
+
u,
|
|
143
|
+
a ?? "",
|
|
144
|
+
l ? [
|
|
145
|
+
t,
|
|
146
|
+
n,
|
|
147
|
+
l.identityKey
|
|
148
|
+
] : null
|
|
149
|
+
]), g = v.get(h);
|
|
150
|
+
if (g) return M(g, s, null);
|
|
151
|
+
let y = fetch(t, {
|
|
143
152
|
method: "POST",
|
|
144
153
|
headers: {
|
|
145
154
|
"Content-Type": "application/json",
|
|
@@ -150,55 +159,56 @@ async function P(e) {
|
|
|
150
159
|
body: JSON.stringify({
|
|
151
160
|
query: _,
|
|
152
161
|
variables: { input: {
|
|
153
|
-
workspaceId:
|
|
154
|
-
...
|
|
162
|
+
workspaceId: u,
|
|
163
|
+
...m ? { organizationId: m } : {},
|
|
155
164
|
...a ? { projectId: a } : {}
|
|
156
165
|
} }
|
|
157
166
|
})
|
|
158
167
|
}).then(async (e) => {
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
if (l && !e.ok) return null;
|
|
169
|
+
let t = await e.json(), n = t.data?.issueWorkspaceToken;
|
|
170
|
+
return l && (t.errors !== void 0 && (!Array.isArray(t.errors) || t.errors.length !== 0) || n?.success !== !0 || typeof n.token != "string" || n.token.length === 0 || n.workspaceId !== u) ? null : n?.success && n.token ? l && (!l.isCurrent() || !l.accepts(n.token, n.workspaceId || u)) ? null : (j(n.workspaceId || u, n.token, m ?? void 0), n.token) : null;
|
|
161
171
|
}).catch(() => null).finally(() => {
|
|
162
|
-
v.delete(
|
|
172
|
+
v.delete(h);
|
|
163
173
|
});
|
|
164
|
-
return v.set(
|
|
174
|
+
return v.set(h, y), M(y, s, null);
|
|
165
175
|
}
|
|
166
|
-
function
|
|
176
|
+
function P(e, n) {
|
|
167
177
|
let i = r[e], a = t(), o = e === "global" ? a.globalBaseUrl : a.workspaceBaseUrl, s = n || o;
|
|
168
178
|
return `${s.endsWith("/") ? s.slice(0, -1) : s}${i.graphql}`;
|
|
169
179
|
}
|
|
170
|
-
function
|
|
180
|
+
function F(e) {
|
|
171
181
|
return e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
172
182
|
}
|
|
173
|
-
function
|
|
174
|
-
if (e?.aborted) throw
|
|
183
|
+
function I(e) {
|
|
184
|
+
if (e?.aborted) throw F(e);
|
|
175
185
|
}
|
|
176
|
-
function
|
|
186
|
+
function L() {
|
|
177
187
|
return globalThis;
|
|
178
188
|
}
|
|
179
|
-
function
|
|
180
|
-
let e =
|
|
189
|
+
function R() {
|
|
190
|
+
let e = L();
|
|
181
191
|
return e.__graphqlFetchQueues ||= /* @__PURE__ */ new Map(), e.__graphqlFetchQueues;
|
|
182
192
|
}
|
|
183
|
-
function
|
|
184
|
-
let e =
|
|
193
|
+
function z() {
|
|
194
|
+
let e = L();
|
|
185
195
|
return e.__graphqlFetchResponseCache ||= /* @__PURE__ */ new Map(), e.__graphqlFetchResponseCache;
|
|
186
196
|
}
|
|
187
|
-
function
|
|
188
|
-
let e =
|
|
197
|
+
function B() {
|
|
198
|
+
let e = L();
|
|
189
199
|
return e.__graphqlFetchPendingResponses ||= /* @__PURE__ */ new Map(), e.__graphqlFetchPendingResponses;
|
|
190
200
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
201
|
+
function V() {
|
|
202
|
+
z().clear(), B().clear(), n();
|
|
193
203
|
}
|
|
194
|
-
var
|
|
204
|
+
var H = 10, ne = 600, U = 100, re = 1e4, W = 15e3, ie = new Set([
|
|
195
205
|
"traceparent",
|
|
196
206
|
"tracestate",
|
|
197
207
|
"baggage"
|
|
198
208
|
]), G = "Apollo-Require-Preflight";
|
|
199
209
|
function ae() {
|
|
200
210
|
if (typeof performance > "u") return U;
|
|
201
|
-
let e =
|
|
211
|
+
let e = L();
|
|
202
212
|
return e.__graphqlFetchBurstStartedAt ??= performance.now(), performance.now() - e.__graphqlFetchBurstStartedAt < re ? ne : U;
|
|
203
213
|
}
|
|
204
214
|
function oe(e) {
|
|
@@ -258,7 +268,7 @@ async function X(e, t, n) {
|
|
|
258
268
|
...r.keepalive ? { keepalive: !0 } : {}
|
|
259
269
|
}), i = await Y(n);
|
|
260
270
|
if (!n.ok && !q(i)) throw Error(J(n));
|
|
261
|
-
r.cacheKey && !q(i) &&
|
|
271
|
+
r.cacheKey && !q(i) && z().set(r.cacheKey, {
|
|
262
272
|
value: i,
|
|
263
273
|
expiresAt: Date.now() + W
|
|
264
274
|
}), r.resolve(i);
|
|
@@ -278,7 +288,7 @@ async function X(e, t, n) {
|
|
|
278
288
|
if (!i.ok && !q(a)) throw Error(J(i));
|
|
279
289
|
if (Array.isArray(a)) a.forEach((e, t) => {
|
|
280
290
|
let r = n[t];
|
|
281
|
-
r && (r.cacheKey && !q(e) &&
|
|
291
|
+
r && (r.cacheKey && !q(e) && z().set(r.cacheKey, {
|
|
282
292
|
value: e,
|
|
283
293
|
expiresAt: Date.now() + W
|
|
284
294
|
}), r.resolve(e));
|
|
@@ -292,15 +302,15 @@ async function X(e, t, n) {
|
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
304
|
function Z(e, t, n, r, i) {
|
|
295
|
-
let a = ce(t), o = i?.keepalive === !0, s = o ? 1 : Math.max(1, i?.batchMax ??
|
|
296
|
-
if (r?.aborted) return Promise.reject(
|
|
305
|
+
let a = ce(t), o = i?.keepalive === !0, s = o ? 1 : Math.max(1, i?.batchMax ?? H), c = Math.max(0, i?.batchInterval ?? ae()), l = `${e}|${JSON.stringify(a)}`, u = oe(n) ? `${l}|${JSON.stringify(se(n))}` : void 0;
|
|
306
|
+
if (r?.aborted) return Promise.reject(F(r));
|
|
297
307
|
if (u) {
|
|
298
|
-
let e =
|
|
308
|
+
let e = z(), t = e.get(u);
|
|
299
309
|
if (t) {
|
|
300
310
|
if (t.expiresAt > Date.now()) return Promise.resolve(t.value);
|
|
301
311
|
e.delete(u);
|
|
302
312
|
}
|
|
303
|
-
let n =
|
|
313
|
+
let n = B().get(u);
|
|
304
314
|
if (n) return n;
|
|
305
315
|
}
|
|
306
316
|
let d = new Promise((t, i) => {
|
|
@@ -315,7 +325,7 @@ function Z(e, t, n, r, i) {
|
|
|
315
325
|
}]);
|
|
316
326
|
return;
|
|
317
327
|
}
|
|
318
|
-
let d =
|
|
328
|
+
let d = R(), f = d.get(l);
|
|
319
329
|
f || (f = {
|
|
320
330
|
requests: [],
|
|
321
331
|
timer: null,
|
|
@@ -330,82 +340,82 @@ function Z(e, t, n, r, i) {
|
|
|
330
340
|
cacheKey: u
|
|
331
341
|
};
|
|
332
342
|
if (f.requests.push(p), r && r.addEventListener("abort", () => {
|
|
333
|
-
let e =
|
|
334
|
-
e && t >= 0 && (e.requests.splice(t, 1), e.requests.length === 0 && (e.timer && clearTimeout(e.timer),
|
|
343
|
+
let e = R().get(l), t = e ? e.requests.indexOf(p) : -1;
|
|
344
|
+
e && t >= 0 && (e.requests.splice(t, 1), e.requests.length === 0 && (e.timer && clearTimeout(e.timer), R().delete(l))), i(F(r));
|
|
335
345
|
}, { once: !0 }), f.requests.length >= f.batchMax) {
|
|
336
346
|
Q(e, a, l);
|
|
337
347
|
return;
|
|
338
348
|
}
|
|
339
349
|
f.timer ||= setTimeout(() => Q(e, a, l), f.batchInterval);
|
|
340
350
|
});
|
|
341
|
-
return u && !r && (
|
|
342
|
-
|
|
351
|
+
return u && !r && (B().set(u, d), d.finally(() => {
|
|
352
|
+
B().delete(u);
|
|
343
353
|
}).catch(() => {})), d;
|
|
344
354
|
}
|
|
345
355
|
function Q(e, t, n) {
|
|
346
|
-
let r =
|
|
356
|
+
let r = R(), i = r.get(n);
|
|
347
357
|
i && (r.delete(n), i.timer &&= (clearTimeout(i.timer), null), X(e, t, i.requests));
|
|
348
358
|
}
|
|
349
359
|
async function $(e) {
|
|
350
|
-
let { gateway: n, query: r, variables: i, operationName: a, authToken: o, workspaceToken: s, workspaceId: c, organizationId: u, tenantId: h, projectId: _, locale: v, baseUrl: x, extraHeaders:
|
|
351
|
-
|
|
352
|
-
let
|
|
353
|
-
if (!
|
|
360
|
+
let { gateway: n, query: r, variables: i, operationName: a, authToken: o, workspaceToken: s, workspaceId: c, organizationId: u, tenantId: h, projectId: _, locale: v, baseUrl: x, extraHeaders: C, signal: T, suppressGlobalErrorEvent: E, keepalive: O } = e;
|
|
361
|
+
I(T);
|
|
362
|
+
let k = d(P(n, x)), j = o && !ee(o) ? o : y();
|
|
363
|
+
if (!j && !e.skipAuthRetry && typeof window < "u" && !window.location.pathname.startsWith("/auth/") && S()) {
|
|
354
364
|
let e = await import("../utils/authErrorHandling.js");
|
|
355
365
|
await e.attemptTokenRefresh({
|
|
356
366
|
globalBaseUrl: n === "global" && x ? x : t().globalBaseUrl,
|
|
357
367
|
...e.getSharedTokenRefreshRefs()
|
|
358
|
-
}) ?
|
|
368
|
+
}) ? j = y() : g({
|
|
359
369
|
operationName: a,
|
|
360
370
|
gateway: n
|
|
361
|
-
}),
|
|
371
|
+
}), I(T);
|
|
362
372
|
}
|
|
363
|
-
let
|
|
373
|
+
let M = v ?? w(), F = A({
|
|
364
374
|
workspaceId: c,
|
|
365
375
|
organizationId: u,
|
|
366
376
|
tenantId: h,
|
|
367
377
|
projectId: _
|
|
368
|
-
}),
|
|
378
|
+
}), L = {
|
|
369
379
|
"Content-Type": "application/json",
|
|
370
380
|
[G]: "true"
|
|
371
381
|
};
|
|
372
|
-
|
|
373
|
-
let
|
|
374
|
-
if (
|
|
382
|
+
j && (L.Authorization = `Bearer ${j}`), M && (L["Accept-Language"] = M);
|
|
383
|
+
let R = te();
|
|
384
|
+
if (R?.country && (L["X-Geo-Country"] = R.country), R?.currency && (L["X-Geo-Currency"] = R.currency), R?.timezone && (L["X-Geo-Timezone"] = R.timezone), n === "workspace" ? s !== !1 : s) {
|
|
375
385
|
let e = typeof s == "string" ? s : b();
|
|
376
|
-
e && !f(e,
|
|
377
|
-
url:
|
|
378
|
-
authToken:
|
|
379
|
-
workspaceId:
|
|
380
|
-
organizationId:
|
|
381
|
-
projectId:
|
|
382
|
-
locale:
|
|
383
|
-
signal:
|
|
386
|
+
e && !f(e, F) && (e = null), !e && (s === !0 || n === "workspace" && s === void 0 || typeof s == "string") && (e = await N({
|
|
387
|
+
url: k,
|
|
388
|
+
authToken: j,
|
|
389
|
+
workspaceId: F.workspaceId,
|
|
390
|
+
organizationId: F.organizationId,
|
|
391
|
+
projectId: F.projectId,
|
|
392
|
+
locale: M,
|
|
393
|
+
signal: T,
|
|
384
394
|
currentQuery: r
|
|
385
|
-
}),
|
|
395
|
+
}), I(T)), e && (L["X-Workspace-Authorization"] = `Bearer ${e}`);
|
|
386
396
|
}
|
|
387
397
|
if (n === "workspace" || c) {
|
|
388
|
-
let e =
|
|
389
|
-
e && (
|
|
398
|
+
let e = F.workspaceId;
|
|
399
|
+
e && (L["x-workspace-id"] = e);
|
|
390
400
|
}
|
|
391
401
|
if (n === "global" || u) {
|
|
392
|
-
let e =
|
|
393
|
-
e && (
|
|
402
|
+
let e = F.organizationId;
|
|
403
|
+
e && (L["x-org-id"] = e);
|
|
394
404
|
}
|
|
395
405
|
if (h) {
|
|
396
|
-
let e = typeof h == "string" ? h :
|
|
397
|
-
e && (
|
|
406
|
+
let e = typeof h == "string" ? h : D();
|
|
407
|
+
e && (L["x-tenant-id"] = e);
|
|
398
408
|
}
|
|
399
409
|
if (n === "workspace" || _) {
|
|
400
|
-
let e =
|
|
401
|
-
e && (
|
|
410
|
+
let e = F.projectId;
|
|
411
|
+
e && (L["x-project-id"] = e);
|
|
402
412
|
}
|
|
403
|
-
let
|
|
404
|
-
|
|
405
|
-
let
|
|
406
|
-
i && (
|
|
407
|
-
let
|
|
408
|
-
if (e.skipAuthRetry || !
|
|
413
|
+
let z = l(C);
|
|
414
|
+
z && Object.assign(L, z);
|
|
415
|
+
let B = { query: r };
|
|
416
|
+
i && (B.variables = i), a && (B.operationName = a);
|
|
417
|
+
let V = async (r) => {
|
|
418
|
+
if (e.skipAuthRetry || !j || typeof window > "u" || !r?.length) return null;
|
|
409
419
|
let i = await import("../utils/authErrorHandling.js");
|
|
410
420
|
return i.hasAuthGraphQLErrors(r) ? await i.attemptTokenRefresh({
|
|
411
421
|
globalBaseUrl: n === "global" && x ? x : t().globalBaseUrl,
|
|
@@ -421,24 +431,24 @@ async function $(e) {
|
|
|
421
431
|
}), null) : null;
|
|
422
432
|
};
|
|
423
433
|
try {
|
|
424
|
-
let e = await Z(
|
|
434
|
+
let e = await Z(k, L, B, T, O ? { keepalive: !0 } : void 0);
|
|
425
435
|
if (m(), e.errors?.length) {
|
|
426
|
-
let t = await
|
|
436
|
+
let t = await V(e.errors);
|
|
427
437
|
if (t) return t;
|
|
428
|
-
|
|
438
|
+
E || p({ errors: e.errors }, { operationName: a });
|
|
429
439
|
}
|
|
430
440
|
return e;
|
|
431
441
|
} catch (e) {
|
|
432
442
|
let t = e.errors;
|
|
433
443
|
if (t?.length) {
|
|
434
|
-
let e = await
|
|
444
|
+
let e = await V(t);
|
|
435
445
|
if (e) return e;
|
|
436
446
|
}
|
|
437
|
-
throw
|
|
447
|
+
throw E || p(e, {
|
|
438
448
|
operationName: a,
|
|
439
449
|
fallbackMessage: "We could not reach the server. Please check your connection and try again."
|
|
440
450
|
}), e;
|
|
441
451
|
}
|
|
442
452
|
}
|
|
443
453
|
//#endregion
|
|
444
|
-
export { h as SESSION_EXPIRED_EVENT,
|
|
454
|
+
export { h as SESSION_EXPIRED_EVENT, V as clearGraphqlFetchResponseCache, Z as enqueueGraphQLFetch, N as ensureWorkspaceToken, y as getStoredAuthToken, w as getStoredLocale, E as getStoredOrganizationId, O as getStoredProjectId, D as getStoredTenantId, T as getStoredWorkspaceId, b as getStoredWorkspaceToken, $ as graphqlFetch, P as resolveGatewayUrl };
|
|
@@ -8,3 +8,4 @@ export { WsLink, type WsLinkOptions } from './links/ws-link';
|
|
|
8
8
|
export { ApolloClient, InMemoryCache, type NormalizedCacheObject } from '@apollo/client/core';
|
|
9
9
|
export { ApolloProvider, useQuery, useMutation, useLazyQuery, useSubscription, useApolloClient, } from '@apollo/client/react';
|
|
10
10
|
export { gql } from '@apollo/client/core';
|
|
11
|
+
export { prepareWorkspaceRequest, type WorkspaceRequestIntent } from './prepareWorkspaceRequest';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface WorkspaceRequestIntent {
|
|
2
|
+
url: string;
|
|
3
|
+
authToken: string;
|
|
4
|
+
actorId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
tenantId?: string;
|
|
7
|
+
workspaceToken?: string;
|
|
8
|
+
currentQuery: string;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/** Immutable authority check for transports that must not replay mutations. */
|
|
12
|
+
export declare function prepareWorkspaceRequest(intent: WorkspaceRequestIntent): Promise<{
|
|
13
|
+
workspaceToken: string;
|
|
14
|
+
assertCurrent(): void;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getActiveProfileId as e, getActiveUser as t } from "../providers/shell/ProfileStorageManager.js";
|
|
2
|
+
import { validateGatewayBaseUrl as n } from "./security.js";
|
|
3
|
+
import { getWorkspaceTokenPayload as r, isWorkspaceTokenValidForContext as i } from "./workspaceToken.js";
|
|
4
|
+
import { ensureWorkspaceToken as a, getStoredAuthToken as o, getStoredOrganizationId as s, getStoredProjectId as c, getStoredTenantId as l, getStoredWorkspaceId as u, getStoredWorkspaceToken as d } from "./fetch.js";
|
|
5
|
+
//#region src/shared/graphql/prepareWorkspaceRequest.ts
|
|
6
|
+
async function f(f) {
|
|
7
|
+
let p = {
|
|
8
|
+
...f,
|
|
9
|
+
url: n(f.url)
|
|
10
|
+
};
|
|
11
|
+
if (p.signal?.aborted) throw new DOMException("The operation was aborted.", "AbortError");
|
|
12
|
+
let m = () => ({
|
|
13
|
+
profileId: e(),
|
|
14
|
+
authToken: o(),
|
|
15
|
+
actorId: t()?.id,
|
|
16
|
+
workspaceId: u(),
|
|
17
|
+
organizationId: s(),
|
|
18
|
+
tenantId: l(),
|
|
19
|
+
projectId: c()
|
|
20
|
+
}), h = m(), g = JSON.stringify(h), _ = () => JSON.stringify(m()) === g, v = () => {
|
|
21
|
+
if (!_()) throw Error("The active account or workspace changed. Review the action again.");
|
|
22
|
+
};
|
|
23
|
+
if (!h.profileId || !p.authToken || !p.actorId || !p.workspaceId || h.authToken !== p.authToken || h.actorId !== p.actorId || h.workspaceId !== p.workspaceId || (h.tenantId ?? void 0) !== p.tenantId) throw Error("The active account or workspace changed. Review the action again.");
|
|
24
|
+
let y = {
|
|
25
|
+
workspaceId: p.workspaceId,
|
|
26
|
+
organizationId: h.organizationId,
|
|
27
|
+
tenantId: h.tenantId,
|
|
28
|
+
projectId: h.projectId
|
|
29
|
+
}, b = (e, t) => {
|
|
30
|
+
let n = r(e);
|
|
31
|
+
return t === p.workspaceId && n !== null && n.tokenType === "WORKSPACE_ACCESS" && n.sub === p.actorId && typeof n.exp == "number" && Number.isFinite(n.exp) && n.exp * 1e3 > Date.now() + 3e4 && n.workspaceId === y.workspaceId && (n.organizationId ?? null) === y.organizationId && (n.tenantId ?? null) === y.tenantId && (n.projectId ?? null) === y.projectId && i(e, y);
|
|
32
|
+
}, x = d(), S = x && b(x, p.workspaceId) ? x : p.workspaceToken;
|
|
33
|
+
if ((!S || !b(S, p.workspaceId)) && (v(), S = await a({
|
|
34
|
+
url: p.url,
|
|
35
|
+
authToken: p.authToken,
|
|
36
|
+
workspaceId: p.workspaceId,
|
|
37
|
+
organizationId: h.organizationId ?? void 0,
|
|
38
|
+
projectId: h.projectId ?? void 0,
|
|
39
|
+
signal: p.signal,
|
|
40
|
+
currentQuery: p.currentQuery,
|
|
41
|
+
issuanceGuard: {
|
|
42
|
+
identityKey: g,
|
|
43
|
+
isCurrent: _,
|
|
44
|
+
accepts: b
|
|
45
|
+
}
|
|
46
|
+
}) ?? void 0), v(), !S || !b(S, p.workspaceId)) throw Error("Unable to renew workspace authority. No action was sent.");
|
|
47
|
+
let C = S;
|
|
48
|
+
return {
|
|
49
|
+
workspaceToken: C,
|
|
50
|
+
assertCurrent: () => {
|
|
51
|
+
if (v(), !b(C, p.workspaceId)) throw Error("Workspace authority expired. Review the action again.");
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { f as prepareWorkspaceRequest };
|
package/dist/shared-graphql.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createGraphQLClient as f, getGlobalClient as p, getWorkspaceClient as m
|
|
|
5
5
|
import { GatewayProvider as _, useGateway as v, useGatewayClient as y, useSafeGateway as b, useSafeGatewayClient as x } from "./shared/graphql/GatewayContext.js";
|
|
6
6
|
import { useHasAuthToken as S } from "./shared/graphql/useHasAuthToken.js";
|
|
7
7
|
import { WsLink as C } from "./shared/graphql/links/ws-link.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
8
|
+
import { prepareWorkspaceRequest as w } from "./shared/graphql/prepareWorkspaceRequest.js";
|
|
9
|
+
import { ApolloClient as T, InMemoryCache as E, gql as D } from "@apollo/client/core";
|
|
10
|
+
import { ApolloProvider as O, useApolloClient as k, useLazyQuery as A, useMutation as j, useQuery as M, useSubscription as N } from "@apollo/client/react";
|
|
11
|
+
export { T as ApolloClient, O as ApolloProvider, _ as GatewayProvider, E as InMemoryCache, d as SSELink, C as WsLink, n as clearGraphqlFetchResponseCache, f as createGraphQLClient, p as getGlobalClient, r as getStoredAuthToken, i as getStoredLocale, a as getStoredOrganizationId, o as getStoredProjectId, s as getStoredWorkspaceId, c as getStoredWorkspaceToken, m as getWorkspaceClient, e as getWorkspaceTokenPayload, D as gql, l as graphqlFetch, h as initializeAppClients, t as isWorkspaceTokenValidForContext, w as prepareWorkspaceRequest, g as resetAppClients, u as resolveGatewayUrl, k as useApolloClient, v as useGateway, y as useGatewayClient, S as useHasAuthToken, A as useLazyQuery, j as useMutation, M as useQuery, b as useSafeGateway, x as useSafeGatewayClient, N as useSubscription };
|