@robelest/convex-auth 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/bin.cjs +27733 -0
- package/dist/client/index.d.ts +49 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +283 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +36 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +295 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +4 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/index.d.ts +15 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/component/index.js +13 -0
- package/dist/component/index.js.map +1 -0
- package/dist/component/public.d.ts +450 -0
- package/dist/component/public.d.ts.map +1 -0
- package/dist/component/public.js +528 -0
- package/dist/component/public.js.map +1 -0
- package/dist/component/schema.d.ts +107 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +26 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/providers/Anonymous.d.ts +50 -0
- package/dist/providers/Anonymous.d.ts.map +1 -0
- package/dist/providers/Anonymous.js +39 -0
- package/dist/providers/Anonymous.js.map +1 -0
- package/dist/providers/ConvexCredentials.d.ts +88 -0
- package/dist/providers/ConvexCredentials.d.ts.map +1 -0
- package/dist/providers/ConvexCredentials.js +37 -0
- package/dist/providers/ConvexCredentials.js.map +1 -0
- package/dist/providers/Email.d.ts +33 -0
- package/dist/providers/Email.d.ts.map +1 -0
- package/dist/providers/Email.js +50 -0
- package/dist/providers/Email.js.map +1 -0
- package/dist/providers/Password.d.ts +95 -0
- package/dist/providers/Password.d.ts.map +1 -0
- package/dist/providers/Password.js +174 -0
- package/dist/providers/Password.js.map +1 -0
- package/dist/providers/Phone.d.ts +22 -0
- package/dist/providers/Phone.d.ts.map +1 -0
- package/dist/providers/Phone.js +37 -0
- package/dist/providers/Phone.js.map +1 -0
- package/dist/server/convex_types.d.ts +17 -0
- package/dist/server/convex_types.d.ts.map +1 -0
- package/dist/server/convex_types.js +2 -0
- package/dist/server/convex_types.js.map +1 -0
- package/dist/server/cookies.d.ts +35 -0
- package/dist/server/cookies.d.ts.map +1 -0
- package/dist/server/cookies.js +34 -0
- package/dist/server/cookies.js.map +1 -0
- package/dist/server/implementation/db.d.ts +80 -0
- package/dist/server/implementation/db.d.ts.map +1 -0
- package/dist/server/implementation/db.js +59 -0
- package/dist/server/implementation/db.js.map +1 -0
- package/dist/server/implementation/index.d.ts +370 -0
- package/dist/server/implementation/index.d.ts.map +1 -0
- package/dist/server/implementation/index.js +521 -0
- package/dist/server/implementation/index.js.map +1 -0
- package/dist/server/implementation/mutations/createAccountFromCredentials.d.ts +33 -0
- package/dist/server/implementation/mutations/createAccountFromCredentials.d.ts.map +1 -0
- package/dist/server/implementation/mutations/createAccountFromCredentials.js +71 -0
- package/dist/server/implementation/mutations/createAccountFromCredentials.js.map +1 -0
- package/dist/server/implementation/mutations/createVerificationCode.d.ts +25 -0
- package/dist/server/implementation/mutations/createVerificationCode.d.ts.map +1 -0
- package/dist/server/implementation/mutations/createVerificationCode.js +84 -0
- package/dist/server/implementation/mutations/createVerificationCode.js.map +1 -0
- package/dist/server/implementation/mutations/index.d.ts +304 -0
- package/dist/server/implementation/mutations/index.d.ts.map +1 -0
- package/dist/server/implementation/mutations/index.js +108 -0
- package/dist/server/implementation/mutations/index.js.map +1 -0
- package/dist/server/implementation/mutations/invalidateSessions.d.ts +13 -0
- package/dist/server/implementation/mutations/invalidateSessions.d.ts.map +1 -0
- package/dist/server/implementation/mutations/invalidateSessions.js +35 -0
- package/dist/server/implementation/mutations/invalidateSessions.js.map +1 -0
- package/dist/server/implementation/mutations/modifyAccount.d.ts +23 -0
- package/dist/server/implementation/mutations/modifyAccount.d.ts.map +1 -0
- package/dist/server/implementation/mutations/modifyAccount.js +48 -0
- package/dist/server/implementation/mutations/modifyAccount.js.map +1 -0
- package/dist/server/implementation/mutations/refreshSession.d.ts +16 -0
- package/dist/server/implementation/mutations/refreshSession.d.ts.map +1 -0
- package/dist/server/implementation/mutations/refreshSession.js +116 -0
- package/dist/server/implementation/mutations/refreshSession.js.map +1 -0
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.d.ts +27 -0
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.d.ts.map +1 -0
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js +55 -0
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js.map +1 -0
- package/dist/server/implementation/mutations/signIn.d.ts +17 -0
- package/dist/server/implementation/mutations/signIn.d.ts.map +1 -0
- package/dist/server/implementation/mutations/signIn.js +26 -0
- package/dist/server/implementation/mutations/signIn.js.map +1 -0
- package/dist/server/implementation/mutations/signOut.d.ts +11 -0
- package/dist/server/implementation/mutations/signOut.d.ts.map +1 -0
- package/dist/server/implementation/mutations/signOut.js +24 -0
- package/dist/server/implementation/mutations/signOut.js.map +1 -0
- package/dist/server/implementation/mutations/userOAuth.d.ts +19 -0
- package/dist/server/implementation/mutations/userOAuth.d.ts.map +1 -0
- package/dist/server/implementation/mutations/userOAuth.js +84 -0
- package/dist/server/implementation/mutations/userOAuth.js.map +1 -0
- package/dist/server/implementation/mutations/verifier.d.ts +8 -0
- package/dist/server/implementation/mutations/verifier.d.ts.map +1 -0
- package/dist/server/implementation/mutations/verifier.js +19 -0
- package/dist/server/implementation/mutations/verifier.js.map +1 -0
- package/dist/server/implementation/mutations/verifierSignature.d.ts +15 -0
- package/dist/server/implementation/mutations/verifierSignature.d.ts.map +1 -0
- package/dist/server/implementation/mutations/verifierSignature.js +29 -0
- package/dist/server/implementation/mutations/verifierSignature.js.map +1 -0
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.d.ts +21 -0
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.d.ts.map +1 -0
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.js +127 -0
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.js.map +1 -0
- package/dist/server/implementation/provider.d.ts +6 -0
- package/dist/server/implementation/provider.d.ts.map +1 -0
- package/dist/server/implementation/provider.js +21 -0
- package/dist/server/implementation/provider.js.map +1 -0
- package/dist/server/implementation/rateLimit.d.ts +6 -0
- package/dist/server/implementation/rateLimit.d.ts.map +1 -0
- package/dist/server/implementation/rateLimit.js +76 -0
- package/dist/server/implementation/rateLimit.js.map +1 -0
- package/dist/server/implementation/redirects.d.ts +6 -0
- package/dist/server/implementation/redirects.d.ts.map +1 -0
- package/dist/server/implementation/redirects.js +40 -0
- package/dist/server/implementation/redirects.js.map +1 -0
- package/dist/server/implementation/refreshTokens.d.ts +40 -0
- package/dist/server/implementation/refreshTokens.d.ts.map +1 -0
- package/dist/server/implementation/refreshTokens.js +160 -0
- package/dist/server/implementation/refreshTokens.js.map +1 -0
- package/dist/server/implementation/sessions.d.ts +43 -0
- package/dist/server/implementation/sessions.d.ts.map +1 -0
- package/dist/server/implementation/sessions.js +94 -0
- package/dist/server/implementation/sessions.js.map +1 -0
- package/dist/server/implementation/signIn.d.ts +31 -0
- package/dist/server/implementation/signIn.d.ts.map +1 -0
- package/dist/server/implementation/signIn.js +148 -0
- package/dist/server/implementation/signIn.js.map +1 -0
- package/dist/server/implementation/tokens.d.ts +7 -0
- package/dist/server/implementation/tokens.d.ts.map +1 -0
- package/dist/server/implementation/tokens.js +18 -0
- package/dist/server/implementation/tokens.js.map +1 -0
- package/dist/server/implementation/types.d.ts +288 -0
- package/dist/server/implementation/types.d.ts.map +1 -0
- package/dist/server/implementation/types.js +182 -0
- package/dist/server/implementation/types.js.map +1 -0
- package/dist/server/implementation/users.d.ts +27 -0
- package/dist/server/implementation/users.d.ts.map +1 -0
- package/dist/server/implementation/users.js +181 -0
- package/dist/server/implementation/users.js.map +1 -0
- package/dist/server/implementation/utils.d.ts +17 -0
- package/dist/server/implementation/utils.d.ts.map +1 -0
- package/dist/server/implementation/utils.js +72 -0
- package/dist/server/implementation/utils.js.map +1 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +54 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/oauth/authorizationUrl.d.ts +13 -0
- package/dist/server/oauth/authorizationUrl.d.ts.map +1 -0
- package/dist/server/oauth/authorizationUrl.js +91 -0
- package/dist/server/oauth/authorizationUrl.js.map +1 -0
- package/dist/server/oauth/callback.d.ts +19 -0
- package/dist/server/oauth/callback.d.ts.map +1 -0
- package/dist/server/oauth/callback.js +173 -0
- package/dist/server/oauth/callback.js.map +1 -0
- package/dist/server/oauth/checks.d.ts +52 -0
- package/dist/server/oauth/checks.d.ts.map +1 -0
- package/dist/server/oauth/checks.js +106 -0
- package/dist/server/oauth/checks.js.map +1 -0
- package/dist/server/oauth/convexAuth.d.ts +12 -0
- package/dist/server/oauth/convexAuth.d.ts.map +1 -0
- package/dist/server/oauth/convexAuth.js +137 -0
- package/dist/server/oauth/convexAuth.js.map +1 -0
- package/dist/server/oauth/lib/utils/customFetch.d.ts +9 -0
- package/dist/server/oauth/lib/utils/customFetch.d.ts.map +1 -0
- package/dist/server/oauth/lib/utils/customFetch.js +11 -0
- package/dist/server/oauth/lib/utils/customFetch.js.map +1 -0
- package/dist/server/oauth/lib/utils/providers.d.ts +3 -0
- package/dist/server/oauth/lib/utils/providers.d.ts.map +1 -0
- package/dist/server/oauth/lib/utils/providers.js +7 -0
- package/dist/server/oauth/lib/utils/providers.js.map +1 -0
- package/dist/server/oauth/providers/oauth.d.ts +43 -0
- package/dist/server/oauth/providers/oauth.d.ts.map +1 -0
- package/dist/server/oauth/providers/oauth.js +3 -0
- package/dist/server/oauth/providers/oauth.js.map +1 -0
- package/dist/server/oauth/types.d.ts +24 -0
- package/dist/server/oauth/types.d.ts.map +1 -0
- package/dist/server/oauth/types.js +5 -0
- package/dist/server/oauth/types.js.map +1 -0
- package/dist/server/provider_utils.d.ts +76 -0
- package/dist/server/provider_utils.d.ts.map +1 -0
- package/dist/server/provider_utils.js +177 -0
- package/dist/server/provider_utils.js.map +1 -0
- package/dist/server/types.d.ts +412 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +2 -0
- package/dist/server/types.js.map +1 -0
- package/dist/server/utils.d.ts +3 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/server/utils.js +11 -0
- package/dist/server/utils.js.map +1 -0
- package/package.json +126 -0
- package/providers/Anonymous/package.json +6 -0
- package/providers/ConvexCredentials/package.json +6 -0
- package/providers/Email/package.json +6 -0
- package/providers/Password/package.json +6 -0
- package/providers/Phone/package.json +6 -0
- package/server/package.json +6 -0
- package/src/cli/command.ts +69 -0
- package/src/cli/generateKeys.ts +20 -0
- package/src/cli/index.ts +840 -0
- package/src/client/index.ts +415 -0
- package/src/component/_generated/api.ts +52 -0
- package/src/component/_generated/component.ts +586 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +5 -0
- package/src/component/index.ts +40 -0
- package/src/component/public.ts +607 -0
- package/src/component/schema.ts +35 -0
- package/src/providers/Anonymous.ts +79 -0
- package/src/providers/ConvexCredentials.ts +108 -0
- package/src/providers/Email.ts +60 -0
- package/src/providers/Password.ts +253 -0
- package/src/providers/Phone.ts +46 -0
- package/src/server/convex_types.ts +55 -0
- package/src/server/cookies.ts +42 -0
- package/src/server/implementation/db.ts +125 -0
- package/src/server/implementation/index.ts +815 -0
- package/src/server/implementation/mutations/createAccountFromCredentials.ts +113 -0
- package/src/server/implementation/mutations/createVerificationCode.ts +139 -0
- package/src/server/implementation/mutations/index.ts +157 -0
- package/src/server/implementation/mutations/invalidateSessions.ts +47 -0
- package/src/server/implementation/mutations/modifyAccount.ts +65 -0
- package/src/server/implementation/mutations/refreshSession.ts +188 -0
- package/src/server/implementation/mutations/retrieveAccountWithCredentials.ts +87 -0
- package/src/server/implementation/mutations/signIn.ts +51 -0
- package/src/server/implementation/mutations/signOut.ts +38 -0
- package/src/server/implementation/mutations/userOAuth.ts +112 -0
- package/src/server/implementation/mutations/verifier.ts +29 -0
- package/src/server/implementation/mutations/verifierSignature.ts +44 -0
- package/src/server/implementation/mutations/verifyCodeAndSignIn.ts +205 -0
- package/src/server/implementation/provider.ts +38 -0
- package/src/server/implementation/rateLimit.ts +105 -0
- package/src/server/implementation/redirects.ts +58 -0
- package/src/server/implementation/refreshTokens.ts +221 -0
- package/src/server/implementation/sessions.ts +155 -0
- package/src/server/implementation/signIn.ts +253 -0
- package/src/server/implementation/tokens.ts +29 -0
- package/src/server/implementation/types.ts +220 -0
- package/src/server/implementation/users.ts +286 -0
- package/src/server/implementation/utils.ts +91 -0
- package/src/server/index.ts +74 -0
- package/src/server/oauth/NOTICE.txt +21 -0
- package/src/server/oauth/README.md +7 -0
- package/src/server/oauth/authorizationUrl.ts +113 -0
- package/src/server/oauth/callback.ts +243 -0
- package/src/server/oauth/checks.ts +136 -0
- package/src/server/oauth/convexAuth.ts +168 -0
- package/src/server/oauth/lib/utils/customFetch.ts +18 -0
- package/src/server/oauth/lib/utils/providers.ts +12 -0
- package/src/server/oauth/providers/oauth.ts +56 -0
- package/src/server/oauth/types.ts +60 -0
- package/src/server/provider_utils.ts +222 -0
- package/src/server/types.ts +470 -0
- package/src/server/utils.ts +12 -0
- package/src/test.ts +24 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Infer } from "convex/values";
|
|
2
|
+
import { ActionCtx, MutationCtx } from "../types.js";
|
|
3
|
+
import * as Provider from "../provider.js";
|
|
4
|
+
export declare const createVerificationCodeArgs: import("convex/values").VObject<{
|
|
5
|
+
email?: string | undefined;
|
|
6
|
+
phone?: string | undefined;
|
|
7
|
+
accountId?: string | undefined;
|
|
8
|
+
expirationTime: number;
|
|
9
|
+
provider: string;
|
|
10
|
+
code: string;
|
|
11
|
+
allowExtraProviders: boolean;
|
|
12
|
+
}, {
|
|
13
|
+
accountId: import("convex/values").VString<string | undefined, "optional">;
|
|
14
|
+
provider: import("convex/values").VString<string, "required">;
|
|
15
|
+
email: import("convex/values").VString<string | undefined, "optional">;
|
|
16
|
+
phone: import("convex/values").VString<string | undefined, "optional">;
|
|
17
|
+
code: import("convex/values").VString<string, "required">;
|
|
18
|
+
expirationTime: import("convex/values").VFloat64<number, "required">;
|
|
19
|
+
allowExtraProviders: import("convex/values").VBoolean<boolean, "required">;
|
|
20
|
+
}, "required", "email" | "phone" | "expirationTime" | "provider" | "accountId" | "code" | "allowExtraProviders">;
|
|
21
|
+
type ReturnType = string;
|
|
22
|
+
export declare function createVerificationCodeImpl(ctx: MutationCtx, args: Infer<typeof createVerificationCodeArgs>, getProviderOrThrow: Provider.GetProviderOrThrowFunc, config: Provider.Config): Promise<ReturnType>;
|
|
23
|
+
export declare const callCreateVerificationCode: (ctx: ActionCtx, args: Infer<typeof createVerificationCodeArgs>) => Promise<ReturnType>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=createVerificationCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVerificationCode.d.ts","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/createVerificationCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,EAAK,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAO3C,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;gHAQrC,CAAC;AAEH,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,KAAK,CAAC,OAAO,0BAA0B,CAAC,EAC9C,kBAAkB,EAAE,QAAQ,CAAC,sBAAsB,EACnD,MAAM,EAAE,QAAQ,CAAC,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC,CAsDrB;AAED,eAAO,MAAM,0BAA0B,GACrC,KAAK,SAAS,EACd,MAAM,KAAK,CAAC,OAAO,0BAA0B,CAAC,KAC7C,OAAO,CAAC,UAAU,CAOpB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { getAccountOrThrow, upsertUserAndAccount } from "../users.js";
|
|
3
|
+
import { getAuthSessionId } from "../sessions.js";
|
|
4
|
+
import { LOG_LEVELS, logWithLevel, sha256 } from "../utils.js";
|
|
5
|
+
import { createAuthDb } from "../db.js";
|
|
6
|
+
export const createVerificationCodeArgs = v.object({
|
|
7
|
+
accountId: v.optional(v.string()),
|
|
8
|
+
provider: v.string(),
|
|
9
|
+
email: v.optional(v.string()),
|
|
10
|
+
phone: v.optional(v.string()),
|
|
11
|
+
code: v.string(),
|
|
12
|
+
expirationTime: v.number(),
|
|
13
|
+
allowExtraProviders: v.boolean(),
|
|
14
|
+
});
|
|
15
|
+
export async function createVerificationCodeImpl(ctx, args, getProviderOrThrow, config) {
|
|
16
|
+
logWithLevel(LOG_LEVELS.DEBUG, "createVerificationCodeImpl args:", args);
|
|
17
|
+
const { email, phone, code, expirationTime, provider: providerId, accountId: existingAccountId, allowExtraProviders, } = args;
|
|
18
|
+
const authDb = config.component !== undefined ? createAuthDb(ctx, config.component) : null;
|
|
19
|
+
const typedExistingAccountId = existingAccountId;
|
|
20
|
+
const existingAccount = typedExistingAccountId !== undefined
|
|
21
|
+
? await getAccountOrThrow(ctx, typedExistingAccountId, config)
|
|
22
|
+
: authDb !== null
|
|
23
|
+
? await authDb.accounts.get(providerId, email ?? phone)
|
|
24
|
+
: await ctx.db
|
|
25
|
+
.query("account")
|
|
26
|
+
.withIndex("providerAndAccountId", (q) => q
|
|
27
|
+
.eq("provider", providerId)
|
|
28
|
+
.eq("providerAccountId", email ?? phone))
|
|
29
|
+
.unique();
|
|
30
|
+
const provider = getProviderOrThrow(providerId, allowExtraProviders);
|
|
31
|
+
const { accountId } = await upsertUserAndAccount(ctx, await getAuthSessionId(ctx), existingAccount !== null
|
|
32
|
+
? { existingAccount }
|
|
33
|
+
: { providerAccountId: email ?? phone }, provider.type === "email"
|
|
34
|
+
? { type: "email", provider, profile: { email: email } }
|
|
35
|
+
: { type: "phone", provider, profile: { phone: phone } }, config);
|
|
36
|
+
await generateUniqueVerificationCode(ctx, accountId, providerId, code, expirationTime, { email, phone }, config);
|
|
37
|
+
return email ?? phone;
|
|
38
|
+
}
|
|
39
|
+
export const callCreateVerificationCode = async (ctx, args) => {
|
|
40
|
+
return ctx.runMutation("auth:store", {
|
|
41
|
+
args: {
|
|
42
|
+
type: "createVerificationCode",
|
|
43
|
+
...args,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
async function generateUniqueVerificationCode(ctx, accountId, provider, code, expirationTime, { email, phone }, config) {
|
|
48
|
+
const authDb = config.component !== undefined ? createAuthDb(ctx, config.component) : null;
|
|
49
|
+
const existingCode = authDb !== null
|
|
50
|
+
? await authDb.verificationCodes.getByAccountId(accountId)
|
|
51
|
+
: await ctx.db
|
|
52
|
+
.query("verification")
|
|
53
|
+
.withIndex("accountId", (q) => q.eq("accountId", accountId))
|
|
54
|
+
.unique();
|
|
55
|
+
if (existingCode !== null) {
|
|
56
|
+
if (authDb !== null) {
|
|
57
|
+
await authDb.verificationCodes.delete(existingCode._id);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
await ctx.db.delete(existingCode._id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (authDb !== null) {
|
|
64
|
+
await authDb.verificationCodes.create({
|
|
65
|
+
accountId,
|
|
66
|
+
provider,
|
|
67
|
+
code: await sha256(code),
|
|
68
|
+
expirationTime,
|
|
69
|
+
emailVerified: email,
|
|
70
|
+
phoneVerified: phone,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
await ctx.db.insert("verification", {
|
|
75
|
+
accountId,
|
|
76
|
+
provider,
|
|
77
|
+
code: await sha256(code),
|
|
78
|
+
expirationTime,
|
|
79
|
+
emailVerified: email,
|
|
80
|
+
phoneVerified: phone,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=createVerificationCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVerificationCode.js","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/createVerificationCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,CAAC,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MA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304 @@
|
|
|
1
|
+
import { Infer } from "convex/values";
|
|
2
|
+
import { MutationCtx } from "../types.js";
|
|
3
|
+
import * as Provider from "../provider.js";
|
|
4
|
+
export { callInvalidateSessions } from "./invalidateSessions.js";
|
|
5
|
+
export { callModifyAccount } from "./modifyAccount.js";
|
|
6
|
+
export { callRetreiveAccountWithCredentials } from "./retrieveAccountWithCredentials.js";
|
|
7
|
+
export { callCreateAccountFromCredentials } from "./createAccountFromCredentials.js";
|
|
8
|
+
export { callCreateVerificationCode } from "./createVerificationCode.js";
|
|
9
|
+
export { callUserOAuth } from "./userOAuth.js";
|
|
10
|
+
export { callVerifierSignature } from "./verifierSignature.js";
|
|
11
|
+
export { callVerifyCodeAndSignIn } from "./verifyCodeAndSignIn.js";
|
|
12
|
+
export { callVerifier } from "./verifier.js";
|
|
13
|
+
export { callRefreshSession } from "./refreshSession.js";
|
|
14
|
+
export { callSignOut } from "./signOut.js";
|
|
15
|
+
export { callSignIn } from "./signIn.js";
|
|
16
|
+
export declare const storeArgs: import("convex/values").VObject<{
|
|
17
|
+
args: {
|
|
18
|
+
sessionId?: string | undefined;
|
|
19
|
+
type: "signIn";
|
|
20
|
+
userId: string;
|
|
21
|
+
generateTokens: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
type: "signOut";
|
|
24
|
+
} | {
|
|
25
|
+
type: "refreshSession";
|
|
26
|
+
refreshToken: string;
|
|
27
|
+
} | {
|
|
28
|
+
provider?: string | undefined;
|
|
29
|
+
verifier?: string | undefined;
|
|
30
|
+
type: "verifyCodeAndSignIn";
|
|
31
|
+
generateTokens: boolean;
|
|
32
|
+
params: any;
|
|
33
|
+
allowExtraProviders: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
type: "verifier";
|
|
36
|
+
} | {
|
|
37
|
+
type: "verifierSignature";
|
|
38
|
+
verifier: string;
|
|
39
|
+
signature: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "userOAuth";
|
|
42
|
+
profile: any;
|
|
43
|
+
provider: string;
|
|
44
|
+
providerAccountId: string;
|
|
45
|
+
signature: string;
|
|
46
|
+
} | {
|
|
47
|
+
email?: string | undefined;
|
|
48
|
+
phone?: string | undefined;
|
|
49
|
+
accountId?: string | undefined;
|
|
50
|
+
type: "createVerificationCode";
|
|
51
|
+
expirationTime: number;
|
|
52
|
+
provider: string;
|
|
53
|
+
code: string;
|
|
54
|
+
allowExtraProviders: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
shouldLinkViaEmail?: boolean | undefined;
|
|
57
|
+
shouldLinkViaPhone?: boolean | undefined;
|
|
58
|
+
type: "createAccountFromCredentials";
|
|
59
|
+
profile: any;
|
|
60
|
+
account: {
|
|
61
|
+
secret?: string | undefined;
|
|
62
|
+
id: string;
|
|
63
|
+
};
|
|
64
|
+
provider: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: "retrieveAccountWithCredentials";
|
|
67
|
+
account: {
|
|
68
|
+
secret?: string | undefined;
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
provider: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: "modifyAccount";
|
|
74
|
+
account: {
|
|
75
|
+
id: string;
|
|
76
|
+
secret: string;
|
|
77
|
+
};
|
|
78
|
+
provider: string;
|
|
79
|
+
} | {
|
|
80
|
+
except?: string[] | undefined;
|
|
81
|
+
type: "invalidateSessions";
|
|
82
|
+
userId: string;
|
|
83
|
+
};
|
|
84
|
+
}, {
|
|
85
|
+
args: import("convex/values").VUnion<{
|
|
86
|
+
sessionId?: string | undefined;
|
|
87
|
+
type: "signIn";
|
|
88
|
+
userId: string;
|
|
89
|
+
generateTokens: boolean;
|
|
90
|
+
} | {
|
|
91
|
+
type: "signOut";
|
|
92
|
+
} | {
|
|
93
|
+
type: "refreshSession";
|
|
94
|
+
refreshToken: string;
|
|
95
|
+
} | {
|
|
96
|
+
provider?: string | undefined;
|
|
97
|
+
verifier?: string | undefined;
|
|
98
|
+
type: "verifyCodeAndSignIn";
|
|
99
|
+
generateTokens: boolean;
|
|
100
|
+
params: any;
|
|
101
|
+
allowExtraProviders: boolean;
|
|
102
|
+
} | {
|
|
103
|
+
type: "verifier";
|
|
104
|
+
} | {
|
|
105
|
+
type: "verifierSignature";
|
|
106
|
+
verifier: string;
|
|
107
|
+
signature: string;
|
|
108
|
+
} | {
|
|
109
|
+
type: "userOAuth";
|
|
110
|
+
profile: any;
|
|
111
|
+
provider: string;
|
|
112
|
+
providerAccountId: string;
|
|
113
|
+
signature: string;
|
|
114
|
+
} | {
|
|
115
|
+
email?: string | undefined;
|
|
116
|
+
phone?: string | undefined;
|
|
117
|
+
accountId?: string | undefined;
|
|
118
|
+
type: "createVerificationCode";
|
|
119
|
+
expirationTime: number;
|
|
120
|
+
provider: string;
|
|
121
|
+
code: string;
|
|
122
|
+
allowExtraProviders: boolean;
|
|
123
|
+
} | {
|
|
124
|
+
shouldLinkViaEmail?: boolean | undefined;
|
|
125
|
+
shouldLinkViaPhone?: boolean | undefined;
|
|
126
|
+
type: "createAccountFromCredentials";
|
|
127
|
+
profile: any;
|
|
128
|
+
account: {
|
|
129
|
+
secret?: string | undefined;
|
|
130
|
+
id: string;
|
|
131
|
+
};
|
|
132
|
+
provider: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "retrieveAccountWithCredentials";
|
|
135
|
+
account: {
|
|
136
|
+
secret?: string | undefined;
|
|
137
|
+
id: string;
|
|
138
|
+
};
|
|
139
|
+
provider: string;
|
|
140
|
+
} | {
|
|
141
|
+
type: "modifyAccount";
|
|
142
|
+
account: {
|
|
143
|
+
id: string;
|
|
144
|
+
secret: string;
|
|
145
|
+
};
|
|
146
|
+
provider: string;
|
|
147
|
+
} | {
|
|
148
|
+
except?: string[] | undefined;
|
|
149
|
+
type: "invalidateSessions";
|
|
150
|
+
userId: string;
|
|
151
|
+
}, [import("convex/values").VObject<{
|
|
152
|
+
sessionId?: string | undefined;
|
|
153
|
+
type: "signIn";
|
|
154
|
+
userId: string;
|
|
155
|
+
generateTokens: boolean;
|
|
156
|
+
}, {
|
|
157
|
+
userId: import("convex/values").VString<string, "required">;
|
|
158
|
+
sessionId: import("convex/values").VString<string | undefined, "optional">;
|
|
159
|
+
generateTokens: import("convex/values").VBoolean<boolean, "required">;
|
|
160
|
+
type: import("convex/values").VLiteral<"signIn", "required">;
|
|
161
|
+
}, "required", "type" | "userId" | "sessionId" | "generateTokens">, import("convex/values").VObject<{
|
|
162
|
+
type: "signOut";
|
|
163
|
+
}, {
|
|
164
|
+
type: import("convex/values").VLiteral<"signOut", "required">;
|
|
165
|
+
}, "required", "type">, import("convex/values").VObject<{
|
|
166
|
+
type: "refreshSession";
|
|
167
|
+
refreshToken: string;
|
|
168
|
+
}, {
|
|
169
|
+
refreshToken: import("convex/values").VString<string, "required">;
|
|
170
|
+
type: import("convex/values").VLiteral<"refreshSession", "required">;
|
|
171
|
+
}, "required", "type" | "refreshToken">, import("convex/values").VObject<{
|
|
172
|
+
provider?: string | undefined;
|
|
173
|
+
verifier?: string | undefined;
|
|
174
|
+
type: "verifyCodeAndSignIn";
|
|
175
|
+
generateTokens: boolean;
|
|
176
|
+
params: any;
|
|
177
|
+
allowExtraProviders: boolean;
|
|
178
|
+
}, {
|
|
179
|
+
params: import("convex/values").VAny<any, "required", string>;
|
|
180
|
+
provider: import("convex/values").VString<string | undefined, "optional">;
|
|
181
|
+
verifier: import("convex/values").VString<string | undefined, "optional">;
|
|
182
|
+
generateTokens: import("convex/values").VBoolean<boolean, "required">;
|
|
183
|
+
allowExtraProviders: import("convex/values").VBoolean<boolean, "required">;
|
|
184
|
+
type: import("convex/values").VLiteral<"verifyCodeAndSignIn", "required">;
|
|
185
|
+
}, "required", "type" | "provider" | "verifier" | "generateTokens" | "params" | "allowExtraProviders" | `params.${string}`>, import("convex/values").VObject<{
|
|
186
|
+
type: "verifier";
|
|
187
|
+
}, {
|
|
188
|
+
type: import("convex/values").VLiteral<"verifier", "required">;
|
|
189
|
+
}, "required", "type">, import("convex/values").VObject<{
|
|
190
|
+
type: "verifierSignature";
|
|
191
|
+
verifier: string;
|
|
192
|
+
signature: string;
|
|
193
|
+
}, {
|
|
194
|
+
verifier: import("convex/values").VString<string, "required">;
|
|
195
|
+
signature: import("convex/values").VString<string, "required">;
|
|
196
|
+
type: import("convex/values").VLiteral<"verifierSignature", "required">;
|
|
197
|
+
}, "required", "type" | "verifier" | "signature">, import("convex/values").VObject<{
|
|
198
|
+
type: "userOAuth";
|
|
199
|
+
profile: any;
|
|
200
|
+
provider: string;
|
|
201
|
+
providerAccountId: string;
|
|
202
|
+
signature: string;
|
|
203
|
+
}, {
|
|
204
|
+
provider: import("convex/values").VString<string, "required">;
|
|
205
|
+
providerAccountId: import("convex/values").VString<string, "required">;
|
|
206
|
+
profile: import("convex/values").VAny<any, "required", string>;
|
|
207
|
+
signature: import("convex/values").VString<string, "required">;
|
|
208
|
+
type: import("convex/values").VLiteral<"userOAuth", "required">;
|
|
209
|
+
}, "required", "type" | "profile" | "provider" | "providerAccountId" | "signature" | `profile.${string}`>, import("convex/values").VObject<{
|
|
210
|
+
email?: string | undefined;
|
|
211
|
+
phone?: string | undefined;
|
|
212
|
+
accountId?: string | undefined;
|
|
213
|
+
type: "createVerificationCode";
|
|
214
|
+
expirationTime: number;
|
|
215
|
+
provider: string;
|
|
216
|
+
code: string;
|
|
217
|
+
allowExtraProviders: boolean;
|
|
218
|
+
}, {
|
|
219
|
+
accountId: import("convex/values").VString<string | undefined, "optional">;
|
|
220
|
+
provider: import("convex/values").VString<string, "required">;
|
|
221
|
+
email: import("convex/values").VString<string | undefined, "optional">;
|
|
222
|
+
phone: import("convex/values").VString<string | undefined, "optional">;
|
|
223
|
+
code: import("convex/values").VString<string, "required">;
|
|
224
|
+
expirationTime: import("convex/values").VFloat64<number, "required">;
|
|
225
|
+
allowExtraProviders: import("convex/values").VBoolean<boolean, "required">;
|
|
226
|
+
type: import("convex/values").VLiteral<"createVerificationCode", "required">;
|
|
227
|
+
}, "required", "type" | "email" | "phone" | "expirationTime" | "provider" | "accountId" | "code" | "allowExtraProviders">, import("convex/values").VObject<{
|
|
228
|
+
shouldLinkViaEmail?: boolean | undefined;
|
|
229
|
+
shouldLinkViaPhone?: boolean | undefined;
|
|
230
|
+
type: "createAccountFromCredentials";
|
|
231
|
+
profile: any;
|
|
232
|
+
account: {
|
|
233
|
+
secret?: string | undefined;
|
|
234
|
+
id: string;
|
|
235
|
+
};
|
|
236
|
+
provider: string;
|
|
237
|
+
}, {
|
|
238
|
+
provider: import("convex/values").VString<string, "required">;
|
|
239
|
+
account: import("convex/values").VObject<{
|
|
240
|
+
secret?: string | undefined;
|
|
241
|
+
id: string;
|
|
242
|
+
}, {
|
|
243
|
+
id: import("convex/values").VString<string, "required">;
|
|
244
|
+
secret: import("convex/values").VString<string | undefined, "optional">;
|
|
245
|
+
}, "required", "id" | "secret">;
|
|
246
|
+
profile: import("convex/values").VAny<any, "required", string>;
|
|
247
|
+
shouldLinkViaEmail: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
248
|
+
shouldLinkViaPhone: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
249
|
+
type: import("convex/values").VLiteral<"createAccountFromCredentials", "required">;
|
|
250
|
+
}, "required", "type" | "profile" | "account" | "provider" | `profile.${string}` | "shouldLinkViaEmail" | "shouldLinkViaPhone" | "account.id" | "account.secret">, import("convex/values").VObject<{
|
|
251
|
+
type: "retrieveAccountWithCredentials";
|
|
252
|
+
account: {
|
|
253
|
+
secret?: string | undefined;
|
|
254
|
+
id: string;
|
|
255
|
+
};
|
|
256
|
+
provider: string;
|
|
257
|
+
}, {
|
|
258
|
+
provider: import("convex/values").VString<string, "required">;
|
|
259
|
+
account: import("convex/values").VObject<{
|
|
260
|
+
secret?: string | undefined;
|
|
261
|
+
id: string;
|
|
262
|
+
}, {
|
|
263
|
+
id: import("convex/values").VString<string, "required">;
|
|
264
|
+
secret: import("convex/values").VString<string | undefined, "optional">;
|
|
265
|
+
}, "required", "id" | "secret">;
|
|
266
|
+
type: import("convex/values").VLiteral<"retrieveAccountWithCredentials", "required">;
|
|
267
|
+
}, "required", "type" | "account" | "provider" | "account.id" | "account.secret">, import("convex/values").VObject<{
|
|
268
|
+
type: "modifyAccount";
|
|
269
|
+
account: {
|
|
270
|
+
id: string;
|
|
271
|
+
secret: string;
|
|
272
|
+
};
|
|
273
|
+
provider: string;
|
|
274
|
+
}, {
|
|
275
|
+
provider: import("convex/values").VString<string, "required">;
|
|
276
|
+
account: import("convex/values").VObject<{
|
|
277
|
+
id: string;
|
|
278
|
+
secret: string;
|
|
279
|
+
}, {
|
|
280
|
+
id: import("convex/values").VString<string, "required">;
|
|
281
|
+
secret: import("convex/values").VString<string, "required">;
|
|
282
|
+
}, "required", "id" | "secret">;
|
|
283
|
+
type: import("convex/values").VLiteral<"modifyAccount", "required">;
|
|
284
|
+
}, "required", "type" | "account" | "provider" | "account.id" | "account.secret">, import("convex/values").VObject<{
|
|
285
|
+
except?: string[] | undefined;
|
|
286
|
+
type: "invalidateSessions";
|
|
287
|
+
userId: string;
|
|
288
|
+
}, {
|
|
289
|
+
userId: import("convex/values").VString<string, "required">;
|
|
290
|
+
except: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
|
|
291
|
+
type: import("convex/values").VLiteral<"invalidateSessions", "required">;
|
|
292
|
+
}, "required", "type" | "userId" | "except">], "required", "type" | "profile" | "account" | "email" | "phone" | "userId" | "expirationTime" | "provider" | "providerAccountId" | "sessionId" | "accountId" | "code" | "verifier" | "signature" | "generateTokens" | "refreshToken" | "params" | "allowExtraProviders" | `params.${string}` | `profile.${string}` | "shouldLinkViaEmail" | "shouldLinkViaPhone" | "account.id" | "account.secret" | "except">;
|
|
293
|
+
}, "required", "args" | "args.type" | "args.profile" | "args.account" | "args.email" | "args.phone" | "args.userId" | "args.expirationTime" | "args.provider" | "args.providerAccountId" | "args.sessionId" | "args.accountId" | "args.code" | "args.verifier" | "args.signature" | "args.generateTokens" | "args.refreshToken" | "args.params" | "args.allowExtraProviders" | `args.params.${string}` | `args.profile.${string}` | "args.shouldLinkViaEmail" | "args.shouldLinkViaPhone" | "args.account.id" | "args.account.secret" | "args.except">;
|
|
294
|
+
export declare const storeImpl: (ctx: MutationCtx, fnArgs: Infer<typeof storeArgs>, getProviderOrThrow: Provider.GetProviderOrThrowFunc, config: Provider.Config) => Promise<string | void | {
|
|
295
|
+
userId: import("convex/values").GenericId<"user">;
|
|
296
|
+
sessionId: import("convex/values").GenericId<"session">;
|
|
297
|
+
} | {
|
|
298
|
+
token: string;
|
|
299
|
+
refreshToken: string;
|
|
300
|
+
} | {
|
|
301
|
+
account: import("../types.js").Doc<"account">;
|
|
302
|
+
user: import("../types.js").Doc<"user">;
|
|
303
|
+
} | null>;
|
|
304
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAK,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA8B1C,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;shBAiDpB,CAAC;AAEH,eAAO,MAAM,SAAS,GACpB,KAAK,WAAW,EAChB,QAAQ,KAAK,CAAC,OAAO,SAAS,CAAC,EAC/B,oBAAoB,QAAQ,CAAC,sBAAsB,EACnD,QAAQ,QAAQ,CAAC,MAAM;;;;;;;;;SAsDxB,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { signInArgs, signInImpl } from "./signIn.js";
|
|
3
|
+
import { signOutImpl } from "./signOut.js";
|
|
4
|
+
import { refreshSessionArgs, refreshSessionImpl } from "./refreshSession.js";
|
|
5
|
+
import { verifyCodeAndSignInArgs, verifyCodeAndSignInImpl, } from "./verifyCodeAndSignIn.js";
|
|
6
|
+
import { verifierSignatureArgs, verifierSignatureImpl, } from "./verifierSignature.js";
|
|
7
|
+
import { userOAuthArgs, userOAuthImpl } from "./userOAuth.js";
|
|
8
|
+
import { createVerificationCodeArgs, createVerificationCodeImpl, } from "./createVerificationCode.js";
|
|
9
|
+
import { createAccountFromCredentialsArgs, createAccountFromCredentialsImpl, } from "./createAccountFromCredentials.js";
|
|
10
|
+
import { retrieveAccountWithCredentialsArgs, retrieveAccountWithCredentialsImpl, } from "./retrieveAccountWithCredentials.js";
|
|
11
|
+
import { modifyAccountArgs, modifyAccountImpl } from "./modifyAccount.js";
|
|
12
|
+
import { invalidateSessionsArgs, invalidateSessionsImpl, } from "./invalidateSessions.js";
|
|
13
|
+
import { verifierImpl } from "./verifier.js";
|
|
14
|
+
import { LOG_LEVELS, logWithLevel } from "../utils.js";
|
|
15
|
+
export { callInvalidateSessions } from "./invalidateSessions.js";
|
|
16
|
+
export { callModifyAccount } from "./modifyAccount.js";
|
|
17
|
+
export { callRetreiveAccountWithCredentials } from "./retrieveAccountWithCredentials.js";
|
|
18
|
+
export { callCreateAccountFromCredentials } from "./createAccountFromCredentials.js";
|
|
19
|
+
export { callCreateVerificationCode } from "./createVerificationCode.js";
|
|
20
|
+
export { callUserOAuth } from "./userOAuth.js";
|
|
21
|
+
export { callVerifierSignature } from "./verifierSignature.js";
|
|
22
|
+
export { callVerifyCodeAndSignIn } from "./verifyCodeAndSignIn.js";
|
|
23
|
+
export { callVerifier } from "./verifier.js";
|
|
24
|
+
export { callRefreshSession } from "./refreshSession.js";
|
|
25
|
+
export { callSignOut } from "./signOut.js";
|
|
26
|
+
export { callSignIn } from "./signIn.js";
|
|
27
|
+
export const storeArgs = v.object({
|
|
28
|
+
args: v.union(v.object({
|
|
29
|
+
type: v.literal("signIn"),
|
|
30
|
+
...signInArgs.fields,
|
|
31
|
+
}), v.object({
|
|
32
|
+
type: v.literal("signOut"),
|
|
33
|
+
}), v.object({
|
|
34
|
+
type: v.literal("refreshSession"),
|
|
35
|
+
...refreshSessionArgs.fields,
|
|
36
|
+
}), v.object({
|
|
37
|
+
type: v.literal("verifyCodeAndSignIn"),
|
|
38
|
+
...verifyCodeAndSignInArgs.fields,
|
|
39
|
+
}), v.object({
|
|
40
|
+
type: v.literal("verifier"),
|
|
41
|
+
}), v.object({
|
|
42
|
+
type: v.literal("verifierSignature"),
|
|
43
|
+
...verifierSignatureArgs.fields,
|
|
44
|
+
}), v.object({
|
|
45
|
+
type: v.literal("userOAuth"),
|
|
46
|
+
...userOAuthArgs.fields,
|
|
47
|
+
}), v.object({
|
|
48
|
+
type: v.literal("createVerificationCode"),
|
|
49
|
+
...createVerificationCodeArgs.fields,
|
|
50
|
+
}), v.object({
|
|
51
|
+
type: v.literal("createAccountFromCredentials"),
|
|
52
|
+
...createAccountFromCredentialsArgs.fields,
|
|
53
|
+
}), v.object({
|
|
54
|
+
type: v.literal("retrieveAccountWithCredentials"),
|
|
55
|
+
...retrieveAccountWithCredentialsArgs.fields,
|
|
56
|
+
}), v.object({
|
|
57
|
+
type: v.literal("modifyAccount"),
|
|
58
|
+
...modifyAccountArgs.fields,
|
|
59
|
+
}), v.object({
|
|
60
|
+
type: v.literal("invalidateSessions"),
|
|
61
|
+
...invalidateSessionsArgs.fields,
|
|
62
|
+
})),
|
|
63
|
+
});
|
|
64
|
+
export const storeImpl = async (ctx, fnArgs, getProviderOrThrow, config) => {
|
|
65
|
+
const args = fnArgs.args;
|
|
66
|
+
logWithLevel(LOG_LEVELS.INFO, `\`auth:store\` type: ${args.type}`);
|
|
67
|
+
switch (args.type) {
|
|
68
|
+
case "signIn": {
|
|
69
|
+
return signInImpl(ctx, args, config);
|
|
70
|
+
}
|
|
71
|
+
case "signOut": {
|
|
72
|
+
return signOutImpl(ctx, config);
|
|
73
|
+
}
|
|
74
|
+
case "refreshSession": {
|
|
75
|
+
return refreshSessionImpl(ctx, args, getProviderOrThrow, config);
|
|
76
|
+
}
|
|
77
|
+
case "verifyCodeAndSignIn": {
|
|
78
|
+
return verifyCodeAndSignInImpl(ctx, args, getProviderOrThrow, config);
|
|
79
|
+
}
|
|
80
|
+
case "verifier": {
|
|
81
|
+
return verifierImpl(ctx, config);
|
|
82
|
+
}
|
|
83
|
+
case "verifierSignature": {
|
|
84
|
+
return verifierSignatureImpl(ctx, args, config);
|
|
85
|
+
}
|
|
86
|
+
case "userOAuth": {
|
|
87
|
+
return userOAuthImpl(ctx, args, getProviderOrThrow, config);
|
|
88
|
+
}
|
|
89
|
+
case "createVerificationCode": {
|
|
90
|
+
return createVerificationCodeImpl(ctx, args, getProviderOrThrow, config);
|
|
91
|
+
}
|
|
92
|
+
case "createAccountFromCredentials": {
|
|
93
|
+
return createAccountFromCredentialsImpl(ctx, args, getProviderOrThrow, config);
|
|
94
|
+
}
|
|
95
|
+
case "retrieveAccountWithCredentials": {
|
|
96
|
+
return retrieveAccountWithCredentialsImpl(ctx, args, getProviderOrThrow, config);
|
|
97
|
+
}
|
|
98
|
+
case "modifyAccount": {
|
|
99
|
+
return modifyAccountImpl(ctx, args, getProviderOrThrow, config);
|
|
100
|
+
}
|
|
101
|
+
case "invalidateSessions": {
|
|
102
|
+
return invalidateSessionsImpl(ctx, args, config);
|
|
103
|
+
}
|
|
104
|
+
default:
|
|
105
|
+
args;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,CAAC,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,mCAAmC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,OAAO,0BAA0B,CAAC,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC;QACD,KAAK,8BAA8B,CAAC,CAAC,CAAC;YACpC,OAAO,gCAAgC,CACrC,GAAG,EACH,IAAI,EACJ,kBAAkB,EAClB,MAAM,CACP,CAAC;QACJ,CAAC;QACD,KAAK,gCAAgC,CAAC,CAAC,CAAC;YACtC,OAAO,kCAAkC,CACvC,GAAG,EACH,IAAI,EACJ,kBAAkB,EAClB,MAAM,CACP,CAAC;QACJ,CAAC;QACD,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,oBAAoB,CAAC,CAAC,CAAC;YAC1B,OAAO,sBAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;QACD;YACE,IAAoB,CAAC;IACzB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Infer } from "convex/values";
|
|
2
|
+
import { ActionCtx, MutationCtx } from "../types.js";
|
|
3
|
+
import * as Provider from "../provider.js";
|
|
4
|
+
export declare const invalidateSessionsArgs: import("convex/values").VObject<{
|
|
5
|
+
except?: string[] | undefined;
|
|
6
|
+
userId: string;
|
|
7
|
+
}, {
|
|
8
|
+
userId: import("convex/values").VString<string, "required">;
|
|
9
|
+
except: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
|
|
10
|
+
}, "required", "userId" | "except">;
|
|
11
|
+
export declare const callInvalidateSessions: (ctx: ActionCtx, args: Infer<typeof invalidateSessionsArgs>) => Promise<void>;
|
|
12
|
+
export declare const invalidateSessionsImpl: (ctx: MutationCtx, args: Infer<typeof invalidateSessionsArgs>, config: Provider.Config) => Promise<void>;
|
|
13
|
+
//# sourceMappingURL=invalidateSessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidateSessions.d.ts","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/invalidateSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,EAAK,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,eAAO,MAAM,sBAAsB;;;;;;mCAGjC,CAAC;AAEH,eAAO,MAAM,sBAAsB,GACjC,KAAK,SAAS,EACd,MAAM,KAAK,CAAC,OAAO,sBAAsB,CAAC,KACzC,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,KAAK,WAAW,EAChB,MAAM,KAAK,CAAC,OAAO,sBAAsB,CAAC,EAC1C,QAAQ,QAAQ,CAAC,MAAM,KACtB,OAAO,CAAC,IAAI,CAkBd,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { deleteSession } from "../sessions.js";
|
|
3
|
+
import { LOG_LEVELS, logWithLevel } from "../utils.js";
|
|
4
|
+
import { createAuthDb } from "../db.js";
|
|
5
|
+
export const invalidateSessionsArgs = v.object({
|
|
6
|
+
userId: v.string(),
|
|
7
|
+
except: v.optional(v.array(v.string())),
|
|
8
|
+
});
|
|
9
|
+
export const callInvalidateSessions = async (ctx, args) => {
|
|
10
|
+
return ctx.runMutation("auth:store", {
|
|
11
|
+
args: {
|
|
12
|
+
type: "invalidateSessions",
|
|
13
|
+
...args,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export const invalidateSessionsImpl = async (ctx, args, config) => {
|
|
18
|
+
logWithLevel(LOG_LEVELS.DEBUG, "invalidateSessionsImpl args:", args);
|
|
19
|
+
const { userId, except } = args;
|
|
20
|
+
const exceptSet = new Set(except ?? []);
|
|
21
|
+
const typedUserId = userId;
|
|
22
|
+
const sessions = config.component !== undefined
|
|
23
|
+
? await createAuthDb(ctx, config.component).sessions.listByUser(typedUserId)
|
|
24
|
+
: await ctx.db
|
|
25
|
+
.query("session")
|
|
26
|
+
.withIndex("userId", (q) => q.eq("userId", typedUserId))
|
|
27
|
+
.collect();
|
|
28
|
+
for (const session of sessions) {
|
|
29
|
+
if (!exceptSet.has(session._id)) {
|
|
30
|
+
await deleteSession(ctx, session, config);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=invalidateSessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidateSessions.js","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/invalidateSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,CAAC,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,GAAc,EACd,IAA0C,EAC3B,EAAE;IACjB,OAAO,GAAG,CAAC,WAAW,CAAC,YAAmB,EAAE;QAC1C,IAAI,EAAE;YACJ,IAAI,EAAE,oBAAoB;YAC1B,GAAG,IAAI;SACR;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,GAAgB,EAChB,IAA0C,EAC1C,MAAuB,EACR,EAAE;IACjB,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,8BAA8B,EAAE,IAAI,CAAC,CAAC;IACrE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,MAA2B,CAAC;IAChD,MAAM,QAAQ,GACZ,MAAM,CAAC,SAAS,KAAK,SAAS;QAC5B,CAAC,CAAC,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;QAC5E,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;aACT,KAAK,CAAC,SAAS,CAAC;aAChB,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;aACvD,OAAO,EAAE,CAAC;IACnB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,OAAO;AACT,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Infer } from "convex/values";
|
|
2
|
+
import { ActionCtx, MutationCtx } from "../types.js";
|
|
3
|
+
import { GetProviderOrThrowFunc } from "../provider.js";
|
|
4
|
+
import * as Provider from "../provider.js";
|
|
5
|
+
export declare const modifyAccountArgs: import("convex/values").VObject<{
|
|
6
|
+
account: {
|
|
7
|
+
id: string;
|
|
8
|
+
secret: string;
|
|
9
|
+
};
|
|
10
|
+
provider: string;
|
|
11
|
+
}, {
|
|
12
|
+
provider: import("convex/values").VString<string, "required">;
|
|
13
|
+
account: import("convex/values").VObject<{
|
|
14
|
+
id: string;
|
|
15
|
+
secret: string;
|
|
16
|
+
}, {
|
|
17
|
+
id: import("convex/values").VString<string, "required">;
|
|
18
|
+
secret: import("convex/values").VString<string, "required">;
|
|
19
|
+
}, "required", "id" | "secret">;
|
|
20
|
+
}, "required", "account" | "provider" | "account.id" | "account.secret">;
|
|
21
|
+
export declare function modifyAccountImpl(ctx: MutationCtx, args: Infer<typeof modifyAccountArgs>, getProviderOrThrow: GetProviderOrThrowFunc, config: Provider.Config): Promise<void>;
|
|
22
|
+
export declare const callModifyAccount: (ctx: ActionCtx, args: Infer<typeof modifyAccountArgs>) => Promise<void>;
|
|
23
|
+
//# sourceMappingURL=modifyAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifyAccount.d.ts","sourceRoot":"","sources":["../../../../src/server/implementation/mutations/modifyAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAK,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAQ,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;wEAG5B,CAAC;AAEH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,KAAK,CAAC,OAAO,iBAAiB,CAAC,EACrC,kBAAkB,EAAE,sBAAsB,EAC1C,MAAM,EAAE,QAAQ,CAAC,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAmCf;AAED,eAAO,MAAM,iBAAiB,GAC5B,KAAK,SAAS,EACd,MAAM,KAAK,CAAC,OAAO,iBAAiB,CAAC,KACpC,OAAO,CAAC,IAAI,CAOd,CAAC"}
|