@access-dlsu/leapify 0.260507.5 → 0.260524.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/chunk-64MMUYMK.cjs +167 -0
- package/dist/chunk-64MMUYMK.cjs.map +1 -0
- package/dist/chunk-AKCERDGP.js +161 -0
- package/dist/chunk-AKCERDGP.js.map +1 -0
- package/dist/client/index.cjs +60 -841
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.ts +3 -8
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +58 -839
- package/dist/client/index.js.map +1 -1
- package/dist/client/turnstile.d.ts +25 -0
- package/dist/client/turnstile.d.ts.map +1 -0
- package/dist/client/types.d.ts +2 -15
- package/dist/client/types.d.ts.map +1 -1
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/schema/classes.d.ts +0 -19
- package/dist/db/schema/classes.d.ts.map +1 -1
- package/dist/db/schema/site-config.d.ts +0 -83
- package/dist/db/schema/site-config.d.ts.map +1 -1
- package/dist/index.cjs +666 -38320
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +519 -38166
- package/dist/index.js.map +1 -1
- package/dist/lib/middleware/cors.d.ts.map +1 -1
- package/dist/lib/middleware/rate-limit.d.ts.map +1 -1
- package/dist/lib/middleware/referer-guard.d.ts.map +1 -1
- package/dist/lib/middleware/turnstile-challenge.cjs +29 -0
- package/dist/lib/middleware/turnstile-challenge.cjs.map +1 -0
- package/dist/lib/middleware/turnstile-challenge.d.ts +45 -0
- package/dist/lib/middleware/turnstile-challenge.d.ts.map +1 -0
- package/dist/lib/middleware/turnstile-challenge.js +4 -0
- package/dist/lib/middleware/turnstile-challenge.js.map +1 -0
- package/dist/queues/jobs.d.ts +0 -5
- package/dist/queues/jobs.d.ts.map +1 -1
- package/dist/routes/classes.d.ts.map +1 -1
- package/dist/routes/faqs.d.ts.map +1 -1
- package/dist/routes/site-config.d.ts.map +1 -1
- package/dist/routes/themes.d.ts.map +1 -1
- package/dist/routes/uploads.d.ts.map +1 -1
- package/dist/types.d.ts +5 -26
- package/dist/types.d.ts.map +1 -1
- package/dist/worker-handler.d.ts +1 -0
- package/dist/worker-handler.d.ts.map +1 -1
- package/dist/worker.js +684 -64365
- package/dist/worker.js.map +1 -1
- package/package.json +11 -9
- package/dist/bun-sqlite-dialect-na--YwnN-NIYANHVJ.cjs +0 -162
- package/dist/bun-sqlite-dialect-na--YwnN-NIYANHVJ.cjs.map +0 -1
- package/dist/bun-sqlite-dialect-na--YwnN-XVQNOKSL.js +0 -160
- package/dist/bun-sqlite-dialect-na--YwnN-XVQNOKSL.js.map +0 -1
- package/dist/chunk-4DPT2KQR.cjs +0 -467
- package/dist/chunk-4DPT2KQR.cjs.map +0 -1
- package/dist/chunk-5JKLV7IE.cjs +0 -2962
- package/dist/chunk-5JKLV7IE.cjs.map +0 -1
- package/dist/chunk-5OQD5ALM.cjs +0 -76
- package/dist/chunk-5OQD5ALM.cjs.map +0 -1
- package/dist/chunk-5YYVBPAE.js +0 -2301
- package/dist/chunk-5YYVBPAE.js.map +0 -1
- package/dist/chunk-6MMWL46O.cjs +0 -7170
- package/dist/chunk-6MMWL46O.cjs.map +0 -1
- package/dist/chunk-EGRHWZRV.js +0 -3
- package/dist/chunk-EGRHWZRV.js.map +0 -1
- package/dist/chunk-EMMSS5I5.cjs +0 -37
- package/dist/chunk-EMMSS5I5.cjs.map +0 -1
- package/dist/chunk-FUCJEA2S.js +0 -6196
- package/dist/chunk-FUCJEA2S.js.map +0 -1
- package/dist/chunk-G3PMV62Z.js +0 -33
- package/dist/chunk-G3PMV62Z.js.map +0 -1
- package/dist/chunk-GNRL67OU.js +0 -2949
- package/dist/chunk-GNRL67OU.js.map +0 -1
- package/dist/chunk-HHNEB7YR.js +0 -8
- package/dist/chunk-HHNEB7YR.js.map +0 -1
- package/dist/chunk-IQEWVHLM.js +0 -889
- package/dist/chunk-IQEWVHLM.js.map +0 -1
- package/dist/chunk-JIZPYG6H.js +0 -72
- package/dist/chunk-JIZPYG6H.js.map +0 -1
- package/dist/chunk-JPVIXCF5.cjs +0 -10
- package/dist/chunk-JPVIXCF5.cjs.map +0 -1
- package/dist/chunk-JQSZJWBN.cjs +0 -3075
- package/dist/chunk-JQSZJWBN.cjs.map +0 -1
- package/dist/chunk-LVKPYSXI.cjs +0 -2312
- package/dist/chunk-LVKPYSXI.cjs.map +0 -1
- package/dist/chunk-MNEW2V4T.js +0 -447
- package/dist/chunk-MNEW2V4T.js.map +0 -1
- package/dist/chunk-MY37YE52.js +0 -3034
- package/dist/chunk-MY37YE52.js.map +0 -1
- package/dist/chunk-NKIQRCOM.cjs +0 -4
- package/dist/chunk-NKIQRCOM.cjs.map +0 -1
- package/dist/chunk-OK6RVPEH.cjs +0 -6200
- package/dist/chunk-OK6RVPEH.cjs.map +0 -1
- package/dist/chunk-OZ6HZKR5.js +0 -228
- package/dist/chunk-OZ6HZKR5.js.map +0 -1
- package/dist/chunk-RFP2X2FA.cjs +0 -903
- package/dist/chunk-RFP2X2FA.cjs.map +0 -1
- package/dist/chunk-S5DBMZVP.cjs +0 -234
- package/dist/chunk-S5DBMZVP.cjs.map +0 -1
- package/dist/chunk-XJSWMHDL.js +0 -7142
- package/dist/chunk-XJSWMHDL.js.map +0 -1
- package/dist/client/pow.d.ts +0 -28
- package/dist/client/pow.d.ts.map +0 -1
- package/dist/cron/lifecycle-check.d.ts +0 -10
- package/dist/cron/lifecycle-check.d.ts.map +0 -1
- package/dist/d1-sqlite-dialect-C2B7YsIT-6TVV7EJ5.js +0 -122
- package/dist/d1-sqlite-dialect-C2B7YsIT-6TVV7EJ5.js.map +0 -1
- package/dist/d1-sqlite-dialect-C2B7YsIT-PE74FLHQ.cjs +0 -124
- package/dist/d1-sqlite-dialect-C2B7YsIT-PE74FLHQ.cjs.map +0 -1
- package/dist/dist-DZHA5VYX.cjs +0 -260
- package/dist/dist-DZHA5VYX.cjs.map +0 -1
- package/dist/dist-RRQUBLLO.js +0 -258
- package/dist/dist-RRQUBLLO.js.map +0 -1
- package/dist/kysely-adapter-C76KJVG7.js +0 -10
- package/dist/kysely-adapter-C76KJVG7.js.map +0 -1
- package/dist/kysely-adapter-TGY4UUP5.cjs +0 -27
- package/dist/kysely-adapter-TGY4UUP5.cjs.map +0 -1
- package/dist/lib/middleware/pow-challenge.cjs +0 -29
- package/dist/lib/middleware/pow-challenge.cjs.map +0 -1
- package/dist/lib/middleware/pow-challenge.d.ts +0 -58
- package/dist/lib/middleware/pow-challenge.d.ts.map +0 -1
- package/dist/lib/middleware/pow-challenge.js +0 -4
- package/dist/lib/middleware/pow-challenge.js.map +0 -1
- package/dist/node-sqlite-dialect-B3H37T3R.cjs +0 -162
- package/dist/node-sqlite-dialect-B3H37T3R.cjs.map +0 -1
- package/dist/node-sqlite-dialect-GDP7ZE54.js +0 -160
- package/dist/node-sqlite-dialect-GDP7ZE54.js.map +0 -1
- package/dist/routes/contentful-sync.d.ts +0 -4
- package/dist/routes/contentful-sync.d.ts.map +0 -1
- package/dist/services/contentful-management.d.ts +0 -38
- package/dist/services/contentful-management.d.ts.map +0 -1
- package/dist/services/contentful.d.ts +0 -97
- package/dist/services/contentful.d.ts.map +0 -1
- package/dist/services/snapshot.d.ts +0 -95
- package/dist/services/snapshot.d.ts.map +0 -1
package/dist/client/index.js
CHANGED
|
@@ -1,798 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '../chunk-EGRHWZRV.js';
|
|
4
|
-
import '../chunk-MNEW2V4T.js';
|
|
5
|
-
import '../chunk-G3PMV62Z.js';
|
|
1
|
+
import '../chunk-PZ5AY32C.js';
|
|
2
|
+
import { createAuthClient } from 'better-auth/client';
|
|
6
3
|
|
|
7
|
-
// node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
8
|
-
var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
9
|
-
var now = () => Math.floor(Date.now() / 1e3);
|
|
10
|
-
var WindowBroadcastChannel = class {
|
|
11
|
-
listeners = /* @__PURE__ */ new Set();
|
|
12
|
-
name;
|
|
13
|
-
constructor(name = "better-auth.message") {
|
|
14
|
-
this.name = name;
|
|
15
|
-
}
|
|
16
|
-
subscribe(listener) {
|
|
17
|
-
this.listeners.add(listener);
|
|
18
|
-
return () => {
|
|
19
|
-
this.listeners.delete(listener);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
post(message) {
|
|
23
|
-
if (typeof window === "undefined") return;
|
|
24
|
-
try {
|
|
25
|
-
localStorage.setItem(this.name, JSON.stringify({
|
|
26
|
-
...message,
|
|
27
|
-
timestamp: now()
|
|
28
|
-
}));
|
|
29
|
-
} catch {
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
setup() {
|
|
33
|
-
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
34
|
-
};
|
|
35
|
-
const handler = (event) => {
|
|
36
|
-
if (event.key !== this.name) return;
|
|
37
|
-
const message = JSON.parse(event.newValue ?? "{}");
|
|
38
|
-
if (message?.event !== "session" || !message?.data) return;
|
|
39
|
-
this.listeners.forEach((listener) => listener(message));
|
|
40
|
-
};
|
|
41
|
-
window.addEventListener("storage", handler);
|
|
42
|
-
return () => {
|
|
43
|
-
window.removeEventListener("storage", handler);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
48
|
-
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
49
|
-
return globalThis[kBroadcastChannel];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// node_modules/better-auth/dist/client/focus-manager.mjs
|
|
53
|
-
var kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
54
|
-
var WindowFocusManager = class {
|
|
55
|
-
listeners = /* @__PURE__ */ new Set();
|
|
56
|
-
subscribe(listener) {
|
|
57
|
-
this.listeners.add(listener);
|
|
58
|
-
return () => {
|
|
59
|
-
this.listeners.delete(listener);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
setFocused(focused) {
|
|
63
|
-
this.listeners.forEach((listener) => listener(focused));
|
|
64
|
-
}
|
|
65
|
-
setup() {
|
|
66
|
-
if (typeof window === "undefined" || typeof document === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
67
|
-
};
|
|
68
|
-
const visibilityHandler = () => {
|
|
69
|
-
if (document.visibilityState === "visible") this.setFocused(true);
|
|
70
|
-
};
|
|
71
|
-
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
72
|
-
return () => {
|
|
73
|
-
document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
function getGlobalFocusManager() {
|
|
78
|
-
if (!globalThis[kFocusManager]) globalThis[kFocusManager] = new WindowFocusManager();
|
|
79
|
-
return globalThis[kFocusManager];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// node_modules/better-auth/dist/client/online-manager.mjs
|
|
83
|
-
var kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
84
|
-
var WindowOnlineManager = class {
|
|
85
|
-
listeners = /* @__PURE__ */ new Set();
|
|
86
|
-
isOnline = typeof navigator !== "undefined" ? navigator.onLine : true;
|
|
87
|
-
subscribe(listener) {
|
|
88
|
-
this.listeners.add(listener);
|
|
89
|
-
return () => {
|
|
90
|
-
this.listeners.delete(listener);
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
setOnline(online) {
|
|
94
|
-
this.isOnline = online;
|
|
95
|
-
this.listeners.forEach((listener) => listener(online));
|
|
96
|
-
}
|
|
97
|
-
setup() {
|
|
98
|
-
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {
|
|
99
|
-
};
|
|
100
|
-
const onOnline = () => this.setOnline(true);
|
|
101
|
-
const onOffline = () => this.setOnline(false);
|
|
102
|
-
window.addEventListener("online", onOnline, false);
|
|
103
|
-
window.addEventListener("offline", onOffline, false);
|
|
104
|
-
return () => {
|
|
105
|
-
window.removeEventListener("online", onOnline, false);
|
|
106
|
-
window.removeEventListener("offline", onOffline, false);
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
function getGlobalOnlineManager() {
|
|
111
|
-
if (!globalThis[kOnlineManager]) globalThis[kOnlineManager] = new WindowOnlineManager();
|
|
112
|
-
return globalThis[kOnlineManager];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// node_modules/better-auth/dist/client/parser.mjs
|
|
116
|
-
var PROTO_POLLUTION_PATTERNS = {
|
|
117
|
-
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*:/,
|
|
118
|
-
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*:/,
|
|
119
|
-
protoShort: /"__proto__"\s*:/,
|
|
120
|
-
constructorShort: /"constructor"\s*:/
|
|
121
|
-
};
|
|
122
|
-
var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
123
|
-
var SPECIAL_VALUES = {
|
|
124
|
-
true: true,
|
|
125
|
-
false: false,
|
|
126
|
-
null: null,
|
|
127
|
-
undefined: void 0,
|
|
128
|
-
nan: NaN,
|
|
129
|
-
infinity: Number.POSITIVE_INFINITY,
|
|
130
|
-
"-infinity": Number.NEGATIVE_INFINITY
|
|
131
|
-
};
|
|
132
|
-
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}))$/;
|
|
133
|
-
function isValidDate(date) {
|
|
134
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
135
|
-
}
|
|
136
|
-
function parseISODate(value) {
|
|
137
|
-
const match = ISO_DATE_REGEX.exec(value);
|
|
138
|
-
if (!match) return null;
|
|
139
|
-
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
140
|
-
const date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
141
|
-
if (offsetSign) {
|
|
142
|
-
const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
143
|
-
date.setUTCMinutes(date.getUTCMinutes() + offset);
|
|
144
|
-
}
|
|
145
|
-
return isValidDate(date) ? date : null;
|
|
146
|
-
}
|
|
147
|
-
function betterJSONParse(value, options = {}) {
|
|
148
|
-
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
149
|
-
if (typeof value !== "string") return value;
|
|
150
|
-
const trimmed = value.trim();
|
|
151
|
-
if (trimmed.length > 0 && trimmed[0] === '"' && trimmed.endsWith('"') && !trimmed.slice(1, -1).includes('"')) return trimmed.slice(1, -1);
|
|
152
|
-
const lowerValue = trimmed.toLowerCase();
|
|
153
|
-
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
154
|
-
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
155
|
-
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
156
|
-
return value;
|
|
157
|
-
}
|
|
158
|
-
if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key, pattern]) => {
|
|
159
|
-
const matches = pattern.test(trimmed);
|
|
160
|
-
if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key} pattern`);
|
|
161
|
-
return matches;
|
|
162
|
-
}) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
163
|
-
try {
|
|
164
|
-
const secureReviver = (key, value2) => {
|
|
165
|
-
if (key === "__proto__" || key === "constructor" && value2 && typeof value2 === "object" && "prototype" in value2) {
|
|
166
|
-
if (warnings) console.warn(`[better-json] Dropping "${key}" key to prevent prototype pollution`);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (parseDates && typeof value2 === "string") {
|
|
170
|
-
const date = parseISODate(value2);
|
|
171
|
-
if (date) return date;
|
|
172
|
-
}
|
|
173
|
-
return reviver ? reviver(key, value2) : value2;
|
|
174
|
-
};
|
|
175
|
-
return JSON.parse(trimmed, secureReviver);
|
|
176
|
-
} catch (error) {
|
|
177
|
-
if (strict) throw error;
|
|
178
|
-
return value;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function parseJSON(value, options = { strict: true }) {
|
|
182
|
-
return betterJSONParse(value, options);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// node_modules/nanostores/clean-stores/index.js
|
|
186
|
-
var clean = Symbol("clean");
|
|
187
|
-
|
|
188
|
-
// node_modules/nanostores/atom/index.js
|
|
189
|
-
var listenerQueue = [];
|
|
190
|
-
var lqIndex = 0;
|
|
191
|
-
var QUEUE_ITEMS_PER_LISTENER = 4;
|
|
192
|
-
var nanostoresGlobal = globalThis.nanostoresGlobal ||= { epoch: 0 };
|
|
193
|
-
var atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
|
|
194
|
-
let listeners = [];
|
|
195
|
-
let $atom = {
|
|
196
|
-
get() {
|
|
197
|
-
if (!$atom.lc) {
|
|
198
|
-
$atom.listen(() => {
|
|
199
|
-
})();
|
|
200
|
-
}
|
|
201
|
-
return $atom.value;
|
|
202
|
-
},
|
|
203
|
-
init: initialValue,
|
|
204
|
-
lc: 0,
|
|
205
|
-
listen(listener) {
|
|
206
|
-
$atom.lc = listeners.push(listener);
|
|
207
|
-
return () => {
|
|
208
|
-
for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length; ) {
|
|
209
|
-
if (listenerQueue[i] === listener) {
|
|
210
|
-
listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
|
|
211
|
-
} else {
|
|
212
|
-
i += QUEUE_ITEMS_PER_LISTENER;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
let index = listeners.indexOf(listener);
|
|
216
|
-
if (~index) {
|
|
217
|
-
listeners.splice(index, 1);
|
|
218
|
-
if (!--$atom.lc) $atom.off();
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
},
|
|
222
|
-
notify(oldValue, changedKey) {
|
|
223
|
-
nanostoresGlobal.epoch++;
|
|
224
|
-
let runListenerQueue = !listenerQueue.length;
|
|
225
|
-
for (let listener of listeners) {
|
|
226
|
-
listenerQueue.push(listener, $atom.value, oldValue, changedKey);
|
|
227
|
-
}
|
|
228
|
-
if (runListenerQueue) {
|
|
229
|
-
for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) {
|
|
230
|
-
listenerQueue[lqIndex](
|
|
231
|
-
listenerQueue[lqIndex + 1],
|
|
232
|
-
listenerQueue[lqIndex + 2],
|
|
233
|
-
listenerQueue[lqIndex + 3]
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
listenerQueue.length = 0;
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
/* It will be called on last listener unsubscribing.
|
|
240
|
-
We will redefine it in onMount and onStop. */
|
|
241
|
-
off() {
|
|
242
|
-
},
|
|
243
|
-
set(newValue) {
|
|
244
|
-
let oldValue = $atom.value;
|
|
245
|
-
if (oldValue !== newValue) {
|
|
246
|
-
$atom.value = newValue;
|
|
247
|
-
$atom.notify(oldValue);
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
subscribe(listener) {
|
|
251
|
-
let unbind = $atom.listen(listener);
|
|
252
|
-
listener($atom.value);
|
|
253
|
-
return unbind;
|
|
254
|
-
},
|
|
255
|
-
value: initialValue
|
|
256
|
-
};
|
|
257
|
-
{
|
|
258
|
-
$atom[clean] = () => {
|
|
259
|
-
listeners = [];
|
|
260
|
-
$atom.lc = 0;
|
|
261
|
-
$atom.off();
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
return $atom;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// node_modules/nanostores/lifecycle/index.js
|
|
268
|
-
var MOUNT = 5;
|
|
269
|
-
var UNMOUNT = 6;
|
|
270
|
-
var REVERT_MUTATION = 10;
|
|
271
|
-
var on = (object, listener, eventKey, mutateStore) => {
|
|
272
|
-
object.events = object.events || {};
|
|
273
|
-
if (!object.events[eventKey + REVERT_MUTATION]) {
|
|
274
|
-
object.events[eventKey + REVERT_MUTATION] = mutateStore((eventProps) => {
|
|
275
|
-
object.events[eventKey].reduceRight((event, l) => (l(event), event), {
|
|
276
|
-
shared: {},
|
|
277
|
-
...eventProps
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
object.events[eventKey] = object.events[eventKey] || [];
|
|
282
|
-
object.events[eventKey].push(listener);
|
|
283
|
-
return () => {
|
|
284
|
-
let currentListeners = object.events[eventKey];
|
|
285
|
-
let index = currentListeners.indexOf(listener);
|
|
286
|
-
currentListeners.splice(index, 1);
|
|
287
|
-
if (!currentListeners.length) {
|
|
288
|
-
delete object.events[eventKey];
|
|
289
|
-
object.events[eventKey + REVERT_MUTATION]();
|
|
290
|
-
delete object.events[eventKey + REVERT_MUTATION];
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
};
|
|
294
|
-
var STORE_UNMOUNT_DELAY = 1e3;
|
|
295
|
-
var onMount = ($store, initialize) => {
|
|
296
|
-
let listener = (payload) => {
|
|
297
|
-
let destroy = initialize(payload);
|
|
298
|
-
if (destroy) $store.events[UNMOUNT].push(destroy);
|
|
299
|
-
};
|
|
300
|
-
return on($store, listener, MOUNT, (runListeners) => {
|
|
301
|
-
let originListen = $store.listen;
|
|
302
|
-
$store.listen = (...args) => {
|
|
303
|
-
if (!$store.lc && !$store.active) {
|
|
304
|
-
$store.active = true;
|
|
305
|
-
runListeners();
|
|
306
|
-
}
|
|
307
|
-
return originListen(...args);
|
|
308
|
-
};
|
|
309
|
-
let originOff = $store.off;
|
|
310
|
-
$store.events[UNMOUNT] = [];
|
|
311
|
-
$store.off = () => {
|
|
312
|
-
originOff();
|
|
313
|
-
setTimeout(() => {
|
|
314
|
-
if ($store.active && !$store.lc) {
|
|
315
|
-
$store.active = false;
|
|
316
|
-
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
317
|
-
$store.events[UNMOUNT] = [];
|
|
318
|
-
}
|
|
319
|
-
}, STORE_UNMOUNT_DELAY);
|
|
320
|
-
};
|
|
321
|
-
{
|
|
322
|
-
let originClean = $store[clean];
|
|
323
|
-
$store[clean] = () => {
|
|
324
|
-
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
325
|
-
$store.events[UNMOUNT] = [];
|
|
326
|
-
$store.active = false;
|
|
327
|
-
originClean();
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
return () => {
|
|
331
|
-
$store.listen = originListen;
|
|
332
|
-
$store.off = originOff;
|
|
333
|
-
};
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
// node_modules/better-auth/dist/client/query.mjs
|
|
338
|
-
var isServer = () => typeof window === "undefined";
|
|
339
|
-
var useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
340
|
-
const value = atom({
|
|
341
|
-
data: null,
|
|
342
|
-
error: null,
|
|
343
|
-
isPending: true,
|
|
344
|
-
isRefetching: false,
|
|
345
|
-
refetch: (queryParams) => fn(queryParams)
|
|
346
|
-
});
|
|
347
|
-
const fn = async (queryParams) => {
|
|
348
|
-
return new Promise((resolve) => {
|
|
349
|
-
const opts = typeof options === "function" ? options({
|
|
350
|
-
data: value.get().data,
|
|
351
|
-
error: value.get().error,
|
|
352
|
-
isPending: value.get().isPending
|
|
353
|
-
}) : options;
|
|
354
|
-
$fetch(path, {
|
|
355
|
-
...opts,
|
|
356
|
-
query: {
|
|
357
|
-
...opts?.query,
|
|
358
|
-
...queryParams?.query
|
|
359
|
-
},
|
|
360
|
-
async onSuccess(context) {
|
|
361
|
-
value.set({
|
|
362
|
-
data: context.data,
|
|
363
|
-
error: null,
|
|
364
|
-
isPending: false,
|
|
365
|
-
isRefetching: false,
|
|
366
|
-
refetch: value.value.refetch
|
|
367
|
-
});
|
|
368
|
-
await opts?.onSuccess?.(context);
|
|
369
|
-
},
|
|
370
|
-
async onError(context) {
|
|
371
|
-
const { request } = context;
|
|
372
|
-
const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
|
|
373
|
-
const retryAttempt = request.retryAttempt || 0;
|
|
374
|
-
if (retryAttempts && retryAttempt < retryAttempts) return;
|
|
375
|
-
const isUnauthorized = context.error.status === 401;
|
|
376
|
-
value.set({
|
|
377
|
-
error: context.error,
|
|
378
|
-
data: isUnauthorized ? null : value.get().data,
|
|
379
|
-
isPending: false,
|
|
380
|
-
isRefetching: false,
|
|
381
|
-
refetch: value.value.refetch
|
|
382
|
-
});
|
|
383
|
-
await opts?.onError?.(context);
|
|
384
|
-
},
|
|
385
|
-
async onRequest(context) {
|
|
386
|
-
const currentValue = value.get();
|
|
387
|
-
value.set({
|
|
388
|
-
isPending: currentValue.data === null,
|
|
389
|
-
data: currentValue.data,
|
|
390
|
-
error: null,
|
|
391
|
-
isRefetching: true,
|
|
392
|
-
refetch: value.value.refetch
|
|
393
|
-
});
|
|
394
|
-
await opts?.onRequest?.(context);
|
|
395
|
-
}
|
|
396
|
-
}).catch((error) => {
|
|
397
|
-
value.set({
|
|
398
|
-
error,
|
|
399
|
-
data: value.get().data,
|
|
400
|
-
isPending: false,
|
|
401
|
-
isRefetching: false,
|
|
402
|
-
refetch: value.value.refetch
|
|
403
|
-
});
|
|
404
|
-
}).finally(() => {
|
|
405
|
-
resolve(void 0);
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
410
|
-
let isInitialized = false;
|
|
411
|
-
for (const initAtom of initializedAtom) initAtom.subscribe(async () => {
|
|
412
|
-
if (isServer()) return;
|
|
413
|
-
if (isInitialized) await fn();
|
|
414
|
-
else onMount(value, () => {
|
|
415
|
-
const timeoutId = setTimeout(async () => {
|
|
416
|
-
if (!isInitialized) {
|
|
417
|
-
isInitialized = true;
|
|
418
|
-
await fn();
|
|
419
|
-
}
|
|
420
|
-
}, 0);
|
|
421
|
-
return () => {
|
|
422
|
-
value.off();
|
|
423
|
-
initAtom.off();
|
|
424
|
-
clearTimeout(timeoutId);
|
|
425
|
-
};
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
return value;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
// node_modules/better-auth/dist/client/session-refresh.mjs
|
|
432
|
-
var now2 = () => Math.floor(Date.now() / 1e3);
|
|
433
|
-
function normalizeSessionResponse(res) {
|
|
434
|
-
if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
|
|
435
|
-
return {
|
|
436
|
-
data: res,
|
|
437
|
-
error: null
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
var FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
|
|
441
|
-
function createSessionRefreshManager(opts) {
|
|
442
|
-
const { sessionAtom, sessionSignal, $fetch, options = {} } = opts;
|
|
443
|
-
const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
|
|
444
|
-
const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
|
|
445
|
-
const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
|
|
446
|
-
const state = {
|
|
447
|
-
lastSync: 0,
|
|
448
|
-
lastSessionRequest: 0,
|
|
449
|
-
cachedSession: void 0
|
|
450
|
-
};
|
|
451
|
-
const shouldRefetch = () => {
|
|
452
|
-
return refetchWhenOffline || getGlobalOnlineManager().isOnline;
|
|
453
|
-
};
|
|
454
|
-
const triggerRefetch = (event) => {
|
|
455
|
-
if (!shouldRefetch()) return;
|
|
456
|
-
if (event?.event === "storage") {
|
|
457
|
-
state.lastSync = now2();
|
|
458
|
-
sessionSignal.set(!sessionSignal.get());
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
const currentSession = sessionAtom.get();
|
|
462
|
-
const fetchSessionWithRefresh = () => {
|
|
463
|
-
state.lastSessionRequest = now2();
|
|
464
|
-
$fetch("/get-session").then(async (res) => {
|
|
465
|
-
let { data, error } = normalizeSessionResponse(res);
|
|
466
|
-
if (data?.needsRefresh) try {
|
|
467
|
-
const refreshRes = await $fetch("/get-session", { method: "POST" });
|
|
468
|
-
({ data, error } = normalizeSessionResponse(refreshRes));
|
|
469
|
-
} catch {
|
|
470
|
-
}
|
|
471
|
-
const sessionData = data?.session && data?.user ? data : null;
|
|
472
|
-
sessionAtom.set({
|
|
473
|
-
...currentSession,
|
|
474
|
-
data: sessionData,
|
|
475
|
-
error
|
|
476
|
-
});
|
|
477
|
-
state.lastSync = now2();
|
|
478
|
-
sessionSignal.set(!sessionSignal.get());
|
|
479
|
-
}).catch(() => {
|
|
480
|
-
});
|
|
481
|
-
};
|
|
482
|
-
if (event?.event === "poll") {
|
|
483
|
-
fetchSessionWithRefresh();
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
if (event?.event === "visibilitychange") {
|
|
487
|
-
if (now2() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS) return;
|
|
488
|
-
state.lastSessionRequest = now2();
|
|
489
|
-
}
|
|
490
|
-
if (event?.event === "visibilitychange") {
|
|
491
|
-
fetchSessionWithRefresh();
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
if (currentSession?.data === null || currentSession?.data === void 0) {
|
|
495
|
-
state.lastSync = now2();
|
|
496
|
-
sessionSignal.set(!sessionSignal.get());
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
const broadcastSessionUpdate = (trigger) => {
|
|
500
|
-
getGlobalBroadcastChannel().post({
|
|
501
|
-
event: "session",
|
|
502
|
-
data: { trigger },
|
|
503
|
-
clientId: Math.random().toString(36).substring(7)
|
|
504
|
-
});
|
|
505
|
-
};
|
|
506
|
-
const setupPolling = () => {
|
|
507
|
-
if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
|
|
508
|
-
if (sessionAtom.get()?.data) triggerRefetch({ event: "poll" });
|
|
509
|
-
}, refetchInterval * 1e3);
|
|
510
|
-
};
|
|
511
|
-
const setupBroadcast = () => {
|
|
512
|
-
state.unsubscribeBroadcast = getGlobalBroadcastChannel().subscribe(() => {
|
|
513
|
-
triggerRefetch({ event: "storage" });
|
|
514
|
-
});
|
|
515
|
-
};
|
|
516
|
-
const setupFocusRefetch = () => {
|
|
517
|
-
if (!refetchOnWindowFocus) return;
|
|
518
|
-
state.unsubscribeFocus = getGlobalFocusManager().subscribe(() => {
|
|
519
|
-
triggerRefetch({ event: "visibilitychange" });
|
|
520
|
-
});
|
|
521
|
-
};
|
|
522
|
-
const setupOnlineRefetch = () => {
|
|
523
|
-
state.unsubscribeOnline = getGlobalOnlineManager().subscribe((online) => {
|
|
524
|
-
if (online) triggerRefetch({ event: "visibilitychange" });
|
|
525
|
-
});
|
|
526
|
-
};
|
|
527
|
-
const init = () => {
|
|
528
|
-
setupPolling();
|
|
529
|
-
setupBroadcast();
|
|
530
|
-
setupFocusRefetch();
|
|
531
|
-
setupOnlineRefetch();
|
|
532
|
-
getGlobalBroadcastChannel().setup();
|
|
533
|
-
getGlobalFocusManager().setup();
|
|
534
|
-
getGlobalOnlineManager().setup();
|
|
535
|
-
};
|
|
536
|
-
const cleanup = () => {
|
|
537
|
-
if (state.pollInterval) {
|
|
538
|
-
clearInterval(state.pollInterval);
|
|
539
|
-
state.pollInterval = void 0;
|
|
540
|
-
}
|
|
541
|
-
if (state.unsubscribeBroadcast) {
|
|
542
|
-
state.unsubscribeBroadcast();
|
|
543
|
-
state.unsubscribeBroadcast = void 0;
|
|
544
|
-
}
|
|
545
|
-
if (state.unsubscribeFocus) {
|
|
546
|
-
state.unsubscribeFocus();
|
|
547
|
-
state.unsubscribeFocus = void 0;
|
|
548
|
-
}
|
|
549
|
-
if (state.unsubscribeOnline) {
|
|
550
|
-
state.unsubscribeOnline();
|
|
551
|
-
state.unsubscribeOnline = void 0;
|
|
552
|
-
}
|
|
553
|
-
state.lastSync = 0;
|
|
554
|
-
state.lastSessionRequest = 0;
|
|
555
|
-
state.cachedSession = void 0;
|
|
556
|
-
};
|
|
557
|
-
return {
|
|
558
|
-
init,
|
|
559
|
-
cleanup,
|
|
560
|
-
triggerRefetch,
|
|
561
|
-
broadcastSessionUpdate
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
566
|
-
var redirectPlugin = {
|
|
567
|
-
id: "redirect",
|
|
568
|
-
name: "Redirect",
|
|
569
|
-
hooks: { onSuccess(context) {
|
|
570
|
-
if (context.data?.url && context.data?.redirect) {
|
|
571
|
-
if (typeof window !== "undefined" && window.location) {
|
|
572
|
-
if (window.location) try {
|
|
573
|
-
window.location.href = context.data.url;
|
|
574
|
-
} catch {
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
} }
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
// node_modules/better-auth/dist/client/session-atom.mjs
|
|
582
|
-
function getSessionAtom($fetch, options) {
|
|
583
|
-
const $signal = atom(false);
|
|
584
|
-
const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
|
|
585
|
-
let broadcastSessionUpdate = () => {
|
|
586
|
-
};
|
|
587
|
-
onMount(session, () => {
|
|
588
|
-
const refreshManager = createSessionRefreshManager({
|
|
589
|
-
sessionAtom: session,
|
|
590
|
-
sessionSignal: $signal,
|
|
591
|
-
$fetch,
|
|
592
|
-
options
|
|
593
|
-
});
|
|
594
|
-
refreshManager.init();
|
|
595
|
-
broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
|
|
596
|
-
return () => {
|
|
597
|
-
refreshManager.cleanup();
|
|
598
|
-
};
|
|
599
|
-
});
|
|
600
|
-
return {
|
|
601
|
-
session,
|
|
602
|
-
$sessionSignal: $signal,
|
|
603
|
-
broadcastSessionUpdate: (trigger) => broadcastSessionUpdate(trigger)
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// node_modules/better-auth/dist/client/config.mjs
|
|
608
|
-
var resolvePublicAuthUrl = (basePath) => {
|
|
609
|
-
if (typeof process === "undefined") return void 0;
|
|
610
|
-
const path = basePath ?? "/api/auth";
|
|
611
|
-
if (process.env.NEXT_PUBLIC_AUTH_URL) return process.env.NEXT_PUBLIC_AUTH_URL;
|
|
612
|
-
if (typeof window === "undefined") {
|
|
613
|
-
if (process.env.NEXTAUTH_URL) try {
|
|
614
|
-
return process.env.NEXTAUTH_URL;
|
|
615
|
-
} catch {
|
|
616
|
-
}
|
|
617
|
-
if (process.env.VERCEL_URL) try {
|
|
618
|
-
const protocol = process.env.VERCEL_URL.startsWith("http") ? "" : "https://";
|
|
619
|
-
return `${new URL(`${protocol}${process.env.VERCEL_URL}`).origin}${path}`;
|
|
620
|
-
} catch {
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
var getClientConfig = (options, loadEnv) => {
|
|
625
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
626
|
-
const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? resolvePublicAuthUrl(options?.basePath) ?? "/api/auth";
|
|
627
|
-
const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
|
|
628
|
-
const lifeCyclePlugin = {
|
|
629
|
-
id: "lifecycle-hooks",
|
|
630
|
-
name: "lifecycle-hooks",
|
|
631
|
-
hooks: {
|
|
632
|
-
onSuccess: options?.fetchOptions?.onSuccess,
|
|
633
|
-
onError: options?.fetchOptions?.onError,
|
|
634
|
-
onRequest: options?.fetchOptions?.onRequest,
|
|
635
|
-
onResponse: options?.fetchOptions?.onResponse
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
const { onSuccess: _onSuccess, onError: _onError, onRequest: _onRequest, onResponse: _onResponse, ...restOfFetchOptions } = options?.fetchOptions || {};
|
|
639
|
-
const $fetch = createFetch({
|
|
640
|
-
baseURL,
|
|
641
|
-
...isCredentialsSupported ? { credentials: "include" } : {},
|
|
642
|
-
method: "GET",
|
|
643
|
-
jsonParser(text) {
|
|
644
|
-
if (!text) return null;
|
|
645
|
-
return parseJSON(text, { strict: false });
|
|
646
|
-
},
|
|
647
|
-
customFetchImpl: fetch,
|
|
648
|
-
...restOfFetchOptions,
|
|
649
|
-
plugins: [
|
|
650
|
-
lifeCyclePlugin,
|
|
651
|
-
...restOfFetchOptions.plugins || [],
|
|
652
|
-
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
653
|
-
...pluginsFetchPlugins
|
|
654
|
-
]
|
|
655
|
-
});
|
|
656
|
-
const { $sessionSignal, session, broadcastSessionUpdate } = getSessionAtom($fetch, options);
|
|
657
|
-
const plugins = options?.plugins || [];
|
|
658
|
-
let pluginsActions = {};
|
|
659
|
-
const pluginsAtoms = {
|
|
660
|
-
$sessionSignal,
|
|
661
|
-
session
|
|
662
|
-
};
|
|
663
|
-
const pluginPathMethods = {
|
|
664
|
-
"/sign-out": "POST",
|
|
665
|
-
"/revoke-sessions": "POST",
|
|
666
|
-
"/revoke-other-sessions": "POST",
|
|
667
|
-
"/delete-user": "POST"
|
|
668
|
-
};
|
|
669
|
-
const atomListeners = [{
|
|
670
|
-
signal: "$sessionSignal",
|
|
671
|
-
matcher(path) {
|
|
672
|
-
return path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
|
|
673
|
-
},
|
|
674
|
-
callback(path) {
|
|
675
|
-
if (path === "/sign-out") broadcastSessionUpdate("signout");
|
|
676
|
-
else if (path === "/update-user" || path === "/update-session") broadcastSessionUpdate("updateUser");
|
|
677
|
-
}
|
|
678
|
-
}];
|
|
679
|
-
for (const plugin of plugins) {
|
|
680
|
-
if (plugin.getAtoms) Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
|
|
681
|
-
if (plugin.pathMethods) Object.assign(pluginPathMethods, plugin.pathMethods);
|
|
682
|
-
if (plugin.atomListeners) atomListeners.push(...plugin.atomListeners);
|
|
683
|
-
}
|
|
684
|
-
const $store = {
|
|
685
|
-
notify: (signal) => {
|
|
686
|
-
pluginsAtoms[signal].set(!pluginsAtoms[signal].get());
|
|
687
|
-
},
|
|
688
|
-
listen: (signal, listener) => {
|
|
689
|
-
pluginsAtoms[signal].subscribe(listener);
|
|
690
|
-
},
|
|
691
|
-
atoms: pluginsAtoms
|
|
692
|
-
};
|
|
693
|
-
for (const plugin of plugins) if (plugin.getActions) pluginsActions = defu(plugin.getActions?.($fetch, $store, options) ?? {}, pluginsActions);
|
|
694
|
-
return {
|
|
695
|
-
get baseURL() {
|
|
696
|
-
return baseURL;
|
|
697
|
-
},
|
|
698
|
-
pluginsActions,
|
|
699
|
-
pluginsAtoms,
|
|
700
|
-
pluginPathMethods,
|
|
701
|
-
atomListeners,
|
|
702
|
-
$fetch,
|
|
703
|
-
$store
|
|
704
|
-
};
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
// node_modules/better-auth/dist/utils/is-atom.mjs
|
|
708
|
-
function isAtom(value) {
|
|
709
|
-
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
// node_modules/better-auth/dist/client/proxy.mjs
|
|
713
|
-
function getMethod(path, knownPathMethods, args) {
|
|
714
|
-
const method = knownPathMethods[path];
|
|
715
|
-
const { fetchOptions, query: _query, ...body } = args || {};
|
|
716
|
-
if (method) return method;
|
|
717
|
-
if (fetchOptions?.method) return fetchOptions.method;
|
|
718
|
-
if (body && Object.keys(body).length > 0) return "POST";
|
|
719
|
-
return "GET";
|
|
720
|
-
}
|
|
721
|
-
function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomListeners) {
|
|
722
|
-
function createProxy(path = []) {
|
|
723
|
-
return new Proxy(function() {
|
|
724
|
-
}, {
|
|
725
|
-
get(_, prop) {
|
|
726
|
-
if (typeof prop !== "string") return;
|
|
727
|
-
if (prop === "then" || prop === "catch" || prop === "finally") return;
|
|
728
|
-
const fullPath = [...path, prop];
|
|
729
|
-
let current = routes;
|
|
730
|
-
for (const segment of fullPath) if (current && typeof current === "object" && segment in current) current = current[segment];
|
|
731
|
-
else {
|
|
732
|
-
current = void 0;
|
|
733
|
-
break;
|
|
734
|
-
}
|
|
735
|
-
if (typeof current === "function") return current;
|
|
736
|
-
if (isAtom(current)) return current;
|
|
737
|
-
return createProxy(fullPath);
|
|
738
|
-
},
|
|
739
|
-
apply: async (_, __, args) => {
|
|
740
|
-
const routePath = "/" + path.map((segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)).join("/");
|
|
741
|
-
const arg = args[0] || {};
|
|
742
|
-
const fetchOptions = args[1] || {};
|
|
743
|
-
const { query, fetchOptions: argFetchOptions, ...body } = arg;
|
|
744
|
-
const options = {
|
|
745
|
-
...fetchOptions,
|
|
746
|
-
...argFetchOptions
|
|
747
|
-
};
|
|
748
|
-
const method = getMethod(routePath, knownPathMethods, arg);
|
|
749
|
-
return await client(routePath, {
|
|
750
|
-
...options,
|
|
751
|
-
body: method === "GET" ? void 0 : {
|
|
752
|
-
...body,
|
|
753
|
-
...options?.body || {}
|
|
754
|
-
},
|
|
755
|
-
query: query || options?.query,
|
|
756
|
-
method,
|
|
757
|
-
async onSuccess(context) {
|
|
758
|
-
await options?.onSuccess?.(context);
|
|
759
|
-
if (!atomListeners || options.disableSignal) return;
|
|
760
|
-
const matches = atomListeners.filter((s) => s.matcher(routePath));
|
|
761
|
-
if (!matches.length) return;
|
|
762
|
-
const visited = /* @__PURE__ */ new Set();
|
|
763
|
-
for (const match of matches) {
|
|
764
|
-
const signal = atoms[match.signal];
|
|
765
|
-
if (!signal) return;
|
|
766
|
-
if (visited.has(match.signal)) continue;
|
|
767
|
-
visited.add(match.signal);
|
|
768
|
-
const val = signal.get();
|
|
769
|
-
setTimeout(() => {
|
|
770
|
-
signal.set(!val);
|
|
771
|
-
}, 10);
|
|
772
|
-
match.callback?.(routePath);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
return createProxy();
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
// node_modules/better-auth/dist/client/vanilla.mjs
|
|
783
|
-
function createAuthClient(options) {
|
|
784
|
-
const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
785
|
-
const resolvedHooks = {};
|
|
786
|
-
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;
|
|
787
|
-
return createDynamicPathProxy({
|
|
788
|
-
...pluginsActions,
|
|
789
|
-
...resolvedHooks,
|
|
790
|
-
$fetch,
|
|
791
|
-
$store
|
|
792
|
-
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
// src/client/auth.ts
|
|
796
4
|
var AUTH_TOKEN_KEY = "better-auth.session_token";
|
|
797
5
|
function createLeapifyAuthClient(baseUrl) {
|
|
798
6
|
return createAuthClient({
|
|
@@ -841,50 +49,69 @@ async function signOut(authClient) {
|
|
|
841
49
|
return result;
|
|
842
50
|
}
|
|
843
51
|
|
|
844
|
-
// src/client/
|
|
845
|
-
var
|
|
846
|
-
|
|
52
|
+
// src/client/turnstile.ts
|
|
53
|
+
var TURNSTILE_VERIFY_PATH = "/.well-known/leapify/turnstile/verify";
|
|
54
|
+
function getTurnstileSiteKey() {
|
|
55
|
+
const config = window.__CONFIG__;
|
|
56
|
+
return config?.turnstileSiteKey;
|
|
57
|
+
}
|
|
58
|
+
function loadTurnstileScript() {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
if (typeof window.turnstile !== "undefined") {
|
|
61
|
+
resolve();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const script = document.createElement("script");
|
|
65
|
+
script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
|
|
66
|
+
script.async = true;
|
|
67
|
+
script.defer = true;
|
|
68
|
+
script.onload = () => resolve();
|
|
69
|
+
script.onerror = () => reject(new Error("Failed to load Turnstile script"));
|
|
70
|
+
document.head.appendChild(script);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function executeTurnstile(siteKey) {
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
const container = document.createElement("div");
|
|
76
|
+
container.id = "leapify-turnstile-container";
|
|
77
|
+
container.style.display = "none";
|
|
78
|
+
document.body.appendChild(container);
|
|
79
|
+
const timer = setTimeout(() => {
|
|
80
|
+
container.remove();
|
|
81
|
+
resolve("");
|
|
82
|
+
}, 1e4);
|
|
83
|
+
window.turnstile.render(`#${container.id}`, {
|
|
84
|
+
sitekey: siteKey,
|
|
85
|
+
callback: (token) => {
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
container.remove();
|
|
88
|
+
resolve(token);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function solveTurnstileChallenge(baseUrl, siteKey) {
|
|
94
|
+
siteKey = siteKey ?? getTurnstileSiteKey();
|
|
95
|
+
if (!siteKey) return false;
|
|
847
96
|
const base = baseUrl?.replace(/\/$/, "") ?? "";
|
|
848
|
-
let html;
|
|
849
97
|
try {
|
|
850
|
-
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
98
|
+
await loadTurnstileScript();
|
|
99
|
+
const token = await executeTurnstile(siteKey);
|
|
100
|
+
const res = await fetch(`${base}${TURNSTILE_VERIFY_PATH}`, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: { "Content-Type": "application/json" },
|
|
103
|
+
body: JSON.stringify({ token }),
|
|
104
|
+
credentials: "include"
|
|
105
|
+
});
|
|
106
|
+
return res.ok;
|
|
856
107
|
} catch {
|
|
857
108
|
return false;
|
|
858
109
|
}
|
|
859
|
-
const idMatch = html.match(/challengeId\s*=\s*"([^"]+)"/);
|
|
860
|
-
const diffMatch = html.match(/difficulty\s*=\s*(\d+)/);
|
|
861
|
-
if (!idMatch || !diffMatch) {
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
const challengeId = idMatch[1];
|
|
865
|
-
const difficulty = Number(diffMatch[1]);
|
|
866
|
-
const prefix = "0".repeat(Math.ceil(difficulty / 4));
|
|
867
|
-
let nonce = 0;
|
|
868
|
-
while (true) {
|
|
869
|
-
const input = new TextEncoder().encode(`${challengeId}:${nonce}`);
|
|
870
|
-
const hash = await crypto.subtle.digest("SHA-256", input);
|
|
871
|
-
const hex = Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
872
|
-
if (hex.startsWith(prefix)) {
|
|
873
|
-
await fetch(`${base}${POW_VERIFY_PATH}`, {
|
|
874
|
-
method: "POST",
|
|
875
|
-
headers: { "Content-Type": "application/json" },
|
|
876
|
-
body: JSON.stringify({ id: challengeId, nonce, elapsed: 0 }),
|
|
877
|
-
credentials: "include"
|
|
878
|
-
});
|
|
879
|
-
return true;
|
|
880
|
-
}
|
|
881
|
-
nonce++;
|
|
882
|
-
}
|
|
883
110
|
}
|
|
884
111
|
|
|
885
112
|
// src/client/session.ts
|
|
886
113
|
async function initializeSession(baseUrl, getToken) {
|
|
887
|
-
await
|
|
114
|
+
await solveTurnstileChallenge(baseUrl);
|
|
888
115
|
const token = await getToken();
|
|
889
116
|
if (!token) return null;
|
|
890
117
|
const base = baseUrl.replace(/\/$/, "");
|
|
@@ -897,7 +124,7 @@ async function initializeSession(baseUrl, getToken) {
|
|
|
897
124
|
}
|
|
898
125
|
|
|
899
126
|
// src/client/index.ts
|
|
900
|
-
function
|
|
127
|
+
function getClientConfig() {
|
|
901
128
|
if (typeof window === "undefined") return null;
|
|
902
129
|
const config = window.__CONFIG__;
|
|
903
130
|
if (!config || typeof config !== "object") return null;
|
|
@@ -1216,14 +443,6 @@ function createLeapifyClient(baseUrl, getToken) {
|
|
|
1216
443
|
formData.append("file", file);
|
|
1217
444
|
return postFormData("/api/uploads/images", formData);
|
|
1218
445
|
},
|
|
1219
|
-
// ── Content Sync ───────────────────────────────────────────────────────
|
|
1220
|
-
/**
|
|
1221
|
-
* POST /api/config/sync-content — admin only.
|
|
1222
|
-
* Pushes all D1 content to Contentful. Auto-generates content types if missing.
|
|
1223
|
-
*/
|
|
1224
|
-
syncContent() {
|
|
1225
|
-
return post("/api/config/sync-content");
|
|
1226
|
-
},
|
|
1227
446
|
// ── Health ─────────────────────────────────────────────────────────────
|
|
1228
447
|
/**
|
|
1229
448
|
* GET /health
|
|
@@ -1235,6 +454,6 @@ function createLeapifyClient(baseUrl, getToken) {
|
|
|
1235
454
|
};
|
|
1236
455
|
}
|
|
1237
456
|
|
|
1238
|
-
export { LEAPIFY_ERROR_CODES, LeapifyApiError, createLeapifyAuthClient, createLeapifyClient,
|
|
457
|
+
export { LEAPIFY_ERROR_CODES, LeapifyApiError, createLeapifyAuthClient, createLeapifyClient, getClientConfig, getLeapifyToken, initializeSession, signInWithGoogleRedirect, signOut, solveTurnstileChallenge, syncCookieSessionToStorage };
|
|
1239
458
|
//# sourceMappingURL=index.js.map
|
|
1240
459
|
//# sourceMappingURL=index.js.map
|