@robelest/convex-auth 0.0.4-preview.2 → 0.0.4-preview.21
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 +67 -26
- package/dist/authorization/index.d.ts +63 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +63 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/bin.js +6185 -0
- package/dist/client/core/types.d.ts +20 -0
- package/dist/client/core/types.d.ts.map +1 -0
- package/dist/client/index.d.ts +2 -299
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +407 -534
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +42 -0
- 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 +2546 -90
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/client/core/types.d.ts +2 -0
- package/dist/component/client/index.d.ts +2 -0
- package/dist/component/convex.config.d.ts +2 -2
- package/dist/component/functions.d.ts +11 -9
- package/dist/component/functions.d.ts.map +1 -1
- package/dist/component/functions.js.map +1 -1
- package/dist/component/index.d.ts +7 -11
- package/dist/component/index.js +2 -3
- package/dist/component/model.d.ts +153 -0
- package/dist/component/model.d.ts.map +1 -0
- package/dist/component/model.js +349 -0
- package/dist/component/model.js.map +1 -0
- package/dist/component/providers/anonymous.d.ts +54 -0
- package/dist/component/providers/anonymous.d.ts.map +1 -0
- package/dist/component/providers/credentials.d.ts +5 -5
- package/dist/component/providers/credentials.d.ts.map +1 -1
- package/dist/component/providers/device.d.ts +67 -0
- package/dist/component/providers/device.d.ts.map +1 -0
- package/dist/component/providers/email.d.ts +62 -0
- package/dist/component/providers/email.d.ts.map +1 -0
- package/dist/component/providers/oauth.d.ts.map +1 -1
- package/dist/component/providers/oauth.js.map +1 -1
- package/dist/component/providers/passkey.d.ts +57 -0
- package/dist/component/providers/passkey.d.ts.map +1 -0
- package/dist/component/providers/password.d.ts +88 -0
- package/dist/component/providers/password.d.ts.map +1 -0
- package/dist/component/providers/phone.d.ts +48 -0
- package/dist/component/providers/phone.d.ts.map +1 -0
- package/dist/component/providers/sso.d.ts +50 -0
- package/dist/component/providers/sso.d.ts.map +1 -0
- package/dist/component/providers/totp.d.ts +45 -0
- package/dist/component/providers/totp.d.ts.map +1 -0
- package/dist/component/public/enterprise/audit.d.ts +73 -0
- package/dist/component/public/enterprise/audit.d.ts.map +1 -0
- package/dist/component/public/enterprise/audit.js +108 -0
- package/dist/component/public/enterprise/audit.js.map +1 -0
- package/dist/component/public/enterprise/core.d.ts +176 -0
- package/dist/component/public/enterprise/core.d.ts.map +1 -0
- package/dist/component/public/enterprise/core.js +292 -0
- package/dist/component/public/enterprise/core.js.map +1 -0
- package/dist/component/public/enterprise/domains.d.ts +174 -0
- package/dist/component/public/enterprise/domains.d.ts.map +1 -0
- package/dist/component/public/enterprise/domains.js +271 -0
- package/dist/component/public/enterprise/domains.js.map +1 -0
- package/dist/component/public/enterprise/scim.d.ts +245 -0
- package/dist/component/public/enterprise/scim.d.ts.map +1 -0
- package/dist/component/public/enterprise/scim.js +344 -0
- package/dist/component/public/enterprise/scim.js.map +1 -0
- package/dist/component/public/enterprise/secrets.d.ts +78 -0
- package/dist/component/public/enterprise/secrets.d.ts.map +1 -0
- package/dist/component/public/enterprise/secrets.js +118 -0
- package/dist/component/public/enterprise/secrets.js.map +1 -0
- package/dist/component/public/enterprise/webhooks.d.ts +211 -0
- package/dist/component/public/enterprise/webhooks.d.ts.map +1 -0
- package/dist/component/public/enterprise/webhooks.js +300 -0
- package/dist/component/public/enterprise/webhooks.js.map +1 -0
- package/dist/component/public/factors/devices.d.ts +157 -0
- package/dist/component/public/factors/devices.d.ts.map +1 -0
- package/dist/component/public/factors/devices.js +216 -0
- package/dist/component/public/factors/devices.js.map +1 -0
- package/dist/component/public/factors/passkeys.d.ts +175 -0
- package/dist/component/public/factors/passkeys.d.ts.map +1 -0
- package/dist/component/public/factors/passkeys.js +238 -0
- package/dist/component/public/factors/passkeys.js.map +1 -0
- package/dist/component/public/factors/totp.d.ts +189 -0
- package/dist/component/public/factors/totp.d.ts.map +1 -0
- package/dist/component/public/factors/totp.js +254 -0
- package/dist/component/public/factors/totp.js.map +1 -0
- package/dist/component/public/groups/core.d.ts +137 -0
- package/dist/component/public/groups/core.d.ts.map +1 -0
- package/dist/component/public/groups/core.js +321 -0
- package/dist/component/public/groups/core.js.map +1 -0
- package/dist/component/public/groups/invites.d.ts +217 -0
- package/dist/component/public/groups/invites.d.ts.map +1 -0
- package/dist/component/public/groups/invites.js +457 -0
- package/dist/component/public/groups/invites.js.map +1 -0
- package/dist/component/public/groups/members.d.ts +204 -0
- package/dist/component/public/groups/members.d.ts.map +1 -0
- package/dist/component/public/groups/members.js +355 -0
- package/dist/component/public/groups/members.js.map +1 -0
- package/dist/component/public/identity/accounts.d.ts +147 -0
- package/dist/component/public/identity/accounts.d.ts.map +1 -0
- package/dist/component/public/identity/accounts.js +200 -0
- package/dist/component/public/identity/accounts.js.map +1 -0
- package/dist/component/public/identity/codes.d.ts +104 -0
- package/dist/component/public/identity/codes.d.ts.map +1 -0
- package/dist/component/public/identity/codes.js +140 -0
- package/dist/component/public/identity/codes.js.map +1 -0
- package/dist/component/public/identity/sessions.d.ts +128 -0
- package/dist/component/public/identity/sessions.d.ts.map +1 -0
- package/dist/component/public/identity/sessions.js +192 -0
- package/dist/component/public/identity/sessions.js.map +1 -0
- package/dist/component/public/identity/tokens.d.ts +169 -0
- package/dist/component/public/identity/tokens.d.ts.map +1 -0
- package/dist/component/public/identity/tokens.js +227 -0
- package/dist/component/public/identity/tokens.js.map +1 -0
- package/dist/component/public/identity/users.d.ts +212 -0
- package/dist/component/public/identity/users.d.ts.map +1 -0
- package/dist/component/public/identity/users.js +311 -0
- package/dist/component/public/identity/users.js.map +1 -0
- package/dist/component/public/identity/verifiers.d.ts +116 -0
- package/dist/component/public/identity/verifiers.d.ts.map +1 -0
- package/dist/component/public/identity/verifiers.js +154 -0
- package/dist/component/public/identity/verifiers.js.map +1 -0
- package/dist/component/public/security/keys.d.ts +209 -0
- package/dist/component/public/security/keys.d.ts.map +1 -0
- package/dist/component/public/security/keys.js +319 -0
- package/dist/component/public/security/keys.js.map +1 -0
- package/dist/component/public/security/limits.d.ts +114 -0
- package/dist/component/public/security/limits.d.ts.map +1 -0
- package/dist/component/public/security/limits.js +169 -0
- package/dist/component/public/security/limits.js.map +1 -0
- package/dist/component/public.d.ts +24 -271
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +21 -1229
- package/dist/component/schema.d.ts +473 -110
- package/dist/component/schema.js +162 -73
- package/dist/component/schema.js.map +1 -1
- package/dist/component/server/auth.d.ts +318 -373
- package/dist/component/server/auth.d.ts.map +1 -1
- package/dist/component/server/auth.js +204 -123
- package/dist/component/server/auth.js.map +1 -1
- package/dist/component/server/authError.js +34 -0
- package/dist/component/server/authError.js.map +1 -0
- package/dist/component/server/{providers.js → config.js} +43 -12
- package/dist/component/server/config.js.map +1 -0
- package/dist/component/server/cookies.js +3 -0
- package/dist/component/server/cookies.js.map +1 -1
- package/dist/component/server/core.js +713 -0
- package/dist/component/server/core.js.map +1 -0
- package/dist/component/server/crypto.js +38 -0
- package/dist/component/server/crypto.js.map +1 -0
- package/dist/component/server/{implementation/db.js → db.js} +2 -1
- package/dist/component/server/db.js.map +1 -0
- package/dist/component/server/device.js +109 -0
- package/dist/component/server/device.js.map +1 -0
- package/dist/component/server/enterprise/config.js +46 -0
- package/dist/component/server/enterprise/config.js.map +1 -0
- package/dist/component/server/enterprise/domain.js +885 -0
- package/dist/component/server/enterprise/domain.js.map +1 -0
- package/dist/component/server/enterprise/http.js +766 -0
- package/dist/component/server/enterprise/http.js.map +1 -0
- package/dist/component/server/enterprise/oidc.js +248 -0
- package/dist/component/server/enterprise/oidc.js.map +1 -0
- package/dist/component/server/enterprise/policy.js +85 -0
- package/dist/component/server/enterprise/policy.js.map +1 -0
- package/dist/component/server/enterprise/saml.js +338 -0
- package/dist/component/server/enterprise/saml.js.map +1 -0
- package/dist/component/server/enterprise/scim.js +97 -0
- package/dist/component/server/enterprise/scim.js.map +1 -0
- package/dist/component/server/enterprise/shared.js +51 -0
- package/dist/component/server/enterprise/shared.js.map +1 -0
- package/dist/component/server/errors.d.ts +1 -0
- package/dist/component/server/errors.js +24 -16
- package/dist/component/server/errors.js.map +1 -1
- package/dist/component/server/http.js +288 -0
- package/dist/component/server/http.js.map +1 -0
- package/dist/component/server/identity.js +13 -0
- package/dist/component/server/identity.js.map +1 -0
- package/dist/{server/implementation → component/server}/keys.js +9 -31
- package/dist/component/server/keys.js.map +1 -0
- package/dist/component/server/limits.js +61 -0
- package/dist/component/server/limits.js.map +1 -0
- package/dist/component/server/mutations/account.js +44 -0
- package/dist/component/server/mutations/account.js.map +1 -0
- package/dist/component/server/{implementation/mutations → mutations}/code.js +7 -4
- package/dist/component/server/mutations/code.js.map +1 -0
- package/dist/component/server/mutations/invalidate.js +32 -0
- package/dist/component/server/mutations/invalidate.js.map +1 -0
- package/dist/component/server/mutations/oauth.js +110 -0
- package/dist/component/server/mutations/oauth.js.map +1 -0
- package/dist/component/server/mutations/refresh.js +119 -0
- package/dist/component/server/mutations/refresh.js.map +1 -0
- package/dist/component/server/mutations/register.js +83 -0
- package/dist/component/server/mutations/register.js.map +1 -0
- package/dist/component/server/mutations/retrieve.js +65 -0
- package/dist/component/server/mutations/retrieve.js.map +1 -0
- package/dist/component/server/mutations/signature.js +32 -0
- package/dist/component/server/mutations/signature.js.map +1 -0
- package/dist/component/server/{implementation/mutations → mutations}/signin.js +2 -2
- package/dist/component/server/mutations/signin.js.map +1 -0
- package/dist/component/server/mutations/signout.js +27 -0
- package/dist/component/server/mutations/signout.js.map +1 -0
- package/dist/component/server/mutations/store/refs.js +15 -0
- package/dist/component/server/mutations/store/refs.js.map +1 -0
- package/dist/component/server/mutations/store.js +85 -0
- package/dist/component/server/mutations/store.js.map +1 -0
- package/dist/component/server/mutations/verifier.js +18 -0
- package/dist/component/server/mutations/verifier.js.map +1 -0
- package/dist/component/server/mutations/verify.js +98 -0
- package/dist/component/server/mutations/verify.js.map +1 -0
- package/dist/component/server/oauth.js +106 -60
- package/dist/component/server/oauth.js.map +1 -1
- package/dist/component/server/passkey.js +328 -0
- package/dist/component/server/passkey.js.map +1 -0
- package/dist/{server/implementation → component/server}/redirects.js +13 -11
- package/dist/component/server/redirects.js.map +1 -0
- package/dist/component/server/refresh.js +96 -0
- package/dist/component/server/refresh.js.map +1 -0
- package/dist/component/server/runtime.d.ts +136 -0
- package/dist/component/server/runtime.d.ts.map +1 -0
- package/dist/component/server/runtime.js +413 -0
- package/dist/component/server/runtime.js.map +1 -0
- package/dist/{server/implementation → component/server}/sessions.js +14 -8
- package/dist/component/server/sessions.js.map +1 -0
- package/dist/component/server/signin.js +201 -0
- package/dist/component/server/signin.js.map +1 -0
- package/dist/component/server/tokens.js +17 -0
- package/dist/component/server/tokens.js.map +1 -0
- package/dist/component/server/totp.js +148 -0
- package/dist/component/server/totp.js.map +1 -0
- package/dist/component/server/types.d.ts +387 -298
- package/dist/component/server/types.d.ts.map +1 -1
- package/dist/component/server/{implementation/types.js → types.js} +1 -1
- package/dist/component/server/types.js.map +1 -0
- package/dist/component/server/{implementation/users.js → users.js} +54 -35
- package/dist/component/server/users.js.map +1 -0
- package/dist/component/server/utils.js +110 -4
- package/dist/component/server/utils.js.map +1 -1
- package/dist/core/types.d.ts +369 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/factors/device.js +105 -0
- package/dist/factors/device.js.map +1 -0
- package/dist/factors/passkey.js +181 -0
- package/dist/factors/passkey.js.map +1 -0
- package/dist/factors/totp.js +122 -0
- package/dist/factors/totp.js.map +1 -0
- package/dist/providers/anonymous.d.ts +3 -9
- package/dist/providers/anonymous.d.ts.map +1 -1
- package/dist/providers/anonymous.js +1 -18
- package/dist/providers/anonymous.js.map +1 -1
- package/dist/providers/credentials.d.ts +8 -10
- package/dist/providers/credentials.d.ts.map +1 -1
- package/dist/providers/credentials.js +3 -5
- package/dist/providers/credentials.js.map +1 -1
- package/dist/providers/device.d.ts +18 -10
- package/dist/providers/device.d.ts.map +1 -1
- package/dist/providers/device.js +4 -8
- package/dist/providers/device.js.map +1 -1
- package/dist/providers/email.d.ts +50 -23
- package/dist/providers/email.d.ts.map +1 -1
- package/dist/providers/email.js +58 -34
- package/dist/providers/email.js.map +1 -1
- package/dist/providers/index.d.ts +7 -3
- package/dist/providers/index.js +4 -1
- package/dist/providers/oauth.d.ts.map +1 -1
- package/dist/providers/oauth.js.map +1 -1
- package/dist/providers/passkey.d.ts +12 -9
- package/dist/providers/passkey.d.ts.map +1 -1
- package/dist/providers/passkey.js +1 -7
- package/dist/providers/passkey.js.map +1 -1
- package/dist/providers/password.d.ts +6 -12
- package/dist/providers/password.d.ts.map +1 -1
- package/dist/providers/password.js +189 -89
- package/dist/providers/password.js.map +1 -1
- package/dist/providers/phone.d.ts +40 -11
- package/dist/providers/phone.d.ts.map +1 -1
- package/dist/providers/phone.js +52 -21
- package/dist/providers/phone.js.map +1 -1
- package/dist/providers/sso.d.ts +50 -0
- package/dist/providers/sso.d.ts.map +1 -0
- package/dist/providers/sso.js +34 -0
- package/dist/providers/sso.js.map +1 -0
- package/dist/providers/totp.d.ts +12 -9
- package/dist/providers/totp.d.ts.map +1 -1
- package/dist/providers/totp.js +1 -7
- package/dist/providers/totp.js.map +1 -1
- package/dist/runtime/browser.js +68 -0
- package/dist/runtime/browser.js.map +1 -0
- package/dist/runtime/invite.js +51 -0
- package/dist/runtime/invite.js.map +1 -0
- package/dist/runtime/proxy.js +70 -0
- package/dist/runtime/proxy.js.map +1 -0
- package/dist/runtime/storage.js +37 -0
- package/dist/runtime/storage.js.map +1 -0
- package/dist/server/auth.d.ts +335 -370
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +204 -123
- package/dist/server/auth.js.map +1 -1
- package/dist/server/authError.d.ts +46 -0
- package/dist/server/authError.d.ts.map +1 -0
- package/dist/server/authError.js +34 -0
- package/dist/server/authError.js.map +1 -0
- package/dist/server/config.d.ts +1 -0
- package/dist/server/{providers.js → config.js} +43 -12
- package/dist/server/config.js.map +1 -0
- package/dist/server/cookies.d.ts +1 -38
- package/dist/server/cookies.js +3 -0
- package/dist/server/cookies.js.map +1 -1
- package/dist/server/core.d.ts +1436 -0
- package/dist/server/core.d.ts.map +1 -0
- package/dist/server/core.js +713 -0
- package/dist/server/core.js.map +1 -0
- package/dist/server/crypto.d.ts +8 -0
- package/dist/server/crypto.d.ts.map +1 -0
- package/dist/server/crypto.js +38 -0
- package/dist/server/crypto.js.map +1 -0
- package/dist/server/db.d.ts +1 -0
- package/dist/server/{implementation/db.js → db.js} +2 -1
- package/dist/server/db.js.map +1 -0
- package/dist/server/device.d.ts +1 -0
- package/dist/server/device.js +109 -0
- package/dist/server/device.js.map +1 -0
- package/dist/server/enterprise/config.d.ts +1 -0
- package/dist/server/enterprise/config.js +46 -0
- package/dist/server/enterprise/config.js.map +1 -0
- package/dist/server/enterprise/domain.d.ts +409 -0
- package/dist/server/enterprise/domain.d.ts.map +1 -0
- package/dist/server/enterprise/domain.js +885 -0
- package/dist/server/enterprise/domain.js.map +1 -0
- package/dist/server/enterprise/http.d.ts +26 -0
- package/dist/server/enterprise/http.d.ts.map +1 -0
- package/dist/server/enterprise/http.js +766 -0
- package/dist/server/enterprise/http.js.map +1 -0
- package/dist/server/enterprise/oidc.d.ts +1 -0
- package/dist/server/enterprise/oidc.js +248 -0
- package/dist/server/enterprise/oidc.js.map +1 -0
- package/dist/server/enterprise/policy.d.ts +1 -0
- package/dist/server/enterprise/policy.js +85 -0
- package/dist/server/enterprise/policy.js.map +1 -0
- package/dist/server/enterprise/saml.d.ts +1 -0
- package/dist/server/enterprise/saml.js +338 -0
- package/dist/server/enterprise/saml.js.map +1 -0
- package/dist/server/enterprise/scim.d.ts +1 -0
- package/dist/server/enterprise/scim.js +97 -0
- package/dist/server/enterprise/scim.js.map +1 -0
- package/dist/server/enterprise/shared.d.ts +5 -0
- package/dist/server/enterprise/shared.d.ts.map +1 -0
- package/dist/server/enterprise/shared.js +51 -0
- package/dist/server/enterprise/shared.js.map +1 -0
- package/dist/server/enterprise/validators.d.ts +1 -0
- package/dist/server/enterprise/validators.js +60 -0
- package/dist/server/enterprise/validators.js.map +1 -0
- package/dist/server/errors.d.ts +33 -1
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js +44 -1
- package/dist/server/errors.js.map +1 -1
- package/dist/server/http.d.ts +59 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +288 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server/identity.d.ts +1 -0
- package/dist/server/identity.js +13 -0
- package/dist/server/identity.js.map +1 -0
- package/dist/server/index.d.ts +4 -182
- package/dist/server/index.js +4 -376
- package/dist/server/keys.d.ts +1 -0
- package/dist/{component/server/implementation → server}/keys.js +9 -31
- package/dist/server/keys.js.map +1 -0
- package/dist/server/limits.d.ts +1 -0
- package/dist/server/limits.js +61 -0
- package/dist/server/limits.js.map +1 -0
- package/dist/server/mounts.d.ts +647 -0
- package/dist/server/mounts.d.ts.map +1 -0
- package/dist/server/mounts.js +643 -0
- package/dist/server/mounts.js.map +1 -0
- package/dist/server/mutations/account.d.ts +30 -0
- package/dist/server/mutations/account.d.ts.map +1 -0
- package/dist/server/mutations/account.js +44 -0
- package/dist/server/mutations/account.js.map +1 -0
- package/dist/server/mutations/code.d.ts +30 -0
- package/dist/server/mutations/code.d.ts.map +1 -0
- package/dist/server/{implementation/mutations → mutations}/code.js +7 -4
- package/dist/server/mutations/code.js.map +1 -0
- package/dist/server/mutations/index.d.ts +14 -0
- package/dist/server/mutations/index.js +15 -0
- package/dist/server/mutations/invalidate.d.ts +20 -0
- package/dist/server/mutations/invalidate.d.ts.map +1 -0
- package/dist/server/mutations/invalidate.js +32 -0
- package/dist/server/mutations/invalidate.js.map +1 -0
- package/dist/server/mutations/oauth.d.ts +28 -0
- package/dist/server/mutations/oauth.d.ts.map +1 -0
- package/dist/server/mutations/oauth.js +110 -0
- package/dist/server/mutations/oauth.js.map +1 -0
- package/dist/server/mutations/refresh.d.ts +21 -0
- package/dist/server/mutations/refresh.d.ts.map +1 -0
- package/dist/server/mutations/refresh.js +119 -0
- package/dist/server/mutations/refresh.js.map +1 -0
- package/dist/server/mutations/register.d.ts +38 -0
- package/dist/server/mutations/register.d.ts.map +1 -0
- package/dist/server/mutations/register.js +83 -0
- package/dist/server/mutations/register.js.map +1 -0
- package/dist/server/mutations/retrieve.d.ts +33 -0
- package/dist/server/mutations/retrieve.d.ts.map +1 -0
- package/dist/server/mutations/retrieve.js +65 -0
- package/dist/server/mutations/retrieve.js.map +1 -0
- package/dist/server/mutations/signature.d.ts +22 -0
- package/dist/server/mutations/signature.d.ts.map +1 -0
- package/dist/server/mutations/signature.js +32 -0
- package/dist/server/mutations/signature.js.map +1 -0
- package/dist/server/mutations/signin.d.ts +22 -0
- package/dist/server/mutations/signin.d.ts.map +1 -0
- package/dist/server/{implementation/mutations → mutations}/signin.js +2 -2
- package/dist/server/mutations/signin.js.map +1 -0
- package/dist/server/mutations/signout.d.ts +16 -0
- package/dist/server/mutations/signout.d.ts.map +1 -0
- package/dist/server/mutations/signout.js +27 -0
- package/dist/server/mutations/signout.js.map +1 -0
- package/dist/server/mutations/store/refs.d.ts +12 -0
- package/dist/server/mutations/store/refs.d.ts.map +1 -0
- package/dist/server/mutations/store/refs.js +15 -0
- package/dist/server/mutations/store/refs.js.map +1 -0
- package/dist/server/mutations/store.d.ts +306 -0
- package/dist/server/mutations/store.d.ts.map +1 -0
- package/dist/server/mutations/store.js +85 -0
- package/dist/server/mutations/store.js.map +1 -0
- package/dist/server/mutations/verifier.d.ts +13 -0
- package/dist/server/mutations/verifier.d.ts.map +1 -0
- package/dist/server/mutations/verifier.js +18 -0
- package/dist/server/mutations/verifier.js.map +1 -0
- package/dist/server/mutations/verify.d.ts +26 -0
- package/dist/server/mutations/verify.d.ts.map +1 -0
- package/dist/server/mutations/verify.js +98 -0
- package/dist/server/mutations/verify.js.map +1 -0
- package/dist/server/oauth.d.ts +1 -48
- package/dist/server/oauth.js +107 -64
- package/dist/server/oauth.js.map +1 -1
- package/dist/server/passkey.d.ts +27 -0
- package/dist/server/passkey.d.ts.map +1 -0
- package/dist/server/passkey.js +328 -0
- package/dist/server/passkey.js.map +1 -0
- package/dist/server/redirects.d.ts +1 -0
- package/dist/{component/server/implementation → server}/redirects.js +13 -11
- package/dist/server/redirects.js.map +1 -0
- package/dist/server/refresh.d.ts +1 -0
- package/dist/server/refresh.js +96 -0
- package/dist/server/refresh.js.map +1 -0
- package/dist/server/runtime.d.ts +136 -0
- package/dist/server/runtime.d.ts.map +1 -0
- package/dist/server/runtime.js +413 -0
- package/dist/server/runtime.js.map +1 -0
- package/dist/server/sessions.d.ts +1 -0
- package/dist/{component/server/implementation → server}/sessions.js +14 -8
- package/dist/server/sessions.js.map +1 -0
- package/dist/server/signin.d.ts +1 -0
- package/dist/server/signin.js +201 -0
- package/dist/server/signin.js.map +1 -0
- package/dist/server/ssr.d.ts +226 -0
- package/dist/server/ssr.d.ts.map +1 -0
- package/dist/server/ssr.js +786 -0
- package/dist/server/ssr.js.map +1 -0
- package/dist/server/templates.d.ts +1 -21
- package/dist/server/templates.js +2 -1
- package/dist/server/templates.js.map +1 -1
- package/dist/server/tokens.d.ts +1 -0
- package/dist/server/tokens.js +17 -0
- package/dist/server/tokens.js.map +1 -0
- package/dist/server/totp.d.ts +1 -0
- package/dist/server/totp.js +148 -0
- package/dist/server/totp.js.map +1 -0
- package/dist/server/types.d.ts +498 -306
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js +108 -1
- package/dist/server/types.js.map +1 -0
- package/dist/server/users.d.ts +1 -0
- package/dist/server/{implementation/users.js → users.js} +54 -35
- package/dist/server/users.js.map +1 -0
- package/dist/server/utils.d.ts +1 -6
- package/dist/server/utils.js +110 -4
- package/dist/server/utils.js.map +1 -1
- package/package.json +49 -46
- package/src/authorization/index.ts +83 -0
- package/src/cli/bin.ts +5 -0
- package/src/cli/command.ts +6 -5
- package/src/cli/index.ts +456 -248
- package/src/cli/keys.ts +3 -0
- package/src/client/core/types.ts +437 -0
- package/src/client/factors/device.ts +160 -0
- package/src/client/factors/passkey.ts +282 -0
- package/src/client/factors/totp.ts +150 -0
- package/src/client/index.ts +745 -989
- package/src/client/runtime/browser.ts +112 -0
- package/src/client/runtime/invite.ts +65 -0
- package/src/client/runtime/proxy.ts +111 -0
- package/src/client/runtime/storage.ts +79 -0
- package/src/component/_generated/api.ts +42 -0
- package/src/component/_generated/component.ts +3123 -102
- package/src/component/functions.ts +38 -22
- package/src/component/index.ts +10 -20
- package/src/component/model.ts +449 -0
- package/src/component/public/enterprise/audit.ts +120 -0
- package/src/component/public/enterprise/core.ts +354 -0
- package/src/component/public/enterprise/domains.ts +323 -0
- package/src/component/public/enterprise/scim.ts +396 -0
- package/src/component/public/enterprise/secrets.ts +132 -0
- package/src/component/public/enterprise/webhooks.ts +306 -0
- package/src/component/public/factors/devices.ts +223 -0
- package/src/component/public/factors/passkeys.ts +242 -0
- package/src/component/public/factors/totp.ts +258 -0
- package/src/component/public/groups/core.ts +481 -0
- package/src/component/public/groups/invites.ts +602 -0
- package/src/component/public/groups/members.ts +409 -0
- package/src/component/public/identity/accounts.ts +206 -0
- package/src/component/public/identity/codes.ts +148 -0
- package/src/component/public/identity/sessions.ts +209 -0
- package/src/component/public/identity/tokens.ts +250 -0
- package/src/component/public/identity/users.ts +354 -0
- package/src/component/public/identity/verifiers.ts +157 -0
- package/src/component/public/security/keys.ts +365 -0
- package/src/component/public/security/limits.ts +173 -0
- package/src/component/public.ts +26 -1766
- package/src/component/schema.ts +273 -100
- package/src/providers/anonymous.ts +10 -20
- package/src/providers/credentials.ts +14 -22
- package/src/providers/device.ts +3 -14
- package/src/providers/email.ts +83 -47
- package/src/providers/index.ts +7 -0
- package/src/providers/oauth.ts +5 -3
- package/src/providers/passkey.ts +0 -13
- package/src/providers/password.ts +307 -130
- package/src/providers/phone.ts +81 -37
- package/src/providers/sso.ts +54 -0
- package/src/providers/totp.ts +0 -13
- package/src/samlify.d.ts +53 -0
- package/src/server/auth.ts +701 -247
- package/src/server/authError.ts +44 -0
- package/src/server/{providers.ts → config.ts} +84 -15
- package/src/server/cookies.ts +8 -1
- package/src/server/core.ts +2095 -0
- package/src/server/crypto.ts +88 -0
- package/src/server/{implementation/db.ts → db.ts} +90 -15
- package/src/server/device.ts +221 -0
- package/src/server/enterprise/config.ts +51 -0
- package/src/server/enterprise/domain.ts +1751 -0
- package/src/server/enterprise/http.ts +1324 -0
- package/src/server/enterprise/oidc.ts +500 -0
- package/src/server/enterprise/policy.ts +128 -0
- package/src/server/enterprise/saml.ts +578 -0
- package/src/server/enterprise/scim.ts +135 -0
- package/src/server/enterprise/shared.ts +134 -0
- package/src/server/enterprise/validators.ts +93 -0
- package/src/server/errors.ts +130 -119
- package/src/server/http.ts +531 -0
- package/src/server/identity.ts +18 -0
- package/src/server/index.ts +32 -650
- package/src/server/{implementation/keys.ts → keys.ts} +16 -44
- package/src/server/limits.ts +134 -0
- package/src/server/mounts.ts +948 -0
- package/src/server/mutations/account.ts +76 -0
- package/src/server/{implementation/mutations → mutations}/code.ts +22 -11
- package/src/server/mutations/index.ts +13 -0
- package/src/server/mutations/invalidate.ts +50 -0
- package/src/server/mutations/oauth.ts +237 -0
- package/src/server/mutations/refresh.ts +298 -0
- package/src/server/mutations/register.ts +200 -0
- package/src/server/mutations/retrieve.ts +109 -0
- package/src/server/mutations/signature.ts +50 -0
- package/src/server/{implementation/mutations → mutations}/signin.ts +9 -7
- package/src/server/mutations/signout.ts +43 -0
- package/src/server/mutations/store/refs.ts +10 -0
- package/src/server/mutations/store.ts +138 -0
- package/src/server/mutations/verifier.ts +34 -0
- package/src/server/mutations/verify.ts +202 -0
- package/src/server/oauth.ts +243 -131
- package/src/server/passkey.ts +784 -0
- package/src/server/{implementation/redirects.ts → redirects.ts} +21 -16
- package/src/server/refresh.ts +222 -0
- package/src/server/runtime.ts +880 -0
- package/src/server/{implementation/sessions.ts → sessions.ts} +33 -25
- package/src/server/signin.ts +438 -0
- package/src/server/ssr.ts +1764 -0
- package/src/server/templates.ts +8 -3
- package/src/server/{implementation/tokens.ts → tokens.ts} +11 -5
- package/src/server/totp.ts +349 -0
- package/src/server/types.ts +972 -207
- package/src/server/{implementation/users.ts → users.ts} +129 -75
- package/src/server/utils.ts +192 -5
- package/src/test.ts +28 -4
- package/dist/bin.cjs +0 -27757
- package/dist/component/providers/email.js +0 -47
- package/dist/component/providers/email.js.map +0 -1
- package/dist/component/public.js.map +0 -1
- package/dist/component/server/implementation/db.js.map +0 -1
- package/dist/component/server/implementation/device.js +0 -135
- package/dist/component/server/implementation/device.js.map +0 -1
- package/dist/component/server/implementation/index.d.ts +0 -870
- package/dist/component/server/implementation/index.d.ts.map +0 -1
- package/dist/component/server/implementation/index.js +0 -610
- package/dist/component/server/implementation/index.js.map +0 -1
- package/dist/component/server/implementation/keys.js.map +0 -1
- package/dist/component/server/implementation/mutations/account.js +0 -39
- package/dist/component/server/implementation/mutations/account.js.map +0 -1
- package/dist/component/server/implementation/mutations/code.js.map +0 -1
- package/dist/component/server/implementation/mutations/index.js +0 -70
- package/dist/component/server/implementation/mutations/index.js.map +0 -1
- package/dist/component/server/implementation/mutations/invalidate.js +0 -29
- package/dist/component/server/implementation/mutations/invalidate.js.map +0 -1
- package/dist/component/server/implementation/mutations/oauth.js +0 -51
- package/dist/component/server/implementation/mutations/oauth.js.map +0 -1
- package/dist/component/server/implementation/mutations/refresh.js +0 -85
- package/dist/component/server/implementation/mutations/refresh.js.map +0 -1
- package/dist/component/server/implementation/mutations/register.js +0 -65
- package/dist/component/server/implementation/mutations/register.js.map +0 -1
- package/dist/component/server/implementation/mutations/retrieve.js +0 -50
- package/dist/component/server/implementation/mutations/retrieve.js.map +0 -1
- package/dist/component/server/implementation/mutations/signature.js +0 -27
- package/dist/component/server/implementation/mutations/signature.js.map +0 -1
- package/dist/component/server/implementation/mutations/signin.js.map +0 -1
- package/dist/component/server/implementation/mutations/signout.js +0 -27
- package/dist/component/server/implementation/mutations/signout.js.map +0 -1
- package/dist/component/server/implementation/mutations/store.js +0 -12
- package/dist/component/server/implementation/mutations/store.js.map +0 -1
- package/dist/component/server/implementation/mutations/verifier.js +0 -16
- package/dist/component/server/implementation/mutations/verifier.js.map +0 -1
- package/dist/component/server/implementation/mutations/verify.js +0 -105
- package/dist/component/server/implementation/mutations/verify.js.map +0 -1
- package/dist/component/server/implementation/passkey.js +0 -307
- package/dist/component/server/implementation/passkey.js.map +0 -1
- package/dist/component/server/implementation/provider.js +0 -19
- package/dist/component/server/implementation/provider.js.map +0 -1
- package/dist/component/server/implementation/ratelimit.js +0 -48
- package/dist/component/server/implementation/ratelimit.js.map +0 -1
- package/dist/component/server/implementation/redirects.js.map +0 -1
- package/dist/component/server/implementation/refresh.js +0 -109
- package/dist/component/server/implementation/refresh.js.map +0 -1
- package/dist/component/server/implementation/sessions.js.map +0 -1
- package/dist/component/server/implementation/signin.js +0 -148
- package/dist/component/server/implementation/signin.js.map +0 -1
- package/dist/component/server/implementation/tokens.js +0 -15
- package/dist/component/server/implementation/tokens.js.map +0 -1
- package/dist/component/server/implementation/totp.js +0 -142
- package/dist/component/server/implementation/totp.js.map +0 -1
- package/dist/component/server/implementation/types.d.ts +0 -42
- package/dist/component/server/implementation/types.d.ts.map +0 -1
- package/dist/component/server/implementation/types.js.map +0 -1
- package/dist/component/server/implementation/users.js.map +0 -1
- package/dist/component/server/implementation/utils.js +0 -56
- package/dist/component/server/implementation/utils.js.map +0 -1
- package/dist/component/server/providers.js.map +0 -1
- package/dist/component/server/templates.js +0 -84
- package/dist/component/server/templates.js.map +0 -1
- package/dist/server/cookies.d.ts.map +0 -1
- package/dist/server/implementation/db.d.ts +0 -86
- package/dist/server/implementation/db.d.ts.map +0 -1
- package/dist/server/implementation/db.js.map +0 -1
- package/dist/server/implementation/device.d.ts +0 -30
- package/dist/server/implementation/device.d.ts.map +0 -1
- package/dist/server/implementation/device.js +0 -135
- package/dist/server/implementation/device.js.map +0 -1
- package/dist/server/implementation/index.d.ts +0 -870
- package/dist/server/implementation/index.d.ts.map +0 -1
- package/dist/server/implementation/index.js +0 -610
- package/dist/server/implementation/index.js.map +0 -1
- package/dist/server/implementation/keys.d.ts +0 -66
- package/dist/server/implementation/keys.d.ts.map +0 -1
- package/dist/server/implementation/keys.js.map +0 -1
- package/dist/server/implementation/mutations/account.d.ts +0 -27
- package/dist/server/implementation/mutations/account.d.ts.map +0 -1
- package/dist/server/implementation/mutations/account.js +0 -39
- package/dist/server/implementation/mutations/account.js.map +0 -1
- package/dist/server/implementation/mutations/code.d.ts +0 -29
- package/dist/server/implementation/mutations/code.d.ts.map +0 -1
- package/dist/server/implementation/mutations/code.js.map +0 -1
- package/dist/server/implementation/mutations/index.d.ts +0 -310
- package/dist/server/implementation/mutations/index.d.ts.map +0 -1
- package/dist/server/implementation/mutations/index.js +0 -70
- package/dist/server/implementation/mutations/index.js.map +0 -1
- package/dist/server/implementation/mutations/invalidate.d.ts +0 -18
- package/dist/server/implementation/mutations/invalidate.d.ts.map +0 -1
- package/dist/server/implementation/mutations/invalidate.js +0 -29
- package/dist/server/implementation/mutations/invalidate.js.map +0 -1
- package/dist/server/implementation/mutations/oauth.d.ts +0 -23
- package/dist/server/implementation/mutations/oauth.d.ts.map +0 -1
- package/dist/server/implementation/mutations/oauth.js +0 -51
- package/dist/server/implementation/mutations/oauth.js.map +0 -1
- package/dist/server/implementation/mutations/refresh.d.ts +0 -20
- package/dist/server/implementation/mutations/refresh.d.ts.map +0 -1
- package/dist/server/implementation/mutations/refresh.js +0 -85
- package/dist/server/implementation/mutations/refresh.js.map +0 -1
- package/dist/server/implementation/mutations/register.d.ts +0 -37
- package/dist/server/implementation/mutations/register.d.ts.map +0 -1
- package/dist/server/implementation/mutations/register.js +0 -65
- package/dist/server/implementation/mutations/register.js.map +0 -1
- package/dist/server/implementation/mutations/retrieve.d.ts +0 -31
- package/dist/server/implementation/mutations/retrieve.d.ts.map +0 -1
- package/dist/server/implementation/mutations/retrieve.js +0 -50
- package/dist/server/implementation/mutations/retrieve.js.map +0 -1
- package/dist/server/implementation/mutations/signature.d.ts +0 -19
- package/dist/server/implementation/mutations/signature.d.ts.map +0 -1
- package/dist/server/implementation/mutations/signature.js +0 -27
- package/dist/server/implementation/mutations/signature.js.map +0 -1
- package/dist/server/implementation/mutations/signin.d.ts +0 -21
- package/dist/server/implementation/mutations/signin.d.ts.map +0 -1
- package/dist/server/implementation/mutations/signin.js.map +0 -1
- package/dist/server/implementation/mutations/signout.d.ts +0 -14
- package/dist/server/implementation/mutations/signout.d.ts.map +0 -1
- package/dist/server/implementation/mutations/signout.js +0 -27
- package/dist/server/implementation/mutations/signout.js.map +0 -1
- package/dist/server/implementation/mutations/store.d.ts +0 -11
- package/dist/server/implementation/mutations/store.d.ts.map +0 -1
- package/dist/server/implementation/mutations/store.js +0 -12
- package/dist/server/implementation/mutations/store.js.map +0 -1
- package/dist/server/implementation/mutations/verifier.d.ts +0 -11
- package/dist/server/implementation/mutations/verifier.d.ts.map +0 -1
- package/dist/server/implementation/mutations/verifier.js +0 -16
- package/dist/server/implementation/mutations/verifier.js.map +0 -1
- package/dist/server/implementation/mutations/verify.d.ts +0 -25
- package/dist/server/implementation/mutations/verify.d.ts.map +0 -1
- package/dist/server/implementation/mutations/verify.js +0 -105
- package/dist/server/implementation/mutations/verify.js.map +0 -1
- package/dist/server/implementation/passkey.d.ts +0 -24
- package/dist/server/implementation/passkey.d.ts.map +0 -1
- package/dist/server/implementation/passkey.js +0 -307
- package/dist/server/implementation/passkey.js.map +0 -1
- package/dist/server/implementation/provider.d.ts +0 -10
- package/dist/server/implementation/provider.d.ts.map +0 -1
- package/dist/server/implementation/provider.js +0 -19
- package/dist/server/implementation/provider.js.map +0 -1
- package/dist/server/implementation/ratelimit.d.ts +0 -10
- package/dist/server/implementation/ratelimit.d.ts.map +0 -1
- package/dist/server/implementation/ratelimit.js +0 -48
- package/dist/server/implementation/ratelimit.js.map +0 -1
- package/dist/server/implementation/redirects.d.ts +0 -10
- package/dist/server/implementation/redirects.d.ts.map +0 -1
- package/dist/server/implementation/redirects.js.map +0 -1
- package/dist/server/implementation/refresh.d.ts +0 -37
- package/dist/server/implementation/refresh.d.ts.map +0 -1
- package/dist/server/implementation/refresh.js +0 -109
- package/dist/server/implementation/refresh.js.map +0 -1
- package/dist/server/implementation/sessions.d.ts +0 -29
- package/dist/server/implementation/sessions.d.ts.map +0 -1
- package/dist/server/implementation/sessions.js.map +0 -1
- package/dist/server/implementation/signin.d.ts +0 -55
- package/dist/server/implementation/signin.d.ts.map +0 -1
- package/dist/server/implementation/signin.js +0 -148
- package/dist/server/implementation/signin.js.map +0 -1
- package/dist/server/implementation/tokens.d.ts +0 -11
- package/dist/server/implementation/tokens.d.ts.map +0 -1
- package/dist/server/implementation/tokens.js +0 -15
- package/dist/server/implementation/tokens.js.map +0 -1
- package/dist/server/implementation/totp.d.ts +0 -31
- package/dist/server/implementation/totp.d.ts.map +0 -1
- package/dist/server/implementation/totp.js +0 -142
- package/dist/server/implementation/totp.js.map +0 -1
- package/dist/server/implementation/types.d.ts +0 -189
- package/dist/server/implementation/types.d.ts.map +0 -1
- package/dist/server/implementation/types.js +0 -97
- package/dist/server/implementation/types.js.map +0 -1
- package/dist/server/implementation/users.d.ts +0 -30
- package/dist/server/implementation/users.d.ts.map +0 -1
- package/dist/server/implementation/users.js.map +0 -1
- package/dist/server/implementation/utils.d.ts +0 -19
- package/dist/server/implementation/utils.d.ts.map +0 -1
- package/dist/server/implementation/utils.js +0 -56
- package/dist/server/implementation/utils.js.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/oauth.d.ts.map +0 -1
- package/dist/server/providers.d.ts +0 -72
- package/dist/server/providers.d.ts.map +0 -1
- package/dist/server/providers.js.map +0 -1
- package/dist/server/templates.d.ts.map +0 -1
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/version.d.ts +0 -5
- package/dist/server/version.d.ts.map +0 -1
- package/dist/server/version.js +0 -6
- package/dist/server/version.js.map +0 -1
- package/src/cli/utils.ts +0 -248
- package/src/server/implementation/device.ts +0 -307
- package/src/server/implementation/index.ts +0 -1583
- package/src/server/implementation/mutations/account.ts +0 -50
- package/src/server/implementation/mutations/index.ts +0 -157
- package/src/server/implementation/mutations/invalidate.ts +0 -42
- package/src/server/implementation/mutations/oauth.ts +0 -73
- package/src/server/implementation/mutations/refresh.ts +0 -175
- package/src/server/implementation/mutations/register.ts +0 -100
- package/src/server/implementation/mutations/retrieve.ts +0 -79
- package/src/server/implementation/mutations/signature.ts +0 -39
- package/src/server/implementation/mutations/signout.ts +0 -35
- package/src/server/implementation/mutations/store.ts +0 -7
- package/src/server/implementation/mutations/verifier.ts +0 -24
- package/src/server/implementation/mutations/verify.ts +0 -194
- package/src/server/implementation/passkey.ts +0 -620
- package/src/server/implementation/provider.ts +0 -36
- package/src/server/implementation/ratelimit.ts +0 -79
- package/src/server/implementation/refresh.ts +0 -172
- package/src/server/implementation/signin.ts +0 -296
- package/src/server/implementation/totp.ts +0 -342
- package/src/server/implementation/types.ts +0 -444
- package/src/server/implementation/utils.ts +0 -91
- package/src/server/version.ts +0 -2
package/src/server/types.ts
CHANGED
|
@@ -1,27 +1,107 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AnyDataModel,
|
|
3
|
+
DataModelFromSchemaDefinition,
|
|
3
4
|
DocumentByName,
|
|
4
5
|
FunctionReference,
|
|
5
6
|
GenericActionCtx,
|
|
6
7
|
GenericDataModel,
|
|
7
8
|
GenericMutationCtx,
|
|
9
|
+
GenericQueryCtx,
|
|
8
10
|
RegisteredAction,
|
|
9
11
|
RegisteredMutation,
|
|
10
12
|
RegisteredQuery,
|
|
11
13
|
TableNamesInDataModel,
|
|
12
14
|
} from "convex/server";
|
|
15
|
+
import type { Infer } from "convex/values";
|
|
13
16
|
import { GenericId, Value } from "convex/values";
|
|
14
|
-
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
vApiKeyDoc,
|
|
20
|
+
vAuthVerifierDoc,
|
|
21
|
+
vDeviceCodeDoc,
|
|
22
|
+
vPasskeyDoc,
|
|
23
|
+
vTotpFactorDoc,
|
|
24
|
+
vUserDoc,
|
|
25
|
+
} from "../component/model";
|
|
26
|
+
import schema from "../component/schema";
|
|
27
|
+
import type { CredentialsConfig } from "../providers/credentials";
|
|
15
28
|
|
|
16
29
|
// ============================================================================
|
|
17
30
|
// Utility types
|
|
18
31
|
// ============================================================================
|
|
19
32
|
|
|
20
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* A value that is either `T` or a `PromiseLike<T>`.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam T - The underlying value type.
|
|
37
|
+
*/
|
|
21
38
|
export type Awaitable<T> = T | PromiseLike<T>;
|
|
22
39
|
|
|
23
40
|
/**
|
|
24
|
-
*
|
|
41
|
+
* A single role definition within the authorization config.
|
|
42
|
+
*
|
|
43
|
+
* Each role has an optional human-readable label and a list of grant strings
|
|
44
|
+
* that members with this role receive.
|
|
45
|
+
*
|
|
46
|
+
* @see {@link AuthAuthorizationConfig}
|
|
47
|
+
*/
|
|
48
|
+
export type AuthRoleDefinition = {
|
|
49
|
+
/** Optional stable identifier (defaults to the record key). */
|
|
50
|
+
id?: string;
|
|
51
|
+
/** Human-readable label for admin UIs. */
|
|
52
|
+
label?: string;
|
|
53
|
+
/** Permission grant strings conferred by this role. */
|
|
54
|
+
grants: string[];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Authorization configuration mapping role IDs to {@link AuthRoleDefinition}s.
|
|
59
|
+
*
|
|
60
|
+
* Passed as `authorization.roles` in {@link ConvexAuthConfig}.
|
|
61
|
+
*
|
|
62
|
+
* @see {@link AuthRoleDefinition}
|
|
63
|
+
* @see {@link ConvexAuthConfig}
|
|
64
|
+
*/
|
|
65
|
+
export type AuthAuthorizationConfig = {
|
|
66
|
+
roles: Record<string, AuthRoleDefinition>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Extracts the union of role ID strings from an authorization config.
|
|
71
|
+
*
|
|
72
|
+
* When `TAuthorization` is defined, this resolves to the literal key union
|
|
73
|
+
* of the `roles` record. Otherwise falls back to `string`.
|
|
74
|
+
*
|
|
75
|
+
* @typeParam TAuthorization - The authorization config type, or `undefined`.
|
|
76
|
+
*
|
|
77
|
+
* @see {@link AuthGrant}
|
|
78
|
+
*/
|
|
79
|
+
export type AuthRoleId<
|
|
80
|
+
TAuthorization extends AuthAuthorizationConfig | undefined,
|
|
81
|
+
> = TAuthorization extends { roles: infer TRoles extends Record<string, any> }
|
|
82
|
+
? keyof TRoles & string
|
|
83
|
+
: string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Extracts the union of grant strings from all roles in an authorization config.
|
|
87
|
+
*
|
|
88
|
+
* When `TAuthorization` is defined, this resolves to the literal union
|
|
89
|
+
* of all `grants` array elements across every role. Otherwise falls back to `string`.
|
|
90
|
+
*
|
|
91
|
+
* @typeParam TAuthorization - The authorization config type, or `undefined`.
|
|
92
|
+
*
|
|
93
|
+
* @see {@link AuthRoleId}
|
|
94
|
+
*/
|
|
95
|
+
export type AuthGrant<
|
|
96
|
+
TAuthorization extends AuthAuthorizationConfig | undefined,
|
|
97
|
+
> = TAuthorization extends {
|
|
98
|
+
roles: infer TRoles extends Record<string, { grants: readonly any[] }>;
|
|
99
|
+
}
|
|
100
|
+
? TRoles[keyof TRoles]["grants"][number] & string
|
|
101
|
+
: string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The config for the Convex Auth library, passed to `createAuth`.
|
|
25
105
|
*/
|
|
26
106
|
export type ConvexAuthConfig = {
|
|
27
107
|
/**
|
|
@@ -46,12 +126,16 @@ export type ConvexAuthConfig = {
|
|
|
46
126
|
* How long can a user session last without the user reauthenticating.
|
|
47
127
|
*
|
|
48
128
|
* Defaults to 30 days.
|
|
129
|
+
*
|
|
130
|
+
* @defaultValue 2_592_000_000
|
|
49
131
|
*/
|
|
50
132
|
totalDurationMs?: number;
|
|
51
133
|
/**
|
|
52
134
|
* How long can a user session last without the user being active.
|
|
53
135
|
*
|
|
54
136
|
* Defaults to 30 days.
|
|
137
|
+
*
|
|
138
|
+
* @defaultValue 2_592_000_000
|
|
55
139
|
*/
|
|
56
140
|
inactiveDurationMs?: number;
|
|
57
141
|
};
|
|
@@ -63,6 +147,8 @@ export type ConvexAuthConfig = {
|
|
|
63
147
|
* How long is the JWT valid for after it is signed initially.
|
|
64
148
|
*
|
|
65
149
|
* Defaults to 1 hour.
|
|
150
|
+
*
|
|
151
|
+
* @defaultValue 3_600_000
|
|
66
152
|
*/
|
|
67
153
|
durationMs?: number;
|
|
68
154
|
};
|
|
@@ -76,63 +162,11 @@ export type ConvexAuthConfig = {
|
|
|
76
162
|
*
|
|
77
163
|
* Defaults to 10 times per hour (that is 10 failed attempts, and then
|
|
78
164
|
* allow another one every 6 minutes).
|
|
165
|
+
*
|
|
166
|
+
* @defaultValue 10
|
|
79
167
|
*/
|
|
80
|
-
|
|
168
|
+
maxFailedAttemptsPerHour?: number;
|
|
81
169
|
};
|
|
82
|
-
/**
|
|
83
|
-
* API key configuration for programmatic access.
|
|
84
|
-
*
|
|
85
|
-
* Enables `auth.key.*` helpers for creating, verifying, and managing
|
|
86
|
-
* API keys with scoped permissions and optional per-key rate limiting.
|
|
87
|
-
*/
|
|
88
|
-
apiKeys?: ApiKeyConfig;
|
|
89
|
-
/**
|
|
90
|
-
* Email transport configuration.
|
|
91
|
-
*
|
|
92
|
-
* Required for magic link authentication.
|
|
93
|
-
* The library generates email content (subject, styled HTML); you
|
|
94
|
-
* provide the delivery mechanism — Resend, SendGrid, SES, Postmark,
|
|
95
|
-
* or any other provider.
|
|
96
|
-
*
|
|
97
|
-
* When configured, a magic link email provider (`id: "email"`) is
|
|
98
|
-
* auto-registered — no need to add a separate Auth.js email provider
|
|
99
|
-
* to `providers`.
|
|
100
|
-
*
|
|
101
|
-
* Works seamlessly with the `@convex-dev/resend` Convex component:
|
|
102
|
-
*
|
|
103
|
-
* ```ts
|
|
104
|
-
* import { Resend } from "@convex-dev/resend";
|
|
105
|
-
*
|
|
106
|
-
* const resend = new Resend(components.resend, { testMode: false });
|
|
107
|
-
*
|
|
108
|
-
* const auth = new Auth(components.auth, {
|
|
109
|
-
* providers: [google],
|
|
110
|
-
* email: {
|
|
111
|
-
* from: "My App <noreply@example.com>",
|
|
112
|
-
* send: (ctx, params) => resend.sendEmail(ctx, params),
|
|
113
|
-
* },
|
|
114
|
-
* });
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* Or with any email API directly:
|
|
118
|
-
*
|
|
119
|
-
* ```ts
|
|
120
|
-
* email: {
|
|
121
|
-
* from: "My App <noreply@example.com>",
|
|
122
|
-
* send: async (_ctx, { from, to, subject, html }) => {
|
|
123
|
-
* await fetch("https://api.resend.com/emails", {
|
|
124
|
-
* method: "POST",
|
|
125
|
-
* headers: {
|
|
126
|
-
* Authorization: `Bearer ${process.env.AUTH_RESEND_KEY}`,
|
|
127
|
-
* "Content-Type": "application/json",
|
|
128
|
-
* },
|
|
129
|
-
* body: JSON.stringify({ from, to, subject, html }),
|
|
130
|
-
* });
|
|
131
|
-
* },
|
|
132
|
-
* },
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
email?: EmailTransport;
|
|
136
170
|
/**
|
|
137
171
|
* Lifecycle callbacks for customizing sign-in behavior.
|
|
138
172
|
*
|
|
@@ -145,20 +179,21 @@ export type ConvexAuthConfig = {
|
|
|
145
179
|
* Control which URLs are allowed as a destination after OAuth sign-in
|
|
146
180
|
* and for magic links:
|
|
147
181
|
*
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
182
|
+
* ```ts
|
|
183
|
+
* import { createAuth } from "@robelest/convex-auth/component";
|
|
184
|
+
* import { components } from "./_generated/api";
|
|
185
|
+
*
|
|
186
|
+
* const auth = createAuth(components.auth, {
|
|
187
|
+
* providers: [google],
|
|
188
|
+
* callbacks: {
|
|
189
|
+
* async redirect({ redirectTo }) {
|
|
190
|
+
* // Check that redirectTo is valid
|
|
191
|
+
* // and return the relative or absolute URL
|
|
192
|
+
* // to redirect to.
|
|
193
|
+
* },
|
|
194
|
+
* },
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
162
197
|
*
|
|
163
198
|
* Convex Auth performs redirect only during OAuth sign-in. By default,
|
|
164
199
|
* it redirects back to the URL specified via the `SITE_URL` environment
|
|
@@ -201,7 +236,7 @@ export type ConvexAuthConfig = {
|
|
|
201
236
|
* If this is a sign-in to an existing account,
|
|
202
237
|
* this is the existing user ID linked to that account.
|
|
203
238
|
*/
|
|
204
|
-
existingUserId: GenericId<"
|
|
239
|
+
existingUserId: GenericId<"User"> | null;
|
|
205
240
|
/**
|
|
206
241
|
* The provider type or "verification" if this callback is called
|
|
207
242
|
* after an email or phone token verification.
|
|
@@ -230,7 +265,7 @@ export type ConvexAuthConfig = {
|
|
|
230
265
|
*/
|
|
231
266
|
shouldLink?: boolean;
|
|
232
267
|
},
|
|
233
|
-
) => Promise<GenericId<"
|
|
268
|
+
) => Promise<GenericId<"User">>;
|
|
234
269
|
/**
|
|
235
270
|
* Perform additional writes after a user is created.
|
|
236
271
|
*
|
|
@@ -251,12 +286,12 @@ export type ConvexAuthConfig = {
|
|
|
251
286
|
/**
|
|
252
287
|
* The ID of the user that is being signed in.
|
|
253
288
|
*/
|
|
254
|
-
userId: GenericId<"
|
|
289
|
+
userId: GenericId<"User">;
|
|
255
290
|
/**
|
|
256
291
|
* If this is a sign-in to an existing account,
|
|
257
292
|
* this is the existing user ID linked to that account.
|
|
258
293
|
*/
|
|
259
|
-
existingUserId: GenericId<"
|
|
294
|
+
existingUserId: GenericId<"User"> | null;
|
|
260
295
|
/**
|
|
261
296
|
* The provider type or "verification" if this callback is called
|
|
262
297
|
* after an email or phone token verification.
|
|
@@ -287,6 +322,18 @@ export type ConvexAuthConfig = {
|
|
|
287
322
|
},
|
|
288
323
|
) => Promise<void>;
|
|
289
324
|
};
|
|
325
|
+
/**
|
|
326
|
+
* Application-defined role and grant model used by membership access checks.
|
|
327
|
+
*/
|
|
328
|
+
authorization?: {
|
|
329
|
+
roles: Record<
|
|
330
|
+
string,
|
|
331
|
+
{
|
|
332
|
+
label?: string;
|
|
333
|
+
grants: string[];
|
|
334
|
+
}
|
|
335
|
+
>;
|
|
336
|
+
};
|
|
290
337
|
};
|
|
291
338
|
|
|
292
339
|
/**
|
|
@@ -299,6 +346,14 @@ export type ConvexAuthConfig = {
|
|
|
299
346
|
*/
|
|
300
347
|
export type AuthProviderConfig =
|
|
301
348
|
| import("../providers/oauth").OAuthProviderInstance
|
|
349
|
+
| import("../providers/password").Password
|
|
350
|
+
| import("../providers/passkey").Passkey
|
|
351
|
+
| import("../providers/totp").Totp
|
|
352
|
+
| import("../providers/anonymous").Anonymous
|
|
353
|
+
| import("../providers/device").Device
|
|
354
|
+
| import("../providers/sso").SSO
|
|
355
|
+
| import("../providers/email").Email
|
|
356
|
+
| import("../providers/phone").Phone
|
|
302
357
|
| OAuthMaterializedConfig
|
|
303
358
|
| ConvexCredentialsConfig
|
|
304
359
|
| ((...args: any) => ConvexCredentialsConfig)
|
|
@@ -311,10 +366,117 @@ export type AuthProviderConfig =
|
|
|
311
366
|
| TotpProviderConfig
|
|
312
367
|
| ((...args: any) => TotpProviderConfig)
|
|
313
368
|
| DeviceProviderConfig
|
|
314
|
-
| ((...args: any) => DeviceProviderConfig)
|
|
369
|
+
| ((...args: any) => DeviceProviderConfig)
|
|
370
|
+
| SSOProviderConfig;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Minimal config stored for the SSO provider at runtime.
|
|
374
|
+
* No options — enterprise configuration is entirely per-tenant runtime state.
|
|
375
|
+
*/
|
|
376
|
+
export interface SSOProviderConfig {
|
|
377
|
+
id: string;
|
|
378
|
+
type: "sso";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Account linking strategy for enterprise SSO sign-in.
|
|
383
|
+
*
|
|
384
|
+
* - `"verifiedEmail"` — link accounts when the IdP-provided email matches a verified email on an existing user.
|
|
385
|
+
* - `"none"` — never auto-link; always create a new account.
|
|
386
|
+
*/
|
|
387
|
+
export type EnterpriseAccountLinkingPolicy = "verifiedEmail" | "none";
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Policy for reusing existing users during SCIM provisioning.
|
|
391
|
+
*
|
|
392
|
+
* - `"externalId"` — match by the SCIM `externalId` to reuse a previously provisioned user.
|
|
393
|
+
* - `"none"` — always create a new user for each SCIM provision request.
|
|
394
|
+
*/
|
|
395
|
+
export type EnterpriseScimReuseUserPolicy = "externalId" | "none";
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Just-in-time provisioning mode for enterprise SSO.
|
|
399
|
+
*
|
|
400
|
+
* - `"off"` — no JIT provisioning; users must be pre-provisioned.
|
|
401
|
+
* - `"createUser"` — create a user record on first SSO sign-in.
|
|
402
|
+
* - `"createUserAndMembership"` — create a user and add them to the enterprise group on first SSO sign-in.
|
|
403
|
+
*/
|
|
404
|
+
export type EnterpriseJitProvisioningMode =
|
|
405
|
+
| "off"
|
|
406
|
+
| "createUser"
|
|
407
|
+
| "createUserAndMembership";
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Deprovisioning strategy when a SCIM user is deleted.
|
|
411
|
+
*
|
|
412
|
+
* - `"soft"` — mark the user as inactive but preserve the record.
|
|
413
|
+
* - `"hard"` — permanently delete the user and associated data.
|
|
414
|
+
*/
|
|
415
|
+
export type EnterpriseDeprovisionMode = "soft" | "hard";
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Effective enterprise policy document stored for an SSO/SCIM tenant.
|
|
419
|
+
*
|
|
420
|
+
* Controls account linking, JIT provisioning, SCIM reuse behavior,
|
|
421
|
+
* deprovisioning, and any app-defined extension metadata.
|
|
422
|
+
*
|
|
423
|
+
* @see {@link EnterprisePolicyPatch}
|
|
424
|
+
*/
|
|
425
|
+
export interface EnterprisePolicy {
|
|
426
|
+
version: 1;
|
|
427
|
+
identity: {
|
|
428
|
+
accountLinking: {
|
|
429
|
+
oidc: EnterpriseAccountLinkingPolicy;
|
|
430
|
+
saml: EnterpriseAccountLinkingPolicy;
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
provisioning: {
|
|
434
|
+
scimReuse: {
|
|
435
|
+
user: EnterpriseScimReuseUserPolicy;
|
|
436
|
+
};
|
|
437
|
+
jit: {
|
|
438
|
+
mode: EnterpriseJitProvisioningMode;
|
|
439
|
+
defaultRoleIds: string[];
|
|
440
|
+
};
|
|
441
|
+
deprovision: {
|
|
442
|
+
mode: EnterpriseDeprovisionMode;
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
extend?: Record<string, unknown>;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Partial update payload for {@link EnterprisePolicy}.
|
|
450
|
+
*
|
|
451
|
+
* Use this when patching only selected enterprise policy sections without
|
|
452
|
+
* replacing the entire stored policy document.
|
|
453
|
+
*/
|
|
454
|
+
export interface EnterprisePolicyPatch {
|
|
455
|
+
identity?: {
|
|
456
|
+
accountLinking?: {
|
|
457
|
+
oidc?: EnterpriseAccountLinkingPolicy;
|
|
458
|
+
saml?: EnterpriseAccountLinkingPolicy;
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
provisioning?: {
|
|
462
|
+
scimReuse?: {
|
|
463
|
+
user?: EnterpriseScimReuseUserPolicy;
|
|
464
|
+
};
|
|
465
|
+
jit?: {
|
|
466
|
+
mode?: EnterpriseJitProvisioningMode;
|
|
467
|
+
defaultRoleIds?: string[];
|
|
468
|
+
};
|
|
469
|
+
deprovision?: {
|
|
470
|
+
mode?: EnterpriseDeprovisionMode;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
extend?: Record<string, unknown>;
|
|
474
|
+
}
|
|
315
475
|
|
|
316
476
|
/**
|
|
317
477
|
* Email provider config for magic link / OTP sign-in.
|
|
478
|
+
*
|
|
479
|
+
* @typeParam DataModel - The Convex data model for typed action contexts.
|
|
318
480
|
*/
|
|
319
481
|
export interface EmailConfig<
|
|
320
482
|
DataModel extends GenericDataModel = GenericDataModel,
|
|
@@ -327,7 +489,11 @@ export interface EmailConfig<
|
|
|
327
489
|
name?: string;
|
|
328
490
|
/** Sender address (e.g. `"My App <noreply@example.com>"`). */
|
|
329
491
|
from?: string;
|
|
330
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* Token expiration in seconds. Defaults to 86 400 (24 hours).
|
|
494
|
+
*
|
|
495
|
+
* @defaultValue 86400
|
|
496
|
+
*/
|
|
331
497
|
maxAge?: number;
|
|
332
498
|
/**
|
|
333
499
|
* Send the verification token to the user.
|
|
@@ -369,14 +535,18 @@ export interface EmailConfig<
|
|
|
369
535
|
* The values passed to the `signIn` function.
|
|
370
536
|
*/
|
|
371
537
|
params: Record<string, Value | undefined>,
|
|
372
|
-
account: GenericDoc<DataModel, "
|
|
538
|
+
account: GenericDoc<DataModel, "Account">,
|
|
373
539
|
) => Promise<void>;
|
|
374
540
|
/** Raw user options before merging with defaults. */
|
|
375
541
|
options: EmailUserConfig<DataModel>;
|
|
376
542
|
}
|
|
377
543
|
|
|
378
544
|
/**
|
|
379
|
-
*
|
|
545
|
+
* User-facing configuration shape accepted by the email provider.
|
|
546
|
+
*
|
|
547
|
+
* Equivalent to `Partial<EmailConfig>` without internal runtime-only fields.
|
|
548
|
+
*
|
|
549
|
+
* @typeParam DataModel - The Convex data model.
|
|
380
550
|
*/
|
|
381
551
|
export type EmailUserConfig<
|
|
382
552
|
DataModel extends GenericDataModel = GenericDataModel,
|
|
@@ -385,6 +555,8 @@ export type EmailUserConfig<
|
|
|
385
555
|
/**
|
|
386
556
|
* Same as email provider config, but verifies
|
|
387
557
|
* phone number instead of the email address.
|
|
558
|
+
*
|
|
559
|
+
* @typeParam DataModel - The Convex data model for typed action contexts.
|
|
388
560
|
*/
|
|
389
561
|
export interface PhoneConfig<
|
|
390
562
|
DataModel extends GenericDataModel = GenericDataModel,
|
|
@@ -439,22 +611,26 @@ export interface PhoneConfig<
|
|
|
439
611
|
* The values passed to the `signIn` function.
|
|
440
612
|
*/
|
|
441
613
|
params: Record<string, Value | undefined>,
|
|
442
|
-
account: GenericDoc<DataModel, "
|
|
614
|
+
account: GenericDoc<DataModel, "Account">,
|
|
443
615
|
) => Promise<void>;
|
|
444
616
|
options: PhoneUserConfig<DataModel>;
|
|
445
617
|
}
|
|
446
618
|
|
|
447
619
|
/**
|
|
448
|
-
*
|
|
620
|
+
* User-facing configuration shape accepted by the phone provider.
|
|
621
|
+
*
|
|
622
|
+
* Equivalent to `Partial<PhoneConfig>` without internal runtime-only fields.
|
|
623
|
+
*
|
|
624
|
+
* @typeParam DataModel - The Convex data model.
|
|
449
625
|
*/
|
|
450
626
|
export type PhoneUserConfig<
|
|
451
627
|
DataModel extends GenericDataModel = GenericDataModel,
|
|
452
628
|
> = Omit<Partial<PhoneConfig<DataModel>>, "options" | "type">;
|
|
453
629
|
|
|
454
630
|
/**
|
|
455
|
-
*
|
|
631
|
+
* Credentials provider config used by Convex Auth.
|
|
456
632
|
*/
|
|
457
|
-
export type ConvexCredentialsConfig =
|
|
633
|
+
export type ConvexCredentialsConfig = CredentialsConfig<any> & {
|
|
458
634
|
type: "credentials";
|
|
459
635
|
id: string;
|
|
460
636
|
};
|
|
@@ -472,17 +648,37 @@ export interface PasskeyProviderConfig {
|
|
|
472
648
|
rpId?: string;
|
|
473
649
|
/** Allowed origins for credential verification. Defaults to SITE_URL. */
|
|
474
650
|
origin?: string | string[];
|
|
475
|
-
/**
|
|
651
|
+
/**
|
|
652
|
+
* Attestation conveyance preference. Defaults to "none".
|
|
653
|
+
*
|
|
654
|
+
* @defaultValue "none"
|
|
655
|
+
*/
|
|
476
656
|
attestation?: "none" | "direct";
|
|
477
|
-
/**
|
|
657
|
+
/**
|
|
658
|
+
* User verification requirement. Defaults to "required".
|
|
659
|
+
*
|
|
660
|
+
* @defaultValue "required"
|
|
661
|
+
*/
|
|
478
662
|
userVerification?: "required" | "preferred" | "discouraged";
|
|
479
|
-
/**
|
|
663
|
+
/**
|
|
664
|
+
* Resident key (discoverable credential) preference. Defaults to "preferred".
|
|
665
|
+
*
|
|
666
|
+
* @defaultValue "preferred"
|
|
667
|
+
*/
|
|
480
668
|
residentKey?: "required" | "preferred" | "discouraged";
|
|
481
669
|
/** Restrict to platform or cross-platform authenticators. */
|
|
482
670
|
authenticatorAttachment?: "platform" | "cross-platform";
|
|
483
|
-
/**
|
|
671
|
+
/**
|
|
672
|
+
* Supported COSE algorithms. Defaults to [-7 (ES256), -257 (RS256)].
|
|
673
|
+
*
|
|
674
|
+
* @defaultValue [-7, -257]
|
|
675
|
+
*/
|
|
484
676
|
algorithms?: number[];
|
|
485
|
-
/**
|
|
677
|
+
/**
|
|
678
|
+
* Challenge expiration in ms. Defaults to 300_000 (5 minutes).
|
|
679
|
+
*
|
|
680
|
+
* @defaultValue 300_000
|
|
681
|
+
*/
|
|
486
682
|
challengeExpirationMs?: number;
|
|
487
683
|
};
|
|
488
684
|
}
|
|
@@ -496,9 +692,17 @@ export interface TotpProviderConfig {
|
|
|
496
692
|
options: {
|
|
497
693
|
/** Issuer name shown in authenticator apps (e.g. "My App"). */
|
|
498
694
|
issuer: string;
|
|
499
|
-
/**
|
|
695
|
+
/**
|
|
696
|
+
* Number of digits in each code (default: 6).
|
|
697
|
+
*
|
|
698
|
+
* @defaultValue 6
|
|
699
|
+
*/
|
|
500
700
|
digits: number;
|
|
501
|
-
/**
|
|
701
|
+
/**
|
|
702
|
+
* Time period in seconds for code rotation (default: 30).
|
|
703
|
+
*
|
|
704
|
+
* @defaultValue 30
|
|
705
|
+
*/
|
|
502
706
|
period: number;
|
|
503
707
|
};
|
|
504
708
|
}
|
|
@@ -526,6 +730,8 @@ export interface OAuthProfile {
|
|
|
526
730
|
*
|
|
527
731
|
* This is what the OAuth flow code receives — it maps to the user-facing
|
|
528
732
|
* `OAuthConfig` from `@robelest/convex-auth/providers`.
|
|
733
|
+
*
|
|
734
|
+
* @internal
|
|
529
735
|
*/
|
|
530
736
|
export interface OAuthProviderConfig {
|
|
531
737
|
/** OAuth scopes to request. */
|
|
@@ -573,52 +779,107 @@ export type AuthUpdateAccountArgs = {
|
|
|
573
779
|
|
|
574
780
|
/** Arguments for `auth.session.invalidate()`. */
|
|
575
781
|
export type AuthInvalidateSessionsArgs = {
|
|
576
|
-
userId: GenericId<"
|
|
577
|
-
except?: GenericId<"
|
|
782
|
+
userId: GenericId<"User">;
|
|
783
|
+
except?: GenericId<"Session">[];
|
|
578
784
|
};
|
|
579
785
|
|
|
580
786
|
/** Arguments for `auth.provider.signIn()`. */
|
|
581
787
|
export type AuthProviderSignInArgs = {
|
|
582
|
-
accountId?: GenericId<"
|
|
788
|
+
accountId?: GenericId<"Account">;
|
|
583
789
|
params?: Record<string, Value | undefined>;
|
|
584
790
|
};
|
|
585
791
|
|
|
586
792
|
/** Return type of `auth.provider.signIn()` — user and session IDs, or `null` on failure. */
|
|
587
793
|
export type AuthProviderSignInResult = {
|
|
588
|
-
userId: GenericId<"
|
|
589
|
-
sessionId: GenericId<"
|
|
794
|
+
userId: GenericId<"User">;
|
|
795
|
+
sessionId: GenericId<"Session">;
|
|
590
796
|
} | null;
|
|
591
797
|
|
|
592
|
-
/**
|
|
798
|
+
/** Arguments for `auth.member.resolve()`. */
|
|
799
|
+
export type AuthMemberResolveArgs = {
|
|
800
|
+
userId: GenericId<"User">;
|
|
801
|
+
groupId: GenericId<"Group">;
|
|
802
|
+
ancestry?: boolean;
|
|
803
|
+
roleIds?: string[];
|
|
804
|
+
grants?: string[];
|
|
805
|
+
maxDepth?: number;
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
/** Result of `auth.member.resolve()` — membership check with role and grant details. */
|
|
809
|
+
export type AuthMemberResolveResult = {
|
|
810
|
+
ok: boolean;
|
|
811
|
+
membership: GenericDoc<GenericDataModel, "GroupMember"> | null;
|
|
812
|
+
matchedGroupId: GenericId<"Group"> | null;
|
|
813
|
+
roleIds: string[];
|
|
814
|
+
grants: string[];
|
|
815
|
+
missingGrants: string[];
|
|
816
|
+
depth: number | null;
|
|
817
|
+
isDirect: boolean;
|
|
818
|
+
isInherited: boolean;
|
|
819
|
+
traversedGroupIds: GenericId<"Group">[];
|
|
820
|
+
code?: "INVALID_ROLE_IDS";
|
|
821
|
+
invalidRoleIds?: string[];
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Server-side auth helper methods injected into `ctx.auth` within provider actions.
|
|
826
|
+
*
|
|
827
|
+
* Provides programmatic access to account management, session lifecycle,
|
|
828
|
+
* membership resolution, and provider sign-in from within Convex actions
|
|
829
|
+
* that use {@link GenericActionCtxWithAuthConfig}.
|
|
830
|
+
*
|
|
831
|
+
* @see {@link GenericActionCtxWithAuthConfig}
|
|
832
|
+
*
|
|
833
|
+
* @example
|
|
834
|
+
* ```ts
|
|
835
|
+
* // Inside a credentials provider's authorize callback:
|
|
836
|
+
* const { account, user } = await ctx.auth.account.get(ctx, {
|
|
837
|
+
* provider: "password",
|
|
838
|
+
* account: { id: email },
|
|
839
|
+
* });
|
|
840
|
+
* ```
|
|
841
|
+
*/
|
|
593
842
|
export type AuthServerHelpers = {
|
|
843
|
+
/** Account management: create, retrieve, and update provider-linked accounts. */
|
|
594
844
|
account: {
|
|
595
845
|
create: (
|
|
596
846
|
ctx: GenericActionCtx<any>,
|
|
597
847
|
args: AuthCreateAccountArgs,
|
|
598
848
|
) => Promise<{
|
|
599
|
-
|
|
600
|
-
|
|
849
|
+
ok: true;
|
|
850
|
+
account: GenericDoc<GenericDataModel, "Account">;
|
|
851
|
+
user: GenericDoc<GenericDataModel, "User">;
|
|
601
852
|
}>;
|
|
602
853
|
get: (
|
|
603
854
|
ctx: GenericActionCtx<any>,
|
|
604
855
|
args: AuthRetrieveAccountArgs,
|
|
605
856
|
) => Promise<{
|
|
606
|
-
account: GenericDoc<GenericDataModel, "
|
|
607
|
-
user: GenericDoc<GenericDataModel, "
|
|
857
|
+
account: GenericDoc<GenericDataModel, "Account">;
|
|
858
|
+
user: GenericDoc<GenericDataModel, "User">;
|
|
608
859
|
}>;
|
|
609
860
|
update: (
|
|
610
861
|
ctx: GenericActionCtx<any>,
|
|
611
862
|
args: AuthUpdateAccountArgs,
|
|
612
|
-
) => Promise<
|
|
863
|
+
) => Promise<{ ok: true; accountId: GenericId<"Account"> }>;
|
|
613
864
|
};
|
|
614
865
|
session: {
|
|
615
|
-
current: (
|
|
616
|
-
|
|
617
|
-
) => Promise<GenericId<"
|
|
866
|
+
current: (ctx: {
|
|
867
|
+
auth: GenericActionCtx<GenericDataModel>["auth"];
|
|
868
|
+
}) => Promise<GenericId<"Session"> | null>;
|
|
618
869
|
invalidate: (
|
|
619
870
|
ctx: GenericActionCtx<any>,
|
|
620
871
|
args: AuthInvalidateSessionsArgs,
|
|
621
|
-
) => Promise<
|
|
872
|
+
) => Promise<{
|
|
873
|
+
ok: true;
|
|
874
|
+
userId: GenericId<"User">;
|
|
875
|
+
except: GenericId<"Session">[];
|
|
876
|
+
}>;
|
|
877
|
+
};
|
|
878
|
+
member: {
|
|
879
|
+
resolve: (
|
|
880
|
+
ctx: GenericActionCtx<any>,
|
|
881
|
+
args: AuthMemberResolveArgs,
|
|
882
|
+
) => Promise<AuthMemberResolveResult>;
|
|
622
883
|
};
|
|
623
884
|
provider: {
|
|
624
885
|
signIn: (
|
|
@@ -631,7 +892,9 @@ export type AuthServerHelpers = {
|
|
|
631
892
|
|
|
632
893
|
/**
|
|
633
894
|
* Your `ActionCtx` enriched with `ctx.auth.config` field with
|
|
634
|
-
* the config passed to `
|
|
895
|
+
* the config passed to `createAuth`.
|
|
896
|
+
*
|
|
897
|
+
* @typeParam DataModel - The Convex data model.
|
|
635
898
|
*/
|
|
636
899
|
export type GenericActionCtxWithAuthConfig<DataModel extends GenericDataModel> =
|
|
637
900
|
GenericActionCtx<DataModel> & {
|
|
@@ -641,7 +904,7 @@ export type GenericActionCtxWithAuthConfig<DataModel extends GenericDataModel> =
|
|
|
641
904
|
};
|
|
642
905
|
|
|
643
906
|
/**
|
|
644
|
-
* The config for the Convex Auth library, passed to `
|
|
907
|
+
* The config for the Convex Auth library, passed to `createAuth`,
|
|
645
908
|
* with defaults and initialized providers.
|
|
646
909
|
*
|
|
647
910
|
* See {@link ConvexAuthConfig}
|
|
@@ -650,29 +913,67 @@ export type ConvexAuthMaterializedConfig = {
|
|
|
650
913
|
providers: AuthProviderMaterializedConfig[];
|
|
651
914
|
} & Pick<
|
|
652
915
|
ConvexAuthConfig,
|
|
653
|
-
"component" | "session" | "jwt" | "signIn" | "callbacks"
|
|
916
|
+
"component" | "session" | "jwt" | "signIn" | "callbacks" | "authorization"
|
|
654
917
|
>;
|
|
655
918
|
|
|
919
|
+
/**
|
|
920
|
+
* Maps SAML assertion attribute names to user profile fields.
|
|
921
|
+
*
|
|
922
|
+
* Use this to tell the SSO flow which SAML attributes correspond to
|
|
923
|
+
* the user's subject identifier, email, and display name fields.
|
|
924
|
+
*/
|
|
925
|
+
export interface SAMLAttributeMapping {
|
|
926
|
+
/** SAML attribute for the unique subject identifier (NameID). */
|
|
927
|
+
subject?: string;
|
|
928
|
+
/** SAML attribute for the user's email address. */
|
|
929
|
+
email?: string;
|
|
930
|
+
/** SAML attribute for the user's full display name. */
|
|
931
|
+
name?: string;
|
|
932
|
+
/** SAML attribute for the user's first / given name. */
|
|
933
|
+
firstName?: string;
|
|
934
|
+
/** SAML attribute for the user's last / family name. */
|
|
935
|
+
lastName?: string;
|
|
936
|
+
}
|
|
937
|
+
|
|
656
938
|
/**
|
|
657
939
|
* Materialized OAuth provider config (Arctic-based).
|
|
658
940
|
*
|
|
659
941
|
* Carries the Arctic provider instance along with scopes and profile config.
|
|
660
|
-
|
|
942
|
+
* Produced by materializing an `OAuthProviderInstance` during `configDefaults`.
|
|
661
943
|
*/
|
|
662
944
|
export interface OAuthMaterializedConfig {
|
|
945
|
+
/**
|
|
946
|
+
* Provider identifier (e.g. `"google"`, `"github"`).
|
|
947
|
+
* @readonly
|
|
948
|
+
*/
|
|
663
949
|
readonly id: string;
|
|
950
|
+
/**
|
|
951
|
+
* Discriminant for provider type routing.
|
|
952
|
+
* @readonly
|
|
953
|
+
*/
|
|
664
954
|
readonly type: "oauth";
|
|
665
|
-
/**
|
|
955
|
+
/**
|
|
956
|
+
* The Arctic provider instance.
|
|
957
|
+
* @readonly
|
|
958
|
+
*/
|
|
666
959
|
readonly provider: any;
|
|
667
|
-
/**
|
|
960
|
+
/**
|
|
961
|
+
* OAuth scopes to request.
|
|
962
|
+
* @readonly
|
|
963
|
+
*/
|
|
668
964
|
readonly scopes: string[];
|
|
669
|
-
/** User-provided profile extraction callback. */
|
|
670
|
-
readonly profile?: (tokens: import("arctic").OAuth2Tokens) => Promise<OAuthProfile>;
|
|
671
965
|
/**
|
|
672
|
-
*
|
|
673
|
-
*
|
|
966
|
+
* User-provided profile extraction callback.
|
|
967
|
+
* @readonly
|
|
968
|
+
*/
|
|
969
|
+
readonly profile?: (
|
|
970
|
+
tokens: import("arctic").OAuth2Tokens,
|
|
971
|
+
) => Promise<OAuthProfile>;
|
|
972
|
+
/**
|
|
973
|
+
* Account-linking policy for OAuth identities. Defaults to verified email linking.
|
|
974
|
+
* @readonly
|
|
674
975
|
*/
|
|
675
|
-
readonly
|
|
976
|
+
readonly accountLinking?: "verifiedEmail" | "none";
|
|
676
977
|
}
|
|
677
978
|
|
|
678
979
|
/**
|
|
@@ -711,58 +1012,26 @@ export type AuthProviderMaterializedConfig =
|
|
|
711
1012
|
| ConvexCredentialsConfig
|
|
712
1013
|
| PasskeyProviderConfig
|
|
713
1014
|
| TotpProviderConfig
|
|
714
|
-
| DeviceProviderConfig
|
|
715
|
-
|
|
716
|
-
// ============================================================================
|
|
717
|
-
// Email transport types
|
|
718
|
-
// ============================================================================
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Email delivery parameters passed to `EmailTransport.send`.
|
|
722
|
-
*/
|
|
723
|
-
export interface EmailMessage {
|
|
724
|
-
/** Sender address (from `email.from` in your Auth config). */
|
|
725
|
-
from: string;
|
|
726
|
-
/** Recipient email address. */
|
|
727
|
-
to: string;
|
|
728
|
-
/** Email subject line. */
|
|
729
|
-
subject: string;
|
|
730
|
-
/** HTML body content. */
|
|
731
|
-
html: string;
|
|
732
|
-
}
|
|
1015
|
+
| DeviceProviderConfig
|
|
1016
|
+
| SSOProviderConfig;
|
|
733
1017
|
|
|
734
1018
|
/**
|
|
735
|
-
*
|
|
1019
|
+
* Resolves to `true` when the providers list includes `SSO`, otherwise `false`.
|
|
736
1020
|
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
1021
|
+
* Used to make `auth.sso` conditionally present on the `createAuth`
|
|
1022
|
+
* return type — it only appears when `new SSO()` is in the providers array.
|
|
739
1023
|
*/
|
|
740
|
-
export
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
* ```
|
|
752
|
-
*
|
|
753
|
-
* For plain HTTP email APIs, ignore the `ctx` parameter:
|
|
754
|
-
*
|
|
755
|
-
* ```ts
|
|
756
|
-
* send: async (_ctx, { from, to, subject, html }) => {
|
|
757
|
-
* await fetch("https://api.resend.com/emails", { ... });
|
|
758
|
-
* }
|
|
759
|
-
* ```
|
|
760
|
-
*/
|
|
761
|
-
send: (
|
|
762
|
-
ctx: GenericActionCtx<any>,
|
|
763
|
-
params: EmailMessage,
|
|
764
|
-
) => Promise<void>;
|
|
765
|
-
}
|
|
1024
|
+
export type HasSSO<P extends AuthProviderConfig[]> =
|
|
1025
|
+
import("../providers/sso").SSO extends P[number] ? true : false;
|
|
1026
|
+
|
|
1027
|
+
export type HasPasskeyProvider<P extends AuthProviderConfig[]> =
|
|
1028
|
+
import("../providers/passkey").Passkey extends P[number] ? true : false;
|
|
1029
|
+
|
|
1030
|
+
export type HasTotpProvider<P extends AuthProviderConfig[]> =
|
|
1031
|
+
import("../providers/totp").Totp extends P[number] ? true : false;
|
|
1032
|
+
|
|
1033
|
+
export type HasDeviceProvider<P extends AuthProviderConfig[]> =
|
|
1034
|
+
import("../providers/device").Device extends P[number] ? true : false;
|
|
766
1035
|
|
|
767
1036
|
// ============================================================================
|
|
768
1037
|
// API Key types
|
|
@@ -799,39 +1068,6 @@ export interface ScopeChecker {
|
|
|
799
1068
|
scopes: KeyScope[];
|
|
800
1069
|
}
|
|
801
1070
|
|
|
802
|
-
/**
|
|
803
|
-
* Configuration for API key support on the Auth class.
|
|
804
|
-
*
|
|
805
|
-
* ```ts
|
|
806
|
-
* const auth = new Auth(components.auth, {
|
|
807
|
-
* providers: [github],
|
|
808
|
-
* apiKeys: {
|
|
809
|
-
* scopes: {
|
|
810
|
-
* users: ["read", "list", "create", "delete"],
|
|
811
|
-
* messages: ["read", "write"],
|
|
812
|
-
* },
|
|
813
|
-
* defaultRateLimit: { maxRequests: 1000, windowMs: 3600000 },
|
|
814
|
-
* },
|
|
815
|
-
* });
|
|
816
|
-
* ```
|
|
817
|
-
*/
|
|
818
|
-
export interface ApiKeyConfig {
|
|
819
|
-
/**
|
|
820
|
-
* Define the available resource:action scopes for your API keys.
|
|
821
|
-
* Keys can only be created with scopes that are a subset of these.
|
|
822
|
-
*/
|
|
823
|
-
scopes?: Record<string, string[]>;
|
|
824
|
-
/**
|
|
825
|
-
* Default rate limit applied to new keys when not specified per-key.
|
|
826
|
-
* Uses a token-bucket algorithm.
|
|
827
|
-
*/
|
|
828
|
-
defaultRateLimit?: { maxRequests: number; windowMs: number };
|
|
829
|
-
/**
|
|
830
|
-
* Key prefix. Defaults to `"sk_live_"`.
|
|
831
|
-
*/
|
|
832
|
-
prefix?: string;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
1071
|
/**
|
|
836
1072
|
* An API key record as returned by `auth.key.list()` and `auth.key.get()`.
|
|
837
1073
|
* Never includes the raw key material — only the display prefix.
|
|
@@ -841,7 +1077,7 @@ export interface KeyRecord {
|
|
|
841
1077
|
_id: string;
|
|
842
1078
|
/** Owner user ID. */
|
|
843
1079
|
userId: string;
|
|
844
|
-
/** Display prefix (e.g. `"
|
|
1080
|
+
/** Display prefix (e.g. `"sk_abc1"`). Safe to show in UIs. */
|
|
845
1081
|
prefix: string;
|
|
846
1082
|
/** Human-readable name (e.g. "CI Pipeline"). */
|
|
847
1083
|
name: string;
|
|
@@ -857,6 +1093,8 @@ export interface KeyRecord {
|
|
|
857
1093
|
createdAt: number;
|
|
858
1094
|
/** `true` when the key has been revoked (soft-deleted). */
|
|
859
1095
|
revoked: boolean;
|
|
1096
|
+
/** Arbitrary app-specific metadata attached to the key. */
|
|
1097
|
+
metadata?: Record<string, unknown>;
|
|
860
1098
|
}
|
|
861
1099
|
|
|
862
1100
|
// ============================================================================
|
|
@@ -867,6 +1105,9 @@ export interface KeyRecord {
|
|
|
867
1105
|
* Options for paginated list queries. Every entity list method uses this
|
|
868
1106
|
* same shape with entity-specific `TWhere` and `TOrderBy` type parameters.
|
|
869
1107
|
*
|
|
1108
|
+
* @typeParam TWhere - The type of the optional filter object.
|
|
1109
|
+
* @typeParam TOrderBy - The union of sortable field names.
|
|
1110
|
+
*
|
|
870
1111
|
* ```ts
|
|
871
1112
|
* const result = await auth.group.list(ctx, {
|
|
872
1113
|
* where: { type: "team" },
|
|
@@ -894,6 +1135,8 @@ export type ListOptions<
|
|
|
894
1135
|
|
|
895
1136
|
/**
|
|
896
1137
|
* Paginated list result returned by every entity list method.
|
|
1138
|
+
*
|
|
1139
|
+
* @typeParam T - The type of items in the result array.
|
|
897
1140
|
*/
|
|
898
1141
|
export type ListResult<T> = {
|
|
899
1142
|
/** The page of items. */
|
|
@@ -938,16 +1181,16 @@ export type GroupWhere = {
|
|
|
938
1181
|
/** Sortable fields for `auth.group.list()`. */
|
|
939
1182
|
export type GroupOrderBy = "_creationTime" | "name" | "slug" | "type";
|
|
940
1183
|
|
|
941
|
-
/** Filter fields for `auth.
|
|
1184
|
+
/** Filter fields for `auth.member.list()`. All optional. */
|
|
942
1185
|
export type MemberWhere = {
|
|
943
1186
|
groupId?: string;
|
|
944
1187
|
userId?: string;
|
|
945
|
-
|
|
1188
|
+
roleId?: string;
|
|
946
1189
|
status?: string;
|
|
947
1190
|
};
|
|
948
1191
|
|
|
949
|
-
/** Sortable fields for `auth.
|
|
950
|
-
export type MemberOrderBy = "_creationTime" | "
|
|
1192
|
+
/** Sortable fields for `auth.member.list()`. */
|
|
1193
|
+
export type MemberOrderBy = "_creationTime" | "status";
|
|
951
1194
|
|
|
952
1195
|
/** Filter fields for `auth.invite.list()`. All optional. */
|
|
953
1196
|
export type InviteWhere = {
|
|
@@ -956,7 +1199,7 @@ export type InviteWhere = {
|
|
|
956
1199
|
status?: "pending" | "accepted" | "revoked" | "expired";
|
|
957
1200
|
email?: string;
|
|
958
1201
|
invitedByUserId?: string;
|
|
959
|
-
|
|
1202
|
+
roleId?: string;
|
|
960
1203
|
acceptedByUserId?: string;
|
|
961
1204
|
};
|
|
962
1205
|
|
|
@@ -1043,7 +1286,7 @@ export interface CorsConfig {
|
|
|
1043
1286
|
* Component function references required by core auth runtime.
|
|
1044
1287
|
*
|
|
1045
1288
|
* @internal Consumers should not depend on this shape — it may change
|
|
1046
|
-
* between minor versions. Pass `components.auth` directly to
|
|
1289
|
+
* between minor versions. Pass `components.auth` directly to `createAuth`.
|
|
1047
1290
|
*/
|
|
1048
1291
|
export type AuthComponentApi = {
|
|
1049
1292
|
public: {
|
|
@@ -1054,9 +1297,11 @@ export type AuthComponentApi = {
|
|
|
1054
1297
|
userInsert: FunctionReference<"mutation", "internal">;
|
|
1055
1298
|
userUpsert: FunctionReference<"mutation", "internal">;
|
|
1056
1299
|
userPatch: FunctionReference<"mutation", "internal">;
|
|
1300
|
+
userDelete: FunctionReference<"mutation", "internal">;
|
|
1057
1301
|
accountGet: FunctionReference<"query", "internal">;
|
|
1058
1302
|
accountGetById: FunctionReference<"query", "internal">;
|
|
1059
1303
|
accountInsert: FunctionReference<"mutation", "internal">;
|
|
1304
|
+
accountListByUser: FunctionReference<"query", "internal">;
|
|
1060
1305
|
accountPatch: FunctionReference<"mutation", "internal">;
|
|
1061
1306
|
accountDelete: FunctionReference<"mutation", "internal">;
|
|
1062
1307
|
sessionCreate: FunctionReference<"mutation", "internal">;
|
|
@@ -1091,20 +1336,20 @@ export type AuthComponentApi = {
|
|
|
1091
1336
|
memberAdd: FunctionReference<"mutation", "internal">;
|
|
1092
1337
|
memberGet: FunctionReference<"query", "internal">;
|
|
1093
1338
|
memberList: FunctionReference<"query", "internal">;
|
|
1094
|
-
memberListByUser: FunctionReference<"query", "internal">;
|
|
1095
1339
|
memberGetByGroupAndUser: FunctionReference<"query", "internal">;
|
|
1096
1340
|
memberRemove: FunctionReference<"mutation", "internal">;
|
|
1097
1341
|
memberUpdate: FunctionReference<"mutation", "internal">;
|
|
1098
1342
|
inviteCreate: FunctionReference<"mutation", "internal">;
|
|
1099
1343
|
inviteGet: FunctionReference<"query", "internal">;
|
|
1344
|
+
inviteGetByTokenHash: FunctionReference<"query", "internal">;
|
|
1100
1345
|
inviteList: FunctionReference<"query", "internal">;
|
|
1101
1346
|
inviteAccept: FunctionReference<"mutation", "internal">;
|
|
1347
|
+
inviteAcceptByToken: FunctionReference<"mutation", "internal">;
|
|
1102
1348
|
inviteRevoke: FunctionReference<"mutation", "internal">;
|
|
1103
1349
|
keyInsert: FunctionReference<"mutation", "internal">;
|
|
1104
1350
|
keyGetByHashedKey: FunctionReference<"query", "internal">;
|
|
1105
1351
|
keyGetById: FunctionReference<"query", "internal">;
|
|
1106
1352
|
keyList: FunctionReference<"query", "internal">;
|
|
1107
|
-
keyListByUserId: FunctionReference<"query", "internal">;
|
|
1108
1353
|
keyPatch: FunctionReference<"mutation", "internal">;
|
|
1109
1354
|
keyDelete: FunctionReference<"mutation", "internal">;
|
|
1110
1355
|
passkeyInsert: FunctionReference<"mutation", "internal">;
|
|
@@ -1126,6 +1371,142 @@ export type AuthComponentApi = {
|
|
|
1126
1371
|
deviceAuthorize: FunctionReference<"mutation", "internal", any, any>;
|
|
1127
1372
|
deviceUpdateLastPolled: FunctionReference<"mutation", "internal", any, any>;
|
|
1128
1373
|
deviceDelete: FunctionReference<"mutation", "internal", any, any>;
|
|
1374
|
+
enterpriseCreate: FunctionReference<"mutation", "internal", any, any>;
|
|
1375
|
+
enterpriseGet: FunctionReference<"query", "internal", any, any>;
|
|
1376
|
+
enterpriseGetByGroup: FunctionReference<"query", "internal", any, any>;
|
|
1377
|
+
enterpriseGetByDomain: FunctionReference<"query", "internal", any, any>;
|
|
1378
|
+
enterpriseList: FunctionReference<"query", "internal", any, any>;
|
|
1379
|
+
enterpriseUpdate: FunctionReference<"mutation", "internal", any, any>;
|
|
1380
|
+
enterpriseDelete: FunctionReference<"mutation", "internal", any, any>;
|
|
1381
|
+
enterpriseDomainAdd: FunctionReference<"mutation", "internal", any, any>;
|
|
1382
|
+
enterpriseDomainList: FunctionReference<"query", "internal", any, any>;
|
|
1383
|
+
enterpriseDomainDelete: FunctionReference<"mutation", "internal", any, any>;
|
|
1384
|
+
enterpriseDomainVerificationGet: FunctionReference<
|
|
1385
|
+
"query",
|
|
1386
|
+
"internal",
|
|
1387
|
+
any,
|
|
1388
|
+
any
|
|
1389
|
+
>;
|
|
1390
|
+
enterpriseDomainVerificationUpsert: FunctionReference<
|
|
1391
|
+
"mutation",
|
|
1392
|
+
"internal",
|
|
1393
|
+
any,
|
|
1394
|
+
any
|
|
1395
|
+
>;
|
|
1396
|
+
enterpriseDomainVerificationDelete: FunctionReference<
|
|
1397
|
+
"mutation",
|
|
1398
|
+
"internal",
|
|
1399
|
+
any,
|
|
1400
|
+
any
|
|
1401
|
+
>;
|
|
1402
|
+
enterpriseDomainVerify: FunctionReference<"mutation", "internal", any, any>;
|
|
1403
|
+
enterpriseSecretUpsert: FunctionReference<"mutation", "internal", any, any>;
|
|
1404
|
+
enterpriseSecretGet: FunctionReference<"query", "internal", any, any>;
|
|
1405
|
+
enterpriseSecretDelete: FunctionReference<"mutation", "internal", any, any>;
|
|
1406
|
+
enterpriseScimConfigUpsert: FunctionReference<
|
|
1407
|
+
"mutation",
|
|
1408
|
+
"internal",
|
|
1409
|
+
any,
|
|
1410
|
+
any
|
|
1411
|
+
>;
|
|
1412
|
+
enterpriseScimConfigGetByEnterprise: FunctionReference<
|
|
1413
|
+
"query",
|
|
1414
|
+
"internal",
|
|
1415
|
+
any,
|
|
1416
|
+
any
|
|
1417
|
+
>;
|
|
1418
|
+
enterpriseScimConfigGetByTokenHash: FunctionReference<
|
|
1419
|
+
"query",
|
|
1420
|
+
"internal",
|
|
1421
|
+
any,
|
|
1422
|
+
any
|
|
1423
|
+
>;
|
|
1424
|
+
enterpriseScimIdentityGet: FunctionReference<"query", "internal", any, any>;
|
|
1425
|
+
enterpriseScimIdentityGetByUser: FunctionReference<
|
|
1426
|
+
"query",
|
|
1427
|
+
"internal",
|
|
1428
|
+
any,
|
|
1429
|
+
any
|
|
1430
|
+
>;
|
|
1431
|
+
enterpriseScimIdentityGetByEnterpriseAndUser: FunctionReference<
|
|
1432
|
+
"query",
|
|
1433
|
+
"internal",
|
|
1434
|
+
any,
|
|
1435
|
+
any
|
|
1436
|
+
>;
|
|
1437
|
+
enterpriseScimIdentityGetByMappedGroup: FunctionReference<
|
|
1438
|
+
"query",
|
|
1439
|
+
"internal",
|
|
1440
|
+
any,
|
|
1441
|
+
any
|
|
1442
|
+
>;
|
|
1443
|
+
enterpriseScimIdentityListByEnterprise: FunctionReference<
|
|
1444
|
+
"query",
|
|
1445
|
+
"internal",
|
|
1446
|
+
any,
|
|
1447
|
+
any
|
|
1448
|
+
>;
|
|
1449
|
+
enterpriseScimIdentityUpsert: FunctionReference<
|
|
1450
|
+
"mutation",
|
|
1451
|
+
"internal",
|
|
1452
|
+
any,
|
|
1453
|
+
any
|
|
1454
|
+
>;
|
|
1455
|
+
enterpriseScimIdentityDelete: FunctionReference<
|
|
1456
|
+
"mutation",
|
|
1457
|
+
"internal",
|
|
1458
|
+
any,
|
|
1459
|
+
any
|
|
1460
|
+
>;
|
|
1461
|
+
enterpriseAuditEventCreate: FunctionReference<
|
|
1462
|
+
"mutation",
|
|
1463
|
+
"internal",
|
|
1464
|
+
any,
|
|
1465
|
+
any
|
|
1466
|
+
>;
|
|
1467
|
+
enterpriseAuditEventList: FunctionReference<"query", "internal", any, any>;
|
|
1468
|
+
enterpriseWebhookEndpointCreate: FunctionReference<
|
|
1469
|
+
"mutation",
|
|
1470
|
+
"internal",
|
|
1471
|
+
any,
|
|
1472
|
+
any
|
|
1473
|
+
>;
|
|
1474
|
+
enterpriseWebhookEndpointList: FunctionReference<
|
|
1475
|
+
"query",
|
|
1476
|
+
"internal",
|
|
1477
|
+
any,
|
|
1478
|
+
any
|
|
1479
|
+
>;
|
|
1480
|
+
enterpriseWebhookEndpointGet: FunctionReference<
|
|
1481
|
+
"query",
|
|
1482
|
+
"internal",
|
|
1483
|
+
any,
|
|
1484
|
+
any
|
|
1485
|
+
>;
|
|
1486
|
+
enterpriseWebhookEndpointUpdate: FunctionReference<
|
|
1487
|
+
"mutation",
|
|
1488
|
+
"internal",
|
|
1489
|
+
any,
|
|
1490
|
+
any
|
|
1491
|
+
>;
|
|
1492
|
+
enterpriseWebhookDeliveryEnqueue: FunctionReference<
|
|
1493
|
+
"mutation",
|
|
1494
|
+
"internal",
|
|
1495
|
+
any,
|
|
1496
|
+
any
|
|
1497
|
+
>;
|
|
1498
|
+
enterpriseWebhookDeliveryListReady: FunctionReference<
|
|
1499
|
+
"query",
|
|
1500
|
+
"internal",
|
|
1501
|
+
any,
|
|
1502
|
+
any
|
|
1503
|
+
>;
|
|
1504
|
+
enterpriseWebhookDeliveryPatch: FunctionReference<
|
|
1505
|
+
"mutation",
|
|
1506
|
+
"internal",
|
|
1507
|
+
any,
|
|
1508
|
+
any
|
|
1509
|
+
>;
|
|
1129
1510
|
};
|
|
1130
1511
|
};
|
|
1131
1512
|
|
|
@@ -1177,3 +1558,387 @@ export type FunctionReferenceFromExport<Export> =
|
|
|
1177
1558
|
type ConvertReturnType<T> = UndefinedToNull<Awaited<T>>;
|
|
1178
1559
|
|
|
1179
1560
|
type UndefinedToNull<T> = T extends void ? null : T;
|
|
1561
|
+
|
|
1562
|
+
// Internal server data-model types (merged from former internalTypes.ts)
|
|
1563
|
+
|
|
1564
|
+
/** Data model derived from the component schema. */
|
|
1565
|
+
export type AuthDataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
1566
|
+
|
|
1567
|
+
/** Action context typed to the auth component's data model. */
|
|
1568
|
+
export type ActionCtx = GenericActionCtx<AuthDataModel>;
|
|
1569
|
+
|
|
1570
|
+
/** Mutation context typed to the auth component's data model. */
|
|
1571
|
+
export type MutationCtx = GenericMutationCtx<AuthDataModel>;
|
|
1572
|
+
|
|
1573
|
+
/** Query context typed to the auth component's data model. */
|
|
1574
|
+
export type QueryCtx = GenericQueryCtx<AuthDataModel>;
|
|
1575
|
+
|
|
1576
|
+
/** A document from any table in the auth component schema. */
|
|
1577
|
+
export type Doc<T extends TableNamesInDataModel<AuthDataModel>> = GenericDoc<
|
|
1578
|
+
AuthDataModel,
|
|
1579
|
+
T
|
|
1580
|
+
>;
|
|
1581
|
+
|
|
1582
|
+
/** A pair of JWT access token and refresh token. */
|
|
1583
|
+
export type Tokens = { token: string; refreshToken: string };
|
|
1584
|
+
|
|
1585
|
+
/** Session information returned after authentication. */
|
|
1586
|
+
export type SessionInfo = {
|
|
1587
|
+
userId: GenericId<"User">;
|
|
1588
|
+
sessionId: GenericId<"Session">;
|
|
1589
|
+
tokens: Tokens | null;
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
/** Session information with guaranteed non-null tokens. */
|
|
1593
|
+
export type SessionInfoWithTokens = {
|
|
1594
|
+
userId: GenericId<"User">;
|
|
1595
|
+
sessionId: GenericId<"Session">;
|
|
1596
|
+
tokens: Tokens;
|
|
1597
|
+
};
|
|
1598
|
+
|
|
1599
|
+
// ---------------------------------------------------------------------------
|
|
1600
|
+
// Cross-component document shapes
|
|
1601
|
+
// ---------------------------------------------------------------------------
|
|
1602
|
+
// These mirror the component schema tables. They exist so that server-side
|
|
1603
|
+
// code can work with typed results from cross-component queries/mutations
|
|
1604
|
+
// instead of casting to `any` at every field access.
|
|
1605
|
+
|
|
1606
|
+
export type TotpDoc = Infer<typeof vTotpFactorDoc>;
|
|
1607
|
+
|
|
1608
|
+
export type PasskeyDoc = Infer<typeof vPasskeyDoc>;
|
|
1609
|
+
|
|
1610
|
+
export type VerifierDoc = Infer<typeof vAuthVerifierDoc>;
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Cross-component user document shape inferred from the component validator.
|
|
1614
|
+
*
|
|
1615
|
+
* Used by internal typed wrappers (`queryUserById`, etc.) so server code stays
|
|
1616
|
+
* aligned with the component runtime contract. Not intended for consumer use —
|
|
1617
|
+
* consumers should use `UserDoc` (exported from
|
|
1618
|
+
* `@robelest/convex-auth/component`).
|
|
1619
|
+
*
|
|
1620
|
+
* @internal
|
|
1621
|
+
*/
|
|
1622
|
+
export type CrossComponentUserDoc = Infer<typeof vUserDoc>;
|
|
1623
|
+
|
|
1624
|
+
export type KeyDoc = Infer<typeof vApiKeyDoc>;
|
|
1625
|
+
|
|
1626
|
+
// ---------------------------------------------------------------------------
|
|
1627
|
+
// Cross-component wrapper context
|
|
1628
|
+
// ---------------------------------------------------------------------------
|
|
1629
|
+
// Structural type accepted by all wrappers below. Works for both action and
|
|
1630
|
+
// mutation contexts — the only capabilities we need are runQuery / runMutation
|
|
1631
|
+
// and access to the component API via `auth.config.component`.
|
|
1632
|
+
|
|
1633
|
+
/** @internal */
|
|
1634
|
+
export type ComponentCallCtx = {
|
|
1635
|
+
runQuery: GenericActionCtx<AuthDataModel>["runQuery"];
|
|
1636
|
+
runMutation: GenericActionCtx<AuthDataModel>["runMutation"];
|
|
1637
|
+
auth: { config: { component: AuthComponentApi } };
|
|
1638
|
+
};
|
|
1639
|
+
|
|
1640
|
+
// ---------------------------------------------------------------------------
|
|
1641
|
+
// Typed wrappers for cross-component calls
|
|
1642
|
+
// ---------------------------------------------------------------------------
|
|
1643
|
+
// Each wrapper encapsulates the single `as any` cast at the component
|
|
1644
|
+
// boundary so that callers get full type safety on both args and return
|
|
1645
|
+
// values.
|
|
1646
|
+
|
|
1647
|
+
// -- User queries --
|
|
1648
|
+
|
|
1649
|
+
export async function queryUserById(
|
|
1650
|
+
ctx: ComponentCallCtx,
|
|
1651
|
+
userId: string,
|
|
1652
|
+
): Promise<CrossComponentUserDoc | null> {
|
|
1653
|
+
return (await ctx.runQuery(ctx.auth.config.component.public.userGetById, {
|
|
1654
|
+
userId,
|
|
1655
|
+
})) as CrossComponentUserDoc | null;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
export async function queryUserByVerifiedEmail(
|
|
1659
|
+
ctx: ComponentCallCtx,
|
|
1660
|
+
email: string,
|
|
1661
|
+
): Promise<CrossComponentUserDoc | null> {
|
|
1662
|
+
return (await ctx.runQuery(
|
|
1663
|
+
ctx.auth.config.component.public.userFindByVerifiedEmail,
|
|
1664
|
+
{ email },
|
|
1665
|
+
)) as CrossComponentUserDoc | null;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
// -- Verifier queries / mutations --
|
|
1669
|
+
|
|
1670
|
+
export async function queryVerifierById(
|
|
1671
|
+
ctx: ComponentCallCtx,
|
|
1672
|
+
verifierId: string,
|
|
1673
|
+
): Promise<VerifierDoc | null> {
|
|
1674
|
+
return (await ctx.runQuery(ctx.auth.config.component.public.verifierGetById, {
|
|
1675
|
+
verifierId,
|
|
1676
|
+
})) as VerifierDoc | null;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
export async function mutateVerifierDelete(
|
|
1680
|
+
ctx: ComponentCallCtx,
|
|
1681
|
+
verifierId: string,
|
|
1682
|
+
): Promise<void> {
|
|
1683
|
+
await ctx.runMutation(ctx.auth.config.component.public.verifierDelete, {
|
|
1684
|
+
verifierId,
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// -- TOTP queries / mutations --
|
|
1689
|
+
|
|
1690
|
+
export async function queryTotpById(
|
|
1691
|
+
ctx: ComponentCallCtx,
|
|
1692
|
+
totpId: string,
|
|
1693
|
+
): Promise<TotpDoc | null> {
|
|
1694
|
+
return (await ctx.runQuery(ctx.auth.config.component.public.totpGetById, {
|
|
1695
|
+
totpId,
|
|
1696
|
+
})) as TotpDoc | null;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
export async function queryTotpVerifiedByUserId(
|
|
1700
|
+
ctx: ComponentCallCtx,
|
|
1701
|
+
userId: string,
|
|
1702
|
+
): Promise<TotpDoc | null> {
|
|
1703
|
+
return (await ctx.runQuery(
|
|
1704
|
+
ctx.auth.config.component.public.totpGetVerifiedByUserId,
|
|
1705
|
+
{ userId },
|
|
1706
|
+
)) as TotpDoc | null;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
export async function mutateTotpInsert(
|
|
1710
|
+
ctx: ComponentCallCtx,
|
|
1711
|
+
args: {
|
|
1712
|
+
userId: string;
|
|
1713
|
+
secret: ArrayBuffer;
|
|
1714
|
+
digits: number;
|
|
1715
|
+
period: number;
|
|
1716
|
+
verified: boolean;
|
|
1717
|
+
name?: string;
|
|
1718
|
+
createdAt: number;
|
|
1719
|
+
},
|
|
1720
|
+
): Promise<string> {
|
|
1721
|
+
return (await ctx.runMutation(
|
|
1722
|
+
ctx.auth.config.component.public.totpInsert,
|
|
1723
|
+
args,
|
|
1724
|
+
)) as string;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
export async function mutateTotpMarkVerified(
|
|
1728
|
+
ctx: ComponentCallCtx,
|
|
1729
|
+
totpId: string,
|
|
1730
|
+
lastUsedAt: number,
|
|
1731
|
+
): Promise<void> {
|
|
1732
|
+
await ctx.runMutation(ctx.auth.config.component.public.totpMarkVerified, {
|
|
1733
|
+
totpId,
|
|
1734
|
+
lastUsedAt,
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
export async function mutateTotpUpdateLastUsed(
|
|
1739
|
+
ctx: ComponentCallCtx,
|
|
1740
|
+
totpId: string,
|
|
1741
|
+
lastUsedAt: number,
|
|
1742
|
+
): Promise<void> {
|
|
1743
|
+
await ctx.runMutation(ctx.auth.config.component.public.totpUpdateLastUsed, {
|
|
1744
|
+
totpId,
|
|
1745
|
+
lastUsedAt,
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
// -- Passkey queries / mutations --
|
|
1750
|
+
|
|
1751
|
+
export async function queryPasskeysByUserId(
|
|
1752
|
+
ctx: ComponentCallCtx,
|
|
1753
|
+
userId: string,
|
|
1754
|
+
): Promise<PasskeyDoc[]> {
|
|
1755
|
+
return (await ctx.runQuery(
|
|
1756
|
+
ctx.auth.config.component.public.passkeyListByUserId,
|
|
1757
|
+
{ userId },
|
|
1758
|
+
)) as PasskeyDoc[];
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
export async function queryPasskeyByCredentialId(
|
|
1762
|
+
ctx: ComponentCallCtx,
|
|
1763
|
+
credentialId: string,
|
|
1764
|
+
): Promise<PasskeyDoc | null> {
|
|
1765
|
+
return (await ctx.runQuery(
|
|
1766
|
+
ctx.auth.config.component.public.passkeyGetByCredentialId,
|
|
1767
|
+
{ credentialId },
|
|
1768
|
+
)) as PasskeyDoc | null;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
export async function mutatePasskeyInsert(
|
|
1772
|
+
ctx: ComponentCallCtx,
|
|
1773
|
+
args: {
|
|
1774
|
+
userId: string;
|
|
1775
|
+
credentialId: string;
|
|
1776
|
+
publicKey: ArrayBuffer | ArrayBufferLike;
|
|
1777
|
+
algorithm: number;
|
|
1778
|
+
counter: number;
|
|
1779
|
+
transports?: string[];
|
|
1780
|
+
deviceType: string;
|
|
1781
|
+
backedUp: boolean;
|
|
1782
|
+
name?: string;
|
|
1783
|
+
createdAt: number;
|
|
1784
|
+
},
|
|
1785
|
+
): Promise<string> {
|
|
1786
|
+
return (await ctx.runMutation(
|
|
1787
|
+
ctx.auth.config.component.public.passkeyInsert,
|
|
1788
|
+
args,
|
|
1789
|
+
)) as string;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
export async function mutatePasskeyUpdateCounter(
|
|
1793
|
+
ctx: ComponentCallCtx,
|
|
1794
|
+
passkeyId: string,
|
|
1795
|
+
counter: number,
|
|
1796
|
+
lastUsedAt: number,
|
|
1797
|
+
): Promise<void> {
|
|
1798
|
+
await ctx.runMutation(ctx.auth.config.component.public.passkeyUpdateCounter, {
|
|
1799
|
+
passkeyId,
|
|
1800
|
+
counter,
|
|
1801
|
+
lastUsedAt,
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// -- Key queries / mutations --
|
|
1806
|
+
|
|
1807
|
+
export async function mutateKeyInsert(
|
|
1808
|
+
ctx: ComponentCallCtx,
|
|
1809
|
+
args: {
|
|
1810
|
+
userId: string;
|
|
1811
|
+
prefix: string;
|
|
1812
|
+
hashedKey: string;
|
|
1813
|
+
name: string;
|
|
1814
|
+
scopes: Array<{ resource: string; actions: string[] }>;
|
|
1815
|
+
rateLimit?: { maxRequests: number; windowMs: number };
|
|
1816
|
+
expiresAt?: number;
|
|
1817
|
+
},
|
|
1818
|
+
): Promise<string> {
|
|
1819
|
+
return (await ctx.runMutation(
|
|
1820
|
+
ctx.auth.config.component.public.keyInsert,
|
|
1821
|
+
args,
|
|
1822
|
+
)) as string;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
export async function queryKeysByUserId(
|
|
1826
|
+
ctx: ComponentCallCtx,
|
|
1827
|
+
userId: string,
|
|
1828
|
+
): Promise<KeyDoc[]> {
|
|
1829
|
+
const items: KeyDoc[] = [];
|
|
1830
|
+
let cursor: string | null = null;
|
|
1831
|
+
do {
|
|
1832
|
+
const page = (await ctx.runQuery(ctx.auth.config.component.public.keyList, {
|
|
1833
|
+
where: { userId },
|
|
1834
|
+
limit: 100,
|
|
1835
|
+
cursor,
|
|
1836
|
+
})) as {
|
|
1837
|
+
items: KeyDoc[];
|
|
1838
|
+
nextCursor: string | null;
|
|
1839
|
+
};
|
|
1840
|
+
items.push(...page.items);
|
|
1841
|
+
cursor = page.nextCursor;
|
|
1842
|
+
} while (cursor !== null);
|
|
1843
|
+
return items;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
export async function queryKeyById(
|
|
1847
|
+
ctx: ComponentCallCtx,
|
|
1848
|
+
keyId: string,
|
|
1849
|
+
): Promise<KeyDoc | null> {
|
|
1850
|
+
return (await ctx.runQuery(ctx.auth.config.component.public.keyGetById, {
|
|
1851
|
+
keyId,
|
|
1852
|
+
})) as KeyDoc | null;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
export async function mutateKeyPatch(
|
|
1856
|
+
ctx: ComponentCallCtx,
|
|
1857
|
+
keyId: string,
|
|
1858
|
+
data: Record<string, unknown>,
|
|
1859
|
+
): Promise<void> {
|
|
1860
|
+
await ctx.runMutation(ctx.auth.config.component.public.keyPatch, {
|
|
1861
|
+
keyId,
|
|
1862
|
+
data,
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
export async function mutateKeyDelete(
|
|
1867
|
+
ctx: ComponentCallCtx,
|
|
1868
|
+
keyId: string,
|
|
1869
|
+
): Promise<void> {
|
|
1870
|
+
await ctx.runMutation(ctx.auth.config.component.public.keyDelete, { keyId });
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// -- Device authorization queries / mutations --
|
|
1874
|
+
|
|
1875
|
+
export type DeviceDoc = Infer<typeof vDeviceCodeDoc>;
|
|
1876
|
+
|
|
1877
|
+
export async function mutateDeviceInsert(
|
|
1878
|
+
ctx: ComponentCallCtx,
|
|
1879
|
+
args: {
|
|
1880
|
+
deviceCodeHash: string;
|
|
1881
|
+
userCode: string;
|
|
1882
|
+
expiresAt: number;
|
|
1883
|
+
interval: number;
|
|
1884
|
+
status: "pending" | "authorized" | "denied";
|
|
1885
|
+
},
|
|
1886
|
+
): Promise<string> {
|
|
1887
|
+
return (await ctx.runMutation(
|
|
1888
|
+
ctx.auth.config.component.public.deviceInsert,
|
|
1889
|
+
args,
|
|
1890
|
+
)) as string;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
export async function queryDeviceByCodeHash(
|
|
1894
|
+
ctx: ComponentCallCtx,
|
|
1895
|
+
deviceCodeHash: string,
|
|
1896
|
+
): Promise<DeviceDoc | null> {
|
|
1897
|
+
return (await ctx.runQuery(
|
|
1898
|
+
ctx.auth.config.component.public.deviceGetByCodeHash,
|
|
1899
|
+
{ deviceCodeHash },
|
|
1900
|
+
)) as DeviceDoc | null;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
export async function queryDeviceByUserCode(
|
|
1904
|
+
ctx: ComponentCallCtx,
|
|
1905
|
+
userCode: string,
|
|
1906
|
+
): Promise<DeviceDoc | null> {
|
|
1907
|
+
return (await ctx.runQuery(
|
|
1908
|
+
ctx.auth.config.component.public.deviceGetByUserCode,
|
|
1909
|
+
{ userCode },
|
|
1910
|
+
)) as DeviceDoc | null;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
export async function mutateDeviceAuthorize(
|
|
1914
|
+
ctx: ComponentCallCtx,
|
|
1915
|
+
deviceId: string,
|
|
1916
|
+
userId: string,
|
|
1917
|
+
sessionId: string,
|
|
1918
|
+
): Promise<void> {
|
|
1919
|
+
await ctx.runMutation(ctx.auth.config.component.public.deviceAuthorize, {
|
|
1920
|
+
deviceId,
|
|
1921
|
+
userId,
|
|
1922
|
+
sessionId,
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
export async function mutateDeviceUpdateLastPolled(
|
|
1927
|
+
ctx: ComponentCallCtx,
|
|
1928
|
+
deviceId: string,
|
|
1929
|
+
lastPolledAt: number,
|
|
1930
|
+
): Promise<void> {
|
|
1931
|
+
await ctx.runMutation(
|
|
1932
|
+
ctx.auth.config.component.public.deviceUpdateLastPolled,
|
|
1933
|
+
{ deviceId, lastPolledAt },
|
|
1934
|
+
);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
export async function mutateDeviceDelete(
|
|
1938
|
+
ctx: ComponentCallCtx,
|
|
1939
|
+
deviceId: string,
|
|
1940
|
+
): Promise<void> {
|
|
1941
|
+
await ctx.runMutation(ctx.auth.config.component.public.deviceDelete, {
|
|
1942
|
+
deviceId,
|
|
1943
|
+
});
|
|
1944
|
+
}
|