@burdenoff/fe-libs 2026.611.1 → 2026.616.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/shared/graphql/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAY,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/shared/graphql/fetch.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
import { createBrowserTraceContext as e } from "../events/metadata.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { resolveGatewayUrls as t } from "../config/gatewayUrls.js";
|
|
3
|
+
import { GATEWAYS as n } from "../../shared-config.js";
|
|
4
|
+
import { getActiveWorkspaceToken as r, resolveActiveProfileId as i, setProfileWorkspaceToken as a } from "../providers/shell/ProfileStorageManager.js";
|
|
5
|
+
import { readActiveContextValueWithUrlPrecedence as o } from "../providers/shell/ActiveContextStorage.js";
|
|
6
|
+
import { getValidAccessTokenFromStorage as s, sanitizeExtraHeaders as c, sanitizeGeography as l, validateGatewayBaseUrl as u } from "./security.js";
|
|
7
|
+
import { isWorkspaceTokenValidForContext as d } from "./workspaceToken.js";
|
|
8
|
+
import { dispatchBackendErrorEvent as f, markConnectionHealthy as p } from "../utils/backendErrors.js";
|
|
8
9
|
//#region src/shared/graphql/fetch.ts
|
|
9
|
-
var
|
|
10
|
-
function
|
|
10
|
+
var m = "\n mutation IssueWorkspaceToken($input: IssueWorkspaceTokenInput!) {\n issueWorkspaceToken(input: $input) {\n success\n token\n workspaceId\n error {\n message\n }\n }\n }\n", h = /* @__PURE__ */ new Map();
|
|
11
|
+
function g() {
|
|
11
12
|
try {
|
|
12
13
|
let e = sessionStorage.getItem("bf-active-profile");
|
|
13
|
-
return e ?
|
|
14
|
+
return e ? s(localStorage.getItem(`bf-p-${e}-tokens`)) : null;
|
|
14
15
|
} catch {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function _() {
|
|
19
20
|
try {
|
|
20
|
-
return
|
|
21
|
+
return r();
|
|
21
22
|
} catch {
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function v() {
|
|
26
27
|
try {
|
|
27
28
|
return sessionStorage.getItem("bf-active-profile");
|
|
28
29
|
} catch {
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function y(e) {
|
|
33
34
|
try {
|
|
34
35
|
let [, t] = e.split(".");
|
|
35
36
|
if (!t || typeof globalThis.atob != "function") return null;
|
|
@@ -39,24 +40,24 @@ function v(e) {
|
|
|
39
40
|
return null;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
let t =
|
|
43
|
+
function b(e) {
|
|
44
|
+
let t = y(e)?.exp;
|
|
44
45
|
return typeof t == "number" ? t * 1e3 <= Date.now() + 3e4 : !1;
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
+
function x() {
|
|
47
48
|
try {
|
|
48
49
|
let e = sessionStorage.getItem("bf-active-profile");
|
|
49
50
|
if (e) {
|
|
50
51
|
let t = localStorage.getItem(`bf-p-${e}-geography`);
|
|
51
|
-
if (t) return
|
|
52
|
+
if (t) return l(JSON.parse(t));
|
|
52
53
|
}
|
|
53
54
|
let t = localStorage.getItem("burdenoff-geography");
|
|
54
|
-
return t ?
|
|
55
|
+
return t ? l(JSON.parse(t)) : null;
|
|
55
56
|
} catch {
|
|
56
57
|
return null;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function S() {
|
|
60
61
|
try {
|
|
61
62
|
let e = sessionStorage.getItem("bf-active-profile");
|
|
62
63
|
if (e) {
|
|
@@ -68,53 +69,53 @@ function x() {
|
|
|
68
69
|
return "en";
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
function S() {
|
|
72
|
-
return a("workspace");
|
|
73
|
-
}
|
|
74
72
|
function C() {
|
|
75
|
-
return
|
|
73
|
+
return o("workspace");
|
|
76
74
|
}
|
|
77
75
|
function w() {
|
|
78
|
-
return
|
|
76
|
+
return o("organization");
|
|
79
77
|
}
|
|
80
78
|
function T() {
|
|
81
|
-
return
|
|
79
|
+
return o("tenant");
|
|
82
80
|
}
|
|
83
81
|
function E() {
|
|
82
|
+
return o("project");
|
|
83
|
+
}
|
|
84
|
+
function D() {
|
|
84
85
|
try {
|
|
85
86
|
return typeof window > "u" ? null : new URLSearchParams(window.location.search).get("org");
|
|
86
87
|
} catch {
|
|
87
88
|
return null;
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
+
function O(e) {
|
|
91
92
|
return {
|
|
92
|
-
workspaceId: typeof e.workspaceId == "string" ? e.workspaceId :
|
|
93
|
-
organizationId: typeof e.organizationId == "string" ? e.organizationId :
|
|
94
|
-
tenantId: typeof e.tenantId == "string" ? e.tenantId :
|
|
95
|
-
projectId: typeof e.projectId == "string" ? e.projectId :
|
|
93
|
+
workspaceId: typeof e.workspaceId == "string" ? e.workspaceId : C() || void 0,
|
|
94
|
+
organizationId: typeof e.organizationId == "string" ? e.organizationId : w() || D() || void 0,
|
|
95
|
+
tenantId: typeof e.tenantId == "string" ? e.tenantId : T() || void 0,
|
|
96
|
+
projectId: typeof e.projectId == "string" ? e.projectId : E() || void 0
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
+
function k(e, t, n) {
|
|
99
100
|
try {
|
|
100
|
-
let
|
|
101
|
-
if (!
|
|
102
|
-
|
|
101
|
+
let r = i() ?? v();
|
|
102
|
+
if (!r) return;
|
|
103
|
+
a(r, t), sessionStorage.setItem("burdenoff-active-context-workspace", e), n && sessionStorage.setItem("burdenoff-active-context-organization", n);
|
|
103
104
|
} catch {}
|
|
104
105
|
}
|
|
105
|
-
async function
|
|
106
|
+
async function A(e) {
|
|
106
107
|
let { url: t, authToken: n, workspaceId: r, organizationId: i, projectId: a, locale: o, signal: s, currentQuery: c } = e;
|
|
107
108
|
if (!n || c.includes("issueWorkspaceToken")) return null;
|
|
108
|
-
let l = r ||
|
|
109
|
+
let l = r || C();
|
|
109
110
|
if (!l) return null;
|
|
110
|
-
let
|
|
111
|
-
if (
|
|
111
|
+
let u = _(), f = C(), p = i || w() || D();
|
|
112
|
+
if (u && f === l && d(u, {
|
|
112
113
|
workspaceId: l,
|
|
113
|
-
organizationId:
|
|
114
|
+
organizationId: p,
|
|
114
115
|
projectId: a
|
|
115
|
-
})) return
|
|
116
|
-
if (!
|
|
117
|
-
let
|
|
116
|
+
})) return u;
|
|
117
|
+
if (!p) return null;
|
|
118
|
+
let g = `${p}:${l}:${a ?? ""}`, v = h.get(g);
|
|
118
119
|
if (v) return v;
|
|
119
120
|
let y = fetch(t, {
|
|
120
121
|
method: "POST",
|
|
@@ -124,9 +125,9 @@ async function k(e) {
|
|
|
124
125
|
...o ? { "Accept-Language": o } : {}
|
|
125
126
|
},
|
|
126
127
|
body: JSON.stringify({
|
|
127
|
-
query:
|
|
128
|
+
query: m,
|
|
128
129
|
variables: { input: {
|
|
129
|
-
organizationId:
|
|
130
|
+
organizationId: p,
|
|
130
131
|
workspaceId: l,
|
|
131
132
|
...a ? { projectId: a } : {}
|
|
132
133
|
} }
|
|
@@ -134,76 +135,76 @@ async function k(e) {
|
|
|
134
135
|
signal: s
|
|
135
136
|
}).then(async (e) => {
|
|
136
137
|
let t = (await e.json()).data?.issueWorkspaceToken;
|
|
137
|
-
return t?.success && t.token ? (
|
|
138
|
+
return t?.success && t.token ? (k(t.workspaceId || l, t.token, p), t.token) : null;
|
|
138
139
|
}).catch(() => null).finally(() => {
|
|
139
|
-
|
|
140
|
+
h.delete(g);
|
|
140
141
|
});
|
|
141
|
-
return
|
|
142
|
+
return h.set(g, y), y;
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
-
let
|
|
145
|
-
return `${
|
|
144
|
+
function j(e, r) {
|
|
145
|
+
let i = n[e], a = t(), o = e === "global" ? a.globalBaseUrl : a.workspaceBaseUrl, s = r || o;
|
|
146
|
+
return `${s.endsWith("/") ? s.slice(0, -1) : s}${i.graphql}`;
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
+
function M() {
|
|
148
149
|
return globalThis;
|
|
149
150
|
}
|
|
150
|
-
function
|
|
151
|
-
let e =
|
|
151
|
+
function N() {
|
|
152
|
+
let e = M();
|
|
152
153
|
return e.__graphqlFetchQueues ||= /* @__PURE__ */ new Map(), e.__graphqlFetchQueues;
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
-
let e =
|
|
155
|
+
function P() {
|
|
156
|
+
let e = M();
|
|
156
157
|
return e.__graphqlFetchResponseCache ||= /* @__PURE__ */ new Map(), e.__graphqlFetchResponseCache;
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
-
let e =
|
|
159
|
+
function F() {
|
|
160
|
+
let e = M();
|
|
160
161
|
return e.__graphqlFetchPendingResponses ||= /* @__PURE__ */ new Map(), e.__graphqlFetchPendingResponses;
|
|
161
162
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
163
|
+
function I() {
|
|
164
|
+
P().clear(), F().clear();
|
|
164
165
|
}
|
|
165
|
-
var
|
|
166
|
+
var L = 10, R = 600, z = 100, B = 1e4, V = 15e3, H = new Set([
|
|
166
167
|
"traceparent",
|
|
167
168
|
"tracestate",
|
|
168
169
|
"baggage"
|
|
169
170
|
]);
|
|
170
|
-
function
|
|
171
|
-
if (typeof performance > "u") return
|
|
172
|
-
let e =
|
|
173
|
-
return e.__graphqlFetchBurstStartedAt ??= performance.now(), performance.now() - e.__graphqlFetchBurstStartedAt <
|
|
171
|
+
function U() {
|
|
172
|
+
if (typeof performance > "u") return z;
|
|
173
|
+
let e = M();
|
|
174
|
+
return e.__graphqlFetchBurstStartedAt ??= performance.now(), performance.now() - e.__graphqlFetchBurstStartedAt < B ? R : z;
|
|
174
175
|
}
|
|
175
|
-
function
|
|
176
|
+
function W(e) {
|
|
176
177
|
return typeof e.query == "string" ? /^\s*query\b/.test(e.query) : !1;
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
+
function G(e) {
|
|
179
180
|
return typeof e.operationName == "string" && e.operationName.length > 0 ? {
|
|
180
181
|
operationName: e.operationName,
|
|
181
182
|
variables: e.variables ?? null
|
|
182
183
|
} : e;
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
+
function K(e) {
|
|
185
186
|
let t = /* @__PURE__ */ new Map();
|
|
186
187
|
for (let [n, r] of Object.entries(e)) {
|
|
187
188
|
let e = n.toLowerCase();
|
|
188
|
-
|
|
189
|
+
H.has(e) || t.set(e, r);
|
|
189
190
|
}
|
|
190
191
|
return Object.fromEntries(Array.from(t.entries()).sort(([e], [t]) => e.localeCompare(t)));
|
|
191
192
|
}
|
|
192
|
-
function
|
|
193
|
+
function q(t) {
|
|
193
194
|
let n = e();
|
|
194
195
|
return {
|
|
195
196
|
...t,
|
|
196
197
|
traceparent: n.traceparent
|
|
197
198
|
};
|
|
198
199
|
}
|
|
199
|
-
function q(e) {
|
|
200
|
-
return Y(e) && Array.isArray(e.errors);
|
|
201
|
-
}
|
|
202
200
|
function J(e) {
|
|
201
|
+
return ee(e) && Array.isArray(e.errors);
|
|
202
|
+
}
|
|
203
|
+
function Y(e) {
|
|
203
204
|
let t = e.status;
|
|
204
205
|
return t === 401 ? "Invalid email or password." : t === 403 ? "You do not have permission to do that." : t === 404 ? "We could not find what you were looking for." : t === 408 || t === 504 ? "The server took too long to respond. Please try again." : t === 429 ? "Too many requests. Please wait a moment and try again." : t >= 500 && t < 600 ? "The server is having trouble right now. Please try again in a moment." : t >= 400 && t < 500 ? "The request could not be processed. Please refresh and try again." : "We could not reach the server. Please check your connection and try again.";
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function ee(e) {
|
|
207
208
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
208
209
|
}
|
|
209
210
|
async function X(e) {
|
|
@@ -221,15 +222,15 @@ async function Z(e, t, n) {
|
|
|
221
222
|
try {
|
|
222
223
|
let n = await fetch(e, {
|
|
223
224
|
method: "POST",
|
|
224
|
-
headers:
|
|
225
|
+
headers: q(t),
|
|
225
226
|
credentials: "include",
|
|
226
227
|
body: JSON.stringify(r.body),
|
|
227
228
|
signal: r.signal
|
|
228
229
|
}), i = await X(n);
|
|
229
|
-
if (!n.ok && !
|
|
230
|
-
r.cacheKey &&
|
|
230
|
+
if (!n.ok && !J(i)) throw Error(Y(n));
|
|
231
|
+
r.cacheKey && P().set(r.cacheKey, {
|
|
231
232
|
value: i,
|
|
232
|
-
expiresAt: Date.now() +
|
|
233
|
+
expiresAt: Date.now() + V
|
|
233
234
|
}), r.resolve(i);
|
|
234
235
|
} catch (e) {
|
|
235
236
|
r.reject(e);
|
|
@@ -240,21 +241,21 @@ async function Z(e, t, n) {
|
|
|
240
241
|
try {
|
|
241
242
|
let i = await fetch(e, {
|
|
242
243
|
method: "POST",
|
|
243
|
-
headers:
|
|
244
|
+
headers: q(t),
|
|
244
245
|
credentials: "include",
|
|
245
246
|
body: JSON.stringify(r)
|
|
246
247
|
}), a = await X(i);
|
|
247
|
-
if (!i.ok && !
|
|
248
|
+
if (!i.ok && !J(a)) throw Error(Y(i));
|
|
248
249
|
Array.isArray(a) ? a.forEach((e, t) => {
|
|
249
250
|
let r = n[t];
|
|
250
|
-
r && (r.cacheKey &&
|
|
251
|
+
r && (r.cacheKey && P().set(r.cacheKey, {
|
|
251
252
|
value: e,
|
|
252
|
-
expiresAt: Date.now() +
|
|
253
|
+
expiresAt: Date.now() + V
|
|
253
254
|
}), r.resolve(e));
|
|
254
255
|
}) : n.forEach((e) => {
|
|
255
|
-
e.cacheKey &&
|
|
256
|
+
e.cacheKey && P().set(e.cacheKey, {
|
|
256
257
|
value: a,
|
|
257
|
-
expiresAt: Date.now() +
|
|
258
|
+
expiresAt: Date.now() + V
|
|
258
259
|
}), e.resolve(a);
|
|
259
260
|
});
|
|
260
261
|
} catch (e) {
|
|
@@ -262,14 +263,14 @@ async function Z(e, t, n) {
|
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
265
|
function Q(e, t, n, r, i) {
|
|
265
|
-
let a =
|
|
266
|
+
let a = K(t), o = Math.max(1, i?.batchMax ?? L), s = Math.max(0, i?.batchInterval ?? U()), c = `${e}|${JSON.stringify(a)}`, l = W(n) ? `${c}|${JSON.stringify(G(n))}` : void 0;
|
|
266
267
|
if (l) {
|
|
267
|
-
let e =
|
|
268
|
+
let e = P(), t = e.get(l);
|
|
268
269
|
if (t) {
|
|
269
270
|
if (t.expiresAt > Date.now()) return Promise.resolve(t.value);
|
|
270
271
|
e.delete(l);
|
|
271
272
|
}
|
|
272
|
-
let n =
|
|
273
|
+
let n = F().get(l);
|
|
273
274
|
if (n) return n;
|
|
274
275
|
}
|
|
275
276
|
let u = new Promise((t, i) => {
|
|
@@ -283,7 +284,7 @@ function Q(e, t, n, r, i) {
|
|
|
283
284
|
}]);
|
|
284
285
|
return;
|
|
285
286
|
}
|
|
286
|
-
let u =
|
|
287
|
+
let u = N(), d = u.get(c);
|
|
287
288
|
if (d || (d = {
|
|
288
289
|
requests: [],
|
|
289
290
|
timer: null,
|
|
@@ -301,65 +302,65 @@ function Q(e, t, n, r, i) {
|
|
|
301
302
|
}
|
|
302
303
|
d.timer ||= setTimeout(() => $(e, a, c), d.batchInterval);
|
|
303
304
|
});
|
|
304
|
-
return l && (
|
|
305
|
-
|
|
305
|
+
return l && (F().set(l, u), u.finally(() => {
|
|
306
|
+
F().delete(l);
|
|
306
307
|
}).catch(() => {})), u;
|
|
307
308
|
}
|
|
308
309
|
function $(e, t, n) {
|
|
309
|
-
let r =
|
|
310
|
+
let r = N(), i = r.get(n);
|
|
310
311
|
i && (r.delete(n), i.timer &&= (clearTimeout(i.timer), null), Z(e, t, i.requests));
|
|
311
312
|
}
|
|
312
|
-
async function
|
|
313
|
-
let { gateway: t, query: n, variables: r, operationName: i, authToken: a, workspaceToken: o, workspaceId:
|
|
314
|
-
workspaceId:
|
|
315
|
-
organizationId:
|
|
313
|
+
async function te(e) {
|
|
314
|
+
let { gateway: t, query: n, variables: r, operationName: i, authToken: a, workspaceToken: o, workspaceId: s, organizationId: l, tenantId: m, projectId: h, locale: v, baseUrl: y, extraHeaders: C, signal: w, suppressGlobalErrorEvent: E } = e, D = u(j(t, y)), k = a && !b(a) ? a : g(), M = v ?? S(), N = O({
|
|
315
|
+
workspaceId: s,
|
|
316
|
+
organizationId: l,
|
|
316
317
|
tenantId: m,
|
|
317
|
-
projectId:
|
|
318
|
+
projectId: h
|
|
318
319
|
}), P = { "Content-Type": "application/json" };
|
|
319
|
-
|
|
320
|
-
let F =
|
|
320
|
+
k && (P.Authorization = `Bearer ${k}`), M && (P["Accept-Language"] = M);
|
|
321
|
+
let F = x();
|
|
321
322
|
if (F?.country && (P["X-Geo-Country"] = F.country), F?.currency && (P["X-Geo-Currency"] = F.currency), F?.timezone && (P["X-Geo-Timezone"] = F.timezone), t === "workspace" ? o !== !1 : o) {
|
|
322
|
-
let e = typeof o == "string" ? o :
|
|
323
|
-
e && !
|
|
324
|
-
url:
|
|
325
|
-
authToken:
|
|
323
|
+
let e = typeof o == "string" ? o : _();
|
|
324
|
+
e && !d(e, N) && (e = null), !e && o === !0 && (e = await A({
|
|
325
|
+
url: D,
|
|
326
|
+
authToken: k,
|
|
326
327
|
workspaceId: N.workspaceId,
|
|
327
328
|
organizationId: N.organizationId,
|
|
328
329
|
projectId: N.projectId,
|
|
329
330
|
locale: M,
|
|
330
|
-
signal:
|
|
331
|
+
signal: w,
|
|
331
332
|
currentQuery: n
|
|
332
333
|
})), e && (P["X-Workspace-Authorization"] = `Bearer ${e}`);
|
|
333
334
|
}
|
|
334
|
-
if (t === "workspace" ||
|
|
335
|
+
if (t === "workspace" || s) {
|
|
335
336
|
let e = N.workspaceId;
|
|
336
337
|
e && (P["x-workspace-id"] = e);
|
|
337
338
|
}
|
|
338
|
-
if (t === "global" ||
|
|
339
|
+
if (t === "global" || l) {
|
|
339
340
|
let e = N.organizationId;
|
|
340
341
|
e && (P["x-org-id"] = e);
|
|
341
342
|
}
|
|
342
343
|
if (m) {
|
|
343
|
-
let e = typeof m == "string" ? m :
|
|
344
|
+
let e = typeof m == "string" ? m : T();
|
|
344
345
|
e && (P["x-tenant-id"] = e);
|
|
345
346
|
}
|
|
346
|
-
if (t === "workspace" ||
|
|
347
|
+
if (t === "workspace" || h) {
|
|
347
348
|
let e = N.projectId;
|
|
348
349
|
e && (P["x-project-id"] = e);
|
|
349
350
|
}
|
|
350
|
-
let I =
|
|
351
|
+
let I = c(C);
|
|
351
352
|
I && Object.assign(P, I);
|
|
352
353
|
let L = { query: n };
|
|
353
354
|
r && (L.variables = r), i && (L.operationName = i);
|
|
354
355
|
try {
|
|
355
|
-
let e = await Q(
|
|
356
|
-
return
|
|
356
|
+
let e = await Q(D, P, L, w);
|
|
357
|
+
return p(), e.errors?.length && !E && f({ errors: e.errors }, { operationName: i }), e;
|
|
357
358
|
} catch (e) {
|
|
358
|
-
throw E ||
|
|
359
|
+
throw E || f(e, {
|
|
359
360
|
operationName: i,
|
|
360
361
|
fallbackMessage: "We could not reach the server. Please check your connection and try again."
|
|
361
362
|
}), e;
|
|
362
363
|
}
|
|
363
364
|
}
|
|
364
365
|
//#endregion
|
|
365
|
-
export {
|
|
366
|
+
export { I as clearGraphqlFetchResponseCache, Q as enqueueGraphQLFetch, g as getStoredAuthToken, S as getStoredLocale, w as getStoredOrganizationId, E as getStoredProjectId, C as getStoredWorkspaceId, _ as getStoredWorkspaceToken, te as graphqlFetch, j as resolveGatewayUrl };
|
|
@@ -34,6 +34,12 @@ export interface GatewayBaseMapping {
|
|
|
34
34
|
* @param localDefaults - Override defaults for local development
|
|
35
35
|
*/
|
|
36
36
|
export declare function resolveGatewayBases(extraMappings?: GatewayBaseMapping[], localDefaults?: GatewayBases): GatewayBases;
|
|
37
|
+
/**
|
|
38
|
+
* Attach Cloudflare Access service-token headers to a request iff a token is
|
|
39
|
+
* provided AND the request targets one of the CF-protected gateway origins.
|
|
40
|
+
* Pure + exported so it can be unit-tested without mocking `import.meta.env`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function maybeAttachCfAccessHeaders(request: Request, gatewayOrigins: ReadonlySet<string>, clientId?: string, clientSecret?: string): Request;
|
|
37
43
|
/**
|
|
38
44
|
* Install a global fetch interceptor that rewrites GraphQL request URLs
|
|
39
45
|
* to the correct gateway domain based on the URL path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gatewayFetchRewrite.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/gatewayFetchRewrite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,KAAK,EAAE,YAAY,CAAC;CACrB;AAmID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,kBAAkB,EAAE,EACpC,aAAa,CAAC,EAAE,YAAY,GAC3B,YAAY,CAad;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"gatewayFetchRewrite.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/gatewayFetchRewrite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,KAAK,EAAE,YAAY,CAAC;CACrB;AAmID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,kBAAkB,EAAE,EACpC,aAAa,CAAC,EAAE,YAAY,GAC3B,YAAY,CAad;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EACnC,QAAQ,CAAC,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAaT;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CA+IpE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAyB,GAAG,IAAI,CAQtE"}
|
|
@@ -81,13 +81,35 @@ function v(e, t) {
|
|
|
81
81
|
for (let e of a) if (n === e.hostname) return e.bases;
|
|
82
82
|
return t ?? i;
|
|
83
83
|
}
|
|
84
|
-
function y(e) {
|
|
84
|
+
function y(e, t, n, r) {
|
|
85
|
+
if (!n || !r) return e;
|
|
86
|
+
let i;
|
|
87
|
+
try {
|
|
88
|
+
i = new URL(e.url).origin;
|
|
89
|
+
} catch {
|
|
90
|
+
return e;
|
|
91
|
+
}
|
|
92
|
+
if (!t.has(i)) return e;
|
|
93
|
+
let a = new Headers(e.headers);
|
|
94
|
+
return a.set("CF-Access-Client-Id", n), a.set("CF-Access-Client-Secret", r), new Request(e, { headers: a });
|
|
95
|
+
}
|
|
96
|
+
function b(e) {
|
|
85
97
|
let { globalBase: t, workspaceBase: n } = e;
|
|
86
98
|
if (!t || !n) return;
|
|
87
|
-
let r = globalThis.fetch.bind(globalThis), i = window.location.origin, o =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
let r = globalThis.fetch.bind(globalThis), i = window.location.origin, o = {
|
|
100
|
+
BASE_URL: "/",
|
|
101
|
+
DEV: !1,
|
|
102
|
+
MODE: "production",
|
|
103
|
+
PROD: !0,
|
|
104
|
+
SSR: !1
|
|
105
|
+
}, s = o.VITE_CF_ACCESS_CLIENT_ID, c = o.VITE_CF_ACCESS_CLIENT_SECRET, u = !!(s && c), d = /* @__PURE__ */ new Set();
|
|
106
|
+
if (u) for (let e of [t, n]) try {
|
|
107
|
+
d.add(new URL(e).origin);
|
|
108
|
+
} catch {}
|
|
109
|
+
let f = (e) => u ? y(e, d, s, c) : e, v = new Set([i, "https://gw-global.local.burdenoff.com"]), b = new Set([i, "https://gw-wspace.local.burdenoff.com"]), x = (e) => /(?:^|\/)global\/graphql$/.test(e) ? "/global/graphql" : /(?:^|\/)workspaces\/graphql$/.test(e) ? "/workspaces/graphql" : "", S = (e) => {
|
|
110
|
+
let r = new URL(e, window.location.origin), i = x(r.pathname);
|
|
111
|
+
return i === "/global/graphql" && v.has(r.origin) ? `${t}${i}${r.search}${r.hash}` : i === "/workspaces/graphql" && b.has(r.origin) ? `${n}${i}${r.search}${r.hash}` : e;
|
|
112
|
+
}, C = async (e) => {
|
|
91
113
|
if (!(e.method.toUpperCase() === "POST" && /(?:^|\/)graphql$/.test(new URL(e.url).pathname))) return r(e);
|
|
92
114
|
let t = await e.clone().text(), n = _(e.clone()), i = m(t);
|
|
93
115
|
if (!i?.length) return r(e);
|
|
@@ -109,18 +131,18 @@ function y(e) {
|
|
|
109
131
|
});
|
|
110
132
|
} catch {}
|
|
111
133
|
return c;
|
|
112
|
-
},
|
|
134
|
+
}, w = r, T = ((e, t) => {
|
|
113
135
|
if (e == null) return r(e, t);
|
|
114
136
|
if (e instanceof Request) {
|
|
115
|
-
let n =
|
|
116
|
-
return
|
|
137
|
+
let n = S(e.url), r = new Request(n, e);
|
|
138
|
+
return C(f(t ? new Request(r, t) : r));
|
|
117
139
|
}
|
|
118
140
|
let n = typeof e == "string" ? e : e.toString();
|
|
119
|
-
return
|
|
141
|
+
return C(f(new Request(S(n), t)));
|
|
120
142
|
});
|
|
121
|
-
|
|
143
|
+
w.preconnect && (T.preconnect = w.preconnect), globalThis.fetch = T;
|
|
122
144
|
}
|
|
123
|
-
function
|
|
145
|
+
function x(e = "VITE_VERBOSE_CONSOLE") {
|
|
124
146
|
({
|
|
125
147
|
BASE_URL: "/",
|
|
126
148
|
DEV: !1,
|
|
@@ -130,4 +152,4 @@ function b(e = "VITE_VERBOSE_CONSOLE") {
|
|
|
130
152
|
})?.[e] !== "true" && (console.log = () => {}, console.info = () => {}, console.debug = () => {});
|
|
131
153
|
}
|
|
132
154
|
//#endregion
|
|
133
|
-
export {
|
|
155
|
+
export { b as installGatewayFetchRewrite, v as resolveGatewayBases, x as suppressConsole };
|