@robelest/convex-auth 0.0.3-preview → 0.0.3-preview.3
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 +15 -15
- package/dist/client/index.d.ts +40 -12
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +73 -12
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -2
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +1 -1
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/{portalBridge.d.ts → bridge.d.ts} +2 -2
- package/dist/component/bridge.d.ts.map +1 -0
- package/dist/component/{portalBridge.js → bridge.js} +2 -2
- package/dist/component/bridge.js.map +1 -0
- package/dist/component/index.d.ts +11 -4
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js +8 -2
- package/dist/component/index.js.map +1 -1
- package/dist/component/public.d.ts +24 -17
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +23 -4
- package/dist/component/public.js.map +1 -1
- package/dist/component/schema.d.ts +11 -7
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +4 -1
- package/dist/component/schema.js.map +1 -1
- package/dist/providers/anonymous.d.ts +3 -0
- package/dist/providers/anonymous.d.ts.map +1 -1
- package/dist/providers/anonymous.js +3 -0
- package/dist/providers/anonymous.js.map +1 -1
- package/dist/providers/credentials.d.ts +3 -0
- package/dist/providers/credentials.d.ts.map +1 -1
- package/dist/providers/credentials.js +3 -0
- package/dist/providers/credentials.js.map +1 -1
- package/dist/providers/email.d.ts +3 -0
- package/dist/providers/email.d.ts.map +1 -1
- package/dist/providers/email.js +3 -0
- package/dist/providers/email.js.map +1 -1
- package/dist/providers/passkey.d.ts +7 -1
- package/dist/providers/passkey.d.ts.map +1 -1
- package/dist/providers/passkey.js +7 -1
- package/dist/providers/passkey.js.map +1 -1
- package/dist/providers/password.d.ts +3 -0
- package/dist/providers/password.d.ts.map +1 -1
- package/dist/providers/password.js +3 -0
- package/dist/providers/password.js.map +1 -1
- package/dist/providers/phone.d.ts +3 -0
- package/dist/providers/phone.d.ts.map +1 -1
- package/dist/providers/phone.js +3 -0
- package/dist/providers/phone.js.map +1 -1
- package/dist/providers/totp.d.ts +8 -0
- package/dist/providers/totp.d.ts.map +1 -1
- package/dist/providers/totp.js +8 -0
- package/dist/providers/totp.js.map +1 -1
- package/dist/server/{convex-auth.d.ts → auth.d.ts} +226 -36
- package/dist/server/auth.d.ts.map +1 -0
- package/dist/server/{convex-auth.js → auth.js} +287 -111
- package/dist/server/auth.js.map +1 -0
- package/dist/server/errors.d.ts +148 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +179 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/implementation/index.d.ts +170 -48
- package/dist/server/implementation/index.d.ts.map +1 -1
- package/dist/server/implementation/index.js +383 -167
- package/dist/server/implementation/index.js.map +1 -1
- package/dist/server/implementation/{apiKey.d.ts → keys.d.ts} +1 -1
- package/dist/server/implementation/keys.d.ts.map +1 -0
- package/dist/server/implementation/{apiKey.js → keys.js} +4 -5
- package/dist/server/implementation/keys.js.map +1 -0
- package/dist/server/implementation/mutations/{modifyAccount.d.ts → account.d.ts} +3 -3
- package/dist/server/implementation/mutations/account.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{modifyAccount.js → account.js} +4 -3
- package/dist/server/implementation/mutations/account.js.map +1 -0
- package/dist/server/implementation/mutations/{createVerificationCode.d.ts → code.d.ts} +1 -1
- package/dist/server/implementation/mutations/code.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{createVerificationCode.js → code.js} +2 -2
- package/dist/server/implementation/mutations/code.js.map +1 -0
- package/dist/server/implementation/mutations/index.d.ts +33 -33
- package/dist/server/implementation/mutations/index.d.ts.map +1 -1
- package/dist/server/implementation/mutations/index.js +22 -22
- package/dist/server/implementation/mutations/index.js.map +1 -1
- package/dist/server/implementation/mutations/{invalidateSessions.d.ts → invalidate.d.ts} +1 -1
- package/dist/server/implementation/mutations/invalidate.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{invalidateSessions.js → invalidate.js} +2 -2
- package/dist/server/implementation/mutations/invalidate.js.map +1 -0
- package/dist/server/implementation/mutations/{userOAuth.d.ts → oauth.d.ts} +3 -3
- package/dist/server/implementation/mutations/oauth.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{userOAuth.js → oauth.js} +4 -3
- package/dist/server/implementation/mutations/oauth.js.map +1 -0
- package/dist/server/implementation/mutations/{refreshSession.d.ts → refresh.d.ts} +1 -1
- package/dist/server/implementation/mutations/refresh.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{refreshSession.js → refresh.js} +3 -3
- package/dist/server/implementation/mutations/refresh.js.map +1 -0
- package/dist/server/implementation/mutations/{createAccountFromCredentials.d.ts → register.d.ts} +4 -4
- package/dist/server/implementation/mutations/register.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{createAccountFromCredentials.js → register.js} +4 -3
- package/dist/server/implementation/mutations/register.js.map +1 -0
- package/dist/server/implementation/mutations/{retrieveAccountWithCredentials.d.ts → retrieve.d.ts} +3 -3
- package/dist/server/implementation/mutations/retrieve.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{retrieveAccountWithCredentials.js → retrieve.js} +3 -3
- package/dist/server/implementation/mutations/retrieve.js.map +1 -0
- package/dist/server/implementation/mutations/{verifierSignature.d.ts → signature.d.ts} +1 -1
- package/dist/server/implementation/mutations/signature.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{verifierSignature.js → signature.js} +4 -3
- package/dist/server/implementation/mutations/signature.js.map +1 -0
- package/dist/server/implementation/mutations/{signIn.d.ts → signin.d.ts} +1 -1
- package/dist/server/implementation/mutations/{signIn.d.ts.map → signin.d.ts.map} +1 -1
- package/dist/server/implementation/mutations/{signIn.js → signin.js} +2 -2
- package/dist/server/implementation/mutations/{signIn.js.map → signin.js.map} +1 -1
- package/dist/server/implementation/mutations/{signOut.d.ts → signout.d.ts} +1 -1
- package/dist/server/implementation/mutations/{signOut.d.ts.map → signout.d.ts.map} +1 -1
- package/dist/server/implementation/mutations/{signOut.js → signout.js} +2 -2
- package/dist/server/implementation/mutations/{signOut.js.map → signout.js.map} +1 -1
- package/dist/server/implementation/mutations/{storeRef.d.ts → store.d.ts} +1 -1
- package/dist/server/implementation/mutations/store.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{storeRef.js → store.js} +1 -1
- package/dist/server/implementation/mutations/store.js.map +1 -0
- package/dist/server/implementation/mutations/verifier.js +1 -1
- package/dist/server/implementation/mutations/verifier.js.map +1 -1
- package/dist/server/implementation/mutations/{verifyCodeAndSignIn.d.ts → verify.d.ts} +1 -1
- package/dist/server/implementation/mutations/verify.d.ts.map +1 -0
- package/dist/server/implementation/mutations/{verifyCodeAndSignIn.js → verify.js} +3 -3
- package/dist/server/implementation/mutations/verify.js.map +1 -0
- package/dist/server/implementation/passkey.d.ts.map +1 -1
- package/dist/server/implementation/passkey.js +47 -55
- package/dist/server/implementation/passkey.js.map +1 -1
- package/dist/server/implementation/provider.d.ts.map +1 -1
- package/dist/server/implementation/provider.js +5 -4
- package/dist/server/implementation/provider.js.map +1 -1
- package/dist/server/implementation/{rateLimit.d.ts → ratelimit.d.ts} +1 -1
- package/dist/server/implementation/{rateLimit.d.ts.map → ratelimit.d.ts.map} +1 -1
- package/dist/server/implementation/{rateLimit.js → ratelimit.js} +1 -1
- package/dist/server/implementation/{rateLimit.js.map → ratelimit.js.map} +1 -1
- package/dist/server/implementation/redirects.d.ts.map +1 -1
- package/dist/server/implementation/redirects.js +2 -1
- package/dist/server/implementation/redirects.js.map +1 -1
- package/dist/server/implementation/{refreshTokens.d.ts → refresh.d.ts} +1 -1
- package/dist/server/implementation/refresh.d.ts.map +1 -0
- package/dist/server/implementation/{refreshTokens.js → refresh.js} +3 -2
- package/dist/server/implementation/refresh.js.map +1 -0
- package/dist/server/implementation/sessions.js +1 -1
- package/dist/server/implementation/sessions.js.map +1 -1
- package/dist/server/implementation/{signIn.d.ts → signin.d.ts} +1 -1
- package/dist/server/implementation/{signIn.d.ts.map → signin.d.ts.map} +1 -1
- package/dist/server/implementation/{signIn.js → signin.js} +12 -8
- package/dist/server/implementation/signin.js.map +1 -0
- package/dist/server/implementation/totp.d.ts.map +1 -1
- package/dist/server/implementation/totp.js +29 -29
- package/dist/server/implementation/totp.js.map +1 -1
- package/dist/server/implementation/types.d.ts +131 -1
- package/dist/server/implementation/types.d.ts.map +1 -1
- package/dist/server/implementation/types.js +65 -1
- 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 +3 -2
- package/dist/server/implementation/users.js.map +1 -1
- package/dist/server/index.d.ts +131 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +117 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/oauth/{authorizationUrl.d.ts → authorization.d.ts} +1 -1
- package/dist/server/oauth/authorization.d.ts.map +1 -0
- package/dist/server/oauth/{authorizationUrl.js → authorization.js} +4 -3
- package/dist/server/oauth/authorization.js.map +1 -0
- package/dist/server/oauth/callback.d.ts.map +1 -1
- package/dist/server/oauth/callback.js +7 -6
- package/dist/server/oauth/callback.js.map +1 -1
- package/dist/server/oauth/checks.d.ts.map +1 -1
- package/dist/server/oauth/checks.js +2 -1
- package/dist/server/oauth/checks.js.map +1 -1
- package/dist/server/oauth/{convexAuth.d.ts → helpers.d.ts} +1 -1
- package/dist/server/oauth/helpers.d.ts.map +1 -0
- package/dist/server/oauth/{convexAuth.js → helpers.js} +6 -5
- package/dist/server/oauth/helpers.js.map +1 -0
- package/dist/server/oauth/lib/utils/{customFetch.d.ts → fetch.d.ts} +1 -1
- package/dist/server/oauth/lib/utils/fetch.d.ts.map +1 -0
- package/dist/server/oauth/lib/utils/{customFetch.js → fetch.js} +1 -1
- package/dist/server/oauth/lib/utils/fetch.js.map +1 -0
- package/dist/server/{provider_utils.d.ts → providers.d.ts} +1 -1
- package/dist/server/providers.d.ts.map +1 -0
- package/dist/server/{provider_utils.js → providers.js} +1 -1
- package/dist/server/providers.js.map +1 -0
- package/dist/server/{email-templates.d.ts → templates.d.ts} +8 -1
- package/dist/server/templates.d.ts.map +1 -0
- package/dist/server/{portal-email.js → templates.js} +74 -3
- package/dist/server/templates.js.map +1 -0
- package/dist/server/types.d.ts +88 -5
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/server/utils.js +2 -1
- package/dist/server/utils.js.map +1 -1
- package/dist/server/version.d.ts +1 -1
- package/dist/server/version.d.ts.map +1 -1
- package/dist/server/version.js +1 -1
- package/dist/server/version.js.map +1 -1
- package/package.json +5 -1
- package/src/cli/index.ts +5 -5
- package/src/cli/{portal-link.ts → link.ts} +1 -1
- package/src/cli/utils.ts +1 -1
- package/src/client/index.ts +102 -17
- package/src/component/_generated/api.ts +2 -2
- package/src/component/_generated/component.ts +1 -1
- package/src/component/{portalBridge.ts → bridge.ts} +2 -2
- package/src/component/index.ts +10 -2
- package/src/component/public.ts +25 -4
- package/src/component/schema.ts +4 -1
- package/src/providers/anonymous.ts +3 -0
- package/src/providers/credentials.ts +3 -0
- package/src/providers/email.ts +3 -0
- package/src/providers/passkey.ts +8 -1
- package/src/providers/password.ts +3 -0
- package/src/providers/phone.ts +3 -0
- package/src/providers/totp.ts +9 -0
- package/src/server/auth.ts +969 -0
- package/src/server/errors.ts +275 -0
- package/src/server/implementation/index.ts +370 -88
- package/src/server/implementation/{apiKey.ts → keys.ts} +7 -6
- package/src/server/implementation/mutations/{modifyAccount.ts → account.ts} +3 -4
- package/src/server/implementation/mutations/{createVerificationCode.ts → code.ts} +1 -1
- package/src/server/implementation/mutations/index.ts +22 -22
- package/src/server/implementation/mutations/{invalidateSessions.ts → invalidate.ts} +1 -1
- package/src/server/implementation/mutations/{userOAuth.ts → oauth.ts} +3 -2
- package/src/server/implementation/mutations/{refreshSession.ts → refresh.ts} +2 -2
- package/src/server/implementation/mutations/{createAccountFromCredentials.ts → register.ts} +3 -2
- package/src/server/implementation/mutations/{retrieveAccountWithCredentials.ts → retrieve.ts} +2 -2
- package/src/server/implementation/mutations/{verifierSignature.ts → signature.ts} +3 -2
- package/src/server/implementation/mutations/{signIn.ts → signin.ts} +1 -1
- package/src/server/implementation/mutations/{signOut.ts → signout.ts} +1 -1
- package/src/server/implementation/mutations/verifier.ts +1 -1
- package/src/server/implementation/mutations/{verifyCodeAndSignIn.ts → verify.ts} +2 -2
- package/src/server/implementation/passkey.ts +86 -116
- package/src/server/implementation/provider.ts +5 -8
- package/src/server/implementation/redirects.ts +2 -3
- package/src/server/implementation/{refreshTokens.ts → refresh.ts} +2 -1
- package/src/server/implementation/sessions.ts +1 -1
- package/src/server/implementation/{signIn.ts → signin.ts} +13 -11
- package/src/server/implementation/totp.ts +60 -84
- package/src/server/implementation/types.ts +316 -1
- package/src/server/implementation/users.ts +4 -7
- package/src/server/index.ts +142 -3
- package/src/server/oauth/{authorizationUrl.ts → authorization.ts} +3 -2
- package/src/server/oauth/callback.ts +7 -6
- package/src/server/oauth/checks.ts +3 -1
- package/src/server/oauth/{convexAuth.ts → helpers.ts} +8 -5
- package/src/server/{portal-email.ts → templates.ts} +78 -2
- package/src/server/types.ts +133 -4
- package/src/server/utils.ts +3 -1
- package/src/server/version.ts +1 -1
- package/dist/component/portalBridge.d.ts.map +0 -1
- package/dist/component/portalBridge.js.map +0 -1
- package/dist/server/convex-auth.d.ts.map +0 -1
- package/dist/server/convex-auth.js.map +0 -1
- package/dist/server/convex_types.d.ts +0 -17
- package/dist/server/convex_types.d.ts.map +0 -1
- package/dist/server/convex_types.js +0 -2
- package/dist/server/convex_types.js.map +0 -1
- package/dist/server/email-templates.d.ts.map +0 -1
- package/dist/server/email-templates.js +0 -74
- package/dist/server/email-templates.js.map +0 -1
- package/dist/server/implementation/apiKey.d.ts.map +0 -1
- package/dist/server/implementation/apiKey.js.map +0 -1
- package/dist/server/implementation/mutations/createAccountFromCredentials.d.ts.map +0 -1
- package/dist/server/implementation/mutations/createAccountFromCredentials.js.map +0 -1
- package/dist/server/implementation/mutations/createVerificationCode.d.ts.map +0 -1
- package/dist/server/implementation/mutations/createVerificationCode.js.map +0 -1
- package/dist/server/implementation/mutations/invalidateSessions.d.ts.map +0 -1
- package/dist/server/implementation/mutations/invalidateSessions.js.map +0 -1
- package/dist/server/implementation/mutations/modifyAccount.d.ts.map +0 -1
- package/dist/server/implementation/mutations/modifyAccount.js.map +0 -1
- package/dist/server/implementation/mutations/refreshSession.d.ts.map +0 -1
- package/dist/server/implementation/mutations/refreshSession.js.map +0 -1
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.d.ts.map +0 -1
- package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js.map +0 -1
- package/dist/server/implementation/mutations/storeRef.d.ts.map +0 -1
- package/dist/server/implementation/mutations/storeRef.js.map +0 -1
- package/dist/server/implementation/mutations/userOAuth.d.ts.map +0 -1
- package/dist/server/implementation/mutations/userOAuth.js.map +0 -1
- package/dist/server/implementation/mutations/verifierSignature.d.ts.map +0 -1
- package/dist/server/implementation/mutations/verifierSignature.js.map +0 -1
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.d.ts.map +0 -1
- package/dist/server/implementation/mutations/verifyCodeAndSignIn.js.map +0 -1
- package/dist/server/implementation/refreshTokens.d.ts.map +0 -1
- package/dist/server/implementation/refreshTokens.js.map +0 -1
- package/dist/server/implementation/signIn.js.map +0 -1
- package/dist/server/oauth/authorizationUrl.d.ts.map +0 -1
- package/dist/server/oauth/authorizationUrl.js.map +0 -1
- package/dist/server/oauth/convexAuth.d.ts.map +0 -1
- package/dist/server/oauth/convexAuth.js.map +0 -1
- package/dist/server/oauth/lib/utils/customFetch.d.ts.map +0 -1
- package/dist/server/oauth/lib/utils/customFetch.js.map +0 -1
- package/dist/server/portal-email.d.ts +0 -19
- package/dist/server/portal-email.d.ts.map +0 -1
- package/dist/server/portal-email.js.map +0 -1
- package/dist/server/provider_utils.d.ts.map +0 -1
- package/dist/server/provider_utils.js.map +0 -1
- package/src/server/convex-auth.ts +0 -602
- package/src/server/convex_types.ts +0 -55
- package/src/server/email-templates.ts +0 -77
- /package/src/cli/{generateKeys.ts → keys.ts} +0 -0
- /package/src/cli/{portal-upload.ts → upload.ts} +0 -0
- /package/src/server/implementation/mutations/{storeRef.ts → store.ts} +0 -0
- /package/src/server/implementation/{rateLimit.ts → ratelimit.ts} +0 -0
- /package/src/server/oauth/lib/utils/{customFetch.ts → fetch.ts} +0 -0
- /package/src/server/{provider_utils.ts → providers.ts} +0 -0
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { sha256, generateRandomString } from "./utils.js";
|
|
12
12
|
import type { KeyScope, ScopeChecker } from "../types.js";
|
|
13
|
+
import { throwAuthError } from "../errors.js";
|
|
13
14
|
|
|
14
15
|
// ============================================================================
|
|
15
16
|
// Constants
|
|
@@ -110,16 +111,16 @@ export function validateScopes(
|
|
|
110
111
|
for (const scope of requested) {
|
|
111
112
|
const allowedActions = allowed[scope.resource];
|
|
112
113
|
if (!allowedActions) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
throwAuthError(
|
|
115
|
+
"API_KEY_INVALID_SCOPE",
|
|
116
|
+
`Unknown resource "${scope.resource}" in API key scopes. Allowed resources: ${Object.keys(allowed).join(", ")}`,
|
|
116
117
|
);
|
|
117
118
|
}
|
|
118
119
|
for (const action of scope.actions) {
|
|
119
120
|
if (action !== "*" && !allowedActions.includes(action)) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
throwAuthError(
|
|
122
|
+
"API_KEY_INVALID_SCOPE",
|
|
123
|
+
`Unknown action "${action}" for resource "${scope.resource}". Allowed actions: ${allowedActions.join(", ")}`,
|
|
123
124
|
);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
@@ -4,7 +4,8 @@ import { GetProviderOrThrowFunc, hash } from "../provider.js";
|
|
|
4
4
|
import { LOG_LEVELS, logWithLevel, maybeRedact } from "../utils.js";
|
|
5
5
|
import * as Provider from "../provider.js";
|
|
6
6
|
import { authDb } from "../db.js";
|
|
7
|
-
import { AUTH_STORE_REF } from "./
|
|
7
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
8
|
+
import { throwAuthError } from "../../errors.js";
|
|
8
9
|
|
|
9
10
|
export const modifyAccountArgs = v.object({
|
|
10
11
|
provider: v.string(),
|
|
@@ -28,9 +29,7 @@ export async function modifyAccountImpl(
|
|
|
28
29
|
});
|
|
29
30
|
const existingAccount = await db.accounts.get(provider, account.id);
|
|
30
31
|
if (existingAccount === null) {
|
|
31
|
-
|
|
32
|
-
`Cannot modify account with ID ${account.id} because it does not exist`,
|
|
33
|
-
);
|
|
32
|
+
throwAuthError("ACCOUNT_NOT_FOUND", `Cannot modify account with ID ${account.id} because it does not exist`);
|
|
34
33
|
}
|
|
35
34
|
await db.accounts.patch(existingAccount._id, {
|
|
36
35
|
secret: await hash(getProviderOrThrow(provider), account.secret),
|
|
@@ -6,7 +6,7 @@ import { getAccountOrThrow, upsertUserAndAccount } from "../users.js";
|
|
|
6
6
|
import { getAuthSessionId } from "../sessions.js";
|
|
7
7
|
import { LOG_LEVELS, logWithLevel, sha256 } from "../utils.js";
|
|
8
8
|
import { authDb } from "../db.js";
|
|
9
|
-
import { AUTH_STORE_REF } from "./
|
|
9
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
10
10
|
|
|
11
11
|
export const createVerificationCodeArgs = v.object({
|
|
12
12
|
accountId: v.optional(v.string()),
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
import { Infer, v } from "convex/values";
|
|
2
2
|
import { MutationCtx } from "../types.js";
|
|
3
|
-
import { signInArgs, signInImpl } from "./
|
|
4
|
-
import { signOutImpl } from "./
|
|
5
|
-
import { refreshSessionArgs, refreshSessionImpl } from "./
|
|
3
|
+
import { signInArgs, signInImpl } from "./signin.js";
|
|
4
|
+
import { signOutImpl } from "./signout.js";
|
|
5
|
+
import { refreshSessionArgs, refreshSessionImpl } from "./refresh.js";
|
|
6
6
|
import {
|
|
7
7
|
verifyCodeAndSignInArgs,
|
|
8
8
|
verifyCodeAndSignInImpl,
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./verify.js";
|
|
10
10
|
import {
|
|
11
11
|
verifierSignatureArgs,
|
|
12
12
|
verifierSignatureImpl,
|
|
13
|
-
} from "./
|
|
14
|
-
import { userOAuthArgs, userOAuthImpl } from "./
|
|
13
|
+
} from "./signature.js";
|
|
14
|
+
import { userOAuthArgs, userOAuthImpl } from "./oauth.js";
|
|
15
15
|
import {
|
|
16
16
|
createVerificationCodeArgs,
|
|
17
17
|
createVerificationCodeImpl,
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./code.js";
|
|
19
19
|
import {
|
|
20
20
|
createAccountFromCredentialsArgs,
|
|
21
21
|
createAccountFromCredentialsImpl,
|
|
22
|
-
} from "./
|
|
22
|
+
} from "./register.js";
|
|
23
23
|
import {
|
|
24
24
|
retrieveAccountWithCredentialsArgs,
|
|
25
25
|
retrieveAccountWithCredentialsImpl,
|
|
26
|
-
} from "./
|
|
27
|
-
import { modifyAccountArgs, modifyAccountImpl } from "./
|
|
26
|
+
} from "./retrieve.js";
|
|
27
|
+
import { modifyAccountArgs, modifyAccountImpl } from "./account.js";
|
|
28
28
|
import {
|
|
29
29
|
invalidateSessionsArgs,
|
|
30
30
|
invalidateSessionsImpl,
|
|
31
|
-
} from "./
|
|
31
|
+
} from "./invalidate.js";
|
|
32
32
|
import * as Provider from "../provider.js";
|
|
33
33
|
import { verifierImpl } from "./verifier.js";
|
|
34
34
|
import { LOG_LEVELS, logWithLevel } from "../utils.js";
|
|
35
|
-
export { callInvalidateSessions } from "./
|
|
36
|
-
export { callModifyAccount } from "./
|
|
37
|
-
export { callRetreiveAccountWithCredentials } from "./
|
|
38
|
-
export { callCreateAccountFromCredentials } from "./
|
|
39
|
-
export { callCreateVerificationCode } from "./
|
|
40
|
-
export { callUserOAuth } from "./
|
|
41
|
-
export { callVerifierSignature } from "./
|
|
42
|
-
export { callVerifyCodeAndSignIn } from "./
|
|
35
|
+
export { callInvalidateSessions } from "./invalidate.js";
|
|
36
|
+
export { callModifyAccount } from "./account.js";
|
|
37
|
+
export { callRetreiveAccountWithCredentials } from "./retrieve.js";
|
|
38
|
+
export { callCreateAccountFromCredentials } from "./register.js";
|
|
39
|
+
export { callCreateVerificationCode } from "./code.js";
|
|
40
|
+
export { callUserOAuth } from "./oauth.js";
|
|
41
|
+
export { callVerifierSignature } from "./signature.js";
|
|
42
|
+
export { callVerifyCodeAndSignIn } from "./verify.js";
|
|
43
43
|
export { callVerifier } from "./verifier.js";
|
|
44
|
-
export { callRefreshSession } from "./
|
|
45
|
-
export { callSignOut } from "./
|
|
46
|
-
export { callSignIn } from "./
|
|
44
|
+
export { callRefreshSession } from "./refresh.js";
|
|
45
|
+
export { callSignOut } from "./signout.js";
|
|
46
|
+
export { callSignIn } from "./signin.js";
|
|
47
47
|
|
|
48
48
|
export const storeArgs = v.object({
|
|
49
49
|
args: v.union(
|
|
@@ -4,7 +4,7 @@ import { ActionCtx, MutationCtx } from "../types.js";
|
|
|
4
4
|
import { LOG_LEVELS, logWithLevel } from "../utils.js";
|
|
5
5
|
import * as Provider from "../provider.js";
|
|
6
6
|
import { authDb } from "../db.js";
|
|
7
|
-
import { AUTH_STORE_REF } from "./
|
|
7
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
8
8
|
|
|
9
9
|
export const invalidateSessionsArgs = v.object({
|
|
10
10
|
userId: v.string(),
|
|
@@ -5,7 +5,8 @@ import { OAuthConfig } from "@auth/core/providers/oauth.js";
|
|
|
5
5
|
import { upsertUserAndAccount } from "../users.js";
|
|
6
6
|
import { generateRandomString, logWithLevel, sha256 } from "../utils.js";
|
|
7
7
|
import { authDb } from "../db.js";
|
|
8
|
-
import { AUTH_STORE_REF } from "./
|
|
8
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
9
|
+
import { throwAuthError } from "../../errors.js";
|
|
9
10
|
|
|
10
11
|
const OAUTH_SIGN_IN_EXPIRATION_MS = 1000 * 60 * 2; // 2 minutes
|
|
11
12
|
|
|
@@ -32,7 +33,7 @@ export async function userOAuthImpl(
|
|
|
32
33
|
|
|
33
34
|
const verifier = await db.verifiers.getBySignature(signature);
|
|
34
35
|
if (verifier === null) {
|
|
35
|
-
|
|
36
|
+
throwAuthError("OAUTH_INVALID_STATE");
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
const { accountId } = await upsertUserAndAccount(
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
parseRefreshToken,
|
|
10
10
|
REFRESH_TOKEN_REUSE_WINDOW_MS,
|
|
11
11
|
refreshTokenIfValid,
|
|
12
|
-
} from "../
|
|
12
|
+
} from "../refresh.js";
|
|
13
13
|
import { generateTokensForSession } from "../sessions.js";
|
|
14
14
|
import { authDb } from "../db.js";
|
|
15
|
-
import { AUTH_STORE_REF } from "./
|
|
15
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
16
16
|
|
|
17
17
|
export const refreshSessionArgs = v.object({
|
|
18
18
|
refreshToken: v.string(),
|
|
@@ -6,7 +6,8 @@ import { upsertUserAndAccount } from "../users.js";
|
|
|
6
6
|
import { getAuthSessionId } from "../sessions.js";
|
|
7
7
|
import { LOG_LEVELS, logWithLevel, maybeRedact } from "../utils.js";
|
|
8
8
|
import { authDb } from "../db.js";
|
|
9
|
-
import { AUTH_STORE_REF } from "./
|
|
9
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
10
|
+
import { throwAuthError } from "../../errors.js";
|
|
10
11
|
|
|
11
12
|
export const createAccountFromCredentialsArgs = v.object({
|
|
12
13
|
provider: v.string(),
|
|
@@ -53,7 +54,7 @@ export async function createAccountFromCredentialsImpl(
|
|
|
53
54
|
existingAccount.secret ?? "",
|
|
54
55
|
))
|
|
55
56
|
) {
|
|
56
|
-
|
|
57
|
+
throwAuthError("ACCOUNT_ALREADY_EXISTS", `Account ${account.id} already exists`);
|
|
57
58
|
}
|
|
58
59
|
return {
|
|
59
60
|
account: existingAccount,
|
package/src/server/implementation/mutations/{retrieveAccountWithCredentials.ts → retrieve.ts}
RENAMED
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
isSignInRateLimited,
|
|
5
5
|
recordFailedSignIn,
|
|
6
6
|
resetSignInRateLimit,
|
|
7
|
-
} from "../
|
|
7
|
+
} from "../ratelimit.js";
|
|
8
8
|
import * as Provider from "../provider.js";
|
|
9
9
|
import { LOG_LEVELS, logWithLevel, maybeRedact } from "../utils.js";
|
|
10
10
|
import { authDb } from "../db.js";
|
|
11
|
-
import { AUTH_STORE_REF } from "./
|
|
11
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
12
12
|
|
|
13
13
|
export const retrieveAccountWithCredentialsArgs = v.object({
|
|
14
14
|
provider: v.string(),
|
|
@@ -2,7 +2,8 @@ import { GenericId, Infer, v } from "convex/values";
|
|
|
2
2
|
import { ActionCtx, MutationCtx } from "../types.js";
|
|
3
3
|
import * as Provider from "../provider.js";
|
|
4
4
|
import { authDb } from "../db.js";
|
|
5
|
-
import { AUTH_STORE_REF } from "./
|
|
5
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
6
|
+
import { throwAuthError } from "../../errors.js";
|
|
6
7
|
|
|
7
8
|
export const verifierSignatureArgs = v.object({
|
|
8
9
|
verifier: v.string(),
|
|
@@ -20,7 +21,7 @@ export async function verifierSignatureImpl(
|
|
|
20
21
|
const db = authDb(ctx, config);
|
|
21
22
|
const verifierDoc = await db.verifiers.getById(verifier as GenericId<"verifier">);
|
|
22
23
|
if (verifierDoc === null) {
|
|
23
|
-
|
|
24
|
+
throwAuthError("INVALID_VERIFIER");
|
|
24
25
|
}
|
|
25
26
|
return await db.verifiers.patch(verifierDoc._id, { signature });
|
|
26
27
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
maybeGenerateTokensForSession,
|
|
7
7
|
} from "../sessions.js";
|
|
8
8
|
import { LOG_LEVELS, logWithLevel } from "../utils.js";
|
|
9
|
-
import { AUTH_STORE_REF } from "./
|
|
9
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
10
10
|
|
|
11
11
|
export const signInArgs = v.object({
|
|
12
12
|
userId: v.string(),
|
|
@@ -3,7 +3,7 @@ import { ActionCtx, MutationCtx } from "../types.js";
|
|
|
3
3
|
import { deleteSession, getAuthSessionId } from "../sessions.js";
|
|
4
4
|
import * as Provider from "../provider.js";
|
|
5
5
|
import { authDb } from "../db.js";
|
|
6
|
-
import { AUTH_STORE_REF } from "./
|
|
6
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
7
7
|
|
|
8
8
|
type ReturnType = {
|
|
9
9
|
userId: GenericId<"user">;
|
|
@@ -3,7 +3,7 @@ import { ActionCtx, MutationCtx } from "../types.js";
|
|
|
3
3
|
import { getAuthSessionId } from "../sessions.js";
|
|
4
4
|
import * as Provider from "../provider.js";
|
|
5
5
|
import { authDb } from "../db.js";
|
|
6
|
-
import { AUTH_STORE_REF } from "./
|
|
6
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
7
7
|
|
|
8
8
|
type ReturnType = GenericId<"verifier">;
|
|
9
9
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
isSignInRateLimited,
|
|
5
5
|
recordFailedSignIn,
|
|
6
6
|
resetSignInRateLimit,
|
|
7
|
-
} from "../
|
|
7
|
+
} from "../ratelimit.js";
|
|
8
8
|
import * as Provider from "../provider.js";
|
|
9
9
|
import {
|
|
10
10
|
createNewAndDeleteExistingSession,
|
|
@@ -15,7 +15,7 @@ import { ConvexAuthConfig } from "../../types.js";
|
|
|
15
15
|
import { LOG_LEVELS, logWithLevel, sha256 } from "../utils.js";
|
|
16
16
|
import { upsertUserAndAccount } from "../users.js";
|
|
17
17
|
import { authDb } from "../db.js";
|
|
18
|
-
import { AUTH_STORE_REF } from "./
|
|
18
|
+
import { AUTH_STORE_REF } from "./store.js";
|
|
19
19
|
|
|
20
20
|
export const verifyCodeAndSignInArgs = v.object({
|
|
21
21
|
params: v.any(),
|