@robelest/convex-auth 0.0.2 → 0.0.3-preview

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.
Files changed (69) hide show
  1. package/dist/bin.cjs +1 -1
  2. package/dist/client/index.d.ts.map +1 -1
  3. package/dist/client/index.js +10 -1
  4. package/dist/client/index.js.map +1 -1
  5. package/dist/component/_generated/component.d.ts +48 -0
  6. package/dist/component/_generated/component.d.ts.map +1 -1
  7. package/dist/component/index.d.ts +1 -2
  8. package/dist/component/index.d.ts.map +1 -1
  9. package/dist/component/index.js +0 -1
  10. package/dist/component/index.js.map +1 -1
  11. package/dist/component/public.d.ts +160 -0
  12. package/dist/component/public.d.ts.map +1 -1
  13. package/dist/component/public.js +124 -0
  14. package/dist/component/public.js.map +1 -1
  15. package/dist/component/schema.d.ts +79 -0
  16. package/dist/component/schema.d.ts.map +1 -1
  17. package/dist/component/schema.js +45 -0
  18. package/dist/component/schema.js.map +1 -1
  19. package/dist/server/convex-auth.d.ts +66 -13
  20. package/dist/server/convex-auth.d.ts.map +1 -1
  21. package/dist/server/convex-auth.js +154 -39
  22. package/dist/server/convex-auth.js.map +1 -1
  23. package/dist/server/email-templates.d.ts +18 -0
  24. package/dist/server/email-templates.d.ts.map +1 -0
  25. package/dist/server/email-templates.js +74 -0
  26. package/dist/server/email-templates.js.map +1 -0
  27. package/dist/server/implementation/apiKey.d.ts +74 -0
  28. package/dist/server/implementation/apiKey.d.ts.map +1 -0
  29. package/dist/server/implementation/apiKey.js +140 -0
  30. package/dist/server/implementation/apiKey.js.map +1 -0
  31. package/dist/server/implementation/index.d.ts +89 -0
  32. package/dist/server/implementation/index.d.ts.map +1 -1
  33. package/dist/server/implementation/index.js +132 -0
  34. package/dist/server/implementation/index.js.map +1 -1
  35. package/dist/server/implementation/signIn.js +3 -14
  36. package/dist/server/implementation/signIn.js.map +1 -1
  37. package/dist/server/index.d.ts +26 -2
  38. package/dist/server/index.d.ts.map +1 -1
  39. package/dist/server/index.js +63 -16
  40. package/dist/server/index.js.map +1 -1
  41. package/dist/server/provider_utils.d.ts +2 -0
  42. package/dist/server/provider_utils.d.ts.map +1 -1
  43. package/dist/server/types.d.ts +205 -2
  44. package/dist/server/types.d.ts.map +1 -1
  45. package/dist/server/version.d.ts +2 -0
  46. package/dist/server/version.d.ts.map +1 -0
  47. package/dist/server/version.js +3 -0
  48. package/dist/server/version.js.map +1 -0
  49. package/package.json +3 -2
  50. package/src/cli/index.ts +1 -1
  51. package/src/cli/utils.ts +248 -0
  52. package/src/client/index.ts +12 -1
  53. package/src/component/_generated/component.ts +61 -0
  54. package/src/component/index.ts +4 -1
  55. package/src/component/public.ts +142 -0
  56. package/src/component/schema.ts +52 -0
  57. package/src/server/convex-auth.ts +188 -56
  58. package/src/server/email-templates.ts +77 -0
  59. package/src/server/implementation/apiKey.ts +185 -0
  60. package/src/server/implementation/index.ts +192 -0
  61. package/src/server/implementation/signIn.ts +2 -12
  62. package/src/server/index.ts +98 -34
  63. package/src/server/types.ts +219 -2
  64. package/src/server/version.ts +2 -0
  65. package/dist/server/portal.d.ts +0 -116
  66. package/dist/server/portal.d.ts.map +0 -1
  67. package/dist/server/portal.js +0 -294
  68. package/dist/server/portal.js.map +0 -1
  69. package/src/server/portal.ts +0 -375
@@ -1,116 +0,0 @@
1
- import type { HttpRouter } from "convex/server";
2
- import type { ComponentApi as AuthComponentApi } from "../component/_generated/component.js";
3
- /**
4
- * Configure the Convex Auth Portal. Returns all the functions needed to
5
- * serve the portal admin UI, manage invite links, and query auth data.
6
- *
7
- * The portal dogfoods the same `Auth()` instance as your app. Portal admins
8
- * sign in via email magic link and are identified by accepted invites with
9
- * `role: "portalAdmin"`.
10
- *
11
- * ```ts filename="convex/portal.ts"
12
- * import { Portal } from "@robelest/convex-auth/component";
13
- * import { auth } from "./auth";
14
- * import { components } from "./_generated/api";
15
- *
16
- * export const {
17
- * hosting, getCurrentDeployment,
18
- * portalQuery, portalMutation,
19
- * validateInvite, acceptInvite, createPortalInvite,
20
- * portal,
21
- * } = Portal(components.auth, components.selfHosting, auth);
22
- * ```
23
- *
24
- * ## Setup
25
- *
26
- * 1. Configure an email provider in your `Auth()` config (e.g. Resend).
27
- * 2. Generate an admin invite link:
28
- * `npx @robelest/convex-auth portal link [--prod]`
29
- * 3. Visit the link, enter your email, click the magic link, and you're in.
30
- *
31
- * The portal URL is auto-derived from `CONVEX_SITE_URL` (always set by Convex).
32
- * Override with `options.portalUrl` if you need a custom URL.
33
- */
34
- export declare function Portal(authComponent: AuthComponentApi, selfHostingComponent: any, auth: any, options?: {
35
- portalUrl?: string;
36
- }): {
37
- /**
38
- * Combined internal mutation for self-hosting operations.
39
- * Used by the CLI (`@robelest/convex-auth portal upload`) to
40
- * upload static assets and manage deployments.
41
- */
42
- hosting: import("convex/server").RegisteredMutation<"internal", any, Promise<any>>;
43
- getCurrentDeployment: import("convex/server").RegisteredQuery<"public", {}, Promise<any>>;
44
- /**
45
- * Validate an invite token. Returns the invite if valid and pending,
46
- * or `null` otherwise. Used by the portal UI to check if an invite
47
- * link is valid before showing the registration form.
48
- */
49
- validateInvite: import("convex/server").RegisteredQuery<"public", {
50
- tokenHash: string;
51
- }, Promise<{
52
- _id: any;
53
- role: any;
54
- } | null>>;
55
- /**
56
- * Accept a portal invite. Must be called by an authenticated user.
57
- * Marks the invite as accepted and records the accepting user's ID.
58
- *
59
- * The portal UI calls this after the user has signed in via magic link
60
- * following an invite link.
61
- */
62
- acceptInvite: import("convex/server").RegisteredMutation<"public", {
63
- tokenHash: string;
64
- }, Promise<void>>;
65
- /**
66
- * Create a portal admin invite. Internal mutation called by the CLI
67
- * (`npx @robelest/convex-auth portal link`).
68
- */
69
- createPortalInvite: import("convex/server").RegisteredMutation<"internal", {
70
- tokenHash: string;
71
- }, Promise<{
72
- portalUrl: string;
73
- }>>;
74
- /**
75
- * Combined portal query for all auth data reads.
76
- * Requires the caller to be an authenticated portal admin.
77
- *
78
- * Actions:
79
- * - `listUsers` — List all users
80
- * - `listSessions` — List all sessions
81
- * - `getUser` — Get a single user by ID (requires `userId`)
82
- * - `getUserSessions` — List sessions for a user (requires `userId`)
83
- * - `getUserAccounts` — List auth accounts for a user (requires `userId`)
84
- * - `isAdmin` — Check if the current user is a portal admin
85
- */
86
- portalQuery: import("convex/server").RegisteredQuery<"public", {
87
- action: string;
88
- userId?: string;
89
- }, Promise<any>>;
90
- /**
91
- * Combined portal mutation for all auth data writes.
92
- * Requires the caller to be an authenticated portal admin.
93
- *
94
- * Actions:
95
- * - `revokeSession` — Revoke (delete) a session (requires `sessionId`)
96
- */
97
- portalMutation: import("convex/server").RegisteredMutation<"public", {
98
- action: string;
99
- sessionId?: string;
100
- }, Promise<void>>;
101
- portal: {
102
- /**
103
- * The URL where the portal is served. Used by the Svelte client
104
- * as the `redirectTo` for magic link sign-in.
105
- */
106
- portalUrl: string;
107
- /**
108
- * Register HTTP routes that serve the portal static UI.
109
- */
110
- addHttpRoutes: (http: HttpRouter, opts?: {
111
- pathPrefix?: string;
112
- spaFallback?: boolean;
113
- }) => void;
114
- };
115
- };
116
- //# sourceMappingURL=portal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/server/portal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAiC7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CACpB,aAAa,EAAE,gBAAgB,EAC/B,oBAAoB,EAAE,GAAG,EACzB,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;IAW9B;;;;OAIG;;;IAoFH;;;;OAIG;;mBAGqD,MAAM;;;;;IAe9D;;;;;;OAMG;;mBAGqD,MAAM;;IAwB9D;;;OAGG;;mBAGqD,MAAM;;;;IAY9D;;;;;;;;;;;OAWG;;gBAQ+B,MAAM;iBAAW,MAAM;;IAkDzD;;;;;;OAMG;;gBAQkC,MAAM;oBAAc,MAAM;;;QAqB7D;;;WAGG;;QAGH;;WAEG;8BAEK,UAAU,SACT;YAAE,UAAU,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE;;EAY5D"}
@@ -1,294 +0,0 @@
1
- import { queryGeneric, mutationGeneric, internalMutationGeneric, } from "convex/server";
2
- import { v } from "convex/values";
3
- import { registerStaticRoutes } from "@convex-dev/self-hosting";
4
- // ============================================================================
5
- // Helpers
6
- // ============================================================================
7
- /**
8
- * Check if the authenticated user is a portal admin.
9
- * Portal admins are identified by having an accepted invite
10
- * with `role: "portalAdmin"`.
11
- */
12
- async function requirePortalAdmin(ctx, authComponent, userId) {
13
- const invites = await ctx.runQuery(authComponent.public.inviteList, {
14
- status: "accepted",
15
- });
16
- const isAdmin = invites.some((invite) => invite.role === "portalAdmin" && invite.acceptedByUserId === userId);
17
- if (!isAdmin) {
18
- throw new Error("Not authorized: portal admin access required");
19
- }
20
- }
21
- // ============================================================================
22
- // Portal() factory
23
- // ============================================================================
24
- /**
25
- * Configure the Convex Auth Portal. Returns all the functions needed to
26
- * serve the portal admin UI, manage invite links, and query auth data.
27
- *
28
- * The portal dogfoods the same `Auth()` instance as your app. Portal admins
29
- * sign in via email magic link and are identified by accepted invites with
30
- * `role: "portalAdmin"`.
31
- *
32
- * ```ts filename="convex/portal.ts"
33
- * import { Portal } from "@robelest/convex-auth/component";
34
- * import { auth } from "./auth";
35
- * import { components } from "./_generated/api";
36
- *
37
- * export const {
38
- * hosting, getCurrentDeployment,
39
- * portalQuery, portalMutation,
40
- * validateInvite, acceptInvite, createPortalInvite,
41
- * portal,
42
- * } = Portal(components.auth, components.selfHosting, auth);
43
- * ```
44
- *
45
- * ## Setup
46
- *
47
- * 1. Configure an email provider in your `Auth()` config (e.g. Resend).
48
- * 2. Generate an admin invite link:
49
- * `npx @robelest/convex-auth portal link [--prod]`
50
- * 3. Visit the link, enter your email, click the magic link, and you're in.
51
- *
52
- * The portal URL is auto-derived from `CONVEX_SITE_URL` (always set by Convex).
53
- * Override with `options.portalUrl` if you need a custom URL.
54
- */
55
- export function Portal(authComponent, selfHostingComponent, auth, options) {
56
- const portalUrl = options?.portalUrl ??
57
- (process.env.CONVEX_SITE_URL
58
- ? `${process.env.CONVEX_SITE_URL.replace(/\/$/, "")}/portal`
59
- : "/portal");
60
- return {
61
- // ---- Self-hosting: combined internal mutation for CLI ----
62
- /**
63
- * Combined internal mutation for self-hosting operations.
64
- * Used by the CLI (`@robelest/convex-auth portal upload`) to
65
- * upload static assets and manage deployments.
66
- */
67
- hosting: internalMutationGeneric({
68
- args: {
69
- action: v.string(),
70
- path: v.optional(v.string()),
71
- storageId: v.optional(v.string()),
72
- blobId: v.optional(v.string()),
73
- contentType: v.optional(v.string()),
74
- deploymentId: v.optional(v.string()),
75
- currentDeploymentId: v.optional(v.string()),
76
- limit: v.optional(v.number()),
77
- },
78
- handler: async (ctx, args) => {
79
- switch (args.action) {
80
- case "generateUploadUrl": {
81
- return await ctx.storage.generateUploadUrl();
82
- }
83
- case "recordAsset": {
84
- const { oldStorageId, oldBlobId } = await ctx.runMutation(selfHostingComponent.lib.recordAsset, {
85
- path: args.path,
86
- ...(args.storageId ? { storageId: args.storageId } : {}),
87
- ...(args.blobId ? { blobId: args.blobId } : {}),
88
- contentType: args.contentType,
89
- deploymentId: args.deploymentId,
90
- });
91
- if (oldStorageId) {
92
- try {
93
- await ctx.storage.delete(oldStorageId);
94
- }
95
- catch {
96
- // Ignore — old file may have been in different storage
97
- }
98
- }
99
- return oldBlobId ?? null;
100
- }
101
- case "gcOldAssets": {
102
- const { storageIds, blobIds } = await ctx.runMutation(selfHostingComponent.lib.gcOldAssets, { currentDeploymentId: args.currentDeploymentId });
103
- for (const storageId of storageIds) {
104
- try {
105
- await ctx.storage.delete(storageId);
106
- }
107
- catch {
108
- // Ignore
109
- }
110
- }
111
- await ctx.runMutation(selfHostingComponent.lib.setCurrentDeployment, { deploymentId: args.currentDeploymentId });
112
- return { deleted: storageIds.length, blobIds };
113
- }
114
- case "listAssets": {
115
- return await ctx.runQuery(selfHostingComponent.lib.listAssets, {
116
- limit: args.limit,
117
- });
118
- }
119
- default:
120
- throw new Error(`Unknown hosting action: ${args.action}`);
121
- }
122
- },
123
- }),
124
- // ---- Deployment query (public, for client live-reload) ----
125
- getCurrentDeployment: queryGeneric({
126
- args: {},
127
- handler: async (ctx) => {
128
- return await ctx.runQuery(selfHostingComponent.lib.getCurrentDeployment, {});
129
- },
130
- }),
131
- // ---- Invite management ----
132
- /**
133
- * Validate an invite token. Returns the invite if valid and pending,
134
- * or `null` otherwise. Used by the portal UI to check if an invite
135
- * link is valid before showing the registration form.
136
- */
137
- validateInvite: queryGeneric({
138
- args: { tokenHash: v.string() },
139
- handler: async (ctx, { tokenHash }) => {
140
- const invite = await ctx.runQuery(authComponent.public.inviteGetByTokenHash, { tokenHash });
141
- if (!invite || invite.status !== "pending") {
142
- return null;
143
- }
144
- if (invite.expiresTime && invite.expiresTime < Date.now()) {
145
- return null;
146
- }
147
- return { _id: invite._id, role: invite.role };
148
- },
149
- }),
150
- /**
151
- * Accept a portal invite. Must be called by an authenticated user.
152
- * Marks the invite as accepted and records the accepting user's ID.
153
- *
154
- * The portal UI calls this after the user has signed in via magic link
155
- * following an invite link.
156
- */
157
- acceptInvite: mutationGeneric({
158
- args: { tokenHash: v.string() },
159
- handler: async (ctx, { tokenHash }) => {
160
- const userId = await auth.user.require(ctx);
161
- const invite = await ctx.runQuery(authComponent.public.inviteGetByTokenHash, { tokenHash });
162
- if (!invite) {
163
- throw new Error("Invalid invite token");
164
- }
165
- if (invite.status !== "pending") {
166
- throw new Error(`Invite already ${invite.status}`);
167
- }
168
- if (invite.expiresTime && invite.expiresTime < Date.now()) {
169
- throw new Error("Invite has expired");
170
- }
171
- await ctx.runMutation(authComponent.public.inviteAccept, {
172
- inviteId: invite._id,
173
- acceptedByUserId: userId,
174
- });
175
- },
176
- }),
177
- /**
178
- * Create a portal admin invite. Internal mutation called by the CLI
179
- * (`npx @robelest/convex-auth portal link`).
180
- */
181
- createPortalInvite: internalMutationGeneric({
182
- args: { tokenHash: v.string() },
183
- handler: async (ctx, { tokenHash }) => {
184
- await ctx.runMutation(authComponent.public.inviteCreate, {
185
- tokenHash,
186
- role: "portalAdmin",
187
- status: "pending",
188
- });
189
- return { portalUrl };
190
- },
191
- }),
192
- // ---- Portal data query (auth-gated) ----
193
- /**
194
- * Combined portal query for all auth data reads.
195
- * Requires the caller to be an authenticated portal admin.
196
- *
197
- * Actions:
198
- * - `listUsers` — List all users
199
- * - `listSessions` — List all sessions
200
- * - `getUser` — Get a single user by ID (requires `userId`)
201
- * - `getUserSessions` — List sessions for a user (requires `userId`)
202
- * - `getUserAccounts` — List auth accounts for a user (requires `userId`)
203
- * - `isAdmin` — Check if the current user is a portal admin
204
- */
205
- portalQuery: queryGeneric({
206
- args: {
207
- action: v.string(),
208
- userId: v.optional(v.string()),
209
- },
210
- handler: async (ctx, { action, userId }) => {
211
- const currentUserId = await auth.user.require(ctx);
212
- // Allow isAdmin check without admin requirement
213
- if (action === "isAdmin") {
214
- try {
215
- await requirePortalAdmin(ctx, authComponent, currentUserId);
216
- return true;
217
- }
218
- catch {
219
- return false;
220
- }
221
- }
222
- await requirePortalAdmin(ctx, authComponent, currentUserId);
223
- switch (action) {
224
- case "listUsers":
225
- return await ctx.runQuery(authComponent.public.userList);
226
- case "listSessions":
227
- return await ctx.runQuery(authComponent.public.sessionList);
228
- case "getUser":
229
- return await ctx.runQuery(authComponent.public.userGetById, {
230
- userId: userId,
231
- });
232
- case "getUserSessions":
233
- return await ctx.runQuery(authComponent.public.sessionListByUser, {
234
- userId: userId,
235
- });
236
- case "getUserAccounts": {
237
- const accounts = await ctx.runQuery(authComponent.public.accountListByUser, { userId: userId });
238
- // Strip secrets — never send password hashes to the frontend
239
- return accounts.map(({ secret: _, ...rest }) => rest);
240
- }
241
- default:
242
- throw new Error(`Unknown portal query action: ${action}`);
243
- }
244
- },
245
- }),
246
- // ---- Portal mutation (auth-gated) ----
247
- /**
248
- * Combined portal mutation for all auth data writes.
249
- * Requires the caller to be an authenticated portal admin.
250
- *
251
- * Actions:
252
- * - `revokeSession` — Revoke (delete) a session (requires `sessionId`)
253
- */
254
- portalMutation: mutationGeneric({
255
- args: {
256
- action: v.string(),
257
- sessionId: v.optional(v.string()),
258
- },
259
- handler: async (ctx, { action, sessionId }) => {
260
- const currentUserId = await auth.user.require(ctx);
261
- await requirePortalAdmin(ctx, authComponent, currentUserId);
262
- switch (action) {
263
- case "revokeSession":
264
- await ctx.runMutation(authComponent.public.sessionDelete, {
265
- sessionId: sessionId,
266
- });
267
- return;
268
- default:
269
- throw new Error(`Unknown portal mutation action: ${action}`);
270
- }
271
- },
272
- }),
273
- // ---- Portal namespace ----
274
- portal: {
275
- /**
276
- * The URL where the portal is served. Used by the Svelte client
277
- * as the `redirectTo` for magic link sign-in.
278
- */
279
- portalUrl,
280
- /**
281
- * Register HTTP routes that serve the portal static UI.
282
- */
283
- addHttpRoutes: (http, opts) => {
284
- const prefix = opts?.pathPrefix ?? "/portal";
285
- // Static file serving
286
- registerStaticRoutes(http, selfHostingComponent, {
287
- pathPrefix: prefix,
288
- spaFallback: opts?.spaFallback ?? true,
289
- });
290
- },
291
- },
292
- };
293
- }
294
- //# sourceMappingURL=portal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"portal.js","sourceRoot":"","sources":["../../src/server/portal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,+EAA+E;AAC/E,UA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