@keystrokehq/cli 0.1.104 → 0.1.106
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/dist-BvmFovtv.mjs.map +1 -1
- package/dist/dist-odLBD6p1.mjs.map +1 -1
- package/dist/index.mjs +516 -337
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -415,7 +415,7 @@ const validateAndMerge = (...sources) => {
|
|
|
415
415
|
for (const source of sources) if ((!isObject(source) || Array.isArray(source)) && source !== void 0) throw new TypeError("The `options` argument must be an object");
|
|
416
416
|
return deepMerge({}, ...sources);
|
|
417
417
|
};
|
|
418
|
-
const mergeHeaders = (source1 = {}, source2 = {}) => {
|
|
418
|
+
const mergeHeaders$1 = (source1 = {}, source2 = {}) => {
|
|
419
419
|
const result = new globalThis.Headers(source1);
|
|
420
420
|
const isHeadersInstance = source2 instanceof globalThis.Headers;
|
|
421
421
|
const source = new globalThis.Headers(source2);
|
|
@@ -423,7 +423,7 @@ const mergeHeaders = (source1 = {}, source2 = {}) => {
|
|
|
423
423
|
else result.set(key, value);
|
|
424
424
|
return result;
|
|
425
425
|
};
|
|
426
|
-
const isPlainObject$
|
|
426
|
+
const isPlainObject$2 = (value) => {
|
|
427
427
|
if (!isObject(value) || Array.isArray(value)) return false;
|
|
428
428
|
const prototype = Object.getPrototypeOf(value);
|
|
429
429
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -437,16 +437,16 @@ const cloneShallow = (value) => {
|
|
|
437
437
|
}
|
|
438
438
|
if (value instanceof globalThis.Headers) return new globalThis.Headers(value);
|
|
439
439
|
if (Array.isArray(value)) return [...value];
|
|
440
|
-
if (isPlainObject$
|
|
440
|
+
if (isPlainObject$2(value)) return { ...value };
|
|
441
441
|
return value;
|
|
442
442
|
};
|
|
443
443
|
const normalizeHeaderObject = (headers) => Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] !== void 0));
|
|
444
444
|
const mergeHeaderContainers = (source1, source2) => {
|
|
445
|
-
if (isPlainObject$
|
|
445
|
+
if (isPlainObject$2(source1) && isPlainObject$2(source2)) return normalizeHeaderObject({
|
|
446
446
|
...source1,
|
|
447
447
|
...source2
|
|
448
448
|
});
|
|
449
|
-
return mergeHeaders(source1, source2);
|
|
449
|
+
return mergeHeaders$1(source1, source2);
|
|
450
450
|
};
|
|
451
451
|
function newHookValue(original, incoming, property) {
|
|
452
452
|
return Object.hasOwn(incoming, property) && incoming[property] === void 0 ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
|
|
@@ -904,7 +904,7 @@ var Ky = class Ky {
|
|
|
904
904
|
if (Object.hasOwn(options, "prefixUrl")) throw new Error(prefixUrlRenamedErrorMessage);
|
|
905
905
|
this.#options = {
|
|
906
906
|
...options,
|
|
907
|
-
headers: mergeHeaders(this.#input.headers, options.headers),
|
|
907
|
+
headers: mergeHeaders$1(this.#input.headers, options.headers),
|
|
908
908
|
hooks: mergeHooks({}, options.hooks),
|
|
909
909
|
method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
|
|
910
910
|
prefix: String(options.prefix || ""),
|
|
@@ -1721,10 +1721,10 @@ function createJwtTokenCache(mint) {
|
|
|
1721
1721
|
};
|
|
1722
1722
|
}
|
|
1723
1723
|
//#endregion
|
|
1724
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
1725
|
-
const PACKAGE_VERSION = "1.6.
|
|
1724
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/version.mjs
|
|
1725
|
+
const PACKAGE_VERSION = "1.6.23";
|
|
1726
1726
|
//#endregion
|
|
1727
|
-
//#region ../../node_modules/.pnpm/better-call@1.3.
|
|
1727
|
+
//#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.4.3/node_modules/better-call/dist/error.mjs
|
|
1728
1728
|
function isErrorStackTraceLimitWritable() {
|
|
1729
1729
|
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
1730
1730
|
if (desc === void 0) return Object.isExtensible(Error);
|
|
@@ -1836,7 +1836,7 @@ var InternalAPIError = class extends Error {
|
|
|
1836
1836
|
};
|
|
1837
1837
|
makeErrorForHideStackFrame(InternalAPIError, Error);
|
|
1838
1838
|
//#endregion
|
|
1839
|
-
//#region ../../node_modules/.pnpm/@better-auth+core@1.6.
|
|
1839
|
+
//#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/error/index.mjs
|
|
1840
1840
|
var BetterAuthError = class extends Error {
|
|
1841
1841
|
constructor(message, options) {
|
|
1842
1842
|
super(message, options);
|
|
@@ -1846,7 +1846,7 @@ var BetterAuthError = class extends Error {
|
|
|
1846
1846
|
}
|
|
1847
1847
|
};
|
|
1848
1848
|
//#endregion
|
|
1849
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
1849
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
|
|
1850
1850
|
const deviceAuthorizationClient = () => {
|
|
1851
1851
|
return {
|
|
1852
1852
|
id: "device-authorization",
|
|
@@ -1862,6 +1862,175 @@ const deviceAuthorizationClient = () => {
|
|
|
1862
1862
|
};
|
|
1863
1863
|
};
|
|
1864
1864
|
//#endregion
|
|
1865
|
+
//#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/env/env-impl.mjs
|
|
1866
|
+
const _envShim = Object.create(null);
|
|
1867
|
+
const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
|
|
1868
|
+
const env = new Proxy(_envShim, {
|
|
1869
|
+
get(_, prop) {
|
|
1870
|
+
return _getEnv()[prop] ?? _envShim[prop];
|
|
1871
|
+
},
|
|
1872
|
+
has(_, prop) {
|
|
1873
|
+
return prop in _getEnv() || prop in _envShim;
|
|
1874
|
+
},
|
|
1875
|
+
set(_, prop, value) {
|
|
1876
|
+
const env = _getEnv(true);
|
|
1877
|
+
env[prop] = value;
|
|
1878
|
+
return true;
|
|
1879
|
+
},
|
|
1880
|
+
deleteProperty(_, prop) {
|
|
1881
|
+
if (!prop) return false;
|
|
1882
|
+
const env = _getEnv(true);
|
|
1883
|
+
delete env[prop];
|
|
1884
|
+
return true;
|
|
1885
|
+
},
|
|
1886
|
+
ownKeys() {
|
|
1887
|
+
const env = _getEnv(true);
|
|
1888
|
+
return Object.keys(env);
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
env.NODE_ENV;
|
|
1892
|
+
/**
|
|
1893
|
+
* Get environment variable with fallback
|
|
1894
|
+
*/
|
|
1895
|
+
function getEnvVar(key, fallback) {
|
|
1896
|
+
if (typeof process !== "undefined" && process.env) return process.env[key] ?? fallback;
|
|
1897
|
+
if (typeof Deno !== "undefined") return Deno.env.get(key) ?? fallback;
|
|
1898
|
+
if (typeof Bun !== "undefined") return Bun.env[key] ?? fallback;
|
|
1899
|
+
return fallback;
|
|
1900
|
+
}
|
|
1901
|
+
Object.freeze({
|
|
1902
|
+
get BETTER_AUTH_SECRET() {
|
|
1903
|
+
return getEnvVar("BETTER_AUTH_SECRET");
|
|
1904
|
+
},
|
|
1905
|
+
get AUTH_SECRET() {
|
|
1906
|
+
return getEnvVar("AUTH_SECRET");
|
|
1907
|
+
},
|
|
1908
|
+
get BETTER_AUTH_TELEMETRY() {
|
|
1909
|
+
return getEnvVar("BETTER_AUTH_TELEMETRY");
|
|
1910
|
+
},
|
|
1911
|
+
get BETTER_AUTH_TELEMETRY_ID() {
|
|
1912
|
+
return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
|
|
1913
|
+
},
|
|
1914
|
+
get NODE_ENV() {
|
|
1915
|
+
return getEnvVar("NODE_ENV", "development");
|
|
1916
|
+
},
|
|
1917
|
+
get PACKAGE_VERSION() {
|
|
1918
|
+
return getEnvVar("PACKAGE_VERSION", "0.0.0");
|
|
1919
|
+
},
|
|
1920
|
+
get BETTER_AUTH_TELEMETRY_ENDPOINT() {
|
|
1921
|
+
return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
//#endregion
|
|
1925
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/utils/url.mjs
|
|
1926
|
+
const SLASH_CHAR_CODE = "/".charCodeAt(0);
|
|
1927
|
+
function trimTrailingSlashes(value) {
|
|
1928
|
+
let end = value.length;
|
|
1929
|
+
while (end > 0 && value.charCodeAt(end - 1) === SLASH_CHAR_CODE) end--;
|
|
1930
|
+
return end === value.length ? value : value.slice(0, end);
|
|
1931
|
+
}
|
|
1932
|
+
function checkHasPath(url) {
|
|
1933
|
+
try {
|
|
1934
|
+
return (trimTrailingSlashes(new URL(url).pathname) || "/") !== "/";
|
|
1935
|
+
} catch {
|
|
1936
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
function assertHasProtocol(url) {
|
|
1940
|
+
try {
|
|
1941
|
+
const parsedUrl = new URL(url);
|
|
1942
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
|
|
1943
|
+
} catch (error) {
|
|
1944
|
+
if (error instanceof BetterAuthError) throw error;
|
|
1945
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
function withPath(url, path = "/api/auth") {
|
|
1949
|
+
assertHasProtocol(url);
|
|
1950
|
+
if (checkHasPath(url)) return url;
|
|
1951
|
+
const trimmedUrl = trimTrailingSlashes(url);
|
|
1952
|
+
if (!path || path === "/") return trimmedUrl;
|
|
1953
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
1954
|
+
return `${trimmedUrl}${path}`;
|
|
1955
|
+
}
|
|
1956
|
+
function validateProxyHeader(header, type) {
|
|
1957
|
+
if (!header || header.trim() === "") return false;
|
|
1958
|
+
if (type === "proto") return header === "http" || header === "https";
|
|
1959
|
+
if (type === "host") {
|
|
1960
|
+
if ([
|
|
1961
|
+
/\.\./,
|
|
1962
|
+
/\0/,
|
|
1963
|
+
/[\s]/,
|
|
1964
|
+
/^[.]/,
|
|
1965
|
+
/[<>'"]/,
|
|
1966
|
+
/javascript:/i,
|
|
1967
|
+
/file:/i,
|
|
1968
|
+
/data:/i
|
|
1969
|
+
].some((pattern) => pattern.test(header))) return false;
|
|
1970
|
+
return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
|
|
1971
|
+
}
|
|
1972
|
+
return false;
|
|
1973
|
+
}
|
|
1974
|
+
function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
|
|
1975
|
+
if (url) return withPath(url, path);
|
|
1976
|
+
if (loadEnv !== false) {
|
|
1977
|
+
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
1978
|
+
if (fromEnv) return withPath(fromEnv, path);
|
|
1979
|
+
}
|
|
1980
|
+
const fromRequest = request?.headers.get("x-forwarded-host");
|
|
1981
|
+
const fromRequestProto = request?.headers.get("x-forwarded-proto");
|
|
1982
|
+
if (fromRequest && fromRequestProto && trustedProxyHeaders) {
|
|
1983
|
+
if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
|
|
1984
|
+
return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
1985
|
+
} catch (_error) {}
|
|
1986
|
+
}
|
|
1987
|
+
if (request) {
|
|
1988
|
+
const url = getOrigin(request.url);
|
|
1989
|
+
if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
1990
|
+
return withPath(url, path);
|
|
1991
|
+
}
|
|
1992
|
+
if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
|
|
1993
|
+
}
|
|
1994
|
+
function getOrigin(url) {
|
|
1995
|
+
try {
|
|
1996
|
+
const parsedUrl = new URL(url);
|
|
1997
|
+
return parsedUrl.origin === "null" ? null : parsedUrl.origin;
|
|
1998
|
+
} catch {
|
|
1999
|
+
return null;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
//#endregion
|
|
2003
|
+
//#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/utils/url.mjs
|
|
2004
|
+
/**
|
|
2005
|
+
* Schemes that execute or embed code when navigated to or accepted as a
|
|
2006
|
+
* redirect target. These are never safe as an OAuth `redirect_uri` or as a
|
|
2007
|
+
* client-side navigation target (`window.location.href`, `location.assign`, ...).
|
|
2008
|
+
*/
|
|
2009
|
+
const DANGEROUS_URL_SCHEMES = [
|
|
2010
|
+
"javascript:",
|
|
2011
|
+
"data:",
|
|
2012
|
+
"vbscript:"
|
|
2013
|
+
];
|
|
2014
|
+
/**
|
|
2015
|
+
* Returns `false` only when `value` is an absolute URL using a dangerous scheme
|
|
2016
|
+
* (`javascript:`, `data:`, `vbscript:`). Relative URLs (e.g. `/dashboard`) and
|
|
2017
|
+
* safe absolute schemes (`http`, `https`, custom app schemes such as
|
|
2018
|
+
* `myapp://`) return `true`.
|
|
2019
|
+
*
|
|
2020
|
+
* Use this to guard browser navigation sinks and any redirect target that may
|
|
2021
|
+
* originate from untrusted input. It is intentionally narrow: it blocks code
|
|
2022
|
+
* execution schemes without rejecting relative paths or mobile deep links.
|
|
2023
|
+
*/
|
|
2024
|
+
function isSafeUrlScheme(value) {
|
|
2025
|
+
let parsed;
|
|
2026
|
+
try {
|
|
2027
|
+
parsed = new URL(value);
|
|
2028
|
+
} catch {
|
|
2029
|
+
return true;
|
|
2030
|
+
}
|
|
2031
|
+
return !DANGEROUS_URL_SCHEMES.includes(parsed.protocol);
|
|
2032
|
+
}
|
|
2033
|
+
//#endregion
|
|
1865
2034
|
//#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/clean-stores/index.js
|
|
1866
2035
|
const clean = Symbol("clean");
|
|
1867
2036
|
//#endregion
|
|
@@ -1924,6 +2093,7 @@ const atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
|
|
|
1924
2093
|
};
|
|
1925
2094
|
//#endregion
|
|
1926
2095
|
//#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/lifecycle/index.js
|
|
2096
|
+
const SET = 2;
|
|
1927
2097
|
const MOUNT = 5;
|
|
1928
2098
|
const UNMOUNT = 6;
|
|
1929
2099
|
const REVERT_MUTATION = 10;
|
|
@@ -1948,6 +2118,40 @@ let on = (object, listener, eventKey, mutateStore) => {
|
|
|
1948
2118
|
}
|
|
1949
2119
|
};
|
|
1950
2120
|
};
|
|
2121
|
+
let onSet = ($store, listener) => on($store, listener, SET, (runListeners) => {
|
|
2122
|
+
let originSet = $store.set;
|
|
2123
|
+
let originSetKey = $store.setKey;
|
|
2124
|
+
if ($store.setKey) $store.setKey = (changed, changedValue) => {
|
|
2125
|
+
let isAborted;
|
|
2126
|
+
let abort = () => {
|
|
2127
|
+
isAborted = true;
|
|
2128
|
+
};
|
|
2129
|
+
runListeners({
|
|
2130
|
+
abort,
|
|
2131
|
+
changed,
|
|
2132
|
+
newValue: {
|
|
2133
|
+
...$store.value,
|
|
2134
|
+
[changed]: changedValue
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
if (!isAborted) return originSetKey(changed, changedValue);
|
|
2138
|
+
};
|
|
2139
|
+
$store.set = (newValue) => {
|
|
2140
|
+
let isAborted;
|
|
2141
|
+
let abort = () => {
|
|
2142
|
+
isAborted = true;
|
|
2143
|
+
};
|
|
2144
|
+
runListeners({
|
|
2145
|
+
abort,
|
|
2146
|
+
newValue
|
|
2147
|
+
});
|
|
2148
|
+
if (!isAborted) return originSet(newValue);
|
|
2149
|
+
};
|
|
2150
|
+
return () => {
|
|
2151
|
+
$store.set = originSet;
|
|
2152
|
+
$store.setKey = originSetKey;
|
|
2153
|
+
};
|
|
2154
|
+
});
|
|
1951
2155
|
const STORE_UNMOUNT_DELAY = 1e3;
|
|
1952
2156
|
let onMount = ($store, initialize) => {
|
|
1953
2157
|
let listener = (payload) => {
|
|
@@ -1991,101 +2195,47 @@ let onMount = ($store, initialize) => {
|
|
|
1991
2195
|
});
|
|
1992
2196
|
};
|
|
1993
2197
|
//#endregion
|
|
1994
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
const
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
if (retryAttempts && retryAttempt < retryAttempts) return;
|
|
2032
|
-
const isUnauthorized = context.error.status === 401;
|
|
2033
|
-
value.set({
|
|
2034
|
-
error: context.error,
|
|
2035
|
-
data: isUnauthorized ? null : value.get().data,
|
|
2036
|
-
isPending: false,
|
|
2037
|
-
isRefetching: false,
|
|
2038
|
-
refetch: value.value.refetch
|
|
2039
|
-
});
|
|
2040
|
-
await opts?.onError?.(context);
|
|
2041
|
-
},
|
|
2042
|
-
async onRequest(context) {
|
|
2043
|
-
const currentValue = value.get();
|
|
2044
|
-
value.set({
|
|
2045
|
-
isPending: currentValue.data === null,
|
|
2046
|
-
data: currentValue.data,
|
|
2047
|
-
error: null,
|
|
2048
|
-
isRefetching: true,
|
|
2049
|
-
refetch: value.value.refetch
|
|
2050
|
-
});
|
|
2051
|
-
await opts?.onRequest?.(context);
|
|
2052
|
-
}
|
|
2053
|
-
}).catch((error) => {
|
|
2054
|
-
value.set({
|
|
2055
|
-
error,
|
|
2056
|
-
data: value.get().data,
|
|
2057
|
-
isPending: false,
|
|
2058
|
-
isRefetching: false,
|
|
2059
|
-
refetch: value.value.refetch
|
|
2060
|
-
});
|
|
2061
|
-
}).finally(() => {
|
|
2062
|
-
resolve(void 0);
|
|
2063
|
-
});
|
|
2064
|
-
});
|
|
2065
|
-
};
|
|
2066
|
-
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
2067
|
-
let isInitialized = false;
|
|
2068
|
-
for (const initAtom of initializedAtom) initAtom.subscribe(async () => {
|
|
2069
|
-
if (isServer()) return;
|
|
2070
|
-
if (isInitialized) await fn();
|
|
2071
|
-
else onMount(value, () => {
|
|
2072
|
-
const timeoutId = setTimeout(async () => {
|
|
2073
|
-
if (!isInitialized) {
|
|
2074
|
-
isInitialized = true;
|
|
2075
|
-
await fn();
|
|
2076
|
-
}
|
|
2077
|
-
}, 0);
|
|
2078
|
-
return () => {
|
|
2079
|
-
value.off();
|
|
2080
|
-
initAtom.off();
|
|
2081
|
-
clearTimeout(timeoutId);
|
|
2082
|
-
};
|
|
2083
|
-
});
|
|
2198
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/equality.mjs
|
|
2199
|
+
function isPlainObject$1(value) {
|
|
2200
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2201
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2202
|
+
return prototype === Object.prototype || prototype === null;
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Deep structural equality for JSON-serializable values.
|
|
2206
|
+
* Handles: primitives, null, arrays, and plain objects.
|
|
2207
|
+
* Short-circuits on referential equality at every recursion level.
|
|
2208
|
+
*/
|
|
2209
|
+
function isJsonEqual(a, b) {
|
|
2210
|
+
if (a === b) return true;
|
|
2211
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2212
|
+
if (a.length !== b.length) return false;
|
|
2213
|
+
for (let i = 0; i < a.length; i++) if (!isJsonEqual(a[i], b[i])) return false;
|
|
2214
|
+
return true;
|
|
2215
|
+
}
|
|
2216
|
+
if (isPlainObject$1(a) && isPlainObject$1(b)) {
|
|
2217
|
+
const keysA = Object.keys(a);
|
|
2218
|
+
const keysB = Object.keys(b);
|
|
2219
|
+
if (keysA.length !== keysB.length) return false;
|
|
2220
|
+
for (const key of keysA) if (!(key in b) || !isJsonEqual(a[key], b[key])) return false;
|
|
2221
|
+
return true;
|
|
2222
|
+
}
|
|
2223
|
+
return false;
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Attach an equality gate to a nanostores atom via `onSet`.
|
|
2227
|
+
* When `isEqual(currentValue, newValue)` returns true, the `set()` call
|
|
2228
|
+
* is aborted: no listeners fire, no framework re-renders occur.
|
|
2229
|
+
*
|
|
2230
|
+
* Returns the unsubscribe function from `onSet`.
|
|
2231
|
+
*/
|
|
2232
|
+
function withEquality(store, isEqual) {
|
|
2233
|
+
return onSet(store, ({ newValue, abort }) => {
|
|
2234
|
+
if (isEqual(store.value, newValue)) abort();
|
|
2084
2235
|
});
|
|
2085
|
-
|
|
2086
|
-
};
|
|
2236
|
+
}
|
|
2087
2237
|
//#endregion
|
|
2088
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
2238
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
2089
2239
|
const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
2090
2240
|
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
2091
2241
|
var WindowBroadcastChannel = class {
|
|
@@ -2128,7 +2278,7 @@ function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
|
2128
2278
|
return globalThis[kBroadcastChannel];
|
|
2129
2279
|
}
|
|
2130
2280
|
//#endregion
|
|
2131
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
2281
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
2132
2282
|
const kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
2133
2283
|
var WindowFocusManager = class {
|
|
2134
2284
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -2157,7 +2307,7 @@ function getGlobalFocusManager() {
|
|
|
2157
2307
|
return globalThis[kFocusManager];
|
|
2158
2308
|
}
|
|
2159
2309
|
//#endregion
|
|
2160
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
2310
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/online-manager.mjs
|
|
2161
2311
|
const kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
2162
2312
|
var WindowOnlineManager = class {
|
|
2163
2313
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -2189,7 +2339,7 @@ function getGlobalOnlineManager() {
|
|
|
2189
2339
|
return globalThis[kOnlineManager];
|
|
2190
2340
|
}
|
|
2191
2341
|
//#endregion
|
|
2192
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
2342
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/parser.mjs
|
|
2193
2343
|
const PROTO_POLLUTION_PATTERNS = {
|
|
2194
2344
|
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
2195
2345
|
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
@@ -2225,7 +2375,6 @@ function betterJSONParse(value, options = {}) {
|
|
|
2225
2375
|
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
2226
2376
|
if (typeof value !== "string") return value;
|
|
2227
2377
|
const trimmed = value.trim();
|
|
2228
|
-
if (trimmed.length > 0 && trimmed[0] === "\"" && trimmed.endsWith("\"") && !trimmed.slice(1, -1).includes("\"")) return trimmed.slice(1, -1);
|
|
2229
2378
|
const lowerValue = trimmed.toLowerCase();
|
|
2230
2379
|
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
2231
2380
|
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
@@ -2259,31 +2408,20 @@ function parseJSON(value, options = { strict: true }) {
|
|
|
2259
2408
|
return betterJSONParse(value, options);
|
|
2260
2409
|
}
|
|
2261
2410
|
//#endregion
|
|
2262
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
2411
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
2263
2412
|
const now = () => Math.floor(Date.now() / 1e3);
|
|
2264
2413
|
/**
|
|
2265
|
-
* Normalize $fetch response: `throw: true` returns data directly, otherwise `{ data, error }`.
|
|
2266
|
-
*/
|
|
2267
|
-
function normalizeSessionResponse(res) {
|
|
2268
|
-
if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
|
|
2269
|
-
return {
|
|
2270
|
-
data: res,
|
|
2271
|
-
error: null
|
|
2272
|
-
};
|
|
2273
|
-
}
|
|
2274
|
-
/**
|
|
2275
2414
|
* Rate limit: don't refetch on focus if a session request was made within this many seconds
|
|
2276
2415
|
*/
|
|
2277
2416
|
const FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
|
|
2278
2417
|
function createSessionRefreshManager(opts) {
|
|
2279
|
-
const {
|
|
2418
|
+
const { fetchSession, shouldPollSession = () => true, sessionSignal, options = {} } = opts;
|
|
2280
2419
|
const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
|
|
2281
2420
|
const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
|
|
2282
2421
|
const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
|
|
2283
2422
|
const state = {
|
|
2284
|
-
|
|
2285
|
-
lastSessionRequest: 0
|
|
2286
|
-
cachedSession: void 0
|
|
2423
|
+
isInitialized: false,
|
|
2424
|
+
lastSessionRequest: 0
|
|
2287
2425
|
};
|
|
2288
2426
|
const shouldRefetch = () => {
|
|
2289
2427
|
return refetchWhenOffline || getGlobalOnlineManager().isOnline;
|
|
@@ -2291,45 +2429,21 @@ function createSessionRefreshManager(opts) {
|
|
|
2291
2429
|
const triggerRefetch = (event) => {
|
|
2292
2430
|
if (!shouldRefetch()) return;
|
|
2293
2431
|
if (event?.event === "storage") {
|
|
2294
|
-
|
|
2295
|
-
sessionSignal.set(!sessionSignal.get());
|
|
2432
|
+
fetchSession();
|
|
2296
2433
|
return;
|
|
2297
2434
|
}
|
|
2298
|
-
const currentSession = sessionAtom.get();
|
|
2299
|
-
const fetchSessionWithRefresh = () => {
|
|
2300
|
-
state.lastSessionRequest = now();
|
|
2301
|
-
$fetch("/get-session").then(async (res) => {
|
|
2302
|
-
let { data, error } = normalizeSessionResponse(res);
|
|
2303
|
-
if (data?.needsRefresh) try {
|
|
2304
|
-
const refreshRes = await $fetch("/get-session", { method: "POST" });
|
|
2305
|
-
({data, error} = normalizeSessionResponse(refreshRes));
|
|
2306
|
-
} catch {}
|
|
2307
|
-
const sessionData = data?.session && data?.user ? data : null;
|
|
2308
|
-
sessionAtom.set({
|
|
2309
|
-
...currentSession,
|
|
2310
|
-
data: sessionData,
|
|
2311
|
-
error
|
|
2312
|
-
});
|
|
2313
|
-
state.lastSync = now();
|
|
2314
|
-
sessionSignal.set(!sessionSignal.get());
|
|
2315
|
-
}).catch(() => {});
|
|
2316
|
-
};
|
|
2317
2435
|
if (event?.event === "poll") {
|
|
2318
|
-
|
|
2436
|
+
state.lastSessionRequest = now();
|
|
2437
|
+
fetchSession();
|
|
2319
2438
|
return;
|
|
2320
2439
|
}
|
|
2321
2440
|
if (event?.event === "visibilitychange") {
|
|
2322
2441
|
if (now() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS) return;
|
|
2323
2442
|
state.lastSessionRequest = now();
|
|
2324
|
-
|
|
2325
|
-
if (event?.event === "visibilitychange") {
|
|
2326
|
-
fetchSessionWithRefresh();
|
|
2443
|
+
fetchSession();
|
|
2327
2444
|
return;
|
|
2328
2445
|
}
|
|
2329
|
-
|
|
2330
|
-
state.lastSync = now();
|
|
2331
|
-
sessionSignal.set(!sessionSignal.get());
|
|
2332
|
-
}
|
|
2446
|
+
fetchSession();
|
|
2333
2447
|
};
|
|
2334
2448
|
const broadcastSessionUpdate = (trigger) => {
|
|
2335
2449
|
getGlobalBroadcastChannel().post({
|
|
@@ -2340,7 +2454,7 @@ function createSessionRefreshManager(opts) {
|
|
|
2340
2454
|
};
|
|
2341
2455
|
const setupPolling = () => {
|
|
2342
2456
|
if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
|
|
2343
|
-
if (
|
|
2457
|
+
if (shouldPollSession()) triggerRefetch({ event: "poll" });
|
|
2344
2458
|
}, refetchInterval * 1e3);
|
|
2345
2459
|
};
|
|
2346
2460
|
const setupBroadcast = () => {
|
|
@@ -2359,16 +2473,25 @@ function createSessionRefreshManager(opts) {
|
|
|
2359
2473
|
if (online) triggerRefetch({ event: "visibilitychange" });
|
|
2360
2474
|
});
|
|
2361
2475
|
};
|
|
2476
|
+
const setupSignalSubscription = () => {
|
|
2477
|
+
state.unsubscribeSignal = sessionSignal.listen(() => {
|
|
2478
|
+
fetchSession();
|
|
2479
|
+
});
|
|
2480
|
+
};
|
|
2362
2481
|
const init = () => {
|
|
2482
|
+
if (state.isInitialized) return;
|
|
2483
|
+
state.isInitialized = true;
|
|
2363
2484
|
setupPolling();
|
|
2364
2485
|
setupBroadcast();
|
|
2365
2486
|
setupFocusRefetch();
|
|
2366
2487
|
setupOnlineRefetch();
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2488
|
+
setupSignalSubscription();
|
|
2489
|
+
state.cleanupBroadcastSetup = getGlobalBroadcastChannel().setup();
|
|
2490
|
+
state.cleanupFocusSetup = getGlobalFocusManager().setup();
|
|
2491
|
+
state.cleanupOnlineSetup = getGlobalOnlineManager().setup();
|
|
2370
2492
|
};
|
|
2371
2493
|
const cleanup = () => {
|
|
2494
|
+
if (!state.isInitialized) return;
|
|
2372
2495
|
if (state.pollInterval) {
|
|
2373
2496
|
clearInterval(state.pollInterval);
|
|
2374
2497
|
state.pollInterval = void 0;
|
|
@@ -2385,9 +2508,24 @@ function createSessionRefreshManager(opts) {
|
|
|
2385
2508
|
state.unsubscribeOnline();
|
|
2386
2509
|
state.unsubscribeOnline = void 0;
|
|
2387
2510
|
}
|
|
2388
|
-
state.
|
|
2511
|
+
if (state.unsubscribeSignal) {
|
|
2512
|
+
state.unsubscribeSignal();
|
|
2513
|
+
state.unsubscribeSignal = void 0;
|
|
2514
|
+
}
|
|
2515
|
+
if (state.cleanupBroadcastSetup) {
|
|
2516
|
+
state.cleanupBroadcastSetup();
|
|
2517
|
+
state.cleanupBroadcastSetup = void 0;
|
|
2518
|
+
}
|
|
2519
|
+
if (state.cleanupFocusSetup) {
|
|
2520
|
+
state.cleanupFocusSetup();
|
|
2521
|
+
state.cleanupFocusSetup = void 0;
|
|
2522
|
+
}
|
|
2523
|
+
if (state.cleanupOnlineSetup) {
|
|
2524
|
+
state.cleanupOnlineSetup();
|
|
2525
|
+
state.cleanupOnlineSetup = void 0;
|
|
2526
|
+
}
|
|
2527
|
+
state.isInitialized = false;
|
|
2389
2528
|
state.lastSessionRequest = 0;
|
|
2390
|
-
state.cachedSession = void 0;
|
|
2391
2529
|
};
|
|
2392
2530
|
return {
|
|
2393
2531
|
init,
|
|
@@ -2397,144 +2535,12 @@ function createSessionRefreshManager(opts) {
|
|
|
2397
2535
|
};
|
|
2398
2536
|
}
|
|
2399
2537
|
//#endregion
|
|
2400
|
-
//#region ../../node_modules/.pnpm
|
|
2401
|
-
const _envShim = Object.create(null);
|
|
2402
|
-
const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
|
|
2403
|
-
const env = new Proxy(_envShim, {
|
|
2404
|
-
get(_, prop) {
|
|
2405
|
-
return _getEnv()[prop] ?? _envShim[prop];
|
|
2406
|
-
},
|
|
2407
|
-
has(_, prop) {
|
|
2408
|
-
return prop in _getEnv() || prop in _envShim;
|
|
2409
|
-
},
|
|
2410
|
-
set(_, prop, value) {
|
|
2411
|
-
const env = _getEnv(true);
|
|
2412
|
-
env[prop] = value;
|
|
2413
|
-
return true;
|
|
2414
|
-
},
|
|
2415
|
-
deleteProperty(_, prop) {
|
|
2416
|
-
if (!prop) return false;
|
|
2417
|
-
const env = _getEnv(true);
|
|
2418
|
-
delete env[prop];
|
|
2419
|
-
return true;
|
|
2420
|
-
},
|
|
2421
|
-
ownKeys() {
|
|
2422
|
-
const env = _getEnv(true);
|
|
2423
|
-
return Object.keys(env);
|
|
2424
|
-
}
|
|
2425
|
-
});
|
|
2426
|
-
typeof process !== "undefined" && process.env && process.env.NODE_ENV;
|
|
2427
|
-
/**
|
|
2428
|
-
* Get environment variable with fallback
|
|
2429
|
-
*/
|
|
2430
|
-
function getEnvVar(key, fallback) {
|
|
2431
|
-
if (typeof process !== "undefined" && process.env) return process.env[key] ?? fallback;
|
|
2432
|
-
if (typeof Deno !== "undefined") return Deno.env.get(key) ?? fallback;
|
|
2433
|
-
if (typeof Bun !== "undefined") return Bun.env[key] ?? fallback;
|
|
2434
|
-
return fallback;
|
|
2435
|
-
}
|
|
2436
|
-
Object.freeze({
|
|
2437
|
-
get BETTER_AUTH_SECRET() {
|
|
2438
|
-
return getEnvVar("BETTER_AUTH_SECRET");
|
|
2439
|
-
},
|
|
2440
|
-
get AUTH_SECRET() {
|
|
2441
|
-
return getEnvVar("AUTH_SECRET");
|
|
2442
|
-
},
|
|
2443
|
-
get BETTER_AUTH_TELEMETRY() {
|
|
2444
|
-
return getEnvVar("BETTER_AUTH_TELEMETRY");
|
|
2445
|
-
},
|
|
2446
|
-
get BETTER_AUTH_TELEMETRY_ID() {
|
|
2447
|
-
return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
|
|
2448
|
-
},
|
|
2449
|
-
get NODE_ENV() {
|
|
2450
|
-
return getEnvVar("NODE_ENV", "development");
|
|
2451
|
-
},
|
|
2452
|
-
get PACKAGE_VERSION() {
|
|
2453
|
-
return getEnvVar("PACKAGE_VERSION", "0.0.0");
|
|
2454
|
-
},
|
|
2455
|
-
get BETTER_AUTH_TELEMETRY_ENDPOINT() {
|
|
2456
|
-
return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
|
|
2457
|
-
}
|
|
2458
|
-
});
|
|
2459
|
-
//#endregion
|
|
2460
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/utils/url.mjs
|
|
2461
|
-
function checkHasPath(url) {
|
|
2462
|
-
try {
|
|
2463
|
-
return (new URL(url).pathname.replace(/\/+$/, "") || "/") !== "/";
|
|
2464
|
-
} catch {
|
|
2465
|
-
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
function assertHasProtocol(url) {
|
|
2469
|
-
try {
|
|
2470
|
-
const parsedUrl = new URL(url);
|
|
2471
|
-
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
|
|
2472
|
-
} catch (error) {
|
|
2473
|
-
if (error instanceof BetterAuthError) throw error;
|
|
2474
|
-
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
function withPath(url, path = "/api/auth") {
|
|
2478
|
-
assertHasProtocol(url);
|
|
2479
|
-
if (checkHasPath(url)) return url;
|
|
2480
|
-
const trimmedUrl = url.replace(/\/+$/, "");
|
|
2481
|
-
if (!path || path === "/") return trimmedUrl;
|
|
2482
|
-
path = path.startsWith("/") ? path : `/${path}`;
|
|
2483
|
-
return `${trimmedUrl}${path}`;
|
|
2484
|
-
}
|
|
2485
|
-
function validateProxyHeader(header, type) {
|
|
2486
|
-
if (!header || header.trim() === "") return false;
|
|
2487
|
-
if (type === "proto") return header === "http" || header === "https";
|
|
2488
|
-
if (type === "host") {
|
|
2489
|
-
if ([
|
|
2490
|
-
/\.\./,
|
|
2491
|
-
/\0/,
|
|
2492
|
-
/[\s]/,
|
|
2493
|
-
/^[.]/,
|
|
2494
|
-
/[<>'"]/,
|
|
2495
|
-
/javascript:/i,
|
|
2496
|
-
/file:/i,
|
|
2497
|
-
/data:/i
|
|
2498
|
-
].some((pattern) => pattern.test(header))) return false;
|
|
2499
|
-
return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
|
|
2500
|
-
}
|
|
2501
|
-
return false;
|
|
2502
|
-
}
|
|
2503
|
-
function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
|
|
2504
|
-
if (url) return withPath(url, path);
|
|
2505
|
-
if (loadEnv !== false) {
|
|
2506
|
-
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
2507
|
-
if (fromEnv) return withPath(fromEnv, path);
|
|
2508
|
-
}
|
|
2509
|
-
const fromRequest = request?.headers.get("x-forwarded-host");
|
|
2510
|
-
const fromRequestProto = request?.headers.get("x-forwarded-proto");
|
|
2511
|
-
if (fromRequest && fromRequestProto && trustedProxyHeaders) {
|
|
2512
|
-
if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
|
|
2513
|
-
return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
2514
|
-
} catch (_error) {}
|
|
2515
|
-
}
|
|
2516
|
-
if (request) {
|
|
2517
|
-
const url = getOrigin(request.url);
|
|
2518
|
-
if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
2519
|
-
return withPath(url, path);
|
|
2520
|
-
}
|
|
2521
|
-
if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
|
|
2522
|
-
}
|
|
2523
|
-
function getOrigin(url) {
|
|
2524
|
-
try {
|
|
2525
|
-
const parsedUrl = new URL(url);
|
|
2526
|
-
return parsedUrl.origin === "null" ? null : parsedUrl.origin;
|
|
2527
|
-
} catch {
|
|
2528
|
-
return null;
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
//#endregion
|
|
2532
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
2538
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
2533
2539
|
const redirectPlugin = {
|
|
2534
2540
|
id: "redirect",
|
|
2535
2541
|
name: "Redirect",
|
|
2536
2542
|
hooks: { onSuccess(context) {
|
|
2537
|
-
if (context.data?.url && context.data?.redirect) {
|
|
2543
|
+
if (context.data?.url && context.data?.redirect && isSafeUrlScheme(context.data.url)) {
|
|
2538
2544
|
if (typeof window !== "undefined" && window.location) {
|
|
2539
2545
|
if (window.location) try {
|
|
2540
2546
|
window.location.href = context.data.url;
|
|
@@ -2544,21 +2550,146 @@ const redirectPlugin = {
|
|
|
2544
2550
|
} }
|
|
2545
2551
|
};
|
|
2546
2552
|
//#endregion
|
|
2547
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
2553
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/session-atom.mjs
|
|
2554
|
+
const isServer = () => typeof window === "undefined";
|
|
2555
|
+
/**
|
|
2556
|
+
* Normalize $fetch response: `throw: true` returns data directly,
|
|
2557
|
+
* otherwise `{ data, error }`.
|
|
2558
|
+
*/
|
|
2559
|
+
function normalizeSessionResponse(res) {
|
|
2560
|
+
if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
|
|
2561
|
+
return {
|
|
2562
|
+
data: res,
|
|
2563
|
+
error: null
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
function normalizeSessionData(data) {
|
|
2567
|
+
if (!data) return null;
|
|
2568
|
+
if (data.session === null && data.user === null) return null;
|
|
2569
|
+
return data;
|
|
2570
|
+
}
|
|
2571
|
+
function isSessionAtomEqual(a, b) {
|
|
2572
|
+
return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
|
|
2573
|
+
}
|
|
2548
2574
|
function getSessionAtom($fetch, options) {
|
|
2549
2575
|
const $signal = /* @__PURE__ */ atom(false);
|
|
2550
|
-
|
|
2576
|
+
let abortController;
|
|
2577
|
+
const refetch = (queryParams) => fetchSession(queryParams);
|
|
2578
|
+
const session = /* @__PURE__ */ atom({
|
|
2579
|
+
data: null,
|
|
2580
|
+
error: null,
|
|
2581
|
+
isPending: true,
|
|
2582
|
+
isRefetching: false,
|
|
2583
|
+
refetch
|
|
2584
|
+
});
|
|
2585
|
+
withEquality(session, isSessionAtomEqual);
|
|
2586
|
+
const settleAbortedFetch = (controller) => {
|
|
2587
|
+
if (abortController !== controller) return;
|
|
2588
|
+
const current = session.get();
|
|
2589
|
+
abortController = void 0;
|
|
2590
|
+
if (!current.isPending && !current.isRefetching) return;
|
|
2591
|
+
session.set({
|
|
2592
|
+
...current,
|
|
2593
|
+
isPending: false,
|
|
2594
|
+
isRefetching: false,
|
|
2595
|
+
refetch
|
|
2596
|
+
});
|
|
2597
|
+
};
|
|
2598
|
+
const fetchSession = async (queryParams) => {
|
|
2599
|
+
abortController?.abort();
|
|
2600
|
+
const controller = new AbortController();
|
|
2601
|
+
abortController = controller;
|
|
2602
|
+
const current = session.get();
|
|
2603
|
+
session.set({
|
|
2604
|
+
...current,
|
|
2605
|
+
isPending: current.data === null,
|
|
2606
|
+
isRefetching: true,
|
|
2607
|
+
error: null,
|
|
2608
|
+
refetch
|
|
2609
|
+
});
|
|
2610
|
+
try {
|
|
2611
|
+
const res = await $fetch("/get-session", {
|
|
2612
|
+
method: "GET",
|
|
2613
|
+
query: queryParams?.query,
|
|
2614
|
+
signal: controller.signal
|
|
2615
|
+
});
|
|
2616
|
+
if (controller.signal.aborted) {
|
|
2617
|
+
settleAbortedFetch(controller);
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2620
|
+
let { data, error } = normalizeSessionResponse(res);
|
|
2621
|
+
if (data?.needsRefresh) try {
|
|
2622
|
+
const refreshRes = await $fetch("/get-session", {
|
|
2623
|
+
method: "POST",
|
|
2624
|
+
signal: controller.signal
|
|
2625
|
+
});
|
|
2626
|
+
if (controller.signal.aborted) {
|
|
2627
|
+
settleAbortedFetch(controller);
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
({data, error} = normalizeSessionResponse(refreshRes));
|
|
2631
|
+
} catch {
|
|
2632
|
+
if (controller.signal.aborted) {
|
|
2633
|
+
settleAbortedFetch(controller);
|
|
2634
|
+
return;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
if (error) {
|
|
2638
|
+
const latest = session.get();
|
|
2639
|
+
const isUnauthorized = error?.status === 401;
|
|
2640
|
+
session.set({
|
|
2641
|
+
data: isUnauthorized ? null : latest.data,
|
|
2642
|
+
error,
|
|
2643
|
+
isPending: false,
|
|
2644
|
+
isRefetching: false,
|
|
2645
|
+
refetch
|
|
2646
|
+
});
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2649
|
+
const sessionData = normalizeSessionData(data);
|
|
2650
|
+
const current = session.get();
|
|
2651
|
+
const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
|
|
2652
|
+
session.set({
|
|
2653
|
+
data: stableData,
|
|
2654
|
+
error: null,
|
|
2655
|
+
isPending: false,
|
|
2656
|
+
isRefetching: false,
|
|
2657
|
+
refetch
|
|
2658
|
+
});
|
|
2659
|
+
} catch (fetchError) {
|
|
2660
|
+
if (controller.signal.aborted) {
|
|
2661
|
+
settleAbortedFetch(controller);
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
const latest = session.get();
|
|
2665
|
+
session.set({
|
|
2666
|
+
data: latest.data,
|
|
2667
|
+
error: fetchError,
|
|
2668
|
+
isPending: false,
|
|
2669
|
+
isRefetching: false,
|
|
2670
|
+
refetch
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
};
|
|
2551
2674
|
let broadcastSessionUpdate = () => {};
|
|
2552
2675
|
onMount(session, () => {
|
|
2676
|
+
let timeoutId;
|
|
2677
|
+
if (!isServer()) timeoutId = setTimeout(() => {
|
|
2678
|
+
fetchSession();
|
|
2679
|
+
}, 0);
|
|
2553
2680
|
const refreshManager = createSessionRefreshManager({
|
|
2554
|
-
|
|
2681
|
+
fetchSession,
|
|
2682
|
+
shouldPollSession: () => session.get().data != null,
|
|
2555
2683
|
sessionSignal: $signal,
|
|
2556
|
-
$fetch,
|
|
2557
2684
|
options
|
|
2558
2685
|
});
|
|
2559
2686
|
refreshManager.init();
|
|
2560
2687
|
broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
|
|
2561
2688
|
return () => {
|
|
2689
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
2690
|
+
const controller = abortController;
|
|
2691
|
+
controller?.abort();
|
|
2692
|
+
if (controller) settleAbortedFetch(controller);
|
|
2562
2693
|
refreshManager.cleanup();
|
|
2563
2694
|
};
|
|
2564
2695
|
});
|
|
@@ -2597,7 +2728,7 @@ function createDefu(merger) {
|
|
|
2597
2728
|
}
|
|
2598
2729
|
const defu = createDefu();
|
|
2599
2730
|
//#endregion
|
|
2600
|
-
//#region ../../node_modules/.pnpm/@better-fetch+fetch@1.1
|
|
2731
|
+
//#region ../../node_modules/.pnpm/@better-fetch+fetch@1.3.1/node_modules/@better-fetch/fetch/dist/index.js
|
|
2601
2732
|
var __defProp = Object.defineProperty;
|
|
2602
2733
|
var __defProps = Object.defineProperties;
|
|
2603
2734
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -2764,13 +2895,25 @@ function getFetch(options) {
|
|
|
2764
2895
|
if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
|
|
2765
2896
|
throw new Error("No fetch implementation found");
|
|
2766
2897
|
}
|
|
2898
|
+
function mergeHeaders(...sources) {
|
|
2899
|
+
const merged = {};
|
|
2900
|
+
for (const source of sources) {
|
|
2901
|
+
if (!source) continue;
|
|
2902
|
+
if (source instanceof Headers) source.forEach((value, key) => {
|
|
2903
|
+
merged[key] = value;
|
|
2904
|
+
});
|
|
2905
|
+
else {
|
|
2906
|
+
const entries = Array.isArray(source) ? source : Object.entries(source);
|
|
2907
|
+
for (const [key, value] of entries) if (value !== null && value !== void 0) merged[key] = value;
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
return merged;
|
|
2911
|
+
}
|
|
2767
2912
|
async function getHeaders(opts) {
|
|
2768
|
-
const headers = new Headers(opts == null ? void 0 : opts.headers);
|
|
2769
|
-
const authHeader = await getAuthHeader(opts);
|
|
2770
|
-
for (const [key, value] of Object.entries(authHeader || {})) headers.set(key, value);
|
|
2913
|
+
const headers = new Headers(mergeHeaders(opts == null ? void 0 : opts.headers, await getAuthHeader(opts)));
|
|
2771
2914
|
if (!headers.has("content-type")) {
|
|
2772
|
-
const
|
|
2773
|
-
if (
|
|
2915
|
+
const contentType = detectContentType(opts == null ? void 0 : opts.body);
|
|
2916
|
+
if (contentType) headers.set("content-type", contentType);
|
|
2774
2917
|
}
|
|
2775
2918
|
return headers;
|
|
2776
2919
|
}
|
|
@@ -2778,18 +2921,17 @@ function detectContentType(body) {
|
|
|
2778
2921
|
if (isJSONSerializable(body)) return "application/json";
|
|
2779
2922
|
return null;
|
|
2780
2923
|
}
|
|
2781
|
-
function
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
if (
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
return options.body;
|
|
2924
|
+
function getMediaType(headers) {
|
|
2925
|
+
const contentType = headers.get("content-type");
|
|
2926
|
+
return contentType ? contentType.split(";")[0].trim().toLowerCase() : null;
|
|
2927
|
+
}
|
|
2928
|
+
function getBody(options, headers) {
|
|
2929
|
+
const { body } = options;
|
|
2930
|
+
if (!body) return null;
|
|
2931
|
+
if (!isJSONSerializable(body)) return body;
|
|
2932
|
+
if (typeof body === "string") return body;
|
|
2933
|
+
if (getMediaType(headers) === "application/x-www-form-urlencoded") return new URLSearchParams(body).toString();
|
|
2934
|
+
return JSON.stringify(body);
|
|
2793
2935
|
}
|
|
2794
2936
|
function getMethod$1(url, options) {
|
|
2795
2937
|
var _a;
|
|
@@ -2851,11 +2993,29 @@ var applySchemaPlugin = (config) => ({
|
|
|
2851
2993
|
if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
|
|
2852
2994
|
if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
|
|
2853
2995
|
}
|
|
2996
|
+
if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
|
|
2854
2997
|
const keySchema = schema.schema[urlKey];
|
|
2855
2998
|
if (keySchema) {
|
|
2999
|
+
let validatedHeaders = options == null ? void 0 : options.headers;
|
|
3000
|
+
if (keySchema.headers && !(options == null ? void 0 : options.disableValidation)) {
|
|
3001
|
+
const normalizedHeaders = {};
|
|
3002
|
+
if (options == null ? void 0 : options.headers) {
|
|
3003
|
+
if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
|
|
3004
|
+
normalizedHeaders[key.toLowerCase()] = value;
|
|
3005
|
+
});
|
|
3006
|
+
else if (typeof options.headers === "object") {
|
|
3007
|
+
for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
|
|
3011
|
+
const finalHeaders = {};
|
|
3012
|
+
for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
|
|
3013
|
+
validatedHeaders = finalHeaders;
|
|
3014
|
+
}
|
|
2856
3015
|
let opts = __spreadProps(__spreadValues({}, options), {
|
|
2857
3016
|
method: keySchema.method,
|
|
2858
|
-
output: keySchema.output
|
|
3017
|
+
output: keySchema.output,
|
|
3018
|
+
headers: validatedHeaders
|
|
2859
3019
|
});
|
|
2860
3020
|
if (!(options == null ? void 0 : options.disableValidation)) opts = __spreadProps(__spreadValues({}, opts), {
|
|
2861
3021
|
body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
|
|
@@ -2876,11 +3036,14 @@ var applySchemaPlugin = (config) => ({
|
|
|
2876
3036
|
});
|
|
2877
3037
|
var createFetch = (config) => {
|
|
2878
3038
|
async function $fetch(url, options) {
|
|
2879
|
-
const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
3039
|
+
const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
|
|
3040
|
+
headers: mergeHeaders(config == null ? void 0 : config.headers, options == null ? void 0 : options.headers),
|
|
3041
|
+
plugins: [
|
|
3042
|
+
...(config == null ? void 0 : config.plugins) || [],
|
|
3043
|
+
applySchemaPlugin(config || {}),
|
|
3044
|
+
...(options == null ? void 0 : options.plugins) || []
|
|
3045
|
+
]
|
|
3046
|
+
});
|
|
2884
3047
|
if (config == null ? void 0 : config.catchAllError) try {
|
|
2885
3048
|
return await betterFetch(url, opts);
|
|
2886
3049
|
} catch (error) {
|
|
@@ -2898,6 +3061,13 @@ var createFetch = (config) => {
|
|
|
2898
3061
|
}
|
|
2899
3062
|
return $fetch;
|
|
2900
3063
|
};
|
|
3064
|
+
var isReservedPathSegment = (value) => value === "." || value === "..";
|
|
3065
|
+
function encodePathSegment(segment, pathParams) {
|
|
3066
|
+
let pathSegment = segment;
|
|
3067
|
+
for (const [key, value] of pathParams) pathSegment = pathSegment.replace(key, value);
|
|
3068
|
+
if (isReservedPathSegment(pathSegment)) throw new TypeError("Path parameters cannot be reserved path segments");
|
|
3069
|
+
return encodeURIComponent(pathSegment);
|
|
3070
|
+
}
|
|
2901
3071
|
function getURL2(url, option) {
|
|
2902
3072
|
const { baseURL, params, query } = option || {
|
|
2903
3073
|
query: {},
|
|
@@ -2922,15 +3092,16 @@ function getURL2(url, option) {
|
|
|
2922
3092
|
} else serializedValue = JSON.stringify(value);
|
|
2923
3093
|
queryParams.set(key, serializedValue);
|
|
2924
3094
|
}
|
|
3095
|
+
const pathParams = /* @__PURE__ */ new Map();
|
|
2925
3096
|
if (params) if (Array.isArray(params)) {
|
|
2926
3097
|
const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
|
|
2927
3098
|
for (const [index, key] of paramPaths.entries()) {
|
|
2928
3099
|
const value = params[index];
|
|
2929
|
-
|
|
3100
|
+
pathParams.set(key, String(value));
|
|
2930
3101
|
}
|
|
2931
|
-
} else for (const [key, value] of Object.entries(params))
|
|
2932
|
-
path = path.split("/").map(
|
|
2933
|
-
|
|
3102
|
+
} else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
|
|
3103
|
+
path = path.split("/").map((segment) => encodePathSegment(segment, pathParams)).join("/");
|
|
3104
|
+
path = path.replace(/^\/+/, "");
|
|
2934
3105
|
let queryParamString = queryParams.toString();
|
|
2935
3106
|
queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
|
|
2936
3107
|
if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
|
|
@@ -2943,10 +3114,10 @@ var betterFetch = async (url, options) => {
|
|
|
2943
3114
|
const controller = new AbortController();
|
|
2944
3115
|
const signal = (_a = opts.signal) != null ? _a : controller.signal;
|
|
2945
3116
|
const _url = getURL2(__url, opts);
|
|
2946
|
-
const body = getBody(opts);
|
|
2947
3117
|
const headers = await getHeaders(opts);
|
|
3118
|
+
const body = getBody(opts, headers);
|
|
2948
3119
|
const method = getMethod$1(__url, opts);
|
|
2949
|
-
|
|
3120
|
+
const context = __spreadProps(__spreadValues({}, opts), {
|
|
2950
3121
|
url: _url,
|
|
2951
3122
|
headers,
|
|
2952
3123
|
body,
|
|
@@ -2955,7 +3126,7 @@ var betterFetch = async (url, options) => {
|
|
|
2955
3126
|
});
|
|
2956
3127
|
for (const onRequest of hooks.onRequest) if (onRequest) {
|
|
2957
3128
|
const res = await onRequest(context);
|
|
2958
|
-
if (typeof res === "object" && res !== null) context
|
|
3129
|
+
if (typeof res === "object" && res !== null) Object.assign(context, res);
|
|
2959
3130
|
}
|
|
2960
3131
|
if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
|
|
2961
3132
|
if (!("duplex" in context)) context.duplex = "half";
|
|
@@ -3031,7 +3202,7 @@ var betterFetch = async (url, options) => {
|
|
|
3031
3202
|
};
|
|
3032
3203
|
};
|
|
3033
3204
|
//#endregion
|
|
3034
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
3205
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/config.mjs
|
|
3035
3206
|
const resolvePublicAuthUrl = (basePath) => {
|
|
3036
3207
|
if (typeof process === "undefined") return void 0;
|
|
3037
3208
|
const path = basePath ?? "/api/auth";
|
|
@@ -3129,12 +3300,25 @@ const getClientConfig = (options, loadEnv) => {
|
|
|
3129
3300
|
};
|
|
3130
3301
|
};
|
|
3131
3302
|
//#endregion
|
|
3132
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.
|
|
3303
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
3133
3304
|
function isAtom(value) {
|
|
3134
3305
|
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
3135
3306
|
}
|
|
3136
3307
|
//#endregion
|
|
3137
|
-
//#region ../../node_modules/.pnpm
|
|
3308
|
+
//#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/utils/string.mjs
|
|
3309
|
+
function capitalizeFirstLetter(str) {
|
|
3310
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3311
|
+
}
|
|
3312
|
+
const WORD_PATTERN = /[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu;
|
|
3313
|
+
const APOSTROPHE_PATTERN = /['\u2019]/g;
|
|
3314
|
+
function splitWords(input) {
|
|
3315
|
+
return input.replace(APOSTROPHE_PATTERN, "").match(WORD_PATTERN) ?? [];
|
|
3316
|
+
}
|
|
3317
|
+
function toKebabCase(input) {
|
|
3318
|
+
return splitWords(input).map((word) => word.toLowerCase()).join("-");
|
|
3319
|
+
}
|
|
3320
|
+
//#endregion
|
|
3321
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/proxy.mjs
|
|
3138
3322
|
function getMethod(path, knownPathMethods, args) {
|
|
3139
3323
|
const method = knownPathMethods[path];
|
|
3140
3324
|
const { fetchOptions, query: _query, ...body } = args || {};
|
|
@@ -3161,7 +3345,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
3161
3345
|
return createProxy(fullPath);
|
|
3162
3346
|
},
|
|
3163
3347
|
apply: async (_, __, args) => {
|
|
3164
|
-
const routePath = "/" + path.map(
|
|
3348
|
+
const routePath = "/" + path.map(toKebabCase).join("/");
|
|
3165
3349
|
const arg = args[0] || {};
|
|
3166
3350
|
const fetchOptions = args[1] || {};
|
|
3167
3351
|
const { query, fetchOptions: argFetchOptions, ...body } = arg;
|
|
@@ -3209,12 +3393,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
3209
3393
|
return createProxy();
|
|
3210
3394
|
}
|
|
3211
3395
|
//#endregion
|
|
3212
|
-
//#region ../../node_modules/.pnpm
|
|
3213
|
-
function capitalizeFirstLetter(str) {
|
|
3214
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3215
|
-
}
|
|
3216
|
-
//#endregion
|
|
3217
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/vanilla.mjs
|
|
3396
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/vanilla.mjs
|
|
3218
3397
|
function createAuthClient(options) {
|
|
3219
3398
|
const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
3220
3399
|
const resolvedHooks = {};
|