@seamless-auth/react 0.1.1 → 0.2.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @seamless-auth/react
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 24a17b8: Release the current React SDK improvements as the first Changesets-managed package version.
8
+
9
+ This release includes the public headless client and React hooks for custom auth UIs, expanded provider helpers for OAuth and step-up flows, scoped role utilities, OTP and passkey flow polish, and the reviewed release PR workflow for future package publishing.
10
+
11
+ ## 0.1.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Last published version before Changesets-managed release PRs.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @seamless-auth/react
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@seamless-auth/react.svg?label=%40seamless-auth%2Freact)](https://www.npmjs.com/package/@seamless-auth/react)
4
+ [![CI](https://github.com/fells-code/seamless-auth-react/actions/workflows/ci.yml/badge.svg)](https://github.com/fells-code/seamless-auth-react/actions/workflows/ci.yml)
5
+ [![Release](https://github.com/fells-code/seamless-auth-react/actions/workflows/release.yml/badge.svg)](https://github.com/fells-code/seamless-auth-react/actions/workflows/release.yml)
4
6
  [![coverage](https://img.shields.io/codecov/c/github/fells-code/seamless-auth-react)](https://app.codecov.io/gh/fells-code/seamless-auth-react)
5
7
  [![license](https://img.shields.io/github/license/fells-code/seamless-auth-react)](./LICENSE)
6
8
 
@@ -14,7 +16,8 @@
14
16
  - `createSeamlessAuthClient()`
15
17
  - `useAuthClient()`
16
18
  - `usePasskeySupport()`
17
- - types including `AuthMode`, `AuthContextType`, `Credential`, `User`, and the headless client input/result types
19
+ - `hasScopedRole()` and `roleGrantsAccess()`
20
+ - types including `AuthContextType`, `Credential`, `User`, `OAuthProvider`, `StepUpStatus`, and the headless client input/result types
18
21
 
19
22
  ## Installation
20
23
 
@@ -22,6 +25,13 @@
22
25
  npm install @seamless-auth/react
23
26
  ```
24
27
 
28
+ ## Releases
29
+
30
+ Published versions are listed in [CHANGELOG.md](./CHANGELOG.md) and GitHub Releases. Releases are
31
+ managed with Changesets: adopter-facing changes include a changeset, the `Release` workflow opens a
32
+ version PR for review, and merging that PR publishes the npm package with provenance from GitHub
33
+ Actions. See [RELEASES.md](./RELEASES.md) for maintainer release details.
34
+
25
35
  ## Choose Your Integration Style
26
36
 
27
37
  You can use this package in three ways:
@@ -41,7 +51,7 @@ import { AuthProvider } from '@seamless-auth/react';
41
51
  import { BrowserRouter } from 'react-router-dom';
42
52
 
43
53
  <BrowserRouter>
44
- <AuthProvider apiHost="https://your.api" mode="server">
54
+ <AuthProvider apiHost="https://your.api">
45
55
  <AppRoutes />
46
56
  </AuthProvider>
47
57
  </BrowserRouter>;
@@ -96,15 +106,23 @@ You are still responsible for your app’s route protection and redirects.
96
106
  {
97
107
  user: User | null;
98
108
  credentials: Credential[];
109
+ stepUpStatus: StepUpStatus | null;
99
110
  isAuthenticated: boolean;
100
111
  loading: boolean;
101
112
  apiHost: string;
102
- mode: AuthMode;
103
113
  hasSignedInBefore: boolean;
104
114
  markSignedIn(): void;
105
115
  hasRole(role: string): boolean | undefined;
116
+ hasScopedRole(role: string | string[]): boolean | undefined;
117
+ listOAuthProviders(): Promise<OAuthProvidersResult>;
118
+ startOAuthLogin(input: StartOAuthLoginInput): Promise<StartOAuthLoginResult>;
119
+ finishOAuthLogin(input: FinishOAuthLoginInput): Promise<void>;
106
120
  refreshSession(): Promise<void>;
121
+ refreshStepUpStatus(): Promise<StepUpStatus | null>;
122
+ verifyStepUpWithPasskey(): Promise<StepUpVerificationResult>;
123
+ verifyStepUpWithPasskeyPrf(input: PasskeyPrfInput): Promise<StepUpWithPasskeyPrfResult>;
107
124
  logout(): Promise<void>;
125
+ logoutAllSessions(): Promise<void>;
108
126
  deleteUser(): Promise<void>;
109
127
  login(identifier: string, passkeyAvailable: boolean): Promise<Response>;
110
128
  handlePasskeyLogin(): Promise<boolean>;
@@ -115,6 +133,236 @@ You are still responsible for your app’s route protection and redirects.
115
133
 
116
134
  Use `refreshSession()` after completing a custom auth flow that should update provider state.
117
135
 
136
+ ### `hasSignedInBefore`
137
+
138
+ `hasSignedInBefore` is a small convenience flag backed by `localStorage`. The provider reads the `seamlessauth_seen` key on load and sets the flag to `true` after `markSignedIn()` runs.
139
+
140
+ This is mainly useful for login UIs that want to branch between first-time and returning-user behavior. For example, the built-in `Login` view uses it to default returning users to sign-in mode instead of registration.
141
+
142
+ ```tsx
143
+ import { useAuth } from '@seamless-auth/react';
144
+
145
+ function SignInHint() {
146
+ const { hasSignedInBefore } = useAuth();
147
+
148
+ return hasSignedInBefore ? (
149
+ <p>Welcome back. Sign in with your email, phone, or passkey.</p>
150
+ ) : (
151
+ <p>New here? Start by creating your account.</p>
152
+ );
153
+ }
154
+ ```
155
+
156
+ If you are building a fully custom flow, call `markSignedIn()` after a successful sign-in or registration step once you want future visits treated as returning-user sessions.
157
+
158
+ ```tsx
159
+ const { markSignedIn, refreshSession } = useAuth();
160
+
161
+ async function completeLogin() {
162
+ const response = await authClient.login({
163
+ identifier: 'user@example.com',
164
+ passkeyAvailable: true,
165
+ });
166
+
167
+ if (response.ok) {
168
+ markSignedIn();
169
+ await refreshSession();
170
+ }
171
+ }
172
+ ```
173
+
174
+ To disable this auto-detection entirely, pass `autoDetectPreviousSignin={false}` to `AuthProvider`.
175
+
176
+ ### Scoped roles
177
+
178
+ `hasRole(role)` remains an exact role check. Use `hasScopedRole(role)` for colon-separated scoped
179
+ roles such as `admin:read` and `admin:write`.
180
+
181
+ ```tsx
182
+ const { hasRole, hasScopedRole } = useAuth();
183
+
184
+ hasRole('admin'); // exact legacy role check
185
+ hasScopedRole('admin:read'); // true for admin, admin:read, or admin:write
186
+ hasScopedRole('admin:write'); // true for admin or admin:write
187
+ ```
188
+
189
+ The package also exports standalone `hasScopedRole(roles, required)` and `roleGrantsAccess(...)`
190
+ helpers for code that is not inside `AuthProvider`.
191
+
192
+ ### Step-up authentication
193
+
194
+ Use step-up authentication before sensitive actions that should require a fresh user verification, such as deleting an account, changing MFA settings, or viewing recovery material.
195
+
196
+ ```tsx
197
+ import { useAuth } from '@seamless-auth/react';
198
+
199
+ function DeleteAccountButton() {
200
+ const { refreshStepUpStatus, verifyStepUpWithPasskey } = useAuth();
201
+
202
+ async function handleDeleteAccount() {
203
+ const status = await refreshStepUpStatus();
204
+ const fresh = status?.fresh ? true : (await verifyStepUpWithPasskey()).success;
205
+
206
+ if (!fresh) {
207
+ return;
208
+ }
209
+
210
+ await deleteAccount();
211
+ }
212
+
213
+ return <button onClick={() => void handleDeleteAccount()}>Delete account</button>;
214
+ }
215
+ ```
216
+
217
+ The current step-up backend supports WebAuthn/passkeys. `refreshStepUpStatus()` calls `/step-up/status`, and `verifyStepUpWithPasskey()` performs the `/step-up/webauthn/start` and `/step-up/webauthn/finish` challenge flow.
218
+
219
+ ### WebAuthn PRF
220
+
221
+ WebAuthn PRF lets a compatible passkey and browser derive local key material during a WebAuthn assertion. Seamless Auth verifies the passkey assertion on the server, while the React SDK returns the PRF output only to the browser caller. PRF output is stripped before `/webAuthn/login/finish` and `/step-up/webauthn/finish`, and should never be logged, stored, or sent to your API.
222
+
223
+ Browser and authenticator support is not universal. Call `isPasskeyPrfSupported()` before offering PRF-required flows, and keep a fallback for passkeys that authenticate successfully without returning PRF output.
224
+
225
+ Treat PRF salts as sensitive in client logs. PRF output is browser-local key material; keep it in
226
+ memory only as long as your application needs it and do not send it to Seamless Auth or your own API.
227
+
228
+ ```ts
229
+ import { createSeamlessAuthClient } from '@seamless-auth/react';
230
+
231
+ const authClient = createSeamlessAuthClient({
232
+ apiHost: 'https://your.api',
233
+ });
234
+
235
+ const prfSupported = await authClient.isPasskeyPrfSupported();
236
+
237
+ if (prfSupported) {
238
+ await authClient.registerPasskey({
239
+ metadata: {
240
+ friendlyName: 'My laptop',
241
+ platform: 'macOS',
242
+ browser: 'Chrome',
243
+ deviceInfo: navigator.userAgent,
244
+ },
245
+ requirePrf: true,
246
+ });
247
+ }
248
+ ```
249
+
250
+ For local key unwrap flows such as Seamless Secrets, use PRF during step-up and consume the returned bytes in browser memory:
251
+
252
+ ```ts
253
+ const result = await authClient.verifyStepUpWithPasskeyPrf({
254
+ salt: vaultSaltBase64url,
255
+ credentialId,
256
+ });
257
+
258
+ if (!result.success || !result.prf) {
259
+ throw new Error('PRF step-up failed');
260
+ }
261
+
262
+ const vaultUnlockMaterial: { credentialId: string; output: Uint8Array } = {
263
+ credentialId: result.credentialId!,
264
+ output: result.prf.output,
265
+ };
266
+ ```
267
+
268
+ The salt may be an `ArrayBuffer`, `ArrayBufferView`, or base64url string. Authentication proves identity and user presence; the PRF output is local key material for your application to use without sending it to Seamless Auth.
269
+
270
+ ### OAuth Login
271
+
272
+ OAuth lets your app offer external identity providers such as Google, GitHub, Facebook, or custom
273
+ OIDC-style providers configured on the Seamless Auth API. The React SDK does not receive provider
274
+ access tokens. It only starts the provider redirect and completes the callback so Seamless Auth can
275
+ issue the normal access/refresh session.
276
+
277
+ Use `listOAuthProviders()` when you want to render enabled providers dynamically:
278
+
279
+ ```tsx
280
+ import { useEffect, useState } from 'react';
281
+ import { useAuth } from '@seamless-auth/react';
282
+ import type { OAuthProvider } from '@seamless-auth/react';
283
+
284
+ function OAuthButtons() {
285
+ const { listOAuthProviders, startOAuthLogin } = useAuth();
286
+ const [providers, setProviders] = useState<OAuthProvider[]>([]);
287
+
288
+ useEffect(() => {
289
+ void listOAuthProviders().then(result => setProviders(result.providers));
290
+ }, [listOAuthProviders]);
291
+
292
+ async function signIn(providerId: string) {
293
+ const result = await startOAuthLogin({
294
+ providerId,
295
+ redirectUri: `${window.location.origin}/oauth/callback`,
296
+ returnTo: `${window.location.origin}/dashboard`,
297
+ });
298
+
299
+ window.location.assign(result.authorizationUrl);
300
+ }
301
+
302
+ return (
303
+ <div>
304
+ {providers.map(provider => (
305
+ <button key={provider.id} onClick={() => void signIn(provider.id)}>
306
+ Continue with {provider.name}
307
+ </button>
308
+ ))}
309
+ </div>
310
+ );
311
+ }
312
+ ```
313
+
314
+ Create a callback route that reads the provider query params and asks Seamless Auth to complete the
315
+ login:
316
+
317
+ ```tsx
318
+ import { useEffect } from 'react';
319
+ import { useAuth } from '@seamless-auth/react';
320
+
321
+ function OAuthCallback() {
322
+ const { finishOAuthLogin } = useAuth();
323
+
324
+ useEffect(() => {
325
+ const params = new URLSearchParams(window.location.search);
326
+ const providerId = 'google';
327
+ const code = params.get('code');
328
+ const state = params.get('state');
329
+
330
+ if (!code || !state) {
331
+ return;
332
+ }
333
+
334
+ void finishOAuthLogin({ providerId, code, state }).then(() => {
335
+ window.location.assign('/dashboard');
336
+ });
337
+ }, [finishOAuthLogin]);
338
+
339
+ return <p>Finishing sign-in...</p>;
340
+ }
341
+ ```
342
+
343
+ For fully custom UI without `useAuth()`, call the headless client directly:
344
+
345
+ ```ts
346
+ const providers = await authClient.listOAuthProviders();
347
+ const started = await authClient.startOAuthLogin({
348
+ providerId: providers.providers[0].id,
349
+ redirectUri: `${window.location.origin}/oauth/callback`,
350
+ });
351
+
352
+ window.location.assign(started.authorizationUrl);
353
+ ```
354
+
355
+ OAuth must be enabled on the Seamless Auth API with `LOGIN_METHODS` including `oauth` and at least
356
+ one configured `oauth_providers` entry. Provider client secrets live on the server and are referenced
357
+ by environment variable name; they are never passed through this SDK.
358
+
359
+ For production providers, configure exact `redirectUris` on the Seamless Auth API. The SDK should
360
+ send the callback URL it expects to receive, but redirect allowlisting, signed state expiry, OIDC
361
+ nonce handling, email verification policy, and account-linking policy are enforced by the API.
362
+
363
+ The built-in views avoid logging OTPs, magic-link tokens, bootstrap tokens, PRF salts, or raw
364
+ exception payloads that may contain sensitive request URLs.
365
+
118
366
  ## Headless Client
119
367
 
120
368
  For custom auth UIs, use the exported client directly:
@@ -124,7 +372,6 @@ import { createSeamlessAuthClient } from '@seamless-auth/react';
124
372
 
125
373
  const authClient = createSeamlessAuthClient({
126
374
  apiHost: 'https://your.api',
127
- mode: 'server',
128
375
  });
129
376
 
130
377
  const response = await authClient.login({
@@ -144,14 +391,22 @@ The headless client exposes helpers for:
144
391
  - registration
145
392
  - phone OTP and email OTP
146
393
  - magic-link request, verify, and polling
394
+ - OAuth provider listing, start, and callback completion
147
395
  - passkey registration
396
+ - step-up status and passkey verification
148
397
  - logout and delete-user
149
398
  - credential update and deletion
150
399
 
151
400
  Client methods return raw `Response` objects except for the passkey convenience helpers:
152
401
 
153
- - `loginWithPasskey(): Promise<PasskeyLoginResult>`
154
- - `registerPasskey(metadata): Promise<PasskeyRegistrationResult>`
402
+ - `loginWithPasskey(options?: PasskeyLoginOptions): Promise<PasskeyLoginWithPrfResult>`
403
+ - `registerPasskey(metadata | { metadata, requestPrf?, requirePrf? }): Promise<PasskeyRegistrationResult>`
404
+ - `isPasskeyPrfSupported(): Promise<boolean>`
405
+ - `verifyStepUpWithPasskey(): Promise<StepUpVerificationResult>`
406
+ - `verifyStepUpWithPasskeyPrf(input): Promise<StepUpWithPasskeyPrfResult>`
407
+ - `listOAuthProviders(): Promise<OAuthProvidersResult>`
408
+ - `startOAuthLogin(input): Promise<StartOAuthLoginResult>`
409
+ - `finishOAuthLogin(input): Promise<Response>`
155
410
 
156
411
  ## React Hooks For Custom UI
157
412
 
@@ -200,17 +455,18 @@ These are optional UI wrappers over the same SDK primitives the package now expo
200
455
 
201
456
  ## Backend Expectations
202
457
 
203
- This package assumes a Seamless Auth-compatible backend with cookie-based auth flows.
458
+ This package assumes a Seamless Auth-compatible backend with the auth adapter mounted at `/auth`.
204
459
 
205
- - In `web` mode, requests target `${apiHost}/...`
206
- - In `server` mode, requests target `${apiHost}/auth/...`
460
+ - Requests target `${apiHost}/auth/...`
461
+ - `apiHost` may be provided with or without a trailing slash
207
462
  - Requests are sent with `credentials: 'include'`
208
463
  - `AuthProvider` validates the current session by calling `/users/me` on load
209
464
 
210
465
  The built-in flows assume compatible endpoints for:
211
466
 
212
467
  - `/login`
213
- - `/logout`
468
+ - `DELETE /logout` for the current session
469
+ - `DELETE /logout/all` for every session owned by the current user
214
470
  - `/registration/register`
215
471
  - `/webAuthn/login/start`
216
472
  - `/webAuthn/login/finish`
@@ -223,6 +479,12 @@ The built-in flows assume compatible endpoints for:
223
479
  - `/magic-link`
224
480
  - `/magic-link/check`
225
481
  - `/magic-link/verify/:token`
482
+ - `/oauth/providers`
483
+ - `/oauth/:providerId/start`
484
+ - `/oauth/:providerId/callback`
485
+ - `/step-up/status`
486
+ - `/step-up/webauthn/start`
487
+ - `/step-up/webauthn/finish`
226
488
  - `/users/me`
227
489
  - `/users/credentials`
228
490
  - `/users/delete`
@@ -1,22 +1,34 @@
1
- import { Credential, User } from '@/types';
1
+ import { FinishOAuthLoginInput, OAuthProvidersResult, StartOAuthLoginInput, StartOAuthLoginResult, StepUpWithPasskeyPrfResult, StepUpStatus, StepUpVerificationResult } from '@/client/createSeamlessAuthClient';
2
+ import { PasskeyPrfInput } from '@/client/webauthnPrf';
3
+ import { Credential, Organization, User } from '@/types';
2
4
  import React, { ReactNode } from 'react';
3
- import { AuthMode } from './fetchWithAuth';
4
5
  export interface AuthContextType {
5
6
  user: User | null;
6
7
  logout: () => Promise<void>;
8
+ logoutAllSessions: () => Promise<void>;
7
9
  deleteUser: () => Promise<void>;
8
10
  refreshSession: () => Promise<void>;
9
11
  isAuthenticated: boolean;
10
12
  hasRole: (role: string) => boolean | undefined;
13
+ hasScopedRole: (role: string | string[]) => boolean | undefined;
11
14
  apiHost: string;
12
15
  markSignedIn: () => void;
13
16
  hasSignedInBefore: boolean;
14
- mode: AuthMode;
15
17
  credentials: Credential[];
18
+ organizations: Organization[];
19
+ activeOrganization: Organization | null;
20
+ switchOrganization: (organizationId: string) => Promise<void>;
21
+ listOAuthProviders: () => Promise<OAuthProvidersResult>;
22
+ startOAuthLogin: (input: StartOAuthLoginInput) => Promise<StartOAuthLoginResult>;
23
+ finishOAuthLogin: (input: FinishOAuthLoginInput) => Promise<void>;
24
+ stepUpStatus: StepUpStatus | null;
16
25
  updateCredential: (credential: Credential) => Promise<Credential>;
17
26
  deleteCredential: (credentialId: string) => Promise<void>;
18
27
  login: (identifier: string, passkeyAvailable: boolean) => Promise<Response | null>;
19
28
  handlePasskeyLogin: () => Promise<boolean>;
29
+ refreshStepUpStatus: () => Promise<StepUpStatus | null>;
30
+ verifyStepUpWithPasskey: () => Promise<StepUpVerificationResult>;
31
+ verifyStepUpWithPasskeyPrf: (input: PasskeyPrfInput) => Promise<StepUpWithPasskeyPrfResult>;
20
32
  loading: boolean;
21
33
  }
22
34
  /**
@@ -28,7 +40,6 @@ interface AuthProviderProps {
28
40
  children: ReactNode;
29
41
  apiHost: string;
30
42
  autoDetectPreviousSignin?: boolean;
31
- mode?: AuthMode;
32
43
  }
33
44
  export declare const AuthProvider: React.FC<AuthProviderProps>;
34
45
  export {};
@@ -1,13 +1,18 @@
1
- import { AuthMode } from '../fetchWithAuth';
2
- import { Credential, User } from '../types';
1
+ import { Credential, Organization, OrganizationMembership, User } from '../types';
2
+ import { PasskeyPrfInput, PasskeyPrfResult } from './webauthnPrf';
3
3
  export interface SeamlessAuthClientOptions {
4
4
  apiHost: string;
5
- mode: AuthMode;
6
5
  }
7
6
  export interface LoginInput {
8
7
  identifier: string;
9
8
  passkeyAvailable: boolean;
10
9
  }
10
+ export type LoginMethod = 'passkey' | 'magic_link' | 'email_otp' | 'phone_otp' | 'oauth';
11
+ export interface LoginStartResult {
12
+ message?: string;
13
+ identifierType?: 'email' | 'phone';
14
+ loginMethods?: LoginMethod[];
15
+ }
11
16
  export interface RegisterInput {
12
17
  email: string;
13
18
  phone: string;
@@ -22,6 +27,62 @@ export interface PasskeyMetadata {
22
27
  export interface CurrentUserResult {
23
28
  user: User;
24
29
  credentials: Credential[];
30
+ organizations?: Organization[];
31
+ activeOrganization?: Organization | null;
32
+ }
33
+ export interface CreateOrganizationInput {
34
+ name: string;
35
+ slug?: string;
36
+ metadata?: Record<string, unknown> | null;
37
+ }
38
+ export interface UpdateOrganizationInput {
39
+ name?: string;
40
+ slug?: string;
41
+ metadata?: Record<string, unknown> | null;
42
+ }
43
+ export interface OrganizationMemberInput {
44
+ userId?: string;
45
+ email?: string;
46
+ roles?: string[];
47
+ scopes?: string[];
48
+ }
49
+ export interface OrganizationMemberUpdateInput {
50
+ roles?: string[];
51
+ scopes?: string[];
52
+ }
53
+ export interface OrganizationsResult {
54
+ organizations: Organization[];
55
+ activeOrganizationId?: string | null;
56
+ }
57
+ export interface OrganizationResult {
58
+ organization: Organization;
59
+ }
60
+ export interface OrganizationMembersResult {
61
+ members: OrganizationMembership[];
62
+ total: number;
63
+ }
64
+ export interface OAuthProvider {
65
+ id: string;
66
+ name: string;
67
+ scopes: string[];
68
+ }
69
+ export interface OAuthProvidersResult {
70
+ providers: OAuthProvider[];
71
+ }
72
+ export interface StartOAuthLoginInput {
73
+ providerId: string;
74
+ redirectUri?: string;
75
+ returnTo?: string;
76
+ }
77
+ export interface StartOAuthLoginResult {
78
+ provider: OAuthProvider;
79
+ state: string;
80
+ authorizationUrl: string;
81
+ }
82
+ export interface FinishOAuthLoginInput {
83
+ providerId: string;
84
+ code: string;
85
+ state: string;
25
86
  }
26
87
  export interface PasskeyLoginResult {
27
88
  success: boolean;
@@ -31,26 +92,80 @@ export interface PasskeyLoginResult {
31
92
  export interface PasskeyRegistrationResult {
32
93
  success: boolean;
33
94
  message: string;
95
+ credentialId?: string;
96
+ prfCapable?: boolean;
97
+ }
98
+ export interface RegisterPasskeyOptions {
99
+ metadata: PasskeyMetadata;
100
+ requestPrf?: boolean;
101
+ requirePrf?: boolean;
102
+ }
103
+ export type StepUpMethod = 'webauthn';
104
+ export interface StepUpStatus {
105
+ fresh: boolean;
106
+ method: StepUpMethod | null;
107
+ verifiedAt: string | null;
108
+ expiresAt: string | null;
109
+ maxAgeSeconds: number;
110
+ }
111
+ export interface StepUpVerificationResult extends StepUpStatus {
112
+ success: boolean;
113
+ message: string;
114
+ }
115
+ export interface PasskeyLoginOptions {
116
+ prf?: PasskeyPrfInput;
117
+ }
118
+ export interface PasskeyLoginWithPrfResult extends PasskeyLoginResult {
119
+ prf?: PasskeyPrfResult;
120
+ }
121
+ export interface StepUpWithPasskeyPrfResult extends StepUpVerificationResult {
122
+ credentialId: string | null;
123
+ prf: PasskeyPrfResult | null;
124
+ }
125
+ export type LogoutScope = 'current_session' | 'all_sessions';
126
+ export interface LogoutOptions {
127
+ scope?: LogoutScope;
34
128
  }
35
129
  export interface SeamlessAuthClient {
36
130
  getCurrentUser: () => Promise<Response>;
37
131
  login: (input: LoginInput) => Promise<Response>;
38
- loginWithPasskey: () => Promise<PasskeyLoginResult>;
39
- logout: () => Promise<Response>;
132
+ loginWithPasskey: (options?: PasskeyLoginOptions) => Promise<PasskeyLoginWithPrfResult>;
133
+ logout: (options?: LogoutOptions) => Promise<Response>;
134
+ logoutAllSessions: () => Promise<Response>;
40
135
  deleteUser: () => Promise<Response>;
41
136
  register: (input: RegisterInput) => Promise<Response>;
42
137
  requestPhoneOtp: () => Promise<Response>;
43
138
  verifyPhoneOtp: (verificationToken: string) => Promise<Response>;
139
+ requestLoginPhoneOtp: () => Promise<Response>;
140
+ verifyLoginPhoneOtp: (verificationToken: string) => Promise<Response>;
44
141
  requestEmailOtp: () => Promise<Response>;
45
142
  verifyEmailOtp: (verificationToken: string) => Promise<Response>;
143
+ requestLoginEmailOtp: () => Promise<Response>;
144
+ verifyLoginEmailOtp: (verificationToken: string) => Promise<Response>;
46
145
  requestMagicLink: () => Promise<Response>;
47
146
  checkMagicLink: () => Promise<Response>;
48
147
  verifyMagicLink: (token: string) => Promise<Response>;
49
- registerPasskey: (metadata: PasskeyMetadata) => Promise<PasskeyRegistrationResult>;
148
+ listOAuthProviders: () => Promise<OAuthProvidersResult>;
149
+ startOAuthLogin: (input: StartOAuthLoginInput) => Promise<StartOAuthLoginResult>;
150
+ finishOAuthLogin: (input: FinishOAuthLoginInput) => Promise<Response>;
151
+ registerPasskey: (input: PasskeyMetadata | RegisterPasskeyOptions) => Promise<PasskeyRegistrationResult>;
152
+ isPasskeyPrfSupported: () => Promise<boolean>;
153
+ getStepUpStatus: () => Promise<Response>;
154
+ verifyStepUpWithPasskey: () => Promise<StepUpVerificationResult>;
155
+ verifyStepUpWithPasskeyPrf: (input: PasskeyPrfInput) => Promise<StepUpWithPasskeyPrfResult>;
50
156
  updateCredential: (input: {
51
157
  id: string;
52
158
  friendlyName: string | null;
53
159
  }) => Promise<Response>;
54
160
  deleteCredential: (id: string) => Promise<Response>;
161
+ listOrganizations: () => Promise<Response>;
162
+ createOrganization: (input: CreateOrganizationInput) => Promise<Response>;
163
+ getOrganization: (organizationId: string) => Promise<Response>;
164
+ updateOrganization: (organizationId: string, input: UpdateOrganizationInput) => Promise<Response>;
165
+ switchOrganization: (organizationId: string) => Promise<Response>;
166
+ listOrganizationMembers: (organizationId: string) => Promise<Response>;
167
+ addOrganizationMember: (organizationId: string, input: OrganizationMemberInput) => Promise<Response>;
168
+ updateOrganizationMember: (organizationId: string, userId: string, input: OrganizationMemberUpdateInput) => Promise<Response>;
169
+ removeOrganizationMember: (organizationId: string, userId: string) => Promise<Response>;
55
170
  }
56
171
  export declare const createSeamlessAuthClient: (opts: SeamlessAuthClientOptions) => SeamlessAuthClient;
@@ -0,0 +1,27 @@
1
+ import { type AuthenticationResponseJSON, type PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/browser';
2
+ export type PasskeyPrfSalt = ArrayBuffer | ArrayBufferView | string;
3
+ export interface PasskeyPrfInput {
4
+ salt: PasskeyPrfSalt;
5
+ secondSalt?: PasskeyPrfSalt;
6
+ credentialId?: string;
7
+ }
8
+ export interface PasskeyPrfResult {
9
+ credentialId: string;
10
+ output: Uint8Array;
11
+ outputBase64url: string;
12
+ }
13
+ export declare function encodePrfSalt(salt: PasskeyPrfSalt): string;
14
+ export declare function createPrfRequestBody(input: PasskeyPrfInput): {
15
+ prf: {
16
+ secondSalt?: string | undefined;
17
+ salt: string;
18
+ };
19
+ credentialId?: string | undefined;
20
+ };
21
+ export declare function isPasskeyPrfSupported(): Promise<boolean>;
22
+ export declare function preparePrfRequestOptions(optionsJSON: PublicKeyCredentialRequestOptionsJSON): PublicKeyCredentialRequestOptionsJSON;
23
+ export declare function extractPasskeyPrfResult(credential: AuthenticationResponseJSON): PasskeyPrfResult | null;
24
+ export declare function stripPrfResultsFromAssertion(credential: AuthenticationResponseJSON): AuthenticationResponseJSON;
25
+ export declare function getRegistrationPrfCapable(attestationResponse: {
26
+ clientExtensionResults?: unknown;
27
+ }): boolean;
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
+ import type { LoginMethod } from '@/client/createSeamlessAuthClient';
2
3
  interface AuthFallbackOptionsProps {
3
4
  identifier: string;
4
5
  onMagicLink: () => void;
6
+ onEmailOtp?: () => void;
5
7
  onPhoneOtp: () => void;
6
- onPasskeyRetry: () => void;
8
+ onPasskeyRetry?: () => void;
9
+ loginMethods?: LoginMethod[];
7
10
  }
8
11
  declare const AuthFallbackOptions: React.FC<AuthFallbackOptionsProps>;
9
12
  export default AuthFallbackOptions;
@@ -1,6 +1,4 @@
1
- export type AuthMode = 'web' | 'server';
2
1
  interface FetchWithAuthOptions {
3
- authMode: AuthMode;
4
2
  authHost?: string;
5
3
  }
6
4
  export declare const createFetchWithAuth: (opts: FetchWithAuthOptions) => (input: string, init?: RequestInit) => Promise<Response>;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { AuthContextType, AuthProvider, useAuth } from '@/AuthProvider';
2
2
  import { AuthRoutes } from '@/AuthRoutes';
3
- import { createSeamlessAuthClient, CurrentUserResult, LoginInput, PasskeyLoginResult, PasskeyMetadata, PasskeyRegistrationResult, RegisterInput, SeamlessAuthClient, SeamlessAuthClientOptions } from '@/client/createSeamlessAuthClient';
4
- import { AuthMode } from '@/fetchWithAuth';
3
+ import { createSeamlessAuthClient, CreateOrganizationInput, CurrentUserResult, FinishOAuthLoginInput, LoginInput, LoginMethod, LoginStartResult, OAuthProvider, OAuthProvidersResult, OrganizationMemberInput, OrganizationMemberUpdateInput, OrganizationMembersResult, OrganizationResult, OrganizationsResult, PasskeyLoginResult, PasskeyLoginWithPrfResult, PasskeyMetadata, PasskeyRegistrationResult, RegisterInput, RegisterPasskeyOptions, SeamlessAuthClient, SeamlessAuthClientOptions, StartOAuthLoginInput, StartOAuthLoginResult, StepUpMethod, StepUpStatus, StepUpWithPasskeyPrfResult, StepUpVerificationResult, UpdateOrganizationInput } from '@/client/createSeamlessAuthClient';
4
+ import { encodePrfSalt, extractPasskeyPrfResult, isPasskeyPrfSupported, PasskeyPrfInput, PasskeyPrfResult } from '@/client/webauthnPrf';
5
5
  import { useAuthClient } from '@/hooks/useAuthClient';
6
6
  import { usePasskeySupport } from '@/hooks/usePasskeySupport';
7
- import { Credential, User } from '@/types';
8
- export { AuthProvider, AuthRoutes, createSeamlessAuthClient, useAuth, useAuthClient, usePasskeySupport, };
9
- export type { AuthContextType, AuthMode, Credential, CurrentUserResult, LoginInput, PasskeyLoginResult, PasskeyMetadata, PasskeyRegistrationResult, RegisterInput, SeamlessAuthClient, SeamlessAuthClientOptions, User, };
7
+ import { hasScopedRole, roleGrantsAccess } from '@/scopedRoles';
8
+ import { Credential, Organization, OrganizationMembership, User } from '@/types';
9
+ export { AuthProvider, AuthRoutes, createSeamlessAuthClient, encodePrfSalt, extractPasskeyPrfResult, hasScopedRole, isPasskeyPrfSupported, roleGrantsAccess, useAuth, useAuthClient, usePasskeySupport, };
10
+ export type { AuthContextType, Credential, CreateOrganizationInput, CurrentUserResult, FinishOAuthLoginInput, LoginInput, LoginMethod, LoginStartResult, OAuthProvider, OAuthProvidersResult, Organization, OrganizationMemberInput, OrganizationMembership, OrganizationMemberUpdateInput, OrganizationMembersResult, OrganizationResult, OrganizationsResult, PasskeyLoginWithPrfResult, PasskeyLoginResult, PasskeyMetadata, PasskeyPrfInput, PasskeyPrfResult, PasskeyRegistrationResult, RegisterInput, RegisterPasskeyOptions, SeamlessAuthClient, SeamlessAuthClientOptions, StartOAuthLoginInput, StartOAuthLoginResult, StepUpMethod, StepUpStatus, StepUpWithPasskeyPrfResult, StepUpVerificationResult, UpdateOrganizationInput, User, };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as o,Fragment as n}from"react/jsx-runtime";import{startRegistration as r,WebAuthnError as i,startAuthentication as t}from"@simplewebauthn/browser";import{useState as a,useEffect as s,createContext as l,useMemo as d,useCallback as c,useContext as _,useRef as m}from"react";import{useNavigate as u,useSearchParams as g,useLocation as p,Routes as h,Route as f,Navigate as y}from"react-router-dom";import b,{AsYouType as k,parsePhoneNumberFromString as v}from"libphonenumber-js";const x=e=>{const o=(e=>{const{authMode:o,authHost:n}=e;return async function(e,r){const i=`${n}${"server"===o?"auth":""}${e.startsWith("/")?e:`/${e}`}`,t={...r,credentials:"include",headers:{"Content-Type":"application/json",...r?.headers}},a=await fetch(i,t);return a.ok||console.warn("Auth fetch failed:",a.status,i),a}})({authMode:e.mode,authHost:e.apiHost});return{getCurrentUser:()=>o("users/me",{method:"GET"}),login:e=>o("/login",{method:"POST",body:JSON.stringify(e)}),loginWithPasskey:async()=>{const e=await o("/webAuthn/login/start",{method:"POST"});if(!e.ok)return{success:!1,mfaRequired:!1,message:"Failed to start passkey login."};try{const n=await e.json(),r=await t({optionsJSON:n}),i=await o("/webAuthn/login/finish",{method:"POST",body:JSON.stringify({assertionResponse:r})});if(!i.ok)return{success:!1,mfaRequired:!1,message:"Failed to verify passkey."};const a=await i.json();return"Success"===a.message?{success:!a.mfaLogin,mfaRequired:Boolean(a.mfaLogin),message:a.mfaLogin?"Passkey login requires MFA.":"Passkey login succeeded."}:{success:!1,mfaRequired:!1,message:a.message??"Passkey login failed."}}catch(e){return console.error("Passkey login error:",e),{success:!1,mfaRequired:!1,message:"Passkey login failed."}}},logout:()=>o("/logout",{method:"GET"}),deleteUser:()=>o("/users/delete",{method:"DELETE"}),register:e=>o("/registration/register",{method:"POST",body:JSON.stringify({email:e.email,phone:e.phone,...e.bootstrapToken?{bootstrapToken:e.bootstrapToken}:{}})}),requestPhoneOtp:()=>o("/otp/generate-phone-otp",{method:"GET"}),verifyPhoneOtp:e=>o("/otp/verify-phone-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationToken:e}),credentials:"include"}),requestEmailOtp:()=>o("/otp/generate-email-otp",{method:"GET",headers:{"Content-Type":"application/json"}}),verifyEmailOtp:e=>o("/otp/verify-email-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationToken:e}),credentials:"include"}),requestMagicLink:()=>o("/magic-link",{method:"GET"}),checkMagicLink:()=>o("/magic-link/check",{method:"GET",headers:{"Content-Type":"application/json"}}),verifyMagicLink:e=>o(`/magic-link/verify/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}}),registerPasskey:async e=>{const n=await o("/webAuthn/register/start",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!n.ok)return{success:!1,message:"Failed to fetch passkey registration challenge."};const t=await n.json();let a;try{a=await r({optionsJSON:t})}catch(e){return e instanceof i?{success:!1,message:e.name}:(console.error("Passkey registration error:",e),{success:!1,message:"Passkey registration failed."})}return(await o("/webAuthn/register/finish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attestationResponse:a,metadata:e}),credentials:"include"})).ok?{success:!0,message:"Passkey registered successfully."}:{success:!1,message:"Verification failed."}},updateCredential:e=>o("users/credentials",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),deleteCredential:e=>o("users/credentials",{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})})}};const w=l(void 0),P=()=>{const e=_(w);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},N=({children:o,apiHost:n,autoDetectPreviousSignin:r=!0,mode:i="web"})=>{const[t,l]=a(null),[_,m]=a([]),[u,g]=a(!1),[p,h]=a(!0),{hasSignedInBefore:f,markSignedIn:y}=function(e="seamlessauth_seen"){const[o,n]=a(!1);return s(()=>{try{"true"===localStorage.getItem(e)&&n(!0)}catch{}},[e]),{hasSignedInBefore:o,markSignedIn:()=>{try{localStorage.setItem(e,"true"),n(!0)}catch{}}}}(),b=i,k=d(()=>x({mode:b,apiHost:n}),[b,n]),v=c(async()=>{try{await k.logout()}catch{console.error("Error during logout")}finally{g(!1),l(null),m([])}},[k]),P=c(async()=>{h(!0);try{const e=await k.getCurrentUser();if(e.ok){const{user:o,credentials:n}=await e.json();l(o),m(n??[]),g(!0)}else await v()}catch{await v()}finally{h(!1)}},[k,v]);return s(()=>{P()},[P]),s(()=>{t&&u&&y()},[t,u,y]),e(w.Provider,{value:{user:t,logout:v,refreshSession:P,loading:p,deleteUser:async()=>{try{if((await k.deleteUser()).ok)return l(null),g(!1),void m([]);throw new Error("Could not delete user.")}catch(e){throw console.error("Something went wrong deleting user:",e),new Error("Could not delete user.")}},isAuthenticated:u,hasRole:e=>t?.roles?.includes(e),apiHost:n,markSignedIn:y,hasSignedInBefore:!!r&&f,mode:b,credentials:_,updateCredential:async e=>{const o=await k.updateCredential({friendlyName:e.friendlyName,id:e.id});if(o.ok)return o.json();throw new Error("Failed to update credential")},deleteCredential:async e=>{const o=await k.deleteCredential(e);if(o.ok)return o.json();throw new Error("Failed to update credential")},login:async(e,o)=>k.login({identifier:e,passkeyAvailable:o}),handlePasskeyLogin:async()=>{const e=await k.loginWithPasskey();return e.mfaRequired?(console.warn("Passkey login requested MFA, but the built-in MFA route is not currently available."),!1):e.success?(await P(),!0):(console.error("Passkey login failed:",e.message),!1)}},children:o})};function C(e,o){void 0===o&&(o={});var n=o.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var M="login-module__container___YggDx",T="login-module__card___Ub-Py",S="login-module__heading___neEqb",I="login-module__inputGroup___P6qgS",O="login-module__label___mx5vu",E="login-module__input___U07lW",A="login-module__helperText___kDQ4-",j="login-module__error___40zxh",B="login-module__button___0kFBs",z="login-module__toggle___1JiG1",L="login-module__underline___gs-RS",F="login-module__phoneRow___oeNtq",q="login-module__select___rRV1O",R="login-module__phoneInput___2MPQC",G="login-module__fallbackCard___HdIk-",V="login-module__fallbackHeader___-il2v",D="login-module__fallbackDescription___ea5EB",U="login-module__fallbackActions___AD3ni",K="login-module__fallbackActionButton___lFgWf",W="login-module__actionTitle___ycrMp",J="login-module__actionSubtext___opaIV",H="login-module__linkButton___5lsoe";C(".login-module__container___YggDx{align-items:center;color:#fff;display:flex;justify-content:center}.login-module__card___Ub-Py{background-color:#1f2937;border-radius:.5rem;box-shadow:0 4px 6px rgba(0,0,0,.1);max-width:28rem;padding:2rem;width:100%}.login-module__heading___neEqb{color:#fff;font-size:1.5rem;font-weight:700;margin-bottom:1.5rem;text-align:center}.login-module__message___qSejT{color:#68d391;text-align:center}.login-module__inputGroup___P6qgS{margin-bottom:1rem}.login-module__label___mx5vu{color:#d1d5db;display:block}.login-module__input___U07lW{background-color:#4b5563;border:1px solid #d1d5db;border-radius:.375rem;margin-top:.25rem;padding:.5rem;width:100%}.login-module__input___U07lW:focus{box-shadow:0 0 0 2px #3b82f6;outline:none}.login-module__helperText___kDQ4-{color:#9ca3af;font-size:.75rem;margin-top:.5rem}.login-module__error___40zxh{color:#f87171;font-size:.875rem}.login-module__button___0kFBs{background-color:#2563eb;border-radius:.375rem;color:#fff;cursor:pointer;margin-top:1rem;padding:.5rem;transition:background-color .3s;width:100%}.login-module__button___0kFBs:hover{background-color:#1d4ed8}.login-module__button___0kFBs:disabled{background-color:#9ca3af;cursor:not-allowed}.login-module__toggle___1JiG1{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.875rem;margin-top:1.5rem;text-align:center;width:100%}.login-module__underline___gs-RS{text-decoration:underline}.login-module__phoneRow___oeNtq{display:grid;gap:.5rem;grid-template-columns:1fr 3fr;margin-top:.25rem}.login-module__phoneInput___2MPQC,.login-module__select___rRV1O{background-color:#4b5563;border:1px solid #d1d5db;border-radius:.375rem;padding:.5rem;width:100%}@media (max-width:500px){.login-module__phoneRow___oeNtq{grid-template-columns:1fr}}.login-module__fallbackCard___HdIk-{background:hsla(0,0%,100%,.04);border:1px solid hsla(0,0%,100%,.08);border-radius:12px;display:flex;flex-direction:column;gap:14px;margin-top:18px;padding:18px}.login-module__fallbackHeader___-il2v{color:#f3f4f6;font-size:.95rem;font-weight:600}.login-module__fallbackDescription___ea5EB{color:#9ca3af;font-size:.85rem;line-height:1.4}.login-module__fallbackActions___AD3ni{display:flex;flex-direction:column;gap:10px}.login-module__fallbackActionButton___lFgWf{background:rgba(0,0,0,.25);border:1px solid hsla(0,0%,100%,.08);border-radius:8px;cursor:pointer;display:flex;flex-direction:column;padding:12px 14px;text-align:left;transition:all .15s ease}.login-module__fallbackActionButton___lFgWf:hover{background:hsla(0,0%,100%,.06);border-color:hsla(0,0%,100%,.15)}.login-module__actionTitle___ycrMp{color:#f9fafb;font-size:.9rem;font-weight:500}.login-module__actionSubtext___opaIV{color:#9ca3af;font-size:.75rem;margin-top:2px}.login-module__linkButton___5lsoe{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.8rem;margin-top:6px}.login-module__linkButton___5lsoe:hover{text-decoration:underline}");var $="termsModal-module__overlay___-j6r5",Y="termsModal-module__modal___4PxZV",Z="termsModal-module__header___B7wxb",Q="termsModal-module__title___Sucwt",X="termsModal-module__closeBtn___evIs5",ee="termsModal-module__content___5BDhN",oe="termsModal-module__link___oPZrU";C(".termsModal-module__overlay___-j6r5{align-items:center;background-color:rgba(0,0,0,.7);display:flex;inset:0;justify-content:center;position:fixed;z-index:999}.termsModal-module__modal___4PxZV{background-color:#1a1a1a;border-radius:8px;box-shadow:0 10px 25px rgba(0,0,0,.4);color:#fff;max-height:80vh;max-width:640px;outline:none;overflow-y:auto;padding:24px;width:100%}.termsModal-module__header___B7wxb{align-items:center;display:flex;justify-content:space-between;margin-bottom:16px}.termsModal-module__title___Sucwt{color:#60a5fa;font-size:1.25rem;font-weight:700}.termsModal-module__closeBtn___evIs5{background:none;border:none;color:#ccc;cursor:pointer;font-size:1.75rem}.termsModal-module__closeBtn___evIs5:hover{color:#fff}.termsModal-module__content___5BDhN{color:#d1d5db;font-size:.9rem;line-height:1.6}.termsModal-module__link___oPZrU{color:#60a5fa;text-decoration:underline}.termsModal-module__link___oPZrU:hover{text-decoration:none}");const ne=({isOpen:n,onClose:r})=>{const i=m(null);return s(()=>{const e=e=>{"Escape"===e.key&&r()};return n&&(document.addEventListener("keydown",e),i.current?.focus()),()=>{document.removeEventListener("keydown",e)}},[n,r]),n?e("div",{className:$,role:"dialog","aria-modal":"true","aria-labelledby":"terms-title",children:o("div",{className:Y,tabIndex:-1,ref:i,children:[o("div",{className:Z,children:[e("h2",{id:"terms-title",className:Q,children:"SMS Terms & Conditions"}),e("button",{onClick:r,className:X,children:"×"})]}),o("div",{className:ee,children:[o("p",{children:[e("strong",{children:"Effective Date:"})," June 01, 2025"]}),e("p",{children:"By providing your phone number to SeamlessAuth, a Fells Code LLC product, you agree to receive SMS messages for identity verification, authentication, and account security."}),o("p",{children:[e("strong",{children:"1. Purpose:"})," SMS is used only for account security (OTP, MFA). No marketing messages."]}),o("p",{children:[e("strong",{children:"2. Frequency:"})," Based on login and account activity."]}),o("p",{children:[e("strong",{children:"3. Opt-Out:"})," Contact support@seamlessauth.com to opt out."]}),o("p",{children:[e("strong",{children:"4. Fees:"})," Message and data rates may apply."]}),o("p",{children:[e("strong",{children:"5. Supported Carriers:"})," Most major providers supported, delivery not guaranteed."]}),o("p",{children:[e("strong",{children:"6. Privacy:"})," Your phone number is not shared or sold. See our Privacy Policy."]}),o("p",{children:[e("strong",{children:"7. Changes:"})," Terms may be updated with notice on this page."]}),o("p",{children:["Questions? Email us at"," ",e("a",{className:oe,href:"mailto:support@seamlessauth.com",children:"support@seamlessauth.com"}),"."]})]})]})}):null},re=[{code:"US",name:"United States",dialCode:"+1",flag:"🇺🇸"},{code:"CA",name:"Canada",dialCode:"+1",flag:"🇨🇦"},{code:"GB",name:"United Kingdom",dialCode:"+44",flag:"🇬🇧"},{code:"IN",name:"India",dialCode:"+91",flag:"🇮🇳"},{code:"AU",name:"Australia",dialCode:"+61",flag:"🇦🇺"}];function ie({phone:n,setPhone:r,phoneError:i,setPhoneError:t}){const[l,d]=a(!1),[c,_]=a(re[0]);s(()=>{const e=function(){try{const e=Intl.DateTimeFormat().resolvedOptions().locale||"en-US",o=e.split("-")[1]?.toUpperCase()||"US";return re.find(e=>e.code===o)||re[0]}catch{return re[0]}}();_(e)},[]);return o("div",{className:I,children:[e("label",{id:"phone",className:O,children:"Phone Number"}),o("div",{className:F,children:[e("select",{value:c.code,onChange:e=>{const o=re.find(o=>o.code===e.target.value);if(o){_(o);const e=n.replace(/^\+\d+/,""),i=(new k).input(o.dialCode+e);r(i)}},className:q,children:re.map(e=>o("option",{value:e.code,children:[e.flag," (",e.dialCode,")"]},e.code))}),e("input",{"aria-labelledby":"phone",type:"tel",value:n,onChange:e=>{const o=e.target.value,n=o.startsWith(c.dialCode)?o:c.dialCode+o,a=(new k).input(n);r(a),i&&t("")},onBlur:()=>{if(n){const e=v(n),o=e?.isValid();t(o?"":"Please enter a valid phone number.")}},autoComplete:"off",placeholder:"(555) 123-4567",className:R})]}),o("p",{className:A,children:["By signing up, you agree to our"," ",e("button",{onClick:()=>d(!0),className:L,children:"SMS Terms & Conditions"}),"."]}),i&&e("p",{className:j,children:i}),e(ne,{isOpen:l,onClose:()=>d(!1)})]})}const te=()=>{const{apiHost:e,mode:o}=P();return d(()=>x({apiHost:e,mode:o}),[e,o])},ae=e=>{if("string"!=typeof e)return!1;const o=e.trim();if(o.length<3||o.length>320)return!1;const n=o.split("@");if(2!==n.length)return!1;const[r,i]=n;return!(!/^[A-Za-z0-9._%+-]+$/.test(r)||r.startsWith(".")||r.endsWith(".")||r.includes(".."))&&!(!/^[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(i)||i.startsWith("-")||i.endsWith("-")||i.startsWith(".")||i.endsWith(".")||i.includes(".."))},se=e=>{const o=b(e);return o?.isValid()||!1};const le=()=>{const[e,o]=a(!1),[n,r]=a(!0);return s(()=>{let e=!0;return(async()=>{try{const n=await async function(){if(window.PublicKeyCredential&&"function"==typeof window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)try{return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch(e){return console.error("Error checking passkey support:",e),!1}return!1}();e&&o(n)}catch{e&&o(!1)}finally{e&&r(!1)}})(),()=>{e=!1}},[]),{passkeySupported:e,loading:n}},de=({identifier:n,onMagicLink:r,onPhoneOtp:i,onPasskeyRetry:t})=>{const a=ae(n),s=se(n);return o("div",{className:G,children:[e("div",{className:V,children:"Trouble with passkey login?"}),e("p",{className:D,children:"Choose another secure sign-in method."}),o("div",{className:U,children:[a&&o("button",{type:"button",className:K,onClick:r,children:[e("span",{className:W,children:"Email Magic Link"}),e("span",{className:J,children:"Send a secure sign-in link to your email"})]}),s&&o("button",{type:"button",className:K,onClick:i,children:[e("span",{className:W,children:"Text Message Code"}),e("span",{className:J,children:"Receive a one-time code via SMS"})]})]}),e("button",{type:"button",className:H,onClick:t,children:"Try passkey anyway"})]})},ce=()=>{const r=u(),{hasSignedInBefore:i,login:t,handlePasskeyLogin:l}=P(),d=te(),{passkeySupported:c}=le(),[_,m]=a(""),[g,p]=a(""),[h,f]=a("register"),[y,b]=a(""),[k,v]=a(""),[x,w]=a(""),[N,C]=a(""),[L,F]=a(""),[q,R]=a(!1),[G,V]=a(null);s(()=>{i&&f("login");const e=new URLSearchParams(window.location.search).get("bootstrapToken");e&&e.length>10&&(V(e),console.log("Bootstrap token detected in URL"))},[i]);return e("div",{className:M,children:o("div",{className:T,children:[e("h2",{className:S,children:"login"===h?"Sign In":"Create Account"}),e(n,{children:o("form",{onSubmit:async e=>{e.preventDefault(),v(""),R(!1);try{if("login"===h){const e=await t(_,c);if(e?.ok&&c){return await l()?void r("/"):(R(!0),void v("Passkey sign-in could not be completed. Choose another sign-in method."))}return e?.ok?void R(!0):void v("Failed to start sign-in. Please try again.")}"register"===h&&await(async()=>{v("");try{const e=await d.register({email:g,phone:y,bootstrapToken:G});if(!e.ok)return void v("Failed to register. Please try again.");if("Success"===(await e.json()).message)return void r("/verifyPhoneOTP");v("An unexpected error occurred. Try again. If the problem persists, try resetting your password.")}catch(e){console.error("Unexpected login error",e),v("An unexpected error occurred. Try again. If the problem persists, try resetting your password.")}})()}catch(e){console.error(e),v("Failed to continue sign-in. Please try again.")}},children:["login"===h&&o("div",{className:I,children:[e("label",{htmlFor:"identifier",className:O,children:"Email Address / Phone Number"}),e("input",{id:"identifier",type:"text",value:_,onChange:e=>{const o=e.target.value;m(o)},autoComplete:"off",placeholder:"Email or Phone Number",className:E,onBlur:()=>{if(_){const e=ae(_)||se(_);F(e?"":"Please enter a valid email or phone number")}},required:!0}),e("p",{className:A,children:"Phone numbers must include a country code e.g. +1"}),q&&e(de,{identifier:_,onMagicLink:async()=>{try{if(!(await d.requestMagicLink()).ok)return void v("Failed to send magic link.");r("/magiclinks-sent",{state:{identifier:_}})}catch(e){console.error(e),v("Failed to send magic link.")}},onPhoneOtp:async()=>{try{if(!(await d.requestPhoneOtp()).ok)return void v("Failed to send OTP.");r("/verifyPhoneOTP")}catch(e){console.error(e),v("Failed to send OTP.")}},onPasskeyRetry:l}),L&&e("p",{className:j,children:L})]}),"register"===h&&o(n,{children:[o("div",{className:I,children:[e("label",{htmlFor:"email",className:O,children:"Email Address"}),e("input",{id:"email",type:"email",value:g,onChange:e=>{const o=e.target.value;p(o)},autoComplete:"off",className:E,onBlur:()=>{if(g){const e=ae(g);C(e?"":"Please enter a valid email")}},required:!0}),N&&e("p",{className:j,children:N})]}),e(ie,{phone:y,setPhone:b,phoneError:x,setPhoneError:w})]}),e("button",{type:"submit",className:B,disabled:!("login"===h&&_?ae(_)||se(_):ae(g)&&se(y)),children:"login"===h?"Login":"Register"}),k&&e("p",{className:j,children:k}),e("button",{type:"button",onClick:()=>f("login"===h?"register":"login"),className:z,children:"login"===h?"Don't have an account? Create one":"Already have an account? Sign in"})]})})]})})};var _e={container:"passKeyLogin-module__container___IUKxF",card:"passKeyLogin-module__card___2sKM1",title:"passKeyLogin-module__title___HZxvc",button:"passKeyLogin-module__button___FvR4I"};C(".passKeyLogin-module__container___IUKxF{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.passKeyLogin-module__card___2sKM1{background-color:#1f2937;border-radius:1rem;box-shadow:0 4px 20px rgba(0,0,0,.4);display:flex;flex-direction:column;gap:1.5rem;max-width:400px;padding:2rem;width:100%}.passKeyLogin-module__title___HZxvc{color:#fff;font-size:1.5rem;font-weight:600;text-align:center}.passKeyLogin-module__button___FvR4I{background-color:#2563eb;border:1px solid #3b82f6;border-radius:.5rem;color:#fff;cursor:pointer;font-weight:500;padding:.75rem 1rem;text-align:center;transition:background-color .2s ease;width:100%}.passKeyLogin-module__button___FvR4I:hover{background-color:#1d4ed8}@media (max-width:480px){.passKeyLogin-module__card___2sKM1{padding:1.25rem}.passKeyLogin-module__button___FvR4I{font-size:1rem}}");const me=()=>{const n=u(),{handlePasskeyLogin:r}=P(),[i,t]=a("");return e("div",{className:_e.container,children:o("div",{className:_e.card,children:[e("h2",{className:_e.title,children:"Login with Passkey"}),e("button",{onClick:async()=>{t("");await r()?n("/"):t("Passkey sign-in could not be completed. Try another sign-in method.")},className:_e.button,children:"Use Passkey"}),i&&e("p",{className:_e.error,children:i})]})})};var ue="registerPasskey-module__container___jqEh8",ge="registerPasskey-module__card___MJAyC",pe="registerPasskey-module__loading___Q4i1x",he="registerPasskey-module__spinner___V1nhd",fe="registerPasskey-module__supported___ihTih",ye="registerPasskey-module__title___vn2Qu",be="registerPasskey-module__description___AWmO-",ke="registerPasskey-module__button___D3b4B",ve="registerPasskey-module__message___RiOw-",xe="registerPasskey-module__success___HP5aX",we="registerPasskey-module__error___hGiqE";C(".registerPasskey-module__container___jqEh8{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.registerPasskey-module__card___MJAyC{background-color:#1f2937;border-radius:1rem;box-shadow:0 4px 20px rgba(0,0,0,.4);max-width:400px;padding:1.5rem;width:100%}.registerPasskey-module__loading___Q4i1x{align-items:center;background-color:#f9fafb;border-radius:.75rem;box-shadow:0 2px 8px rgba(0,0,0,.1);color:#374151;display:flex;font-weight:500;gap:.75rem;justify-content:center;padding:1.5rem}.registerPasskey-module__spinner___V1nhd{animation:registerPasskey-module__spin___oYcsC 1s linear infinite;border-color:#3b82f6 transparent;border-radius:9999px;border-style:solid;border-width:2px;height:1.5rem;width:1.5rem}@keyframes registerPasskey-module__spin___oYcsC{to{transform:rotate(1turn)}}.registerPasskey-module__supported___ihTih{background-color:#ecfdf5;border-radius:.75rem;box-shadow:0 2px 12px rgba(0,0,0,.1);color:#065f46;padding:1.25rem}.registerPasskey-module__title___vn2Qu{font-size:1.125rem;font-weight:600;margin-bottom:.5rem}.registerPasskey-module__description___AWmO-{margin-bottom:1rem}.registerPasskey-module__button___D3b4B{background-color:#059669;border:none;border-radius:.5rem;color:#fff;cursor:pointer;font-weight:500;padding:.75rem 1rem;transition:background-color .2s ease;width:100%}.registerPasskey-module__button___D3b4B:hover{background-color:#047857}.registerPasskey-module__message___RiOw-{font-size:.875rem;margin-top:1rem}.registerPasskey-module__success___HP5aX{color:#6ee7b7}.registerPasskey-module__error___hGiqE{color:#f87171}");var Pe="deviceNameModal-module__overlay___fmdPd",Ne="deviceNameModal-module__modal___uoEda",Ce="deviceNameModal-module__description___-HMTA",Me="deviceNameModal-module__input___4vQMI",Te="deviceNameModal-module__actions___KXw7b",Se="deviceNameModal-module__primary___9Ozlk",Ie="deviceNameModal-module__secondary___HILhc";C(".deviceNameModal-module__overlay___fmdPd{align-items:center;background:rgba(0,0,0,.45);display:flex;inset:0;justify-content:center;position:fixed;z-index:1000}.deviceNameModal-module__modal___uoEda{background:#1f2937;border-radius:12px;box-shadow:0 20px 40px rgba(0,0,0,.15);color:#fff;max-width:420px;padding:24px;width:100%}.deviceNameModal-module__description___-HMTA{color:#fff;font-size:14px;margin-bottom:16px}.deviceNameModal-module__input___4vQMI{border:1px solid #ddd;border-radius:8px;font-size:14px;margin-bottom:20px;padding:10px 12px;width:100%}.deviceNameModal-module__actions___KXw7b{display:flex;gap:10px;justify-content:flex-end}.deviceNameModal-module__primary___9Ozlk{background:#2563eb;border:none;border-radius:8px;color:#fff;cursor:pointer;padding:8px 14px}.deviceNameModal-module__secondary___HILhc{background:transparent;border:1px solid #ccc;border-radius:8px;cursor:pointer;padding:8px 14px}");const Oe=({isOpen:n,onCancel:r,onConfirm:i})=>{const[t,s]=a("");return n?e("div",{className:Pe,children:o("div",{className:Ne,children:[e("h3",{children:"Name This Device"}),e("p",{className:Ce,children:"Give this passkey a friendly name so you can recognize it later."}),e("input",{type:"text",placeholder:"e.g., MacBook Pro, iPhone, YubiKey",value:t,onChange:e=>s(e.target.value),className:Me,autoFocus:!0}),o("div",{className:Te,children:[e("button",{onClick:r,className:Ie,children:"Cancel"}),e("button",{onClick:()=>i(t.trim()),disabled:!t.trim(),className:Se,children:"Continue"})]})]})}):null},Ee=()=>{const{refreshSession:r}=P(),i=te(),{passkeySupported:t,loading:s}=le(),l=u(),[d,c]=a("idle"),[_,m]=a(""),[g,p]=a(!1),[h,f]=a(null);return o(n,{children:[e("div",{className:ue,children:e("div",{className:ge,children:o("div",s||!t?{className:pe,children:[e("div",{className:he}),e("span",{children:s?"Checking for Passkey Support...":"Passkeys are not supported on this device."})]}:{className:fe,children:[e("h2",{className:ye,children:"Secure Your Account with a Passkey"}),e("p",{className:be,children:"Your device supports passkeys! Register one to skip passwords forever."}),e("button",{onClick:()=>{const{platform:e,browser:o,deviceInfo:n}=function(){const e=navigator.userAgent.toLowerCase();let o="unknown",n="unknown";return/iphone|ipad|ipod/.test(e)?o="ios":/android/.test(e)?o="android":/mac os/.test(e)?o="mac":/windows/.test(e)?o="windows":/linux/.test(e)&&(o="linux"),/chrome/.test(e)&&(n="chrome"),/safari/.test(e)&&!/chrome/.test(e)&&(n="safari"),/firefox/.test(e)&&(n="firefox"),/edg/.test(e)&&(n="edge"),{platform:o,browser:n,deviceInfo:`${o} • ${n}`}}();f({platform:e,browser:o,deviceInfo:n}),p(!0)},disabled:"loading"===d,className:ke,children:"loading"===d?"Registering...":"Register Passkey"}),_&&e("p",{className:`${ve} ${"success"===d?xe:we}`,children:_})]})})}),e(Oe,{isOpen:g,onCancel:()=>{p(!1),f(null)},onConfirm:async e=>{if(!h)return;const o={friendlyName:e,...h};c("loading");try{const e=await i.registerPasskey(o);if(!e.success)throw new Error(e.message);await r(),c("success"),m(e.message),l("/")}catch(e){console.error(e),c("error"),m("Error registering passkey.")}finally{p(!1),f(null)}}})]})};var Ae="verifyOTP-module__container___wgoDE",je="verifyOTP-module__card___3cs2p",Be="verifyOTP-module__title___fZ-1d",ze="verifyOTP-module__subtitle___dGSu3",Le="verifyOTP-module__error___GEtlG",Fe="verifyOTP-module__success___46TjG",qe="verifyOTP-module__form___jiGG-",Re="verifyOTP-module__label___Zq5Mi",Ge="verifyOTP-module__timer___smq-a",Ve="verifyOTP-module__resend___PlmkG",De="verifyOTP-module__button___8pIuO",Ue="verifyOTP-module__toggle___wbzVa";C(".verifyOTP-module__container___wgoDE{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.verifyOTP-module__card___3cs2p{background-color:#1f2937;border-radius:.5rem;box-shadow:0 0 10px rgba(0,0,0,.3);max-width:28rem;padding:1.5rem;width:100%}.verifyOTP-module__title___fZ-1d{color:#fff;font-size:1.5rem;font-weight:700;margin-bottom:1rem;text-align:center}.verifyOTP-module__subtitle___dGSu3{color:#9ca3af;font-size:.875rem;margin-bottom:1.5rem;text-align:center}.verifyOTP-module__error___GEtlG{color:#f87171;margin-bottom:1rem;text-align:center}.verifyOTP-module__success___46TjG{color:#34d399;margin-bottom:.75rem;text-align:center}.verifyOTP-module__form___jiGG-{display:flex;flex-direction:column;gap:1rem}.verifyOTP-module__label___Zq5Mi{color:#d1d5db;display:block;font-size:.875rem;margin-bottom:.25rem}.verifyOTP-module__timer___smq-a{color:#facc15;font-size:.875rem}.verifyOTP-module__input___yqIXM{background-color:#374151;border:1px solid #4b5563;border-radius:.375rem;color:#fff;outline:none;padding:.5rem;width:100%}.verifyOTP-module__input___yqIXM:focus{box-shadow:0 0 0 2px #3b82f6}.verifyOTP-module__resend___PlmkG{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.75rem;margin-top:.25rem;text-decoration:underline}.verifyOTP-module__resend___PlmkG:hover{color:#3b82f6}.verifyOTP-module__button___8pIuO{background-color:#2563eb;border:none;border-radius:.375rem;color:#fff;cursor:pointer;padding:.5rem;transition:background-color .2s;width:100%}.verifyOTP-module__button___8pIuO:hover{background-color:#1d4ed8}.verifyOTP-module__toggle___wbzVa{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.875rem;margin-top:1.5rem;text-align:center;width:100%}");var Ke="otpInput-module__otpContainer___MUjby",We="otpInput-module__otpInput___3YMVm";C(".otpInput-module__otpContainer___MUjby{display:flex;gap:8px;justify-content:center;margin-top:8px}.otpInput-module__otpInput___3YMVm{background:#374151;border:1px solid #4b5563;border-radius:8px;color:#fff;font-size:1.2rem;height:48px;text-align:center;transition:border-color .15s ease,box-shadow .15s ease;width:42px}.otpInput-module__otpInput___3YMVm:focus{border-color:#60a5fa;box-shadow:0 0 0 2px rgba(96,165,250,.25);outline:none}");const Je=({length:o=6,value:n,inputMode:r="numeric",onChange:i,name:t="otp"})=>{const a=m([]),s=n.split("").concat(Array(o).fill("")).slice(0,o),l=(e,o)=>{var n;if(o.length>1)d(e,o);else if(!o||(n=o,"numeric"===r?/^\d$/.test(n):/^[a-zA-Z]$/.test(n))){const n=[...s];n[e]=o;const r=n.join("");i(r),o&&a.current[e+1]&&a.current[e+1]?.focus()}},d=(e,n)=>{let t=n;t="numeric"===r?n.replace(/\D/g,""):n.replace(/[^a-zA-Z]/g,"");const l=t.slice(0,o).split(""),d=[...s];l.forEach((n,r)=>{e+r<o&&(d[e+r]=n)}),i(d.join("")),a.current[Math.min(e+l.length,o-1)]?.focus()};return e("div",{className:Ke,role:"group","aria-label":"One-time password input",onPaste:e=>{e.preventDefault(),d(0,e.clipboardData.getData("text"))},children:s.map((n,d)=>e("input",{ref:e=>a.current[d]=e,type:"text",inputMode:"numeric"===r?"numeric":"text",autoComplete:"one-time-code",name:`${t}-${d}`,maxLength:1,value:n,className:We,onChange:e=>l(d,e.target.value),onKeyDown:e=>((e,n)=>{if("Backspace"===n.key){n.preventDefault();const o=[...s];s[e]?(o[e]="",i(o.join(""))):e>0&&(o[e-1]="",i(o.join("")),a.current[e-1]?.focus())}"ArrowLeft"===n.key&&e>0&&a.current[e-1]?.focus(),"ArrowRight"===n.key&&e<o-1&&a.current[e+1]?.focus()})(d,e),"aria-label":`Digit ${d+1}`},d))})},He=()=>{const n=u(),[r,i]=a(""),[t,l]=a(null),[d,c]=a(""),[_,m]=a(!1),[g,p]=a(""),[h,f]=a(300),y=te(),b=async()=>{m(!0);try{if(!t){(await y.verifyPhoneOtp(r)).ok?l(!0):c("Verification failed.")}}catch(e){console.error(e),c("Verification failed.")}m(!1)},k=async()=>{p(""),await(async()=>{c("");const e=await y.requestPhoneOtp(),o=await e.json();e.ok?(o.token&&localStorage.setItem("token",o.token),p("Verification SMS has been resent.")):c("Failed to send SMS code. If this persists, refresh the page and try again.")})(),p("Verification SMS has been resent.")};return s(()=>{const e=setInterval(()=>{f(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[]),s(()=>{t&&(async()=>{(await y.requestEmailOtp()).ok?n("/verifyEmailOTP"):c("Failed to send Email code. If this persists, refresh the page and try registering again.")})()},[t,n,y]),e("div",{className:Ae,children:o("div",{className:je,children:[e("h2",{className:Be,children:"Verify Your Phone Number"}),e("p",{className:ze,children:"Enter the code sent to your phone number."}),d&&e("p",{className:Le,children:d}),g&&e("p",{className:Fe,children:g}),o("form",{onSubmit:async e=>{if(e.preventDefault(),c(""),6===r.length){m(!0);try{await b()}catch{c("Unexpected error occurred.")}finally{m(!1)}}else c("Please enter a valid code.")},className:qe,children:[o("div",{children:[o("label",{htmlFor:"phoneCode",className:Re,children:["Phone Verification Code ",(x=t,!0===x?e("span",{className:"text-green-400 ml-2",children:"✅"}):!1===x?e("span",{className:"text-red-400 ml-2",children:"❌"}):null)," -"," ",o("span",{className:Ge,children:["Code expires in: ",(v=h,`${Math.floor(v/60).toString().padStart(2,"0")}:${(v%60).toString().padStart(2,"0")}`)]})]}),e(Je,{length:6,value:r,onChange:i}),e("button",{type:"button",onClick:()=>k(),className:Ve,children:"Resend code to phone"})]}),e("button",{type:"submit",className:De,children:_?"Verifying...":"Verify & Continue"}),e("button",{type:"button",onClick:()=>n("/login"),className:Ue,children:"Back to login"})]})]})});var v,x},$e=()=>{const n=u(),{refreshSession:r}=P(),i=te(),{passkeySupported:t}=le(),[l,d]=a(!1),[c,_]=a(""),[m,g]=a(300),[p,h]=a(""),[f,y]=a("");return s(()=>{const e=setInterval(()=>{g(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[]),e("div",{className:Ae,children:o("div",{className:je,children:[e("h2",{className:Be,children:"Verify Your Email"}),e("p",{className:ze,children:"We sent you a verification email. Enter the code below."}),p&&e("p",{className:Le,children:p}),f&&e("p",{className:Fe,children:f}),o("form",{onSubmit:async e=>{if(e.preventDefault(),h(""),6===c.length){d(!0);try{if(!(await i.verifyEmailOtp(c)).ok)return void h("Verification failed.");t?n("/registerPasskey"):(await r(),n("/"))}catch(e){console.error(e),h("Verification failed.")}finally{d(!1)}}else h("Please enter a valid code.")},className:qe,children:[o("div",{children:[o("label",{htmlFor:"emailCode",className:Re,children:["Email Verification Code",o("span",{className:Ge,children:[" ","— Code expires in ",(b=m,`${Math.floor(b/60).toString().padStart(2,"0")}:${(b%60).toString().padStart(2,"0")}`)]})]}),e(Je,{length:6,value:c,onChange:_,inputMode:"text"}),e("button",{type:"button",onClick:async()=>{h(""),y("");(await i.requestEmailOtp()).ok?y("Verification email has been resent."):h("Failed to send Email code. If this persists, refresh the page and try again.")},className:Ve,children:"Resend code to email"})]}),e("button",{type:"submit",className:De,disabled:l,children:l?"Verifying...":"Verify & Continue"}),e("button",{type:"button",onClick:()=>n("/login"),className:Ue,children:"Back to login"})]})]})});var b};var Ye={container:"verifyMagiclink-module__container___qrSXf",card:"verifyMagiclink-module__card___niKgr",title:"verifyMagiclink-module__title___SumxD",verificationContent:"verifyMagiclink-module__verificationContent___NdsS0",spinner:"verifyMagiclink-module__spinner___lnW1k",successIcon:"verifyMagiclink-module__successIcon___XjFEM",checkIcon:"verifyMagiclink-module__checkIcon___I0JOP",successText:"verifyMagiclink-module__successText___lO5Qq"};C(".verifyMagiclink-module__container___qrSXf{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.verifyMagiclink-module__card___niKgr{background-color:#1f2937;border-radius:.5rem;box-shadow:0 0 10px rgba(0,0,0,.3);max-width:28rem;padding:1.5rem;width:100%}.verifyMagiclink-module__title___SumxD{color:#fff;font-size:1.5rem;font-weight:700;margin-bottom:1rem;text-align:center}.verifyMagiclink-module__verificationContent___NdsS0{align-items:center;display:flex;flex-direction:column;gap:14px;margin:20px 0}.verifyMagiclink-module__spinner___lnW1k{animation:verifyMagiclink-module__spin___2lGzj .9s linear infinite;border:3px solid hsla(0,0%,100%,.15);border-radius:50%;border-top-color:#60a5fa;height:28px;width:28px}.verifyMagiclink-module__successIcon___XjFEM{align-items:center;background:rgba(16,185,129,.15);border-radius:50%;display:flex;height:36px;justify-content:center;width:36px}.verifyMagiclink-module__checkIcon___I0JOP{animation:verifyMagiclink-module__checkPop___-3qJu .25s ease-out;color:#34d399;height:22px;width:22px}.verifyMagiclink-module__successText___lO5Qq{color:#34d399;font-size:.9rem}@keyframes verifyMagiclink-module__checkPop___-3qJu{0%{opacity:0;transform:scale(.6)}80%{transform:scale(1.15)}to{opacity:1;transform:scale(1)}}@keyframes verifyMagiclink-module__spin___2lGzj{to{transform:rotate(1turn)}}");const Ze=()=>{const[n]=g(),r=u(),i=n.get("token"),[t,l]=a(""),[d,c]=a(""),_=te();return s(()=>{(async()=>{if(!i)return l("Missing token for verification."),void console.error("No token found",i);try{if(!(await _.verifyMagicLink(i)).ok)return console.error("Failed to verify token"),void l("Failed to verify token")}catch(e){console.error(e)}new BroadcastChannel("seamless-auth").postMessage({type:"MAGIC_LINK_AUTH_SUCCESS"}),c("You have been verified on the device and browser that initiated this request"),setTimeout(()=>{r("/")},900)})()},[i,_,r]),e("div",{className:Ye.container,children:o("div",{className:Ye.card,children:[e("h1",{className:Ye.title,children:"Verifying your login"}),o("div",{className:Ye.verificationContent,children:[!d&&!t&&e("div",{className:Ye.spinner}),d&&e("div",{className:Ye.successIcon,children:e("svg",{viewBox:"0 0 24 24",className:Ye.checkIcon,fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M5 13l4 4L19 7"})})}),!d&&!t&&e("p",{className:Ye.helperText,children:"Please wait while we securely verify your sign-in link."}),d&&e("p",{className:Ye.successText,children:"Login verified. Redirecting…"}),t&&e("p",{className:Ye.error,children:t})]})]})})};var Qe="magiclink-module__container___45zcA",Xe="magiclink-module__card___Au9oN",eo="magiclink-module__iconWrapper___k5ndr",oo="magiclink-module__mailIcon___Pwb7q",no="magiclink-module__iconRing___bdLvf",ro="magiclink-module__heading___b9cre",io="magiclink-module__message___kiVFj",to="magiclink-module__identifier___JtcFM",ao="magiclink-module__helperText___7Mlfh",so="magiclink-module__actions___64I-3",lo="magiclink-module__secondaryButton___BntAI",co="magiclink-module__cooldown___Ib4rm",_o="magiclink-module__linkButton___maJiv";C(".magiclink-module__container___45zcA{align-items:center;color:#fff;display:flex;justify-content:center}.magiclink-module__card___Au9oN{background-color:#1f2937;border-radius:.75rem;box-shadow:0 10px 25px rgba(0,0,0,.25);max-width:420px;padding:2.5rem 2rem;text-align:center;width:100%}.magiclink-module__iconWrapper___k5ndr{display:flex;justify-content:center;margin-bottom:1.25rem;position:relative}.magiclink-module__mailIcon___Pwb7q{color:#a5b4fc;height:38px;width:38px;z-index:2}.magiclink-module__iconRing___bdLvf{animation:magiclink-module__pulse___YGm-I 2s infinite;background:rgba(99,102,241,.15);border-radius:50%;height:72px;position:absolute;width:72px}@keyframes magiclink-module__pulse___YGm-I{0%{opacity:.8;transform:scale(.6)}70%{opacity:0;transform:scale(1.4)}to{opacity:0}}.magiclink-module__heading___b9cre{font-size:1.55rem;font-weight:600;margin-bottom:.75rem}.magiclink-module__message___kiVFj{color:#d1d5db;font-size:.95rem;line-height:1.4;margin-bottom:1rem}.magiclink-module__identifier___JtcFM{background:hsla(0,0%,100%,.05);border-radius:6px;display:inline-block;font-size:1rem;font-weight:600;margin-bottom:1rem;padding:.45rem .6rem}.magiclink-module__helperText___7Mlfh{color:#9ca3af;font-size:.85rem;line-height:1.4;margin-bottom:.6rem}.magiclink-module__actions___64I-3{display:flex;flex-direction:column;gap:.6rem;margin-top:1.6rem}.magiclink-module__secondaryButton___BntAI{background:#111827;border:1px solid #374151;border-radius:8px;color:#fff;cursor:pointer;font-weight:500;padding:.65rem}.magiclink-module__secondaryButton___BntAI:hover:not(:disabled){background:#1f2937}.magiclink-module__secondaryButton___BntAI:disabled{cursor:not-allowed;opacity:.5}.magiclink-module__cooldown___Ib4rm{color:#9ca3af;font-size:.8rem}.magiclink-module__linkButton___maJiv{background:none;border:none;color:#a5b4fc;cursor:pointer;font-size:.85rem;margin-top:.4rem}.magiclink-module__linkButton___maJiv:hover{text-decoration:underline}");const mo=()=>{const{refreshSession:n}=P(),r=u(),i=p(),t=te(),l=i.state?.identifier,[d,c]=a(30);s(()=>{const e=setInterval(()=>{c(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[]);return s(()=>{const e=new BroadcastChannel("seamless-auth");return e.onmessage=async e=>{if("MAGIC_LINK_AUTH_SUCCESS"===e.data?.type){200===(await t.checkMagicLink()).status&&(await n(),r("/"))}},()=>{e.close()}},[t,r,n]),s(()=>{const e=setInterval(async()=>{try{200===(await t.checkMagicLink()).status&&(await n(),r("/"))}catch{}},5e3);return()=>clearInterval(e)},[t,n,r]),e("div",{className:Qe,children:o("div",{className:Xe,children:[o("div",{className:eo,children:[e("div",{className:no}),o("svg",{className:oo,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e("path",{d:"M4 6h16v12H4z"}),e("path",{d:"m4 6 8 6 8-6"})]})]}),e("h2",{className:ro,children:"Check your email"}),e("p",{className:io,children:"If an account exists for this address, we sent a secure sign-in link."}),l&&e("div",{className:to,children:l}),e("p",{className:ao,children:"Open the email and click the link to finish signing in."}),e("p",{className:ao,children:"Didn’t receive anything? Check your spam folder or try creating a new account."}),o("div",{className:so,children:[e("button",{className:lo,disabled:d>0,onClick:async()=>{d>0||(await t.requestMagicLink(),c(30))},children:"Resend link"}),d>0&&o("div",{className:co,children:["Available in ",d,"s"]}),e("button",{className:_o,onClick:()=>r("/login"),children:"Change email or phone"})]})]})})},uo=()=>o(h,{children:[e(f,{path:"/login",element:e(ce,{})}),e(f,{path:"/passKeyLogin",element:e(me,{})}),e(f,{path:"/verifyPhoneOTP",element:e(He,{})}),e(f,{path:"/verifyEmailOTP",element:e($e,{})}),e(f,{path:"/verify-magiclink",element:e(Ze,{})}),e(f,{path:"/registerPasskey",element:e(Ee,{})}),e(f,{path:"/magiclinks-sent",element:e(mo,{})}),e(f,{path:"*",element:e(y,{to:"/login",replace:!0})})]});export{N as AuthProvider,uo as AuthRoutes,x as createSeamlessAuthClient,P as useAuth,te as useAuthClient,le as usePasskeySupport};
1
+ import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import{bufferToBase64URLString as n,browserSupportsWebAuthn as i,base64URLStringToBuffer as r,startAuthentication as a,startRegistration as s,WebAuthnError as l}from"@simplewebauthn/browser";import{useState as d,useEffect as c,createContext as u,useMemo as _,useCallback as m,useContext as p,useRef as g}from"react";import{useNavigate as h,useLocation as f,useSearchParams as y,Routes as b,Route as k,Navigate as v}from"react-router-dom";import w,{AsYouType as x,parsePhoneNumberFromString as P}from"libphonenumber-js";function N(e){if(e instanceof ArrayBuffer)return e;const o=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t=new Uint8Array(o.byteLength);return t.set(o),t.buffer}function S(e){return"string"==typeof e?e:n(N(e))}function O(e){return"string"==typeof e?r(e):e}function C(e){return{...e.credentialId?{credentialId:e.credentialId}:{},prf:{salt:S(e.salt),...e.secondSalt?{secondSalt:S(e.secondSalt)}:{}}}}async function T(){return!!i()&&(("undefined"==typeof window||!1!==window.isSecureContext)&&(void 0!==globalThis.PublicKeyCredential&&"undefined"!=typeof navigator&&"function"==typeof navigator.credentials?.get))}function M(e){const o=e,t=o.extensions?.prf?.eval;return t?{...o,extensions:{...o.extensions,prf:{...o.extensions?.prf,eval:{...t,...t.first?{first:O(t.first)}:{},...t.second?{second:O(t.second)}:{}}}}}:e}function A(e){const o=e.clientExtensionResults,t=o?.prf?.results?.first;if(!t)return null;const i=(r=t)instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer,r.byteOffset,r.byteLength);var r;return{credentialId:e.id,output:i,outputBase64url:n(N(i))}}function I(e){const o=e.clientExtensionResults;return o?.prf?.results?{...e,clientExtensionResults:{...e.clientExtensionResults,prf:{...o.prf,results:void 0}}}:e}function E(e){const o=e.clientExtensionResults;return!0===o?.prf?.enabled}const z=e=>({success:!1,fresh:!1,method:null,verifiedAt:null,expiresAt:null,maxAgeSeconds:0,message:e}),L=e=>({...z(e),credentialId:null,prf:null});function j(e){return e?{method:"POST",body:JSON.stringify(C(e))}:{method:"POST"}}const F=e=>{const o=(e=>{const{authHost:o}=e;return async function(e,t){const n=`${o?.replace(/\/+$/,"")??""}/auth${e.startsWith("/")?e:`/${e}`}`,i={...t,credentials:"include",headers:{"Content-Type":"application/json",...t?.headers}},r=await fetch(n,i);return r.ok||console.warn("Auth fetch failed:",r.status),r}})({authHost:e.apiHost});return{getCurrentUser:()=>o("users/me",{method:"GET"}),login:e=>o("/login",{method:"POST",body:JSON.stringify(e)}),loginWithPasskey:async e=>{const t=await o("/webAuthn/login/start",{...j(e?.prf)});if(!t.ok)return{success:!1,mfaRequired:!1,message:"Failed to start passkey login."};try{const e=await t.json(),n=await a({optionsJSON:M(e)}),i=A(n),r=I(n),s=await o("/webAuthn/login/finish",{method:"POST",body:JSON.stringify({assertionResponse:r})});if(!s.ok)return{success:!1,mfaRequired:!1,message:"Failed to verify passkey."};const l=await s.json();return"Success"===l.message?{success:!l.mfaLogin,mfaRequired:Boolean(l.mfaLogin),message:l.mfaLogin?"Passkey login requires MFA.":"Passkey login succeeded.",...i?{prf:i}:{}}:{success:!1,mfaRequired:!1,message:l.message??"Passkey login failed."}}catch{return console.error("Passkey login error."),{success:!1,mfaRequired:!1,message:"Passkey login failed."}}},logout:(e={})=>o("all_sessions"===e.scope?"/logout/all":"/logout",{method:"DELETE"}),logoutAllSessions:()=>o("/logout/all",{method:"DELETE"}),deleteUser:()=>o("/users/delete",{method:"DELETE"}),register:e=>o("/registration/register",{method:"POST",body:JSON.stringify({email:e.email,phone:e.phone,...e.bootstrapToken?{bootstrapToken:e.bootstrapToken}:{}})}),requestPhoneOtp:()=>o("/otp/generate-phone-otp",{method:"GET"}),verifyPhoneOtp:e=>o("/otp/verify-phone-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationToken:e}),credentials:"include"}),requestLoginPhoneOtp:()=>o("/otp/generate-login-phone-otp",{method:"GET"}),verifyLoginPhoneOtp:e=>o("/otp/verify-login-phone-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationToken:e}),credentials:"include"}),requestEmailOtp:()=>o("/otp/generate-email-otp",{method:"GET",headers:{"Content-Type":"application/json"}}),verifyEmailOtp:e=>o("/otp/verify-email-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationToken:e}),credentials:"include"}),requestLoginEmailOtp:()=>o("/otp/generate-login-email-otp",{method:"GET",headers:{"Content-Type":"application/json"}}),verifyLoginEmailOtp:e=>o("/otp/verify-login-email-otp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationToken:e}),credentials:"include"}),requestMagicLink:()=>o("/magic-link",{method:"GET"}),checkMagicLink:()=>o("/magic-link/check",{method:"GET",headers:{"Content-Type":"application/json"}}),verifyMagicLink:e=>o(`/magic-link/verify/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}}),listOAuthProviders:async()=>{const e=await o("/oauth/providers",{method:"GET"});if(!e.ok)throw new Error("Failed to list OAuth providers.");return e.json()},startOAuthLogin:async e=>{const t=await o(`/oauth/${encodeURIComponent(e.providerId)}/start`,{method:"POST",body:JSON.stringify({...e.redirectUri?{redirectUri:e.redirectUri}:{},...e.returnTo?{returnTo:e.returnTo}:{}})});if(!t.ok)throw new Error("Failed to start OAuth login.");return t.json()},finishOAuthLogin:e=>o(`/oauth/${encodeURIComponent(e.providerId)}/callback`,{method:"POST",body:JSON.stringify({code:e.code,state:e.state})}),registerPasskey:async e=>{const t=function(e){return"metadata"in e?e:{metadata:e}}(e),n=await o(function(e){const o=new URLSearchParams;e.requirePrf?o.set("requirePrf","true"):e.requestPrf&&o.set("requestPrf","true");const t=o.toString();return"/webAuthn/register/start"+(t?`?${t}`:"")}(t),{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!n.ok)return{success:!1,message:"Failed to fetch passkey registration challenge."};const i=await n.json();let r;try{r=await s({optionsJSON:i})}catch(e){return e instanceof l?{success:!1,message:e.name}:(console.error("Passkey registration error."),{success:!1,message:"Passkey registration failed."})}return(await o("/webAuthn/register/finish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attestationResponse:r,metadata:{...t.metadata,prfCapable:E(r)}}),credentials:"include"})).ok?{success:!0,message:"Passkey registered successfully.",credentialId:r.id,prfCapable:E(r)}:{success:!1,message:"Verification failed."}},isPasskeyPrfSupported:T,getStepUpStatus:()=>o("/step-up/status",{method:"GET"}),verifyStepUpWithPasskey:async()=>{const e=await o("/step-up/webauthn/start",{method:"POST"});if(!e.ok)return z("Failed to start step-up authentication.");try{const t=await e.json(),n=I(await a({optionsJSON:M(t)})),i=await o("/step-up/webauthn/finish",{method:"POST",body:JSON.stringify({assertionResponse:n})});if(!i.ok)return z("Failed to verify step-up authentication.");const r=await i.json(),s="webauthn"===r.method?r.method:null,l="Success"===r.message&&!0===r.fresh&&"webauthn"===s;return{success:l,fresh:Boolean(r.fresh),method:s,verifiedAt:r.verifiedAt??null,expiresAt:r.expiresAt??null,maxAgeSeconds:r.maxAgeSeconds??0,message:l?"Step-up authentication succeeded.":r.message??"Step-up authentication failed."}}catch{return console.error("Step-up authentication error."),z("Step-up authentication failed.")}},verifyStepUpWithPasskeyPrf:async e=>{const t=await o("/step-up/webauthn/start",{...j(e)});if(!t.ok)return L("Failed to start step-up authentication.");try{const e=await t.json(),n=await a({optionsJSON:M(e)}),i=A(n),r=I(n);if(!i)return L("Passkey did not return PRF output.");const s=await o("/step-up/webauthn/finish",{method:"POST",body:JSON.stringify({assertionResponse:r})});if(!s.ok)return L("Failed to verify step-up authentication.");const l=await s.json(),d="webauthn"===l.method?l.method:null,c="Success"===l.message&&!0===l.fresh&&"webauthn"===d;return{success:c,fresh:Boolean(l.fresh),method:d,verifiedAt:l.verifiedAt??null,expiresAt:l.expiresAt??null,maxAgeSeconds:l.maxAgeSeconds??0,message:c?"Step-up authentication succeeded.":l.message??"Step-up authentication failed.",credentialId:i.credentialId,prf:i}}catch{return console.error("Step-up authentication error."),L("Step-up authentication failed.")}},updateCredential:e=>o("users/credentials",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),deleteCredential:e=>o("users/credentials",{method:"DELETE",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})}),listOrganizations:()=>o("/organizations",{method:"GET"}),createOrganization:e=>o("/organizations",{method:"POST",body:JSON.stringify(e)}),getOrganization:e=>o(`/organizations/${encodeURIComponent(e)}`,{method:"GET"}),updateOrganization:(e,t)=>o(`/organizations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),switchOrganization:e=>o(`/organizations/${encodeURIComponent(e)}/switch`,{method:"POST"}),listOrganizationMembers:e=>o(`/organizations/${encodeURIComponent(e)}/members`,{method:"GET"}),addOrganizationMember:(e,t)=>o(`/organizations/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}),updateOrganizationMember:(e,t,n)=>o(`/organizations/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)}),removeOrganizationMember:(e,t)=>o(`/organizations/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"})}};function U(e,o){const t=e.trim(),n=o.trim();if(!t||!n)return!1;if(t===n)return!0;if(t.endsWith(":*")){const e=t.slice(0,-2);return n===e||n.startsWith(`${e}:`)}if(!n.includes(":"))return!1;if(!t.includes(":"))return n.startsWith(`${t}:`);const i=t.split(":"),r=n.split(":"),a=i[i.length-1],s=r[r.length-1],l=i.slice(0,-1),d=r.slice(0,-1);return"write"===a&&"read"===s&&l.length===d.length&&l.every((e,o)=>e===d[o])}function B(e,o){if(!Array.isArray(e))return!1;const t=e.filter(e=>"string"==typeof e);return(Array.isArray(o)?o:[o]).some(e=>t.some(o=>U(o,e)))}const R=u(void 0),q=()=>{const e=p(R);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},G=({children:o,apiHost:t,autoDetectPreviousSignin:n=!0})=>{const[i,r]=d(null),[a,s]=d([]),[l,u]=d([]),[p,g]=d(null),[h,f]=d(null),[y,b]=d(!1),[k,v]=d(!0),{hasSignedInBefore:w,markSignedIn:x}=function(e="seamlessauth_seen"){const[o,t]=d(!1);return c(()=>{try{"true"===localStorage.getItem(e)&&t(!0)}catch{}},[e]),{hasSignedInBefore:o,markSignedIn:()=>{try{localStorage.setItem(e,"true"),t(!0)}catch{}}}}(),P=_(()=>F({apiHost:t}),[t]),N=m(()=>{b(!1),r(null),s([]),u([]),g(null),f(null)},[]),S=m(async()=>{try{await P.logout()}catch{console.error("Error during logout")}finally{N()}},[P,N]),O=m(async()=>{try{await P.logoutAllSessions()}catch{console.error("Error during logout")}finally{N()}},[P,N]),C=m(async()=>{v(!0);try{const e=await P.getCurrentUser();if(e.ok){const{user:o,credentials:t,organizations:n,activeOrganization:i}=await e.json();r(o),s(t??[]),u(n??[]),g(i??null),b(!0)}else await S()}catch{await S()}finally{v(!1)}},[P,S]),T=m(async()=>{const e=await P.getStepUpStatus();if(!e.ok)return f(null),null;const o=await e.json();return f(o),o},[P]),M=m(async()=>{const e=await P.verifyStepUpWithPasskey();return e.success&&f({fresh:e.fresh,method:e.method,verifiedAt:e.verifiedAt,expiresAt:e.expiresAt,maxAgeSeconds:e.maxAgeSeconds}),e},[P]),A=m(async e=>{const o=await P.verifyStepUpWithPasskeyPrf(e);return o.success&&f({fresh:o.fresh,method:o.method,verifiedAt:o.verifiedAt,expiresAt:o.expiresAt,maxAgeSeconds:o.maxAgeSeconds}),o},[P]);return c(()=>{C()},[C]),c(()=>{i&&y&&x()},[i,y,x]),e(R.Provider,{value:{user:i,logout:S,logoutAllSessions:O,refreshSession:C,loading:k,deleteUser:async()=>{try{if((await P.deleteUser()).ok)return r(null),b(!1),s([]),u([]),g(null),void f(null);throw new Error("Could not delete user.")}catch{throw console.error("Something went wrong deleting user."),new Error("Could not delete user.")}},isAuthenticated:y,hasRole:e=>i?.roles?.includes(e),hasScopedRole:e=>i?B(i.roles,e):void 0,apiHost:t,markSignedIn:x,hasSignedInBefore:!!n&&w,credentials:a,organizations:l,activeOrganization:p,switchOrganization:async e=>{if(!(await P.switchOrganization(e)).ok)throw new Error("Failed to switch organization");await C()},listOAuthProviders:()=>P.listOAuthProviders(),startOAuthLogin:e=>P.startOAuthLogin(e),finishOAuthLogin:async e=>{if(!(await P.finishOAuthLogin(e)).ok)throw new Error("Failed to finish OAuth login");await C()},stepUpStatus:h,updateCredential:async e=>{const o=await P.updateCredential({friendlyName:e.friendlyName,id:e.id});if(o.ok){const e=await o.json(),t=e.credential??e;return s(e=>e.map(e=>e.id===t.id?{...e,...t}:e)),e}throw new Error("Failed to update credential")},deleteCredential:async e=>{const o=await P.deleteCredential(e);if(o.ok){const t=await o.json();return s(o=>o.filter(o=>o.id!==e)),t}throw new Error("Failed to delete credential")},login:async(e,o)=>P.login({identifier:e,passkeyAvailable:o}),handlePasskeyLogin:async()=>{const e=await P.loginWithPasskey();return e.mfaRequired?(console.warn("Passkey login requested MFA, but the built-in MFA route is not currently available."),!1):e.success?(await C(),!0):(console.error("Passkey login failed."),!1)},refreshStepUpStatus:T,verifyStepUpWithPasskey:M,verifyStepUpWithPasskeyPrf:A},children:o})};function D(e,o){void 0===o&&(o={});var t=o.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===t&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var J="login-module__container___YggDx",V="login-module__card___Ub-Py",W="login-module__heading___neEqb",$="login-module__inputGroup___P6qgS",K="login-module__label___mx5vu",H="login-module__input___U07lW",Y="login-module__helperText___kDQ4-",Z="login-module__error___40zxh",Q="login-module__button___0kFBs",X="login-module__toggle___1JiG1",ee="login-module__underline___gs-RS",oe="login-module__phoneRow___oeNtq",te="login-module__select___rRV1O",ne="login-module__phoneInput___2MPQC",ie="login-module__fallbackCard___HdIk-",re="login-module__fallbackHeader___-il2v",ae="login-module__fallbackDescription___ea5EB",se="login-module__fallbackActions___AD3ni",le="login-module__fallbackActionButton___lFgWf",de="login-module__actionTitle___ycrMp",ce="login-module__actionSubtext___opaIV",ue="login-module__linkButton___5lsoe";D(".login-module__container___YggDx{align-items:center;color:#fff;display:flex;justify-content:center}.login-module__card___Ub-Py{background-color:#1f2937;border-radius:.5rem;box-shadow:0 4px 6px rgba(0,0,0,.1);max-width:28rem;padding:2rem;width:100%}.login-module__heading___neEqb{color:#fff;font-size:1.5rem;font-weight:700;margin-bottom:1.5rem;text-align:center}.login-module__message___qSejT{color:#68d391;text-align:center}.login-module__inputGroup___P6qgS{margin-bottom:1rem}.login-module__label___mx5vu{color:#d1d5db;display:block}.login-module__input___U07lW{background-color:#4b5563;border:1px solid #d1d5db;border-radius:.375rem;margin-top:.25rem;padding:.5rem;width:100%}.login-module__input___U07lW:focus{box-shadow:0 0 0 2px #3b82f6;outline:none}.login-module__helperText___kDQ4-{color:#9ca3af;font-size:.75rem;margin-top:.5rem}.login-module__error___40zxh{color:#f87171;font-size:.875rem}.login-module__button___0kFBs{background-color:#2563eb;border-radius:.375rem;color:#fff;cursor:pointer;margin-top:1rem;padding:.5rem;transition:background-color .3s;width:100%}.login-module__button___0kFBs:hover{background-color:#1d4ed8}.login-module__button___0kFBs:disabled{background-color:#9ca3af;cursor:not-allowed}.login-module__toggle___1JiG1{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.875rem;margin-top:1.5rem;text-align:center;width:100%}.login-module__underline___gs-RS{text-decoration:underline}.login-module__phoneRow___oeNtq{display:grid;gap:.5rem;grid-template-columns:1fr 3fr;margin-top:.25rem}.login-module__phoneInput___2MPQC,.login-module__select___rRV1O{background-color:#4b5563;border:1px solid #d1d5db;border-radius:.375rem;padding:.5rem;width:100%}@media (max-width:500px){.login-module__phoneRow___oeNtq{grid-template-columns:1fr}}.login-module__fallbackCard___HdIk-{background:hsla(0,0%,100%,.04);border:1px solid hsla(0,0%,100%,.08);border-radius:12px;display:flex;flex-direction:column;gap:14px;margin-top:18px;padding:18px}.login-module__fallbackHeader___-il2v{color:#f3f4f6;font-size:.95rem;font-weight:600}.login-module__fallbackDescription___ea5EB{color:#9ca3af;font-size:.85rem;line-height:1.4}.login-module__fallbackActions___AD3ni{display:flex;flex-direction:column;gap:10px}.login-module__fallbackActionButton___lFgWf{background:rgba(0,0,0,.25);border:1px solid hsla(0,0%,100%,.08);border-radius:8px;cursor:pointer;display:flex;flex-direction:column;padding:12px 14px;text-align:left;transition:all .15s ease}.login-module__fallbackActionButton___lFgWf:hover{background:hsla(0,0%,100%,.06);border-color:hsla(0,0%,100%,.15)}.login-module__actionTitle___ycrMp{color:#f9fafb;font-size:.9rem;font-weight:500}.login-module__actionSubtext___opaIV{color:#9ca3af;font-size:.75rem;margin-top:2px}.login-module__linkButton___5lsoe{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.8rem;margin-top:6px}.login-module__linkButton___5lsoe:hover{text-decoration:underline}");var _e="termsModal-module__overlay___-j6r5",me="termsModal-module__modal___4PxZV",pe="termsModal-module__header___B7wxb",ge="termsModal-module__title___Sucwt",he="termsModal-module__closeBtn___evIs5",fe="termsModal-module__content___5BDhN",ye="termsModal-module__link___oPZrU";D(".termsModal-module__overlay___-j6r5{align-items:center;background-color:rgba(0,0,0,.7);display:flex;inset:0;justify-content:center;position:fixed;z-index:999}.termsModal-module__modal___4PxZV{background-color:#1a1a1a;border-radius:8px;box-shadow:0 10px 25px rgba(0,0,0,.4);color:#fff;max-height:80vh;max-width:640px;outline:none;overflow-y:auto;padding:24px;width:100%}.termsModal-module__header___B7wxb{align-items:center;display:flex;justify-content:space-between;margin-bottom:16px}.termsModal-module__title___Sucwt{color:#60a5fa;font-size:1.25rem;font-weight:700}.termsModal-module__closeBtn___evIs5{background:none;border:none;color:#ccc;cursor:pointer;font-size:1.75rem}.termsModal-module__closeBtn___evIs5:hover{color:#fff}.termsModal-module__content___5BDhN{color:#d1d5db;font-size:.9rem;line-height:1.6}.termsModal-module__link___oPZrU{color:#60a5fa;text-decoration:underline}.termsModal-module__link___oPZrU:hover{text-decoration:none}");const be=({isOpen:t,onClose:n})=>{const i=g(null);return c(()=>{const e=e=>{"Escape"===e.key&&n()};return t&&(document.addEventListener("keydown",e),i.current?.focus()),()=>{document.removeEventListener("keydown",e)}},[t,n]),t?e("div",{className:_e,role:"dialog","aria-modal":"true","aria-labelledby":"terms-title",children:o("div",{className:me,tabIndex:-1,ref:i,children:[o("div",{className:pe,children:[e("h2",{id:"terms-title",className:ge,children:"SMS Terms & Conditions"}),e("button",{onClick:n,className:he,children:"×"})]}),o("div",{className:fe,children:[o("p",{children:[e("strong",{children:"Effective Date:"})," June 01, 2025"]}),e("p",{children:"By providing your phone number to SeamlessAuth, a Fells Code LLC product, you agree to receive SMS messages for identity verification, authentication, and account security."}),o("p",{children:[e("strong",{children:"1. Purpose:"})," SMS is used only for account security (OTP, MFA). No marketing messages."]}),o("p",{children:[e("strong",{children:"2. Frequency:"})," Based on login and account activity."]}),o("p",{children:[e("strong",{children:"3. Opt-Out:"})," Contact support@seamlessauth.com to opt out."]}),o("p",{children:[e("strong",{children:"4. Fees:"})," Message and data rates may apply."]}),o("p",{children:[e("strong",{children:"5. Supported Carriers:"})," Most major providers supported, delivery not guaranteed."]}),o("p",{children:[e("strong",{children:"6. Privacy:"})," Your phone number is not shared or sold. See our Privacy Policy."]}),o("p",{children:[e("strong",{children:"7. Changes:"})," Terms may be updated with notice on this page."]}),o("p",{children:["Questions? Email us at"," ",e("a",{className:ye,href:"mailto:support@seamlessauth.com",children:"support@seamlessauth.com"}),"."]})]})]})}):null},ke=[{code:"US",name:"United States",dialCode:"+1",flag:"🇺🇸"},{code:"CA",name:"Canada",dialCode:"+1",flag:"🇨🇦"},{code:"GB",name:"United Kingdom",dialCode:"+44",flag:"🇬🇧"},{code:"IN",name:"India",dialCode:"+91",flag:"🇮🇳"},{code:"AU",name:"Australia",dialCode:"+61",flag:"🇦🇺"}];function ve({phone:t,setPhone:n,phoneError:i,setPhoneError:r}){const[a,s]=d(!1),[l,u]=d(ke[0]);c(()=>{const e=function(){try{const e=Intl.DateTimeFormat().resolvedOptions().locale||"en-US",o=e.split("-")[1]?.toUpperCase()||"US";return ke.find(e=>e.code===o)||ke[0]}catch{return ke[0]}}();u(e)},[]);return o("div",{className:$,children:[e("label",{id:"phone",className:K,children:"Phone Number"}),o("div",{className:oe,children:[e("select",{value:l.code,onChange:e=>{const o=ke.find(o=>o.code===e.target.value);if(o){u(o);const e=t.replace(/^\+\d+/,""),i=(new x).input(o.dialCode+e);n(i)}},className:te,children:ke.map(e=>o("option",{value:e.code,children:[e.flag," (",e.dialCode,")"]},e.code))}),e("input",{"aria-labelledby":"phone",type:"tel",value:t,onChange:e=>{const o=e.target.value,t=o.startsWith(l.dialCode)?o:l.dialCode+o,a=(new x).input(t);n(a),i&&r("")},onBlur:()=>{if(t){const e=P(t),o=e?.isValid();r(o?"":"Please enter a valid phone number.")}},autoComplete:"off",placeholder:"(555) 123-4567",className:ne})]}),o("p",{className:Y,children:["By signing up, you agree to our"," ",e("button",{onClick:()=>s(!0),className:ee,children:"SMS Terms & Conditions"}),"."]}),i&&e("p",{className:Z,children:i}),e(be,{isOpen:a,onClose:()=>s(!1)})]})}const we=()=>{const{apiHost:e}=q();return _(()=>F({apiHost:e}),[e])},xe=e=>{if("string"!=typeof e)return!1;const o=e.trim();if(o.length<3||o.length>320)return!1;const t=o.split("@");if(2!==t.length)return!1;const[n,i]=t;return!(!/^[A-Za-z0-9._%+-]+$/.test(n)||n.startsWith(".")||n.endsWith(".")||n.includes(".."))&&!(!/^[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(i)||i.startsWith("-")||i.endsWith("-")||i.startsWith(".")||i.endsWith(".")||i.includes(".."))},Pe=e=>{const o=w(e);return o?.isValid()||!1};const Ne=()=>{const[e,o]=d(!1),[t,n]=d(!0);return c(()=>{let e=!0;return(async()=>{try{const t=await async function(){if(window.PublicKeyCredential&&"function"==typeof window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)try{return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return console.error("Error checking passkey support."),!1}return!1}();e&&o(t)}catch{e&&o(!1)}finally{e&&n(!1)}})(),()=>{e=!1}},[]),{passkeySupported:e,loading:t}},Se=({identifier:t,onMagicLink:n,onEmailOtp:i,onPhoneOtp:r,onPasskeyRetry:a,loginMethods:s})=>{const l=new Set(s??["passkey","magic_link","phone_otp"]),d=l.has("magic_link")&&xe(t),c=l.has("email_otp")&&Boolean(i)&&xe(t),u=l.has("phone_otp")&&Pe(t),_=l.has("passkey")&&Boolean(a);return d||c||u||_?o("div",{className:ie,children:[e("div",{className:re,children:"Choose a sign-in method"}),e("p",{className:ae,children:"Choose another secure sign-in method."}),o("div",{className:se,children:[d&&o("button",{type:"button",className:le,onClick:n,children:[e("span",{className:de,children:"Email Magic Link"}),e("span",{className:ce,children:"Send a secure sign-in link to your email"})]}),c&&o("button",{type:"button",className:le,onClick:i,children:[e("span",{className:de,children:"Email Code"}),e("span",{className:ce,children:"Receive a one-time code by email"})]}),u&&o("button",{type:"button",className:le,onClick:r,children:[e("span",{className:de,children:"Text Message Code"}),e("span",{className:ce,children:"Receive a one-time code via SMS"})]})]}),_&&e("button",{type:"button",className:ue,onClick:a,children:"Try passkey anyway"})]}):null},Oe=["passkey","magic_link","phone_otp"],Ce=()=>{const n=h(),{hasSignedInBefore:i,login:r,handlePasskeyLogin:a}=q(),s=we(),{passkeySupported:l}=Ne(),[u,_]=d(""),[m,p]=d(""),[g,f]=d("register"),[y,b]=d(""),[k,v]=d(""),[w,x]=d(""),[P,N]=d(""),[S,O]=d(""),[C,T]=d(!1),[M,A]=d(Oe),[I,E]=d(null);c(()=>{i&&f("login");const e=new URLSearchParams(window.location.search).get("bootstrapToken");e&&e.length>10&&E(e)},[i]);return e("div",{className:J,children:o("div",{className:V,children:[e("h2",{className:W,children:"login"===g?"Sign In":"Create Account"}),e(t,{children:o("form",{onSubmit:async e=>{e.preventDefault(),v(""),T(!1);try{if("login"===g){const e=await r(u,l),o=await(async e=>{if(!e||"function"!=typeof e.json)return null;try{return await e.json()}catch{return null}})(e),t=o?.loginMethods?.length?o.loginMethods:Oe;if(A(t),e?.ok&&l&&t.includes("passkey")){return await a()?void n("/"):(T(!0),void v("Passkey sign-in could not be completed. Choose another sign-in method."))}return e?.ok?void T(!0):void v("Failed to start sign-in. Please try again.")}"register"===g&&await(async()=>{v("");try{const e=await s.register({email:m,phone:y,bootstrapToken:I});if(!e.ok)return void v("Failed to register. Please try again.");if("Success"===(await e.json()).message)return void n("/verifyPhoneOTP");v("An unexpected error occurred. Try again. If the problem persists, try resetting your password.")}catch{console.error("Unexpected login error."),v("An unexpected error occurred. Try again. If the problem persists, try resetting your password.")}})()}catch{console.error("Failed to continue sign-in."),v("Failed to continue sign-in. Please try again.")}},children:["login"===g&&o("div",{className:$,children:[e("label",{htmlFor:"identifier",className:K,children:"Email Address / Phone Number"}),e("input",{id:"identifier",type:"text",value:u,onChange:e=>{const o=e.target.value;_(o)},autoComplete:"off",placeholder:"Email or Phone Number",className:H,onBlur:()=>{if(u){const e=xe(u)||Pe(u);O(e?"":"Please enter a valid email or phone number")}},required:!0}),e("p",{className:Y,children:"Phone numbers must include a country code e.g. +1"}),C&&e(Se,{identifier:u,onMagicLink:async()=>{try{if(!(await s.requestMagicLink()).ok)return void v("Failed to send magic link.");n("/magiclinks-sent",{state:{identifier:u}})}catch{console.error("Failed to send magic link."),v("Failed to send magic link.")}},onEmailOtp:async()=>{try{if(!(await s.requestLoginEmailOtp()).ok)return void v("Failed to send email code.");n("/verifyEmailOTP",{state:{flow:"login"}})}catch{console.error("Failed to send email OTP."),v("Failed to send email code.")}},onPhoneOtp:async()=>{try{if(!(await s.requestLoginPhoneOtp()).ok)return void v("Failed to send OTP.");n("/verifyPhoneOTP",{state:{flow:"login"}})}catch{console.error("Failed to send phone OTP."),v("Failed to send OTP.")}},onPasskeyRetry:l?a:void 0,loginMethods:M}),S&&e("p",{className:Z,children:S})]}),"register"===g&&o(t,{children:[o("div",{className:$,children:[e("label",{htmlFor:"email",className:K,children:"Email Address"}),e("input",{id:"email",type:"email",value:m,onChange:e=>{const o=e.target.value;p(o)},autoComplete:"off",className:H,onBlur:()=>{if(m){const e=xe(m);N(e?"":"Please enter a valid email")}},required:!0}),P&&e("p",{className:Z,children:P})]}),e(ve,{phone:y,setPhone:b,phoneError:w,setPhoneError:x})]}),e("button",{type:"submit",className:Q,disabled:!("login"===g&&u?xe(u)||Pe(u):xe(m)&&Pe(y)),children:"login"===g?"Login":"Register"}),k&&e("p",{className:Z,children:k}),e("button",{type:"button",onClick:()=>f("login"===g?"register":"login"),className:X,children:"login"===g?"Don't have an account? Create one":"Already have an account? Sign in"})]})})]})})};var Te={container:"passKeyLogin-module__container___IUKxF",card:"passKeyLogin-module__card___2sKM1",title:"passKeyLogin-module__title___HZxvc",button:"passKeyLogin-module__button___FvR4I"};D(".passKeyLogin-module__container___IUKxF{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.passKeyLogin-module__card___2sKM1{background-color:#1f2937;border-radius:1rem;box-shadow:0 4px 20px rgba(0,0,0,.4);display:flex;flex-direction:column;gap:1.5rem;max-width:400px;padding:2rem;width:100%}.passKeyLogin-module__title___HZxvc{color:#fff;font-size:1.5rem;font-weight:600;text-align:center}.passKeyLogin-module__button___FvR4I{background-color:#2563eb;border:1px solid #3b82f6;border-radius:.5rem;color:#fff;cursor:pointer;font-weight:500;padding:.75rem 1rem;text-align:center;transition:background-color .2s ease;width:100%}.passKeyLogin-module__button___FvR4I:hover{background-color:#1d4ed8}@media (max-width:480px){.passKeyLogin-module__card___2sKM1{padding:1.25rem}.passKeyLogin-module__button___FvR4I{font-size:1rem}}");const Me=()=>{const t=h(),{handlePasskeyLogin:n}=q(),[i,r]=d("");return e("div",{className:Te.container,children:o("div",{className:Te.card,children:[e("h2",{className:Te.title,children:"Login with Passkey"}),e("button",{onClick:async()=>{r("");await n()?t("/"):r("Passkey sign-in could not be completed. Try another sign-in method.")},className:Te.button,children:"Use Passkey"}),i&&e("p",{className:Te.error,children:i})]})})};var Ae="registerPasskey-module__container___jqEh8",Ie="registerPasskey-module__card___MJAyC",Ee="registerPasskey-module__loading___Q4i1x",ze="registerPasskey-module__spinner___V1nhd",Le="registerPasskey-module__supported___ihTih",je="registerPasskey-module__title___vn2Qu",Fe="registerPasskey-module__description___AWmO-",Ue="registerPasskey-module__button___D3b4B",Be="registerPasskey-module__message___RiOw-",Re="registerPasskey-module__success___HP5aX",qe="registerPasskey-module__error___hGiqE";D(".registerPasskey-module__container___jqEh8{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.registerPasskey-module__card___MJAyC{background-color:#1f2937;border-radius:1rem;box-shadow:0 4px 20px rgba(0,0,0,.4);max-width:400px;padding:1.5rem;width:100%}.registerPasskey-module__loading___Q4i1x{align-items:center;background-color:#f9fafb;border-radius:.75rem;box-shadow:0 2px 8px rgba(0,0,0,.1);color:#374151;display:flex;font-weight:500;gap:.75rem;justify-content:center;padding:1.5rem}.registerPasskey-module__spinner___V1nhd{animation:registerPasskey-module__spin___oYcsC 1s linear infinite;border-color:#3b82f6 transparent;border-radius:9999px;border-style:solid;border-width:2px;height:1.5rem;width:1.5rem}@keyframes registerPasskey-module__spin___oYcsC{to{transform:rotate(1turn)}}.registerPasskey-module__supported___ihTih{background-color:#ecfdf5;border-radius:.75rem;box-shadow:0 2px 12px rgba(0,0,0,.1);color:#065f46;padding:1.25rem}.registerPasskey-module__title___vn2Qu{font-size:1.125rem;font-weight:600;margin-bottom:.5rem}.registerPasskey-module__description___AWmO-{margin-bottom:1rem}.registerPasskey-module__button___D3b4B{background-color:#059669;border:none;border-radius:.5rem;color:#fff;cursor:pointer;font-weight:500;padding:.75rem 1rem;transition:background-color .2s ease;width:100%}.registerPasskey-module__button___D3b4B:hover{background-color:#047857}.registerPasskey-module__message___RiOw-{font-size:.875rem;margin-top:1rem}.registerPasskey-module__success___HP5aX{color:#6ee7b7}.registerPasskey-module__error___hGiqE{color:#f87171}");var Ge="deviceNameModal-module__overlay___fmdPd",De="deviceNameModal-module__modal___uoEda",Je="deviceNameModal-module__description___-HMTA",Ve="deviceNameModal-module__input___4vQMI",We="deviceNameModal-module__actions___KXw7b",$e="deviceNameModal-module__primary___9Ozlk",Ke="deviceNameModal-module__secondary___HILhc";D(".deviceNameModal-module__overlay___fmdPd{align-items:center;background:rgba(0,0,0,.45);display:flex;inset:0;justify-content:center;position:fixed;z-index:1000}.deviceNameModal-module__modal___uoEda{background:#1f2937;border-radius:12px;box-shadow:0 20px 40px rgba(0,0,0,.15);color:#fff;max-width:420px;padding:24px;width:100%}.deviceNameModal-module__description___-HMTA{color:#fff;font-size:14px;margin-bottom:16px}.deviceNameModal-module__input___4vQMI{border:1px solid #ddd;border-radius:8px;font-size:14px;margin-bottom:20px;padding:10px 12px;width:100%}.deviceNameModal-module__actions___KXw7b{display:flex;gap:10px;justify-content:flex-end}.deviceNameModal-module__primary___9Ozlk{background:#2563eb;border:none;border-radius:8px;color:#fff;cursor:pointer;padding:8px 14px}.deviceNameModal-module__secondary___HILhc{background:transparent;border:1px solid #ccc;border-radius:8px;cursor:pointer;padding:8px 14px}");const He=({isOpen:t,onCancel:n,onConfirm:i})=>{const[r,a]=d("");return t?e("div",{className:Ge,children:o("div",{className:De,children:[e("h3",{children:"Name This Device"}),e("p",{className:Je,children:"Give this passkey a friendly name so you can recognize it later."}),e("input",{type:"text",placeholder:"e.g., MacBook Pro, iPhone, YubiKey",value:r,onChange:e=>a(e.target.value),className:Ve,autoFocus:!0}),o("div",{className:We,children:[e("button",{onClick:n,className:Ke,children:"Cancel"}),e("button",{onClick:()=>i(r.trim()),disabled:!r.trim(),className:$e,children:"Continue"})]})]})}):null},Ye=()=>{const{refreshSession:n}=q(),i=we(),{passkeySupported:r,loading:a}=Ne(),s=h(),[l,c]=d("idle"),[u,_]=d(""),[m,p]=d(!1),[g,f]=d(null);return o(t,{children:[e("div",{className:Ae,children:e("div",{className:Ie,children:o("div",a||!r?{className:Ee,children:[e("div",{className:ze}),e("span",{children:a?"Checking for Passkey Support...":"Passkeys are not supported on this device."})]}:{className:Le,children:[e("h2",{className:je,children:"Secure Your Account with a Passkey"}),e("p",{className:Fe,children:"Your device supports passkeys! Register one to skip passwords forever."}),e("button",{onClick:()=>{const{platform:e,browser:o,deviceInfo:t}=function(){const e=navigator.userAgent.toLowerCase();let o="unknown",t="unknown";return/iphone|ipad|ipod/.test(e)?o="ios":/android/.test(e)?o="android":/mac os/.test(e)?o="mac":/windows/.test(e)?o="windows":/linux/.test(e)&&(o="linux"),/chrome/.test(e)&&(t="chrome"),/safari/.test(e)&&!/chrome/.test(e)&&(t="safari"),/firefox/.test(e)&&(t="firefox"),/edg/.test(e)&&(t="edge"),{platform:o,browser:t,deviceInfo:`${o} • ${t}`}}();f({platform:e,browser:o,deviceInfo:t}),p(!0)},disabled:"loading"===l,className:Ue,children:"loading"===l?"Registering...":"Register Passkey"}),u&&e("p",{className:`${Be} ${"success"===l?Re:qe}`,children:u})]})})}),e(He,{isOpen:m,onCancel:()=>{p(!1),f(null)},onConfirm:async e=>{if(!g)return;const o={friendlyName:e,...g};c("loading");try{const e=await i.registerPasskey(o);if(!e.success)throw new Error(e.message);await n(),c("success"),_(e.message),s("/")}catch{console.error("Passkey registration failed."),c("error"),_("Error registering passkey.")}finally{p(!1),f(null)}}})]})};var Ze="verifyOTP-module__container___wgoDE",Qe="verifyOTP-module__card___3cs2p",Xe="verifyOTP-module__title___fZ-1d",eo="verifyOTP-module__subtitle___dGSu3",oo="verifyOTP-module__error___GEtlG",to="verifyOTP-module__success___46TjG",no="verifyOTP-module__form___jiGG-",io="verifyOTP-module__label___Zq5Mi",ro="verifyOTP-module__timer___smq-a",ao="verifyOTP-module__resend___PlmkG",so="verifyOTP-module__button___8pIuO",lo="verifyOTP-module__toggle___wbzVa";D(".verifyOTP-module__container___wgoDE{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.verifyOTP-module__card___3cs2p{background-color:#1f2937;border-radius:.5rem;box-shadow:0 0 10px rgba(0,0,0,.3);max-width:28rem;padding:1.5rem;width:100%}.verifyOTP-module__title___fZ-1d{color:#fff;font-size:1.5rem;font-weight:700;margin-bottom:1rem;text-align:center}.verifyOTP-module__subtitle___dGSu3{color:#9ca3af;font-size:.875rem;margin-bottom:1.5rem;text-align:center}.verifyOTP-module__error___GEtlG{color:#f87171;margin-bottom:1rem;text-align:center}.verifyOTP-module__success___46TjG{color:#34d399;margin-bottom:.75rem;text-align:center}.verifyOTP-module__form___jiGG-{display:flex;flex-direction:column;gap:1rem}.verifyOTP-module__label___Zq5Mi{color:#d1d5db;display:block;font-size:.875rem;margin-bottom:.25rem}.verifyOTP-module__timer___smq-a{color:#facc15;font-size:.875rem}.verifyOTP-module__input___yqIXM{background-color:#374151;border:1px solid #4b5563;border-radius:.375rem;color:#fff;outline:none;padding:.5rem;width:100%}.verifyOTP-module__input___yqIXM:focus{box-shadow:0 0 0 2px #3b82f6}.verifyOTP-module__resend___PlmkG{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.75rem;margin-top:.25rem;text-decoration:underline}.verifyOTP-module__resend___PlmkG:hover{color:#3b82f6}.verifyOTP-module__button___8pIuO{background-color:#2563eb;border:none;border-radius:.375rem;color:#fff;cursor:pointer;padding:.5rem;transition:background-color .2s;width:100%}.verifyOTP-module__button___8pIuO:hover{background-color:#1d4ed8}.verifyOTP-module__toggle___wbzVa{background:none;border:none;color:#60a5fa;cursor:pointer;font-size:.875rem;margin-top:1.5rem;text-align:center;width:100%}");var co="otpInput-module__otpContainer___MUjby",uo="otpInput-module__otpInput___3YMVm";D(".otpInput-module__otpContainer___MUjby{display:flex;gap:8px;justify-content:center;margin-top:8px}.otpInput-module__otpInput___3YMVm{background:#374151;border:1px solid #4b5563;border-radius:8px;color:#fff;font-size:1.2rem;height:48px;text-align:center;transition:border-color .15s ease,box-shadow .15s ease;width:42px}.otpInput-module__otpInput___3YMVm:focus{border-color:#60a5fa;box-shadow:0 0 0 2px rgba(96,165,250,.25);outline:none}");const _o=({length:o=6,value:t,inputMode:n="numeric",onChange:i,name:r="otp"})=>{const a=g([]),s=t.split("").concat(Array(o).fill("")).slice(0,o),l=(e,o)=>{var t;if(o.length>1)d(e,o);else if(!o||(t=o,"numeric"===n?/^\d$/.test(t):/^[a-zA-Z]$/.test(t))){const t=[...s];t[e]=o;const n=t.join("");i(n),o&&a.current[e+1]&&a.current[e+1]?.focus()}},d=(e,t)=>{let r=t;r="numeric"===n?t.replace(/\D/g,""):t.replace(/[^a-zA-Z]/g,"");const l=r.slice(0,o).split(""),d=[...s];l.forEach((t,n)=>{e+n<o&&(d[e+n]=t)}),i(d.join("")),a.current[Math.min(e+l.length,o-1)]?.focus()};return e("div",{className:co,role:"group","aria-label":"One-time password input",onPaste:e=>{e.preventDefault(),d(0,e.clipboardData.getData("text"))},children:s.map((t,d)=>e("input",{ref:e=>a.current[d]=e,type:"text",inputMode:"numeric"===n?"numeric":"text",autoComplete:"one-time-code",name:`${r}-${d}`,maxLength:1,value:t,className:uo,onChange:e=>l(d,e.target.value),onKeyDown:e=>((e,t)=>{if("Backspace"===t.key){t.preventDefault();const o=[...s];s[e]?(o[e]="",i(o.join(""))):e>0&&(o[e-1]="",i(o.join("")),a.current[e-1]?.focus())}"ArrowLeft"===t.key&&e>0&&a.current[e-1]?.focus(),"ArrowRight"===t.key&&e<o-1&&a.current[e+1]?.focus()})(d,e),"aria-label":`Digit ${d+1}`},d))})},mo=()=>{const t=h(),n=f(),{refreshSession:i}=q(),r="login"===n.state?.flow,[a,s]=d(""),[l,u]=d(null),[_,m]=d(""),[p,g]=d(!1),[y,b]=d(""),[k,v]=d(300),w=we(),x=async()=>{g(!0);try{if(!l){if((r?await w.verifyLoginPhoneOtp(a):await w.verifyPhoneOtp(a)).ok){if(r)return await i(),void t("/");u(!0)}else m("Verification failed.")}}catch{console.error("Phone OTP verification failed."),m("Verification failed.")}g(!1)},P=async()=>{b(""),await(async()=>{m(""),(r?await w.requestLoginPhoneOtp():await w.requestPhoneOtp()).ok?b("Verification SMS has been resent."):m("Failed to send SMS code. If this persists, refresh the page and try again.")})(),b("Verification SMS has been resent.")};return c(()=>{const e=setInterval(()=>{v(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[]),c(()=>{l&&!r&&(async()=>{(await w.requestEmailOtp()).ok?t("/verifyEmailOTP"):m("Failed to send Email code. If this persists, refresh the page and try registering again.")})()},[l,r,t,w]),e("div",{className:Ze,children:o("div",{className:Qe,children:[e("h2",{className:Xe,children:"Verify Your Phone Number"}),e("p",{className:eo,children:"Enter the code sent to your phone number."}),_&&e("p",{className:oo,children:_}),y&&e("p",{className:to,children:y}),o("form",{onSubmit:async e=>{if(e.preventDefault(),m(""),6===a.length){g(!0);try{await x()}catch{m("Unexpected error occurred.")}finally{g(!1)}}else m("Please enter a valid code.")},className:no,children:[o("div",{children:[o("label",{htmlFor:"phoneCode",className:io,children:["Phone Verification Code ",(S=l,!0===S?e("span",{className:"text-green-400 ml-2",children:"✅"}):!1===S?e("span",{className:"text-red-400 ml-2",children:"❌"}):null)," -"," ",o("span",{className:ro,children:["Code expires in: ",(N=k,`${Math.floor(N/60).toString().padStart(2,"0")}:${(N%60).toString().padStart(2,"0")}`)]})]}),e(_o,{length:6,value:a,onChange:s}),e("button",{type:"button",onClick:()=>P(),className:ao,children:"Resend code to phone"})]}),e("button",{type:"submit",className:so,children:p?"Verifying...":"Verify & Continue"}),e("button",{type:"button",onClick:()=>t("/login"),className:lo,children:"Back to login"})]})]})});var N,S},po=()=>{const t=h(),n=f(),{refreshSession:i}=q(),r=we(),{passkeySupported:a}=Ne(),s="login"===n.state?.flow,[l,u]=d(!1),[_,m]=d(""),[p,g]=d(300),[y,b]=d(""),[k,v]=d("");return c(()=>{const e=setInterval(()=>{g(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[]),e("div",{className:Ze,children:o("div",{className:Qe,children:[e("h2",{className:Xe,children:"Verify Your Email"}),e("p",{className:eo,children:"We sent you a verification email. Enter the code below."}),y&&e("p",{className:oo,children:y}),k&&e("p",{className:to,children:k}),o("form",{onSubmit:async e=>{if(e.preventDefault(),b(""),6===_.length){u(!0);try{if(!(s?await r.verifyLoginEmailOtp(_):await r.verifyEmailOtp(_)).ok)return void b("Verification failed.");if(s)return await i(),void t("/");a?t("/registerPasskey"):(await i(),t("/"))}catch{console.error("Email OTP verification failed."),b("Verification failed.")}finally{u(!1)}}else b("Please enter a valid code.")},className:no,children:[o("div",{children:[o("label",{htmlFor:"emailCode",className:io,children:["Email Verification Code",o("span",{className:ro,children:[" ","— Code expires in ",(w=p,`${Math.floor(w/60).toString().padStart(2,"0")}:${(w%60).toString().padStart(2,"0")}`)]})]}),e(_o,{length:6,value:_,onChange:m,inputMode:"text"}),e("button",{type:"button",onClick:async()=>{b(""),v("");(s?await r.requestLoginEmailOtp():await r.requestEmailOtp()).ok?v("Verification email has been resent."):b("Failed to send Email code. If this persists, refresh the page and try again.")},className:ao,children:"Resend code to email"})]}),e("button",{type:"submit",className:so,disabled:l,children:l?"Verifying...":"Verify & Continue"}),e("button",{type:"button",onClick:()=>t("/login"),className:lo,children:"Back to login"})]})]})});var w};var go={container:"verifyMagiclink-module__container___qrSXf",card:"verifyMagiclink-module__card___niKgr",title:"verifyMagiclink-module__title___SumxD",verificationContent:"verifyMagiclink-module__verificationContent___NdsS0",spinner:"verifyMagiclink-module__spinner___lnW1k",successIcon:"verifyMagiclink-module__successIcon___XjFEM",checkIcon:"verifyMagiclink-module__checkIcon___I0JOP",successText:"verifyMagiclink-module__successText___lO5Qq"};D(".verifyMagiclink-module__container___qrSXf{align-items:center;color:#fff;display:flex;justify-content:center;padding:1rem}.verifyMagiclink-module__card___niKgr{background-color:#1f2937;border-radius:.5rem;box-shadow:0 0 10px rgba(0,0,0,.3);max-width:28rem;padding:1.5rem;width:100%}.verifyMagiclink-module__title___SumxD{color:#fff;font-size:1.5rem;font-weight:700;margin-bottom:1rem;text-align:center}.verifyMagiclink-module__verificationContent___NdsS0{align-items:center;display:flex;flex-direction:column;gap:14px;margin:20px 0}.verifyMagiclink-module__spinner___lnW1k{animation:verifyMagiclink-module__spin___2lGzj .9s linear infinite;border:3px solid hsla(0,0%,100%,.15);border-radius:50%;border-top-color:#60a5fa;height:28px;width:28px}.verifyMagiclink-module__successIcon___XjFEM{align-items:center;background:rgba(16,185,129,.15);border-radius:50%;display:flex;height:36px;justify-content:center;width:36px}.verifyMagiclink-module__checkIcon___I0JOP{animation:verifyMagiclink-module__checkPop___-3qJu .25s ease-out;color:#34d399;height:22px;width:22px}.verifyMagiclink-module__successText___lO5Qq{color:#34d399;font-size:.9rem}@keyframes verifyMagiclink-module__checkPop___-3qJu{0%{opacity:0;transform:scale(.6)}80%{transform:scale(1.15)}to{opacity:1;transform:scale(1)}}@keyframes verifyMagiclink-module__spin___2lGzj{to{transform:rotate(1turn)}}");const ho=()=>{const[t]=y(),n=h(),i=t.get("token"),[r,a]=d(""),[s,l]=d(""),u=we();return c(()=>{let e=!0,o=null,t=null;return(async()=>{if(!i)return e&&a("Missing token for verification."),void console.error("No magic-link token found.");try{if(!(await u.verifyMagicLink(i)).ok)return console.error("Failed to verify token"),void(e&&a("Failed to verify token"))}catch{console.error("Failed to verify magic-link token.")}e&&(o=new BroadcastChannel("seamless-auth"),o.postMessage({type:"MAGIC_LINK_AUTH_SUCCESS"}),l("You have been verified on the device and browser that initiated this request"),t=setTimeout(()=>{e&&n("/")},900))})(),()=>{e=!1,o?.close(),t&&clearTimeout(t)}},[i,u,n]),e("div",{className:go.container,children:o("div",{className:go.card,children:[e("h1",{className:go.title,children:"Verifying your login"}),o("div",{className:go.verificationContent,children:[!s&&!r&&e("div",{className:go.spinner}),s&&e("div",{className:go.successIcon,children:e("svg",{viewBox:"0 0 24 24",className:go.checkIcon,fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M5 13l4 4L19 7"})})}),!s&&!r&&e("p",{className:go.helperText,children:"Please wait while we securely verify your sign-in link."}),s&&e("p",{className:go.successText,children:"Login verified. Redirecting…"}),r&&e("p",{className:go.error,children:r})]})]})})};var fo="magiclink-module__container___45zcA",yo="magiclink-module__card___Au9oN",bo="magiclink-module__iconWrapper___k5ndr",ko="magiclink-module__mailIcon___Pwb7q",vo="magiclink-module__iconRing___bdLvf",wo="magiclink-module__heading___b9cre",xo="magiclink-module__message___kiVFj",Po="magiclink-module__identifier___JtcFM",No="magiclink-module__helperText___7Mlfh",So="magiclink-module__actions___64I-3",Oo="magiclink-module__secondaryButton___BntAI",Co="magiclink-module__cooldown___Ib4rm",To="magiclink-module__linkButton___maJiv";D(".magiclink-module__container___45zcA{align-items:center;color:#fff;display:flex;justify-content:center}.magiclink-module__card___Au9oN{background-color:#1f2937;border-radius:.75rem;box-shadow:0 10px 25px rgba(0,0,0,.25);max-width:420px;padding:2.5rem 2rem;text-align:center;width:100%}.magiclink-module__iconWrapper___k5ndr{display:flex;justify-content:center;margin-bottom:1.25rem;position:relative}.magiclink-module__mailIcon___Pwb7q{color:#a5b4fc;height:38px;width:38px;z-index:2}.magiclink-module__iconRing___bdLvf{animation:magiclink-module__pulse___YGm-I 2s infinite;background:rgba(99,102,241,.15);border-radius:50%;height:72px;position:absolute;width:72px}@keyframes magiclink-module__pulse___YGm-I{0%{opacity:.8;transform:scale(.6)}70%{opacity:0;transform:scale(1.4)}to{opacity:0}}.magiclink-module__heading___b9cre{font-size:1.55rem;font-weight:600;margin-bottom:.75rem}.magiclink-module__message___kiVFj{color:#d1d5db;font-size:.95rem;line-height:1.4;margin-bottom:1rem}.magiclink-module__identifier___JtcFM{background:hsla(0,0%,100%,.05);border-radius:6px;display:inline-block;font-size:1rem;font-weight:600;margin-bottom:1rem;padding:.45rem .6rem}.magiclink-module__helperText___7Mlfh{color:#9ca3af;font-size:.85rem;line-height:1.4;margin-bottom:.6rem}.magiclink-module__actions___64I-3{display:flex;flex-direction:column;gap:.6rem;margin-top:1.6rem}.magiclink-module__secondaryButton___BntAI{background:#111827;border:1px solid #374151;border-radius:8px;color:#fff;cursor:pointer;font-weight:500;padding:.65rem}.magiclink-module__secondaryButton___BntAI:hover:not(:disabled){background:#1f2937}.magiclink-module__secondaryButton___BntAI:disabled{cursor:not-allowed;opacity:.5}.magiclink-module__cooldown___Ib4rm{color:#9ca3af;font-size:.8rem}.magiclink-module__linkButton___maJiv{background:none;border:none;color:#a5b4fc;cursor:pointer;font-size:.85rem;margin-top:.4rem}.magiclink-module__linkButton___maJiv:hover{text-decoration:underline}");const Mo=()=>{const{refreshSession:t}=q(),n=h(),i=f(),r=we(),a=i.state?.identifier,[s,l]=d(30);c(()=>{const e=setInterval(()=>{l(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[]);return c(()=>{const e=new BroadcastChannel("seamless-auth");return e.onmessage=async e=>{if("MAGIC_LINK_AUTH_SUCCESS"===e.data?.type){200===(await r.checkMagicLink()).status&&(await t(),n("/"))}},()=>{e.close()}},[r,n,t]),c(()=>{const e=setInterval(async()=>{try{200===(await r.checkMagicLink()).status&&(await t(),n("/"))}catch{}},5e3);return()=>clearInterval(e)},[r,t,n]),e("div",{className:fo,children:o("div",{className:yo,children:[o("div",{className:bo,children:[e("div",{className:vo}),o("svg",{className:ko,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e("path",{d:"M4 6h16v12H4z"}),e("path",{d:"m4 6 8 6 8-6"})]})]}),e("h2",{className:wo,children:"Check your email"}),e("p",{className:xo,children:"If an account exists for this address, we sent a secure sign-in link."}),a&&e("div",{className:Po,children:a}),e("p",{className:No,children:"Open the email and click the link to finish signing in."}),e("p",{className:No,children:"Didn’t receive anything? Check your spam folder or try creating a new account."}),o("div",{className:So,children:[e("button",{className:Oo,disabled:s>0,onClick:async()=>{s>0||(await r.requestMagicLink(),l(30))},children:"Resend link"}),s>0&&o("div",{className:Co,children:["Available in ",s,"s"]}),e("button",{className:To,onClick:()=>n("/login"),children:"Change email or phone"})]})]})})},Ao=()=>o(b,{children:[e(k,{path:"/login",element:e(Ce,{})}),e(k,{path:"/passKeyLogin",element:e(Me,{})}),e(k,{path:"/verifyPhoneOTP",element:e(mo,{})}),e(k,{path:"/verifyEmailOTP",element:e(po,{})}),e(k,{path:"/verify-magiclink",element:e(ho,{})}),e(k,{path:"/registerPasskey",element:e(Ye,{})}),e(k,{path:"/magiclinks-sent",element:e(Mo,{})}),e(k,{path:"*",element:e(v,{to:"/login",replace:!0})})]});export{G as AuthProvider,Ao as AuthRoutes,F as createSeamlessAuthClient,S as encodePrfSalt,A as extractPasskeyPrfResult,B as hasScopedRole,T as isPasskeyPrfSupported,U as roleGrantsAccess,q as useAuth,we as useAuthClient,Ne as usePasskeySupport};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/fetchWithAuth.ts","../src/client/createSeamlessAuthClient.ts","../src/AuthProvider.tsx","../src/hooks/usePreviousSignIn.ts","../node_modules/style-inject/dist/style-inject.es.js","../src/components/TermsModal.tsx","../src/components/phoneInput.tsx","../src/hooks/useAuthClient.ts","../src/utils.ts","../src/hooks/usePasskeySupport.ts","../src/components/AuthFallbackOptions.tsx","../src/views/Login.tsx","../src/views/PassKeyLogin.tsx","../src/components/DeviceNameModal.tsx","../src/views/PassKeyRegistration.tsx","../src/components/OtpInput.tsx","../src/views/PhoneRegistration.tsx","../src/views/EmailRegistration.tsx","../src/views/VerifyMagicLink.tsx","../src/components/MagicLinkSent.tsx","../src/AuthRoutes.tsx"],"sourcesContent":[null,null,null,null,"function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["createSeamlessAuthClient","opts","fetchWithAuth","authMode","authHost","async","input","init","url","startsWith","requestInit","credentials","headers","response","fetch","ok","console","warn","status","createFetchWithAuth","mode","apiHost","getCurrentUser","method","login","body","JSON","stringify","loginWithPasskey","success","mfaRequired","message","options","json","credential","startAuthentication","optionsJSON","verificationResponse","assertionResponse","verificationResult","mfaLogin","Boolean","error","logout","deleteUser","register","email","phone","bootstrapToken","requestPhoneOtp","verifyPhoneOtp","verificationToken","requestEmailOtp","verifyEmailOtp","requestMagicLink","checkMagicLink","verifyMagicLink","token","registerPasskey","metadata","challengeRes","attestationResponse","startRegistration","WebAuthnError","name","updateCredential","deleteCredential","id","AuthContext","createContext","undefined","useAuth","context","useContext","Error","AuthProvider","children","autoDetectPreviousSignin","user","setUser","useState","setCredentials","isAuthenticated","setIsAuthenticated","loading","setLoading","hasSignedInBefore","markSignedIn","storageKey","setHasSignedInBefore","useEffect","localStorage","getItem","setItem","usePreviousSignIn","authClient","useMemo","useCallback","validateToken","_jsx","Provider","value","refreshSession","hasRole","role","roles","includes","friendlyName","credentialId","identifier","passkeyAvailable","handlePasskeyLogin","result","styleInject","css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","TermsModal","isOpen","onClose","modalRef","useRef","handleKeyDown","e","key","addEventListener","current","focus","removeEventListener","className","styles","_jsxs","tabIndex","onClick","href","countries","code","dialCode","flag","PhoneInputWithCountryCode","setPhone","phoneError","setPhoneError","showModal","setShowModal","selectedCountry","setSelectedCountry","defaultCountry","locale","Intl","DateTimeFormat","resolvedOptions","countryCode","split","toUpperCase","find","c","getDefaultCountry","onChange","country","target","stripped","replace","newPhone","AsYouType","map","raw","full","formatted","onBlur","parsed","parsePhoneNumberFromString","isValid","autoComplete","placeholder","useAuthClient","isValidEmail","normalized","trim","length","parts","localPart","domainPart","test","endsWith","isValidPhoneNumber","phoneNumber","usePasskeySupport","passkeySupported","setPasskeySupported","active","supported","window","PublicKeyCredential","isUserVerifyingPlatformAuthenticatorAvailable","isPasskeySupported","checkSupport","AuthFallbackOptions","onMagicLink","onPhoneOtp","onPasskeyRetry","showMagicLink","showPhoneOtp","Login","navigate","useNavigate","setIdentifier","setEmail","setMode","formErrors","setFormErrors","emailError","setEmailError","identifierError","setIdentifierError","showFallbackOptions","setShowFallbackOptions","setBootstrapToken","URLSearchParams","location","search","get","log","_Fragment","onSubmit","preventDefault","loginRes","err","htmlFor","required","state","disabled","PassKeyLogin","runPasskeyLogin","setError","container","card","title","button","DeviceNameModal","onCancel","onConfirm","setValue","autoFocus","PasskeyRegistration","passkeySupportLoading","setStatus","setMessage","showDeviceModal","setShowDeviceModal","pendingMetadata","setPendingMetadata","platform","browser","deviceInfo","ua","navigator","userAgent","toLowerCase","parseUserAgent","OtpInput","inputMode","inputs","values","concat","Array","fill","slice","handleChange","index","char","handleBulkInput","newValueArr","newValue","join","cleaned","chars","forEach","i","Math","min","onPaste","clipboardData","getData","el","maxLength","onKeyDown","PhoneRegistration","phoneOtp","setPhoneOtp","phoneVerified","setPhoneVerified","resendMsg","setResendMsg","phoneTimeLeft","setPhoneTimeLeft","verifyPhoneOTP","handleResend","data","onResendPhone","interval","setInterval","prev","clearInterval","nextStep","verified","seconds","floor","toString","padStart","EmailRegistration","emailOtp","setEmailOtp","emailTimeLeft","setEmailTimeLeft","VerifyMagicLink","searchParams","useSearchParams","successMsg","setSuccessMsg","BroadcastChannel","postMessage","setTimeout","verify","verificationContent","spinner","successIcon","viewBox","checkIcon","stroke","strokeWidth","d","helperText","successText","MagicLinkSent","useLocation","cooldown","setCooldown","timer","channel","onmessage","event","close","AuthRoutes","Routes","Route","path","element","Navigate","to"],"mappings":"gfAaO,MC6DMA,EACXC,IAEA,MAAMC,EDhE2B,CAACD,IAClC,MAAME,SAAEA,EAAQC,SAAEA,GAAaH,EAE/B,OAAOI,eACLC,EACAC,GAEA,MAEMC,EAAM,GAAGJ,IAFW,WAAbD,EAAwB,OAAS,KAEbG,EAAMG,WAAW,KAAOH,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cV,EAAA,MAAA,CAAK0C,UAAWC,YAAoBjC,IAEnDV,EAAA,IAAA,CAAG0C,UAAWC,GAAiBlE,SAAA,4DAI/BuB,EAAA,IAAA,CAAG0C,UAAWC,GAAiBlE,SAAA,mFAI/BmE,EAAA,MAAA,CAAKF,UAAWC,GAAclE,SAAA,CAC5BuB,EAAA,SAAA,CACE0C,UAAWC,GACXqG,SAAUyG,EAAW,EACrB3M,QAhFK5I,UACTuV,EAAW,UAET7P,EAAWzC,mBAEjBuS,EAAY,MA2EWjR,SAAA,gBAKhBgR,EAAW,GACV7M,EAAA,MAAA,CAAKF,UAAWC,GAAelE,SAAA,CAAA,gBAAgBgR,SAGjDzP,EAAA,SAAA,CAAQ0C,UAAWC,GAAmBG,QAAS,IAAMuE,EAAS,UAAS5I,SAAA,mCCxGpEuR,GAAa,IACxBpN,EAACqN,EAAM,CAAAxR,SAAA,CACLuB,EAACkQ,EAAK,CAACC,KAAK,SAASC,QAASpQ,EAACoH,GAAK,MACpCpH,EAACkQ,EAAK,CAACC,KAAK,gBAAgBC,QAASpQ,EAACiJ,GAAY,MAClDjJ,EAACkQ,EAAK,CAACC,KAAK,kBAAkBC,QAASpQ,EAACwM,GAAiB,CAAA,KACzDxM,EAACkQ,EAAK,CAACC,KAAK,kBAAkBC,QAASpQ,EAAC+N,GAAiB,CAAA,KACzD/N,EAACkQ,EAAK,CAACC,KAAK,oBAAoBC,QAASpQ,EAACoO,GAAe,CAAA,KACzDpO,EAACkQ,EAAK,CAACC,KAAK,mBAAmBC,QAASpQ,EAAC6J,GAAmB,CAAA,KAC5D7J,EAACkQ,EAAK,CAACC,KAAK,mBAAmBC,QAASpQ,EAACuP,GAAa,CAAA,KACtDvP,EAACkQ,EAAK,CAACC,KAAK,IAAIC,QAASpQ,EAACqQ,EAAQ,CAACC,GAAG,SAAS3L,SAAO","x_google_ignoreList":[4]}
1
+ {"version":3,"file":"index.js","sources":["../src/client/webauthnPrf.ts","../src/client/createSeamlessAuthClient.ts","../src/fetchWithAuth.ts","../src/scopedRoles.ts","../src/AuthProvider.tsx","../src/hooks/usePreviousSignIn.ts","../node_modules/style-inject/dist/style-inject.es.js","../src/components/TermsModal.tsx","../src/components/phoneInput.tsx","../src/hooks/useAuthClient.ts","../src/utils.ts","../src/hooks/usePasskeySupport.ts","../src/components/AuthFallbackOptions.tsx","../src/views/Login.tsx","../src/views/PassKeyLogin.tsx","../src/components/DeviceNameModal.tsx","../src/views/PassKeyRegistration.tsx","../src/components/OtpInput.tsx","../src/views/PhoneRegistration.tsx","../src/views/EmailRegistration.tsx","../src/views/VerifyMagicLink.tsx","../src/components/MagicLinkSent.tsx","../src/AuthRoutes.tsx"],"sourcesContent":[null,null,null,null,null,null,"function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["toArrayBuffer","value","ArrayBuffer","source","Uint8Array","buffer","byteOffset","byteLength","copy","set","encodePrfSalt","salt","bufferToBase64URLString","saltToBufferSource","base64URLStringToBuffer","createPrfRequestBody","input","credentialId","prf","secondSalt","async","isPasskeyPrfSupported","browserSupportsWebAuthn","window","isSecureContext","globalThis","PublicKeyCredential","navigator","credentials","get","preparePrfRequestOptions","optionsJSON","options","prfEval","extensions","eval","first","second","extractPasskeyPrfResult","credential","extensionResults","clientExtensionResults","results","output","id","outputBase64url","stripPrfResultsFromAssertion","undefined","getRegistrationPrfCapable","attestationResponse","enabled","staleStepUpResult","message","success","fresh","method","verifiedAt","expiresAt","maxAgeSeconds","staleStepUpPrfResult","buildAssertionStartInit","body","JSON","stringify","createSeamlessAuthClient","opts","fetchWithAuth","authHost","init","url","replace","startsWith","requestInit","headers","response","fetch","ok","console","warn","status","createFetchWithAuth","apiHost","getCurrentUser","login","loginWithPasskey","optionsInput","mfaRequired","json","startAuthentication","assertionResponse","verificationResponse","verificationResult","mfaLogin","Boolean","error","logout","scope","logoutAllSessions","deleteUser","register","email","phone","bootstrapToken","requestPhoneOtp","verifyPhoneOtp","verificationToken","requestLoginPhoneOtp","verifyLoginPhoneOtp","requestEmailOtp","verifyEmailOtp","requestLoginEmailOtp","verifyLoginEmailOtp","requestMagicLink","checkMagicLink","verifyMagicLink","token","listOAuthProviders","Error","startOAuthLogin","encodeURIComponent","providerId","redirectUri","returnTo","finishOAuthLogin","code","state","registerPasskey","registerInput","metadata","normalizeRegisterPasskeyInput","challengeRes","query","URLSearchParams","requirePrf","requestPrf","queryString","toString","buildRegisterStartPath","startRegistration","WebAuthnError","name","prfCapable","getStepUpStatus","verifyStepUpWithPasskey","verifyStepUpWithPasskeyPrf","updateCredential","deleteCredential","listOrganizations","createOrganization","getOrganization","organizationId","updateOrganization","switchOrganization","listOrganizationMembers","addOrganizationMember","updateOrganizationMember","userId","removeOrganizationMember","roleGrantsAccess","grantedRole","requiredRole","granted","trim","required","endsWith","prefix","slice","includes","grantedParts","split","requiredParts","grantedAction","length","requiredAction","grantedPrefix","requiredPrefix","every","part","index","hasScopedRole","grantedRoles","requiredRoles","Array","isArray","filter","role","some","AuthContext","createContext","useAuth","context","useContext","AuthProvider","children","autoDetectPreviousSignin","user","setUser","useState","setCredentials","organizations","setOrganizations","activeOrganization","setActiveOrganization","stepUpStatus","setStepUpStatus","isAuthenticated","setIsAuthenticated","loading","setLoading","hasSignedInBefore","markSignedIn","storageKey","setHasSignedInBefore","useEffect","localStorage","getItem","setItem","usePreviousSignIn","authClient","useMemo","resetAuthState","useCallback","validateToken","refreshStepUpStatus","result","_jsx","Provider","refreshSession","hasRole","roles","rolesGrantScopedAccess","friendlyName","responseBody","updatedCredential","currentCredentials","map","currentCredential","identifier","passkeyAvailable","handlePasskeyLogin","styleInject","css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","TermsModal","isOpen","onClose","modalRef","useRef","handleKeyDown","e","key","addEventListener","current","focus","removeEventListener","className","styles","_jsxs","tabIndex","onClick","href","countries","dialCode","flag","PhoneInputWithCountryCode","setPhone","phoneError","setPhoneError","showModal","setShowModal","selectedCountry","setSelectedCountry","defaultCountry","locale","Intl","DateTimeFormat","resolvedOptions","countryCode","toUpperCase","find","c","getDefaultCountry","onChange","country","target","stripped","newPhone","AsYouType","raw","full","formatted","onBlur","parsed","parsePhoneNumberFromString","isValid","autoComplete","placeholder","useAuthClient","isValidEmail","normalized","parts","localPart","domainPart","test","isValidPhoneNumber","phoneNumber","usePasskeySupport","passkeySupported","setPasskeySupported","active","supported","isUserVerifyingPlatformAuthenticatorAvailable","isPasskeySupported","checkSupport","AuthFallbackOptions","onMagicLink","onEmailOtp","onPhoneOtp","onPasskeyRetry","loginMethods","allowedMethods","Set","showMagicLink","has","showEmailOtp","showPhoneOtp","showPasskeyRetry","DEFAULT_LOGIN_METHODS","Login","navigate","useNavigate","setIdentifier","setEmail","mode","setMode","formErrors","setFormErrors","emailError","setEmailError","identifierError","setIdentifierError","showFallbackOptions","setShowFallbackOptions","setLoginMethods","setBootstrapToken","location","search","_Fragment","onSubmit","preventDefault","loginRes","loginStart","parseLoginStartResult","availableMethods","htmlFor","flow","disabled","PassKeyLogin","runPasskeyLogin","setError","container","card","title","button","DeviceNameModal","onCancel","onConfirm","setValue","autoFocus","PasskeyRegistration","passkeySupportLoading","setStatus","setMessage","showDeviceModal","setShowDeviceModal","pendingMetadata","setPendingMetadata","platform","browser","deviceInfo","ua","userAgent","toLowerCase","parseUserAgent","OtpInput","inputMode","inputs","values","concat","fill","handleChange","char","handleBulkInput","newValueArr","newValue","join","cleaned","chars","forEach","i","Math","min","onPaste","clipboardData","getData","el","maxLength","onKeyDown","PhoneRegistration","useLocation","isLoginFlow","phoneOtp","setPhoneOtp","phoneVerified","setPhoneVerified","resendMsg","setResendMsg","phoneTimeLeft","setPhoneTimeLeft","verifyPhoneOTP","handleResend","onResendPhone","interval","setInterval","prev","clearInterval","nextStep","verified","seconds","floor","padStart","EmailRegistration","emailOtp","setEmailOtp","emailTimeLeft","setEmailTimeLeft","VerifyMagicLink","searchParams","useSearchParams","successMsg","setSuccessMsg","mounted","channel","redirectTimeout","BroadcastChannel","postMessage","setTimeout","verify","close","clearTimeout","verificationContent","spinner","successIcon","viewBox","checkIcon","stroke","strokeWidth","d","helperText","successText","MagicLinkSent","cooldown","setCooldown","timer","onmessage","event","data","AuthRoutes","Routes","Route","path","element","Navigate","to"],"mappings":"ukBAmDA,SAASA,EAAcC,GACrB,GAAIA,aAAiBC,YACnB,OAAOD,EAGT,MAAME,EAAS,IAAIC,WAAWH,EAAMI,OAAQJ,EAAMK,WAAYL,EAAMM,YAC9DC,EAAO,IAAIJ,WAAWD,EAAOI,YAGnC,OAFAC,EAAKC,IAAIN,GAEFK,EAAKH,MACd,CAUM,SAAUK,EAAcC,GAC5B,MAAoB,iBAATA,EACFA,EAGFC,EAAwBZ,EAAcW,GAC/C,CAEA,SAASE,EAAmBF,GAC1B,MAAoB,iBAATA,EACFG,EAAwBH,GAG1BA,CACT,CAEM,SAAUI,EAAqBC,GACnC,MAAO,IACDA,EAAMC,aAAe,CAAEA,aAAcD,EAAMC,cAAiB,GAChEC,IAAK,CACHP,KAAMD,EAAcM,EAAML,SACtBK,EAAMG,WAAa,CAAEA,WAAYT,EAAcM,EAAMG,aAAgB,IAG/E,CAEOC,eAAeC,IACpB,QAAKC,OAIiB,oBAAXC,SAAqD,IAA3BA,OAAOC,wBAKA,IAAnCC,WAAWC,qBACG,oBAAdC,WAC+B,mBAA/BA,UAAUC,aAAaC,KAElC,CAEM,SAAUC,EACdC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UAAWC,GAAc5E,SAAA,CAC5BgC,EAAA,SAAA,CACE2C,UAAWC,GACXoG,SAAUyG,EAAW,EACrB1M,QAhFK5P,UACTsc,EAAW,UAEThQ,EAAW1G,mBAEjB2W,EAAY,MA2EW1R,SAAA,gBAKhByR,EAAW,GACV5M,EAAA,MAAA,CAAKF,UAAWC,GAAe5E,SAAA,CAAA,gBAAgByR,SAGjDzP,EAAA,SAAA,CAAQ2C,UAAWC,GAAmBG,QAAS,IAAMsE,EAAS,UAASrJ,SAAA,mCCxGpE+R,GAAa,IACxBlN,EAACmN,EAAM,CAAAhS,SAAA,CACLgC,EAACiQ,EAAK,CAACC,KAAK,SAASC,QAASnQ,EAACoH,GAAK,MACpCpH,EAACiQ,EAAK,CAACC,KAAK,gBAAgBC,QAASnQ,EAACiJ,GAAY,MAClDjJ,EAACiQ,EAAK,CAACC,KAAK,kBAAkBC,QAASnQ,EAACoM,GAAiB,CAAA,KACzDpM,EAACiQ,EAAK,CAACC,KAAK,kBAAkBC,QAASnQ,EAAC2N,GAAiB,CAAA,KACzD3N,EAACiQ,EAAK,CAACC,KAAK,oBAAoBC,QAASnQ,EAACgO,GAAe,CAAA,KACzDhO,EAACiQ,EAAK,CAACC,KAAK,mBAAmBC,QAASnQ,EAAC6J,GAAmB,CAAA,KAC5D7J,EAACiQ,EAAK,CAACC,KAAK,mBAAmBC,QAASnQ,EAACwP,GAAa,CAAA,KACtDxP,EAACiQ,EAAK,CAACC,KAAK,IAAIC,QAASnQ,EAACoQ,EAAQ,CAACC,GAAG,SAASha,SAAO","x_google_ignoreList":[6]}
@@ -0,0 +1,2 @@
1
+ export declare function roleGrantsAccess(grantedRole: string, requiredRole: string): boolean;
2
+ export declare function hasScopedRole(grantedRoles: unknown, requiredRoles: string | string[]): boolean;
package/dist/types.d.ts CHANGED
@@ -4,6 +4,28 @@ export interface User {
4
4
  email: string;
5
5
  phone: string;
6
6
  roles?: string[];
7
+ activeOrganizationId?: string | null;
8
+ }
9
+ export interface OrganizationMembership {
10
+ id: string;
11
+ organizationId: string;
12
+ userId: string;
13
+ roles: string[];
14
+ scopes: string[];
15
+ createdAt: string | Date;
16
+ updatedAt: string | Date;
17
+ user?: User;
18
+ }
19
+ export interface Organization {
20
+ id: string;
21
+ name: string;
22
+ slug: string;
23
+ createdByUserId: string | null;
24
+ metadata: Record<string, unknown> | null;
25
+ createdAt: string | Date;
26
+ updatedAt: string | Date;
27
+ membership?: OrganizationMembership;
28
+ memberCount?: number;
7
29
  }
8
30
  export interface Credential {
9
31
  id: string;
@@ -11,6 +33,8 @@ export interface Credential {
11
33
  transports?: AuthenticatorTransportFuture[];
12
34
  deviceType: CredentialDeviceType;
13
35
  backedup: boolean;
36
+ backedUp?: boolean;
37
+ prfCapable?: boolean;
14
38
  friendlyName: string | null;
15
39
  lastUsedAt: Date | null;
16
40
  platform: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamless-auth/react",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A drop-in authentication solution for modern React applications.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,6 +13,7 @@
13
13
  "files": [
14
14
  "dist",
15
15
  "README.md",
16
+ "CHANGELOG.md",
16
17
  "LICENSE"
17
18
  ],
18
19
  "engines": {
@@ -26,7 +27,9 @@
26
27
  "lint": "eslint ./src ./tests",
27
28
  "format": "prettier --write .",
28
29
  "prepare": "husky",
29
- "semantic-release": "semantic-release",
30
+ "changeset": "changeset",
31
+ "version-packages": "changeset version",
32
+ "release:stable": "npm run build && changeset publish",
30
33
  "check-npm-build": "npm pack --dry-run",
31
34
  "lint-staged": "lint-staged"
32
35
  },
@@ -49,12 +52,18 @@
49
52
  "url": "https://github.com/fells-code/seamless-auth-react/issues"
50
53
  },
51
54
  "homepage": "https://github.com/fells-code/seamless-auth-react#readme",
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "registry": "https://registry.npmjs.org/",
58
+ "provenance": true
59
+ },
52
60
  "peerDependencies": {
53
61
  "react": "^18.0.0 || ^19.0.0",
54
62
  "react-dom": "^18.0.0 || ^19.0.0",
55
63
  "react-router-dom": "^6.4.0 || ^7.0.0"
56
64
  },
57
65
  "devDependencies": {
66
+ "@changesets/cli": "^2.31.0",
58
67
  "@commitlint/cli": "^20.1.0",
59
68
  "@commitlint/config-conventional": "^20.0.0",
60
69
  "@eslint/js": "^9.17.0",