@robelest/convex-auth 0.0.4-preview.30 → 0.0.4-preview.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +125 -36
- package/dist/browser/index.d.ts +3 -13
- package/dist/browser/index.js +47 -12
- package/dist/browser/navigation.js +1 -1
- package/dist/browser/passkey.js +7 -7
- package/dist/browser/runtime.js +13 -15
- package/dist/client/core/types.d.ts +179 -63
- package/dist/client/core/types.js +6 -0
- package/dist/client/factors/totp.js +1 -1
- package/dist/client/index.d.ts +5 -4
- package/dist/client/index.js +115 -56
- package/dist/client/runtime/mutex.js +3 -2
- package/dist/component/_generated/component.d.ts +40 -0
- package/dist/component/convex.config.d.ts +2 -2
- package/dist/component/http.js +9 -0
- package/dist/component/index.d.ts +1 -1
- package/dist/component/model.d.ts +25 -25
- package/dist/component/model.js +2 -1
- package/dist/component/modules.js +1 -0
- package/dist/component/public/factors/passkeys.js +31 -1
- package/dist/component/public/identity/codes.js +1 -1
- package/dist/component/public/identity/tokens.js +2 -1
- package/dist/component/public/identity/verifiers.js +15 -5
- package/dist/component/public.js +2 -2
- package/dist/component/schema.d.ts +292 -290
- package/dist/component/schema.js +2 -1
- package/dist/core/index.d.ts +8 -3
- package/dist/core/index.js +7 -2
- package/dist/expo/index.d.ts +21 -0
- package/dist/expo/index.js +148 -0
- package/dist/expo/passkey.js +174 -0
- package/dist/providers/apple.d.ts +1 -1
- package/dist/providers/apple.js +6 -8
- package/dist/providers/custom.d.ts +1 -1
- package/dist/providers/custom.js +4 -7
- package/dist/providers/github.d.ts +1 -1
- package/dist/providers/github.js +5 -8
- package/dist/providers/google.d.ts +1 -1
- package/dist/providers/google.js +5 -8
- package/dist/providers/microsoft.d.ts +1 -1
- package/dist/providers/microsoft.js +5 -9
- package/dist/providers/password.d.ts +18 -37
- package/dist/providers/password.js +170 -115
- package/dist/providers/redirect.d.ts +1 -0
- package/dist/providers/redirect.js +20 -0
- package/dist/server/auth.d.ts +6 -7
- package/dist/server/auth.js +3 -2
- package/dist/server/{ctxCache.js → cache/context.js} +2 -2
- package/dist/server/{componentContext.d.ts → component/context.d.ts} +2 -2
- package/dist/server/context.js +3 -10
- package/dist/server/contract.d.ts +2 -87
- package/dist/server/contract.js +1 -1
- package/dist/server/cookies.js +25 -1
- package/dist/server/core.js +1 -1
- package/dist/server/errors.js +24 -1
- package/dist/server/{auth-context.d.ts → facade.d.ts} +3 -45
- package/dist/server/{auth-context.js → facade.js} +11 -12
- package/dist/server/http.d.ts +7 -7
- package/dist/server/http.js +36 -7
- package/dist/server/{convexIdentity.d.ts → identity/convex.d.ts} +3 -3
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +3 -2
- package/dist/server/mounts.d.ts +175 -22
- package/dist/server/mutations/code.js +7 -1
- package/dist/server/mutations/{credentialsSignIn.js → credentials/signin.js} +10 -10
- package/dist/server/mutations/index.js +1 -1
- package/dist/server/mutations/invalidate.js +11 -1
- package/dist/server/mutations/oauth.js +25 -27
- package/dist/server/mutations/signin.js +6 -0
- package/dist/server/mutations/signout.js +5 -0
- package/dist/server/mutations/store.js +1 -1
- package/dist/server/oauth/factory.js +11 -3
- package/dist/server/passkey.js +126 -110
- package/dist/server/prefetch.js +8 -1
- package/dist/server/redirects.js +11 -3
- package/dist/server/refresh.js +6 -1
- package/dist/server/runtime.d.ts +58 -36
- package/dist/server/runtime.js +333 -36
- package/dist/server/services/group.js +4 -0
- package/dist/server/sessions.js +1 -0
- package/dist/server/signin.js +8 -6
- package/dist/server/sso/domain.d.ts +159 -16
- package/dist/server/sso/domain.js +1 -1
- package/dist/server/sso/http.js +144 -60
- package/dist/server/sso/oidc.js +28 -12
- package/dist/server/sso/policy.js +30 -14
- package/dist/server/sso/provision.js +1 -1
- package/dist/server/sso/saml.js +18 -9
- package/dist/server/sso/scim.js +12 -4
- package/dist/server/sso/shared.js +5 -5
- package/dist/server/telemetry.js +3 -0
- package/dist/server/tokens.js +10 -2
- package/dist/server/totp.js +127 -100
- package/dist/server/types.d.ts +224 -151
- package/dist/server/url.js +1 -1
- package/dist/server/users.js +93 -53
- package/dist/server/wellknown.d.ts +130 -0
- package/dist/server/wellknown.js +195 -0
- package/dist/shared/errors.js +0 -1
- package/package.json +36 -4
- package/dist/server/oauth/index.js +0 -12
- package/dist/server/utils/dispatch.js +0 -36
- package/dist/shared/authResults.d.ts +0 -16
- /package/dist/server/{componentContext.js → component/context.js} +0 -0
- /package/dist/server/{convexIdentity.js → identity/convex.js} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConvexError, Value } from "convex/values";
|
|
1
|
+
import { Value } from "convex/values";
|
|
3
2
|
import { FunctionReference } from "convex/server";
|
|
4
3
|
|
|
5
4
|
//#region src/client/core/types.d.ts
|
|
@@ -23,9 +22,6 @@ interface ConvexTransport {
|
|
|
23
22
|
interface ActionTransport {
|
|
24
23
|
action(action: unknown, args: unknown): Promise<unknown>;
|
|
25
24
|
}
|
|
26
|
-
type SignInApiRef = {
|
|
27
|
-
signIn: AuthApiRefs["signIn"];
|
|
28
|
-
};
|
|
29
25
|
/** Pluggable key-value storage supplied by the host runtime. */
|
|
30
26
|
interface Storage {
|
|
31
27
|
getItem(key: string): string | null | undefined | Promise<string | null | undefined>;
|
|
@@ -36,7 +32,10 @@ interface Storage {
|
|
|
36
32
|
interface LocationRuntime {
|
|
37
33
|
get(): URL | null;
|
|
38
34
|
replace(relativeUrl: string): void | Promise<void>;
|
|
39
|
-
|
|
35
|
+
}
|
|
36
|
+
/** Platform-specific OAuth launch primitive. */
|
|
37
|
+
interface OAuthRuntime {
|
|
38
|
+
open(url: URL): void | Promise<void>;
|
|
40
39
|
}
|
|
41
40
|
/** Cross-context synchronization hooks, such as browser storage events. */
|
|
42
41
|
interface SyncRuntime {
|
|
@@ -60,6 +59,7 @@ interface ClientRuntime {
|
|
|
60
59
|
environment?: "client" | "server";
|
|
61
60
|
storage?: Storage | null;
|
|
62
61
|
location?: LocationRuntime;
|
|
62
|
+
oauth?: OAuthRuntime;
|
|
63
63
|
sync?: SyncRuntime;
|
|
64
64
|
mutex?: MutexRuntime;
|
|
65
65
|
proxy?: ProxyRuntime;
|
|
@@ -70,41 +70,17 @@ interface ClientAdapters {
|
|
|
70
70
|
totp?: TotpClient;
|
|
71
71
|
device?: DeviceClient;
|
|
72
72
|
}
|
|
73
|
-
interface ClientAdapterDeps {
|
|
74
|
-
proxy: string | undefined;
|
|
75
|
-
convex: ConvexTransport;
|
|
76
|
-
requireApiRefs: () => SignInApiRef;
|
|
77
|
-
proxyFetch: (body: Record<string, unknown>) => Promise<unknown>;
|
|
78
|
-
setTokenAndMaybeWait: (args: {
|
|
79
|
-
shouldStore: true;
|
|
80
|
-
tokens: AuthTokens | null;
|
|
81
|
-
waitForHandshake: boolean;
|
|
82
|
-
context: {
|
|
83
|
-
provider?: string;
|
|
84
|
-
flow: string;
|
|
85
|
-
};
|
|
86
|
-
} | {
|
|
87
|
-
shouldStore: false;
|
|
88
|
-
tokens: {
|
|
89
|
-
token: string;
|
|
90
|
-
} | null;
|
|
91
|
-
waitForHandshake: boolean;
|
|
92
|
-
context: {
|
|
93
|
-
provider?: string;
|
|
94
|
-
flow: string;
|
|
95
|
-
};
|
|
96
|
-
}) => Promise<boolean>;
|
|
97
|
-
}
|
|
98
|
-
interface ClientAdapterFactories {
|
|
99
|
-
passkey?: (deps: ClientAdapterDeps) => PasskeyClient;
|
|
100
|
-
}
|
|
101
|
-
type DeviceCodeResult = DeviceCodePayload;
|
|
102
73
|
/**
|
|
103
|
-
* Device
|
|
104
|
-
*
|
|
105
|
-
* The device displays the `userCode` (or `verificationUriComplete`) and
|
|
106
|
-
* polls via `auth.device.poll()` until the user authorizes.
|
|
74
|
+
* Device authorization payload returned from the `deviceCode` sign-in flow.
|
|
107
75
|
*/
|
|
76
|
+
type DeviceCodeResult = {
|
|
77
|
+
deviceCode: string;
|
|
78
|
+
userCode: string;
|
|
79
|
+
verificationUri: string;
|
|
80
|
+
verificationUriComplete: string;
|
|
81
|
+
expiresIn: number;
|
|
82
|
+
interval: number;
|
|
83
|
+
};
|
|
108
84
|
/**
|
|
109
85
|
* Result of a `signIn` call.
|
|
110
86
|
*
|
|
@@ -154,6 +130,22 @@ type AuthApiRefs<HasPasskey extends boolean = boolean, HasTotp extends boolean =
|
|
|
154
130
|
signIn: FunctionReference<"action", "public", Record<string, Value>, unknown>;
|
|
155
131
|
signOut: FunctionReference<"action", "public", Record<string, Value>, unknown>;
|
|
156
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Optional hints for {@link PasskeyClient.register}.
|
|
135
|
+
*/
|
|
136
|
+
type PasskeyRegisterOptions = {
|
|
137
|
+
/** Human-readable label for this credential (e.g. `"MacBook Pro"`). */name?: string; /** Email hint stored with the credential. */
|
|
138
|
+
email?: string; /** WebAuthn `user.name` override. */
|
|
139
|
+
userName?: string; /** WebAuthn `user.displayName` override. */
|
|
140
|
+
userDisplayName?: string;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Optional hints for {@link PasskeyClient.signIn}.
|
|
144
|
+
*/
|
|
145
|
+
type PasskeySignInOptions = {
|
|
146
|
+
/** Email hint to filter discoverable credentials. */email?: string; /** Set to `true` for conditional UI (autofill) mode. */
|
|
147
|
+
autofill?: boolean;
|
|
148
|
+
};
|
|
157
149
|
/**
|
|
158
150
|
* Passkey (WebAuthn) client-side helpers.
|
|
159
151
|
*
|
|
@@ -182,7 +174,7 @@ interface PasskeyClient {
|
|
|
182
174
|
* @example
|
|
183
175
|
* ```ts
|
|
184
176
|
* if (await auth.passkey.isAutofillSupported()) {
|
|
185
|
-
* await auth.passkey.
|
|
177
|
+
* await auth.passkey.signIn({ autofill: true });
|
|
186
178
|
* }
|
|
187
179
|
* ```
|
|
188
180
|
*/
|
|
@@ -197,29 +189,54 @@ interface PasskeyClient {
|
|
|
197
189
|
* @param opts.email - Email hint for discoverable credentials.
|
|
198
190
|
* @param opts.userName - WebAuthn `user.name` override.
|
|
199
191
|
* @param opts.userDisplayName - WebAuthn `user.displayName` override.
|
|
200
|
-
|
|
192
|
+
* @returns A {@link SignInResult} — typically `{ kind: "signedIn" }` once a client session is available.
|
|
201
193
|
*
|
|
202
194
|
* @example
|
|
203
195
|
* ```ts
|
|
204
196
|
* const result = await auth.passkey.register({ name: "My laptop" });
|
|
205
197
|
* ```
|
|
206
198
|
*/
|
|
207
|
-
register(opts?:
|
|
199
|
+
register(opts?: PasskeyRegisterOptions): Promise<SignInResult>;
|
|
208
200
|
/**
|
|
209
|
-
*
|
|
201
|
+
* Sign in with an existing passkey and complete the WebAuthn ceremony.
|
|
210
202
|
*
|
|
211
|
-
* @param opts - Optional
|
|
203
|
+
* @param opts - Optional sign-in hints.
|
|
212
204
|
* @param opts.email - Email hint to filter discoverable credentials.
|
|
213
205
|
* @param opts.autofill - Set to `true` for conditional UI (autofill) mode.
|
|
214
|
-
* @returns A {@link SignInResult} — typically `{ kind: "signedIn" }`
|
|
206
|
+
* @returns A {@link SignInResult} — typically `{ kind: "signedIn" }` once a client session is available.
|
|
215
207
|
*
|
|
216
208
|
* @example
|
|
217
209
|
* ```ts
|
|
218
|
-
* const result = await auth.passkey.
|
|
210
|
+
* const result = await auth.passkey.signIn();
|
|
219
211
|
* ```
|
|
220
212
|
*/
|
|
221
|
-
|
|
213
|
+
signIn(opts?: PasskeySignInOptions): Promise<SignInResult>;
|
|
222
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Optional hints for {@link TotpClient.setup}.
|
|
217
|
+
*/
|
|
218
|
+
type TotpSetupOptions = {
|
|
219
|
+
/** Issuer name shown in the authenticator app. */name?: string; /** Account label shown in the authenticator app. */
|
|
220
|
+
accountName?: string;
|
|
221
|
+
};
|
|
222
|
+
/** Result of {@link TotpClient.setup}. */
|
|
223
|
+
type TotpSetupResult = {
|
|
224
|
+
/** `otpauth://` URL — render as a QR code. */uri: string; /** Raw base32-encoded shared secret. */
|
|
225
|
+
secret: string; /** Verifier token to pass to {@link TotpClient.confirm}. */
|
|
226
|
+
verifier: string; /** Factor ID to pass to {@link TotpClient.confirm}. */
|
|
227
|
+
totpId: string;
|
|
228
|
+
};
|
|
229
|
+
/** Params for {@link TotpClient.confirm}. */
|
|
230
|
+
type TotpConfirmParams = {
|
|
231
|
+
/** Six-digit OTP from the authenticator app. */code: string; /** Verifier token from {@link TotpSetupResult.verifier}. */
|
|
232
|
+
verifier: string; /** Factor ID from {@link TotpSetupResult.totpId}. */
|
|
233
|
+
totpId: string;
|
|
234
|
+
};
|
|
235
|
+
/** Params for {@link TotpClient.verify}. */
|
|
236
|
+
type TotpVerifyParams = {
|
|
237
|
+
/** Six-digit OTP from the authenticator app. */code: string; /** Verifier token from a `totpRequired` sign-in result. */
|
|
238
|
+
verifier: string;
|
|
239
|
+
};
|
|
223
240
|
/**
|
|
224
241
|
* TOTP two-factor authentication client-side helpers.
|
|
225
242
|
*
|
|
@@ -245,7 +262,7 @@ interface TotpClient {
|
|
|
245
262
|
* await auth.totp.confirm({ code: userCode, verifier, totpId });
|
|
246
263
|
* ```
|
|
247
264
|
*/
|
|
248
|
-
setup(opts?:
|
|
265
|
+
setup(opts?: TotpSetupOptions): Promise<TotpSetupResult>;
|
|
249
266
|
/**
|
|
250
267
|
* Confirm a newly created TOTP factor with the first authenticator code.
|
|
251
268
|
*
|
|
@@ -261,7 +278,7 @@ interface TotpClient {
|
|
|
261
278
|
* await auth.totp.confirm({ code: "123456", verifier, totpId });
|
|
262
279
|
* ```
|
|
263
280
|
*/
|
|
264
|
-
confirm(opts:
|
|
281
|
+
confirm(opts: TotpConfirmParams): Promise<void>;
|
|
265
282
|
/**
|
|
266
283
|
* Complete a sign-in that is waiting on TOTP verification.
|
|
267
284
|
*
|
|
@@ -279,8 +296,16 @@ interface TotpClient {
|
|
|
279
296
|
* }
|
|
280
297
|
* ```
|
|
281
298
|
*/
|
|
282
|
-
verify(opts:
|
|
299
|
+
verify(opts: TotpVerifyParams): Promise<void>;
|
|
283
300
|
}
|
|
301
|
+
/** Params for {@link DeviceClient.poll}. */
|
|
302
|
+
type DevicePollParams = {
|
|
303
|
+
code: DeviceCodeResult;
|
|
304
|
+
};
|
|
305
|
+
/** Params for {@link DeviceClient.verify}. */
|
|
306
|
+
type DeviceVerifyParams = {
|
|
307
|
+
code: string;
|
|
308
|
+
};
|
|
284
309
|
/**
|
|
285
310
|
* Device authorization (RFC 8628) client-side helpers.
|
|
286
311
|
*
|
|
@@ -308,9 +333,7 @@ interface DeviceClient {
|
|
|
308
333
|
* }
|
|
309
334
|
* ```
|
|
310
335
|
*/
|
|
311
|
-
poll(opts:
|
|
312
|
-
code: DeviceCodeResult;
|
|
313
|
-
}): Promise<void>;
|
|
336
|
+
poll(opts: DevicePollParams): Promise<void>;
|
|
314
337
|
/**
|
|
315
338
|
* Approve a device flow from the verification page using the displayed user code.
|
|
316
339
|
*
|
|
@@ -326,9 +349,7 @@ interface DeviceClient {
|
|
|
326
349
|
* await auth.device.verify({ code: "WDJB-MJHT" });
|
|
327
350
|
* ```
|
|
328
351
|
*/
|
|
329
|
-
verify(opts:
|
|
330
|
-
code: string;
|
|
331
|
-
}): Promise<void>;
|
|
352
|
+
verify(opts: DeviceVerifyParams): Promise<void>;
|
|
332
353
|
}
|
|
333
354
|
/**
|
|
334
355
|
* Extract capability flags from an AuthApiRefs type.
|
|
@@ -366,6 +387,88 @@ interface PendingInvite {
|
|
|
366
387
|
token: string;
|
|
367
388
|
}>;
|
|
368
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Discriminated union of params for the password provider's flows.
|
|
392
|
+
*
|
|
393
|
+
* Each branch maps to one of the five password flows: `signUp`, `signIn`,
|
|
394
|
+
* `reset`, `verify`, `change`. Selecting a `flow` literal narrows the
|
|
395
|
+
* accepted params automatically.
|
|
396
|
+
*/
|
|
397
|
+
type PasswordParams = {
|
|
398
|
+
flow: "signUp";
|
|
399
|
+
email: string;
|
|
400
|
+
password: string;
|
|
401
|
+
redirectTo?: string;
|
|
402
|
+
} | {
|
|
403
|
+
flow: "signIn";
|
|
404
|
+
email: string;
|
|
405
|
+
password: string;
|
|
406
|
+
redirectTo?: string;
|
|
407
|
+
} | {
|
|
408
|
+
flow: "reset";
|
|
409
|
+
email: string;
|
|
410
|
+
redirectTo?: string;
|
|
411
|
+
} | {
|
|
412
|
+
flow: "verify";
|
|
413
|
+
email: string;
|
|
414
|
+
code: string; /** When set, completes a `reset` flow by updating the password. Otherwise confirms email. */
|
|
415
|
+
newPassword?: string;
|
|
416
|
+
redirectTo?: string;
|
|
417
|
+
} | {
|
|
418
|
+
flow: "change";
|
|
419
|
+
email: string;
|
|
420
|
+
currentPassword: string;
|
|
421
|
+
newPassword: string;
|
|
422
|
+
redirectTo?: string;
|
|
423
|
+
};
|
|
424
|
+
/** Params for the email (magic link) provider's initiation step. */
|
|
425
|
+
type EmailInitiateParams = {
|
|
426
|
+
email: string;
|
|
427
|
+
redirectTo?: string;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Params for completing a code-based flow (no provider). Used to finalise
|
|
431
|
+
* email magic-link sign-ins and password-reset OTPs when the verification
|
|
432
|
+
* call is made without re-specifying the originating provider.
|
|
433
|
+
*/
|
|
434
|
+
type CodeCompletionParams = {
|
|
435
|
+
code: string;
|
|
436
|
+
redirectTo?: string;
|
|
437
|
+
};
|
|
438
|
+
/** Params for the `sso` provider — requires a connection ID. */
|
|
439
|
+
type SsoParams = {
|
|
440
|
+
connectionId: string;
|
|
441
|
+
redirectTo?: string;
|
|
442
|
+
};
|
|
443
|
+
/** Params for the anonymous provider. Empty / `redirectTo` only. */
|
|
444
|
+
type AnonymousParams = {
|
|
445
|
+
redirectTo?: string;
|
|
446
|
+
};
|
|
447
|
+
/** Default params shape for OAuth-style providers (google, github, etc.). */
|
|
448
|
+
type OAuthSignInParams = {
|
|
449
|
+
redirectTo?: string;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Params for `signIn("passkey", ...)`. Direct passkey flows are typically
|
|
453
|
+
* triggered through `auth.passkey.register()` / `auth.passkey.signIn()`
|
|
454
|
+
* — this overload is for advanced callers that bypass the helper.
|
|
455
|
+
*/
|
|
456
|
+
type PasskeySignInParams = {
|
|
457
|
+
redirectTo?: string;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Public signature for `auth.signIn`. The provider literal discriminates the
|
|
461
|
+
* params shape via {@link ParamsForProvider}, and the params slot is
|
|
462
|
+
* automatically optional when the resolved type permits `undefined`.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```ts
|
|
466
|
+
* auth.signIn("password", { flow: "signIn", email, password });
|
|
467
|
+
* auth.signIn("password", { flow: "change", email, currentPassword, newPassword });
|
|
468
|
+
* auth.signIn("anonymous"); // params optional
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
type SignInOverloads = <P extends string | undefined>(provider: P, ...args: SignInArgs<P>) => Promise<SignInResult>;
|
|
369
472
|
/** Base auth client — always present. */
|
|
370
473
|
interface AuthClientBase {
|
|
371
474
|
/**
|
|
@@ -373,6 +476,8 @@ interface AuthClientBase {
|
|
|
373
476
|
* @readonly
|
|
374
477
|
*/
|
|
375
478
|
readonly state: AuthState;
|
|
479
|
+
/** Restore initial auth state for the current runtime. */
|
|
480
|
+
initialize: () => Promise<void>;
|
|
376
481
|
/** SSR-safe query-param reader. */
|
|
377
482
|
param: (name: string) => string | null;
|
|
378
483
|
/**
|
|
@@ -380,8 +485,12 @@ interface AuthClientBase {
|
|
|
380
485
|
* @readonly
|
|
381
486
|
*/
|
|
382
487
|
readonly invite: PendingInvite | null;
|
|
488
|
+
/** Complete an OAuth callback using a URL or authorization code. */
|
|
489
|
+
completeOAuth: (input: URL | string | {
|
|
490
|
+
code: string;
|
|
491
|
+
}) => Promise<OAuthCompletionResult>;
|
|
383
492
|
/** Start a sign-in flow for a provider. */
|
|
384
|
-
signIn:
|
|
493
|
+
signIn: SignInOverloads;
|
|
385
494
|
/** Sign out and clear local auth state. */
|
|
386
495
|
signOut: () => Promise<void>;
|
|
387
496
|
/** Subscribe to auth state changes. Returns an unsubscribe function. */
|
|
@@ -393,8 +502,8 @@ interface AuthClientBase {
|
|
|
393
502
|
* Framework-agnostic auth client return type.
|
|
394
503
|
*
|
|
395
504
|
* Conditionally includes `totp` and `device` helpers based on the
|
|
396
|
-
* capabilities in the `AuthApiRefs` type.
|
|
397
|
-
* added by {@link
|
|
505
|
+
* capabilities in the `AuthApiRefs` type. Platform-specific `passkey` helpers
|
|
506
|
+
* are added by {@link PlatformAuthClient}.
|
|
398
507
|
*
|
|
399
508
|
* @typeParam Api - An AuthApiRefs type that determines which factor helpers are included.
|
|
400
509
|
*/
|
|
@@ -411,9 +520,11 @@ type AuthClient<Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiRefs
|
|
|
411
520
|
*
|
|
412
521
|
* @typeParam Api - An AuthApiRefs type that determines which factor helpers are included.
|
|
413
522
|
*/
|
|
414
|
-
type
|
|
523
|
+
type PlatformAuthClient<Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiRefs> = AuthClient<Api> & (InferCaps<Api>["passkey"] extends true ? {
|
|
415
524
|
passkey: PasskeyClient;
|
|
416
525
|
} : {});
|
|
526
|
+
/** @deprecated Use `PlatformAuthClient`. */
|
|
527
|
+
type BrowserAuthClient<Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiRefs> = PlatformAuthClient<Api>;
|
|
417
528
|
/**
|
|
418
529
|
* Options for {@link client}.
|
|
419
530
|
*
|
|
@@ -440,8 +551,7 @@ type ClientOptions<Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiR
|
|
|
440
551
|
*
|
|
441
552
|
* Defaults to `runtime.storage` when provided, otherwise `null`.
|
|
442
553
|
*/
|
|
443
|
-
storage?: Storage | null;
|
|
444
|
-
replaceUrl?: (relativeUrl: string) => void | Promise<void>;
|
|
554
|
+
storage?: Storage | null;
|
|
445
555
|
/**
|
|
446
556
|
* Proxy endpoint used instead of direct Convex auth calls.
|
|
447
557
|
* When set, provide `runtime.proxy` and omit direct `api`/`httpClient`
|
|
@@ -451,6 +561,12 @@ type ClientOptions<Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiR
|
|
|
451
561
|
tokenSeed?: string | null; /** SSR-safe URL source for reading query parameters. */
|
|
452
562
|
location?: URL | (() => URL | null);
|
|
453
563
|
};
|
|
564
|
+
type OAuthCompletionResult = {
|
|
565
|
+
handled: false;
|
|
566
|
+
} | {
|
|
567
|
+
handled: true;
|
|
568
|
+
cleanupUrl: URL | null;
|
|
569
|
+
};
|
|
454
570
|
//#endregion
|
|
455
|
-
export { AuthApiRefs, AuthClient, AuthState, BrowserAuthClient, ClientOptions, ClientRuntime, DeviceClient, DeviceCodeResult, PasskeyClient, PendingInvite, SignInResult, Storage, TotpClient };
|
|
571
|
+
export { AnonymousParams, AuthApiRefs, AuthClient, AuthState, BrowserAuthClient, ClientOptions, ClientRuntime, CodeCompletionParams, DeviceClient, DeviceCodeResult, DevicePollParams, DeviceVerifyParams, EmailInitiateParams, OAuthCompletionResult, OAuthSignInParams, PasskeyClient, PasskeyRegisterOptions, PasskeySignInOptions, PasskeySignInParams, PasswordParams, PendingInvite, PlatformAuthClient, SignInOverloads, SignInResult, SsoParams, Storage, TotpClient, TotpConfirmParams, TotpSetupOptions, TotpSetupResult, TotpVerifyParams };
|
|
456
572
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
//#region src/client/core/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Create a deferred promise that can be resolved or rejected externally.
|
|
4
|
+
*
|
|
5
|
+
* @returns A deferred object containing the promise and control methods.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
2
8
|
function createDeferred() {
|
|
3
9
|
let resolve;
|
|
4
10
|
let reject;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { AuthApiRefs, AuthClient, AuthState, BrowserAuthClient, ClientOptions, ClientRuntime, DeviceClient, DeviceCodeResult, PasskeyClient, PendingInvite, SignInResult, Storage, TotpClient } from "./core/types.js";
|
|
1
|
+
import { AnonymousParams, AuthApiRefs, AuthClient, AuthState, BrowserAuthClient, ClientOptions, ClientRuntime, CodeCompletionParams, DeviceClient, DeviceCodeResult, DevicePollParams, DeviceVerifyParams, EmailInitiateParams, OAuthCompletionResult, OAuthSignInParams, PasskeyClient, PasskeyRegisterOptions, PasskeySignInOptions, PasskeySignInParams, PasswordParams, PendingInvite, PlatformAuthClient, SignInOverloads, SignInResult, SsoParams, Storage, TotpClient, TotpConfirmParams, TotpSetupOptions, TotpSetupResult, TotpVerifyParams } from "./core/types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/client/index.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Create a framework-agnostic auth client.
|
|
6
6
|
*
|
|
7
7
|
* Returns an object with `signIn`, `signOut`, `onChange`, `state`, and any
|
|
8
|
-
* factor helpers enabled by your configured providers.
|
|
9
|
-
* passkey support is added by
|
|
8
|
+
* factor helpers enabled by your configured providers. Platform-specific
|
|
9
|
+
* passkey support is added by higher-level entrypoints such as
|
|
10
|
+
* `@robelest/convex-auth/browser`.
|
|
10
11
|
*
|
|
11
12
|
* ### SPA mode (default)
|
|
12
13
|
*
|
|
@@ -43,5 +44,5 @@ import { AuthApiRefs, AuthClient, AuthState, BrowserAuthClient, ClientOptions, C
|
|
|
43
44
|
*/
|
|
44
45
|
declare function client<Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiRefs>(options: ClientOptions<Api>): AuthClient<Api>;
|
|
45
46
|
//#endregion
|
|
46
|
-
export { type AuthApiRefs, type AuthClient, type AuthState, type BrowserAuthClient, type ClientOptions, type ClientRuntime, type DeviceClient, type DeviceCodeResult, type PasskeyClient, type PendingInvite, type SignInResult, type Storage, type TotpClient, client };
|
|
47
|
+
export { type AnonymousParams, type AuthApiRefs, type AuthClient, type AuthState, type BrowserAuthClient, type ClientOptions, type ClientRuntime, type CodeCompletionParams, type DeviceClient, type DeviceCodeResult, type DevicePollParams, type DeviceVerifyParams, type EmailInitiateParams, type OAuthCompletionResult, type OAuthSignInParams, type PasskeyClient, type PasskeyRegisterOptions, type PasskeySignInOptions, type PasskeySignInParams, type PasswordParams, type PendingInvite, type PlatformAuthClient, type SignInOverloads, type SignInResult, type SsoParams, type Storage, type TotpClient, type TotpConfirmParams, type TotpSetupOptions, type TotpSetupResult, type TotpVerifyParams, client };
|
|
47
48
|
//# sourceMappingURL=index.d.ts.map
|