@robelest/convex-auth 0.0.2-preview.0 → 0.0.2-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +17 -15
- package/dist/client/index.d.ts +84 -30
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +259 -59
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +46 -120
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/index.d.ts +2 -4
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js +2 -4
- package/dist/component/index.js.map +1 -1
- package/dist/component/public.d.ts +233 -167
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +328 -155
- package/dist/component/public.js.map +1 -1
- package/dist/component/schema.d.ts +127 -12
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +136 -10
- package/dist/component/schema.js.map +1 -1
- package/dist/providers/{Anonymous.d.ts → anonymous.d.ts} +8 -8
- package/dist/providers/{Anonymous.d.ts.map → anonymous.d.ts.map} +1 -1
- package/dist/providers/{Anonymous.js → anonymous.js} +9 -10
- package/dist/providers/anonymous.js.map +1 -0
- package/dist/providers/{ConvexCredentials.d.ts → credentials.d.ts} +11 -11
- package/dist/providers/credentials.d.ts.map +1 -0
- package/dist/providers/{ConvexCredentials.js → credentials.js} +8 -8
- package/dist/providers/credentials.js.map +1 -0
- package/dist/providers/{Email.d.ts → email.d.ts} +6 -6
- package/dist/providers/email.d.ts.map +1 -0
- package/dist/providers/{Email.js → email.js} +6 -6
- package/dist/providers/email.js.map +1 -0
- package/dist/providers/{Password.d.ts → password.d.ts} +10 -10
- package/dist/providers/{Password.d.ts.map → password.d.ts.map} +1 -1
- package/dist/providers/{Password.js → password.js} +19 -20
- package/dist/providers/password.js.map +1 -0
- package/dist/providers/{Phone.d.ts → phone.d.ts} +3 -3
- package/dist/providers/{Phone.d.ts.map → phone.d.ts.map} +1 -1
- package/dist/providers/{Phone.js → phone.js} +3 -3
- package/dist/providers/{Phone.js.map → phone.js.map} +1 -1
- package/dist/server/implementation/db.d.ts +5 -2
- package/dist/server/implementation/db.d.ts.map +1 -1
- package/dist/server/implementation/db.js +2 -1
- package/dist/server/implementation/db.js.map +1 -1
- package/dist/server/implementation/index.d.ts +285 -180
- package/dist/server/implementation/index.d.ts.map +1 -1
- package/dist/server/implementation/index.js +280 -173
- package/dist/server/implementation/index.js.map +1 -1
- package/dist/server/implementation/mutations/createAccountFromCredentials.d.ts.map +1 -1
- package/dist/server/implementation/mutations/createAccountFromCredentials.js +8 -18
- package/dist/server/implementation/mutations/createAccountFromCredentials.js.map +1 -1
- package/dist/server/implementation/mutations/createVerificationCode.d.ts.map +1 -1
- package/dist/server/implementation/mutations/createVerificationCode.js +16 -44
- package/dist/server/implementation/mutations/createVerificationCode.js.map +1 -1
- package/dist/server/implementation/mutations/invalidateSessions.d.ts.map +1 -1
- package/dist/server/implementation/mutations/invalidateSessions.js +4 -8
- package/dist/server/implementation/mutations/invalidateSessions.js.map +1 -1
- package/dist/server/implementation/mutations/modifyAccount.d.ts.map +1 -1
- package/dist/server/implementation/mutations/modifyAccount.js +8 -19
- package/dist/server/implementation/mutations/modifyAccount.js.map +1 -1
- package/dist/server/implementation/mutations/refreshSession.d.ts.map +1 -1
- package/dist/server/implementation/mutations/refreshSession.js +9 -23
- package/dist/server/implementation/mutations/refreshSession.js.map +1 -1
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.d.ts.map +1 -1
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js +6 -12
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js.map +1 -1
- package/dist/server/implementation/mutations/signIn.d.ts.map +1 -1
- package/dist/server/implementation/mutations/signIn.js +2 -1
- package/dist/server/implementation/mutations/signIn.js.map +1 -1
- package/dist/server/implementation/mutations/signOut.d.ts.map +1 -1
- package/dist/server/implementation/mutations/signOut.js +5 -6
- package/dist/server/implementation/mutations/signOut.js.map +1 -1
- package/dist/server/implementation/mutations/storeRef.d.ts +8 -0
- package/dist/server/implementation/mutations/storeRef.d.ts.map +1 -0
- package/dist/server/implementation/mutations/storeRef.js +8 -0
- package/dist/server/implementation/mutations/storeRef.js.map +1 -0
- package/dist/server/implementation/mutations/userOAuth.d.ts.map +1 -1
- package/dist/server/implementation/mutations/userOAuth.js +16 -53
- package/dist/server/implementation/mutations/userOAuth.js.map +1 -1
- package/dist/server/implementation/mutations/verifier.d.ts.map +1 -1
- package/dist/server/implementation/mutations/verifier.js +4 -8
- package/dist/server/implementation/mutations/verifier.js.map +1 -1
- package/dist/server/implementation/mutations/verifierSignature.d.ts.map +1 -1
- package/dist/server/implementation/mutations/verifierSignature.js +6 -10
- package/dist/server/implementation/mutations/verifierSignature.js.map +1 -1
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.d.ts.map +1 -1
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.js +7 -16
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.js.map +1 -1
- package/dist/server/implementation/provider.d.ts +2 -1
- package/dist/server/implementation/provider.d.ts.map +1 -1
- package/dist/server/implementation/provider.js.map +1 -1
- package/dist/server/implementation/rateLimit.d.ts.map +1 -1
- package/dist/server/implementation/rateLimit.js +13 -39
- package/dist/server/implementation/rateLimit.js.map +1 -1
- package/dist/server/implementation/refreshTokens.d.ts +1 -8
- package/dist/server/implementation/refreshTokens.d.ts.map +1 -1
- package/dist/server/implementation/refreshTokens.js +14 -58
- package/dist/server/implementation/refreshTokens.js.map +1 -1
- package/dist/server/implementation/sessions.d.ts +2 -20
- package/dist/server/implementation/sessions.d.ts.map +1 -1
- package/dist/server/implementation/sessions.js +8 -35
- package/dist/server/implementation/sessions.js.map +1 -1
- package/dist/server/implementation/types.d.ts +11 -267
- package/dist/server/implementation/types.d.ts.map +1 -1
- package/dist/server/implementation/types.js +1 -181
- package/dist/server/implementation/types.js.map +1 -1
- package/dist/server/implementation/users.d.ts.map +1 -1
- package/dist/server/implementation/users.js +19 -67
- package/dist/server/implementation/users.js.map +1 -1
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +255 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/provider_utils.d.ts +1 -1
- package/dist/server/provider_utils.d.ts.map +1 -1
- package/dist/server/provider_utils.js +2 -2
- package/dist/server/provider_utils.js.map +1 -1
- package/dist/server/types.d.ts +91 -52
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +3 -6
- package/src/cli/index.ts +20 -19
- package/src/client/index.ts +347 -110
- package/src/component/_generated/component.ts +55 -214
- package/src/component/index.ts +1 -11
- package/src/component/public.ts +366 -178
- package/src/component/schema.ts +150 -19
- package/src/providers/{Anonymous.ts → anonymous.ts} +10 -11
- package/src/providers/{ConvexCredentials.ts → credentials.ts} +11 -11
- package/src/providers/{Email.ts → email.ts} +5 -5
- package/src/providers/{Password.ts → password.ts} +22 -27
- package/src/providers/{Phone.ts → phone.ts} +2 -2
- package/src/server/implementation/db.ts +5 -2
- package/src/server/implementation/index.ts +368 -313
- package/src/server/implementation/mutations/createAccountFromCredentials.ts +11 -25
- package/src/server/implementation/mutations/createVerificationCode.ts +16 -47
- package/src/server/implementation/mutations/invalidateSessions.ts +4 -9
- package/src/server/implementation/mutations/modifyAccount.ts +8 -22
- package/src/server/implementation/mutations/refreshSession.ts +11 -24
- package/src/server/implementation/mutations/retrieveAccountWithCredentials.ts +9 -17
- package/src/server/implementation/mutations/signIn.ts +2 -1
- package/src/server/implementation/mutations/signOut.ts +5 -8
- package/src/server/implementation/mutations/storeRef.ts +7 -0
- package/src/server/implementation/mutations/userOAuth.ts +10 -50
- package/src/server/implementation/mutations/verifier.ts +4 -9
- package/src/server/implementation/mutations/verifierSignature.ts +6 -12
- package/src/server/implementation/mutations/verifyCodeAndSignIn.ts +7 -18
- package/src/server/implementation/provider.ts +2 -1
- package/src/server/implementation/rateLimit.ts +15 -41
- package/src/server/implementation/refreshTokens.ts +26 -76
- package/src/server/implementation/sessions.ts +8 -39
- package/src/server/implementation/types.ts +16 -191
- package/src/server/implementation/users.ts +19 -66
- package/src/server/index.ts +373 -0
- package/src/server/provider_utils.ts +2 -2
- package/src/server/types.ts +116 -51
- package/dist/providers/Anonymous.js.map +0 -1
- package/dist/providers/ConvexCredentials.d.ts.map +0 -1
- package/dist/providers/ConvexCredentials.js.map +0 -1
- package/dist/providers/Email.d.ts.map +0 -1
- package/dist/providers/Email.js.map +0 -1
- package/dist/providers/Password.js.map +0 -1
- package/providers/Anonymous/package.json +0 -6
- package/providers/ConvexCredentials/package.json +0 -6
- package/providers/Email/package.json +0 -6
- package/providers/Password/package.json +0 -6
- package/providers/Phone/package.json +0 -6
- package/server/package.json +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAkBrC,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,EAC/B,cAAc,EAAE,OAAO,GACtB,OAAO,CAAC,WAAW,CAAC,CAatB;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,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
2
|
import { generateToken } from "./tokens.js";
|
|
3
3
|
import { createRefreshToken, formatRefreshToken, deleteAllRefreshTokens, } from "./refreshTokens.js";
|
|
4
|
-
import {
|
|
4
|
+
import { authDb } from "./db.js";
|
|
5
5
|
const DEFAULT_SESSION_TOTAL_DURATION_MS = 1000 * 60 * 60 * 24 * 30; // 30 days
|
|
6
6
|
export async function maybeGenerateTokensForSession(ctx, config, userId, sessionId, generateTokens) {
|
|
7
7
|
return {
|
|
@@ -18,12 +18,10 @@ export async function maybeGenerateTokensForSession(ctx, config, userId, session
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export async function createNewAndDeleteExistingSession(ctx, config, userId) {
|
|
21
|
-
const
|
|
21
|
+
const db = authDb(ctx, config);
|
|
22
22
|
const existingSessionId = await getAuthSessionId(ctx);
|
|
23
23
|
if (existingSessionId !== null) {
|
|
24
|
-
const existingSession =
|
|
25
|
-
? await authDb.sessions.getById(existingSessionId)
|
|
26
|
-
: await ctx.db.get(existingSessionId);
|
|
24
|
+
const existingSession = await db.sessions.getById(existingSessionId);
|
|
27
25
|
if (existingSession !== null) {
|
|
28
26
|
await deleteSession(ctx, existingSession, config);
|
|
29
27
|
}
|
|
@@ -42,46 +40,21 @@ export async function generateTokensForSession(ctx, config, args) {
|
|
|
42
40
|
return result;
|
|
43
41
|
}
|
|
44
42
|
async function createSession(ctx, userId, config) {
|
|
43
|
+
const db = authDb(ctx, config);
|
|
45
44
|
const expirationTime = Date.now() +
|
|
46
45
|
(config.session?.totalDurationMs ??
|
|
47
46
|
stringToNumber(process.env.AUTH_SESSION_TOTAL_DURATION_MS) ??
|
|
48
47
|
DEFAULT_SESSION_TOTAL_DURATION_MS);
|
|
49
|
-
|
|
50
|
-
return (await createAuthDb(ctx, config.component).sessions.create(userId, expirationTime));
|
|
51
|
-
}
|
|
52
|
-
return await ctx.db.insert("session", { expirationTime, userId });
|
|
48
|
+
return (await db.sessions.create(userId, expirationTime));
|
|
53
49
|
}
|
|
54
50
|
export async function deleteSession(ctx, session, config) {
|
|
55
|
-
|
|
56
|
-
await createAuthDb(ctx, config.component).sessions.delete(session._id);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
await ctx.db.delete(session._id);
|
|
60
|
-
}
|
|
51
|
+
await authDb(ctx, config).sessions.delete(session._id);
|
|
61
52
|
await deleteAllRefreshTokens(ctx, session._id, config);
|
|
62
53
|
}
|
|
63
54
|
/**
|
|
64
|
-
* Return the current session ID.
|
|
65
|
-
*
|
|
66
|
-
* ```ts filename="convex/myFunctions.tsx"
|
|
67
|
-
* import { mutation } from "./_generated/server";
|
|
68
|
-
* import { getAuthSessionId } from "@robelest/convex-auth/component";
|
|
69
|
-
*
|
|
70
|
-
* export const doSomething = mutation({
|
|
71
|
-
* args: {/* ... *\/},
|
|
72
|
-
* handler: async (ctx, args) => {
|
|
73
|
-
* const sessionId = await getAuthSessionId(ctx);
|
|
74
|
-
* if (sessionId === null) {
|
|
75
|
-
* throw new Error("Client is not authenticated!")
|
|
76
|
-
* }
|
|
77
|
-
* const session = await ctx.db.get(sessionId);
|
|
78
|
-
* // ...
|
|
79
|
-
* },
|
|
80
|
-
* });
|
|
81
|
-
* ```
|
|
55
|
+
* Return the current session ID from the auth identity subject.
|
|
82
56
|
*
|
|
83
|
-
*
|
|
84
|
-
* @returns the session ID or `null` if the client isn't authenticated
|
|
57
|
+
* Internal helper used by auth runtime internals and `auth.session.current`.
|
|
85
58
|
*/
|
|
86
59
|
export async function getAuthSessionId(ctx) {
|
|
87
60
|
const identity = await ctx.auth.getUserIdentity();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/server/implementation/sessions.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/server/implementation/sessions.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,iCAAiC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAE9E,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,GAAgB,EAChB,MAAwB,EACxB,MAAyB,EACzB,SAA+B,EAC/B,cAAuB;IAEvB,OAAO;QACL,MAAM;QACN,SAAS;QACT,MAAM,EAAE,cAAc;YACpB,CAAC,CAAC,MAAM,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE;gBAC1C,MAAM;gBACN,SAAS;gBACT,oBAAoB,EAAE,IAAI;gBAC1B,oBAAoB,EAAE,IAAI;aAC3B,CAAC;YACJ,CAAC,CAAC,IAAI;KACT,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,GAAgB,EAChB,MAAwB,EACxB,MAAyB;IAEzB,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtD,IAAI,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAC/B,MAAM,eAAe,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAA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8BAA8B,CAAC;YAC1D,iCAAiC,CAAC,CAAC;IACvC,OAAO,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAyB,CAAC;AACpF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAgB,EAChB,OAAuB,EACvB,MAAwB;IAExB,MAAM,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAmB;IACxD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IAClD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACtE,OAAO,SAAiC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,288 +1,32 @@
|
|
|
1
|
-
import { DataModelFromSchemaDefinition, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, TableNamesInDataModel
|
|
1
|
+
import { DataModelFromSchemaDefinition, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, TableNamesInDataModel } from "convex/server";
|
|
2
2
|
import { GenericId } from "convex/values";
|
|
3
3
|
import { GenericDoc } from "../convex_types.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* are set up:
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* ```ts filename="convex/schema.ts"
|
|
12
|
-
* import { defineSchema } from "convex/server";
|
|
13
|
-
* import { authTables } from "@robelest/convex-auth/component";
|
|
14
|
-
*
|
|
15
|
-
* const schema = defineSchema({
|
|
16
|
-
* ...authTables,
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* export default schema;
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* You can inline the table definitions into your schema
|
|
23
|
-
* and extend them with additional optional and required
|
|
24
|
-
* fields. See https://labs.convex.dev/auth/setup/schema
|
|
25
|
-
* for more details.
|
|
26
|
-
*/
|
|
27
|
-
export declare const authTables: {
|
|
28
|
-
/**
|
|
29
|
-
* Users.
|
|
30
|
-
*/
|
|
31
|
-
user: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
32
|
-
name?: string | undefined;
|
|
33
|
-
email?: string | undefined;
|
|
34
|
-
phone?: string | undefined;
|
|
35
|
-
image?: string | undefined;
|
|
36
|
-
emailVerificationTime?: number | undefined;
|
|
37
|
-
phoneVerificationTime?: number | undefined;
|
|
38
|
-
isAnonymous?: boolean | undefined;
|
|
39
|
-
}, {
|
|
40
|
-
name: import("convex/values").VString<string | undefined, "optional">;
|
|
41
|
-
image: import("convex/values").VString<string | undefined, "optional">;
|
|
42
|
-
email: import("convex/values").VString<string | undefined, "optional">;
|
|
43
|
-
emailVerificationTime: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
44
|
-
phone: import("convex/values").VString<string | undefined, "optional">;
|
|
45
|
-
phoneVerificationTime: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
46
|
-
isAnonymous: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
47
|
-
}, "required", "name" | "email" | "phone" | "image" | "emailVerificationTime" | "phoneVerificationTime" | "isAnonymous">, {
|
|
48
|
-
email: ["email", "_creationTime"];
|
|
49
|
-
phone: ["phone", "_creationTime"];
|
|
50
|
-
}, {}, {}>;
|
|
51
|
-
/**
|
|
52
|
-
* Sessions.
|
|
53
|
-
* A single user can have multiple active sessions.
|
|
54
|
-
* See [Session document lifecycle](https://labs.convex.dev/auth/advanced#session-document-lifecycle).
|
|
55
|
-
*/
|
|
56
|
-
session: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
57
|
-
userId: GenericId<"user">;
|
|
58
|
-
expirationTime: number;
|
|
59
|
-
}, {
|
|
60
|
-
userId: import("convex/values").VId<GenericId<"user">, "required">;
|
|
61
|
-
expirationTime: import("convex/values").VFloat64<number, "required">;
|
|
62
|
-
}, "required", "userId" | "expirationTime">, {
|
|
63
|
-
userId: ["userId", "_creationTime"];
|
|
64
|
-
}, {}, {}>;
|
|
65
|
-
/**
|
|
66
|
-
* Accounts. An account corresponds to
|
|
67
|
-
* a single authentication provider.
|
|
68
|
-
* A single user can have multiple accounts linked.
|
|
69
|
-
*/
|
|
70
|
-
account: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
71
|
-
secret?: string | undefined;
|
|
72
|
-
emailVerified?: string | undefined;
|
|
73
|
-
phoneVerified?: string | undefined;
|
|
74
|
-
userId: GenericId<"user">;
|
|
75
|
-
provider: string;
|
|
76
|
-
providerAccountId: string;
|
|
77
|
-
}, {
|
|
78
|
-
userId: import("convex/values").VId<GenericId<"user">, "required">;
|
|
79
|
-
provider: import("convex/values").VString<string, "required">;
|
|
80
|
-
providerAccountId: import("convex/values").VString<string, "required">;
|
|
81
|
-
secret: import("convex/values").VString<string | undefined, "optional">;
|
|
82
|
-
emailVerified: import("convex/values").VString<string | undefined, "optional">;
|
|
83
|
-
phoneVerified: import("convex/values").VString<string | undefined, "optional">;
|
|
84
|
-
}, "required", "secret" | "userId" | "provider" | "providerAccountId" | "emailVerified" | "phoneVerified">, {
|
|
85
|
-
userIdAndProvider: ["userId", "provider", "_creationTime"];
|
|
86
|
-
providerAndAccountId: ["provider", "providerAccountId", "_creationTime"];
|
|
87
|
-
}, {}, {}>;
|
|
88
|
-
/**
|
|
89
|
-
* Refresh tokens.
|
|
90
|
-
* Refresh tokens are generally meant to be used once, to be exchanged for another
|
|
91
|
-
* refresh token and a JWT access token, but with a few exceptions:
|
|
92
|
-
* - The "active refresh token" is the most recently created refresh token that has
|
|
93
|
-
* not been used yet. The parent of the active refresh token can always be used to
|
|
94
|
-
* obtain the active refresh token.
|
|
95
|
-
* - A refresh token can be used within a 10 second window ("reuse window") to
|
|
96
|
-
* obtain a new refresh token.
|
|
97
|
-
* - On any invalid use of a refresh token, the token itself and all its descendants
|
|
98
|
-
* are invalidated.
|
|
99
|
-
*/
|
|
100
|
-
token: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
101
|
-
firstUsedTime?: number | undefined;
|
|
102
|
-
parentRefreshTokenId?: GenericId<"token"> | undefined;
|
|
103
|
-
expirationTime: number;
|
|
104
|
-
sessionId: GenericId<"session">;
|
|
105
|
-
}, {
|
|
106
|
-
sessionId: import("convex/values").VId<GenericId<"session">, "required">;
|
|
107
|
-
expirationTime: import("convex/values").VFloat64<number, "required">;
|
|
108
|
-
firstUsedTime: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
109
|
-
parentRefreshTokenId: import("convex/values").VId<GenericId<"token"> | undefined, "optional">;
|
|
110
|
-
}, "required", "expirationTime" | "sessionId" | "firstUsedTime" | "parentRefreshTokenId">, {
|
|
111
|
-
sessionId: ["sessionId", "_creationTime"];
|
|
112
|
-
sessionIdAndParentRefreshTokenId: ["sessionId", "parentRefreshTokenId", "_creationTime"];
|
|
113
|
-
}, {}, {}>;
|
|
114
|
-
/**
|
|
115
|
-
* Verification codes:
|
|
116
|
-
* - OTP tokens
|
|
117
|
-
* - magic link tokens
|
|
118
|
-
* - OAuth codes
|
|
119
|
-
*/
|
|
120
|
-
verification: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
121
|
-
emailVerified?: string | undefined;
|
|
122
|
-
phoneVerified?: string | undefined;
|
|
123
|
-
verifier?: string | undefined;
|
|
124
|
-
expirationTime: number;
|
|
125
|
-
provider: string;
|
|
126
|
-
accountId: GenericId<"account">;
|
|
127
|
-
code: string;
|
|
128
|
-
}, {
|
|
129
|
-
accountId: import("convex/values").VId<GenericId<"account">, "required">;
|
|
130
|
-
provider: import("convex/values").VString<string, "required">;
|
|
131
|
-
code: import("convex/values").VString<string, "required">;
|
|
132
|
-
expirationTime: import("convex/values").VFloat64<number, "required">;
|
|
133
|
-
verifier: import("convex/values").VString<string | undefined, "optional">;
|
|
134
|
-
emailVerified: import("convex/values").VString<string | undefined, "optional">;
|
|
135
|
-
phoneVerified: import("convex/values").VString<string | undefined, "optional">;
|
|
136
|
-
}, "required", "expirationTime" | "provider" | "emailVerified" | "phoneVerified" | "accountId" | "code" | "verifier">, {
|
|
137
|
-
accountId: ["accountId", "_creationTime"];
|
|
138
|
-
code: ["code", "_creationTime"];
|
|
139
|
-
}, {}, {}>;
|
|
140
|
-
/**
|
|
141
|
-
* PKCE verifiers for OAuth.
|
|
142
|
-
*/
|
|
143
|
-
verifier: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
144
|
-
sessionId?: GenericId<"session"> | undefined;
|
|
145
|
-
signature?: string | undefined;
|
|
146
|
-
}, {
|
|
147
|
-
sessionId: import("convex/values").VId<GenericId<"session"> | undefined, "optional">;
|
|
148
|
-
signature: import("convex/values").VString<string | undefined, "optional">;
|
|
149
|
-
}, "required", "sessionId" | "signature">, {
|
|
150
|
-
signature: ["signature", "_creationTime"];
|
|
151
|
-
}, {}, {}>;
|
|
152
|
-
/**
|
|
153
|
-
* Rate limits for OTP and password sign-in.
|
|
154
|
-
*/
|
|
155
|
-
limit: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
156
|
-
identifier: string;
|
|
157
|
-
lastAttemptTime: number;
|
|
158
|
-
attemptsLeft: number;
|
|
159
|
-
}, {
|
|
160
|
-
identifier: import("convex/values").VString<string, "required">;
|
|
161
|
-
lastAttemptTime: import("convex/values").VFloat64<number, "required">;
|
|
162
|
-
attemptsLeft: import("convex/values").VFloat64<number, "required">;
|
|
163
|
-
}, "required", "identifier" | "lastAttemptTime" | "attemptsLeft">, {
|
|
164
|
-
identifier: ["identifier", "_creationTime"];
|
|
165
|
-
}, {}, {}>;
|
|
166
|
-
organization: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
167
|
-
slug?: string | undefined;
|
|
168
|
-
ownerUserId?: GenericId<"user"> | undefined;
|
|
169
|
-
parentOrganizationId?: GenericId<"organization"> | undefined;
|
|
170
|
-
metadata?: any;
|
|
171
|
-
name: string;
|
|
172
|
-
}, {
|
|
173
|
-
name: import("convex/values").VString<string, "required">;
|
|
174
|
-
slug: import("convex/values").VString<string | undefined, "optional">;
|
|
175
|
-
ownerUserId: import("convex/values").VId<GenericId<"user"> | undefined, "optional">;
|
|
176
|
-
parentOrganizationId: import("convex/values").VId<GenericId<"organization"> | undefined, "optional">;
|
|
177
|
-
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
178
|
-
}, "required", "name" | "slug" | "ownerUserId" | "parentOrganizationId" | "metadata" | `metadata.${string}`>, {
|
|
179
|
-
slug: ["slug", "_creationTime"];
|
|
180
|
-
ownerUserId: ["ownerUserId", "_creationTime"];
|
|
181
|
-
parentOrganizationId: ["parentOrganizationId", "_creationTime"];
|
|
182
|
-
}, {}, {}>;
|
|
183
|
-
team: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
184
|
-
slug?: string | undefined;
|
|
185
|
-
metadata?: any;
|
|
186
|
-
parentTeamId?: GenericId<"team"> | undefined;
|
|
187
|
-
name: string;
|
|
188
|
-
organizationId: GenericId<"organization">;
|
|
189
|
-
}, {
|
|
190
|
-
organizationId: import("convex/values").VId<GenericId<"organization">, "required">;
|
|
191
|
-
name: import("convex/values").VString<string, "required">;
|
|
192
|
-
slug: import("convex/values").VString<string | undefined, "optional">;
|
|
193
|
-
parentTeamId: import("convex/values").VId<GenericId<"team"> | undefined, "optional">;
|
|
194
|
-
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
195
|
-
}, "required", "name" | "slug" | "metadata" | `metadata.${string}` | "organizationId" | "parentTeamId">, {
|
|
196
|
-
organizationId: ["organizationId", "_creationTime"];
|
|
197
|
-
organizationIdAndSlug: ["organizationId", "slug", "_creationTime"];
|
|
198
|
-
parentTeamId: ["parentTeamId", "_creationTime"];
|
|
199
|
-
}, {}, {}>;
|
|
200
|
-
teamRelation: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
201
|
-
relation?: string | undefined;
|
|
202
|
-
organizationId: GenericId<"organization">;
|
|
203
|
-
parentTeamId: GenericId<"team">;
|
|
204
|
-
childTeamId: GenericId<"team">;
|
|
205
|
-
}, {
|
|
206
|
-
organizationId: import("convex/values").VId<GenericId<"organization">, "required">;
|
|
207
|
-
parentTeamId: import("convex/values").VId<GenericId<"team">, "required">;
|
|
208
|
-
childTeamId: import("convex/values").VId<GenericId<"team">, "required">;
|
|
209
|
-
relation: import("convex/values").VString<string | undefined, "optional">;
|
|
210
|
-
}, "required", "organizationId" | "parentTeamId" | "childTeamId" | "relation">, {
|
|
211
|
-
organizationId: ["organizationId", "_creationTime"];
|
|
212
|
-
organizationIdAndParentTeamId: ["organizationId", "parentTeamId", "_creationTime"];
|
|
213
|
-
organizationIdAndChildTeamId: ["organizationId", "childTeamId", "_creationTime"];
|
|
214
|
-
}, {}, {}>;
|
|
215
|
-
member: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
216
|
-
metadata?: any;
|
|
217
|
-
teamId?: GenericId<"team"> | undefined;
|
|
218
|
-
role?: string | undefined;
|
|
219
|
-
status?: string | undefined;
|
|
220
|
-
userId: GenericId<"user">;
|
|
221
|
-
organizationId: GenericId<"organization">;
|
|
222
|
-
}, {
|
|
223
|
-
organizationId: import("convex/values").VId<GenericId<"organization">, "required">;
|
|
224
|
-
userId: import("convex/values").VId<GenericId<"user">, "required">;
|
|
225
|
-
teamId: import("convex/values").VId<GenericId<"team"> | undefined, "optional">;
|
|
226
|
-
role: import("convex/values").VString<string | undefined, "optional">;
|
|
227
|
-
status: import("convex/values").VString<string | undefined, "optional">;
|
|
228
|
-
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
229
|
-
}, "required", "userId" | "metadata" | `metadata.${string}` | "organizationId" | "teamId" | "role" | "status">, {
|
|
230
|
-
organizationId: ["organizationId", "_creationTime"];
|
|
231
|
-
organizationIdAndUserId: ["organizationId", "userId", "_creationTime"];
|
|
232
|
-
teamId: ["teamId", "_creationTime"];
|
|
233
|
-
userId: ["userId", "_creationTime"];
|
|
234
|
-
}, {}, {}>;
|
|
235
|
-
invite: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
236
|
-
metadata?: any;
|
|
237
|
-
organizationId?: GenericId<"organization"> | undefined;
|
|
238
|
-
teamId?: GenericId<"team"> | undefined;
|
|
239
|
-
role?: string | undefined;
|
|
240
|
-
acceptedByUserId?: GenericId<"user"> | undefined;
|
|
241
|
-
acceptedTime?: number | undefined;
|
|
242
|
-
email: string;
|
|
243
|
-
status: "pending" | "accepted" | "revoked" | "expired";
|
|
244
|
-
invitedByUserId: GenericId<"user">;
|
|
245
|
-
tokenHash: string;
|
|
246
|
-
expiresTime: number;
|
|
247
|
-
}, {
|
|
248
|
-
organizationId: import("convex/values").VId<GenericId<"organization"> | undefined, "optional">;
|
|
249
|
-
teamId: import("convex/values").VId<GenericId<"team"> | undefined, "optional">;
|
|
250
|
-
invitedByUserId: import("convex/values").VId<GenericId<"user">, "required">;
|
|
251
|
-
email: import("convex/values").VString<string, "required">;
|
|
252
|
-
tokenHash: import("convex/values").VString<string, "required">;
|
|
253
|
-
role: import("convex/values").VString<string | undefined, "optional">;
|
|
254
|
-
status: import("convex/values").VUnion<"pending" | "accepted" | "revoked" | "expired", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"revoked", "required">, import("convex/values").VLiteral<"expired", "required">], "required", never>;
|
|
255
|
-
expiresTime: import("convex/values").VFloat64<number, "required">;
|
|
256
|
-
acceptedByUserId: import("convex/values").VId<GenericId<"user"> | undefined, "optional">;
|
|
257
|
-
acceptedTime: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
258
|
-
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
259
|
-
}, "required", "email" | "metadata" | `metadata.${string}` | "organizationId" | "teamId" | "role" | "status" | "invitedByUserId" | "tokenHash" | "expiresTime" | "acceptedByUserId" | "acceptedTime">, {
|
|
260
|
-
tokenHash: ["tokenHash", "_creationTime"];
|
|
261
|
-
emailAndStatus: ["email", "status", "_creationTime"];
|
|
262
|
-
invitedByUserIdAndStatus: ["invitedByUserId", "status", "_creationTime"];
|
|
263
|
-
organizationId: ["organizationId", "_creationTime"];
|
|
264
|
-
organizationIdAndStatus: ["organizationId", "status", "_creationTime"];
|
|
265
|
-
}, {}, {}>;
|
|
266
|
-
};
|
|
267
|
-
type DefaultSchema = ReturnType<typeof defineSchema<typeof authTables>>;
|
|
268
|
-
export type AuthDataModel = DataModelFromSchemaDefinition<DefaultSchema>;
|
|
4
|
+
import schema from "../../component/schema.js";
|
|
5
|
+
/** Data model derived from the component schema. */
|
|
6
|
+
export type AuthDataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
7
|
+
/** Action context typed to the auth component's data model. */
|
|
269
8
|
export type ActionCtx = GenericActionCtx<AuthDataModel>;
|
|
9
|
+
/** Mutation context typed to the auth component's data model. */
|
|
270
10
|
export type MutationCtx = GenericMutationCtx<AuthDataModel>;
|
|
11
|
+
/** Query context typed to the auth component's data model. */
|
|
271
12
|
export type QueryCtx = GenericQueryCtx<AuthDataModel>;
|
|
13
|
+
/** A document from any table in the auth component schema. */
|
|
272
14
|
export type Doc<T extends TableNamesInDataModel<AuthDataModel>> = GenericDoc<AuthDataModel, T>;
|
|
15
|
+
/** A pair of JWT access token and refresh token. */
|
|
273
16
|
export type Tokens = {
|
|
274
17
|
token: string;
|
|
275
18
|
refreshToken: string;
|
|
276
19
|
};
|
|
20
|
+
/** Session information returned after authentication. */
|
|
277
21
|
export type SessionInfo = {
|
|
278
22
|
userId: GenericId<"user">;
|
|
279
23
|
sessionId: GenericId<"session">;
|
|
280
24
|
tokens: Tokens | null;
|
|
281
25
|
};
|
|
26
|
+
/** Session information with guaranteed non-null tokens. */
|
|
282
27
|
export type SessionInfoWithTokens = {
|
|
283
28
|
userId: GenericId<"user">;
|
|
284
29
|
sessionId: GenericId<"session">;
|
|
285
30
|
tokens: Tokens;
|
|
286
31
|
};
|
|
287
|
-
export {};
|
|
288
32
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,oDAAoD;AACpD,MAAM,MAAM,aAAa,GAAG,6BAA6B,CAAC,OAAO,MAAM,CAAC,CAAC;AAEzE,+DAA+D;AAC/D,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AAExD,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAE5D,8DAA8D;AAC9D,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;AAEtD,8DAA8D;AAC9D,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,qBAAqB,CAAC,aAAa,CAAC,IAAI,UAAU,CAC1E,aAAa,EACb,CAAC,CACF,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,2DAA2D;AAC3D,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -1,182 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { v } from "convex/values";
|
|
3
|
-
/**
|
|
4
|
-
* The table definitions required by the library.
|
|
5
|
-
*
|
|
6
|
-
* Your schema must include these so that the indexes
|
|
7
|
-
* are set up:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ```ts filename="convex/schema.ts"
|
|
11
|
-
* import { defineSchema } from "convex/server";
|
|
12
|
-
* import { authTables } from "@robelest/convex-auth/component";
|
|
13
|
-
*
|
|
14
|
-
* const schema = defineSchema({
|
|
15
|
-
* ...authTables,
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* export default schema;
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* You can inline the table definitions into your schema
|
|
22
|
-
* and extend them with additional optional and required
|
|
23
|
-
* fields. See https://labs.convex.dev/auth/setup/schema
|
|
24
|
-
* for more details.
|
|
25
|
-
*/
|
|
26
|
-
export const authTables = {
|
|
27
|
-
/**
|
|
28
|
-
* Users.
|
|
29
|
-
*/
|
|
30
|
-
user: defineTable({
|
|
31
|
-
name: v.optional(v.string()),
|
|
32
|
-
image: v.optional(v.string()),
|
|
33
|
-
email: v.optional(v.string()),
|
|
34
|
-
emailVerificationTime: v.optional(v.number()),
|
|
35
|
-
phone: v.optional(v.string()),
|
|
36
|
-
phoneVerificationTime: v.optional(v.number()),
|
|
37
|
-
isAnonymous: v.optional(v.boolean()),
|
|
38
|
-
})
|
|
39
|
-
.index("email", ["email"])
|
|
40
|
-
.index("phone", ["phone"]),
|
|
41
|
-
/**
|
|
42
|
-
* Sessions.
|
|
43
|
-
* A single user can have multiple active sessions.
|
|
44
|
-
* See [Session document lifecycle](https://labs.convex.dev/auth/advanced#session-document-lifecycle).
|
|
45
|
-
*/
|
|
46
|
-
session: defineTable({
|
|
47
|
-
userId: v.id("user"),
|
|
48
|
-
expirationTime: v.number(),
|
|
49
|
-
}).index("userId", ["userId"]),
|
|
50
|
-
/**
|
|
51
|
-
* Accounts. An account corresponds to
|
|
52
|
-
* a single authentication provider.
|
|
53
|
-
* A single user can have multiple accounts linked.
|
|
54
|
-
*/
|
|
55
|
-
account: defineTable({
|
|
56
|
-
userId: v.id("user"),
|
|
57
|
-
provider: v.string(),
|
|
58
|
-
providerAccountId: v.string(),
|
|
59
|
-
secret: v.optional(v.string()),
|
|
60
|
-
emailVerified: v.optional(v.string()),
|
|
61
|
-
phoneVerified: v.optional(v.string()),
|
|
62
|
-
})
|
|
63
|
-
.index("userIdAndProvider", ["userId", "provider"])
|
|
64
|
-
.index("providerAndAccountId", ["provider", "providerAccountId"]),
|
|
65
|
-
/**
|
|
66
|
-
* Refresh tokens.
|
|
67
|
-
* Refresh tokens are generally meant to be used once, to be exchanged for another
|
|
68
|
-
* refresh token and a JWT access token, but with a few exceptions:
|
|
69
|
-
* - The "active refresh token" is the most recently created refresh token that has
|
|
70
|
-
* not been used yet. The parent of the active refresh token can always be used to
|
|
71
|
-
* obtain the active refresh token.
|
|
72
|
-
* - A refresh token can be used within a 10 second window ("reuse window") to
|
|
73
|
-
* obtain a new refresh token.
|
|
74
|
-
* - On any invalid use of a refresh token, the token itself and all its descendants
|
|
75
|
-
* are invalidated.
|
|
76
|
-
*/
|
|
77
|
-
token: defineTable({
|
|
78
|
-
sessionId: v.id("session"),
|
|
79
|
-
expirationTime: v.number(),
|
|
80
|
-
firstUsedTime: v.optional(v.number()),
|
|
81
|
-
// This is the ID of the refresh token that was exchanged to create this one.
|
|
82
|
-
parentRefreshTokenId: v.optional(v.id("token")),
|
|
83
|
-
})
|
|
84
|
-
// Sort by creationTime
|
|
85
|
-
.index("sessionId", ["sessionId"])
|
|
86
|
-
.index("sessionIdAndParentRefreshTokenId", [
|
|
87
|
-
"sessionId",
|
|
88
|
-
"parentRefreshTokenId",
|
|
89
|
-
]),
|
|
90
|
-
/**
|
|
91
|
-
* Verification codes:
|
|
92
|
-
* - OTP tokens
|
|
93
|
-
* - magic link tokens
|
|
94
|
-
* - OAuth codes
|
|
95
|
-
*/
|
|
96
|
-
verification: defineTable({
|
|
97
|
-
accountId: v.id("account"),
|
|
98
|
-
provider: v.string(),
|
|
99
|
-
code: v.string(),
|
|
100
|
-
expirationTime: v.number(),
|
|
101
|
-
verifier: v.optional(v.string()),
|
|
102
|
-
emailVerified: v.optional(v.string()),
|
|
103
|
-
phoneVerified: v.optional(v.string()),
|
|
104
|
-
})
|
|
105
|
-
.index("accountId", ["accountId"])
|
|
106
|
-
.index("code", ["code"]),
|
|
107
|
-
/**
|
|
108
|
-
* PKCE verifiers for OAuth.
|
|
109
|
-
*/
|
|
110
|
-
verifier: defineTable({
|
|
111
|
-
sessionId: v.optional(v.id("session")),
|
|
112
|
-
signature: v.optional(v.string()),
|
|
113
|
-
}).index("signature", ["signature"]),
|
|
114
|
-
/**
|
|
115
|
-
* Rate limits for OTP and password sign-in.
|
|
116
|
-
*/
|
|
117
|
-
limit: defineTable({
|
|
118
|
-
identifier: v.string(),
|
|
119
|
-
lastAttemptTime: v.number(),
|
|
120
|
-
attemptsLeft: v.number(),
|
|
121
|
-
}).index("identifier", ["identifier"]),
|
|
122
|
-
organization: defineTable({
|
|
123
|
-
name: v.string(),
|
|
124
|
-
slug: v.optional(v.string()),
|
|
125
|
-
ownerUserId: v.optional(v.id("user")),
|
|
126
|
-
parentOrganizationId: v.optional(v.id("organization")),
|
|
127
|
-
metadata: v.optional(v.any()),
|
|
128
|
-
})
|
|
129
|
-
.index("slug", ["slug"])
|
|
130
|
-
.index("ownerUserId", ["ownerUserId"])
|
|
131
|
-
.index("parentOrganizationId", ["parentOrganizationId"]),
|
|
132
|
-
team: defineTable({
|
|
133
|
-
organizationId: v.id("organization"),
|
|
134
|
-
name: v.string(),
|
|
135
|
-
slug: v.optional(v.string()),
|
|
136
|
-
parentTeamId: v.optional(v.id("team")),
|
|
137
|
-
metadata: v.optional(v.any()),
|
|
138
|
-
})
|
|
139
|
-
.index("organizationId", ["organizationId"])
|
|
140
|
-
.index("organizationIdAndSlug", ["organizationId", "slug"])
|
|
141
|
-
.index("parentTeamId", ["parentTeamId"]),
|
|
142
|
-
teamRelation: defineTable({
|
|
143
|
-
organizationId: v.id("organization"),
|
|
144
|
-
parentTeamId: v.id("team"),
|
|
145
|
-
childTeamId: v.id("team"),
|
|
146
|
-
relation: v.optional(v.string()),
|
|
147
|
-
})
|
|
148
|
-
.index("organizationId", ["organizationId"])
|
|
149
|
-
.index("organizationIdAndParentTeamId", ["organizationId", "parentTeamId"])
|
|
150
|
-
.index("organizationIdAndChildTeamId", ["organizationId", "childTeamId"]),
|
|
151
|
-
member: defineTable({
|
|
152
|
-
organizationId: v.id("organization"),
|
|
153
|
-
userId: v.id("user"),
|
|
154
|
-
teamId: v.optional(v.id("team")),
|
|
155
|
-
role: v.optional(v.string()),
|
|
156
|
-
status: v.optional(v.string()),
|
|
157
|
-
metadata: v.optional(v.any()),
|
|
158
|
-
})
|
|
159
|
-
.index("organizationId", ["organizationId"])
|
|
160
|
-
.index("organizationIdAndUserId", ["organizationId", "userId"])
|
|
161
|
-
.index("teamId", ["teamId"])
|
|
162
|
-
.index("userId", ["userId"]),
|
|
163
|
-
invite: defineTable({
|
|
164
|
-
organizationId: v.optional(v.id("organization")),
|
|
165
|
-
teamId: v.optional(v.id("team")),
|
|
166
|
-
invitedByUserId: v.id("user"),
|
|
167
|
-
email: v.string(),
|
|
168
|
-
tokenHash: v.string(),
|
|
169
|
-
role: v.optional(v.string()),
|
|
170
|
-
status: v.union(v.literal("pending"), v.literal("accepted"), v.literal("revoked"), v.literal("expired")),
|
|
171
|
-
expiresTime: v.number(),
|
|
172
|
-
acceptedByUserId: v.optional(v.id("user")),
|
|
173
|
-
acceptedTime: v.optional(v.number()),
|
|
174
|
-
metadata: v.optional(v.any()),
|
|
175
|
-
})
|
|
176
|
-
.index("tokenHash", ["tokenHash"])
|
|
177
|
-
.index("emailAndStatus", ["email", "status"])
|
|
178
|
-
.index("invitedByUserIdAndStatus", ["invitedByUserId", "status"])
|
|
179
|
-
.index("organizationId", ["organizationId"])
|
|
180
|
-
.index("organizationIdAndStatus", ["organizationId", "status"]),
|
|
181
|
-
};
|
|
1
|
+
export {};
|
|
182
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/server/implementation/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/server/implementation/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/E,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAAC;IACnE,QAAQ,EAAE,8BAA8B,CAAC;IACzC,OAAO,EAAE,MAA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