@erikey/react 0.2.4 → 0.2.6

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/index.mjs CHANGED
@@ -1,1621 +1,16 @@
1
- import * as __injected_react__ from "react";import * as __injected_react_dom__ from "react-dom";const require = (m) => { if (m === "react") return __injected_react__; if (m === "react-dom") return __injected_react_dom__; throw new Error("Dynamic require of " + m + " is not supported"); };
2
- import "./chunk-4KG3L2KQ.mjs";
3
-
4
- // ../../../node_modules/.pnpm/@better-fetch+fetch@1.1.18/node_modules/@better-fetch/fetch/dist/index.js
5
- var __defProp = Object.defineProperty;
6
- var __defProps = Object.defineProperties;
7
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var BetterFetchError = class extends Error {
25
- constructor(status, statusText, error) {
26
- super(statusText || status.toString(), {
27
- cause: error
28
- });
29
- this.status = status;
30
- this.statusText = statusText;
31
- this.error = error;
32
- }
33
- };
34
- var initializePlugins = async (url, options) => {
35
- var _a, _b, _c, _d, _e, _f;
36
- let opts = options || {};
37
- const hooks = {
38
- onRequest: [options == null ? void 0 : options.onRequest],
39
- onResponse: [options == null ? void 0 : options.onResponse],
40
- onSuccess: [options == null ? void 0 : options.onSuccess],
41
- onError: [options == null ? void 0 : options.onError],
42
- onRetry: [options == null ? void 0 : options.onRetry]
43
- };
44
- if (!options || !(options == null ? void 0 : options.plugins)) {
45
- return {
46
- url,
47
- options: opts,
48
- hooks
49
- };
50
- }
51
- for (const plugin of (options == null ? void 0 : options.plugins) || []) {
52
- if (plugin.init) {
53
- const pluginRes = await ((_a = plugin.init) == null ? void 0 : _a.call(plugin, url.toString(), options));
54
- opts = pluginRes.options || opts;
55
- url = pluginRes.url;
56
- }
57
- hooks.onRequest.push((_b = plugin.hooks) == null ? void 0 : _b.onRequest);
58
- hooks.onResponse.push((_c = plugin.hooks) == null ? void 0 : _c.onResponse);
59
- hooks.onSuccess.push((_d = plugin.hooks) == null ? void 0 : _d.onSuccess);
60
- hooks.onError.push((_e = plugin.hooks) == null ? void 0 : _e.onError);
61
- hooks.onRetry.push((_f = plugin.hooks) == null ? void 0 : _f.onRetry);
62
- }
63
- return {
64
- url,
65
- options: opts,
66
- hooks
67
- };
68
- };
69
- var LinearRetryStrategy = class {
70
- constructor(options) {
71
- this.options = options;
72
- }
73
- shouldAttemptRetry(attempt, response) {
74
- if (this.options.shouldRetry) {
75
- return Promise.resolve(
76
- attempt < this.options.attempts && this.options.shouldRetry(response)
77
- );
78
- }
79
- return Promise.resolve(attempt < this.options.attempts);
80
- }
81
- getDelay() {
82
- return this.options.delay;
83
- }
84
- };
85
- var ExponentialRetryStrategy = class {
86
- constructor(options) {
87
- this.options = options;
88
- }
89
- shouldAttemptRetry(attempt, response) {
90
- if (this.options.shouldRetry) {
91
- return Promise.resolve(
92
- attempt < this.options.attempts && this.options.shouldRetry(response)
93
- );
94
- }
95
- return Promise.resolve(attempt < this.options.attempts);
96
- }
97
- getDelay(attempt) {
98
- const delay = Math.min(
99
- this.options.maxDelay,
100
- this.options.baseDelay * 2 ** attempt
101
- );
102
- return delay;
103
- }
104
- };
105
- function createRetryStrategy(options) {
106
- if (typeof options === "number") {
107
- return new LinearRetryStrategy({
108
- type: "linear",
109
- attempts: options,
110
- delay: 1e3
111
- });
112
- }
113
- switch (options.type) {
114
- case "linear":
115
- return new LinearRetryStrategy(options);
116
- case "exponential":
117
- return new ExponentialRetryStrategy(options);
118
- default:
119
- throw new Error("Invalid retry strategy");
120
- }
121
- }
122
- var getAuthHeader = async (options) => {
123
- const headers = {};
124
- const getValue = async (value) => typeof value === "function" ? await value() : value;
125
- if (options == null ? void 0 : options.auth) {
126
- if (options.auth.type === "Bearer") {
127
- const token = await getValue(options.auth.token);
128
- if (!token) {
129
- return headers;
130
- }
131
- headers["authorization"] = `Bearer ${token}`;
132
- } else if (options.auth.type === "Basic") {
133
- const username = getValue(options.auth.username);
134
- const password = getValue(options.auth.password);
135
- if (!username || !password) {
136
- return headers;
137
- }
138
- headers["authorization"] = `Basic ${btoa(`${username}:${password}`)}`;
139
- } else if (options.auth.type === "Custom") {
140
- const value = getValue(options.auth.value);
141
- if (!value) {
142
- return headers;
143
- }
144
- headers["authorization"] = `${getValue(options.auth.prefix)} ${value}`;
145
- }
146
- }
147
- return headers;
148
- };
149
- var JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
150
- function detectResponseType(request) {
151
- const _contentType = request.headers.get("content-type");
152
- const textTypes = /* @__PURE__ */ new Set([
153
- "image/svg",
154
- "application/xml",
155
- "application/xhtml",
156
- "application/html"
157
- ]);
158
- if (!_contentType) {
159
- return "json";
160
- }
161
- const contentType = _contentType.split(";").shift() || "";
162
- if (JSON_RE.test(contentType)) {
163
- return "json";
164
- }
165
- if (textTypes.has(contentType) || contentType.startsWith("text/")) {
166
- return "text";
167
- }
168
- return "blob";
169
- }
170
- function isJSONParsable(value) {
171
- try {
172
- JSON.parse(value);
173
- return true;
174
- } catch (error) {
175
- return false;
176
- }
177
- }
178
- function isJSONSerializable(value) {
179
- if (value === void 0) {
180
- return false;
181
- }
182
- const t = typeof value;
183
- if (t === "string" || t === "number" || t === "boolean" || t === null) {
184
- return true;
185
- }
186
- if (t !== "object") {
187
- return false;
188
- }
189
- if (Array.isArray(value)) {
190
- return true;
191
- }
192
- if (value.buffer) {
193
- return false;
194
- }
195
- return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
196
- }
197
- function jsonParse(text) {
198
- try {
199
- return JSON.parse(text);
200
- } catch (error) {
201
- return text;
202
- }
203
- }
204
- function isFunction(value) {
205
- return typeof value === "function";
206
- }
207
- function getFetch(options) {
208
- if (options == null ? void 0 : options.customFetchImpl) {
209
- return options.customFetchImpl;
210
- }
211
- if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) {
212
- return globalThis.fetch;
213
- }
214
- if (typeof window !== "undefined" && isFunction(window.fetch)) {
215
- return window.fetch;
216
- }
217
- throw new Error("No fetch implementation found");
218
- }
219
- async function getHeaders(opts) {
220
- const headers = new Headers(opts == null ? void 0 : opts.headers);
221
- const authHeader = await getAuthHeader(opts);
222
- for (const [key, value] of Object.entries(authHeader || {})) {
223
- headers.set(key, value);
224
- }
225
- if (!headers.has("content-type")) {
226
- const t = detectContentType(opts == null ? void 0 : opts.body);
227
- if (t) {
228
- headers.set("content-type", t);
229
- }
230
- }
231
- return headers;
232
- }
233
- function detectContentType(body) {
234
- if (isJSONSerializable(body)) {
235
- return "application/json";
236
- }
237
- return null;
238
- }
239
- function getBody(options) {
240
- if (!(options == null ? void 0 : options.body)) {
241
- return null;
242
- }
243
- const headers = new Headers(options == null ? void 0 : options.headers);
244
- if (isJSONSerializable(options.body) && !headers.has("content-type")) {
245
- for (const [key, value] of Object.entries(options == null ? void 0 : options.body)) {
246
- if (value instanceof Date) {
247
- options.body[key] = value.toISOString();
248
- }
249
- }
250
- return JSON.stringify(options.body);
251
- }
252
- return options.body;
253
- }
254
- function getMethod(url, options) {
255
- var _a;
256
- if (options == null ? void 0 : options.method) {
257
- return options.method.toUpperCase();
258
- }
259
- if (url.startsWith("@")) {
260
- const pMethod = (_a = url.split("@")[1]) == null ? void 0 : _a.split("/")[0];
261
- if (!methods.includes(pMethod)) {
262
- return (options == null ? void 0 : options.body) ? "POST" : "GET";
263
- }
264
- return pMethod.toUpperCase();
265
- }
266
- return (options == null ? void 0 : options.body) ? "POST" : "GET";
267
- }
268
- function getTimeout(options, controller) {
269
- let abortTimeout;
270
- if (!(options == null ? void 0 : options.signal) && (options == null ? void 0 : options.timeout)) {
271
- abortTimeout = setTimeout(() => controller == null ? void 0 : controller.abort(), options == null ? void 0 : options.timeout);
272
- }
273
- return {
274
- abortTimeout,
275
- clearTimeout: () => {
276
- if (abortTimeout) {
277
- clearTimeout(abortTimeout);
278
- }
279
- }
280
- };
281
- }
282
- var ValidationError = class _ValidationError extends Error {
283
- constructor(issues, message) {
284
- super(message || JSON.stringify(issues, null, 2));
285
- this.issues = issues;
286
- Object.setPrototypeOf(this, _ValidationError.prototype);
287
- }
288
- };
289
- async function parseStandardSchema(schema, input) {
290
- let result = await schema["~standard"].validate(input);
291
- if (result.issues) {
292
- throw new ValidationError(result.issues);
293
- }
294
- return result.value;
295
- }
296
- var methods = ["get", "post", "put", "patch", "delete"];
297
- var applySchemaPlugin = (config) => ({
298
- id: "apply-schema",
299
- name: "Apply Schema",
300
- version: "1.0.0",
301
- async init(url, options) {
302
- var _a, _b, _c, _d;
303
- const schema = ((_b = (_a = config.plugins) == null ? void 0 : _a.find(
304
- (plugin) => {
305
- var _a2;
306
- return ((_a2 = plugin.schema) == null ? void 0 : _a2.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
307
- }
308
- )) == null ? void 0 : _b.schema) || config.schema;
309
- if (schema) {
310
- let urlKey = url;
311
- if ((_c = schema.config) == null ? void 0 : _c.prefix) {
312
- if (urlKey.startsWith(schema.config.prefix)) {
313
- urlKey = urlKey.replace(schema.config.prefix, "");
314
- if (schema.config.baseURL) {
315
- url = url.replace(schema.config.prefix, schema.config.baseURL);
316
- }
317
- }
318
- }
319
- if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
320
- if (urlKey.startsWith(schema.config.baseURL)) {
321
- urlKey = urlKey.replace(schema.config.baseURL, "");
322
- }
323
- }
324
- const keySchema = schema.schema[urlKey];
325
- if (keySchema) {
326
- let opts = __spreadProps(__spreadValues({}, options), {
327
- method: keySchema.method,
328
- output: keySchema.output
329
- });
330
- if (!(options == null ? void 0 : options.disableValidation)) {
331
- opts = __spreadProps(__spreadValues({}, opts), {
332
- body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
333
- params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
334
- query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
335
- });
336
- }
337
- return {
338
- url,
339
- options: opts
340
- };
341
- }
342
- }
343
- return {
344
- url,
345
- options
346
- };
347
- }
348
- });
349
- var createFetch = (config) => {
350
- async function $fetch(url, options) {
351
- const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
352
- plugins: [...(config == null ? void 0 : config.plugins) || [], applySchemaPlugin(config || {})]
353
- });
354
- if (config == null ? void 0 : config.catchAllError) {
355
- try {
356
- return await betterFetch(url, opts);
357
- } catch (error) {
358
- return {
359
- data: null,
360
- error: {
361
- status: 500,
362
- statusText: "Fetch Error",
363
- message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
364
- error
365
- }
366
- };
367
- }
368
- }
369
- return await betterFetch(url, opts);
370
- }
371
- return $fetch;
372
- };
373
- function getURL2(url, option) {
374
- let { baseURL, params, query } = option || {
375
- query: {},
376
- params: {},
377
- baseURL: ""
378
- };
379
- let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
380
- if (url.startsWith("@")) {
381
- const m = url.toString().split("@")[1].split("/")[0];
382
- if (methods.includes(m)) {
383
- url = url.replace(`@${m}/`, "/");
384
- }
385
- }
386
- if (!basePath.endsWith("/")) basePath += "/";
387
- let [path, urlQuery] = url.replace(basePath, "").split("?");
388
- const queryParams = new URLSearchParams(urlQuery);
389
- for (const [key, value] of Object.entries(query || {})) {
390
- if (value == null) continue;
391
- queryParams.set(key, String(value));
392
- }
393
- if (params) {
394
- if (Array.isArray(params)) {
395
- const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
396
- for (const [index, key] of paramPaths.entries()) {
397
- const value = params[index];
398
- path = path.replace(key, value);
399
- }
400
- } else {
401
- for (const [key, value] of Object.entries(params)) {
402
- path = path.replace(`:${key}`, String(value));
403
- }
404
- }
405
- }
406
- path = path.split("/").map(encodeURIComponent).join("/");
407
- if (path.startsWith("/")) path = path.slice(1);
408
- let queryParamString = queryParams.toString();
409
- queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
410
- if (!basePath.startsWith("http")) {
411
- return `${basePath}${path}${queryParamString}`;
412
- }
413
- const _url = new URL(`${path}${queryParamString}`, basePath);
414
- return _url;
415
- }
416
- var betterFetch = async (url, options) => {
417
- var _a, _b, _c, _d, _e, _f, _g, _h;
418
- const {
419
- hooks,
420
- url: __url,
421
- options: opts
422
- } = await initializePlugins(url, options);
423
- const fetch2 = getFetch(opts);
424
- const controller = new AbortController();
425
- const signal = (_a = opts.signal) != null ? _a : controller.signal;
426
- const _url = getURL2(__url, opts);
427
- const body = getBody(opts);
428
- const headers = await getHeaders(opts);
429
- const method = getMethod(__url, opts);
430
- let context = __spreadProps(__spreadValues({}, opts), {
431
- url: _url,
432
- headers,
433
- body,
434
- method,
435
- signal
436
- });
437
- for (const onRequest of hooks.onRequest) {
438
- if (onRequest) {
439
- const res = await onRequest(context);
440
- if (res instanceof Object) {
441
- context = res;
442
- }
443
- }
444
- }
445
- if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
446
- if (!("duplex" in context)) {
447
- context.duplex = "half";
448
- }
449
- }
450
- const { clearTimeout: clearTimeout2 } = getTimeout(opts, controller);
451
- let response = await fetch2(context.url, context);
452
- clearTimeout2();
453
- const responseContext = {
454
- response,
455
- request: context
456
- };
457
- for (const onResponse of hooks.onResponse) {
458
- if (onResponse) {
459
- const r = await onResponse(__spreadProps(__spreadValues({}, responseContext), {
460
- response: ((_c = options == null ? void 0 : options.hookOptions) == null ? void 0 : _c.cloneResponse) ? response.clone() : response
461
- }));
462
- if (r instanceof Response) {
463
- response = r;
464
- } else if (r instanceof Object) {
465
- response = r.response;
466
- }
467
- }
468
- }
469
- if (response.ok) {
470
- const hasBody = context.method !== "HEAD";
471
- if (!hasBody) {
472
- return {
473
- data: "",
474
- error: null
475
- };
476
- }
477
- const responseType = detectResponseType(response);
478
- const successContext = {
479
- data: "",
480
- response,
481
- request: context
482
- };
483
- if (responseType === "json" || responseType === "text") {
484
- const text = await response.text();
485
- const parser2 = (_d = context.jsonParser) != null ? _d : jsonParse;
486
- const data = await parser2(text);
487
- successContext.data = data;
488
- } else {
489
- successContext.data = await response[responseType]();
490
- }
491
- if (context == null ? void 0 : context.output) {
492
- if (context.output && !context.disableValidation) {
493
- successContext.data = await parseStandardSchema(
494
- context.output,
495
- successContext.data
496
- );
497
- }
498
- }
499
- for (const onSuccess of hooks.onSuccess) {
500
- if (onSuccess) {
501
- await onSuccess(__spreadProps(__spreadValues({}, successContext), {
502
- response: ((_e = options == null ? void 0 : options.hookOptions) == null ? void 0 : _e.cloneResponse) ? response.clone() : response
503
- }));
504
- }
505
- }
506
- if (options == null ? void 0 : options.throw) {
507
- return successContext.data;
508
- }
509
- return {
510
- data: successContext.data,
511
- error: null
512
- };
513
- }
514
- const parser = (_f = options == null ? void 0 : options.jsonParser) != null ? _f : jsonParse;
515
- const responseText = await response.text();
516
- const isJSONResponse = isJSONParsable(responseText);
517
- const errorObject = isJSONResponse ? await parser(responseText) : null;
518
- const errorContext = {
519
- response,
520
- responseText,
521
- request: context,
522
- error: __spreadProps(__spreadValues({}, errorObject), {
523
- status: response.status,
524
- statusText: response.statusText
525
- })
526
- };
527
- for (const onError of hooks.onError) {
528
- if (onError) {
529
- await onError(__spreadProps(__spreadValues({}, errorContext), {
530
- response: ((_g = options == null ? void 0 : options.hookOptions) == null ? void 0 : _g.cloneResponse) ? response.clone() : response
531
- }));
532
- }
533
- }
534
- if (options == null ? void 0 : options.retry) {
535
- const retryStrategy = createRetryStrategy(options.retry);
536
- const _retryAttempt = (_h = options.retryAttempt) != null ? _h : 0;
537
- if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
538
- for (const onRetry of hooks.onRetry) {
539
- if (onRetry) {
540
- await onRetry(responseContext);
541
- }
542
- }
543
- const delay = retryStrategy.getDelay(_retryAttempt);
544
- await new Promise((resolve) => setTimeout(resolve, delay));
545
- return await betterFetch(url, __spreadProps(__spreadValues({}, options), {
546
- retryAttempt: _retryAttempt + 1
547
- }));
548
- }
549
- }
550
- if (options == null ? void 0 : options.throw) {
551
- throw new BetterFetchError(
552
- response.status,
553
- response.statusText,
554
- isJSONResponse ? errorObject : responseText
555
- );
556
- }
557
- return {
558
- data: null,
559
- error: __spreadProps(__spreadValues({}, errorObject), {
560
- status: response.status,
561
- statusText: response.statusText
562
- })
563
- };
564
- };
565
-
566
- // ../../../node_modules/.pnpm/@better-auth+core@1.3.34_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.18_better-call@1.0._cenebiivepn42iaejxu4tccdyq/node_modules/@better-auth/core/dist/env/index.mjs
567
- var _envShim = /* @__PURE__ */ Object.create(null);
568
- var _getEnv = (useShim) => globalThis.process?.env || //@ts-expect-error
569
- globalThis.Deno?.env.toObject() || //@ts-expect-error
570
- globalThis.__env__ || (useShim ? _envShim : globalThis);
571
- var env = new Proxy(_envShim, {
572
- get(_, prop) {
573
- const env2 = _getEnv();
574
- return env2[prop] ?? _envShim[prop];
575
- },
576
- has(_, prop) {
577
- const env2 = _getEnv();
578
- return prop in env2 || prop in _envShim;
579
- },
580
- set(_, prop, value) {
581
- const env2 = _getEnv(true);
582
- env2[prop] = value;
583
- return true;
584
- },
585
- deleteProperty(_, prop) {
586
- if (!prop) {
587
- return false;
588
- }
589
- const env2 = _getEnv(true);
590
- delete env2[prop];
591
- return true;
592
- },
593
- ownKeys() {
594
- const env2 = _getEnv(true);
595
- return Object.keys(env2);
596
- }
597
- });
598
- var nodeENV = typeof process !== "undefined" && process.env && process.env.NODE_ENV || "";
599
- function getEnvVar(key, fallback) {
600
- if (typeof process !== "undefined" && process.env) {
601
- return process.env[key] ?? fallback;
602
- }
603
- if (typeof Deno !== "undefined") {
604
- return Deno.env.get(key) ?? fallback;
605
- }
606
- if (typeof Bun !== "undefined") {
607
- return Bun.env[key] ?? fallback;
608
- }
609
- return fallback;
610
- }
611
- var ENV = Object.freeze({
612
- get BETTER_AUTH_SECRET() {
613
- return getEnvVar("BETTER_AUTH_SECRET");
614
- },
615
- get AUTH_SECRET() {
616
- return getEnvVar("AUTH_SECRET");
617
- },
618
- get BETTER_AUTH_TELEMETRY() {
619
- return getEnvVar("BETTER_AUTH_TELEMETRY");
620
- },
621
- get BETTER_AUTH_TELEMETRY_ID() {
622
- return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
623
- },
624
- get NODE_ENV() {
625
- return getEnvVar("NODE_ENV", "development");
626
- },
627
- get PACKAGE_VERSION() {
628
- return getEnvVar("PACKAGE_VERSION", "0.0.0");
629
- },
630
- get BETTER_AUTH_TELEMETRY_ENDPOINT() {
631
- return getEnvVar(
632
- "BETTER_AUTH_TELEMETRY_ENDPOINT",
633
- "https://telemetry.better-auth.com/v1/track"
634
- );
635
- }
636
- });
637
- var COLORS_2 = 1;
638
- var COLORS_16 = 4;
639
- var COLORS_256 = 8;
640
- var COLORS_16m = 24;
641
- var TERM_ENVS = {
642
- eterm: COLORS_16,
643
- cons25: COLORS_16,
644
- console: COLORS_16,
645
- cygwin: COLORS_16,
646
- dtterm: COLORS_16,
647
- gnome: COLORS_16,
648
- hurd: COLORS_16,
649
- jfbterm: COLORS_16,
650
- konsole: COLORS_16,
651
- kterm: COLORS_16,
652
- mlterm: COLORS_16,
653
- mosh: COLORS_16m,
654
- putty: COLORS_16,
655
- st: COLORS_16,
656
- // http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
657
- "rxvt-unicode-24bit": COLORS_16m,
658
- // https://bugs.launchpad.net/terminator/+bug/1030562
659
- terminator: COLORS_16m,
660
- "xterm-kitty": COLORS_16m
661
- };
662
- var CI_ENVS_MAP = new Map(
663
- Object.entries({
664
- APPVEYOR: COLORS_256,
665
- BUILDKITE: COLORS_256,
666
- CIRCLECI: COLORS_16m,
667
- DRONE: COLORS_256,
668
- GITEA_ACTIONS: COLORS_16m,
669
- GITHUB_ACTIONS: COLORS_16m,
670
- GITLAB_CI: COLORS_256,
671
- TRAVIS: COLORS_256
672
- })
673
- );
674
- var TERM_ENVS_REG_EXP = [
675
- /ansi/,
676
- /color/,
677
- /linux/,
678
- /direct/,
679
- /^con[0-9]*x[0-9]/,
680
- /^rxvt/,
681
- /^screen/,
682
- /^xterm/,
683
- /^vt100/,
684
- /^vt220/
685
- ];
686
- function getColorDepth() {
687
- if (getEnvVar("FORCE_COLOR") !== void 0) {
688
- switch (getEnvVar("FORCE_COLOR")) {
689
- case "":
690
- case "1":
691
- case "true":
692
- return COLORS_16;
693
- case "2":
694
- return COLORS_256;
695
- case "3":
696
- return COLORS_16m;
697
- default:
698
- return COLORS_2;
699
- }
700
- }
701
- if (getEnvVar("NODE_DISABLE_COLORS") !== void 0 && getEnvVar("NODE_DISABLE_COLORS") !== "" || // See https://no-color.org/
702
- getEnvVar("NO_COLOR") !== void 0 && getEnvVar("NO_COLOR") !== "" || // The "dumb" special terminal, as defined by terminfo, doesn't support
703
- // ANSI color control codes.
704
- // See https://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials
705
- getEnvVar("TERM") === "dumb") {
706
- return COLORS_2;
707
- }
708
- if (getEnvVar("TMUX")) {
709
- return COLORS_16m;
710
- }
711
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
712
- return COLORS_16;
713
- }
714
- if ("CI" in env) {
715
- for (const { 0: envName, 1: colors } of CI_ENVS_MAP) {
716
- if (envName in env) {
717
- return colors;
718
- }
719
- }
720
- if (getEnvVar("CI_NAME") === "codeship") {
721
- return COLORS_256;
722
- }
723
- return COLORS_2;
724
- }
725
- if ("TEAMCITY_VERSION" in env) {
726
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(
727
- getEnvVar("TEAMCITY_VERSION")
728
- ) !== null ? COLORS_16 : COLORS_2;
729
- }
730
- switch (getEnvVar("TERM_PROGRAM")) {
731
- case "iTerm.app":
732
- if (!getEnvVar("TERM_PROGRAM_VERSION") || /^[0-2]\./.exec(getEnvVar("TERM_PROGRAM_VERSION")) !== null) {
733
- return COLORS_256;
734
- }
735
- return COLORS_16m;
736
- case "HyperTerm":
737
- case "MacTerm":
738
- return COLORS_16m;
739
- case "Apple_Terminal":
740
- return COLORS_256;
741
- }
742
- if (getEnvVar("COLORTERM") === "truecolor" || getEnvVar("COLORTERM") === "24bit") {
743
- return COLORS_16m;
744
- }
745
- if (getEnvVar("TERM")) {
746
- if (/truecolor/.exec(getEnvVar("TERM")) !== null) {
747
- return COLORS_16m;
748
- }
749
- if (/^xterm-256/.exec(getEnvVar("TERM")) !== null) {
750
- return COLORS_256;
751
- }
752
- const termEnv = getEnvVar("TERM").toLowerCase();
753
- if (TERM_ENVS[termEnv]) {
754
- return TERM_ENVS[termEnv];
755
- }
756
- if (TERM_ENVS_REG_EXP.some((term) => term.exec(termEnv) !== null)) {
757
- return COLORS_16;
758
- }
759
- }
760
- if (getEnvVar("COLORTERM")) {
761
- return COLORS_16;
762
- }
763
- return COLORS_2;
764
- }
765
- var TTY_COLORS = {
766
- reset: "\x1B[0m",
767
- bright: "\x1B[1m",
768
- dim: "\x1B[2m",
769
- undim: "\x1B[22m",
770
- underscore: "\x1B[4m",
771
- blink: "\x1B[5m",
772
- reverse: "\x1B[7m",
773
- hidden: "\x1B[8m",
774
- fg: {
775
- black: "\x1B[30m",
776
- red: "\x1B[31m",
777
- green: "\x1B[32m",
778
- yellow: "\x1B[33m",
779
- blue: "\x1B[34m",
780
- magenta: "\x1B[35m",
781
- cyan: "\x1B[36m",
782
- white: "\x1B[37m"
783
- },
784
- bg: {
785
- black: "\x1B[40m",
786
- red: "\x1B[41m",
787
- green: "\x1B[42m",
788
- yellow: "\x1B[43m",
789
- blue: "\x1B[44m",
790
- magenta: "\x1B[45m",
791
- cyan: "\x1B[46m",
792
- white: "\x1B[47m"
793
- }
794
- };
795
- var levels = ["info", "success", "warn", "error", "debug"];
796
- function shouldPublishLog(currentLogLevel, logLevel) {
797
- return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
798
- }
799
- var levelColors = {
800
- info: TTY_COLORS.fg.blue,
801
- success: TTY_COLORS.fg.green,
802
- warn: TTY_COLORS.fg.yellow,
803
- error: TTY_COLORS.fg.red,
804
- debug: TTY_COLORS.fg.magenta
805
- };
806
- var formatMessage = (level, message, colorsEnabled) => {
807
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
808
- if (colorsEnabled) {
809
- return `${TTY_COLORS.dim}${timestamp}${TTY_COLORS.reset} ${levelColors[level]}${level.toUpperCase()}${TTY_COLORS.reset} ${TTY_COLORS.bright}[Better Auth]:${TTY_COLORS.reset} ${message}`;
810
- }
811
- return `${timestamp} ${level.toUpperCase()} [Better Auth]: ${message}`;
812
- };
813
- var createLogger = (options) => {
814
- const enabled = options?.disabled !== true;
815
- const logLevel = options?.level ?? "error";
816
- const isDisableColorsSpecified = options?.disableColors !== void 0;
817
- const colorsEnabled = isDisableColorsSpecified ? !options.disableColors : getColorDepth() !== 1;
818
- const LogFunc = (level, message, args = []) => {
819
- if (!enabled || !shouldPublishLog(logLevel, level)) {
820
- return;
821
- }
822
- const formattedMessage = formatMessage(level, message, colorsEnabled);
823
- if (!options || typeof options.log !== "function") {
824
- if (level === "error") {
825
- console.error(formattedMessage, ...args);
826
- } else if (level === "warn") {
827
- console.warn(formattedMessage, ...args);
828
- } else {
829
- console.log(formattedMessage, ...args);
830
- }
831
- return;
832
- }
833
- options.log(level === "success" ? "info" : level, message, ...args);
834
- };
835
- const logger2 = Object.fromEntries(
836
- levels.map((level) => [
837
- level,
838
- (...[message, ...args]) => LogFunc(level, message, args)
839
- ])
840
- );
841
- return {
842
- ...logger2,
843
- get level() {
844
- return logLevel;
845
- }
846
- };
847
- };
848
- var logger = createLogger();
849
-
850
- // ../../../node_modules/.pnpm/@better-auth+core@1.3.34_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.18_better-call@1.0._cenebiivepn42iaejxu4tccdyq/node_modules/@better-auth/core/dist/utils/index.mjs
851
- function defineErrorCodes(codes) {
852
- return codes;
853
- }
854
-
855
- // ../../../node_modules/.pnpm/@better-auth+core@1.3.34_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.18_better-call@1.0._cenebiivepn42iaejxu4tccdyq/node_modules/@better-auth/core/dist/error/index.mjs
856
- var BASE_ERROR_CODES = defineErrorCodes({
857
- USER_NOT_FOUND: "User not found",
858
- FAILED_TO_CREATE_USER: "Failed to create user",
859
- FAILED_TO_CREATE_SESSION: "Failed to create session",
860
- FAILED_TO_UPDATE_USER: "Failed to update user",
861
- FAILED_TO_GET_SESSION: "Failed to get session",
862
- INVALID_PASSWORD: "Invalid password",
863
- INVALID_EMAIL: "Invalid email",
864
- INVALID_EMAIL_OR_PASSWORD: "Invalid email or password",
865
- SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked",
866
- PROVIDER_NOT_FOUND: "Provider not found",
867
- INVALID_TOKEN: "Invalid token",
868
- ID_TOKEN_NOT_SUPPORTED: "id_token not supported",
869
- FAILED_TO_GET_USER_INFO: "Failed to get user info",
870
- USER_EMAIL_NOT_FOUND: "User email not found",
871
- EMAIL_NOT_VERIFIED: "Email not verified",
872
- PASSWORD_TOO_SHORT: "Password too short",
873
- PASSWORD_TOO_LONG: "Password too long",
874
- USER_ALREADY_EXISTS: "User already exists.",
875
- USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.",
876
- EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated",
877
- CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found",
878
- SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.",
879
- FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account",
880
- ACCOUNT_NOT_FOUND: "Account not found",
881
- USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account."
882
- });
883
- var BetterAuthError = class extends Error {
884
- constructor(message, cause) {
885
- super(message);
886
- this.name = "BetterAuthError";
887
- this.message = message;
888
- this.cause = cause;
889
- this.stack = "";
890
- }
891
- };
892
-
893
- // ../../../node_modules/.pnpm/better-auth@1.3.34_next@15.1.9_react-dom@19.0.0_react@19.0.0__react@19.0.0__react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/better-auth/dist/shared/better-auth.DR3R5wdU.mjs
894
- function checkHasPath(url) {
895
- try {
896
- const parsedUrl = new URL(url);
897
- const pathname = parsedUrl.pathname.replace(/\/+$/, "") || "/";
898
- return pathname !== "/";
899
- } catch (error) {
900
- throw new BetterAuthError(
901
- `Invalid base URL: ${url}. Please provide a valid base URL.`
902
- );
903
- }
904
- }
905
- function withPath(url, path = "/api/auth") {
906
- const hasPath = checkHasPath(url);
907
- if (hasPath) {
908
- return url;
909
- }
910
- const trimmedUrl = url.replace(/\/+$/, "");
911
- if (!path || path === "/") {
912
- return trimmedUrl;
913
- }
914
- path = path.startsWith("/") ? path : `/${path}`;
915
- return `${trimmedUrl}${path}`;
916
- }
917
- function getBaseURL(url, path, request, loadEnv) {
918
- if (url) {
919
- return withPath(url, path);
920
- }
921
- if (loadEnv !== false) {
922
- 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);
923
- if (fromEnv) {
924
- return withPath(fromEnv, path);
925
- }
926
- }
927
- const fromRequest = request?.headers.get("x-forwarded-host");
928
- const fromRequestProto = request?.headers.get("x-forwarded-proto");
929
- if (fromRequest && fromRequestProto) {
930
- return withPath(`${fromRequestProto}://${fromRequest}`, path);
931
- }
932
- if (request) {
933
- const url2 = getOrigin(request.url);
934
- if (!url2) {
935
- throw new BetterAuthError(
936
- "Could not get origin from request. Please provide a valid base URL."
937
- );
938
- }
939
- return withPath(url2, path);
940
- }
941
- if (typeof window !== "undefined" && window.location) {
942
- return withPath(window.location.origin, path);
943
- }
944
- return void 0;
945
- }
946
- function getOrigin(url) {
947
- try {
948
- const parsedUrl = new URL(url);
949
- return parsedUrl.origin;
950
- } catch (error) {
951
- return null;
952
- }
953
- }
954
-
955
- // ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/clean-stores/index.js
956
- var clean = Symbol("clean");
957
-
958
- // ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.js
959
- var listenerQueue = [];
960
- var lqIndex = 0;
961
- var QUEUE_ITEMS_PER_LISTENER = 4;
962
- var epoch = 0;
963
- var atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
964
- let listeners = [];
965
- let $atom = {
966
- get() {
967
- if (!$atom.lc) {
968
- $atom.listen(() => {
969
- })();
970
- }
971
- return $atom.value;
972
- },
973
- lc: 0,
974
- listen(listener) {
975
- $atom.lc = listeners.push(listener);
976
- return () => {
977
- for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length; ) {
978
- if (listenerQueue[i] === listener) {
979
- listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
980
- } else {
981
- i += QUEUE_ITEMS_PER_LISTENER;
982
- }
983
- }
984
- let index = listeners.indexOf(listener);
985
- if (~index) {
986
- listeners.splice(index, 1);
987
- if (!--$atom.lc) $atom.off();
988
- }
989
- };
990
- },
991
- notify(oldValue, changedKey) {
992
- epoch++;
993
- let runListenerQueue = !listenerQueue.length;
994
- for (let listener of listeners) {
995
- listenerQueue.push(listener, $atom.value, oldValue, changedKey);
996
- }
997
- if (runListenerQueue) {
998
- for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) {
999
- listenerQueue[lqIndex](
1000
- listenerQueue[lqIndex + 1],
1001
- listenerQueue[lqIndex + 2],
1002
- listenerQueue[lqIndex + 3]
1003
- );
1004
- }
1005
- listenerQueue.length = 0;
1006
- }
1007
- },
1008
- /* It will be called on last listener unsubscribing.
1009
- We will redefine it in onMount and onStop. */
1010
- off() {
1011
- },
1012
- set(newValue) {
1013
- let oldValue = $atom.value;
1014
- if (oldValue !== newValue) {
1015
- $atom.value = newValue;
1016
- $atom.notify(oldValue);
1017
- }
1018
- },
1019
- subscribe(listener) {
1020
- let unbind = $atom.listen(listener);
1021
- listener($atom.value);
1022
- return unbind;
1023
- },
1024
- value: initialValue
1025
- };
1026
- if (process.env.NODE_ENV !== "production") {
1027
- $atom[clean] = () => {
1028
- listeners = [];
1029
- $atom.lc = 0;
1030
- $atom.off();
1031
- };
1032
- }
1033
- return $atom;
1034
- };
1035
-
1036
- // ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/lifecycle/index.js
1037
- var MOUNT = 5;
1038
- var UNMOUNT = 6;
1039
- var REVERT_MUTATION = 10;
1040
- var on = (object, listener, eventKey, mutateStore) => {
1041
- object.events = object.events || {};
1042
- if (!object.events[eventKey + REVERT_MUTATION]) {
1043
- object.events[eventKey + REVERT_MUTATION] = mutateStore((eventProps) => {
1044
- object.events[eventKey].reduceRight((event, l) => (l(event), event), {
1045
- shared: {},
1046
- ...eventProps
1047
- });
1048
- });
1049
- }
1050
- object.events[eventKey] = object.events[eventKey] || [];
1051
- object.events[eventKey].push(listener);
1052
- return () => {
1053
- let currentListeners = object.events[eventKey];
1054
- let index = currentListeners.indexOf(listener);
1055
- currentListeners.splice(index, 1);
1056
- if (!currentListeners.length) {
1057
- delete object.events[eventKey];
1058
- object.events[eventKey + REVERT_MUTATION]();
1059
- delete object.events[eventKey + REVERT_MUTATION];
1060
- }
1061
- };
1062
- };
1063
- var STORE_UNMOUNT_DELAY = 1e3;
1064
- var onMount = ($store, initialize) => {
1065
- let listener = (payload) => {
1066
- let destroy = initialize(payload);
1067
- if (destroy) $store.events[UNMOUNT].push(destroy);
1068
- };
1069
- return on($store, listener, MOUNT, (runListeners) => {
1070
- let originListen = $store.listen;
1071
- $store.listen = (...args) => {
1072
- if (!$store.lc && !$store.active) {
1073
- $store.active = true;
1074
- runListeners();
1075
- }
1076
- return originListen(...args);
1077
- };
1078
- let originOff = $store.off;
1079
- $store.events[UNMOUNT] = [];
1080
- $store.off = () => {
1081
- originOff();
1082
- setTimeout(() => {
1083
- if ($store.active && !$store.lc) {
1084
- $store.active = false;
1085
- for (let destroy of $store.events[UNMOUNT]) destroy();
1086
- $store.events[UNMOUNT] = [];
1087
- }
1088
- }, STORE_UNMOUNT_DELAY);
1089
- };
1090
- if (process.env.NODE_ENV !== "production") {
1091
- let originClean = $store[clean];
1092
- $store[clean] = () => {
1093
- for (let destroy of $store.events[UNMOUNT]) destroy();
1094
- $store.events[UNMOUNT] = [];
1095
- $store.active = false;
1096
- originClean();
1097
- };
1098
- }
1099
- return () => {
1100
- $store.listen = originListen;
1101
- $store.off = originOff;
1102
- };
1103
- });
1104
- };
1105
-
1106
- // ../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/listen-keys/index.js
1107
- function listenKeys($store, keys, listener) {
1108
- let keysSet = new Set(keys).add(void 0);
1109
- return $store.listen((value, oldValue, changed) => {
1110
- if (keysSet.has(changed)) {
1111
- listener(value, oldValue, changed);
1112
- }
1113
- });
1114
- }
1115
-
1116
- // ../../../node_modules/.pnpm/better-auth@1.3.34_next@15.1.9_react-dom@19.0.0_react@19.0.0__react@19.0.0__react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/better-auth/dist/shared/better-auth.BYWGbmZ5.mjs
1117
- var isServer = typeof window === "undefined";
1118
- var useAuthQuery = (initializedAtom, path, $fetch, options) => {
1119
- const value = atom({
1120
- data: null,
1121
- error: null,
1122
- isPending: true,
1123
- isRefetching: false,
1124
- refetch: (queryParams) => {
1125
- return fn(queryParams);
1126
- }
1127
- });
1128
- const fn = (queryParams) => {
1129
- const opts = typeof options === "function" ? options({
1130
- data: value.get().data,
1131
- error: value.get().error,
1132
- isPending: value.get().isPending
1133
- }) : options;
1134
- $fetch(path, {
1135
- ...opts,
1136
- query: {
1137
- ...opts?.query,
1138
- ...queryParams?.query
1139
- },
1140
- async onSuccess(context) {
1141
- value.set({
1142
- data: context.data,
1143
- error: null,
1144
- isPending: false,
1145
- isRefetching: false,
1146
- refetch: value.value.refetch
1147
- });
1148
- await opts?.onSuccess?.(context);
1149
- },
1150
- async onError(context) {
1151
- const { request } = context;
1152
- const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
1153
- const retryAttempt = request.retryAttempt || 0;
1154
- if (retryAttempts && retryAttempt < retryAttempts) return;
1155
- value.set({
1156
- error: context.error,
1157
- data: null,
1158
- isPending: false,
1159
- isRefetching: false,
1160
- refetch: value.value.refetch
1161
- });
1162
- await opts?.onError?.(context);
1163
- },
1164
- async onRequest(context) {
1165
- const currentValue = value.get();
1166
- value.set({
1167
- isPending: currentValue.data === null,
1168
- data: currentValue.data,
1169
- error: null,
1170
- isRefetching: true,
1171
- refetch: value.value.refetch
1172
- });
1173
- await opts?.onRequest?.(context);
1174
- }
1175
- }).catch((error) => {
1176
- value.set({
1177
- error,
1178
- data: null,
1179
- isPending: false,
1180
- isRefetching: false,
1181
- refetch: value.value.refetch
1182
- });
1183
- });
1184
- };
1185
- initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
1186
- let isMounted = false;
1187
- for (const initAtom of initializedAtom) {
1188
- initAtom.subscribe(() => {
1189
- if (isServer) {
1190
- return;
1191
- }
1192
- if (isMounted) {
1193
- fn();
1194
- } else {
1195
- onMount(value, () => {
1196
- const timeoutId = setTimeout(() => {
1197
- if (!isMounted) {
1198
- fn();
1199
- isMounted = true;
1200
- }
1201
- }, 0);
1202
- return () => {
1203
- value.off();
1204
- initAtom.off();
1205
- clearTimeout(timeoutId);
1206
- };
1207
- });
1208
- }
1209
- });
1210
- }
1211
- return value;
1212
- };
1213
-
1214
- // ../../../node_modules/.pnpm/better-auth@1.3.34_next@15.1.9_react-dom@19.0.0_react@19.0.0__react@19.0.0__react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/better-auth/dist/shared/better-auth.msGOU0m9.mjs
1215
- var PROTO_POLLUTION_PATTERNS = {
1216
- 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*:/,
1217
- 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*:/,
1218
- protoShort: /"__proto__"\s*:/,
1219
- constructorShort: /"constructor"\s*:/
1220
- };
1221
- var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
1222
- var SPECIAL_VALUES = {
1223
- true: true,
1224
- false: false,
1225
- null: null,
1226
- undefined: void 0,
1227
- nan: Number.NaN,
1228
- infinity: Number.POSITIVE_INFINITY,
1229
- "-infinity": Number.NEGATIVE_INFINITY
1230
- };
1231
- var ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
1232
- function isValidDate(date) {
1233
- return date instanceof Date && !isNaN(date.getTime());
1234
- }
1235
- function parseISODate(value) {
1236
- const match = ISO_DATE_REGEX.exec(value);
1237
- if (!match) return null;
1238
- const [
1239
- ,
1240
- year,
1241
- month,
1242
- day,
1243
- hour,
1244
- minute,
1245
- second,
1246
- ms,
1247
- offsetSign,
1248
- offsetHour,
1249
- offsetMinute
1250
- ] = match;
1251
- let date = new Date(
1252
- Date.UTC(
1253
- parseInt(year, 10),
1254
- parseInt(month, 10) - 1,
1255
- parseInt(day, 10),
1256
- parseInt(hour, 10),
1257
- parseInt(minute, 10),
1258
- parseInt(second, 10),
1259
- ms ? parseInt(ms.padEnd(3, "0"), 10) : 0
1260
- )
1261
- );
1262
- if (offsetSign) {
1263
- const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
1264
- date.setUTCMinutes(date.getUTCMinutes() + offset);
1265
- }
1266
- return isValidDate(date) ? date : null;
1267
- }
1268
- function betterJSONParse(value, options = {}) {
1269
- const {
1270
- strict = false,
1271
- warnings = false,
1272
- reviver,
1273
- parseDates = true
1274
- } = options;
1275
- if (typeof value !== "string") {
1276
- return value;
1277
- }
1278
- const trimmed = value.trim();
1279
- if (trimmed.length > 0 && trimmed[0] === '"' && trimmed.endsWith('"') && !trimmed.slice(1, -1).includes('"')) {
1280
- return trimmed.slice(1, -1);
1281
- }
1282
- const lowerValue = trimmed.toLowerCase();
1283
- if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) {
1284
- return SPECIAL_VALUES[lowerValue];
1285
- }
1286
- if (!JSON_SIGNATURE.test(trimmed)) {
1287
- if (strict) {
1288
- throw new SyntaxError("[better-json] Invalid JSON");
1289
- }
1290
- return value;
1291
- }
1292
- const hasProtoPattern = Object.entries(PROTO_POLLUTION_PATTERNS).some(
1293
- ([key, pattern]) => {
1294
- const matches = pattern.test(trimmed);
1295
- if (matches && warnings) {
1296
- console.warn(
1297
- `[better-json] Detected potential prototype pollution attempt using ${key} pattern`
1298
- );
1299
- }
1300
- return matches;
1301
- }
1302
- );
1303
- if (hasProtoPattern && strict) {
1304
- throw new Error(
1305
- "[better-json] Potential prototype pollution attempt detected"
1306
- );
1307
- }
1308
- try {
1309
- const secureReviver = (key, value2) => {
1310
- if (key === "__proto__" || key === "constructor" && value2 && typeof value2 === "object" && "prototype" in value2) {
1311
- if (warnings) {
1312
- console.warn(
1313
- `[better-json] Dropping "${key}" key to prevent prototype pollution`
1314
- );
1315
- }
1316
- return void 0;
1317
- }
1318
- if (parseDates && typeof value2 === "string") {
1319
- const date = parseISODate(value2);
1320
- if (date) {
1321
- return date;
1322
- }
1323
- }
1324
- return reviver ? reviver(key, value2) : value2;
1325
- };
1326
- return JSON.parse(trimmed, secureReviver);
1327
- } catch (error) {
1328
- if (strict) {
1329
- throw error;
1330
- }
1331
- return value;
1332
- }
1333
- }
1334
- function parseJSON(value, options = { strict: true }) {
1335
- return betterJSONParse(value, options);
1336
- }
1337
-
1338
- // ../../../node_modules/.pnpm/better-auth@1.3.34_next@15.1.9_react-dom@19.0.0_react@19.0.0__react@19.0.0__react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/better-auth/dist/shared/better-auth.RKafzlkP.mjs
1339
- var redirectPlugin = {
1340
- id: "redirect",
1341
- name: "Redirect",
1342
- hooks: {
1343
- onSuccess(context) {
1344
- if (context.data?.url && context.data?.redirect) {
1345
- if (typeof window !== "undefined" && window.location) {
1346
- if (window.location) {
1347
- try {
1348
- window.location.href = context.data.url;
1349
- } catch {
1350
- }
1351
- }
1352
- }
1353
- }
1354
- }
1355
- }
1356
- };
1357
- function getSessionAtom($fetch) {
1358
- const $signal = atom(false);
1359
- const session = useAuthQuery($signal, "/get-session", $fetch, {
1360
- method: "GET"
1361
- });
1362
- return {
1363
- session,
1364
- $sessionSignal: $signal
1365
- };
1366
- }
1367
- var getClientConfig = (options, loadEnv) => {
1368
- const isCredentialsSupported = "credentials" in Request.prototype;
1369
- const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? "/api/auth";
1370
- const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
1371
- const lifeCyclePlugin = {
1372
- id: "lifecycle-hooks",
1373
- name: "lifecycle-hooks",
1374
- hooks: {
1375
- onSuccess: options?.fetchOptions?.onSuccess,
1376
- onError: options?.fetchOptions?.onError,
1377
- onRequest: options?.fetchOptions?.onRequest,
1378
- onResponse: options?.fetchOptions?.onResponse
1379
- }
1380
- };
1381
- const { onSuccess, onError, onRequest, onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
1382
- const $fetch = createFetch({
1383
- baseURL,
1384
- ...isCredentialsSupported ? { credentials: "include" } : {},
1385
- method: "GET",
1386
- jsonParser(text) {
1387
- if (!text) {
1388
- return null;
1389
- }
1390
- return parseJSON(text, {
1391
- strict: false
1392
- });
1393
- },
1394
- customFetchImpl: fetch,
1395
- ...restOfFetchOptions,
1396
- plugins: [
1397
- lifeCyclePlugin,
1398
- ...restOfFetchOptions.plugins || [],
1399
- ...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
1400
- ...pluginsFetchPlugins
1401
- ]
1402
- });
1403
- const { $sessionSignal, session } = getSessionAtom($fetch);
1404
- const plugins = options?.plugins || [];
1405
- let pluginsActions = {};
1406
- let pluginsAtoms = {
1407
- $sessionSignal,
1408
- session
1409
- };
1410
- let pluginPathMethods = {
1411
- "/sign-out": "POST",
1412
- "/revoke-sessions": "POST",
1413
- "/revoke-other-sessions": "POST",
1414
- "/delete-user": "POST"
1415
- };
1416
- const atomListeners = [
1417
- {
1418
- signal: "$sessionSignal",
1419
- matcher(path) {
1420
- return path === "/sign-out" || path === "/update-user" || path.startsWith("/sign-in") || path.startsWith("/sign-up") || path === "/delete-user" || path === "/verify-email";
1421
- }
1422
- }
1423
- ];
1424
- for (const plugin of plugins) {
1425
- if (plugin.getAtoms) {
1426
- Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
1427
- }
1428
- if (plugin.pathMethods) {
1429
- Object.assign(pluginPathMethods, plugin.pathMethods);
1430
- }
1431
- if (plugin.atomListeners) {
1432
- atomListeners.push(...plugin.atomListeners);
1433
- }
1434
- }
1435
- const $store = {
1436
- notify: (signal) => {
1437
- pluginsAtoms[signal].set(
1438
- !pluginsAtoms[signal].get()
1439
- );
1440
- },
1441
- listen: (signal, listener) => {
1442
- pluginsAtoms[signal].subscribe(listener);
1443
- },
1444
- atoms: pluginsAtoms
1445
- };
1446
- for (const plugin of plugins) {
1447
- if (plugin.getActions) {
1448
- Object.assign(
1449
- pluginsActions,
1450
- plugin.getActions?.($fetch, $store, options)
1451
- );
1452
- }
1453
- }
1454
- return {
1455
- get baseURL() {
1456
- return baseURL;
1457
- },
1458
- pluginsActions,
1459
- pluginsAtoms,
1460
- pluginPathMethods,
1461
- atomListeners,
1462
- $fetch,
1463
- $store
1464
- };
1465
- };
1466
- function isAtom(value) {
1467
- return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
1468
- }
1469
- function getMethod2(path, knownPathMethods, args) {
1470
- const method = knownPathMethods[path];
1471
- const { fetchOptions, query, ...body } = args || {};
1472
- if (method) {
1473
- return method;
1474
- }
1475
- if (fetchOptions?.method) {
1476
- return fetchOptions.method;
1477
- }
1478
- if (body && Object.keys(body).length > 0) {
1479
- return "POST";
1480
- }
1481
- return "GET";
1482
- }
1483
- function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomListeners) {
1484
- function createProxy(path = []) {
1485
- return new Proxy(function() {
1486
- }, {
1487
- get(_, prop) {
1488
- if (typeof prop !== "string") {
1489
- return void 0;
1490
- }
1491
- if (prop === "then" || prop === "catch" || prop === "finally") {
1492
- return void 0;
1493
- }
1494
- const fullPath = [...path, prop];
1495
- let current = routes;
1496
- for (const segment of fullPath) {
1497
- if (current && typeof current === "object" && segment in current) {
1498
- current = current[segment];
1499
- } else {
1500
- current = void 0;
1501
- break;
1502
- }
1503
- }
1504
- if (typeof current === "function") {
1505
- return current;
1506
- }
1507
- if (isAtom(current)) {
1508
- return current;
1509
- }
1510
- return createProxy(fullPath);
1511
- },
1512
- apply: async (_, __, args) => {
1513
- const routePath = "/" + path.map(
1514
- (segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
1515
- ).join("/");
1516
- const arg = args[0] || {};
1517
- const fetchOptions = args[1] || {};
1518
- const { query, fetchOptions: argFetchOptions, ...body } = arg;
1519
- const options = {
1520
- ...fetchOptions,
1521
- ...argFetchOptions
1522
- };
1523
- const method = getMethod2(routePath, knownPathMethods, arg);
1524
- return await client(routePath, {
1525
- ...options,
1526
- body: method === "GET" ? void 0 : {
1527
- ...body,
1528
- ...options?.body || {}
1529
- },
1530
- query: query || options?.query,
1531
- method,
1532
- async onSuccess(context) {
1533
- await options?.onSuccess?.(context);
1534
- if (!atomListeners) return;
1535
- const matches = atomListeners.filter((s) => s.matcher(routePath));
1536
- if (!matches.length) return;
1537
- for (const match of matches) {
1538
- const signal = atoms[match.signal];
1539
- if (!signal) return;
1540
- const val = signal.get();
1541
- setTimeout(() => {
1542
- signal.set(!val);
1543
- }, 10);
1544
- }
1545
- }
1546
- });
1547
- }
1548
- });
1549
- }
1550
- return createProxy();
1551
- }
1552
-
1553
- // ../../../node_modules/.pnpm/better-auth@1.3.34_next@15.1.9_react-dom@19.0.0_react@19.0.0__react@19.0.0__react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/better-auth/dist/client/react/index.mjs
1554
- import { useRef, useCallback, useSyncExternalStore } from "react";
1555
- function useStore(store, options = {}) {
1556
- let snapshotRef = useRef(store.get());
1557
- const { keys, deps = [store, keys] } = options;
1558
- let subscribe = useCallback((onChange) => {
1559
- const emitChange = (value) => {
1560
- if (snapshotRef.current === value) return;
1561
- snapshotRef.current = value;
1562
- onChange();
1563
- };
1564
- emitChange(store.value);
1565
- if (keys?.length) {
1566
- return listenKeys(store, keys, emitChange);
1567
- }
1568
- return store.listen(emitChange);
1569
- }, deps);
1570
- let get = () => snapshotRef.current;
1571
- return useSyncExternalStore(subscribe, get, get);
1572
- }
1573
- function getAtomKey(str) {
1574
- return `use${capitalizeFirstLetter(str)}`;
1575
- }
1576
- function capitalizeFirstLetter(str) {
1577
- return str.charAt(0).toUpperCase() + str.slice(1);
1578
- }
1579
- function createAuthClient(options) {
1580
- const {
1581
- pluginPathMethods,
1582
- pluginsActions,
1583
- pluginsAtoms,
1584
- $fetch,
1585
- $store,
1586
- atomListeners
1587
- } = getClientConfig(options);
1588
- let resolvedHooks = {};
1589
- for (const [key, value] of Object.entries(pluginsAtoms)) {
1590
- resolvedHooks[getAtomKey(key)] = () => useStore(value);
1591
- }
1592
- const routes = {
1593
- ...pluginsActions,
1594
- ...resolvedHooks,
1595
- $fetch,
1596
- $store
1597
- };
1598
- const proxy = createDynamicPathProxy(
1599
- routes,
1600
- $fetch,
1601
- pluginPathMethods,
1602
- pluginsAtoms,
1603
- atomListeners
1604
- );
1605
- return proxy;
1606
- }
1607
-
1608
1
  // src/dashboard-client.ts
2
+ import { createAuthClient as createBetterAuthClient } from "better-auth/react";
1609
3
  function createDashboardClient(config) {
1610
4
  const baseURL = config?.baseURL || "https://api.erikey.com";
1611
- return createAuthClient({
5
+ return createBetterAuthClient({
1612
6
  baseURL,
1613
7
  credentials: config?.credentials || "include"
1614
8
  });
1615
9
  }
1616
10
 
1617
11
  // src/auth-client.ts
1618
- import { useState, useEffect, useCallback as useCallback2 } from "react";
12
+ import { useState, useEffect, useCallback } from "react";
13
+ import { createAuthClient as createBetterAuthClient2 } from "better-auth/react";
1619
14
 
1620
15
  // src/lib/cross-origin-auth.ts
1621
16
  function shouldUseBearerAuth(authApiUrl) {
@@ -1662,7 +57,7 @@ function clearToken(projectId) {
1662
57
  }
1663
58
 
1664
59
  // src/auth-client.ts
1665
- function createAuthClient2(config) {
60
+ function createAuthClient(config) {
1666
61
  const { projectId, baseUrl = "https://auth.erikey.com" } = config;
1667
62
  const useBearerAuth = shouldUseBearerAuth(baseUrl);
1668
63
  const fetchOptions = {
@@ -1678,7 +73,7 @@ function createAuthClient2(config) {
1678
73
  }
1679
74
  }
1680
75
  };
1681
- const client = createAuthClient({
76
+ const client = createBetterAuthClient2({
1682
77
  baseURL: baseUrl,
1683
78
  fetchOptions,
1684
79
  // For same-origin, include cookies
@@ -1765,7 +160,7 @@ function createAuthClient2(config) {
1765
160
  const [data, setData] = useState(null);
1766
161
  const [isPending, setIsPending] = useState(true);
1767
162
  const [error, setError] = useState(null);
1768
- const refetch = useCallback2(async () => {
163
+ const refetch = useCallback(async () => {
1769
164
  setIsPending(true);
1770
165
  try {
1771
166
  const result = await client.getSession();
@@ -2013,7 +408,7 @@ function createKvClient(config) {
2013
408
  };
2014
409
  }
2015
410
  export {
2016
- createAuthClient2 as createAuthClient,
411
+ createAuthClient,
2017
412
  createDashboardClient,
2018
413
  createKvClient
2019
414
  };