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