@burdenoff/fe-libs 2026.616.1 → 2026.616.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.
|
@@ -40,6 +40,23 @@ export declare function resolveGatewayBases(extraMappings?: GatewayBaseMapping[]
|
|
|
40
40
|
* Pure + exported so it can be unit-tested without mocking `import.meta.env`.
|
|
41
41
|
*/
|
|
42
42
|
export declare function maybeAttachCfAccessHeaders(request: Request, gatewayOrigins: ReadonlySet<string>, clientId?: string, clientSecret?: string): Request;
|
|
43
|
+
/**
|
|
44
|
+
* Options for installGatewayFetchRewrite.
|
|
45
|
+
*/
|
|
46
|
+
export interface GatewayFetchRewriteOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Cloudflare Access service-token. Vite only statically inlines custom VITE_
|
|
49
|
+
* env vars in APP source, not inside this bundled library, so the app reads
|
|
50
|
+
* `import.meta.env.VITE_CF_ACCESS_CLIENT_ID/_SECRET` in its own source and
|
|
51
|
+
* forwards them here. When both are present, CF-Access-Client-Id/Secret headers
|
|
52
|
+
* are attached to requests targeting a configured gateway origin. Omit on
|
|
53
|
+
* prod/local (gateways are not CF-gated).
|
|
54
|
+
*/
|
|
55
|
+
cfAccess?: {
|
|
56
|
+
clientId?: string;
|
|
57
|
+
clientSecret?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
43
60
|
/**
|
|
44
61
|
* Install a global fetch interceptor that rewrites GraphQL request URLs
|
|
45
62
|
* to the correct gateway domain based on the URL path.
|
|
@@ -48,8 +65,9 @@ export declare function maybeAttachCfAccessHeaders(request: Request, gatewayOrig
|
|
|
48
65
|
* - `/workspaces/graphql` → workspaceBase
|
|
49
66
|
*
|
|
50
67
|
* @param bases - Gateway base URLs to rewrite to
|
|
68
|
+
* @param options - Optional CF Access service-token for header injection
|
|
51
69
|
*/
|
|
52
|
-
export declare function installGatewayFetchRewrite(bases: GatewayBases): void;
|
|
70
|
+
export declare function installGatewayFetchRewrite(bases: GatewayBases, options?: GatewayFetchRewriteOptions): void;
|
|
53
71
|
/**
|
|
54
72
|
* Suppress verbose console output in production/non-debug environments.
|
|
55
73
|
*
|
|
@@ -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;;;;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
|
|
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;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,0BAA0B,GACnC,IAAI,CA6IN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAyB,GAAG,IAAI,CAQtE"}
|
|
@@ -93,32 +93,26 @@ function y(e, t, n, r) {
|
|
|
93
93
|
let a = new Headers(e.headers);
|
|
94
94
|
return a.set("CF-Access-Client-Id", n), a.set("CF-Access-Client-Secret", r), new Request(e, { headers: a });
|
|
95
95
|
}
|
|
96
|
-
function b(e) {
|
|
97
|
-
let { globalBase:
|
|
98
|
-
if (!
|
|
99
|
-
let
|
|
100
|
-
|
|
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 {
|
|
96
|
+
function b(e, t) {
|
|
97
|
+
let { globalBase: n, workspaceBase: r } = e;
|
|
98
|
+
if (!n || !r) return;
|
|
99
|
+
let i = globalThis.fetch.bind(globalThis), o = window.location.origin, s = t?.cfAccess?.clientId, c = t?.cfAccess?.clientSecret, u = !!(s && c), d = /* @__PURE__ */ new Set();
|
|
100
|
+
if (u) for (let e of [n, r]) try {
|
|
107
101
|
d.add(new URL(e).origin);
|
|
108
102
|
} catch {}
|
|
109
|
-
let f = (e) => u ? y(e, d, s, c) : e, v = new Set([
|
|
110
|
-
let
|
|
111
|
-
return i === "/global/graphql" && v.has(
|
|
103
|
+
let f = (e) => u ? y(e, d, s, c) : e, v = new Set([o, "https://gw-global.local.burdenoff.com"]), b = new Set([o, "https://gw-wspace.local.burdenoff.com"]), x = (e) => /(?:^|\/)global\/graphql$/.test(e) ? "/global/graphql" : /(?:^|\/)workspaces\/graphql$/.test(e) ? "/workspaces/graphql" : "", S = (e) => {
|
|
104
|
+
let t = new URL(e, window.location.origin), i = x(t.pathname);
|
|
105
|
+
return i === "/global/graphql" && v.has(t.origin) ? `${n}${i}${t.search}${t.hash}` : i === "/workspaces/graphql" && b.has(t.origin) ? `${r}${i}${t.search}${t.hash}` : e;
|
|
112
106
|
}, C = async (e) => {
|
|
113
|
-
if (!(e.method.toUpperCase() === "POST" && /(?:^|\/)graphql$/.test(new URL(e.url).pathname))) return
|
|
114
|
-
let t = await e.clone().text(), n = _(e.clone()),
|
|
115
|
-
if (!
|
|
116
|
-
let o = t.trimStart().startsWith("["), s =
|
|
107
|
+
if (!(e.method.toUpperCase() === "POST" && /(?:^|\/)graphql$/.test(new URL(e.url).pathname))) return i(e);
|
|
108
|
+
let t = await e.clone().text(), n = _(e.clone()), r = m(t);
|
|
109
|
+
if (!r?.length) return i(e);
|
|
110
|
+
let o = t.trimStart().startsWith("["), s = r.map((e) => p(n, e));
|
|
117
111
|
if (g() && s.every(Boolean)) {
|
|
118
112
|
let e = l(), t = s.map((t) => e.get(t)), n = Date.now();
|
|
119
113
|
if (t.every((e) => e && e.expiresAt > n)) return h(t.map((e) => e.value), o);
|
|
120
114
|
}
|
|
121
|
-
let c = await
|
|
115
|
+
let c = await i(e);
|
|
122
116
|
if (!c.ok || !s.some(Boolean) || !g()) return c;
|
|
123
117
|
try {
|
|
124
118
|
let e = await c.clone().json(), t = Array.isArray(e) ? e : [e], n = l();
|
|
@@ -131,8 +125,8 @@ function b(e) {
|
|
|
131
125
|
});
|
|
132
126
|
} catch {}
|
|
133
127
|
return c;
|
|
134
|
-
}, w =
|
|
135
|
-
if (e == null) return
|
|
128
|
+
}, w = i, T = ((e, t) => {
|
|
129
|
+
if (e == null) return i(e, t);
|
|
136
130
|
if (e instanceof Request) {
|
|
137
131
|
let n = S(e.url), r = new Request(n, e);
|
|
138
132
|
return C(f(t ? new Request(r, t) : r));
|