@c1m-public/platform-auth 0.9.0 → 0.9.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/access/index.d.ts +1 -153
- package/dist/access/index.js +307 -2
- package/dist/access/next.d.ts +2 -3
- package/dist/access/next.js +337 -7
- package/dist/index-BnchfjP_.d.ts +235 -0
- package/dist/index-CbsCWtku.d.ts +154 -0
- package/dist/index.d.ts +1 -230
- package/dist/index.js +534 -3
- package/dist/next.d.ts +2 -3
- package/dist/next.js +537 -8
- package/package.json +1 -1
- package/dist/chunk-FBC2NUH7.js +0 -83
- package/dist/chunk-Q7YI7RMG.js +0 -404
- package/dist/chunk-U67NBJND.js +0 -267
- package/dist/chunk-ZWSJVE5S.js +0 -52
- package/dist/internal-D6RafCm2.d.ts +0 -6
package/dist/chunk-ZWSJVE5S.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// ../transport/src/forwarding.ts
|
|
2
|
-
function applyForwardedClientHeaders(incoming, headers = new Headers()) {
|
|
3
|
-
const forwardedFor = incoming.get("x-forwarded-for");
|
|
4
|
-
const realIp = incoming.get("x-real-ip") ?? forwardedFor?.split(",")[0]?.trim();
|
|
5
|
-
if (realIp && !headers.has("X-Client-IP")) headers.set("X-Client-IP", realIp);
|
|
6
|
-
if (realIp && !headers.has("X-Real-IP")) headers.set("X-Real-IP", realIp);
|
|
7
|
-
if (forwardedFor && !headers.has("X-Forwarded-For")) headers.set("X-Forwarded-For", forwardedFor);
|
|
8
|
-
const country = incoming.get("cf-ipcountry") ?? incoming.get("x-vercel-ip-country") ?? incoming.get("x-geo-country") ?? incoming.get("x-country-code");
|
|
9
|
-
if (country && country !== "XX" && !headers.has("X-Geo-Country")) {
|
|
10
|
-
headers.set("X-Geo-Country", country);
|
|
11
|
-
}
|
|
12
|
-
const host = incoming.get("host");
|
|
13
|
-
if (host && !headers.has("X-Forwarded-Host")) headers.set("X-Forwarded-Host", host);
|
|
14
|
-
const proto = incoming.get("x-forwarded-proto");
|
|
15
|
-
if (proto && !headers.has("X-Forwarded-Proto")) headers.set("X-Forwarded-Proto", proto);
|
|
16
|
-
const userAgent = incoming.get("user-agent");
|
|
17
|
-
if (userAgent && !headers.has("X-Client-User-Agent")) headers.set("X-Client-User-Agent", userAgent);
|
|
18
|
-
return headers;
|
|
19
|
-
}
|
|
20
|
-
function forwardedRequestHeaders(request, init) {
|
|
21
|
-
return applyForwardedClientHeaders(request.headers, new Headers(init));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// src/internal.ts
|
|
25
|
-
function resolveValue(value) {
|
|
26
|
-
return typeof value === "function" ? value() : value;
|
|
27
|
-
}
|
|
28
|
-
function resolveAsync(value) {
|
|
29
|
-
return typeof value === "function" ? value() : value;
|
|
30
|
-
}
|
|
31
|
-
var isPromise = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
|
|
32
|
-
function resolveAll(...values) {
|
|
33
|
-
const resolved = values.map((value) => resolveAsync(value));
|
|
34
|
-
return resolved.some(isPromise) ? Promise.all(resolved) : resolved;
|
|
35
|
-
}
|
|
36
|
-
var DEFAULT_FETCH_TIMEOUT_MS = 1e4;
|
|
37
|
-
async function timedFetch(url, options = {}) {
|
|
38
|
-
const doFetch = options.fetch ?? options.fetchImpl ?? fetch;
|
|
39
|
-
const controller = options.timeoutMs ? new AbortController() : void 0;
|
|
40
|
-
const timer = controller ? setTimeout(() => controller.abort(), options.timeoutMs) : void 0;
|
|
41
|
-
try {
|
|
42
|
-
return await doFetch(url, {
|
|
43
|
-
...options.init,
|
|
44
|
-
cache: "no-store",
|
|
45
|
-
...controller ? { signal: controller.signal } : {}
|
|
46
|
-
});
|
|
47
|
-
} finally {
|
|
48
|
-
if (timer) clearTimeout(timer);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { DEFAULT_FETCH_TIMEOUT_MS, applyForwardedClientHeaders, forwardedRequestHeaders, resolveAll, resolveValue, timedFetch };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** A value that may be fixed or resolved per call (env read at request time). */
|
|
2
|
-
type Resolvable<T = string> = T | (() => T);
|
|
3
|
-
/** A value, a sync resolver, or an async resolver. */
|
|
4
|
-
type AsyncResolvable<T> = T | (() => T | Promise<T>);
|
|
5
|
-
|
|
6
|
-
export type { AsyncResolvable as A, Resolvable as R };
|