@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/dist/server/index.js
CHANGED
|
@@ -1,14 +1,508 @@
|
|
|
1
1
|
import { Fx } from "./fx.js";
|
|
2
2
|
import { isLocalHost } from "./utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import { makeFunctionReference } from "convex/server";
|
|
3
|
+
import { enterpriseConnectionWhereValidator, enterpriseDomainInputValidator, enterpriseDomainVerificationInputValidator, enterprisePolicyPatchValidator, enterpriseSamlAttributeMappingValidator, enterpriseSamlSpValidator, enterpriseStatusValidator } from "./enterpriseValidators.js";
|
|
4
|
+
import { actionGeneric, makeFunctionReference, mutationGeneric, queryGeneric } from "convex/server";
|
|
5
|
+
import { ConvexError, v } from "convex/values";
|
|
5
6
|
import { parse, serialize } from "cookie";
|
|
6
7
|
import { ConvexHttpClient } from "convex/browser";
|
|
7
8
|
import { jwtDecode } from "jwt-decode";
|
|
8
9
|
|
|
9
10
|
//#region src/server/index.ts
|
|
10
|
-
const signInActionRef = makeFunctionReference("auth
|
|
11
|
-
const signOutActionRef = makeFunctionReference("auth
|
|
11
|
+
const signInActionRef = makeFunctionReference("auth:signIn");
|
|
12
|
+
const signOutActionRef = makeFunctionReference("auth:signOut");
|
|
13
|
+
function requireSignedInUser(auth) {
|
|
14
|
+
return async (ctx) => {
|
|
15
|
+
return await auth.user.require(ctx);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function normalizeCreatorRoleIds(roles) {
|
|
19
|
+
return roles?.map((role) => typeof role === "string" ? role : role.id);
|
|
20
|
+
}
|
|
21
|
+
async function resolveMountedEnterpriseTarget(auth, ctx, target) {
|
|
22
|
+
if (target.groupId !== void 0) return {
|
|
23
|
+
enterpriseId: target.enterpriseId,
|
|
24
|
+
groupId: target.groupId,
|
|
25
|
+
resolvedGroupId: target.groupId
|
|
26
|
+
};
|
|
27
|
+
if (target.enterpriseId !== void 0) {
|
|
28
|
+
const enterprise = await auth.sso.admin.connection.get(ctx, target.enterpriseId);
|
|
29
|
+
if (enterprise === null) throw new ConvexError({
|
|
30
|
+
code: "INVALID_PARAMETERS",
|
|
31
|
+
message: "Enterprise not found."
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
enterpriseId: enterprise._id,
|
|
35
|
+
groupId: enterprise.groupId,
|
|
36
|
+
resolvedGroupId: enterprise.groupId
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (target.domain !== void 0) {
|
|
40
|
+
const resolved = await auth.sso.admin.connection.getByDomain(ctx, target.domain);
|
|
41
|
+
if (resolved?.enterprise === void 0) throw new ConvexError({
|
|
42
|
+
code: "INVALID_PARAMETERS",
|
|
43
|
+
message: "Enterprise not found."
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
enterpriseId: resolved.enterprise._id,
|
|
47
|
+
groupId: resolved.enterprise.groupId,
|
|
48
|
+
resolvedGroupId: resolved.enterprise.groupId
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
enterpriseId: void 0,
|
|
53
|
+
groupId: void 0,
|
|
54
|
+
resolvedGroupId: null
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function createMountedAdminAuthorizer(auth, options) {
|
|
58
|
+
const requireUserId = requireSignedInUser(auth);
|
|
59
|
+
return async (ctx, permission, target = {}) => {
|
|
60
|
+
const userId = await requireUserId(ctx);
|
|
61
|
+
if (!options?.admin?.authorized) throw new ConvexError({
|
|
62
|
+
code: "FORBIDDEN",
|
|
63
|
+
message: "Mounted enterprise admin APIs require an authorized callback."
|
|
64
|
+
});
|
|
65
|
+
const resolved = await resolveMountedEnterpriseTarget(auth, ctx, target);
|
|
66
|
+
await options.admin.authorized(ctx, {
|
|
67
|
+
userId,
|
|
68
|
+
permission,
|
|
69
|
+
enterpriseId: resolved.enterpriseId,
|
|
70
|
+
groupId: resolved.groupId,
|
|
71
|
+
resolvedGroupId: resolved.resolvedGroupId
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
userId,
|
|
75
|
+
...resolved
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build optional public SSO management actions that apps can mount under
|
|
81
|
+
* `convex/auth/sso/**` when they want client-callable enterprise APIs.
|
|
82
|
+
*
|
|
83
|
+
* `admin` is for tenant-admin control-plane operations and should be mounted
|
|
84
|
+
* with an explicit authorization policy. `client` is for end-user sign-in
|
|
85
|
+
* helpers and does not require tenant-admin authorization.
|
|
86
|
+
*/
|
|
87
|
+
function sso(auth, options) {
|
|
88
|
+
const authorize = createMountedAdminAuthorizer(auth, options);
|
|
89
|
+
const adminRoleIds = normalizeCreatorRoleIds(options?.admin?.roles);
|
|
90
|
+
return {
|
|
91
|
+
admin: {
|
|
92
|
+
connection: {
|
|
93
|
+
create: mutationGeneric({
|
|
94
|
+
args: {
|
|
95
|
+
groupId: v.optional(v.string()),
|
|
96
|
+
name: v.optional(v.string()),
|
|
97
|
+
slug: v.optional(v.string()),
|
|
98
|
+
status: v.optional(enterpriseStatusValidator),
|
|
99
|
+
domain: v.optional(v.string())
|
|
100
|
+
},
|
|
101
|
+
handler: async (ctx, args) => {
|
|
102
|
+
const { userId } = await authorize(ctx, "sso.connection.create", { groupId: args.groupId });
|
|
103
|
+
const createsGroup = args.groupId === void 0;
|
|
104
|
+
const groupId = args.groupId ?? (await auth.group.create(ctx, {
|
|
105
|
+
name: args.name?.trim() || args.slug?.trim() || "Enterprise",
|
|
106
|
+
slug: args.slug,
|
|
107
|
+
type: "enterprise"
|
|
108
|
+
})).groupId;
|
|
109
|
+
if (createsGroup) await auth.member.create(ctx, {
|
|
110
|
+
groupId,
|
|
111
|
+
userId,
|
|
112
|
+
roleIds: adminRoleIds
|
|
113
|
+
});
|
|
114
|
+
const created = await auth.sso.admin.connection.create(ctx, {
|
|
115
|
+
groupId,
|
|
116
|
+
name: args.name,
|
|
117
|
+
slug: args.slug,
|
|
118
|
+
status: args.status
|
|
119
|
+
});
|
|
120
|
+
if (args.domain) await auth.sso.admin.connection.domain.set(ctx, created.enterpriseId, [{
|
|
121
|
+
domain: args.domain,
|
|
122
|
+
isPrimary: true
|
|
123
|
+
}]);
|
|
124
|
+
return {
|
|
125
|
+
...created,
|
|
126
|
+
groupId,
|
|
127
|
+
createdGroup: createsGroup
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
get: queryGeneric({
|
|
132
|
+
args: { enterpriseId: v.string() },
|
|
133
|
+
handler: async (ctx, args) => {
|
|
134
|
+
await authorize(ctx, "sso.connection.read", { enterpriseId: args.enterpriseId });
|
|
135
|
+
return await auth.sso.admin.connection.get(ctx, args.enterpriseId);
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
getByGroup: queryGeneric({
|
|
139
|
+
args: { groupId: v.string() },
|
|
140
|
+
handler: async (ctx, args) => {
|
|
141
|
+
await authorize(ctx, "sso.connection.read", { groupId: args.groupId });
|
|
142
|
+
return await auth.sso.admin.connection.getByGroup(ctx, args.groupId);
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
getByDomain: queryGeneric({
|
|
146
|
+
args: { domain: v.string() },
|
|
147
|
+
handler: async (ctx, args) => {
|
|
148
|
+
await authorize(ctx, "sso.connection.read", { domain: args.domain });
|
|
149
|
+
return await auth.sso.admin.connection.getByDomain(ctx, args.domain);
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
list: queryGeneric({
|
|
153
|
+
args: {
|
|
154
|
+
where: v.optional(enterpriseConnectionWhereValidator),
|
|
155
|
+
limit: v.optional(v.number()),
|
|
156
|
+
cursor: v.optional(v.union(v.string(), v.null())),
|
|
157
|
+
orderBy: v.optional(v.string()),
|
|
158
|
+
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
159
|
+
},
|
|
160
|
+
handler: async (ctx, args) => {
|
|
161
|
+
await authorize(ctx, "sso.connection.read", { groupId: args.where?.groupId });
|
|
162
|
+
return await auth.sso.admin.connection.list(ctx, args);
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
update: mutationGeneric({
|
|
166
|
+
args: {
|
|
167
|
+
enterpriseId: v.string(),
|
|
168
|
+
data: v.object({
|
|
169
|
+
name: v.optional(v.string()),
|
|
170
|
+
slug: v.optional(v.string()),
|
|
171
|
+
status: v.optional(enterpriseStatusValidator)
|
|
172
|
+
})
|
|
173
|
+
},
|
|
174
|
+
handler: async (ctx, args) => {
|
|
175
|
+
await authorize(ctx, "sso.connection.manage", { enterpriseId: args.enterpriseId });
|
|
176
|
+
await auth.sso.admin.connection.update(ctx, args.enterpriseId, args.data);
|
|
177
|
+
return {
|
|
178
|
+
ok: true,
|
|
179
|
+
enterpriseId: args.enterpriseId
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
delete: mutationGeneric({
|
|
184
|
+
args: { enterpriseId: v.string() },
|
|
185
|
+
handler: async (ctx, args) => {
|
|
186
|
+
await authorize(ctx, "sso.connection.manage", { enterpriseId: args.enterpriseId });
|
|
187
|
+
return await auth.sso.admin.connection.delete(ctx, args.enterpriseId);
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
status: queryGeneric({
|
|
191
|
+
args: { enterpriseId: v.string() },
|
|
192
|
+
handler: async (ctx, args) => {
|
|
193
|
+
await authorize(ctx, "sso.connection.read", { enterpriseId: args.enterpriseId });
|
|
194
|
+
return await auth.sso.admin.connection.status(ctx, args.enterpriseId);
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
197
|
+
domain: {
|
|
198
|
+
list: queryGeneric({
|
|
199
|
+
args: { enterpriseId: v.string() },
|
|
200
|
+
handler: async (ctx, args) => {
|
|
201
|
+
await authorize(ctx, "sso.connection.read", { enterpriseId: args.enterpriseId });
|
|
202
|
+
return await auth.sso.admin.connection.domain.list(ctx, args.enterpriseId);
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
validate: queryGeneric({
|
|
206
|
+
args: { enterpriseId: v.string() },
|
|
207
|
+
handler: async (ctx, args) => {
|
|
208
|
+
await authorize(ctx, "sso.domain.manage", { enterpriseId: args.enterpriseId });
|
|
209
|
+
return await auth.sso.admin.connection.domain.validate(ctx, args.enterpriseId);
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
set: mutationGeneric({
|
|
213
|
+
args: {
|
|
214
|
+
enterpriseId: v.string(),
|
|
215
|
+
domains: v.array(enterpriseDomainInputValidator)
|
|
216
|
+
},
|
|
217
|
+
handler: async (ctx, args) => {
|
|
218
|
+
await authorize(ctx, "sso.domain.manage", { enterpriseId: args.enterpriseId });
|
|
219
|
+
return await auth.sso.admin.connection.domain.set(ctx, args.enterpriseId, args.domains);
|
|
220
|
+
}
|
|
221
|
+
}),
|
|
222
|
+
verification: {
|
|
223
|
+
request: mutationGeneric({
|
|
224
|
+
args: enterpriseDomainVerificationInputValidator,
|
|
225
|
+
handler: async (ctx, args) => {
|
|
226
|
+
await authorize(ctx, "sso.domain.manage", { enterpriseId: args.enterpriseId });
|
|
227
|
+
return await auth.sso.admin.connection.domain.verification.request(ctx, args);
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
confirm: actionGeneric({
|
|
231
|
+
args: enterpriseDomainVerificationInputValidator,
|
|
232
|
+
handler: async (ctx, args) => {
|
|
233
|
+
await authorize(ctx, "sso.domain.manage", { enterpriseId: args.enterpriseId });
|
|
234
|
+
return await auth.sso.admin.connection.domain.verification.confirm(ctx, args);
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
oidc: {
|
|
241
|
+
configure: mutationGeneric({
|
|
242
|
+
args: {
|
|
243
|
+
enterpriseId: v.string(),
|
|
244
|
+
issuer: v.optional(v.string()),
|
|
245
|
+
discoveryUrl: v.optional(v.string()),
|
|
246
|
+
clientId: v.string(),
|
|
247
|
+
clientSecret: v.optional(v.string()),
|
|
248
|
+
scopes: v.optional(v.array(v.string())),
|
|
249
|
+
authorizationParams: v.optional(v.record(v.string(), v.string())),
|
|
250
|
+
clockToleranceSeconds: v.optional(v.number()),
|
|
251
|
+
strictIssuer: v.optional(v.boolean()),
|
|
252
|
+
extraFields: v.optional(v.record(v.string(), v.string()))
|
|
253
|
+
},
|
|
254
|
+
handler: async (ctx, args) => {
|
|
255
|
+
await authorize(ctx, "sso.protocol.manage", { enterpriseId: args.enterpriseId });
|
|
256
|
+
return await auth.sso.admin.oidc.configure(ctx, args);
|
|
257
|
+
}
|
|
258
|
+
}),
|
|
259
|
+
get: queryGeneric({
|
|
260
|
+
args: { enterpriseId: v.string() },
|
|
261
|
+
handler: async (ctx, args) => {
|
|
262
|
+
await authorize(ctx, "sso.connection.read", { enterpriseId: args.enterpriseId });
|
|
263
|
+
return await auth.sso.admin.oidc.get(ctx, args.enterpriseId);
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
validate: actionGeneric({
|
|
267
|
+
args: { enterpriseId: v.string() },
|
|
268
|
+
handler: async (ctx, args) => {
|
|
269
|
+
await authorize(ctx, "sso.protocol.manage", { enterpriseId: args.enterpriseId });
|
|
270
|
+
return await auth.sso.admin.oidc.validate(ctx, args.enterpriseId);
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
},
|
|
274
|
+
saml: {
|
|
275
|
+
configure: actionGeneric({
|
|
276
|
+
args: {
|
|
277
|
+
enterpriseId: v.string(),
|
|
278
|
+
metadataXml: v.optional(v.string()),
|
|
279
|
+
metadataUrl: v.optional(v.string()),
|
|
280
|
+
domains: v.optional(v.array(v.string())),
|
|
281
|
+
signAuthnRequests: v.optional(v.boolean()),
|
|
282
|
+
attributeMapping: v.optional(enterpriseSamlAttributeMappingValidator),
|
|
283
|
+
sp: v.optional(enterpriseSamlSpValidator)
|
|
284
|
+
},
|
|
285
|
+
handler: async (ctx, args) => {
|
|
286
|
+
await authorize(ctx, "sso.protocol.manage", { enterpriseId: args.enterpriseId });
|
|
287
|
+
return await auth.sso.admin.saml.configure(ctx, args);
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
validate: queryGeneric({
|
|
291
|
+
args: { enterpriseId: v.string() },
|
|
292
|
+
handler: async (ctx, args) => {
|
|
293
|
+
await authorize(ctx, "sso.protocol.manage", { enterpriseId: args.enterpriseId });
|
|
294
|
+
return await auth.sso.admin.saml.validate(ctx, args.enterpriseId);
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
},
|
|
298
|
+
policy: {
|
|
299
|
+
get: queryGeneric({
|
|
300
|
+
args: { enterpriseId: v.string() },
|
|
301
|
+
handler: async (ctx, args) => {
|
|
302
|
+
await authorize(ctx, "sso.connection.read", { enterpriseId: args.enterpriseId });
|
|
303
|
+
return await auth.sso.admin.policy.get(ctx, args.enterpriseId);
|
|
304
|
+
}
|
|
305
|
+
}),
|
|
306
|
+
update: mutationGeneric({
|
|
307
|
+
args: {
|
|
308
|
+
enterpriseId: v.string(),
|
|
309
|
+
patch: enterprisePolicyPatchValidator
|
|
310
|
+
},
|
|
311
|
+
handler: async (ctx, args) => {
|
|
312
|
+
await authorize(ctx, "sso.policy.manage", { enterpriseId: args.enterpriseId });
|
|
313
|
+
return await auth.sso.admin.policy.update(ctx, args.enterpriseId, args.patch);
|
|
314
|
+
}
|
|
315
|
+
}),
|
|
316
|
+
validate: queryGeneric({
|
|
317
|
+
args: { enterpriseId: v.string() },
|
|
318
|
+
handler: async (ctx, args) => {
|
|
319
|
+
await authorize(ctx, "sso.policy.manage", { enterpriseId: args.enterpriseId });
|
|
320
|
+
return await auth.sso.admin.policy.validate(ctx, args.enterpriseId);
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
},
|
|
324
|
+
audit: { list: queryGeneric({
|
|
325
|
+
args: {
|
|
326
|
+
enterpriseId: v.optional(v.string()),
|
|
327
|
+
groupId: v.optional(v.string()),
|
|
328
|
+
limit: v.optional(v.number())
|
|
329
|
+
},
|
|
330
|
+
handler: async (ctx, args) => {
|
|
331
|
+
await authorize(ctx, "sso.audit.read", {
|
|
332
|
+
enterpriseId: args.enterpriseId,
|
|
333
|
+
groupId: args.groupId
|
|
334
|
+
});
|
|
335
|
+
return await auth.sso.admin.audit.list(ctx, args);
|
|
336
|
+
}
|
|
337
|
+
}) },
|
|
338
|
+
webhook: {
|
|
339
|
+
delivery: { list: queryGeneric({
|
|
340
|
+
args: {
|
|
341
|
+
enterpriseId: v.string(),
|
|
342
|
+
limit: v.optional(v.number())
|
|
343
|
+
},
|
|
344
|
+
handler: async (ctx, args) => {
|
|
345
|
+
await authorize(ctx, "sso.webhook.manage", { enterpriseId: args.enterpriseId });
|
|
346
|
+
return await auth.sso.admin.webhook.delivery.list(ctx, args);
|
|
347
|
+
}
|
|
348
|
+
}) },
|
|
349
|
+
endpoint: {
|
|
350
|
+
create: mutationGeneric({
|
|
351
|
+
args: {
|
|
352
|
+
enterpriseId: v.string(),
|
|
353
|
+
url: v.string(),
|
|
354
|
+
secret: v.string(),
|
|
355
|
+
subscriptions: v.array(v.string()),
|
|
356
|
+
createdByUserId: v.optional(v.string())
|
|
357
|
+
},
|
|
358
|
+
handler: async (ctx, args) => {
|
|
359
|
+
const { userId } = await authorize(ctx, "sso.webhook.manage", { enterpriseId: args.enterpriseId });
|
|
360
|
+
return {
|
|
361
|
+
_id: (await auth.sso.admin.webhook.endpoint.create(ctx, {
|
|
362
|
+
...args,
|
|
363
|
+
createdByUserId: args.createdByUserId ?? userId
|
|
364
|
+
})).endpointId,
|
|
365
|
+
enterpriseId: args.enterpriseId,
|
|
366
|
+
url: args.url,
|
|
367
|
+
subscriptions: args.subscriptions,
|
|
368
|
+
createdByUserId: args.createdByUserId ?? userId,
|
|
369
|
+
status: "active",
|
|
370
|
+
failureCount: 0
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
}),
|
|
374
|
+
list: queryGeneric({
|
|
375
|
+
args: { enterpriseId: v.string() },
|
|
376
|
+
handler: async (ctx, args) => {
|
|
377
|
+
await authorize(ctx, "sso.webhook.manage", { enterpriseId: args.enterpriseId });
|
|
378
|
+
return (await auth.sso.admin.webhook.endpoint.list(ctx, args.enterpriseId)).map((endpoint) => {
|
|
379
|
+
const { secretHash: _secretHash, ...rest } = endpoint;
|
|
380
|
+
return rest;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}),
|
|
384
|
+
disable: mutationGeneric({
|
|
385
|
+
args: { endpointId: v.string() },
|
|
386
|
+
handler: async (ctx, args) => {
|
|
387
|
+
const endpoint = await auth.sso.admin.webhook.endpoint.get(ctx, args.endpointId);
|
|
388
|
+
if (!endpoint) throw new ConvexError({
|
|
389
|
+
code: "INVALID_PARAMETERS",
|
|
390
|
+
message: "Webhook endpoint not found."
|
|
391
|
+
});
|
|
392
|
+
await authorize(ctx, "sso.webhook.manage", {
|
|
393
|
+
enterpriseId: endpoint.enterpriseId,
|
|
394
|
+
groupId: endpoint.groupId
|
|
395
|
+
});
|
|
396
|
+
return await auth.sso.admin.webhook.endpoint.disable(ctx, args.endpointId);
|
|
397
|
+
}
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
client: {
|
|
403
|
+
signIn: queryGeneric({
|
|
404
|
+
args: {
|
|
405
|
+
enterpriseId: v.optional(v.string()),
|
|
406
|
+
email: v.optional(v.string()),
|
|
407
|
+
domain: v.optional(v.string()),
|
|
408
|
+
redirectTo: v.optional(v.string())
|
|
409
|
+
},
|
|
410
|
+
handler: async (ctx, args) => {
|
|
411
|
+
return await auth.sso.client.signIn(ctx, args);
|
|
412
|
+
}
|
|
413
|
+
}),
|
|
414
|
+
metadata: queryGeneric({
|
|
415
|
+
args: {
|
|
416
|
+
enterpriseId: v.string(),
|
|
417
|
+
entityId: v.optional(v.string()),
|
|
418
|
+
acsUrl: v.optional(v.string()),
|
|
419
|
+
sloUrl: v.optional(v.string())
|
|
420
|
+
},
|
|
421
|
+
handler: async (ctx, args) => {
|
|
422
|
+
return await auth.sso.client.metadata(ctx, args);
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Build optional public SCIM management actions that apps can mount under
|
|
430
|
+
* `convex/auth/scim/**` when they want client-callable enterprise admin APIs.
|
|
431
|
+
*/
|
|
432
|
+
function scim(auth, options) {
|
|
433
|
+
const authorize = createMountedAdminAuthorizer(auth, options);
|
|
434
|
+
return { admin: {
|
|
435
|
+
configure: mutationGeneric({
|
|
436
|
+
args: {
|
|
437
|
+
enterpriseId: v.string(),
|
|
438
|
+
basePath: v.optional(v.string()),
|
|
439
|
+
status: v.optional(enterpriseStatusValidator)
|
|
440
|
+
},
|
|
441
|
+
handler: async (ctx, args) => {
|
|
442
|
+
await authorize(ctx, "scim.manage", { enterpriseId: args.enterpriseId });
|
|
443
|
+
return await auth.scim.admin.configure(ctx, args);
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
get: queryGeneric({
|
|
447
|
+
args: { enterpriseId: v.string() },
|
|
448
|
+
handler: async (ctx, args) => {
|
|
449
|
+
await authorize(ctx, "scim.manage", { enterpriseId: args.enterpriseId });
|
|
450
|
+
return await auth.scim.admin.get(ctx, args.enterpriseId);
|
|
451
|
+
}
|
|
452
|
+
}),
|
|
453
|
+
validate: queryGeneric({
|
|
454
|
+
args: { enterpriseId: v.string() },
|
|
455
|
+
handler: async (ctx, args) => {
|
|
456
|
+
await authorize(ctx, "scim.manage", { enterpriseId: args.enterpriseId });
|
|
457
|
+
return await auth.scim.admin.validate(ctx, args.enterpriseId);
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
} };
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Build a flat mounted enterprise API surface for app-owned Convex exports.
|
|
464
|
+
*
|
|
465
|
+
* The returned object contains tenant-admin SSO and SCIM control-plane
|
|
466
|
+
* functions plus end-user enterprise sign-in helpers. The `authorized`
|
|
467
|
+
* callback is required for admin operations.
|
|
468
|
+
*/
|
|
469
|
+
function enterprise(auth, options) {
|
|
470
|
+
const mountedSso = sso(auth, { admin: options.admin });
|
|
471
|
+
const mountedScim = scim(auth, { admin: { authorized: options.admin.authorized } });
|
|
472
|
+
return {
|
|
473
|
+
createConnection: mountedSso.admin.connection.create,
|
|
474
|
+
getConnection: mountedSso.admin.connection.get,
|
|
475
|
+
getConnectionByGroup: mountedSso.admin.connection.getByGroup,
|
|
476
|
+
getConnectionByDomain: mountedSso.admin.connection.getByDomain,
|
|
477
|
+
listConnections: mountedSso.admin.connection.list,
|
|
478
|
+
updateConnection: mountedSso.admin.connection.update,
|
|
479
|
+
deleteConnection: mountedSso.admin.connection.delete,
|
|
480
|
+
getConnectionStatus: mountedSso.admin.connection.status,
|
|
481
|
+
listDomains: mountedSso.admin.connection.domain.list,
|
|
482
|
+
validateDomains: mountedSso.admin.connection.domain.validate,
|
|
483
|
+
setDomains: mountedSso.admin.connection.domain.set,
|
|
484
|
+
requestDomainVerification: mountedSso.admin.connection.domain.verification.request,
|
|
485
|
+
confirmDomainVerification: mountedSso.admin.connection.domain.verification.confirm,
|
|
486
|
+
configureOidc: mountedSso.admin.oidc.configure,
|
|
487
|
+
getOidc: mountedSso.admin.oidc.get,
|
|
488
|
+
validateOidc: mountedSso.admin.oidc.validate,
|
|
489
|
+
configureSaml: mountedSso.admin.saml.configure,
|
|
490
|
+
validateSaml: mountedSso.admin.saml.validate,
|
|
491
|
+
getPolicy: mountedSso.admin.policy.get,
|
|
492
|
+
updatePolicy: mountedSso.admin.policy.update,
|
|
493
|
+
validatePolicy: mountedSso.admin.policy.validate,
|
|
494
|
+
listAudit: mountedSso.admin.audit.list,
|
|
495
|
+
createWebhookEndpoint: mountedSso.admin.webhook.endpoint.create,
|
|
496
|
+
listWebhookEndpoints: mountedSso.admin.webhook.endpoint.list,
|
|
497
|
+
listWebhookDeliveries: mountedSso.admin.webhook.delivery.list,
|
|
498
|
+
disableWebhookEndpoint: mountedSso.admin.webhook.endpoint.disable,
|
|
499
|
+
configureScim: mountedScim.admin.configure,
|
|
500
|
+
getScim: mountedScim.admin.get,
|
|
501
|
+
validateScim: mountedScim.admin.validate,
|
|
502
|
+
signIn: mountedSso.client.signIn,
|
|
503
|
+
metadata: mountedSso.client.metadata
|
|
504
|
+
};
|
|
505
|
+
}
|
|
12
506
|
const TOKEN_COOKIE_BASE_NAME = "__convexAuthJWT";
|
|
13
507
|
const REFRESH_COOKIE_BASE_NAME = "__convexAuthRefreshToken";
|
|
14
508
|
const VERIFIER_COOKIE_BASE_NAME = "__convexAuthOAuthVerifier";
|
|
@@ -316,7 +810,7 @@ function server(options) {
|
|
|
316
810
|
if (body === null) return new Response("Invalid request body", { status: 400 });
|
|
317
811
|
const action = body.action;
|
|
318
812
|
const args = typeof body.args === "object" && body.args !== null ? body.args : {};
|
|
319
|
-
const actionDispatch = action === "auth
|
|
813
|
+
const actionDispatch = action === "auth:signIn" ? { action: "sessionStart" } : action === "auth:signOut" ? { action: "sessionStop" } : null;
|
|
320
814
|
if (actionDispatch === null) return new Response("Invalid action", { status: 400 });
|
|
321
815
|
const host = request.headers.get("host") ?? new URL(request.url).host;
|
|
322
816
|
const currentCookies = parseAuthCookies(request.headers.get("cookie"), host, cookieNamespace);
|
|
@@ -476,12 +970,12 @@ function server(options) {
|
|
|
476
970
|
const refreshed = await new ConvexHttpClient(convexUrl).action(signInActionRef, { refreshToken });
|
|
477
971
|
const refreshedTokens = await Fx.run(Fx.match(refreshed, refreshed.kind, {
|
|
478
972
|
signedIn: (signedInResult) => Fx.succeed(signedInResult.tokens),
|
|
479
|
-
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
480
|
-
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
481
|
-
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
482
|
-
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
483
|
-
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
484
|
-
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
973
|
+
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for sign-out fallback refresh")),
|
|
974
|
+
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for sign-out fallback refresh")),
|
|
975
|
+
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for sign-out fallback refresh")),
|
|
976
|
+
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for sign-out fallback refresh")),
|
|
977
|
+
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for sign-out fallback refresh")),
|
|
978
|
+
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for sign-out fallback refresh"))
|
|
485
979
|
}));
|
|
486
980
|
const fallbackSignOutDispatch = refreshedTokens !== null ? {
|
|
487
981
|
kind: "signOutWithRefreshed",
|
|
@@ -563,12 +1057,12 @@ function server(options) {
|
|
|
563
1057
|
kind: "signedIn",
|
|
564
1058
|
tokens: await Fx.run(Fx.match(result, result.kind, {
|
|
565
1059
|
signedIn: (signedInResult) => Fx.succeed(signedInResult.tokens),
|
|
566
|
-
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
567
|
-
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
568
|
-
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
569
|
-
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
570
|
-
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
571
|
-
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
1060
|
+
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for code exchange")),
|
|
1061
|
+
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for code exchange")),
|
|
1062
|
+
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for code exchange")),
|
|
1063
|
+
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for code exchange")),
|
|
1064
|
+
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for code exchange")),
|
|
1065
|
+
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for code exchange"))
|
|
572
1066
|
}))
|
|
573
1067
|
};
|
|
574
1068
|
},
|
|
@@ -661,12 +1155,12 @@ function server(options) {
|
|
|
661
1155
|
const result = await new ConvexHttpClient(convexUrl).action(signInActionRef, { refreshToken: refreshTokenValue });
|
|
662
1156
|
const tokens$1 = await Fx.run(Fx.match(result, result.kind, {
|
|
663
1157
|
signedIn: (signedInResult) => Fx.succeed(signedInResult.tokens),
|
|
664
|
-
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
665
|
-
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
666
|
-
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
667
|
-
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
668
|
-
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
669
|
-
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
1158
|
+
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1159
|
+
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1160
|
+
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1161
|
+
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1162
|
+
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1163
|
+
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh"))
|
|
670
1164
|
}));
|
|
671
1165
|
if (verbose) console.debug(`${(/* @__PURE__ */ new Date()).toISOString()} [convex-auth/server] Refreshed tokens, null=${tokens$1 === null}`);
|
|
672
1166
|
return tokens$1;
|
|
@@ -708,12 +1202,12 @@ function server(options) {
|
|
|
708
1202
|
const result = await new ConvexHttpClient(convexUrl).action(signInActionRef, { refreshToken: refreshTokenValue });
|
|
709
1203
|
const tokens$1 = await Fx.run(Fx.match(result, result.kind, {
|
|
710
1204
|
signedIn: (signedInResult) => Fx.succeed(signedInResult.tokens),
|
|
711
|
-
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
712
|
-
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
713
|
-
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
714
|
-
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
715
|
-
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
716
|
-
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
1205
|
+
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1206
|
+
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1207
|
+
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1208
|
+
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1209
|
+
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1210
|
+
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh"))
|
|
717
1211
|
}));
|
|
718
1212
|
if (verbose) console.debug(`${(/* @__PURE__ */ new Date()).toISOString()} [convex-auth/server] Refreshed tokens, null=${tokens$1 === null}`);
|
|
719
1213
|
return tokens$1;
|
|
@@ -743,12 +1237,12 @@ function server(options) {
|
|
|
743
1237
|
const result = await new ConvexHttpClient(convexUrl).action(signInActionRef, { refreshToken: refreshTokenValue });
|
|
744
1238
|
const tokens$1 = await Fx.run(Fx.match(result, result.kind, {
|
|
745
1239
|
signedIn: (signedInResult) => Fx.succeed(signedInResult.tokens),
|
|
746
|
-
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
747
|
-
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
748
|
-
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
749
|
-
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
750
|
-
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
751
|
-
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth
|
|
1240
|
+
redirect: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1241
|
+
started: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1242
|
+
passkeyOptions: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1243
|
+
totpRequired: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1244
|
+
totpSetup: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh")),
|
|
1245
|
+
deviceCode: () => Fx.fatal(/* @__PURE__ */ new Error("Invalid `auth:signIn` result for token refresh"))
|
|
752
1246
|
}));
|
|
753
1247
|
if (verbose) console.debug(`${(/* @__PURE__ */ new Date()).toISOString()} [convex-auth/server] Refreshed tokens, null=${tokens$1 === null}`);
|
|
754
1248
|
return tokens$1;
|
|
@@ -786,5 +1280,5 @@ function server(options) {
|
|
|
786
1280
|
}
|
|
787
1281
|
|
|
788
1282
|
//#endregion
|
|
789
|
-
export { authCookieNames, parseAuthCookies, serializeAuthCookies, server, shouldProxyAuthAction, structuredAuthCookies };
|
|
1283
|
+
export { authCookieNames, enterprise, parseAuthCookies, scim, serializeAuthCookies, server, shouldProxyAuthAction, sso, structuredAuthCookies };
|
|
790
1284
|
//# sourceMappingURL=index.js.map
|