@burdenoff/fe-libs 2026.615.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.
|
@@ -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 };
|