@robelest/convex-auth 0.0.2-preview.1 → 0.0.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 +466 -63
- package/dist/client/index.d.ts +211 -30
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +673 -59
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +56 -1
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +93 -3
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +2 -0
- package/dist/component/convex.config.js.map +1 -1
- package/dist/component/index.d.ts +5 -3
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js +5 -3
- package/dist/component/index.js.map +1 -1
- package/dist/component/portalBridge.d.ts +80 -0
- package/dist/component/portalBridge.d.ts.map +1 -0
- package/dist/component/portalBridge.js +102 -0
- package/dist/component/portalBridge.js.map +1 -0
- package/dist/component/public.d.ts +193 -9
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +204 -33
- package/dist/component/public.js.map +1 -1
- package/dist/component/schema.d.ts +89 -9
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +68 -7
- 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/passkey.d.ts +20 -0
- package/dist/providers/passkey.d.ts.map +1 -0
- package/dist/providers/passkey.js +32 -0
- package/dist/providers/passkey.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/providers/totp.d.ts +14 -0
- package/dist/providers/totp.d.ts.map +1 -0
- package/dist/providers/totp.js +23 -0
- package/dist/providers/totp.js.map +1 -0
- package/dist/server/convex-auth.d.ts +243 -0
- package/dist/server/convex-auth.d.ts.map +1 -0
- package/dist/server/convex-auth.js +365 -0
- package/dist/server/convex-auth.js.map +1 -0
- package/dist/server/implementation/index.d.ts +153 -166
- package/dist/server/implementation/index.d.ts.map +1 -1
- package/dist/server/implementation/index.js +162 -105
- package/dist/server/implementation/index.js.map +1 -1
- package/dist/server/implementation/passkey.d.ts +33 -0
- package/dist/server/implementation/passkey.d.ts.map +1 -0
- package/dist/server/implementation/passkey.js +450 -0
- package/dist/server/implementation/passkey.js.map +1 -0
- package/dist/server/implementation/redirects.d.ts.map +1 -1
- package/dist/server/implementation/redirects.js +4 -9
- package/dist/server/implementation/redirects.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 +2 -20
- package/dist/server/implementation/sessions.js.map +1 -1
- package/dist/server/implementation/signIn.d.ts +13 -0
- package/dist/server/implementation/signIn.d.ts.map +1 -1
- package/dist/server/implementation/signIn.js +26 -1
- package/dist/server/implementation/signIn.js.map +1 -1
- package/dist/server/implementation/totp.d.ts +40 -0
- package/dist/server/implementation/totp.d.ts.map +1 -0
- package/dist/server/implementation/totp.js +211 -0
- package/dist/server/implementation/totp.js.map +1 -0
- 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/portal-email.d.ts +19 -0
- package/dist/server/portal-email.d.ts.map +1 -0
- package/dist/server/portal-email.js +89 -0
- package/dist/server/portal-email.js.map +1 -0
- package/dist/server/portal.d.ts +116 -0
- package/dist/server/portal.d.ts.map +1 -0
- package/dist/server/portal.js +294 -0
- package/dist/server/portal.js.map +1 -0
- 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 +39 -1
- package/dist/server/provider_utils.js.map +1 -1
- package/dist/server/types.d.ts +128 -11
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/cli/index.ts +48 -6
- package/src/cli/portal-link.ts +112 -0
- package/src/cli/portal-upload.ts +411 -0
- package/src/client/index.ts +823 -109
- package/src/component/_generated/api.ts +72 -1
- package/src/component/_generated/component.ts +180 -4
- package/src/component/convex.config.ts +3 -0
- package/src/component/index.ts +5 -10
- package/src/component/portalBridge.ts +116 -0
- package/src/component/public.ts +231 -37
- package/src/component/schema.ts +70 -7
- 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/passkey.ts +35 -0
- package/src/providers/{Password.ts → password.ts} +22 -27
- package/src/providers/{Phone.ts → phone.ts} +2 -2
- package/src/providers/totp.ts +26 -0
- package/src/server/convex-auth.ts +470 -0
- package/src/server/implementation/index.ts +228 -239
- package/src/server/implementation/passkey.ts +650 -0
- package/src/server/implementation/redirects.ts +4 -11
- package/src/server/implementation/sessions.ts +2 -20
- package/src/server/implementation/signIn.ts +39 -1
- package/src/server/implementation/totp.ts +366 -0
- package/src/server/index.ts +373 -0
- package/src/server/portal-email.ts +95 -0
- package/src/server/portal.ts +375 -0
- package/src/server/provider_utils.ts +42 -1
- package/src/server/types.ts +161 -10
- 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
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
* you can override the `authorize` method to skip the check:
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* import
|
|
19
|
-
* import {
|
|
18
|
+
* import email from "@robelest/convex-auth/providers/email";
|
|
19
|
+
* import { Auth } from "@robelest/convex-auth/component";
|
|
20
20
|
*
|
|
21
|
-
* export const { auth, signIn, signOut, store } =
|
|
21
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
22
22
|
* providers: [
|
|
23
|
-
*
|
|
23
|
+
* email({ authorize: undefined }),
|
|
24
24
|
* ],
|
|
25
25
|
* });
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
28
|
* Make sure the token has high enough entropy to be secure.
|
|
29
29
|
*/
|
|
30
|
-
export function
|
|
30
|
+
export default function email(config) {
|
|
31
31
|
return {
|
|
32
32
|
id: "email",
|
|
33
33
|
type: "email",
|
|
@@ -47,4 +47,4 @@ export function Email(config) {
|
|
|
47
47
|
options: config,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
//# sourceMappingURL=
|
|
50
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/providers/email.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAC3B,MAC8C;IAE9C,OAAO;QACL,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,+BAA+B;QACrC,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,SAAS;QAC1B,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;YACnC,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;YACJ,CAAC;YACD,IAAI,OAAO,CAAC,iBAAiB,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,CACb,sDAAsD;oBACpD,wBAAwB,CAC3B,CAAC;YACJ,CAAC;QACH,CAAC;QACD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;QACvD,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PasskeyProviderConfig } from "../server/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Passkey (WebAuthn) authentication provider.
|
|
4
|
+
*
|
|
5
|
+
* Enables passwordless authentication via biometrics, security keys,
|
|
6
|
+
* and synced passkeys using the Web Authentication API.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import passkey from "@robelest/convex-auth/providers/passkey";
|
|
10
|
+
*
|
|
11
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
12
|
+
* component: components.auth,
|
|
13
|
+
* providers: [passkey()],
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param config Optional configuration for the relying party and credential options.
|
|
18
|
+
*/
|
|
19
|
+
export default function passkey(config?: Partial<PasskeyProviderConfig["options"]>): PasskeyProviderConfig;
|
|
20
|
+
//# sourceMappingURL=passkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/providers/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,GACjD,qBAAqB,CAavB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passkey (WebAuthn) authentication provider.
|
|
3
|
+
*
|
|
4
|
+
* Enables passwordless authentication via biometrics, security keys,
|
|
5
|
+
* and synced passkeys using the Web Authentication API.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import passkey from "@robelest/convex-auth/providers/passkey";
|
|
9
|
+
*
|
|
10
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
11
|
+
* component: components.auth,
|
|
12
|
+
* providers: [passkey()],
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param config Optional configuration for the relying party and credential options.
|
|
17
|
+
*/
|
|
18
|
+
export default function passkey(config) {
|
|
19
|
+
return {
|
|
20
|
+
id: "passkey",
|
|
21
|
+
type: "passkey",
|
|
22
|
+
options: {
|
|
23
|
+
attestation: "none",
|
|
24
|
+
userVerification: "required",
|
|
25
|
+
residentKey: "preferred",
|
|
26
|
+
algorithms: [-7, -257], // ES256, RS256
|
|
27
|
+
challengeExpirationMs: 300_000, // 5 minutes
|
|
28
|
+
...config,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=passkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkey.js","sourceRoot":"","sources":["../../src/providers/passkey.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,MAAkD;IAElD,OAAO;QACL,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACP,WAAW,EAAE,MAAM;YACnB,gBAAgB,EAAE,UAAU;YAC5B,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,eAAe;YACvC,qBAAqB,EAAE,OAAO,EAAE,YAAY;YAC5C,GAAG,MAAM;SACV;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configure {@link
|
|
2
|
+
* Configure {@link password} provider given a {@link PasswordConfig}.
|
|
3
3
|
*
|
|
4
|
-
* The `
|
|
4
|
+
* The `password` provider supports the following flows, determined
|
|
5
5
|
* by the `flow` parameter:
|
|
6
6
|
*
|
|
7
7
|
* - `"signUp"`: Create a new account with a password.
|
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
* included in params, verify an OTP.
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* import
|
|
16
|
-
* import {
|
|
15
|
+
* import password from "@robelest/convex-auth/providers/password";
|
|
16
|
+
* import { Auth } from "@robelest/convex-auth/component";
|
|
17
17
|
*
|
|
18
|
-
* export const { auth, signIn, signOut, store } =
|
|
19
|
-
* providers: [
|
|
18
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
19
|
+
* providers: [password],
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* @module
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
25
|
+
import { CredentialsUserConfig } from "@robelest/convex-auth/providers/credentials";
|
|
26
26
|
import { EmailConfig, GenericActionCtxWithAuthConfig } from "@robelest/convex-auth/component";
|
|
27
27
|
import { DocumentByName, GenericDataModel, WithoutSystemFields } from "convex/server";
|
|
28
28
|
import { Value } from "convex/values";
|
|
29
29
|
/**
|
|
30
|
-
* The available options to a {@link
|
|
30
|
+
* The available options to a {@link password} provider for Convex Auth.
|
|
31
31
|
*/
|
|
32
32
|
export interface PasswordConfig<DataModel extends GenericDataModel> {
|
|
33
33
|
/**
|
|
@@ -70,7 +70,7 @@ export interface PasswordConfig<DataModel extends GenericDataModel> {
|
|
|
70
70
|
* Provide hashing and verification functions if you want to control
|
|
71
71
|
* how passwords are hashed.
|
|
72
72
|
*/
|
|
73
|
-
crypto?:
|
|
73
|
+
crypto?: CredentialsUserConfig["crypto"];
|
|
74
74
|
/**
|
|
75
75
|
* An Auth.js email provider used to require verification
|
|
76
76
|
* before password reset.
|
|
@@ -92,4 +92,4 @@ export interface PasswordConfig<DataModel extends GenericDataModel> {
|
|
|
92
92
|
* an email provider to the `verify` option.
|
|
93
93
|
*/
|
|
94
94
|
export default function password<DataModel extends GenericDataModel>(config?: PasswordConfig<DataModel>): import("@robelest/convex-auth/component").ConvexCredentialsConfig;
|
|
95
|
-
//# sourceMappingURL=
|
|
95
|
+
//# sourceMappingURL=password.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/providers/password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAoB,EAClB,qBAAqB,EACtB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EACX,8BAA8B,EAE/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,SAAS,SAAS,gBAAgB;IAChE;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,OAAO,CAAC,EAAE;IACR;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,SAAS,CAAC;IACzC;;;OAGG;IACH,GAAG,EAAE,8BAA8B,CAAC,SAAS,CAAC,KAC3C,mBAAmB,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,GAAG;QAC5D,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;;;;;;;;;OAUG;IACH,4BAA4B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D;;;OAGG;IACH,MAAM,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACzC;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;IACtD;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;CACxD;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,SAAS,SAAS,gBAAgB,EACjE,MAAM,GAAE,cAAc,CAAC,SAAS,CAAM,qEA8HvC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configure {@link
|
|
2
|
+
* Configure {@link password} provider given a {@link PasswordConfig}.
|
|
3
3
|
*
|
|
4
|
-
* The `
|
|
4
|
+
* The `password` provider supports the following flows, determined
|
|
5
5
|
* by the `flow` parameter:
|
|
6
6
|
*
|
|
7
7
|
* - `"signUp"`: Create a new account with a password.
|
|
@@ -12,18 +12,17 @@
|
|
|
12
12
|
* included in params, verify an OTP.
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* import
|
|
16
|
-
* import {
|
|
15
|
+
* import password from "@robelest/convex-auth/providers/password";
|
|
16
|
+
* import { Auth } from "@robelest/convex-auth/component";
|
|
17
17
|
*
|
|
18
|
-
* export const { auth, signIn, signOut, store } =
|
|
19
|
-
* providers: [
|
|
18
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
19
|
+
* providers: [password],
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* @module
|
|
24
24
|
*/
|
|
25
|
-
import
|
|
26
|
-
import { createAccount, invalidateSessions, modifyAccountCredentials, retrieveAccount, signInViaProvider, } from "@robelest/convex-auth/component";
|
|
25
|
+
import credentials from "@robelest/convex-auth/providers/credentials";
|
|
27
26
|
import { Scrypt } from "lucia";
|
|
28
27
|
/**
|
|
29
28
|
* Email and password authentication provider.
|
|
@@ -36,7 +35,7 @@ import { Scrypt } from "lucia";
|
|
|
36
35
|
*/
|
|
37
36
|
export default function password(config = {}) {
|
|
38
37
|
const provider = config.id ?? "password";
|
|
39
|
-
return
|
|
38
|
+
return credentials({
|
|
40
39
|
id: "password",
|
|
41
40
|
authorize: async (params, ctx) => {
|
|
42
41
|
const flow = params.flow;
|
|
@@ -62,7 +61,7 @@ export default function password(config = {}) {
|
|
|
62
61
|
if (secret === undefined) {
|
|
63
62
|
throw new Error("Missing `password` param for `signUp` flow");
|
|
64
63
|
}
|
|
65
|
-
const created = await
|
|
64
|
+
const created = await ctx.auth.account.create(ctx, {
|
|
66
65
|
provider,
|
|
67
66
|
account: { id: email, secret },
|
|
68
67
|
profile: profile,
|
|
@@ -75,7 +74,7 @@ export default function password(config = {}) {
|
|
|
75
74
|
if (secret === undefined) {
|
|
76
75
|
throw new Error("Missing `password` param for `signIn` flow");
|
|
77
76
|
}
|
|
78
|
-
const retrieved = await
|
|
77
|
+
const retrieved = await ctx.auth.account.get(ctx, {
|
|
79
78
|
provider,
|
|
80
79
|
account: { id: email, secret },
|
|
81
80
|
});
|
|
@@ -89,11 +88,11 @@ export default function password(config = {}) {
|
|
|
89
88
|
if (!config.reset) {
|
|
90
89
|
throw new Error(`Password reset is not enabled for ${provider}`);
|
|
91
90
|
}
|
|
92
|
-
const { account } = await
|
|
91
|
+
const { account } = await ctx.auth.account.get(ctx, {
|
|
93
92
|
provider,
|
|
94
93
|
account: { id: email },
|
|
95
94
|
});
|
|
96
|
-
return await
|
|
95
|
+
return await ctx.auth.provider.signIn(ctx, config.reset, {
|
|
97
96
|
accountId: account._id,
|
|
98
97
|
params,
|
|
99
98
|
});
|
|
@@ -105,17 +104,17 @@ export default function password(config = {}) {
|
|
|
105
104
|
if (params.newPassword === undefined) {
|
|
106
105
|
throw new Error("Missing `newPassword` param for `reset-verification` flow");
|
|
107
106
|
}
|
|
108
|
-
const result = await
|
|
107
|
+
const result = await ctx.auth.provider.signIn(ctx, config.reset, { params });
|
|
109
108
|
if (result === null) {
|
|
110
109
|
throw new Error("Invalid code");
|
|
111
110
|
}
|
|
112
111
|
const { userId, sessionId } = result;
|
|
113
112
|
const secret = params.newPassword;
|
|
114
|
-
await
|
|
113
|
+
await ctx.auth.account.updateCredentials(ctx, {
|
|
115
114
|
provider,
|
|
116
115
|
account: { id: email, secret },
|
|
117
116
|
});
|
|
118
|
-
await
|
|
117
|
+
await ctx.auth.session.invalidate(ctx, { userId, except: [sessionId] });
|
|
119
118
|
return { userId, sessionId };
|
|
120
119
|
// END
|
|
121
120
|
// START: Optional, email verification during sign in
|
|
@@ -124,11 +123,11 @@ export default function password(config = {}) {
|
|
|
124
123
|
if (!config.verify) {
|
|
125
124
|
throw new Error(`Email verification is not enabled for ${provider}`);
|
|
126
125
|
}
|
|
127
|
-
const { account } = await
|
|
126
|
+
const { account } = await ctx.auth.account.get(ctx, {
|
|
128
127
|
provider,
|
|
129
128
|
account: { id: email },
|
|
130
129
|
});
|
|
131
|
-
return await
|
|
130
|
+
return await ctx.auth.provider.signIn(ctx, config.verify, {
|
|
132
131
|
accountId: account._id,
|
|
133
132
|
params,
|
|
134
133
|
});
|
|
@@ -141,7 +140,7 @@ export default function password(config = {}) {
|
|
|
141
140
|
}
|
|
142
141
|
// START: Optional, email verification during sign in
|
|
143
142
|
if (config.verify && !account.emailVerified) {
|
|
144
|
-
return await
|
|
143
|
+
return await ctx.auth.provider.signIn(ctx, config.verify, {
|
|
145
144
|
accountId: account._id,
|
|
146
145
|
params,
|
|
147
146
|
});
|
|
@@ -171,4 +170,4 @@ function defaultProfile(params) {
|
|
|
171
170
|
email: params.email,
|
|
172
171
|
};
|
|
173
172
|
}
|
|
174
|
-
//# sourceMappingURL=
|
|
173
|
+
//# sourceMappingURL=password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../src/providers/password.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,WAEN,MAAM,6CAA6C,CAAC;AAYrD,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AA4D/B;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,SAAoC,EAAE;IAEtC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,IAAI,UAAU,CAAC;IACzC,OAAO,WAAW,CAAY;QAC5B,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAc,CAAC;YACnC,MAAM,kBAAkB,GACtB,IAAI,KAAK,QAAQ;gBACf,CAAC,CAAE,MAAM,CAAC,QAAmB;gBAC7B,CAAC,CAAC,IAAI,KAAK,oBAAoB;oBAC7B,CAAC,CAAE,MAAM,CAAC,WAAsB;oBAChC,CAAC,CAAC,IAAI,CAAC;YACb,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;gBAChC,IAAI,MAAM,CAAC,4BAA4B,KAAK,SAAS,EAAE,CAAC;oBACtD,MAAM,CAAC,4BAA4B,CAAC,kBAAkB,C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AqD;YACrD,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;gBAC5C,OAAO,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE;oBACxD,SAAS,EAAE,OAAO,CAAC,GAAG;oBACtB,MAAM;iBACP,CAAC,CAAC;YACL,CAAC;YACD,MAAM;YACN,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;QAC9B,CAAC;QACD,MAAM,EAAE;YACN,KAAK,CAAC,UAAU,CAAC,QAAgB;gBAC/B,OAAO,MAAM,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;YACD,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,IAAY;gBAC/C,OAAO,MAAM,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;SACF;QACD,cAAc,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QAC7C,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC;AAED,SAAS,mCAAmC,CAAC,QAAgB;IAC3D,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B;IACrD,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAe;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configure {@link
|
|
2
|
+
* Configure {@link phone} provider given a {@link PhoneUserConfig}.
|
|
3
3
|
*
|
|
4
4
|
* Simplifies creating phone providers.
|
|
5
5
|
*
|
|
6
|
-
* By default checks that there is
|
|
6
|
+
* By default checks that there is a `phone` field during token verification
|
|
7
7
|
* that matches the `phone` used during the initial `signIn` call.
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
@@ -19,4 +19,4 @@ import { PhoneConfig, PhoneUserConfig } from "../server/types.js";
|
|
|
19
19
|
* that matches the `phone` used during the initial `signIn` call.
|
|
20
20
|
*/
|
|
21
21
|
export default function phone<DataModel extends GenericDataModel>(config: PhoneUserConfig & Pick<PhoneConfig, "sendVerificationRequest">): PhoneConfig<DataModel>;
|
|
22
|
-
//# sourceMappingURL=
|
|
22
|
+
//# sourceMappingURL=phone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"phone.d.ts","sourceRoot":"","sources":["../../src/providers/phone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,SAAS,SAAS,gBAAgB,EAC9D,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,yBAAyB,CAAC,GACrE,WAAW,CAAC,SAAS,CAAC,CAqBxB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configure {@link
|
|
2
|
+
* Configure {@link phone} provider given a {@link PhoneUserConfig}.
|
|
3
3
|
*
|
|
4
4
|
* Simplifies creating phone providers.
|
|
5
5
|
*
|
|
6
|
-
* By default checks that there is
|
|
6
|
+
* By default checks that there is a `phone` field during token verification
|
|
7
7
|
* that matches the `phone` used during the initial `signIn` call.
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
@@ -34,4 +34,4 @@ export default function phone(config) {
|
|
|
34
34
|
options: config,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=phone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"phone.js","sourceRoot":"","sources":["../../src/providers/phone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAC3B,MAAsE;IAEtE,OAAO;QACL,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,aAAa;QAC9B,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;YACnC,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;YACJ,CAAC;YACD,IAAI,OAAO,CAAC,iBAAiB,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,CACb,sDAAsD;oBACpD,wBAAwB,CAC3B,CAAC;YACJ,CAAC;QACH,CAAC;QACD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;QACvD,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TotpProviderConfig } from "../server/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add TOTP (Time-based One-Time Password) authentication.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import TOTP from "@robelest/convex-auth/providers/totp";
|
|
7
|
+
*
|
|
8
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
9
|
+
* providers: [TOTP({ issuer: "My App" })],
|
|
10
|
+
* });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export default function totp(config?: Partial<TotpProviderConfig["options"]>): TotpProviderConfig;
|
|
14
|
+
//# sourceMappingURL=totp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../src/providers/totp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,GAC9C,kBAAkB,CAUpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add TOTP (Time-based One-Time Password) authentication.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import TOTP from "@robelest/convex-auth/providers/totp";
|
|
6
|
+
*
|
|
7
|
+
* export const { auth, signIn, signOut, store } = Auth({
|
|
8
|
+
* providers: [TOTP({ issuer: "My App" })],
|
|
9
|
+
* });
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export default function totp(config) {
|
|
13
|
+
return {
|
|
14
|
+
id: "totp",
|
|
15
|
+
type: "totp",
|
|
16
|
+
options: {
|
|
17
|
+
issuer: config?.issuer ?? "ConvexAuth",
|
|
18
|
+
digits: config?.digits ?? 6,
|
|
19
|
+
period: config?.period ?? 30,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=totp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.js","sourceRoot":"","sources":["../../src/providers/totp.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,MAA+C;IAE/C,OAAO;QACL,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE;YACP,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,YAAY;YACtC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;YAC3B,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;SAC7B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Auth` class — the main entry point for Convex Auth.
|
|
3
|
+
*
|
|
4
|
+
* Combines authentication and portal admin functionality:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // convex/auth.ts
|
|
8
|
+
* import { Auth, Portal } from "@robelest/convex-auth/component";
|
|
9
|
+
* import github from "@auth/core/providers/github";
|
|
10
|
+
* import { components } from "./_generated/api";
|
|
11
|
+
*
|
|
12
|
+
* export const auth = new Auth(components.auth, {
|
|
13
|
+
* providers: [github],
|
|
14
|
+
* });
|
|
15
|
+
* export const { signIn, signOut, store } = auth;
|
|
16
|
+
* export const { portalQuery, portalMutation, portalInternal } = Portal(auth);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { HttpRouter } from "convex/server";
|
|
22
|
+
import type { ComponentApi as AuthComponentApi } from "../component/_generated/component.js";
|
|
23
|
+
import { Auth as AuthFactory } from "./implementation/index.js";
|
|
24
|
+
import type { ConvexAuthConfig } from "./types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Config for the ConvexAuth class. Extends the standard auth config.
|
|
27
|
+
*
|
|
28
|
+
* Portal functionality (admin dashboard, magic link provider, static hosting)
|
|
29
|
+
* is always available — no configuration flag needed. The portal UI works
|
|
30
|
+
* when you export `portalQuery`, `portalMutation`, `portalInternal` from
|
|
31
|
+
* your `convex/auth.ts` and upload the portal static files via CLI.
|
|
32
|
+
*/
|
|
33
|
+
export type AuthClassConfig = Omit<ConvexAuthConfig, "component">;
|
|
34
|
+
/**
|
|
35
|
+
* Main entry point for Convex Auth. Instantiate with your component
|
|
36
|
+
* reference and config to get all the exports you need.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* export const auth = new Auth(components.auth, {
|
|
40
|
+
* providers: [github, resend({ ... })],
|
|
41
|
+
* });
|
|
42
|
+
* export const { signIn, signOut, store } = auth;
|
|
43
|
+
* export const { portalQuery, portalMutation, portalInternal } = Portal(auth);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class Auth {
|
|
47
|
+
/** The inner `auth` helper object from AuthFactory() */
|
|
48
|
+
private readonly _auth;
|
|
49
|
+
/** The signIn action — export this from your convex/auth.ts */
|
|
50
|
+
readonly signIn: ReturnType<typeof AuthFactory>["signIn"];
|
|
51
|
+
/** The signOut action — export this from your convex/auth.ts */
|
|
52
|
+
readonly signOut: ReturnType<typeof AuthFactory>["signOut"];
|
|
53
|
+
/** The store internal mutation — export this from your convex/auth.ts */
|
|
54
|
+
readonly store: ReturnType<typeof AuthFactory>["store"];
|
|
55
|
+
/** @internal */
|
|
56
|
+
readonly component: AuthComponentApi;
|
|
57
|
+
/** @internal */
|
|
58
|
+
readonly portalUrl: string;
|
|
59
|
+
/** User helpers: `.current(ctx)`, `.require(ctx)`, `.get(ctx, userId)`, `.viewer(ctx)` */
|
|
60
|
+
get user(): {
|
|
61
|
+
current: (ctx: {
|
|
62
|
+
auth: import("convex/server").Auth;
|
|
63
|
+
}) => Promise<import("convex/values").GenericId<"user"> | null>;
|
|
64
|
+
require: (ctx: {
|
|
65
|
+
auth: import("convex/server").Auth;
|
|
66
|
+
}) => Promise<import("convex/values").GenericId<"user">>;
|
|
67
|
+
get: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, userId: string) => Promise<any>;
|
|
68
|
+
viewer: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery"> & {
|
|
69
|
+
auth: import("convex/server").Auth;
|
|
70
|
+
}) => Promise<any>;
|
|
71
|
+
group: {
|
|
72
|
+
list: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts: {
|
|
73
|
+
userId: string;
|
|
74
|
+
}) => Promise<any>;
|
|
75
|
+
get: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts: {
|
|
76
|
+
userId: string;
|
|
77
|
+
groupId: string;
|
|
78
|
+
}) => Promise<any>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/** Session helpers */
|
|
82
|
+
get session(): {
|
|
83
|
+
current: (ctx: {
|
|
84
|
+
auth: import("convex/server").Auth;
|
|
85
|
+
}) => Promise<import("convex/values").GenericId<"session"> | null>;
|
|
86
|
+
invalidate: <DataModel extends import("convex/server").GenericDataModel>(ctx: import("convex/server").GenericActionCtx<DataModel>, args: {
|
|
87
|
+
userId: import("convex/values").GenericId<"user">;
|
|
88
|
+
except?: import("convex/values").GenericId<"session">[];
|
|
89
|
+
}) => Promise<void>;
|
|
90
|
+
};
|
|
91
|
+
/** Provider helpers */
|
|
92
|
+
get provider(): {
|
|
93
|
+
signIn: <DataModel extends import("convex/server").GenericDataModel>(ctx: import("convex/server").GenericActionCtx<DataModel>, provider: import("./types.js").AuthProviderConfig, args: {
|
|
94
|
+
accountId?: import("convex/values").GenericId<"account">;
|
|
95
|
+
params?: Record<string, unknown>;
|
|
96
|
+
}) => Promise<{
|
|
97
|
+
userId: import("convex/values").GenericId<"user">;
|
|
98
|
+
sessionId: import("convex/values").GenericId<"session">;
|
|
99
|
+
} | null>;
|
|
100
|
+
};
|
|
101
|
+
/** Account helpers */
|
|
102
|
+
get account(): {
|
|
103
|
+
create: <DataModel extends import("convex/server").GenericDataModel>(ctx: import("convex/server").GenericActionCtx<DataModel>, args: {
|
|
104
|
+
provider: string;
|
|
105
|
+
account: {
|
|
106
|
+
id: string;
|
|
107
|
+
secret?: string;
|
|
108
|
+
};
|
|
109
|
+
profile: Record<string, unknown>;
|
|
110
|
+
shouldLinkViaEmail?: boolean;
|
|
111
|
+
shouldLinkViaPhone?: boolean;
|
|
112
|
+
}) => Promise<{
|
|
113
|
+
account: import("./implementation/types.js").Doc<"account">;
|
|
114
|
+
user: import("./implementation/types.js").Doc<"user">;
|
|
115
|
+
}>;
|
|
116
|
+
get: <DataModel extends import("convex/server").GenericDataModel>(ctx: import("convex/server").GenericActionCtx<DataModel>, args: {
|
|
117
|
+
provider: string;
|
|
118
|
+
account: {
|
|
119
|
+
id: string;
|
|
120
|
+
secret?: string;
|
|
121
|
+
};
|
|
122
|
+
}) => Promise<{
|
|
123
|
+
account: import("./implementation/types.js").Doc<"account">;
|
|
124
|
+
user: import("./implementation/types.js").Doc<"user">;
|
|
125
|
+
}>;
|
|
126
|
+
updateCredentials: <DataModel extends import("convex/server").GenericDataModel>(ctx: import("convex/server").GenericActionCtx<DataModel>, args: {
|
|
127
|
+
provider: string;
|
|
128
|
+
account: {
|
|
129
|
+
id: string;
|
|
130
|
+
secret: string;
|
|
131
|
+
};
|
|
132
|
+
}) => Promise<void>;
|
|
133
|
+
};
|
|
134
|
+
/** Group helpers */
|
|
135
|
+
get group(): {
|
|
136
|
+
create: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, data: {
|
|
137
|
+
name: string;
|
|
138
|
+
slug?: string;
|
|
139
|
+
parentGroupId?: string;
|
|
140
|
+
extend?: Record<string, unknown>;
|
|
141
|
+
}) => Promise<string>;
|
|
142
|
+
get: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, groupId: string) => Promise<any>;
|
|
143
|
+
list: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts?: {
|
|
144
|
+
parentGroupId?: string;
|
|
145
|
+
}) => Promise<any>;
|
|
146
|
+
update: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, groupId: string, data: Record<string, unknown>) => Promise<void>;
|
|
147
|
+
delete: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, groupId: string) => Promise<void>;
|
|
148
|
+
member: {
|
|
149
|
+
add: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, data: {
|
|
150
|
+
groupId: string;
|
|
151
|
+
userId: string;
|
|
152
|
+
role?: string;
|
|
153
|
+
status?: string;
|
|
154
|
+
extend?: Record<string, unknown>;
|
|
155
|
+
}) => Promise<string>;
|
|
156
|
+
get: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, memberId: string) => Promise<any>;
|
|
157
|
+
list: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts: {
|
|
158
|
+
groupId: string;
|
|
159
|
+
}) => Promise<any>;
|
|
160
|
+
remove: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, memberId: string) => Promise<void>;
|
|
161
|
+
update: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, memberId: string, data: Record<string, unknown>) => Promise<void>;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
/** Invite helpers */
|
|
165
|
+
get invite(): {
|
|
166
|
+
create: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, data: {
|
|
167
|
+
groupId?: string;
|
|
168
|
+
invitedByUserId?: string;
|
|
169
|
+
email?: string;
|
|
170
|
+
tokenHash: string;
|
|
171
|
+
role?: string;
|
|
172
|
+
status: "pending" | "accepted" | "revoked" | "expired";
|
|
173
|
+
expiresTime?: number;
|
|
174
|
+
extend?: Record<string, unknown>;
|
|
175
|
+
}) => Promise<string>;
|
|
176
|
+
get: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, inviteId: string) => Promise<any>;
|
|
177
|
+
getByTokenHash: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, tokenHash: string) => Promise<any>;
|
|
178
|
+
list: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts?: {
|
|
179
|
+
groupId?: string;
|
|
180
|
+
status?: "pending" | "accepted" | "revoked" | "expired";
|
|
181
|
+
}) => Promise<any>;
|
|
182
|
+
accept: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, inviteId: string, acceptedByUserId?: string) => Promise<void>;
|
|
183
|
+
revoke: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, inviteId: string) => Promise<void>;
|
|
184
|
+
};
|
|
185
|
+
/** Passkey helpers */
|
|
186
|
+
get passkey(): {
|
|
187
|
+
list: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts: {
|
|
188
|
+
userId: string;
|
|
189
|
+
}) => Promise<any>;
|
|
190
|
+
rename: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, passkeyId: string, name: string) => Promise<void>;
|
|
191
|
+
remove: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, passkeyId: string) => Promise<void>;
|
|
192
|
+
};
|
|
193
|
+
/** TOTP helpers */
|
|
194
|
+
get totp(): {
|
|
195
|
+
list: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery">, opts: {
|
|
196
|
+
userId: string;
|
|
197
|
+
}) => Promise<any>;
|
|
198
|
+
remove: (ctx: Pick<import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, "runQuery" | "runMutation">, totpId: string) => Promise<void>;
|
|
199
|
+
};
|
|
200
|
+
constructor(component: AuthComponentApi, config: AuthClassConfig);
|
|
201
|
+
/**
|
|
202
|
+
* Register HTTP routes for OAuth, JWT well-known endpoints, and portal
|
|
203
|
+
* static file serving.
|
|
204
|
+
*
|
|
205
|
+
* ```ts
|
|
206
|
+
* // convex/http.ts
|
|
207
|
+
* import { httpRouter } from "convex/server";
|
|
208
|
+
* import { auth } from "./auth";
|
|
209
|
+
*
|
|
210
|
+
* const http = httpRouter();
|
|
211
|
+
* auth.addHttpRoutes(http);
|
|
212
|
+
* export default http;
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
addHttpRoutes(http: HttpRouter, opts?: {
|
|
216
|
+
pathPrefix?: string;
|
|
217
|
+
spaFallback?: boolean;
|
|
218
|
+
}): void;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Create portal function definitions from a ConvexAuth instance.
|
|
222
|
+
*
|
|
223
|
+
* This is a standalone function (not a class method) because Convex's
|
|
224
|
+
* bundler can trace through `export const { x } = fn(instance)` but
|
|
225
|
+
* cannot trace through `instance.method()`.
|
|
226
|
+
*
|
|
227
|
+
* ```ts
|
|
228
|
+
* export const { portalQuery, portalMutation, portalInternal } = Portal(auth);
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
export declare function Portal(auth: Auth): {
|
|
232
|
+
portalQuery: import("convex/server").RegisteredQuery<"public", {
|
|
233
|
+
action: string;
|
|
234
|
+
userId?: string;
|
|
235
|
+
}, Promise<any>>;
|
|
236
|
+
portalMutation: import("convex/server").RegisteredMutation<"public", {
|
|
237
|
+
action: string;
|
|
238
|
+
sessionId?: string;
|
|
239
|
+
tokenHash?: string;
|
|
240
|
+
}, Promise<void>>;
|
|
241
|
+
portalInternal: import("convex/server").RegisteredMutation<"internal", any, Promise<any>>;
|
|
242
|
+
};
|
|
243
|
+
//# sourceMappingURL=convex-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex-auth.d.ts","sourceRoot":"","sources":["../../src/server/convex-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,e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