@niledatabase/client 5.0.0-alpha.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/index.js ADDED
@@ -0,0 +1,725 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Authorizer: () => Authorizer,
24
+ auth: () => auth,
25
+ broadcast: () => broadcast,
26
+ getCsrfToken: () => getCsrfToken,
27
+ getProviders: () => getProviders,
28
+ getSession: () => getSession,
29
+ getStatus: () => getStatus,
30
+ resetPassword: () => resetPassword,
31
+ signIn: () => signIn,
32
+ signOut: () => signOut,
33
+ signUp: () => signUp
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/logger.ts
38
+ var UnknownError = class extends Error {
39
+ code;
40
+ constructor(error) {
41
+ super(error?.message ?? error);
42
+ this.name = "UnknownError";
43
+ this.code = error.code;
44
+ if (error instanceof Error) {
45
+ this.stack = error.stack;
46
+ }
47
+ }
48
+ toJSON() {
49
+ return {
50
+ name: this.name,
51
+ message: this.message,
52
+ stack: this.stack
53
+ };
54
+ }
55
+ };
56
+ function formatError(o) {
57
+ if (o instanceof Error && !(o instanceof UnknownError)) {
58
+ return JSON.stringify({ message: o.message, stack: o.stack, name: o.name });
59
+ }
60
+ if (hasErrorProperty(o)) {
61
+ o.error = formatError(o.error);
62
+ o.message = o.message ?? o.error.message;
63
+ }
64
+ return o;
65
+ }
66
+ function hasErrorProperty(x) {
67
+ return !!x?.error;
68
+ }
69
+ var _logger = {
70
+ error(code, metadata) {
71
+ metadata = formatError(metadata);
72
+ console.error(`[nile-auth][error][${code}]`, metadata.message, metadata);
73
+ },
74
+ warn(code) {
75
+ console.warn(`[nile-auth][warn][${code}]`);
76
+ },
77
+ debug(code, metadata) {
78
+ console.log(`[next-auth][debug][${code}]`, metadata);
79
+ }
80
+ };
81
+ function proxyLogger(logger2 = _logger, authorizer2) {
82
+ try {
83
+ if (typeof window === "undefined") {
84
+ return logger2;
85
+ }
86
+ const clientLogger = {};
87
+ for (const level in logger2) {
88
+ clientLogger[level] = (code, metadata) => {
89
+ _logger[level](code, metadata);
90
+ if (level === "error") {
91
+ metadata = formatError(metadata);
92
+ }
93
+ metadata.client = true;
94
+ const url = `${authorizer2.state.basePath}/_log`;
95
+ const body = new URLSearchParams({ level, code, ...metadata });
96
+ if (navigator.sendBeacon) {
97
+ return navigator.sendBeacon(url, body);
98
+ }
99
+ return fetch(url, { method: "POST", body, keepalive: true });
100
+ };
101
+ }
102
+ return clientLogger;
103
+ } catch {
104
+ return _logger;
105
+ }
106
+ }
107
+ var logger = (authorizer2) => proxyLogger(_logger, authorizer2);
108
+
109
+ // src/broadcast.ts
110
+ function now() {
111
+ return Math.floor(Date.now() / 1e3);
112
+ }
113
+ function BroadcastChannel(name = "nextauth.message") {
114
+ return {
115
+ /** Get notified by other tabs/windows. */
116
+ receive(onReceive) {
117
+ const handler = (event) => {
118
+ if (event.key !== name) return;
119
+ const message = JSON.parse(event.newValue ?? "{}");
120
+ if (message?.event !== "session" || !message?.data) return;
121
+ onReceive(message);
122
+ };
123
+ window.addEventListener("storage", handler);
124
+ return () => window.removeEventListener("storage", handler);
125
+ },
126
+ /** Notify other tabs/windows. */
127
+ post(message) {
128
+ if (typeof window === "undefined") return;
129
+ try {
130
+ localStorage.setItem(
131
+ name,
132
+ JSON.stringify({ ...message, timestamp: now() })
133
+ );
134
+ } catch {
135
+ }
136
+ }
137
+ };
138
+ }
139
+ var broadcast = BroadcastChannel();
140
+
141
+ // src/observable.ts
142
+ function isEqual(a, b) {
143
+ if (a === b) return true;
144
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
145
+ return false;
146
+ }
147
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
148
+ const keysA = Object.keys(a);
149
+ const keysB = Object.keys(b);
150
+ if (keysA.length !== keysB.length) return false;
151
+ for (const key of keysA) {
152
+ if (!keysB.includes(key) || !isEqual(a[key], b[key])) {
153
+ return false;
154
+ }
155
+ }
156
+ return true;
157
+ }
158
+ function createObservableObject(obj, listenerKeys = ["loading", "session"], eventName = "objectChange") {
159
+ const eventTarget = new EventTarget();
160
+ const listeners = /* @__PURE__ */ new Map();
161
+ const handler = {
162
+ set(target, key, value) {
163
+ const prev = target[key];
164
+ target[key] = value;
165
+ if (isEqual(prev, value)) return true;
166
+ if (listenerKeys.includes(String(key))) {
167
+ eventTarget.dispatchEvent(
168
+ new CustomEvent(eventName, {
169
+ detail: { key, prev, next: value }
170
+ })
171
+ );
172
+ }
173
+ return true;
174
+ }
175
+ };
176
+ return {
177
+ proxy: new Proxy(obj, handler),
178
+ eventTarget,
179
+ addListener(callback) {
180
+ if (listeners.has(callback)) {
181
+ return;
182
+ }
183
+ const wrappedCallback = (e) => callback(e.detail);
184
+ listeners.set(callback, wrappedCallback);
185
+ eventTarget.addEventListener(eventName, wrappedCallback);
186
+ },
187
+ removeListener(callback) {
188
+ const wrappedCallback = listeners.get(callback);
189
+ if (wrappedCallback) {
190
+ eventTarget.removeEventListener(eventName, wrappedCallback);
191
+ listeners.delete(callback);
192
+ }
193
+ }
194
+ };
195
+ }
196
+
197
+ // src/Authorizer.ts
198
+ var Authorizer = class {
199
+ state;
200
+ logger;
201
+ requestInit;
202
+ addListener;
203
+ removeListener;
204
+ status;
205
+ constructor(config) {
206
+ const { proxy, addListener, removeListener } = createObservableObject(
207
+ {
208
+ basePath: parseUrl(config?.basePath).path,
209
+ baseUrl: parseUrl(config?.baseUrl).origin,
210
+ lastSync: 0,
211
+ getSession: () => void 0,
212
+ session: void 0,
213
+ loading: true
214
+ },
215
+ config?.listenerKeys,
216
+ "auth"
217
+ );
218
+ this.state = proxy;
219
+ this.addListener = addListener;
220
+ this.removeListener = removeListener;
221
+ this.logger = logger(this);
222
+ this.status = null;
223
+ }
224
+ async sync(event) {
225
+ try {
226
+ const storageEvent = event === "storage";
227
+ if (storageEvent || !this.state.session) {
228
+ this.state.getSession = await this.getSession;
229
+ this.state.lastSync = now();
230
+ }
231
+ if (!event || this.state.session == null || now() < this.state.lastSync) {
232
+ return;
233
+ }
234
+ this.state.lastSync = Date.now();
235
+ this.state.session = await this.getSession();
236
+ } catch (error) {
237
+ this.logger.error("CLIENT_SESSION_ERROR", error);
238
+ }
239
+ }
240
+ set baseUrl(val) {
241
+ this.state.baseUrl = val;
242
+ this.logger = logger(this);
243
+ }
244
+ get baseUrl() {
245
+ this.logger = logger(this);
246
+ return this.state.baseUrl;
247
+ }
248
+ configure(config) {
249
+ if (config?.basePath) this.state.basePath = parseUrl(config?.basePath).path;
250
+ if (config?.baseUrl) this.baseUrl = config.baseUrl;
251
+ if (config?.init) this.requestInit = config.init;
252
+ return this;
253
+ }
254
+ sanitize() {
255
+ return {
256
+ state: {
257
+ baseUrl: this.baseUrl,
258
+ session: {
259
+ user: {
260
+ email: this.state.session?.user?.email
261
+ }
262
+ }
263
+ },
264
+ requestInit: this.requestInit
265
+ };
266
+ }
267
+ async initialize(params) {
268
+ const { baseUrl, session, event } = params ?? {};
269
+ if (baseUrl) this.baseUrl = baseUrl;
270
+ const hasInitialSession = session !== void 0;
271
+ this.state.loading = !hasInitialSession;
272
+ this.state.lastSync = hasInitialSession ? now() : 0;
273
+ this.state.session = session;
274
+ await this.sync(event);
275
+ }
276
+ get apiBaseUrl() {
277
+ return `${this.baseUrl}${this.state.basePath}`;
278
+ }
279
+ async sendData(url, init) {
280
+ try {
281
+ const options = {
282
+ headers: {
283
+ "Content-Type": "application/json"
284
+ },
285
+ ...this.requestInit ? this.requestInit : {},
286
+ ...init
287
+ };
288
+ const filledUrl = !url.startsWith("http") ? `${window.location.origin}${url}` : url;
289
+ const res = await fetch(filledUrl, options);
290
+ this.state.loading = false;
291
+ return res;
292
+ } catch (error) {
293
+ this.logger.error("CLIENT_FETCH_ERROR", { error, url });
294
+ return void 0;
295
+ }
296
+ }
297
+ async fetchData(url, init) {
298
+ const options = {
299
+ ...this.requestInit ? this.requestInit : {},
300
+ ...init
301
+ };
302
+ const res = await this.sendData(url, options);
303
+ const errorHandler = res?.clone();
304
+ try {
305
+ if (res?.ok) {
306
+ const data = await res.json();
307
+ this.state.loading = false;
308
+ if (!res.ok) throw data;
309
+ return Object.keys(data).length > 0 ? data : void 0;
310
+ }
311
+ } catch (error) {
312
+ if (error instanceof Error) {
313
+ if (!error.message.includes("is not valid JSON")) {
314
+ this.logger.error("CLIENT_FETCH_ERROR", {
315
+ error,
316
+ url
317
+ });
318
+ } else {
319
+ const error2 = await errorHandler?.text();
320
+ if (error2) {
321
+ if (errorHandler) {
322
+ const urlSearchParams = new URLSearchParams({ error: error2 });
323
+ return { url: `${url}?${urlSearchParams}` };
324
+ }
325
+ }
326
+ }
327
+ }
328
+ return void 0;
329
+ }
330
+ }
331
+ async fetchFormData(url, init) {
332
+ try {
333
+ const res = await fetch(url, {
334
+ ...this.requestInit,
335
+ ...init,
336
+ headers: {
337
+ "Content-Type": "application/x-www-form-urlencoded"
338
+ }
339
+ });
340
+ if (res) {
341
+ if (res.ok) {
342
+ return {
343
+ data: await res.json(),
344
+ status: res.status,
345
+ ok: res.ok,
346
+ url: res.url
347
+ };
348
+ }
349
+ const { url: responseUrl } = await res.json();
350
+ return {
351
+ data: {},
352
+ status: res.status,
353
+ ok: res?.ok,
354
+ url: responseUrl
355
+ };
356
+ }
357
+ throw new Error(`Unable to fetch ${url}`);
358
+ } catch (error) {
359
+ if (error instanceof Error) {
360
+ if (!error.message.includes("is not valid JSON")) {
361
+ this.logger.error("CLIENT_FETCH_ERROR", {
362
+ error,
363
+ url
364
+ });
365
+ }
366
+ }
367
+ return void 0;
368
+ }
369
+ }
370
+ async getProviders(url) {
371
+ return await this.fetchData(url ?? `${this.apiBaseUrl}/auth/providers`);
372
+ }
373
+ async getCsrfToken(url) {
374
+ const response = await this.fetchData(
375
+ url ?? `${this.apiBaseUrl}/auth/csrf`
376
+ );
377
+ return response?.csrfToken;
378
+ }
379
+ async getSession(params) {
380
+ if (this.status === "getSession" /* SESSION */) {
381
+ return;
382
+ }
383
+ this.status = "getSession" /* SESSION */;
384
+ if (params?.init) {
385
+ this.requestInit = params.init;
386
+ }
387
+ if (params?.baseUrl) {
388
+ this.baseUrl = params.baseUrl;
389
+ }
390
+ if (this.state.session && now() < this.state.lastSync) {
391
+ this.status = null;
392
+ return this.state.session;
393
+ }
394
+ this.state.loading = true;
395
+ const session = await this.fetchData(
396
+ `${this.apiBaseUrl}/auth/session`
397
+ );
398
+ broadcast.post({ event: "session", data: { trigger: "getSession" } });
399
+ this.status = null;
400
+ if (session) {
401
+ this.state.session = session;
402
+ await this.sync("storage");
403
+ return { ...session, loading: this.state.loading };
404
+ }
405
+ return { loading: this.state.loading };
406
+ }
407
+ async refreshSession() {
408
+ this.state.loading = true;
409
+ const session = await this.fetchData(
410
+ `${this.apiBaseUrl}/auth/session`
411
+ );
412
+ broadcast.post({ event: "session", data: { trigger: "getSession" } });
413
+ this.state.session = session;
414
+ await this.sync("storage");
415
+ return session;
416
+ }
417
+ async signOut(options) {
418
+ const {
419
+ callbackUrl = window.location.href,
420
+ baseUrl,
421
+ auth: auth2,
422
+ fetchUrl,
423
+ basePath
424
+ } = options ?? {};
425
+ if (basePath) {
426
+ this.state.basePath = basePath;
427
+ }
428
+ if (baseUrl) {
429
+ this.baseUrl = baseUrl;
430
+ }
431
+ if (auth2) {
432
+ this.requestInit = auth2.requestInit;
433
+ if (auth2.state?.baseUrl) {
434
+ this.baseUrl = auth2.state.baseUrl;
435
+ }
436
+ }
437
+ const baseFetch = fetchUrl ?? `${this.apiBaseUrl}/auth/signout`;
438
+ const fetchOptions = {
439
+ method: "post",
440
+ body: new URLSearchParams({
441
+ csrfToken: String(await this.getCsrfToken()),
442
+ callbackUrl,
443
+ json: String(true)
444
+ })
445
+ };
446
+ const res = await this.fetchFormData(
447
+ baseFetch,
448
+ fetchOptions
449
+ );
450
+ broadcast.post({ event: "session", data: { trigger: "signout" } });
451
+ if (this.requestInit?.credentials) {
452
+ window.location.href = callbackUrl;
453
+ if (callbackUrl.includes("#")) window.location.reload();
454
+ return void 0;
455
+ }
456
+ if (options?.redirect ?? true) {
457
+ const url = res?.data?.url ?? callbackUrl;
458
+ window.location.href = url;
459
+ if (url.includes("#")) window.location.reload();
460
+ return void 0;
461
+ }
462
+ await this.state.getSession({ event: "storage" });
463
+ return res?.data;
464
+ }
465
+ async signIn(provider, options, authorizationParams) {
466
+ const {
467
+ callbackUrl = window.location.href,
468
+ resetUrl = window.location.href,
469
+ providersUrl,
470
+ csrfUrl,
471
+ baseUrl,
472
+ fetchUrl,
473
+ init,
474
+ auth: auth2,
475
+ redirect = true,
476
+ ...remaining
477
+ } = options ?? {};
478
+ if (baseUrl) {
479
+ this.baseUrl = baseUrl;
480
+ }
481
+ if (auth2) {
482
+ if (auth2.requestInit) {
483
+ this.requestInit = auth2.requestInit;
484
+ }
485
+ if (auth2.state?.baseUrl) {
486
+ this.baseUrl = auth2.state.baseUrl;
487
+ }
488
+ }
489
+ if (init) {
490
+ this.requestInit = init;
491
+ }
492
+ const providers = await this.getProviders(providersUrl);
493
+ if (!providers) {
494
+ return { error: "No providers enabled" };
495
+ }
496
+ if (!provider || !(provider in providers)) {
497
+ return { error: `Provider ${provider} not enabled` };
498
+ }
499
+ const isCredentials = providers[provider].type === "credentials";
500
+ const isEmail = providers[provider].type === "email";
501
+ const isSupportingReturn = isCredentials || isEmail;
502
+ const baseFetch = `${this.apiBaseUrl}/auth`;
503
+ const signInUrl = fetchUrl ?? `${baseFetch}/${isCredentials ? "callback" : "signin"}/${provider}`;
504
+ const _signInUrl = `${signInUrl}${authorizationParams ? `?${new URLSearchParams(authorizationParams)}` : ""}`;
505
+ const data = await this.fetchFormData(_signInUrl, {
506
+ method: "post",
507
+ body: new URLSearchParams({
508
+ ...remaining,
509
+ csrfToken: String(await this.getCsrfToken(csrfUrl)),
510
+ callbackUrl,
511
+ json: String(true),
512
+ resetUrl
513
+ })
514
+ });
515
+ if (data?.ok && this.requestInit?.credentials && isSupportingReturn) {
516
+ window.location.reload();
517
+ return;
518
+ }
519
+ if (data?.ok && (redirect || !isSupportingReturn)) {
520
+ const url = data?.data.url ?? callbackUrl;
521
+ window.location.href = url;
522
+ if (url.includes("#")) window.location.reload();
523
+ return;
524
+ }
525
+ const error = data?.data?.url ? new URL(String(data?.data?.url)).searchParams.get("error") : null;
526
+ if (data?.ok) {
527
+ await this.initialize();
528
+ await this.getSession({ event: "storage" });
529
+ }
530
+ return {
531
+ error,
532
+ status: data?.status,
533
+ ok: data?.ok,
534
+ url: error ? null : data?.url
535
+ };
536
+ }
537
+ async signUp(options) {
538
+ const {
539
+ password,
540
+ tenantId,
541
+ fetchUrl,
542
+ newTenantName,
543
+ createTenant,
544
+ baseUrl,
545
+ init,
546
+ email,
547
+ auth: auth2,
548
+ callbackUrl = window.location.href
549
+ } = options;
550
+ if (baseUrl) {
551
+ this.baseUrl = baseUrl;
552
+ }
553
+ if (auth2) {
554
+ if (auth2.requestInit) {
555
+ this.requestInit = auth2.requestInit;
556
+ }
557
+ if (auth2.state?.baseUrl) {
558
+ this.baseUrl = auth2.state.baseUrl;
559
+ }
560
+ }
561
+ if (init) {
562
+ this.requestInit = init;
563
+ }
564
+ const searchParams = new URLSearchParams();
565
+ if (newTenantName) {
566
+ searchParams.set("newTenantName", newTenantName);
567
+ } else if (createTenant) {
568
+ if (typeof createTenant === "boolean") {
569
+ searchParams.set("newTenantName", email);
570
+ } else if (typeof createTenant === "string") {
571
+ searchParams.set("newTenantName", createTenant);
572
+ }
573
+ }
574
+ if (tenantId) {
575
+ searchParams.set("tenantId", tenantId);
576
+ }
577
+ let signUpUrl = fetchUrl ?? `${this.apiBaseUrl}/signup`;
578
+ if (searchParams.size > 0) {
579
+ signUpUrl += `?${searchParams}`;
580
+ }
581
+ const data = await this.fetchData(signUpUrl, {
582
+ method: "post",
583
+ body: JSON.stringify({ email, password })
584
+ });
585
+ const error = data?.url ? new URL(data.url).searchParams.get("error") : null;
586
+ if (!error) {
587
+ if (data) {
588
+ await this.initialize({ event: "storage" });
589
+ await this.getSession({ event: "storage" });
590
+ }
591
+ if (this.requestInit?.credentials) {
592
+ window.location.reload();
593
+ return;
594
+ }
595
+ if (options?.redirect ?? true) {
596
+ const url = callbackUrl;
597
+ window.location.href = url;
598
+ if (url.includes("#")) window.location.reload();
599
+ }
600
+ }
601
+ return {
602
+ data,
603
+ error
604
+ };
605
+ }
606
+ async resetPassword(options) {
607
+ const { password, fetchUrl, email, redirect, callbackUrl } = options;
608
+ this._configureFetch(options);
609
+ const resetPasswordUrl = fetchUrl ?? `${this.apiBaseUrl}/auth/reset-password`;
610
+ let resetPasswordWithParams = resetPasswordUrl;
611
+ const searchParams = new URLSearchParams();
612
+ if (redirect === false) {
613
+ searchParams.set("json", "true");
614
+ }
615
+ if (searchParams.size > 0) {
616
+ resetPasswordWithParams += `?${searchParams}`;
617
+ }
618
+ const data = await this.fetchData(resetPasswordWithParams, {
619
+ method: "post",
620
+ body: JSON.stringify({
621
+ email,
622
+ password,
623
+ redirectUrl: resetPasswordUrl,
624
+ callbackUrl
625
+ })
626
+ });
627
+ if (redirect === false) {
628
+ const { url: urlWithParams } = data;
629
+ resetPasswordWithParams = `${urlWithParams}&redirect=false`;
630
+ await this.sendData(resetPasswordWithParams);
631
+ }
632
+ return await this.sendData(resetPasswordWithParams, {
633
+ method: password ? "put" : "post",
634
+ body: JSON.stringify({ email, password })
635
+ });
636
+ }
637
+ _configureFetch(params) {
638
+ const { baseUrl, init, auth: auth2 } = params;
639
+ if (baseUrl) {
640
+ this.baseUrl = baseUrl;
641
+ }
642
+ if (auth2) {
643
+ if (auth2.requestInit) {
644
+ this.requestInit = auth2.requestInit;
645
+ }
646
+ if (auth2.state?.baseUrl) {
647
+ this.baseUrl = auth2.state.baseUrl;
648
+ }
649
+ }
650
+ if (init) {
651
+ this.requestInit = init;
652
+ }
653
+ }
654
+ };
655
+ function parseUrl(url) {
656
+ let defaultUrl = new URL("http://localhost:3000");
657
+ if (typeof window !== "undefined") {
658
+ defaultUrl = new URL(`${window.location.origin}/api`);
659
+ }
660
+ if (url && !url.startsWith("http")) {
661
+ url = `https://${url}`;
662
+ }
663
+ const _url = new URL(url ?? defaultUrl);
664
+ const path = (_url.pathname === "/" ? defaultUrl.pathname : _url.pathname).replace(/\/$/, "");
665
+ const base = `${_url.origin}${path}`;
666
+ return {
667
+ origin: _url.origin,
668
+ host: _url.host,
669
+ path,
670
+ base,
671
+ toString: () => base
672
+ };
673
+ }
674
+ var authorizer = new Authorizer();
675
+ var _auth = () => {
676
+ return authorizer;
677
+ };
678
+ var auth = _auth();
679
+ var getSession = async function getSession2(params) {
680
+ return await auth.getSession(params);
681
+ };
682
+ var getCsrfToken = async function getCsrfToken2(url) {
683
+ return auth.getCsrfToken(url);
684
+ };
685
+ var getProviders = async function getProviders2() {
686
+ return auth.getProviders();
687
+ };
688
+ var signOut = async function signOut2(options) {
689
+ return auth.signOut(options);
690
+ };
691
+ var signIn = async function signOut3(provider, options, authParams) {
692
+ return auth.signIn(provider, options, authParams);
693
+ };
694
+ var signUp = async function signUp2(options) {
695
+ return auth.signUp(options);
696
+ };
697
+ var resetPassword = async function resetPassword2(options) {
698
+ return auth.resetPassword(options);
699
+ };
700
+
701
+ // src/status.ts
702
+ function getStatus(load, sess) {
703
+ if (load) {
704
+ return "loading";
705
+ }
706
+ if (sess) {
707
+ return "authenticated";
708
+ }
709
+ return "unauthenticated";
710
+ }
711
+ // Annotate the CommonJS export names for ESM import in node:
712
+ 0 && (module.exports = {
713
+ Authorizer,
714
+ auth,
715
+ broadcast,
716
+ getCsrfToken,
717
+ getProviders,
718
+ getSession,
719
+ getStatus,
720
+ resetPassword,
721
+ signIn,
722
+ signOut,
723
+ signUp
724
+ });
725
+ //# sourceMappingURL=index.js.map