@robelest/convex-auth 0.0.4-preview.21 → 0.0.4-preview.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/index.js.map +1 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +36 -39
- package/dist/client/index.js.map +1 -1
- package/dist/component/client/index.d.ts +1 -2
- package/dist/component/convex.config.d.ts +2 -2
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/model.d.ts +5 -5
- package/dist/component/model.d.ts.map +1 -1
- package/dist/component/public/enterprise/audit.d.ts.map +1 -1
- package/dist/component/public/enterprise/audit.js.map +1 -1
- package/dist/component/public/enterprise/core.d.ts.map +1 -1
- package/dist/component/public/enterprise/core.js.map +1 -1
- package/dist/component/public/enterprise/domains.d.ts.map +1 -1
- package/dist/component/public/enterprise/domains.js.map +1 -1
- package/dist/component/public/enterprise/scim.d.ts.map +1 -1
- package/dist/component/public/enterprise/scim.js.map +1 -1
- package/dist/component/public/enterprise/secrets.d.ts.map +1 -1
- package/dist/component/public/enterprise/secrets.js.map +1 -1
- package/dist/component/public/enterprise/webhooks.d.ts.map +1 -1
- package/dist/component/public/enterprise/webhooks.js.map +1 -1
- package/dist/component/public/factors/devices.d.ts.map +1 -1
- package/dist/component/public/factors/devices.js.map +1 -1
- package/dist/component/public/factors/passkeys.d.ts.map +1 -1
- package/dist/component/public/factors/passkeys.js.map +1 -1
- package/dist/component/public/factors/totp.d.ts.map +1 -1
- package/dist/component/public/factors/totp.js.map +1 -1
- package/dist/component/public/groups/core.js.map +1 -1
- package/dist/component/public/groups/invites.d.ts.map +1 -1
- package/dist/component/public/groups/invites.js.map +1 -1
- package/dist/component/public/groups/members.d.ts.map +1 -1
- package/dist/component/public/groups/members.js.map +1 -1
- package/dist/component/public/identity/accounts.d.ts.map +1 -1
- package/dist/component/public/identity/accounts.js.map +1 -1
- package/dist/component/public/identity/codes.d.ts.map +1 -1
- package/dist/component/public/identity/codes.js.map +1 -1
- package/dist/component/public/identity/sessions.d.ts.map +1 -1
- package/dist/component/public/identity/sessions.js.map +1 -1
- package/dist/component/public/identity/tokens.d.ts.map +1 -1
- package/dist/component/public/identity/tokens.js.map +1 -1
- package/dist/component/public/identity/users.d.ts.map +1 -1
- package/dist/component/public/identity/users.js.map +1 -1
- package/dist/component/public/identity/verifiers.d.ts.map +1 -1
- package/dist/component/public/identity/verifiers.js.map +1 -1
- package/dist/component/public/security/keys.d.ts.map +1 -1
- package/dist/component/public/security/keys.js.map +1 -1
- package/dist/component/public/security/limits.d.ts.map +1 -1
- package/dist/component/public/security/limits.js.map +1 -1
- package/dist/component/schema.d.ts +39 -39
- package/dist/component/server/auth.d.ts +95 -52
- package/dist/component/server/auth.d.ts.map +1 -1
- package/dist/component/server/auth.js +63 -43
- package/dist/component/server/auth.js.map +1 -1
- package/dist/component/server/core.js +116 -235
- package/dist/component/server/core.js.map +1 -1
- package/dist/component/server/crypto.js +25 -7
- package/dist/component/server/crypto.js.map +1 -1
- package/dist/component/server/device.js +58 -15
- package/dist/component/server/device.js.map +1 -1
- package/dist/component/server/enterprise/domain.js +148 -59
- package/dist/component/server/enterprise/domain.js.map +1 -1
- package/dist/component/server/enterprise/http.js +36 -15
- package/dist/component/server/enterprise/http.js.map +1 -1
- package/dist/component/server/enterprise/oidc.js +1 -1
- package/dist/component/server/http.js +26 -21
- package/dist/component/server/http.js.map +1 -1
- package/dist/component/server/identity.js +5 -2
- package/dist/component/server/identity.js.map +1 -1
- package/dist/component/server/limits.js +21 -30
- package/dist/component/server/limits.js.map +1 -1
- package/dist/component/server/mutations/account.js +12 -10
- package/dist/component/server/mutations/account.js.map +1 -1
- package/dist/component/server/mutations/code.js +5 -2
- package/dist/component/server/mutations/code.js.map +1 -1
- package/dist/component/server/mutations/invalidate.js +1 -1
- package/dist/component/server/mutations/invalidate.js.map +1 -1
- package/dist/component/server/mutations/oauth.js +10 -4
- package/dist/component/server/mutations/oauth.js.map +1 -1
- package/dist/component/server/mutations/refresh.js +2 -2
- package/dist/component/server/mutations/refresh.js.map +1 -1
- package/dist/component/server/mutations/register.js +46 -42
- package/dist/component/server/mutations/register.js.map +1 -1
- package/dist/component/server/mutations/retrieve.js +21 -25
- package/dist/component/server/mutations/retrieve.js.map +1 -1
- package/dist/component/server/mutations/signature.js +10 -4
- package/dist/component/server/mutations/signature.js.map +1 -1
- package/dist/component/server/mutations/signout.js.map +1 -1
- package/dist/component/server/mutations/store.js +9 -24
- package/dist/component/server/mutations/store.js.map +1 -1
- package/dist/component/server/mutations/verifier.js.map +1 -1
- package/dist/component/server/mutations/verify.js +1 -1
- package/dist/component/server/mutations/verify.js.map +1 -1
- package/dist/component/server/oauth.js +53 -16
- package/dist/component/server/oauth.js.map +1 -1
- package/dist/component/server/passkey.js +115 -31
- package/dist/component/server/passkey.js.map +1 -1
- package/dist/component/server/redirects.js +9 -3
- package/dist/component/server/redirects.js.map +1 -1
- package/dist/component/server/refresh.js +10 -7
- package/dist/component/server/refresh.js.map +1 -1
- package/dist/component/server/runtime.d.ts +3 -3
- package/dist/component/server/runtime.d.ts.map +1 -1
- package/dist/component/server/runtime.js +62 -20
- package/dist/component/server/runtime.js.map +1 -1
- package/dist/component/server/signin.js +34 -10
- package/dist/component/server/signin.js.map +1 -1
- package/dist/component/server/totp.js +79 -19
- package/dist/component/server/totp.js.map +1 -1
- package/dist/component/server/types.d.ts +12 -20
- 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 +6 -3
- package/dist/component/server/users.js.map +1 -1
- package/dist/component/server/utils.js +10 -4
- package/dist/component/server/utils.js.map +1 -1
- package/dist/core/types.d.ts +14 -22
- package/dist/core/types.d.ts.map +1 -1
- package/dist/factors/device.js +8 -9
- package/dist/factors/device.js.map +1 -1
- package/dist/factors/passkey.js +18 -21
- package/dist/factors/passkey.js.map +1 -1
- package/dist/providers/password.js +66 -81
- package/dist/providers/password.js.map +1 -1
- package/dist/runtime/invite.js +2 -8
- package/dist/runtime/invite.js.map +1 -1
- package/dist/server/auth.d.ts +95 -52
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +63 -43
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core.d.ts +71 -159
- package/dist/server/core.d.ts.map +1 -1
- package/dist/server/core.js +116 -235
- package/dist/server/core.js.map +1 -1
- package/dist/server/crypto.d.ts.map +1 -1
- package/dist/server/crypto.js +25 -7
- package/dist/server/crypto.js.map +1 -1
- package/dist/server/device.js +58 -15
- package/dist/server/device.js.map +1 -1
- package/dist/server/enterprise/domain.d.ts +0 -8
- package/dist/server/enterprise/domain.d.ts.map +1 -1
- package/dist/server/enterprise/domain.js +148 -59
- package/dist/server/enterprise/domain.js.map +1 -1
- package/dist/server/enterprise/http.d.ts.map +1 -1
- package/dist/server/enterprise/http.js +35 -14
- package/dist/server/enterprise/http.js.map +1 -1
- package/dist/server/http.d.ts +2 -2
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +25 -20
- package/dist/server/http.js.map +1 -1
- package/dist/server/identity.js +5 -2
- package/dist/server/identity.js.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/limits.js +21 -30
- package/dist/server/limits.js.map +1 -1
- package/dist/server/mounts.d.ts +26 -64
- package/dist/server/mounts.d.ts.map +1 -1
- package/dist/server/mounts.js +45 -106
- package/dist/server/mounts.js.map +1 -1
- package/dist/server/mutations/account.d.ts +8 -9
- package/dist/server/mutations/account.d.ts.map +1 -1
- package/dist/server/mutations/account.js +11 -9
- package/dist/server/mutations/account.js.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/code.js +5 -2
- package/dist/server/mutations/code.js.map +1 -1
- package/dist/server/mutations/invalidate.d.ts +4 -4
- package/dist/server/mutations/invalidate.d.ts.map +1 -1
- package/dist/server/mutations/invalidate.js.map +1 -1
- package/dist/server/mutations/oauth.d.ts +12 -10
- package/dist/server/mutations/oauth.d.ts.map +1 -1
- package/dist/server/mutations/oauth.js +9 -3
- package/dist/server/mutations/oauth.js.map +1 -1
- package/dist/server/mutations/refresh.d.ts +3 -3
- package/dist/server/mutations/refresh.d.ts.map +1 -1
- package/dist/server/mutations/refresh.js +1 -1
- package/dist/server/mutations/refresh.js.map +1 -1
- package/dist/server/mutations/register.d.ts +11 -11
- package/dist/server/mutations/register.d.ts.map +1 -1
- package/dist/server/mutations/register.js +45 -41
- package/dist/server/mutations/register.js.map +1 -1
- package/dist/server/mutations/retrieve.d.ts +6 -6
- package/dist/server/mutations/retrieve.d.ts.map +1 -1
- package/dist/server/mutations/retrieve.js +20 -24
- package/dist/server/mutations/retrieve.js.map +1 -1
- package/dist/server/mutations/signature.d.ts +6 -7
- package/dist/server/mutations/signature.d.ts.map +1 -1
- package/dist/server/mutations/signature.js +9 -3
- package/dist/server/mutations/signature.js.map +1 -1
- package/dist/server/mutations/signin.d.ts +5 -5
- package/dist/server/mutations/signin.d.ts.map +1 -1
- package/dist/server/mutations/signout.js.map +1 -1
- package/dist/server/mutations/store.d.ts +97 -97
- package/dist/server/mutations/store.d.ts.map +1 -1
- package/dist/server/mutations/store.js +8 -23
- package/dist/server/mutations/store.js.map +1 -1
- package/dist/server/mutations/verifier.js.map +1 -1
- package/dist/server/mutations/verify.d.ts +10 -10
- package/dist/server/mutations/verify.d.ts.map +1 -1
- package/dist/server/mutations/verify.js.map +1 -1
- package/dist/server/oauth.js +53 -16
- package/dist/server/oauth.js.map +1 -1
- package/dist/server/passkey.d.ts +2 -2
- package/dist/server/passkey.d.ts.map +1 -1
- package/dist/server/passkey.js +114 -30
- package/dist/server/passkey.js.map +1 -1
- package/dist/server/redirects.js +9 -3
- package/dist/server/redirects.js.map +1 -1
- package/dist/server/refresh.js +10 -7
- package/dist/server/refresh.js.map +1 -1
- package/dist/server/runtime.d.ts +14 -14
- package/dist/server/runtime.d.ts.map +1 -1
- package/dist/server/runtime.js +61 -19
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/signin.js +34 -10
- package/dist/server/signin.js.map +1 -1
- package/dist/server/ssr.d.ts.map +1 -1
- package/dist/server/ssr.js +175 -184
- package/dist/server/ssr.js.map +1 -1
- package/dist/server/totp.js +78 -18
- package/dist/server/totp.js.map +1 -1
- package/dist/server/types.d.ts +13 -21
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/dist/server/users.js +6 -3
- package/dist/server/users.js.map +1 -1
- package/dist/server/utils.js +10 -4
- package/dist/server/utils.js.map +1 -1
- package/package.json +2 -6
- package/src/authorization/index.ts +1 -1
- package/src/cli/index.ts +1 -1
- package/src/client/core/types.ts +14 -14
- package/src/client/factors/device.ts +10 -12
- package/src/client/factors/passkey.ts +23 -26
- package/src/client/index.ts +54 -64
- package/src/client/runtime/invite.ts +5 -7
- package/src/component/index.ts +1 -0
- package/src/component/public/enterprise/audit.ts +6 -1
- package/src/component/public/enterprise/core.ts +1 -0
- package/src/component/public/enterprise/domains.ts +5 -1
- package/src/component/public/enterprise/scim.ts +1 -0
- package/src/component/public/enterprise/secrets.ts +1 -0
- package/src/component/public/enterprise/webhooks.ts +1 -0
- package/src/component/public/factors/devices.ts +1 -0
- package/src/component/public/factors/passkeys.ts +1 -0
- package/src/component/public/factors/totp.ts +1 -0
- package/src/component/public/groups/core.ts +1 -1
- package/src/component/public/groups/invites.ts +7 -1
- package/src/component/public/groups/members.ts +1 -0
- package/src/component/public/identity/accounts.ts +1 -0
- package/src/component/public/identity/codes.ts +1 -0
- package/src/component/public/identity/sessions.ts +1 -0
- package/src/component/public/identity/tokens.ts +1 -0
- package/src/component/public/identity/users.ts +1 -0
- package/src/component/public/identity/verifiers.ts +1 -0
- package/src/component/public/security/keys.ts +1 -0
- package/src/component/public/security/limits.ts +1 -0
- package/src/providers/password.ts +89 -110
- package/src/server/auth.ts +177 -111
- package/src/server/core.ts +197 -233
- package/src/server/crypto.ts +31 -29
- package/src/server/device.ts +65 -32
- package/src/server/enterprise/domain.ts +158 -170
- package/src/server/enterprise/http.ts +46 -39
- package/src/server/http.ts +36 -30
- package/src/server/identity.ts +5 -5
- package/src/server/index.ts +2 -0
- package/src/server/limits.ts +53 -80
- package/src/server/mounts.ts +47 -74
- package/src/server/mutations/account.ts +22 -36
- package/src/server/mutations/code.ts +6 -6
- package/src/server/mutations/invalidate.ts +1 -1
- package/src/server/mutations/oauth.ts +14 -8
- package/src/server/mutations/refresh.ts +5 -4
- package/src/server/mutations/register.ts +87 -132
- package/src/server/mutations/retrieve.ts +44 -44
- package/src/server/mutations/signature.ts +13 -6
- package/src/server/mutations/signout.ts +1 -1
- package/src/server/mutations/store.ts +16 -31
- package/src/server/mutations/verifier.ts +1 -1
- package/src/server/mutations/verify.ts +3 -5
- package/src/server/oauth.ts +60 -69
- package/src/server/passkey.ts +567 -517
- package/src/server/redirects.ts +10 -6
- package/src/server/refresh.ts +14 -18
- package/src/server/runtime.ts +70 -55
- package/src/server/signin.ts +44 -37
- package/src/server/ssr.ts +390 -407
- package/src/server/totp.ts +85 -35
- package/src/server/types.ts +19 -22
- package/src/server/users.ts +7 -6
- package/src/server/utils.ts +10 -12
- package/dist/component/server/authError.js +0 -34
- package/dist/component/server/authError.js.map +0 -1
- package/dist/component/server/errors.d.ts +0 -1
- package/dist/component/server/errors.js +0 -137
- package/dist/component/server/errors.js.map +0 -1
- package/dist/server/authError.d.ts +0 -46
- package/dist/server/authError.d.ts.map +0 -1
- package/dist/server/authError.js +0 -34
- package/dist/server/authError.js.map +0 -1
- package/dist/server/errors.d.ts +0 -177
- package/dist/server/errors.d.ts.map +0 -1
- package/dist/server/errors.js +0 -212
- package/dist/server/errors.js.map +0 -1
- package/src/server/authError.ts +0 -44
- package/src/server/errors.ts +0 -290
package/dist/server/core.d.ts
CHANGED
|
@@ -162,7 +162,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
162
162
|
* @param ctx - Convex mutation context.
|
|
163
163
|
* @param userId - The user's document ID.
|
|
164
164
|
* @param data - Fields to merge into the user document.
|
|
165
|
-
* @returns `{
|
|
165
|
+
* @returns `{ userId }`.
|
|
166
166
|
*
|
|
167
167
|
* @example
|
|
168
168
|
* ```ts
|
|
@@ -173,7 +173,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
175
|
update: (ctx: ComponentCtx, userId: string, data: Record<string, unknown>) => Promise<{
|
|
176
|
-
ok: true;
|
|
177
176
|
userId: string;
|
|
178
177
|
}>;
|
|
179
178
|
/**
|
|
@@ -184,7 +183,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
184
183
|
* @param ctx - Convex mutation context.
|
|
185
184
|
* @param opts.userId - The user's document ID.
|
|
186
185
|
* @param opts.groupId - Group ID to set as active, or `null` to clear.
|
|
187
|
-
* @returns `{
|
|
186
|
+
* @returns `{ userId, groupId }` confirming the active group was set (or cleared).
|
|
188
187
|
*
|
|
189
188
|
* @example
|
|
190
189
|
* ```ts
|
|
@@ -199,11 +198,9 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
199
198
|
userId: string;
|
|
200
199
|
groupId: string | null;
|
|
201
200
|
}) => Promise<{
|
|
202
|
-
ok: true;
|
|
203
201
|
userId: string;
|
|
204
202
|
groupId: null;
|
|
205
203
|
} | {
|
|
206
|
-
ok: true;
|
|
207
204
|
userId: string;
|
|
208
205
|
groupId: string;
|
|
209
206
|
}>;
|
|
@@ -236,18 +233,13 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
236
233
|
* @param ctx - Convex mutation context.
|
|
237
234
|
* @param userId - The user's document ID.
|
|
238
235
|
* @param opts.cascade - Whether to delete related records (default `true`).
|
|
239
|
-
* @returns `{
|
|
236
|
+
* @returns `{ userId }`.
|
|
237
|
+
* @throws `INVALID_PARAMETERS` if `cascade` is `false` but the user has linked data.
|
|
240
238
|
*/
|
|
241
239
|
delete: (ctx: ComponentCtx, userId: string, opts?: {
|
|
242
240
|
cascade?: boolean;
|
|
243
241
|
}) => Promise<{
|
|
244
|
-
ok: false;
|
|
245
|
-
code: "INVALID_PARAMETERS";
|
|
246
|
-
userId?: undefined;
|
|
247
|
-
} | {
|
|
248
|
-
ok: true;
|
|
249
242
|
userId: string;
|
|
250
|
-
code?: undefined;
|
|
251
243
|
}>;
|
|
252
244
|
};
|
|
253
245
|
session: {
|
|
@@ -289,7 +281,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
289
281
|
* @param ctx - Convex action context.
|
|
290
282
|
* @param args.userId - The user whose sessions should be invalidated.
|
|
291
283
|
* @param args.except - Optional array of session IDs to keep valid.
|
|
292
|
-
* @returns `{
|
|
284
|
+
* @returns `{ userId, except }` confirming the operation.
|
|
293
285
|
*
|
|
294
286
|
* @example Sign out everywhere except the current session
|
|
295
287
|
* ```ts
|
|
@@ -304,7 +296,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
304
296
|
userId: GenericId<"User">;
|
|
305
297
|
except?: GenericId<"Session">[];
|
|
306
298
|
}) => Promise<{
|
|
307
|
-
ok: true;
|
|
308
299
|
userId: GenericId<"User">;
|
|
309
300
|
except: GenericId<"Session">[];
|
|
310
301
|
}>;
|
|
@@ -367,7 +358,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
367
358
|
* @param args.profile - Profile data used to create or update the user document.
|
|
368
359
|
* @param args.shouldLinkViaEmail - If `true`, link to an existing user by email match.
|
|
369
360
|
* @param args.shouldLinkViaPhone - If `true`, link to an existing user by phone match.
|
|
370
|
-
* @returns
|
|
361
|
+
* @returns The created account and user information.
|
|
371
362
|
*
|
|
372
363
|
* @example
|
|
373
364
|
* ```ts
|
|
@@ -417,7 +408,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
417
408
|
* @param args.provider - The provider ID (e.g. `"password"`).
|
|
418
409
|
* @param args.account.id - Provider-specific account identifier.
|
|
419
410
|
* @param args.account.secret - The new credential secret to store.
|
|
420
|
-
* @returns `{
|
|
411
|
+
* @returns `{ accountId }` confirming the update.
|
|
421
412
|
*
|
|
422
413
|
* @example Password reset
|
|
423
414
|
* ```ts
|
|
@@ -428,7 +419,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
428
419
|
* ```
|
|
429
420
|
*/
|
|
430
421
|
update: <DataModel extends GenericDataModel>(ctx: GenericActionCtx<DataModel>, args: UpdateAccountCredentialsArgs) => Promise<{
|
|
431
|
-
ok: true;
|
|
432
422
|
accountId: string;
|
|
433
423
|
}>;
|
|
434
424
|
/**
|
|
@@ -441,30 +431,17 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
441
431
|
*
|
|
442
432
|
* @param ctx - Convex mutation context.
|
|
443
433
|
* @param accountId - The account's document ID.
|
|
444
|
-
* @returns `{
|
|
445
|
-
*
|
|
446
|
-
*
|
|
434
|
+
* @returns `{ accountId }` on success.
|
|
435
|
+
* @throws `ACCOUNT_NOT_FOUND` if the account does not exist.
|
|
436
|
+
* @throws `INVALID_PARAMETERS` if it is the user's last account.
|
|
447
437
|
*
|
|
448
438
|
* @example
|
|
449
439
|
* ```ts
|
|
450
|
-
*
|
|
451
|
-
* if (!result.ok) {
|
|
452
|
-
* console.error("Cannot delete account:", result.code);
|
|
453
|
-
* }
|
|
440
|
+
* await auth.account.delete(ctx, accountId);
|
|
454
441
|
* ```
|
|
455
442
|
*/
|
|
456
443
|
delete: (ctx: ComponentCtx, accountId: string) => Promise<{
|
|
457
|
-
ok: false;
|
|
458
|
-
code: "ACCOUNT_NOT_FOUND";
|
|
459
|
-
accountId?: undefined;
|
|
460
|
-
} | {
|
|
461
|
-
ok: false;
|
|
462
|
-
code: "INVALID_PARAMETERS";
|
|
463
|
-
accountId?: undefined;
|
|
464
|
-
} | {
|
|
465
|
-
ok: true;
|
|
466
444
|
accountId: string;
|
|
467
|
-
code?: undefined;
|
|
468
445
|
}>;
|
|
469
446
|
/**
|
|
470
447
|
* List all passkey credentials registered for a user.
|
|
@@ -499,7 +476,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
499
476
|
* @param ctx - Convex mutation context.
|
|
500
477
|
* @param passkeyId - The passkey credential's document ID.
|
|
501
478
|
* @param name - The new display name for the passkey.
|
|
502
|
-
* @returns `{
|
|
479
|
+
* @returns `{ passkeyId }` confirming the rename.
|
|
503
480
|
*
|
|
504
481
|
* @example
|
|
505
482
|
* ```ts
|
|
@@ -507,7 +484,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
507
484
|
* ```
|
|
508
485
|
*/
|
|
509
486
|
renamePasskey: (ctx: ComponentCtx, passkeyId: string, name: string) => Promise<{
|
|
510
|
-
ok: true;
|
|
511
487
|
passkeyId: string;
|
|
512
488
|
}>;
|
|
513
489
|
/**
|
|
@@ -519,7 +495,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
519
495
|
*
|
|
520
496
|
* @param ctx - Convex mutation context.
|
|
521
497
|
* @param passkeyId - The passkey credential's document ID.
|
|
522
|
-
* @returns `{
|
|
498
|
+
* @returns `{ passkeyId }` confirming the deletion.
|
|
523
499
|
*
|
|
524
500
|
* @example
|
|
525
501
|
* ```ts
|
|
@@ -527,7 +503,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
527
503
|
* ```
|
|
528
504
|
*/
|
|
529
505
|
deletePasskey: (ctx: ComponentCtx, passkeyId: string) => Promise<{
|
|
530
|
-
ok: true;
|
|
531
506
|
passkeyId: string;
|
|
532
507
|
}>;
|
|
533
508
|
/**
|
|
@@ -559,7 +534,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
559
534
|
*
|
|
560
535
|
* @param ctx - Convex mutation context.
|
|
561
536
|
* @param totpId - The TOTP factor's document ID.
|
|
562
|
-
* @returns `{
|
|
537
|
+
* @returns `{ totpId }` confirming the deletion.
|
|
563
538
|
*
|
|
564
539
|
* @example
|
|
565
540
|
* ```ts
|
|
@@ -567,7 +542,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
567
542
|
* ```
|
|
568
543
|
*/
|
|
569
544
|
deleteTotp: (ctx: ComponentCtx, totpId: string) => Promise<{
|
|
570
|
-
ok: true;
|
|
571
545
|
totpId: string;
|
|
572
546
|
}>;
|
|
573
547
|
};
|
|
@@ -629,7 +603,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
629
603
|
* @param data.parentGroupId - Nest under this group. Omit for a root group.
|
|
630
604
|
* @param data.tags - Faceted classification tags (normalized at write time).
|
|
631
605
|
* @param data.extend - Arbitrary app-specific metadata.
|
|
632
|
-
* @returns `{
|
|
606
|
+
* @returns `{ groupId }`.
|
|
633
607
|
*
|
|
634
608
|
* @example Root group
|
|
635
609
|
* ```ts
|
|
@@ -656,7 +630,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
656
630
|
}>;
|
|
657
631
|
extend?: Record<string, unknown>;
|
|
658
632
|
}) => Promise<{
|
|
659
|
-
ok: true;
|
|
660
633
|
groupId: string;
|
|
661
634
|
}>;
|
|
662
635
|
/**
|
|
@@ -733,7 +706,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
733
706
|
* @param ctx - Convex mutation context.
|
|
734
707
|
* @param groupId - The group's document ID.
|
|
735
708
|
* @param data - Fields to merge (e.g. `name`, `slug`, `tags`, `parentGroupId`).
|
|
736
|
-
* @returns `{
|
|
709
|
+
* @returns `{ groupId }`.
|
|
737
710
|
*
|
|
738
711
|
* @example
|
|
739
712
|
* ```ts
|
|
@@ -744,7 +717,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
744
717
|
* ```
|
|
745
718
|
*/
|
|
746
719
|
update: (ctx: ComponentCtx, groupId: string, data: Record<string, unknown>) => Promise<{
|
|
747
|
-
ok: true;
|
|
748
720
|
groupId: string;
|
|
749
721
|
}>;
|
|
750
722
|
/**
|
|
@@ -753,7 +725,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
753
725
|
*
|
|
754
726
|
* @param ctx - Convex mutation context.
|
|
755
727
|
* @param groupId - The group's document ID.
|
|
756
|
-
* @returns `{
|
|
728
|
+
* @returns `{ groupId }`.
|
|
757
729
|
*
|
|
758
730
|
* @example
|
|
759
731
|
* ```ts
|
|
@@ -761,7 +733,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
761
733
|
* ```
|
|
762
734
|
*/
|
|
763
735
|
delete: (ctx: ComponentCtx, groupId: string) => Promise<{
|
|
764
|
-
ok: true;
|
|
765
736
|
groupId: string;
|
|
766
737
|
}>;
|
|
767
738
|
/**
|
|
@@ -799,7 +770,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
799
770
|
* Add a user to a group with optional role IDs.
|
|
800
771
|
*
|
|
801
772
|
* Role IDs are validated against the roles defined in `defineRoles()` —
|
|
802
|
-
* invalid IDs
|
|
773
|
+
* invalid IDs throw `INVALID_ROLE_IDS`.
|
|
803
774
|
* Throws `DUPLICATE_MEMBERSHIP` if the user is already a member.
|
|
804
775
|
*
|
|
805
776
|
* @param ctx - Convex mutation context.
|
|
@@ -808,7 +779,8 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
808
779
|
* @param data.roleIds - Role IDs from `defineRoles()` (optional).
|
|
809
780
|
* @param data.status - Membership status string (optional, app-defined).
|
|
810
781
|
* @param data.extend - Arbitrary app-specific metadata.
|
|
811
|
-
* @returns `{
|
|
782
|
+
* @returns `{ memberId }`.
|
|
783
|
+
* @throws `INVALID_ROLE_IDS` if any supplied role IDs are not defined.
|
|
812
784
|
*
|
|
813
785
|
* @example
|
|
814
786
|
* ```ts
|
|
@@ -826,15 +798,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
826
798
|
status?: string;
|
|
827
799
|
extend?: Record<string, unknown>;
|
|
828
800
|
}) => Promise<{
|
|
829
|
-
ok: false;
|
|
830
|
-
code: "INVALID_ROLE_IDS";
|
|
831
|
-
invalidRoleIds: string[];
|
|
832
|
-
memberId?: undefined;
|
|
833
|
-
} | {
|
|
834
|
-
ok: true;
|
|
835
801
|
memberId: string;
|
|
836
|
-
code?: undefined;
|
|
837
|
-
invalidRoleIds?: undefined;
|
|
838
802
|
}>;
|
|
839
803
|
/**
|
|
840
804
|
* Fetch a membership document by its document ID.
|
|
@@ -893,7 +857,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
893
857
|
*
|
|
894
858
|
* @param ctx - Convex mutation context.
|
|
895
859
|
* @param memberId - The membership document ID.
|
|
896
|
-
* @returns `{
|
|
860
|
+
* @returns `{ memberId }`.
|
|
897
861
|
*
|
|
898
862
|
* @example
|
|
899
863
|
* ```ts
|
|
@@ -901,7 +865,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
901
865
|
* ```
|
|
902
866
|
*/
|
|
903
867
|
delete: (ctx: ComponentCtx, memberId: string) => Promise<{
|
|
904
|
-
ok: true;
|
|
905
868
|
memberId: string;
|
|
906
869
|
}>;
|
|
907
870
|
/**
|
|
@@ -911,7 +874,8 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
911
874
|
* @param ctx - Convex mutation context.
|
|
912
875
|
* @param memberId - The membership document ID.
|
|
913
876
|
* @param data - Fields to merge. `roleIds` are validated.
|
|
914
|
-
* @returns `{
|
|
877
|
+
* @returns `{ memberId }`.
|
|
878
|
+
* @throws `INVALID_ROLE_IDS` if any supplied role IDs are not defined.
|
|
915
879
|
*
|
|
916
880
|
* @example
|
|
917
881
|
* ```ts
|
|
@@ -922,15 +886,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
922
886
|
* ```
|
|
923
887
|
*/
|
|
924
888
|
update: (ctx: ComponentCtx, memberId: string, data: Record<string, unknown>) => Promise<{
|
|
925
|
-
ok: false;
|
|
926
|
-
code: "INVALID_ROLE_IDS";
|
|
927
|
-
invalidRoleIds: string[];
|
|
928
|
-
memberId?: undefined;
|
|
929
|
-
} | {
|
|
930
|
-
ok: true;
|
|
931
889
|
memberId: string;
|
|
932
|
-
code?: undefined;
|
|
933
|
-
invalidRoleIds?: undefined;
|
|
934
890
|
}>;
|
|
935
891
|
/**
|
|
936
892
|
* Resolve a user's membership in a group, optionally walking the
|
|
@@ -951,34 +907,41 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
951
907
|
* @param opts.userId - The user's document ID.
|
|
952
908
|
* @param opts.groupId - The group to check membership in.
|
|
953
909
|
* @param opts.ancestry - Walk the hierarchy (default `false`).
|
|
954
|
-
* @param opts.grants - Grant strings to check (optional).
|
|
955
|
-
* @param opts.roleIds - Role IDs to filter by (optional).
|
|
956
910
|
* @param opts.maxDepth - Max hierarchy levels (default 32, only with ancestry).
|
|
957
|
-
* @returns `{
|
|
958
|
-
* `ok` is `true` when membership exists and all requested grants are satisfied.
|
|
911
|
+
* @returns `{ membership, roleIds, grants }`.
|
|
959
912
|
*
|
|
960
913
|
* @example Direct lookup
|
|
961
914
|
* ```ts
|
|
962
|
-
* const result = await auth.member.
|
|
963
|
-
* if (!result.membership) return
|
|
915
|
+
* const result = await auth.member.inspect(ctx, { userId, groupId });
|
|
916
|
+
* if (!result.membership) return null;
|
|
964
917
|
* ```
|
|
965
918
|
*
|
|
966
|
-
* @example Check grants
|
|
919
|
+
* @example Check grants after inspection
|
|
967
920
|
* ```ts
|
|
968
|
-
* const result = await auth.member.
|
|
969
|
-
* userId, groupId,
|
|
921
|
+
* const result = await auth.member.inspect(ctx, {
|
|
922
|
+
* userId, groupId,
|
|
970
923
|
* });
|
|
971
|
-
*
|
|
924
|
+
* const canCreate = result.grants.includes("issues.create");
|
|
972
925
|
* ```
|
|
973
926
|
*
|
|
974
927
|
* @example Walk hierarchy + check grants
|
|
975
928
|
* ```ts
|
|
976
|
-
* const result = await auth.member.
|
|
977
|
-
* userId, groupId: teamId, ancestry: true,
|
|
929
|
+
* const result = await auth.member.inspect(ctx, {
|
|
930
|
+
* userId, groupId: teamId, ancestry: true,
|
|
978
931
|
* });
|
|
979
932
|
* ```
|
|
980
933
|
*/
|
|
981
|
-
|
|
934
|
+
inspect: (ctx: ComponentReadCtx, opts: {
|
|
935
|
+
userId: string;
|
|
936
|
+
groupId: string;
|
|
937
|
+
ancestry?: boolean;
|
|
938
|
+
maxDepth?: number;
|
|
939
|
+
}) => Promise<{
|
|
940
|
+
membership: any;
|
|
941
|
+
roleIds: any;
|
|
942
|
+
grants: string[];
|
|
943
|
+
}>;
|
|
944
|
+
require: (ctx: ComponentReadCtx, opts: {
|
|
982
945
|
userId: string;
|
|
983
946
|
groupId: string;
|
|
984
947
|
ancestry?: boolean;
|
|
@@ -986,31 +949,9 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
986
949
|
grants?: string[];
|
|
987
950
|
maxDepth?: number;
|
|
988
951
|
}) => Promise<{
|
|
989
|
-
ok: false;
|
|
990
|
-
membership: null;
|
|
991
|
-
matchedGroupId: null;
|
|
992
|
-
roleIds: string[];
|
|
993
|
-
grants: string[];
|
|
994
|
-
missingGrants: string[];
|
|
995
|
-
depth: null;
|
|
996
|
-
isDirect: boolean;
|
|
997
|
-
isInherited: boolean;
|
|
998
|
-
traversedGroupIds: string[];
|
|
999
|
-
code: "INVALID_ROLE_IDS";
|
|
1000
|
-
invalidRoleIds: string[];
|
|
1001
|
-
} | {
|
|
1002
|
-
ok: boolean;
|
|
1003
952
|
membership: any;
|
|
1004
|
-
matchedGroupId: string | null;
|
|
1005
953
|
roleIds: any;
|
|
1006
954
|
grants: string[];
|
|
1007
|
-
missingGrants: string[];
|
|
1008
|
-
depth: number | null;
|
|
1009
|
-
isDirect: boolean;
|
|
1010
|
-
isInherited: boolean;
|
|
1011
|
-
traversedGroupIds: string[];
|
|
1012
|
-
code?: undefined;
|
|
1013
|
-
invalidRoleIds?: undefined;
|
|
1014
955
|
}>;
|
|
1015
956
|
};
|
|
1016
957
|
invite: {
|
|
@@ -1025,7 +966,8 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1025
966
|
* @param data.roleIds - Role IDs from `defineRoles()` to assign on acceptance (optional).
|
|
1026
967
|
* @param data.expiresTime - Expiration timestamp in ms since epoch (optional).
|
|
1027
968
|
* @param data.extend - Arbitrary app-specific metadata (optional).
|
|
1028
|
-
* @returns `{
|
|
969
|
+
* @returns `{ inviteId, token }`.
|
|
970
|
+
* @throws `INVALID_ROLE_IDS` if any supplied role IDs are not defined.
|
|
1029
971
|
*
|
|
1030
972
|
* @example
|
|
1031
973
|
* ```ts
|
|
@@ -1042,17 +984,8 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1042
984
|
expiresTime?: number;
|
|
1043
985
|
extend?: Record<string, unknown>;
|
|
1044
986
|
}) => Promise<{
|
|
1045
|
-
ok: false;
|
|
1046
|
-
code: "INVALID_ROLE_IDS";
|
|
1047
|
-
invalidRoleIds: string[];
|
|
1048
|
-
inviteId?: undefined;
|
|
1049
|
-
token?: undefined;
|
|
1050
|
-
} | {
|
|
1051
|
-
ok: true;
|
|
1052
987
|
inviteId: string;
|
|
1053
988
|
token: string;
|
|
1054
|
-
code?: undefined;
|
|
1055
|
-
invalidRoleIds?: undefined;
|
|
1056
989
|
}>;
|
|
1057
990
|
/**
|
|
1058
991
|
* Fetch an invite document by ID.
|
|
@@ -1105,7 +1038,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1105
1038
|
* @param ctx - Convex mutation context.
|
|
1106
1039
|
* @param args.token - The raw invite token string.
|
|
1107
1040
|
* @param args.acceptedByUserId - The user accepting the invite.
|
|
1108
|
-
* @returns
|
|
1041
|
+
* @returns The created membership details.
|
|
1109
1042
|
*
|
|
1110
1043
|
* @example
|
|
1111
1044
|
* ```ts
|
|
@@ -1169,7 +1102,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1169
1102
|
* @param ctx - Convex mutation context.
|
|
1170
1103
|
* @param inviteId - The invite's document ID.
|
|
1171
1104
|
* @param acceptedByUserId - The user who accepted the invite (optional).
|
|
1172
|
-
* @returns `{
|
|
1105
|
+
* @returns `{ inviteId, acceptedByUserId }`.
|
|
1173
1106
|
*
|
|
1174
1107
|
* @example
|
|
1175
1108
|
* ```ts
|
|
@@ -1177,7 +1110,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1177
1110
|
* ```
|
|
1178
1111
|
*/
|
|
1179
1112
|
accept: (ctx: ComponentCtx, inviteId: string, acceptedByUserId?: string) => Promise<{
|
|
1180
|
-
ok: true;
|
|
1181
1113
|
inviteId: string;
|
|
1182
1114
|
acceptedByUserId: string | null;
|
|
1183
1115
|
}>;
|
|
@@ -1189,7 +1121,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1189
1121
|
*
|
|
1190
1122
|
* @param ctx - Convex mutation context.
|
|
1191
1123
|
* @param inviteId - The invite's document ID.
|
|
1192
|
-
* @returns `{
|
|
1124
|
+
* @returns `{ inviteId }`.
|
|
1193
1125
|
*
|
|
1194
1126
|
* @example
|
|
1195
1127
|
* ```ts
|
|
@@ -1197,7 +1129,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1197
1129
|
* ```
|
|
1198
1130
|
*/
|
|
1199
1131
|
revoke: (ctx: ComponentCtx, inviteId: string) => Promise<{
|
|
1200
|
-
ok: true;
|
|
1201
1132
|
inviteId: string;
|
|
1202
1133
|
}>;
|
|
1203
1134
|
};
|
|
@@ -1213,7 +1144,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1213
1144
|
* @param opts.rateLimit - Optional per-key rate limit `{ maxRequests, windowMs }`.
|
|
1214
1145
|
* @param opts.expiresAt - Optional expiration timestamp (ms since epoch).
|
|
1215
1146
|
* @param opts.metadata - Arbitrary app-specific metadata.
|
|
1216
|
-
* @returns `{
|
|
1147
|
+
* @returns `{ keyId, secret }`. Store `secret` securely — it cannot be retrieved later.
|
|
1217
1148
|
*
|
|
1218
1149
|
* @example
|
|
1219
1150
|
* ```ts
|
|
@@ -1235,7 +1166,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1235
1166
|
expiresAt?: number;
|
|
1236
1167
|
metadata?: Record<string, unknown>;
|
|
1237
1168
|
}) => Promise<{
|
|
1238
|
-
ok: true;
|
|
1239
1169
|
keyId: string;
|
|
1240
1170
|
secret: string;
|
|
1241
1171
|
}>;
|
|
@@ -1247,28 +1177,22 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1247
1177
|
*
|
|
1248
1178
|
* @param ctx - Convex mutation context (updates `lastUsedAt` and rate limit state).
|
|
1249
1179
|
* @param rawKey - The raw `sk_*` key string.
|
|
1250
|
-
* @returns
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
* - `"API_KEY_RATE_LIMITED"` — rate limit exceeded.
|
|
1180
|
+
* @returns `{ userId, keyId, scopes }` where `scopes.can(resource, action)` checks permissions.
|
|
1181
|
+
* @throws `INVALID_API_KEY` if the key is not found.
|
|
1182
|
+
* @throws `API_KEY_REVOKED` if the key was revoked.
|
|
1183
|
+
* @throws `API_KEY_EXPIRED` if the key is past its `expiresAt`.
|
|
1184
|
+
* @throws `API_KEY_RATE_LIMITED` if the rate limit is exceeded.
|
|
1256
1185
|
*
|
|
1257
1186
|
* @example
|
|
1258
1187
|
* ```ts
|
|
1259
|
-
* const
|
|
1260
|
-
*
|
|
1261
|
-
* const canRead = result.scopes.can("data", "read");
|
|
1188
|
+
* const { userId, scopes } = await auth.key.verify(ctx, rawKey);
|
|
1189
|
+
* const canRead = scopes.can("data", "read");
|
|
1262
1190
|
* ```
|
|
1263
1191
|
*/
|
|
1264
1192
|
verify: (ctx: ComponentCtx, rawKey: string) => Promise<{
|
|
1265
|
-
ok: true;
|
|
1266
1193
|
userId: string;
|
|
1267
1194
|
keyId: string;
|
|
1268
1195
|
scopes: ScopeChecker;
|
|
1269
|
-
} | {
|
|
1270
|
-
ok: false;
|
|
1271
|
-
code: "INVALID_API_KEY" | "API_KEY_REVOKED" | "API_KEY_EXPIRED" | "API_KEY_RATE_LIMITED";
|
|
1272
1196
|
}>;
|
|
1273
1197
|
/**
|
|
1274
1198
|
* List API keys with optional filtering by user, revocation status, name,
|
|
@@ -1312,21 +1236,16 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1312
1236
|
*
|
|
1313
1237
|
* @param ctx - Convex query or mutation context.
|
|
1314
1238
|
* @param keyId - The API key's document ID.
|
|
1315
|
-
* @returns
|
|
1239
|
+
* @returns The key document, or `null` if not found.
|
|
1316
1240
|
*
|
|
1317
1241
|
* @example
|
|
1318
1242
|
* ```ts
|
|
1319
|
-
* const
|
|
1320
|
-
* if (!
|
|
1321
|
-
* console.log(
|
|
1243
|
+
* const key = await auth.key.get(ctx, keyId);
|
|
1244
|
+
* if (!key) throw new Error("Key not found");
|
|
1245
|
+
* console.log(key.name, key.prefix);
|
|
1322
1246
|
* ```
|
|
1323
1247
|
*/
|
|
1324
|
-
get: (ctx: ComponentReadCtx, keyId: string) => Promise<
|
|
1325
|
-
ok: true;
|
|
1326
|
-
key: KeyDoc;
|
|
1327
|
-
} | {
|
|
1328
|
-
ok: false;
|
|
1329
|
-
}>;
|
|
1248
|
+
get: (ctx: ComponentReadCtx, keyId: string) => Promise<KeyDoc | null>;
|
|
1330
1249
|
/**
|
|
1331
1250
|
* Update a key's name, scopes, or rate limit.
|
|
1332
1251
|
*
|
|
@@ -1336,7 +1255,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1336
1255
|
* @param ctx - Convex mutation context.
|
|
1337
1256
|
* @param keyId - The API key's document ID.
|
|
1338
1257
|
* @param data - Fields to merge into the key document.
|
|
1339
|
-
* @returns `{
|
|
1258
|
+
* @returns `{ keyId }`.
|
|
1340
1259
|
*
|
|
1341
1260
|
* @example
|
|
1342
1261
|
* ```ts
|
|
@@ -1354,19 +1273,18 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1354
1273
|
windowMs: number;
|
|
1355
1274
|
};
|
|
1356
1275
|
}) => Promise<{
|
|
1357
|
-
ok: true;
|
|
1358
1276
|
keyId: string;
|
|
1359
1277
|
}>;
|
|
1360
1278
|
/**
|
|
1361
1279
|
* Soft-delete: set `revoked: true`. The key can no longer be verified.
|
|
1362
1280
|
*
|
|
1363
1281
|
* After revocation, any subsequent calls to `auth.key.verify` with
|
|
1364
|
-
* this key will
|
|
1282
|
+
* this key will throw `API_KEY_REVOKED`.
|
|
1365
1283
|
* The key record is preserved for audit purposes.
|
|
1366
1284
|
*
|
|
1367
1285
|
* @param ctx - Convex mutation context.
|
|
1368
1286
|
* @param keyId - The API key's document ID.
|
|
1369
|
-
* @returns `{
|
|
1287
|
+
* @returns `{ keyId }`.
|
|
1370
1288
|
*
|
|
1371
1289
|
* @example
|
|
1372
1290
|
* ```ts
|
|
@@ -1374,7 +1292,6 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1374
1292
|
* ```
|
|
1375
1293
|
*/
|
|
1376
1294
|
revoke: (ctx: ComponentCtx, keyId: string) => Promise<{
|
|
1377
|
-
ok: true;
|
|
1378
1295
|
keyId: string;
|
|
1379
1296
|
}>;
|
|
1380
1297
|
/**
|
|
@@ -1386,7 +1303,7 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1386
1303
|
*
|
|
1387
1304
|
* @param ctx - Convex mutation context.
|
|
1388
1305
|
* @param keyId - The API key's document ID.
|
|
1389
|
-
* @returns `{
|
|
1306
|
+
* @returns `{ keyId }`.
|
|
1390
1307
|
*
|
|
1391
1308
|
* @example
|
|
1392
1309
|
* ```ts
|
|
@@ -1394,40 +1311,35 @@ declare function createCoreDomains(deps: CoreDeps): {
|
|
|
1394
1311
|
* ```
|
|
1395
1312
|
*/
|
|
1396
1313
|
delete: (ctx: ComponentCtx, keyId: string) => Promise<{
|
|
1397
|
-
ok: true;
|
|
1398
1314
|
keyId: string;
|
|
1399
1315
|
}>;
|
|
1400
1316
|
/**
|
|
1401
1317
|
* Rotate a key: revokes the old key and creates a new one with the
|
|
1402
1318
|
* same user, scopes, and rate limit. Returns the new `keyId` and `secret`.
|
|
1403
|
-
*
|
|
1319
|
+
* Throws if the key does not exist or is already revoked.
|
|
1404
1320
|
*
|
|
1405
1321
|
* @param ctx - Convex mutation context.
|
|
1406
1322
|
* @param keyId - The existing API key's document ID to rotate.
|
|
1407
1323
|
* @param opts.name - Optional new name for the rotated key (defaults to the old name).
|
|
1408
1324
|
* @param opts.expiresAt - Optional new expiration timestamp in ms since epoch.
|
|
1409
|
-
* @returns `{
|
|
1325
|
+
* @returns `{ keyId, secret }` with the new key.
|
|
1326
|
+
* @throws `INVALID_PARAMETERS` if the key does not exist.
|
|
1327
|
+
* @throws `API_KEY_REVOKED` if the key is already revoked.
|
|
1410
1328
|
*
|
|
1411
1329
|
* @example
|
|
1412
1330
|
* ```ts
|
|
1413
|
-
* const
|
|
1331
|
+
* const { keyId, secret } = await auth.key.rotate(ctx, oldKeyId, {
|
|
1414
1332
|
* expiresAt: Date.now() + 30 * 24 * 60 * 60 * 1000, // 30 days
|
|
1415
1333
|
* });
|
|
1416
|
-
*
|
|
1417
|
-
* // Store result.secret securely — shown only once
|
|
1418
|
-
* }
|
|
1334
|
+
* // Store secret securely — shown only once
|
|
1419
1335
|
* ```
|
|
1420
1336
|
*/
|
|
1421
1337
|
rotate: (ctx: ComponentCtx, keyId: string, opts?: {
|
|
1422
1338
|
name?: string;
|
|
1423
1339
|
expiresAt?: number;
|
|
1424
1340
|
}) => Promise<{
|
|
1425
|
-
ok: true;
|
|
1426
1341
|
keyId: string;
|
|
1427
1342
|
secret: string;
|
|
1428
|
-
} | {
|
|
1429
|
-
ok: false;
|
|
1430
|
-
code: "INVALID_PARAMETERS" | "API_KEY_REVOKED";
|
|
1431
1343
|
}>;
|
|
1432
1344
|
};
|
|
1433
1345
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","names":[],"sources":["../../src/server/core.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"core.d.ts","names":[],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