@robelest/convex-auth 0.0.4-preview.13 → 0.0.4-preview.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -9
- package/dist/bin.cjs +5957 -5478
- package/dist/client/index.d.ts +3 -7
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +27 -26
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +14 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +1672 -24
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/convex.config.d.ts +2 -2
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/index.d.ts +1 -1
- package/dist/component/index.js +2 -2
- package/dist/component/model.d.ts +153 -0
- package/dist/component/model.d.ts.map +1 -0
- package/dist/component/model.js +343 -0
- package/dist/component/model.js.map +1 -0
- package/dist/component/providers/sso.d.ts +1 -1
- package/dist/component/public/enterprise.d.ts +54 -0
- package/dist/component/public/enterprise.d.ts.map +1 -0
- package/dist/component/public/enterprise.js +515 -0
- package/dist/component/public/enterprise.js.map +1 -0
- package/dist/component/public/factors.d.ts +52 -0
- package/dist/component/public/factors.d.ts.map +1 -0
- package/dist/component/public/factors.js +285 -0
- package/dist/component/public/factors.js.map +1 -0
- package/dist/component/public/groups.d.ts +116 -0
- package/dist/component/public/groups.d.ts.map +1 -0
- package/dist/component/public/groups.js +596 -0
- package/dist/component/public/groups.js.map +1 -0
- package/dist/component/public/identity.d.ts +93 -0
- package/dist/component/public/identity.d.ts.map +1 -0
- package/dist/component/public/identity.js +426 -0
- package/dist/component/public/identity.js.map +1 -0
- package/dist/component/public/keys.d.ts +41 -0
- package/dist/component/public/keys.d.ts.map +1 -0
- package/dist/component/public/keys.js +157 -0
- package/dist/component/public/keys.js.map +1 -0
- package/dist/component/public/shared.d.ts +26 -0
- package/dist/component/public/shared.d.ts.map +1 -0
- package/dist/component/public/shared.js +32 -0
- package/dist/component/public/shared.js.map +1 -0
- package/dist/component/public.d.ts +9 -321
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +6 -2145
- package/dist/component/schema.d.ts +406 -260
- package/dist/component/schema.js +37 -32
- package/dist/component/schema.js.map +1 -1
- package/dist/component/server/auth.d.ts +161 -15
- package/dist/component/server/auth.d.ts.map +1 -1
- package/dist/component/server/auth.js +100 -7
- package/dist/component/server/auth.js.map +1 -1
- package/dist/component/server/cookies.js +3 -0
- package/dist/component/server/cookies.js.map +1 -1
- package/dist/component/server/db.js +1 -0
- package/dist/component/server/db.js.map +1 -1
- package/dist/component/server/device.js +3 -1
- package/dist/component/server/device.js.map +1 -1
- package/dist/component/server/domains/core.js +629 -0
- package/dist/component/server/domains/core.js.map +1 -0
- package/dist/component/server/domains/sso.js +884 -0
- package/dist/component/server/domains/sso.js.map +1 -0
- package/dist/component/server/factory.d.ts +136 -0
- package/dist/component/server/factory.d.ts.map +1 -0
- package/dist/component/server/factory.js +1134 -0
- package/dist/component/server/factory.js.map +1 -0
- package/dist/component/server/fx.js +2 -1
- package/dist/component/server/fx.js.map +1 -1
- package/dist/component/server/http.js +287 -0
- package/dist/component/server/http.js.map +1 -0
- package/dist/component/server/identity.js +13 -0
- package/dist/component/server/identity.js.map +1 -0
- package/dist/component/server/keys.js +4 -0
- package/dist/component/server/keys.js.map +1 -1
- package/dist/component/server/mutations/account.js +1 -1
- package/dist/component/server/mutations/index.js +2 -2
- package/dist/component/server/mutations/index.js.map +1 -1
- package/dist/component/server/mutations/invalidate.js +1 -1
- package/dist/component/server/mutations/oauth.js +10 -7
- package/dist/component/server/mutations/oauth.js.map +1 -1
- package/dist/component/server/mutations/refresh.js +1 -1
- package/dist/component/server/mutations/register.js +1 -1
- package/dist/component/server/mutations/retrieve.js +1 -1
- package/dist/component/server/mutations/signature.js +1 -1
- package/dist/component/server/mutations/store.js +6 -3
- package/dist/component/server/mutations/store.js.map +1 -1
- package/dist/component/server/mutations/verify.js +1 -1
- package/dist/component/server/oauth.js +3 -0
- package/dist/component/server/oauth.js.map +1 -1
- package/dist/component/server/passkey.js +3 -2
- package/dist/component/server/passkey.js.map +1 -1
- package/dist/component/server/provider.js +2 -0
- package/dist/component/server/provider.js.map +1 -1
- package/dist/component/server/providers.js +10 -0
- package/dist/component/server/providers.js.map +1 -1
- package/dist/component/server/ratelimit.js +3 -0
- package/dist/component/server/ratelimit.js.map +1 -1
- package/dist/component/server/redirects.js +2 -0
- package/dist/component/server/redirects.js.map +1 -1
- package/dist/component/server/refresh.js +5 -0
- package/dist/component/server/refresh.js.map +1 -1
- package/dist/component/server/sessions.js +5 -0
- package/dist/component/server/sessions.js.map +1 -1
- package/dist/component/server/signin.js +2 -1
- package/dist/component/server/signin.js.map +1 -1
- package/dist/component/server/sso.js +166 -19
- package/dist/component/server/sso.js.map +1 -1
- package/dist/component/server/tokens.js +1 -0
- package/dist/component/server/tokens.js.map +1 -1
- package/dist/component/server/totp.js +4 -2
- package/dist/component/server/totp.js.map +1 -1
- package/dist/component/server/types.d.ts +106 -38
- package/dist/component/server/types.d.ts.map +1 -1
- package/dist/component/server/types.js.map +1 -1
- package/dist/component/server/users.js +1 -0
- package/dist/component/server/users.js.map +1 -1
- package/dist/component/server/utils.js +44 -2
- package/dist/component/server/utils.js.map +1 -1
- package/dist/providers/anonymous.d.ts +1 -1
- package/dist/providers/credentials.d.ts +1 -1
- package/dist/providers/password.d.ts +1 -1
- package/dist/providers/sso.d.ts +1 -1
- package/dist/providers/sso.js.map +1 -1
- package/dist/server/auth.d.ts +163 -17
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +100 -7
- package/dist/server/auth.js.map +1 -1
- package/dist/server/cookies.d.ts +1 -38
- package/dist/server/cookies.js +3 -0
- package/dist/server/cookies.js.map +1 -1
- package/dist/server/db.d.ts +1 -125
- package/dist/server/db.js +1 -0
- package/dist/server/db.js.map +1 -1
- package/dist/server/device.d.ts +1 -24
- package/dist/server/device.js +3 -1
- package/dist/server/device.js.map +1 -1
- package/dist/server/domains/core.d.ts +434 -0
- package/dist/server/domains/core.d.ts.map +1 -0
- package/dist/server/domains/core.js +629 -0
- package/dist/server/domains/core.js.map +1 -0
- package/dist/server/domains/sso.d.ts +409 -0
- package/dist/server/domains/sso.d.ts.map +1 -0
- package/dist/server/domains/sso.js +884 -0
- package/dist/server/domains/sso.js.map +1 -0
- package/dist/server/enterpriseValidators.d.ts +1 -0
- package/dist/server/enterpriseValidators.js +60 -0
- package/dist/server/enterpriseValidators.js.map +1 -0
- package/dist/server/factory.d.ts +136 -0
- package/dist/server/factory.d.ts.map +1 -0
- package/dist/server/factory.js +1134 -0
- package/dist/server/factory.js.map +1 -0
- package/dist/server/fx.d.ts +1 -16
- package/dist/server/fx.d.ts.map +1 -1
- package/dist/server/fx.js +1 -0
- package/dist/server/fx.js.map +1 -1
- package/dist/server/http.d.ts +59 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +287 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server/identity.d.ts +1 -0
- package/dist/server/identity.js +13 -0
- package/dist/server/identity.js.map +1 -0
- package/dist/server/index.d.ts +468 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +530 -36
- package/dist/server/index.js.map +1 -1
- package/dist/server/keys.d.ts +1 -57
- package/dist/server/keys.js +4 -0
- package/dist/server/keys.js.map +1 -1
- package/dist/server/mutations/account.d.ts +7 -7
- package/dist/server/mutations/account.d.ts.map +1 -1
- package/dist/server/mutations/code.d.ts +13 -13
- package/dist/server/mutations/code.d.ts.map +1 -1
- package/dist/server/mutations/index.d.ts +107 -107
- package/dist/server/mutations/index.d.ts.map +1 -1
- package/dist/server/mutations/index.js +1 -1
- package/dist/server/mutations/index.js.map +1 -1
- package/dist/server/mutations/invalidate.d.ts +5 -5
- package/dist/server/mutations/invalidate.d.ts.map +1 -1
- package/dist/server/mutations/oauth.d.ts +10 -10
- package/dist/server/mutations/oauth.d.ts.map +1 -1
- package/dist/server/mutations/oauth.js +9 -6
- package/dist/server/mutations/oauth.js.map +1 -1
- package/dist/server/mutations/refresh.d.ts +4 -4
- package/dist/server/mutations/register.d.ts +12 -12
- package/dist/server/mutations/register.d.ts.map +1 -1
- package/dist/server/mutations/retrieve.d.ts +7 -7
- package/dist/server/mutations/signature.d.ts +5 -5
- package/dist/server/mutations/signin.d.ts +6 -6
- package/dist/server/mutations/signin.d.ts.map +1 -1
- package/dist/server/mutations/signout.d.ts +1 -1
- package/dist/server/mutations/store.d.ts +3 -2
- package/dist/server/mutations/store.d.ts.map +1 -1
- package/dist/server/mutations/store.js +6 -3
- package/dist/server/mutations/store.js.map +1 -1
- package/dist/server/mutations/verifier.d.ts +1 -1
- package/dist/server/mutations/verify.d.ts +11 -11
- package/dist/server/mutations/verify.d.ts.map +1 -1
- package/dist/server/oauth.d.ts +1 -59
- package/dist/server/oauth.js +3 -0
- package/dist/server/oauth.js.map +1 -1
- package/dist/server/passkey.d.ts.map +1 -1
- package/dist/server/passkey.js +3 -2
- package/dist/server/passkey.js.map +1 -1
- package/dist/server/provider.d.ts +1 -14
- package/dist/server/provider.d.ts.map +1 -1
- package/dist/server/provider.js +2 -0
- package/dist/server/provider.js.map +1 -1
- package/dist/server/providers.js +10 -0
- package/dist/server/providers.js.map +1 -1
- package/dist/server/ratelimit.d.ts +1 -22
- package/dist/server/ratelimit.js +3 -0
- package/dist/server/ratelimit.js.map +1 -1
- package/dist/server/redirects.d.ts +1 -10
- package/dist/server/redirects.js +2 -0
- package/dist/server/redirects.js.map +1 -1
- package/dist/server/refresh.d.ts +1 -37
- package/dist/server/refresh.js +5 -0
- package/dist/server/refresh.js.map +1 -1
- package/dist/server/sessions.d.ts +1 -28
- package/dist/server/sessions.js +5 -0
- package/dist/server/sessions.js.map +1 -1
- package/dist/server/signin.d.ts +1 -55
- package/dist/server/signin.js +2 -1
- package/dist/server/signin.js.map +1 -1
- package/dist/server/sso.d.ts +1 -348
- package/dist/server/sso.js +165 -18
- package/dist/server/sso.js.map +1 -1
- package/dist/server/templates.d.ts +1 -21
- package/dist/server/templates.js +1 -0
- package/dist/server/templates.js.map +1 -1
- package/dist/server/tokens.d.ts +1 -11
- package/dist/server/tokens.js +1 -0
- package/dist/server/tokens.js.map +1 -1
- package/dist/server/totp.d.ts +1 -23
- package/dist/server/totp.js +4 -2
- package/dist/server/totp.js.map +1 -1
- package/dist/server/types.d.ts +114 -77
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/dist/server/users.d.ts +1 -31
- package/dist/server/users.js +1 -0
- package/dist/server/users.js.map +1 -1
- package/dist/server/utils.d.ts +1 -27
- package/dist/server/utils.js +44 -2
- package/dist/server/utils.js.map +1 -1
- package/dist/server/version.d.ts +1 -1
- package/dist/server/version.js +1 -1
- package/dist/server/version.js.map +1 -1
- package/package.json +4 -5
- package/src/cli/bin.ts +5 -0
- package/src/cli/index.ts +22 -9
- package/src/cli/keys.ts +3 -0
- package/src/client/index.ts +36 -37
- package/src/component/_generated/api.ts +14 -0
- package/src/component/_generated/component.ts +2106 -9
- package/src/component/index.ts +3 -1
- package/src/component/model.ts +441 -0
- package/src/component/public/enterprise.ts +753 -0
- package/src/component/public/factors.ts +332 -0
- package/src/component/public/groups.ts +932 -0
- package/src/component/public/identity.ts +566 -0
- package/src/component/public/keys.ts +209 -0
- package/src/component/public/shared.ts +119 -0
- package/src/component/public.ts +5 -2965
- package/src/component/schema.ts +68 -63
- package/src/providers/sso.ts +1 -1
- package/src/server/auth.ts +413 -18
- package/src/server/cookies.ts +3 -0
- package/src/server/db.ts +3 -0
- package/src/server/device.ts +3 -1
- package/src/server/domains/core.ts +1071 -0
- package/src/server/domains/sso.ts +1749 -0
- package/src/server/enterpriseValidators.ts +93 -0
- package/src/server/factory.ts +2181 -0
- package/src/server/fx.ts +1 -0
- package/src/server/http.ts +529 -0
- package/src/server/identity.ts +18 -0
- package/src/server/index.ts +806 -40
- package/src/server/keys.ts +4 -0
- package/src/server/mutations/index.ts +1 -1
- package/src/server/mutations/oauth.ts +36 -8
- package/src/server/mutations/store.ts +6 -3
- package/src/server/oauth.ts +6 -0
- package/src/server/passkey.ts +3 -2
- package/src/server/provider.ts +2 -0
- package/src/server/providers.ts +20 -0
- package/src/server/ratelimit.ts +3 -0
- package/src/server/redirects.ts +2 -0
- package/src/server/refresh.ts +5 -0
- package/src/server/sessions.ts +5 -0
- package/src/server/signin.ts +1 -0
- package/src/server/sso.ts +259 -17
- package/src/server/templates.ts +1 -0
- package/src/server/tokens.ts +1 -0
- package/src/server/totp.ts +4 -2
- package/src/server/types.ts +178 -83
- package/src/server/users.ts +1 -0
- package/src/server/utils.ts +71 -1
- package/src/server/version.ts +1 -1
- package/dist/component/public.js.map +0 -1
- package/dist/component/server/implementation.d.ts +0 -1264
- package/dist/component/server/implementation.d.ts.map +0 -1
- package/dist/component/server/implementation.js +0 -2365
- package/dist/component/server/implementation.js.map +0 -1
- package/dist/server/cookies.d.ts.map +0 -1
- package/dist/server/db.d.ts.map +0 -1
- package/dist/server/device.d.ts.map +0 -1
- package/dist/server/implementation.d.ts +0 -1264
- package/dist/server/implementation.d.ts.map +0 -1
- package/dist/server/implementation.js +0 -2365
- package/dist/server/implementation.js.map +0 -1
- package/dist/server/keys.d.ts.map +0 -1
- package/dist/server/oauth.d.ts.map +0 -1
- package/dist/server/ratelimit.d.ts.map +0 -1
- package/dist/server/redirects.d.ts.map +0 -1
- package/dist/server/refresh.d.ts.map +0 -1
- package/dist/server/sessions.d.ts.map +0 -1
- package/dist/server/signin.d.ts.map +0 -1
- package/dist/server/sso.d.ts.map +0 -1
- package/dist/server/templates.d.ts.map +0 -1
- package/dist/server/tokens.d.ts.map +0 -1
- package/dist/server/totp.d.ts.map +0 -1
- package/dist/server/users.d.ts.map +0 -1
- package/dist/server/utils.d.ts.map +0 -1
- package/src/server/implementation.ts +0 -5336
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robelest/convex-auth",
|
|
3
|
-
"version": "0.0.4-preview.
|
|
3
|
+
"version": "0.0.4-preview.16",
|
|
4
4
|
"description": "Authentication for Convex",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -106,8 +106,7 @@
|
|
|
106
106
|
"build:version": "vp exec node ../../scripts/generate-version.js",
|
|
107
107
|
"build:lib": "vp exec tsdown",
|
|
108
108
|
"build:component:dts": "vp exec node ../../scripts/fix-component-entrypoint-dts.js",
|
|
109
|
-
"build
|
|
110
|
-
"build": "rm -rf dist && vp run build:version && vp run build:lib && vp run build:component:dts && vp run build:bin",
|
|
109
|
+
"build": "rm -rf dist && vp run build:version && vp run build:lib && vp run build:component:dts",
|
|
111
110
|
"typecheck": "vp exec tsc --project tsconfig.server.json --noEmit && vp exec tsc --project tsconfig.client.json --noEmit && vp exec tsc --project tsconfig.component.json --noEmit",
|
|
112
111
|
"typecheck:consumer": "vp exec tsc --project tsconfig.consumer.json --noEmit",
|
|
113
112
|
"check:attw": "vp exec attw --pack . --profile esm-only --exclude-entrypoints ./test ./_generated/component.js",
|
|
@@ -116,8 +115,8 @@
|
|
|
116
115
|
"docs": "vp run --cwd ../../docs dev",
|
|
117
116
|
"lint": "vp run typecheck",
|
|
118
117
|
"spellcheck": "cspell \"docs/pages/**/*.md*\"",
|
|
119
|
-
"test": "vp test --config ../../vite.config.ts --project convex --project node",
|
|
120
|
-
"test:once": "vp test --config ../../vite.config.ts --run --project convex --project node",
|
|
118
|
+
"test": "vp test --config ../../vite.config.ts --project convex --project node --project interop",
|
|
119
|
+
"test:once": "vp test --config ../../vite.config.ts --run --project convex --project node --project interop",
|
|
121
120
|
"convex:dev": "vp exec convex dev",
|
|
122
121
|
"convex:codegen": "vp exec convex codegen",
|
|
123
122
|
"convex:codegen:component": "vp exec convex codegen --component-dir ./src/component",
|
package/src/cli/bin.ts
ADDED
package/src/cli/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
1
|
import { execFileSync } from "child_process";
|
|
4
2
|
import {
|
|
5
3
|
existsSync,
|
|
@@ -92,7 +90,7 @@ function convexCmd(...subArgs: string[]): { file: string; args: string[] } {
|
|
|
92
90
|
// Commander program
|
|
93
91
|
// ---------------------------------------------------------------------------
|
|
94
92
|
|
|
95
|
-
const program = new Command()
|
|
93
|
+
export const program = new Command()
|
|
96
94
|
.name("@robelest/convex-auth")
|
|
97
95
|
.version(version)
|
|
98
96
|
.description(
|
|
@@ -174,8 +172,6 @@ program
|
|
|
174
172
|
p.outro("Done!");
|
|
175
173
|
});
|
|
176
174
|
|
|
177
|
-
program.parse(process.argv);
|
|
178
|
-
|
|
179
175
|
// ---------------------------------------------------------------------------
|
|
180
176
|
// Types
|
|
181
177
|
// ---------------------------------------------------------------------------
|
|
@@ -284,13 +280,22 @@ async function configureEnvVar(
|
|
|
284
280
|
// ---------------------------------------------------------------------------
|
|
285
281
|
|
|
286
282
|
async function configureKeys(config: ProjectConfig) {
|
|
287
|
-
logStep(config, "Configure
|
|
288
|
-
const { JWT_PRIVATE_KEY, JWKS } =
|
|
283
|
+
logStep(config, "Configure signing and encryption keys");
|
|
284
|
+
const { JWT_PRIVATE_KEY, JWKS, AUTH_SECRET_ENCRYPTION_KEY } =
|
|
285
|
+
await generateKeys();
|
|
289
286
|
const existingPrivateKey = backendEnvVar(config, "JWT_PRIVATE_KEY");
|
|
290
287
|
const existingJwks = backendEnvVar(config, "JWKS");
|
|
291
|
-
|
|
288
|
+
const existingSecretEncryptionKey = backendEnvVar(
|
|
289
|
+
config,
|
|
290
|
+
"AUTH_SECRET_ENCRYPTION_KEY",
|
|
291
|
+
);
|
|
292
|
+
if (
|
|
293
|
+
existingPrivateKey !== "" ||
|
|
294
|
+
existingJwks !== "" ||
|
|
295
|
+
existingSecretEncryptionKey !== ""
|
|
296
|
+
) {
|
|
292
297
|
const shouldOverwrite = await promptForConfirmation(
|
|
293
|
-
`The ${printDeployment(config)} already has JWT_PRIVATE_KEY or
|
|
298
|
+
`The ${printDeployment(config)} already has JWT_PRIVATE_KEY, JWKS, or AUTH_SECRET_ENCRYPTION_KEY configured. Overwrite them?`,
|
|
294
299
|
{ default: false },
|
|
295
300
|
);
|
|
296
301
|
if (!shouldOverwrite) {
|
|
@@ -300,6 +305,14 @@ async function configureKeys(config: ProjectConfig) {
|
|
|
300
305
|
// Use --from-file to avoid shell quoting issues with multiline values
|
|
301
306
|
await setEnvVarFromFile(config, "JWT_PRIVATE_KEY", JWT_PRIVATE_KEY);
|
|
302
307
|
await setEnvVarFromFile(config, "JWKS", JWKS);
|
|
308
|
+
await setEnvVar(
|
|
309
|
+
config,
|
|
310
|
+
"AUTH_SECRET_ENCRYPTION_KEY",
|
|
311
|
+
AUTH_SECRET_ENCRYPTION_KEY,
|
|
312
|
+
{
|
|
313
|
+
hideValue: true,
|
|
314
|
+
},
|
|
315
|
+
);
|
|
303
316
|
}
|
|
304
317
|
|
|
305
318
|
// ---------------------------------------------------------------------------
|
package/src/cli/keys.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
|
|
1
3
|
import { exportJWK, exportPKCS8, generateKeyPair } from "jose";
|
|
2
4
|
|
|
3
5
|
export async function generateKeys() {
|
|
@@ -9,6 +11,7 @@ export async function generateKeys() {
|
|
|
9
11
|
return {
|
|
10
12
|
JWT_PRIVATE_KEY: `${privateKey.trimEnd().replace(/\n/g, " ")}`,
|
|
11
13
|
JWKS: jwks,
|
|
14
|
+
AUTH_SECRET_ENCRYPTION_KEY: randomBytes(32).toString("base64url"),
|
|
12
15
|
};
|
|
13
16
|
} catch (error) {
|
|
14
17
|
console.error(
|
package/src/client/index.ts
CHANGED
|
@@ -128,13 +128,9 @@ export type AuthApiRefs<
|
|
|
128
128
|
HasTotp extends boolean = boolean,
|
|
129
129
|
HasDevice extends boolean = boolean,
|
|
130
130
|
> = {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
store: {
|
|
136
|
-
run: FunctionReference<"mutation", "public", any, any>;
|
|
137
|
-
};
|
|
131
|
+
signIn: FunctionReference<"action", "public", any, any>;
|
|
132
|
+
signOut: FunctionReference<"action", "public", any, any>;
|
|
133
|
+
store: FunctionReference<"mutation", "public", any, any>;
|
|
138
134
|
/** @internal Set automatically by `createAuth` — do not set manually. */
|
|
139
135
|
_capabilities?: {
|
|
140
136
|
passkey: HasPasskey;
|
|
@@ -194,7 +190,9 @@ export type AuthClient<
|
|
|
194
190
|
(InferCaps<Api>["device"] extends true ? { device: DeviceClient } : {});
|
|
195
191
|
|
|
196
192
|
/** Options for {@link client}. */
|
|
197
|
-
export type ClientOptions
|
|
193
|
+
export type ClientOptions<
|
|
194
|
+
Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiRefs,
|
|
195
|
+
> = {
|
|
198
196
|
/** Any Convex client (`ConvexClient` or `ConvexReactClient`). */
|
|
199
197
|
convex: ConvexTransport;
|
|
200
198
|
/**
|
|
@@ -206,11 +204,11 @@ export type ClientOptions = {
|
|
|
206
204
|
* import { api } from "../convex/_generated/api";
|
|
207
205
|
* client({
|
|
208
206
|
* convex,
|
|
209
|
-
* api:
|
|
207
|
+
* api: api.auth,
|
|
210
208
|
* });
|
|
211
209
|
* ```
|
|
212
210
|
*/
|
|
213
|
-
api?:
|
|
211
|
+
api?: Api;
|
|
214
212
|
/**
|
|
215
213
|
* Convex deployment URL. Derived automatically from the client internals
|
|
216
214
|
* when omitted — pass explicitly only if auto-detection fails.
|
|
@@ -321,9 +319,10 @@ function isRetriableProxyRefreshError(error: unknown): boolean {
|
|
|
321
319
|
* ```ts
|
|
322
320
|
* import { ConvexClient } from 'convex/browser';
|
|
323
321
|
* import { client } from '@robelest/convex-auth/client';
|
|
322
|
+
* import { api } from '../convex/_generated/api';
|
|
324
323
|
*
|
|
325
324
|
* const convex = new ConvexClient(CONVEX_URL);
|
|
326
|
-
* const auth = client({ convex });
|
|
325
|
+
* const auth = client({ convex, api: api.auth });
|
|
327
326
|
* ```
|
|
328
327
|
*
|
|
329
328
|
* ### SSR / proxy mode
|
|
@@ -345,7 +344,7 @@ function isRetriableProxyRefreshError(error: unknown): boolean {
|
|
|
345
344
|
*/
|
|
346
345
|
export function client<
|
|
347
346
|
Api extends AuthApiRefs<boolean, boolean, boolean> = AuthApiRefs,
|
|
348
|
-
>(options: ClientOptions): AuthClient<Api> {
|
|
347
|
+
>(options: ClientOptions<Api>): AuthClient<Api> {
|
|
349
348
|
const { convex, proxyPath, api: apiRefs } = options;
|
|
350
349
|
const proxy = proxyPath;
|
|
351
350
|
|
|
@@ -353,7 +352,7 @@ export function client<
|
|
|
353
352
|
if (!apiRefs) {
|
|
354
353
|
throw new Error(
|
|
355
354
|
"The `api` option is required when `proxyPath` is not set. " +
|
|
356
|
-
"Pass { api:
|
|
355
|
+
"Pass { api: api.auth }.",
|
|
357
356
|
);
|
|
358
357
|
}
|
|
359
358
|
return apiRefs;
|
|
@@ -856,7 +855,7 @@ export function client<
|
|
|
856
855
|
Fx.from({
|
|
857
856
|
ok: () =>
|
|
858
857
|
httpClient!.action(
|
|
859
|
-
requireApiRefs().
|
|
858
|
+
requireApiRefs().signIn,
|
|
860
859
|
"code" in args
|
|
861
860
|
? { params: { code: args.code }, verifier: args.verifier }
|
|
862
861
|
: args,
|
|
@@ -1022,7 +1021,7 @@ export function client<
|
|
|
1022
1021
|
|
|
1023
1022
|
if (proxy) {
|
|
1024
1023
|
const result = (await proxyFetch({
|
|
1025
|
-
action: "auth
|
|
1024
|
+
action: "auth:signIn",
|
|
1026
1025
|
args: { provider, params },
|
|
1027
1026
|
})) as SignInActionResult;
|
|
1028
1027
|
return handleSignInActionResult(result, {
|
|
@@ -1034,7 +1033,7 @@ export function client<
|
|
|
1034
1033
|
// SPA mode: call Convex directly.
|
|
1035
1034
|
const verifier = (await storageGet(VERIFIER_STORAGE_KEY)) ?? undefined;
|
|
1036
1035
|
await storageRemove(VERIFIER_STORAGE_KEY);
|
|
1037
|
-
const result = (await convex.action(requireApiRefs().
|
|
1036
|
+
const result = (await convex.action(requireApiRefs().signIn, {
|
|
1038
1037
|
provider,
|
|
1039
1038
|
params,
|
|
1040
1039
|
verifier,
|
|
@@ -1060,7 +1059,7 @@ export function client<
|
|
|
1060
1059
|
if (proxy) {
|
|
1061
1060
|
await Fx.run(
|
|
1062
1061
|
Fx.from({
|
|
1063
|
-
ok: () => proxyFetch({ action: "auth
|
|
1062
|
+
ok: () => proxyFetch({ action: "auth:signOut", args: {} }),
|
|
1064
1063
|
err: () => undefined,
|
|
1065
1064
|
}).pipe(Fx.recover(() => Fx.succeed(undefined))),
|
|
1066
1065
|
);
|
|
@@ -1072,7 +1071,7 @@ export function client<
|
|
|
1072
1071
|
// SPA mode.
|
|
1073
1072
|
await Fx.run(
|
|
1074
1073
|
Fx.from({
|
|
1075
|
-
ok: () => convex.action(requireApiRefs().
|
|
1074
|
+
ok: () => convex.action(requireApiRefs().signOut, {}),
|
|
1076
1075
|
err: () => undefined,
|
|
1077
1076
|
}).pipe(Fx.recover(() => Fx.succeed(undefined))),
|
|
1078
1077
|
);
|
|
@@ -1120,7 +1119,7 @@ export function client<
|
|
|
1120
1119
|
Fx.from({
|
|
1121
1120
|
ok: () =>
|
|
1122
1121
|
proxyFetch({
|
|
1123
|
-
action: "auth
|
|
1122
|
+
action: "auth:signIn",
|
|
1124
1123
|
args: { refreshToken: true },
|
|
1125
1124
|
}),
|
|
1126
1125
|
err: (e) => e,
|
|
@@ -1439,11 +1438,11 @@ export function client<
|
|
|
1439
1438
|
let phase1Result: SignInActionResult;
|
|
1440
1439
|
if (proxy) {
|
|
1441
1440
|
phase1Result = (await proxyFetch({
|
|
1442
|
-
action: "auth
|
|
1441
|
+
action: "auth:signIn",
|
|
1443
1442
|
args: { provider: "passkey", params: phase1Params },
|
|
1444
1443
|
})) as SignInActionResult;
|
|
1445
1444
|
} else {
|
|
1446
|
-
phase1Result = (await convex.action(requireApiRefs().
|
|
1445
|
+
phase1Result = (await convex.action(requireApiRefs().signIn, {
|
|
1447
1446
|
provider: "passkey",
|
|
1448
1447
|
params: phase1Params,
|
|
1449
1448
|
})) as SignInActionResult;
|
|
@@ -1510,7 +1509,7 @@ export function client<
|
|
|
1510
1509
|
// In proxy mode the verifier is stored in an httpOnly cookie by the proxy.
|
|
1511
1510
|
// We pass it back explicitly so the proxy can forward it to Convex.
|
|
1512
1511
|
phase2Result = (await proxyFetch({
|
|
1513
|
-
action: "auth
|
|
1512
|
+
action: "auth:signIn",
|
|
1514
1513
|
args: {
|
|
1515
1514
|
provider: "passkey",
|
|
1516
1515
|
params: phase2Params,
|
|
@@ -1518,7 +1517,7 @@ export function client<
|
|
|
1518
1517
|
},
|
|
1519
1518
|
})) as SignInActionResult;
|
|
1520
1519
|
} else {
|
|
1521
|
-
phase2Result = (await convex.action(requireApiRefs().
|
|
1520
|
+
phase2Result = (await convex.action(requireApiRefs().signIn, {
|
|
1522
1521
|
provider: "passkey",
|
|
1523
1522
|
params: phase2Params,
|
|
1524
1523
|
verifier: phase1Result.verifier,
|
|
@@ -1614,11 +1613,11 @@ export function client<
|
|
|
1614
1613
|
let phase1Result: SignInActionResult;
|
|
1615
1614
|
if (proxy) {
|
|
1616
1615
|
phase1Result = (await proxyFetch({
|
|
1617
|
-
action: "auth
|
|
1616
|
+
action: "auth:signIn",
|
|
1618
1617
|
args: { provider: "passkey", params: phase1Params },
|
|
1619
1618
|
})) as SignInActionResult;
|
|
1620
1619
|
} else {
|
|
1621
|
-
phase1Result = (await convex.action(requireApiRefs().
|
|
1620
|
+
phase1Result = (await convex.action(requireApiRefs().signIn, {
|
|
1622
1621
|
provider: "passkey",
|
|
1623
1622
|
params: phase1Params,
|
|
1624
1623
|
})) as SignInActionResult;
|
|
@@ -1670,7 +1669,7 @@ export function client<
|
|
|
1670
1669
|
let phase2Result: SignInActionResult;
|
|
1671
1670
|
if (proxy) {
|
|
1672
1671
|
phase2Result = (await proxyFetch({
|
|
1673
|
-
action: "auth
|
|
1672
|
+
action: "auth:signIn",
|
|
1674
1673
|
args: {
|
|
1675
1674
|
provider: "passkey",
|
|
1676
1675
|
params: phase2Params,
|
|
@@ -1678,7 +1677,7 @@ export function client<
|
|
|
1678
1677
|
},
|
|
1679
1678
|
})) as SignInActionResult;
|
|
1680
1679
|
} else {
|
|
1681
|
-
phase2Result = (await convex.action(requireApiRefs().
|
|
1680
|
+
phase2Result = (await convex.action(requireApiRefs().signIn, {
|
|
1682
1681
|
provider: "passkey",
|
|
1683
1682
|
params: phase2Params,
|
|
1684
1683
|
verifier: phase1Result.verifier,
|
|
@@ -1757,7 +1756,7 @@ export function client<
|
|
|
1757
1756
|
|
|
1758
1757
|
if (proxy) {
|
|
1759
1758
|
const result = await proxyFetch({
|
|
1760
|
-
action: "auth
|
|
1759
|
+
action: "auth:signIn",
|
|
1761
1760
|
args: { provider: "totp", params },
|
|
1762
1761
|
});
|
|
1763
1762
|
return {
|
|
@@ -1768,7 +1767,7 @@ export function client<
|
|
|
1768
1767
|
};
|
|
1769
1768
|
}
|
|
1770
1769
|
|
|
1771
|
-
const result = await convex.action(requireApiRefs().
|
|
1770
|
+
const result = await convex.action(requireApiRefs().signIn, {
|
|
1772
1771
|
provider: "totp",
|
|
1773
1772
|
params,
|
|
1774
1773
|
});
|
|
@@ -1800,7 +1799,7 @@ export function client<
|
|
|
1800
1799
|
|
|
1801
1800
|
if (proxy) {
|
|
1802
1801
|
const result = await proxyFetch({
|
|
1803
|
-
action: "auth
|
|
1802
|
+
action: "auth:signIn",
|
|
1804
1803
|
args: { provider: "totp", params, verifier: opts.verifier },
|
|
1805
1804
|
});
|
|
1806
1805
|
if (result.tokens) {
|
|
@@ -1815,7 +1814,7 @@ export function client<
|
|
|
1815
1814
|
return;
|
|
1816
1815
|
}
|
|
1817
1816
|
|
|
1818
|
-
const result = await convex.action(requireApiRefs().
|
|
1817
|
+
const result = await convex.action(requireApiRefs().signIn, {
|
|
1819
1818
|
provider: "totp",
|
|
1820
1819
|
params,
|
|
1821
1820
|
verifier: opts.verifier,
|
|
@@ -1850,7 +1849,7 @@ export function client<
|
|
|
1850
1849
|
|
|
1851
1850
|
if (proxy) {
|
|
1852
1851
|
const result = await proxyFetch({
|
|
1853
|
-
action: "auth
|
|
1852
|
+
action: "auth:signIn",
|
|
1854
1853
|
args: { provider: "totp", params, verifier: opts.verifier },
|
|
1855
1854
|
});
|
|
1856
1855
|
if (result.tokens) {
|
|
@@ -1865,7 +1864,7 @@ export function client<
|
|
|
1865
1864
|
return;
|
|
1866
1865
|
}
|
|
1867
1866
|
|
|
1868
|
-
const result = await convex.action(requireApiRefs().
|
|
1867
|
+
const result = await convex.action(requireApiRefs().signIn, {
|
|
1869
1868
|
provider: "totp",
|
|
1870
1869
|
params,
|
|
1871
1870
|
verifier: opts.verifier,
|
|
@@ -1919,11 +1918,11 @@ export function client<
|
|
|
1919
1918
|
|
|
1920
1919
|
if (proxy) {
|
|
1921
1920
|
result = await proxyFetch({
|
|
1922
|
-
action: "auth
|
|
1921
|
+
action: "auth:signIn",
|
|
1923
1922
|
args: { provider: "device", params },
|
|
1924
1923
|
});
|
|
1925
1924
|
} else {
|
|
1926
|
-
result = await convex.action(requireApiRefs().
|
|
1925
|
+
result = await convex.action(requireApiRefs().signIn, {
|
|
1927
1926
|
provider: "device",
|
|
1928
1927
|
params,
|
|
1929
1928
|
});
|
|
@@ -2013,11 +2012,11 @@ export function client<
|
|
|
2013
2012
|
|
|
2014
2013
|
if (proxy) {
|
|
2015
2014
|
await proxyFetch({
|
|
2016
|
-
action: "auth
|
|
2015
|
+
action: "auth:signIn",
|
|
2017
2016
|
args: { provider: "device", params },
|
|
2018
2017
|
});
|
|
2019
2018
|
} else {
|
|
2020
|
-
await convex.action(requireApiRefs().
|
|
2019
|
+
await convex.action(requireApiRefs().signIn, {
|
|
2021
2020
|
provider: "device",
|
|
2022
2021
|
params,
|
|
2023
2022
|
});
|
|
@@ -10,7 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
import type * as functions from "../functions.js";
|
|
12
12
|
import type * as index from "../index.js";
|
|
13
|
+
import type * as model from "../model.js";
|
|
13
14
|
import type * as public_ from "../public.js";
|
|
15
|
+
import type * as public_enterprise from "../public/enterprise.js";
|
|
16
|
+
import type * as public_factors from "../public/factors.js";
|
|
17
|
+
import type * as public_groups from "../public/groups.js";
|
|
18
|
+
import type * as public_identity from "../public/identity.js";
|
|
19
|
+
import type * as public_keys from "../public/keys.js";
|
|
20
|
+
import type * as public_shared from "../public/shared.js";
|
|
14
21
|
|
|
15
22
|
import type {
|
|
16
23
|
ApiFromModules,
|
|
@@ -22,7 +29,14 @@ import { anyApi, componentsGeneric } from "convex/server";
|
|
|
22
29
|
const fullApi: ApiFromModules<{
|
|
23
30
|
functions: typeof functions;
|
|
24
31
|
index: typeof index;
|
|
32
|
+
model: typeof model;
|
|
25
33
|
public: typeof public_;
|
|
34
|
+
"public/enterprise": typeof public_enterprise;
|
|
35
|
+
"public/factors": typeof public_factors;
|
|
36
|
+
"public/groups": typeof public_groups;
|
|
37
|
+
"public/identity": typeof public_identity;
|
|
38
|
+
"public/keys": typeof public_keys;
|
|
39
|
+
"public/shared": typeof public_shared;
|
|
26
40
|
}> = anyApi as any;
|
|
27
41
|
|
|
28
42
|
/**
|