@neondatabase/auth 0.1.0-beta.2 → 0.1.0-beta.20
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/README.md +112 -18
- package/dist/{adapter-core-C12KoaiU.d.mts → adapter-core-23fYTUxT.d.mts} +175 -627
- package/dist/{adapter-core-BDOw-gBC.mjs → adapter-core-8s6XdCco.mjs} +392 -69
- package/dist/{better-auth-react-adapter-FnBHa2nr.mjs → better-auth-react-adapter-D9tIaEyQ.mjs} +10 -8
- package/dist/better-auth-react-adapter-QFe5RtaM.d.mts +2170 -0
- package/dist/better-auth-types-BUiggBfa.d.mts +9 -0
- package/dist/chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs +543 -0
- package/dist/constants-2bpp2_-f.mjs +30 -0
- package/dist/index-Bga0CzOO.d.mts +49 -0
- package/dist/index.d.mts +5 -98
- package/dist/index.mjs +2 -1
- package/dist/middleware-C7jHeulu.mjs +303 -0
- package/dist/{neon-auth-C9XTFffv.mjs → neon-auth-2f58U8_-.mjs} +7 -4
- package/dist/neon-auth-CDYpC_O1.d.mts +107 -0
- package/dist/next/index.d.mts +139 -303
- package/dist/next/index.mjs +37 -174
- package/dist/next/server/index.d.mts +389 -0
- package/dist/next/server/index.mjs +432 -0
- package/dist/react/adapters/index.d.mts +5 -4
- package/dist/react/adapters/index.mjs +2 -1
- package/dist/react/index.d.mts +6 -5
- package/dist/react/index.mjs +5 -92
- package/dist/react/ui/index.d.mts +1 -1
- package/dist/react/ui/index.mjs +3 -91
- package/dist/react/ui/server.mjs +1 -1
- package/dist/{supabase-adapter-ggmqWgPe.mjs → supabase-adapter-BYMJSxOT.mjs} +72 -167
- package/dist/supabase-adapter-Dr-pKvPt.d.mts +2258 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.mjs +3 -0
- package/dist/ui/.safelist.html +3 -0
- package/dist/ui/css.css +2 -2
- package/dist/ui/tailwind.css +3 -2
- package/dist/ui/theme-inline.css +39 -0
- package/dist/ui/theme.css +125 -49
- package/dist/ui-Cg1EZzGG.mjs +12104 -0
- package/dist/vanilla/adapters/index.d.mts +4 -3
- package/dist/vanilla/adapters/index.mjs +2 -1
- package/dist/vanilla/index.d.mts +4 -3
- package/dist/vanilla/index.mjs +2 -1
- package/llms.txt +172 -0
- package/package.json +21 -10
- package/dist/better-auth-react-adapter-BXL48HIU.d.mts +0 -722
- package/dist/supabase-adapter-crabDnl2.d.mts +0 -128
- package/dist/ui-CNFBSekF.mjs +0 -401
- /package/dist/{adapters-Dkx0zoMR.mjs → adapters-B7YKkjaL.mjs} +0 -0
- /package/dist/{index-C-svZlpj.d.mts → index-BHI9uOzY.d.mts} +0 -0
- /package/dist/{index-DuDD6cIY.d.mts → index-CSe4aQIZ.d.mts} +0 -0
- /package/dist/{index-UW23fDSn.d.mts → index-LhFpnU-f.d.mts} +0 -0
package/dist/react/ui/index.mjs
CHANGED
|
@@ -1,93 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { n as
|
|
2
|
+
import { c as getViewByPath, n as authLocalization, r as authViewPaths, t as accountViewPaths, u as organizationViewPaths } from "../../chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs";
|
|
3
|
+
import { $ as RobloxIcon, A as MagicLinkForm, At as useAuthenticate, B as OrganizationSettingsCards, C as GitLabIcon, Ct as UserInvitationsCard, D as KickIcon, Dt as ZoomIcon, E as InputFieldSkeleton, Et as XIcon3, F as OrganizationInvitationsCard, G as PasskeysCard, H as OrganizationSwitcher, I as OrganizationLogo, J as RecoverAccountForm, K as PasswordInput, L as OrganizationLogoCard, M as NeonAuthUIProvider, Mt as useTheme, N as NotionIcon, O as LinearIcon, Ot as socialProviders, P as OrganizationCellView, Q as ResetPasswordForm, R as OrganizationMembersCard, S as GitHubIcon, St as UserButton, T as HuggingFaceIcon, Tt as VKIcon, U as OrganizationView, V as OrganizationSlugCard, W as OrganizationsCard, X as RedirectToSignIn, Y as RedditIcon, Z as RedirectToSignUp, _ as DeleteOrganizationCard, _t as UpdateAvatarCard, a as AppleIcon, at as SignOut, b as FacebookIcon, bt as UpdateUsernameCard, c as AuthLoading, ct as SignedOut, d as AuthView, dt as TeamCell, et as SecuritySettingsCards, f as ChangeEmailCard, ft as TeamsCard, g as DeleteAccountCard, gt as TwoFactorForm, h as CreateTeamDialog, ht as TwoFactorCard, i as AccountsCard, it as SignInForm, j as MicrosoftIcon, jt as useCurrentOrganization, k as LinkedInIcon, kt as useAuthData, l as AuthUIContext, lt as SlackIcon, m as CreateOrganizationDialog, mt as TwitchIcon, n as AccountSettingsCards, nt as SettingsCard, o as AuthCallback, ot as SignUpForm, p as ChangePasswordCard, pt as TikTokIcon, q as ProvidersCard, r as AccountView, rt as SettingsCellSkeleton, s as AuthForm, st as SignedIn, t as AcceptInvitationCard, tt as SessionsCard, u as AuthUIProvider, ut as SpotifyIcon, v as DiscordIcon, vt as UpdateFieldCard, w as GoogleIcon, wt as UserView, x as ForgotPasswordForm, xt as UserAvatar, y as DropboxIcon, yt as UpdateNameCard, z as OrganizationNameCard } from "../../ui-Cg1EZzGG.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
var AccountSettingsCards = dist_exports.AccountSettingsCards;
|
|
6
|
-
var AccountView = dist_exports.AccountView;
|
|
7
|
-
var AccountsCard = dist_exports.AccountsCard;
|
|
8
|
-
var AppleIcon = dist_exports.AppleIcon;
|
|
9
|
-
var AuthCallback = dist_exports.AuthCallback;
|
|
10
|
-
var AuthForm = dist_exports.AuthForm;
|
|
11
|
-
var AuthLoading = dist_exports.AuthLoading;
|
|
12
|
-
var AuthUIContext = dist_exports.AuthUIContext;
|
|
13
|
-
var AuthUIProvider = dist_exports.AuthUIProvider;
|
|
14
|
-
var AuthView = dist_exports.AuthView;
|
|
15
|
-
var ChangeEmailCard = dist_exports.ChangeEmailCard;
|
|
16
|
-
var ChangePasswordCard = dist_exports.ChangePasswordCard;
|
|
17
|
-
var CreateOrganizationDialog = dist_exports.CreateOrganizationDialog;
|
|
18
|
-
var CreateTeamDialog = dist_exports.CreateTeamDialog;
|
|
19
|
-
var DeleteAccountCard = dist_exports.DeleteAccountCard;
|
|
20
|
-
var DeleteOrganizationCard = dist_exports.DeleteOrganizationCard;
|
|
21
|
-
var DiscordIcon = dist_exports.DiscordIcon;
|
|
22
|
-
var DropboxIcon = dist_exports.DropboxIcon;
|
|
23
|
-
var FacebookIcon = dist_exports.FacebookIcon;
|
|
24
|
-
var ForgotPasswordForm = dist_exports.ForgotPasswordForm;
|
|
25
|
-
var GitHubIcon = dist_exports.GitHubIcon;
|
|
26
|
-
var GitLabIcon = dist_exports.GitLabIcon;
|
|
27
|
-
var GoogleIcon = dist_exports.GoogleIcon;
|
|
28
|
-
var HuggingFaceIcon = dist_exports.HuggingFaceIcon;
|
|
29
|
-
var InputFieldSkeleton = dist_exports.InputFieldSkeleton;
|
|
30
|
-
var KickIcon = dist_exports.KickIcon;
|
|
31
|
-
var LinearIcon = dist_exports.LinearIcon;
|
|
32
|
-
var LinkedInIcon = dist_exports.LinkedInIcon;
|
|
33
|
-
var MagicLinkForm = dist_exports.MagicLinkForm;
|
|
34
|
-
var MicrosoftIcon = dist_exports.MicrosoftIcon;
|
|
35
|
-
var NotionIcon = dist_exports.NotionIcon;
|
|
36
|
-
var OrganizationCellView = dist_exports.OrganizationCellView;
|
|
37
|
-
var OrganizationInvitationsCard = dist_exports.OrganizationInvitationsCard;
|
|
38
|
-
var OrganizationLogo = dist_exports.OrganizationLogo;
|
|
39
|
-
var OrganizationLogoCard = dist_exports.OrganizationLogoCard;
|
|
40
|
-
var OrganizationMembersCard = dist_exports.OrganizationMembersCard;
|
|
41
|
-
var OrganizationNameCard = dist_exports.OrganizationNameCard;
|
|
42
|
-
var OrganizationSettingsCards = dist_exports.OrganizationSettingsCards;
|
|
43
|
-
var OrganizationSlugCard = dist_exports.OrganizationSlugCard;
|
|
44
|
-
var OrganizationSwitcher = dist_exports.OrganizationSwitcher;
|
|
45
|
-
var OrganizationView = dist_exports.OrganizationView;
|
|
46
|
-
var OrganizationsCard = dist_exports.OrganizationsCard;
|
|
47
|
-
var PasskeysCard = dist_exports.PasskeysCard;
|
|
48
|
-
var PasswordInput = dist_exports.PasswordInput;
|
|
49
|
-
var ProvidersCard = dist_exports.ProvidersCard;
|
|
50
|
-
var RecoverAccountForm = dist_exports.RecoverAccountForm;
|
|
51
|
-
var RedditIcon = dist_exports.RedditIcon;
|
|
52
|
-
var RedirectToSignIn = dist_exports.RedirectToSignIn;
|
|
53
|
-
var RedirectToSignUp = dist_exports.RedirectToSignUp;
|
|
54
|
-
var ResetPasswordForm = dist_exports.ResetPasswordForm;
|
|
55
|
-
var RobloxIcon = dist_exports.RobloxIcon;
|
|
56
|
-
var SecuritySettingsCards = dist_exports.SecuritySettingsCards;
|
|
57
|
-
var SessionsCard = dist_exports.SessionsCard;
|
|
58
|
-
var SettingsCard = dist_exports.SettingsCard;
|
|
59
|
-
var SettingsCellSkeleton = dist_exports.SettingsCellSkeleton;
|
|
60
|
-
var SignInForm = dist_exports.SignInForm;
|
|
61
|
-
var SignOut = dist_exports.SignOut;
|
|
62
|
-
var SignUpForm = dist_exports.SignUpForm;
|
|
63
|
-
var SignedIn = dist_exports.SignedIn;
|
|
64
|
-
var SignedOut = dist_exports.SignedOut;
|
|
65
|
-
var SlackIcon = dist_exports.SlackIcon;
|
|
66
|
-
var SpotifyIcon = dist_exports.SpotifyIcon;
|
|
67
|
-
var TeamCell = dist_exports.TeamCell;
|
|
68
|
-
var TeamsCard = dist_exports.TeamsCard;
|
|
69
|
-
var TikTokIcon = dist_exports.TikTokIcon;
|
|
70
|
-
var TwitchIcon = dist_exports.TwitchIcon;
|
|
71
|
-
var TwoFactorCard = dist_exports.TwoFactorCard;
|
|
72
|
-
var TwoFactorForm = dist_exports.TwoFactorForm;
|
|
73
|
-
var UpdateAvatarCard = dist_exports.UpdateAvatarCard;
|
|
74
|
-
var UpdateFieldCard = dist_exports.UpdateFieldCard;
|
|
75
|
-
var UpdateNameCard = dist_exports.UpdateNameCard;
|
|
76
|
-
var UpdateUsernameCard = dist_exports.UpdateUsernameCard;
|
|
77
|
-
var UserAvatar = dist_exports.UserAvatar;
|
|
78
|
-
var UserButton = dist_exports.UserButton;
|
|
79
|
-
var UserInvitationsCard = dist_exports.UserInvitationsCard;
|
|
80
|
-
var UserView = dist_exports.UserView;
|
|
81
|
-
var VKIcon = dist_exports.VKIcon;
|
|
82
|
-
var XIcon = dist_exports.XIcon;
|
|
83
|
-
var ZoomIcon = dist_exports.ZoomIcon;
|
|
84
|
-
var accountViewPaths = dist_exports.accountViewPaths;
|
|
85
|
-
var authLocalization = dist_exports.authLocalization;
|
|
86
|
-
var authViewPaths = dist_exports.authViewPaths;
|
|
87
|
-
var getViewByPath = dist_exports.getViewByPath;
|
|
88
|
-
var organizationViewPaths = dist_exports.organizationViewPaths;
|
|
89
|
-
var socialProviders = dist_exports.socialProviders;
|
|
90
|
-
var useAuthData = dist_exports.useAuthData;
|
|
91
|
-
var useAuthenticate = dist_exports.useAuthenticate;
|
|
92
|
-
var useCurrentOrganization = dist_exports.useCurrentOrganization;
|
|
93
|
-
export { AcceptInvitationCard, AccountSettingsCards, AccountView, AccountsCard, AppleIcon, AuthCallback, AuthForm, AuthLoading, AuthUIContext, AuthUIProvider, AuthView, ChangeEmailCard, ChangePasswordCard, CreateOrganizationDialog, CreateTeamDialog, DeleteAccountCard, DeleteOrganizationCard, DiscordIcon, DropboxIcon, FacebookIcon, ForgotPasswordForm, GitHubIcon, GitLabIcon, GoogleIcon, HuggingFaceIcon, InputFieldSkeleton, KickIcon, LinearIcon, LinkedInIcon, MagicLinkForm, MicrosoftIcon, NeonAuthUIProvider, NotionIcon, OrganizationCellView, OrganizationInvitationsCard, OrganizationLogo, OrganizationLogoCard, OrganizationMembersCard, OrganizationNameCard, OrganizationSettingsCards, OrganizationSlugCard, OrganizationSwitcher, OrganizationView, OrganizationsCard, PasskeysCard, PasswordInput, ProvidersCard, RecoverAccountForm, RedditIcon, RedirectToSignIn, RedirectToSignUp, ResetPasswordForm, RobloxIcon, SecuritySettingsCards, SessionsCard, SettingsCard, SettingsCellSkeleton, SignInForm, SignOut, SignUpForm, SignedIn, SignedOut, SlackIcon, SpotifyIcon, TeamCell, TeamsCard, TikTokIcon, TwitchIcon, TwoFactorCard, TwoFactorForm, UpdateAvatarCard, UpdateFieldCard, UpdateNameCard, UpdateUsernameCard, UserAvatar, UserButton, UserInvitationsCard, UserView, VKIcon, XIcon, ZoomIcon, accountViewPaths, authLocalization, authViewPaths, getViewByPath, organizationViewPaths, socialProviders, useAuthData, useAuthenticate, useCurrentOrganization, useTheme };
|
|
5
|
+
export { AcceptInvitationCard, AccountSettingsCards, AccountView, AccountsCard, AppleIcon, AuthCallback, AuthForm, AuthLoading, AuthUIContext, AuthUIProvider, AuthView, ChangeEmailCard, ChangePasswordCard, CreateOrganizationDialog, CreateTeamDialog, DeleteAccountCard, DeleteOrganizationCard, DiscordIcon, DropboxIcon, FacebookIcon, ForgotPasswordForm, GitHubIcon, GitLabIcon, GoogleIcon, HuggingFaceIcon, InputFieldSkeleton, KickIcon, LinearIcon, LinkedInIcon, MagicLinkForm, MicrosoftIcon, NeonAuthUIProvider, NotionIcon, OrganizationCellView, OrganizationInvitationsCard, OrganizationLogo, OrganizationLogoCard, OrganizationMembersCard, OrganizationNameCard, OrganizationSettingsCards, OrganizationSlugCard, OrganizationSwitcher, OrganizationView, OrganizationsCard, PasskeysCard, PasswordInput, ProvidersCard, RecoverAccountForm, RedditIcon, RedirectToSignIn, RedirectToSignUp, ResetPasswordForm, RobloxIcon, SecuritySettingsCards, SessionsCard, SettingsCard, SettingsCellSkeleton, SignInForm, SignOut, SignUpForm, SignedIn, SignedOut, SlackIcon, SpotifyIcon, TeamCell, TeamsCard, TikTokIcon, TwitchIcon, TwoFactorCard, TwoFactorForm, UpdateAvatarCard, UpdateFieldCard, UpdateNameCard, UpdateUsernameCard, UserAvatar, UserButton, UserInvitationsCard, UserView, VKIcon, XIcon3 as XIcon, ZoomIcon, accountViewPaths, authLocalization, authViewPaths, getViewByPath, organizationViewPaths, socialProviders, useAuthData, useAuthenticate, useCurrentOrganization, useTheme };
|
package/dist/react/ui/server.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as getViewByPath, n as authLocalization, r as authViewPaths, t as accountViewPaths, u as organizationViewPaths } from "../../chunk-VCZJYX65-CLnrj1o7-D6ZQkcc_.mjs";
|
|
2
2
|
|
|
3
3
|
export { accountViewPaths, authLocalization, authViewPaths, getViewByPath, organizationViewPaths };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as CURRENT_TAB_CLIENT_ID, n as BETTER_AUTH_METHODS_CACHE, r as BETTER_AUTH_METHODS_HOOKS, t as NeonAuthAdapterCore } from "./adapter-core-8s6XdCco.mjs";
|
|
2
|
+
import { n as DEFAULT_SESSION_EXPIRY_MS } from "./constants-2bpp2_-f.mjs";
|
|
2
3
|
import { createAuthClient, getGlobalBroadcastChannel } from "better-auth/client";
|
|
3
4
|
import { AuthApiError, AuthError, isAuthError } from "@supabase/auth-js";
|
|
4
5
|
import { base64url, decodeJwt, decodeProtectedHeader } from "jose";
|
|
@@ -16,11 +17,6 @@ var BetterAuthVanillaAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
16
17
|
getBetterAuthInstance() {
|
|
17
18
|
return this._betterAuth;
|
|
18
19
|
}
|
|
19
|
-
async getJWTToken() {
|
|
20
|
-
const session = await this._betterAuth.getSession();
|
|
21
|
-
if (session.error) throw session.error;
|
|
22
|
-
return session.data?.session?.token ?? null;
|
|
23
|
-
}
|
|
24
20
|
};
|
|
25
21
|
/**
|
|
26
22
|
* Factory function that returns an adapter builder.
|
|
@@ -41,9 +37,16 @@ var BetterAuthVanillaAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
41
37
|
* ```
|
|
42
38
|
*/
|
|
43
39
|
function BetterAuthVanillaAdapter(options) {
|
|
44
|
-
return (url) => new BetterAuthVanillaAdapterImpl({
|
|
40
|
+
return (url, fetchOptions) => new BetterAuthVanillaAdapterImpl({
|
|
45
41
|
baseURL: url,
|
|
46
|
-
...options
|
|
42
|
+
...options,
|
|
43
|
+
fetchOptions: {
|
|
44
|
+
...options?.fetchOptions,
|
|
45
|
+
headers: {
|
|
46
|
+
...options?.fetchOptions?.headers,
|
|
47
|
+
...fetchOptions?.headers
|
|
48
|
+
}
|
|
49
|
+
}
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
|
|
@@ -81,6 +84,7 @@ const AuthErrorCode = {
|
|
|
81
84
|
NotImplemented: "not_implemented",
|
|
82
85
|
OAuthProviderNotSupported: "oauth_provider_not_supported",
|
|
83
86
|
PhoneProviderDisabled: "phone_provider_disabled",
|
|
87
|
+
MagicLinkNotSupported: "magic_link_not_supported",
|
|
84
88
|
SsoProviderDisabled: "sso_provider_disabled",
|
|
85
89
|
AnonymousProviderDisabled: "anonymous_provider_disabled",
|
|
86
90
|
Web3ProviderDisabled: "web3_provider_disabled",
|
|
@@ -213,6 +217,12 @@ const ERROR_DEFINITIONS = {
|
|
|
213
217
|
message: "Phone authentication not available",
|
|
214
218
|
description: "Phone number authentication is not enabled"
|
|
215
219
|
},
|
|
220
|
+
[AuthErrorCode.MagicLinkNotSupported]: {
|
|
221
|
+
code: AuthErrorCode.MagicLinkNotSupported,
|
|
222
|
+
status: 403,
|
|
223
|
+
message: "Magic link authentication not available",
|
|
224
|
+
description: "Magic link authentication is not supported"
|
|
225
|
+
},
|
|
216
226
|
[AuthErrorCode.SsoProviderDisabled]: {
|
|
217
227
|
code: AuthErrorCode.SsoProviderDisabled,
|
|
218
228
|
status: 403,
|
|
@@ -625,11 +635,6 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
625
635
|
getBetterAuthInstance() {
|
|
626
636
|
return this._betterAuth;
|
|
627
637
|
}
|
|
628
|
-
async getJWTToken() {
|
|
629
|
-
const session = await this.getSession();
|
|
630
|
-
if (session.error) return null;
|
|
631
|
-
return session.data.session?.access_token ?? null;
|
|
632
|
-
}
|
|
633
638
|
initialize = async () => {
|
|
634
639
|
try {
|
|
635
640
|
const session = await this.getSession();
|
|
@@ -752,36 +757,14 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
752
757
|
throw error;
|
|
753
758
|
}
|
|
754
759
|
};
|
|
755
|
-
signInAnonymously = async (
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
user: sessionResult.data.session.user,
|
|
764
|
-
session: sessionResult.data.session
|
|
765
|
-
},
|
|
766
|
-
error: null
|
|
767
|
-
};
|
|
768
|
-
} catch (error) {
|
|
769
|
-
if (isAuthError(error)) return {
|
|
770
|
-
data: {
|
|
771
|
-
user: null,
|
|
772
|
-
session: null
|
|
773
|
-
},
|
|
774
|
-
error
|
|
775
|
-
};
|
|
776
|
-
if (isBetterAuthAPIError(error)) return {
|
|
777
|
-
data: {
|
|
778
|
-
user: null,
|
|
779
|
-
session: null
|
|
780
|
-
},
|
|
781
|
-
error: normalizeBetterAuthError(error)
|
|
782
|
-
};
|
|
783
|
-
throw error;
|
|
784
|
-
}
|
|
760
|
+
signInAnonymously = async () => {
|
|
761
|
+
return {
|
|
762
|
+
data: {
|
|
763
|
+
user: null,
|
|
764
|
+
session: null
|
|
765
|
+
},
|
|
766
|
+
error: createAuthError(AuthErrorCode.AnonymousProviderDisabled, `Anonymous sign-in is not supported. To allow unauthenticated access with an anonymous JWT, use the allowAnonymous option in your Auth configuration instead.`)
|
|
767
|
+
};
|
|
785
768
|
};
|
|
786
769
|
signInWithPassword = async (credentials) => {
|
|
787
770
|
try {
|
|
@@ -856,6 +839,14 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
856
839
|
};
|
|
857
840
|
signInWithOtp = async (credentials) => {
|
|
858
841
|
try {
|
|
842
|
+
if ("phone" in credentials) return {
|
|
843
|
+
data: {
|
|
844
|
+
user: null,
|
|
845
|
+
session: null,
|
|
846
|
+
messageId: void 0
|
|
847
|
+
},
|
|
848
|
+
error: createAuthError(AuthErrorCode.PhoneProviderDisabled, "Phone OTP authentication is not supported. Use email-based authentication instead.")
|
|
849
|
+
};
|
|
859
850
|
if ("email" in credentials) {
|
|
860
851
|
await this._betterAuth.emailOtp.sendVerificationOtp({
|
|
861
852
|
email: credentials.email,
|
|
@@ -870,7 +861,7 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
870
861
|
error: null
|
|
871
862
|
};
|
|
872
863
|
}
|
|
873
|
-
throw createAuthError(AuthErrorCode.
|
|
864
|
+
throw createAuthError(AuthErrorCode.ValidationFailed, "Invalid OTP credentials format");
|
|
874
865
|
} catch (error) {
|
|
875
866
|
if (isAuthError(error)) return {
|
|
876
867
|
data: {
|
|
@@ -1165,8 +1156,21 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
1165
1156
|
};
|
|
1166
1157
|
verifyOtp = async (params) => {
|
|
1167
1158
|
try {
|
|
1159
|
+
if ("phone" in params && params.phone) return {
|
|
1160
|
+
data: {
|
|
1161
|
+
user: null,
|
|
1162
|
+
session: null
|
|
1163
|
+
},
|
|
1164
|
+
error: createAuthError(AuthErrorCode.PhoneProviderDisabled, "Phone OTP verification is not supported. Use email-based authentication instead.")
|
|
1165
|
+
};
|
|
1166
|
+
if ("email" in params && params.type === "magiclink") return {
|
|
1167
|
+
data: {
|
|
1168
|
+
user: null,
|
|
1169
|
+
session: null
|
|
1170
|
+
},
|
|
1171
|
+
error: createAuthError(AuthErrorCode.MagicLinkNotSupported, "Magic link verification is not supported. Use email OTP authentication instead.")
|
|
1172
|
+
};
|
|
1168
1173
|
if ("email" in params && params.email) return await this.verifyEmailOtp(params);
|
|
1169
|
-
if ("phone" in params && params.phone) return await this.verifyPhoneOtp(params);
|
|
1170
1174
|
if ("token_hash" in params && params.token_hash) throw createAuthError(AuthErrorCode.FeatureNotSupported, "Token hash verification not supported");
|
|
1171
1175
|
throw createAuthError(AuthErrorCode.ValidationFailed, "Invalid OTP verification parameters");
|
|
1172
1176
|
} catch (error) {
|
|
@@ -1259,21 +1263,13 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
1259
1263
|
}
|
|
1260
1264
|
throw createAuthError(AuthErrorCode.ValidationFailed, `Unsupported resend type: ${type}`);
|
|
1261
1265
|
}
|
|
1262
|
-
if ("phone" in credentials) {
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
messageId: type === "sms" ? "sms-otp-sent" : "phone-change-otp-sent",
|
|
1270
|
-
user: null,
|
|
1271
|
-
session: null
|
|
1272
|
-
},
|
|
1273
|
-
error: null
|
|
1274
|
-
};
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1266
|
+
if ("phone" in credentials) return {
|
|
1267
|
+
data: {
|
|
1268
|
+
user: null,
|
|
1269
|
+
session: null
|
|
1270
|
+
},
|
|
1271
|
+
error: createAuthError(AuthErrorCode.PhoneProviderDisabled, "SMS resend is not supported. Use email-based authentication instead.")
|
|
1272
|
+
};
|
|
1277
1273
|
throw createAuthError(AuthErrorCode.ValidationFailed, "Invalid credentials format");
|
|
1278
1274
|
} catch (error) {
|
|
1279
1275
|
if (isAuthError(error)) return {
|
|
@@ -1372,34 +1368,13 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
1372
1368
|
error: null
|
|
1373
1369
|
};
|
|
1374
1370
|
}
|
|
1375
|
-
if (type === "magiclink") {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
user: null,
|
|
1383
|
-
session: null
|
|
1384
|
-
},
|
|
1385
|
-
error: normalizeBetterAuthError(result.error)
|
|
1386
|
-
};
|
|
1387
|
-
const sessionResult = await this.getSession({ forceFetch: true });
|
|
1388
|
-
if (!sessionResult.data?.session) return {
|
|
1389
|
-
data: {
|
|
1390
|
-
user: null,
|
|
1391
|
-
session: null
|
|
1392
|
-
},
|
|
1393
|
-
error: createAuthError(AuthErrorCode.SessionNotFound, "Failed to retrieve session after magic link verification")
|
|
1394
|
-
};
|
|
1395
|
-
return {
|
|
1396
|
-
data: {
|
|
1397
|
-
user: sessionResult.data.session?.user || null,
|
|
1398
|
-
session: sessionResult.data.session
|
|
1399
|
-
},
|
|
1400
|
-
error: null
|
|
1401
|
-
};
|
|
1402
|
-
}
|
|
1371
|
+
if (type === "magiclink") return {
|
|
1372
|
+
data: {
|
|
1373
|
+
user: null,
|
|
1374
|
+
session: null
|
|
1375
|
+
},
|
|
1376
|
+
error: createAuthError(AuthErrorCode.MagicLinkNotSupported, "Magic link verification is not supported. Use email OTP authentication instead.")
|
|
1377
|
+
};
|
|
1403
1378
|
if (type === "signup" || type === "invite") {
|
|
1404
1379
|
const result = await this._betterAuth.emailOtp.verifyEmail({
|
|
1405
1380
|
email: params.email,
|
|
@@ -1504,83 +1479,6 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
1504
1479
|
error: createAuthError(AuthErrorCode.ValidationFailed, `Unsupported email OTP type: ${type}`)
|
|
1505
1480
|
};
|
|
1506
1481
|
}
|
|
1507
|
-
async verifyPhoneOtp(params) {
|
|
1508
|
-
if (params.type === "sms") {
|
|
1509
|
-
const result = await this._betterAuth.phoneNumber.verify({
|
|
1510
|
-
phoneNumber: params.phone,
|
|
1511
|
-
code: params.token,
|
|
1512
|
-
disableSession: false,
|
|
1513
|
-
updatePhoneNumber: false
|
|
1514
|
-
});
|
|
1515
|
-
if (result.error) return {
|
|
1516
|
-
data: {
|
|
1517
|
-
user: null,
|
|
1518
|
-
session: null
|
|
1519
|
-
},
|
|
1520
|
-
error: normalizeBetterAuthError(result.error)
|
|
1521
|
-
};
|
|
1522
|
-
const sessionResult = await this.getSession({ forceFetch: true });
|
|
1523
|
-
if (sessionResult.error || !sessionResult.data) return {
|
|
1524
|
-
data: {
|
|
1525
|
-
user: null,
|
|
1526
|
-
session: null
|
|
1527
|
-
},
|
|
1528
|
-
error: sessionResult.error || createAuthError(AuthErrorCode.InternalError, "Failed to get session")
|
|
1529
|
-
};
|
|
1530
|
-
return {
|
|
1531
|
-
data: {
|
|
1532
|
-
user: sessionResult.data?.session?.user || null,
|
|
1533
|
-
session: sessionResult.data?.session || null
|
|
1534
|
-
},
|
|
1535
|
-
error: null
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
if (params.type === "phone_change") {
|
|
1539
|
-
const currentSession = await this._betterAuth.getSession();
|
|
1540
|
-
if (currentSession.error || !currentSession.data?.session) return {
|
|
1541
|
-
data: {
|
|
1542
|
-
user: null,
|
|
1543
|
-
session: null
|
|
1544
|
-
},
|
|
1545
|
-
error: createAuthError(AuthErrorCode.SessionNotFound, "You must be signed in to change your phone number")
|
|
1546
|
-
};
|
|
1547
|
-
const result = await this._betterAuth.phoneNumber.verify({
|
|
1548
|
-
phoneNumber: params.phone,
|
|
1549
|
-
code: params.token,
|
|
1550
|
-
disableSession: false,
|
|
1551
|
-
updatePhoneNumber: true
|
|
1552
|
-
});
|
|
1553
|
-
if (result.error) return {
|
|
1554
|
-
data: {
|
|
1555
|
-
user: null,
|
|
1556
|
-
session: null
|
|
1557
|
-
},
|
|
1558
|
-
error: normalizeBetterAuthError(result.error)
|
|
1559
|
-
};
|
|
1560
|
-
const sessionResult = await this.getSession({ forceFetch: true });
|
|
1561
|
-
if (sessionResult.error || !sessionResult.data) return {
|
|
1562
|
-
data: {
|
|
1563
|
-
user: null,
|
|
1564
|
-
session: null
|
|
1565
|
-
},
|
|
1566
|
-
error: sessionResult.error || createAuthError(AuthErrorCode.InternalError, "Failed to get updated session")
|
|
1567
|
-
};
|
|
1568
|
-
return {
|
|
1569
|
-
data: {
|
|
1570
|
-
user: sessionResult.data.session?.user || null,
|
|
1571
|
-
session: sessionResult.data.session
|
|
1572
|
-
},
|
|
1573
|
-
error: null
|
|
1574
|
-
};
|
|
1575
|
-
}
|
|
1576
|
-
return {
|
|
1577
|
-
data: {
|
|
1578
|
-
user: null,
|
|
1579
|
-
session: null
|
|
1580
|
-
},
|
|
1581
|
-
error: createAuthError(AuthErrorCode.ValidationFailed, `Unsupported phone OTP type: ${params.type}`)
|
|
1582
|
-
};
|
|
1583
|
-
}
|
|
1584
1482
|
async emitInitialSession(callback) {
|
|
1585
1483
|
try {
|
|
1586
1484
|
const { data, error } = await this.getSession();
|
|
@@ -1613,9 +1511,16 @@ var SupabaseAuthAdapterImpl = class extends NeonAuthAdapterCore {
|
|
|
1613
1511
|
* ```
|
|
1614
1512
|
*/
|
|
1615
1513
|
function SupabaseAuthAdapter(options) {
|
|
1616
|
-
return (url) => new SupabaseAuthAdapterImpl({
|
|
1514
|
+
return (url, fetchOptions) => new SupabaseAuthAdapterImpl({
|
|
1617
1515
|
baseURL: url,
|
|
1618
|
-
...options
|
|
1516
|
+
...options,
|
|
1517
|
+
fetchOptions: {
|
|
1518
|
+
...options?.fetchOptions,
|
|
1519
|
+
headers: {
|
|
1520
|
+
...options?.fetchOptions?.headers,
|
|
1521
|
+
...fetchOptions?.headers
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1619
1524
|
});
|
|
1620
1525
|
}
|
|
1621
1526
|
|