@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/dist/component/public.js
CHANGED
|
@@ -1,1230 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { accountDelete, accountGet, accountGetById, accountInsert, accountListByUser, accountPatch } from "./public/identity/accounts.js";
|
|
2
|
+
import { deviceAuthorize, deviceDelete, deviceGetByCodeHash, deviceGetByUserCode, deviceInsert, deviceUpdateLastPolled } from "./public/factors/devices.js";
|
|
3
|
+
import { enterpriseAuditEventCreate, enterpriseAuditEventList } from "./public/enterprise/audit.js";
|
|
4
|
+
import { enterpriseCreate, enterpriseDelete, enterpriseGet, enterpriseGetByDomain, enterpriseGetByGroup, enterpriseList, enterpriseUpdate } from "./public/enterprise/core.js";
|
|
5
|
+
import { enterpriseDomainAdd, enterpriseDomainDelete, enterpriseDomainList, enterpriseDomainVerificationDelete, enterpriseDomainVerificationGet, enterpriseDomainVerificationUpsert, enterpriseDomainVerify } from "./public/enterprise/domains.js";
|
|
6
|
+
import { enterpriseScimConfigGetByEnterprise, enterpriseScimConfigGetByTokenHash, enterpriseScimConfigUpsert, enterpriseScimIdentityDelete, enterpriseScimIdentityGet, enterpriseScimIdentityGetByEnterpriseAndUser, enterpriseScimIdentityGetByMappedGroup, enterpriseScimIdentityGetByUser, enterpriseScimIdentityListByEnterprise, enterpriseScimIdentityUpsert } from "./public/enterprise/scim.js";
|
|
7
|
+
import { enterpriseSecretDelete, enterpriseSecretGet, enterpriseSecretUpsert } from "./public/enterprise/secrets.js";
|
|
8
|
+
import { enterpriseWebhookDeliveryEnqueue, enterpriseWebhookDeliveryList, enterpriseWebhookDeliveryListReady, enterpriseWebhookDeliveryPatch, enterpriseWebhookEndpointCreate, enterpriseWebhookEndpointGet, enterpriseWebhookEndpointList, enterpriseWebhookEndpointUpdate } from "./public/enterprise/webhooks.js";
|
|
9
|
+
import { groupCreate, groupDelete, groupGet, groupList, groupUpdate } from "./public/groups/core.js";
|
|
10
|
+
import { inviteAccept, inviteAcceptByToken, inviteCreate, inviteGet, inviteGetByTokenHash, inviteList, inviteRevoke } from "./public/groups/invites.js";
|
|
11
|
+
import { memberAdd, memberGet, memberGetByGroupAndUser, memberList, memberRemove, memberResolve, memberUpdate } from "./public/groups/members.js";
|
|
12
|
+
import { keyDelete, keyGetByHashedKey, keyGetById, keyInsert, keyList, keyPatch } from "./public/security/keys.js";
|
|
13
|
+
import { passkeyDelete, passkeyGetByCredentialId, passkeyInsert, passkeyListByUserId, passkeyUpdateCounter, passkeyUpdateMeta } from "./public/factors/passkeys.js";
|
|
14
|
+
import { rateLimitCreate, rateLimitDelete, rateLimitGet, rateLimitPatch } from "./public/security/limits.js";
|
|
15
|
+
import { refreshTokenCreate, refreshTokenDeleteAll, refreshTokenGetActive, refreshTokenGetById, refreshTokenGetChildren, refreshTokenListBySession, refreshTokenPatch } from "./public/identity/tokens.js";
|
|
16
|
+
import { sessionCreate, sessionDelete, sessionGetById, sessionList, sessionListByUser } from "./public/identity/sessions.js";
|
|
17
|
+
import { totpDelete, totpGetById, totpGetVerifiedByUserId, totpInsert, totpListByUserId, totpMarkVerified, totpUpdateLastUsed } from "./public/factors/totp.js";
|
|
18
|
+
import { userDelete, userFindByVerifiedEmail, userFindByVerifiedPhone, userGetById, userInsert, userList, userPatch, userUpsert } from "./public/identity/users.js";
|
|
19
|
+
import { verificationCodeCreate, verificationCodeDelete, verificationCodeGetByAccountId, verificationCodeGetByCode } from "./public/identity/codes.js";
|
|
20
|
+
import { verifierCreate, verifierDelete, verifierGetById, verifierGetBySignature, verifierPatch } from "./public/identity/verifiers.js";
|
|
3
21
|
|
|
4
|
-
|
|
5
|
-
/** Validator for a single `{ key, value }` tag pair. */
|
|
6
|
-
const vTag = v.object({
|
|
7
|
-
key: v.string(),
|
|
8
|
-
value: v.string()
|
|
9
|
-
});
|
|
10
|
-
/** Normalize a single tag: trim + lowercase key and value. */
|
|
11
|
-
function normalizeTag(tag) {
|
|
12
|
-
return {
|
|
13
|
-
key: tag.key.trim().toLowerCase(),
|
|
14
|
-
value: tag.value.trim().toLowerCase()
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Normalize and deduplicate an array of tags.
|
|
19
|
-
* Deduplication is based on the normalized `key\0value` composite.
|
|
20
|
-
*/
|
|
21
|
-
function normalizeTags(tags) {
|
|
22
|
-
const seen = /* @__PURE__ */ new Set();
|
|
23
|
-
const result = [];
|
|
24
|
-
for (const raw of tags) {
|
|
25
|
-
const t = normalizeTag(raw);
|
|
26
|
-
const composite = `${t.key}\0${t.value}`;
|
|
27
|
-
if (!seen.has(composite)) {
|
|
28
|
-
seen.add(composite);
|
|
29
|
-
result.push(t);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* List users with optional filtering, sorting, and pagination.
|
|
36
|
-
*
|
|
37
|
-
* Returns `{ items, nextCursor }` — pass `nextCursor` back as `cursor`
|
|
38
|
-
* for the next page, or `null` when exhausted.
|
|
39
|
-
*/
|
|
40
|
-
const userList = query({
|
|
41
|
-
args: {
|
|
42
|
-
where: v.optional(v.object({
|
|
43
|
-
email: v.optional(v.string()),
|
|
44
|
-
phone: v.optional(v.string()),
|
|
45
|
-
isAnonymous: v.optional(v.boolean()),
|
|
46
|
-
name: v.optional(v.string())
|
|
47
|
-
})),
|
|
48
|
-
limit: v.optional(v.number()),
|
|
49
|
-
cursor: v.optional(v.union(v.string(), v.null())),
|
|
50
|
-
orderBy: v.optional(v.union(v.literal("_creationTime"), v.literal("name"), v.literal("email"), v.literal("phone"))),
|
|
51
|
-
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
52
|
-
},
|
|
53
|
-
handler: async (ctx, args) => {
|
|
54
|
-
const where = args.where ?? {};
|
|
55
|
-
const limit = Math.min(Math.max(args.limit ?? 50, 1), 100);
|
|
56
|
-
const order = args.order ?? "desc";
|
|
57
|
-
let q;
|
|
58
|
-
if (where.email !== void 0) q = ctx.db.query("user").withIndex("email", (idx) => idx.eq("email", where.email));
|
|
59
|
-
else if (where.phone !== void 0) q = ctx.db.query("user").withIndex("phone", (idx) => idx.eq("phone", where.phone));
|
|
60
|
-
else q = ctx.db.query("user");
|
|
61
|
-
if (where.isAnonymous !== void 0) q = q.filter((f) => f.eq(f.field("isAnonymous"), where.isAnonymous));
|
|
62
|
-
if (where.name !== void 0) q = q.filter((f) => f.eq(f.field("name"), where.name));
|
|
63
|
-
if (where.email !== void 0 && where.phone !== void 0) q = q.filter((f) => f.eq(f.field("phone"), where.phone));
|
|
64
|
-
q = q.order(order);
|
|
65
|
-
const all = await q.collect();
|
|
66
|
-
let startIdx = 0;
|
|
67
|
-
if (args.cursor) {
|
|
68
|
-
const cursorIdx = all.findIndex((doc) => doc._id === args.cursor);
|
|
69
|
-
if (cursorIdx !== -1) startIdx = cursorIdx + 1;
|
|
70
|
-
}
|
|
71
|
-
const page = all.slice(startIdx, startIdx + limit + 1);
|
|
72
|
-
const hasMore = page.length > limit;
|
|
73
|
-
const items = hasMore ? page.slice(0, limit) : page;
|
|
74
|
-
return {
|
|
75
|
-
items,
|
|
76
|
-
nextCursor: hasMore ? items[items.length - 1]._id : null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
/** Retrieve a user by their document ID. */
|
|
81
|
-
const userGetById = query({
|
|
82
|
-
args: { userId: v.id("user") },
|
|
83
|
-
handler: async (ctx, { userId }) => {
|
|
84
|
-
return await ctx.db.get(userId);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
/**
|
|
88
|
-
* Find a user by their verified email address. Returns `null` if no user
|
|
89
|
-
* has this email verified, or if multiple users share the same verified email
|
|
90
|
-
* (ambiguous — should not happen in normal operation).
|
|
91
|
-
*/
|
|
92
|
-
const userFindByVerifiedEmail = query({
|
|
93
|
-
args: { email: v.string() },
|
|
94
|
-
handler: async (ctx, { email }) => {
|
|
95
|
-
const users = await ctx.db.query("user").withIndex("email", (q) => q.eq("email", email)).filter((q) => q.neq(q.field("emailVerificationTime"), void 0)).take(2);
|
|
96
|
-
return users.length === 1 ? users[0] : null;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* Find a user by their verified phone number. Returns `null` if no user
|
|
101
|
-
* has this phone verified, or if multiple users share the same verified phone
|
|
102
|
-
* (ambiguous — should not happen in normal operation).
|
|
103
|
-
*/
|
|
104
|
-
const userFindByVerifiedPhone = query({
|
|
105
|
-
args: { phone: v.string() },
|
|
106
|
-
handler: async (ctx, { phone }) => {
|
|
107
|
-
const users = await ctx.db.query("user").withIndex("phone", (q) => q.eq("phone", phone)).filter((q) => q.neq(q.field("phoneVerificationTime"), void 0)).take(2);
|
|
108
|
-
return users.length === 1 ? users[0] : null;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
/** Insert a new user document. */
|
|
112
|
-
const userInsert = mutation({
|
|
113
|
-
args: { data: v.any() },
|
|
114
|
-
handler: async (ctx, { data }) => {
|
|
115
|
-
return await ctx.db.insert("user", data);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
/** Insert a new user or update an existing one. */
|
|
119
|
-
const userUpsert = mutation({
|
|
120
|
-
args: {
|
|
121
|
-
userId: v.optional(v.id("user")),
|
|
122
|
-
data: v.any()
|
|
123
|
-
},
|
|
124
|
-
handler: async (ctx, { userId, data }) => {
|
|
125
|
-
if (userId !== void 0) {
|
|
126
|
-
await ctx.db.patch(userId, data);
|
|
127
|
-
return userId;
|
|
128
|
-
}
|
|
129
|
-
return await ctx.db.insert("user", data);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
/** Patch an existing user document with partial data. */
|
|
133
|
-
const userPatch = mutation({
|
|
134
|
-
args: {
|
|
135
|
-
userId: v.id("user"),
|
|
136
|
-
data: v.any()
|
|
137
|
-
},
|
|
138
|
-
handler: async (ctx, { userId, data }) => {
|
|
139
|
-
await ctx.db.patch(userId, data);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
/** List all accounts for a user. */
|
|
143
|
-
const accountListByUser = query({
|
|
144
|
-
args: { userId: v.id("user") },
|
|
145
|
-
handler: async (ctx, { userId }) => {
|
|
146
|
-
return await ctx.db.query("account").withIndex("userIdAndProvider", (q) => q.eq("userId", userId)).collect();
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
/** Look up an account by provider and provider-specific account ID. */
|
|
150
|
-
const accountGet = query({
|
|
151
|
-
args: {
|
|
152
|
-
provider: v.string(),
|
|
153
|
-
providerAccountId: v.string()
|
|
154
|
-
},
|
|
155
|
-
handler: async (ctx, { provider, providerAccountId }) => {
|
|
156
|
-
return await ctx.db.query("account").withIndex("providerAndAccountId", (q) => q.eq("provider", provider).eq("providerAccountId", providerAccountId)).unique();
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
/** Retrieve an account by its document ID. */
|
|
160
|
-
const accountGetById = query({
|
|
161
|
-
args: { accountId: v.id("account") },
|
|
162
|
-
handler: async (ctx, { accountId }) => {
|
|
163
|
-
return await ctx.db.get(accountId);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
/** Create a new account linking a user to an auth provider. */
|
|
167
|
-
const accountInsert = mutation({
|
|
168
|
-
args: {
|
|
169
|
-
userId: v.id("user"),
|
|
170
|
-
provider: v.string(),
|
|
171
|
-
providerAccountId: v.string(),
|
|
172
|
-
secret: v.optional(v.string())
|
|
173
|
-
},
|
|
174
|
-
handler: async (ctx, args) => {
|
|
175
|
-
return await ctx.db.insert("account", args);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
/** Patch an existing account document with partial data. */
|
|
179
|
-
const accountPatch = mutation({
|
|
180
|
-
args: {
|
|
181
|
-
accountId: v.id("account"),
|
|
182
|
-
data: v.any()
|
|
183
|
-
},
|
|
184
|
-
handler: async (ctx, { accountId, data }) => {
|
|
185
|
-
await ctx.db.patch(accountId, data);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
/** Delete an account document. */
|
|
189
|
-
const accountDelete = mutation({
|
|
190
|
-
args: { accountId: v.id("account") },
|
|
191
|
-
handler: async (ctx, { accountId }) => {
|
|
192
|
-
await ctx.db.delete(accountId);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
/**
|
|
196
|
-
* List sessions with optional filtering and pagination.
|
|
197
|
-
*
|
|
198
|
-
* Returns `{ items, nextCursor }`.
|
|
199
|
-
*/
|
|
200
|
-
const sessionList = query({
|
|
201
|
-
args: {
|
|
202
|
-
where: v.optional(v.object({ userId: v.optional(v.id("user")) })),
|
|
203
|
-
limit: v.optional(v.number()),
|
|
204
|
-
cursor: v.optional(v.union(v.string(), v.null())),
|
|
205
|
-
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
206
|
-
},
|
|
207
|
-
handler: async (ctx, args) => {
|
|
208
|
-
const where = args.where ?? {};
|
|
209
|
-
const limit = Math.min(Math.max(args.limit ?? 50, 1), 100);
|
|
210
|
-
const order = args.order ?? "desc";
|
|
211
|
-
let q;
|
|
212
|
-
if (where.userId !== void 0) q = ctx.db.query("session").withIndex("userId", (idx) => idx.eq("userId", where.userId));
|
|
213
|
-
else q = ctx.db.query("session");
|
|
214
|
-
q = q.order(order);
|
|
215
|
-
const all = await q.collect();
|
|
216
|
-
let startIdx = 0;
|
|
217
|
-
if (args.cursor) {
|
|
218
|
-
const cursorIdx = all.findIndex((doc) => doc._id === args.cursor);
|
|
219
|
-
if (cursorIdx !== -1) startIdx = cursorIdx + 1;
|
|
220
|
-
}
|
|
221
|
-
const page = all.slice(startIdx, startIdx + limit + 1);
|
|
222
|
-
const hasMore = page.length > limit;
|
|
223
|
-
const items = hasMore ? page.slice(0, limit) : page;
|
|
224
|
-
return {
|
|
225
|
-
items,
|
|
226
|
-
nextCursor: hasMore ? items[items.length - 1]._id : null
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
/** Create a new session for a user with an expiration time. */
|
|
231
|
-
const sessionCreate = mutation({
|
|
232
|
-
args: {
|
|
233
|
-
userId: v.id("user"),
|
|
234
|
-
expirationTime: v.number()
|
|
235
|
-
},
|
|
236
|
-
handler: async (ctx, { userId, expirationTime }) => {
|
|
237
|
-
return await ctx.db.insert("session", {
|
|
238
|
-
userId,
|
|
239
|
-
expirationTime
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
/** Retrieve a session by its document ID. */
|
|
244
|
-
const sessionGetById = query({
|
|
245
|
-
args: { sessionId: v.id("session") },
|
|
246
|
-
handler: async (ctx, { sessionId }) => {
|
|
247
|
-
return await ctx.db.get(sessionId);
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
/** Delete a session. No-op if the session does not exist. */
|
|
251
|
-
const sessionDelete = mutation({
|
|
252
|
-
args: { sessionId: v.id("session") },
|
|
253
|
-
handler: async (ctx, { sessionId }) => {
|
|
254
|
-
if (await ctx.db.get(sessionId) !== null) await ctx.db.delete(sessionId);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
/** List all sessions for a user. */
|
|
258
|
-
const sessionListByUser = query({
|
|
259
|
-
args: { userId: v.id("user") },
|
|
260
|
-
handler: async (ctx, { userId }) => {
|
|
261
|
-
return await ctx.db.query("session").withIndex("userId", (q) => q.eq("userId", userId)).collect();
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
/** Create a new PKCE verifier, optionally linked to a session. */
|
|
265
|
-
const verifierCreate = mutation({
|
|
266
|
-
args: { sessionId: v.optional(v.id("session")) },
|
|
267
|
-
handler: async (ctx, { sessionId }) => {
|
|
268
|
-
return await ctx.db.insert("verifier", { sessionId });
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
/** Retrieve a verifier by its document ID. */
|
|
272
|
-
const verifierGetById = query({
|
|
273
|
-
args: { verifierId: v.id("verifier") },
|
|
274
|
-
handler: async (ctx, { verifierId }) => {
|
|
275
|
-
return await ctx.db.get(verifierId);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
/** Look up a verifier by its cryptographic signature. */
|
|
279
|
-
const verifierGetBySignature = query({
|
|
280
|
-
args: { signature: v.string() },
|
|
281
|
-
handler: async (ctx, { signature }) => {
|
|
282
|
-
return await ctx.db.query("verifier").withIndex("signature", (q) => q.eq("signature", signature)).unique();
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
/** Patch a verifier document with partial data. */
|
|
286
|
-
const verifierPatch = mutation({
|
|
287
|
-
args: {
|
|
288
|
-
verifierId: v.id("verifier"),
|
|
289
|
-
data: v.any()
|
|
290
|
-
},
|
|
291
|
-
handler: async (ctx, { verifierId, data }) => {
|
|
292
|
-
await ctx.db.patch(verifierId, data);
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
/** Delete a verifier document. */
|
|
296
|
-
const verifierDelete = mutation({
|
|
297
|
-
args: { verifierId: v.id("verifier") },
|
|
298
|
-
handler: async (ctx, { verifierId }) => {
|
|
299
|
-
await ctx.db.delete(verifierId);
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
/** Find a verification code by its associated account ID. */
|
|
303
|
-
const verificationCodeGetByAccountId = query({
|
|
304
|
-
args: { accountId: v.id("account") },
|
|
305
|
-
handler: async (ctx, { accountId }) => {
|
|
306
|
-
return await ctx.db.query("verification").withIndex("accountId", (q) => q.eq("accountId", accountId)).unique();
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
/** Find a verification code by its code string. */
|
|
310
|
-
const verificationCodeGetByCode = query({
|
|
311
|
-
args: { code: v.string() },
|
|
312
|
-
handler: async (ctx, { code }) => {
|
|
313
|
-
return await ctx.db.query("verification").withIndex("code", (q) => q.eq("code", code)).unique();
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
/** Create a new verification code for OTP, magic link, or OAuth flows. */
|
|
317
|
-
const verificationCodeCreate = mutation({
|
|
318
|
-
args: {
|
|
319
|
-
accountId: v.id("account"),
|
|
320
|
-
provider: v.string(),
|
|
321
|
-
code: v.string(),
|
|
322
|
-
expirationTime: v.number(),
|
|
323
|
-
verifier: v.optional(v.string()),
|
|
324
|
-
emailVerified: v.optional(v.string()),
|
|
325
|
-
phoneVerified: v.optional(v.string())
|
|
326
|
-
},
|
|
327
|
-
handler: async (ctx, args) => {
|
|
328
|
-
return await ctx.db.insert("verification", args);
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
/** Delete a verification code document. */
|
|
332
|
-
const verificationCodeDelete = mutation({
|
|
333
|
-
args: { verificationCodeId: v.id("verification") },
|
|
334
|
-
handler: async (ctx, { verificationCodeId }) => {
|
|
335
|
-
await ctx.db.delete(verificationCodeId);
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
/** Create a new refresh token for a session. */
|
|
339
|
-
const refreshTokenCreate = mutation({
|
|
340
|
-
args: {
|
|
341
|
-
sessionId: v.id("session"),
|
|
342
|
-
expirationTime: v.number(),
|
|
343
|
-
parentRefreshTokenId: v.optional(v.id("token"))
|
|
344
|
-
},
|
|
345
|
-
handler: async (ctx, args) => {
|
|
346
|
-
return await ctx.db.insert("token", args);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
/** Retrieve a refresh token by its document ID. */
|
|
350
|
-
const refreshTokenGetById = query({
|
|
351
|
-
args: { refreshTokenId: v.id("token") },
|
|
352
|
-
handler: async (ctx, { refreshTokenId }) => {
|
|
353
|
-
return await ctx.db.get(refreshTokenId);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
/** Patch a refresh token document with partial data. */
|
|
357
|
-
const refreshTokenPatch = mutation({
|
|
358
|
-
args: {
|
|
359
|
-
refreshTokenId: v.id("token"),
|
|
360
|
-
data: v.any()
|
|
361
|
-
},
|
|
362
|
-
handler: async (ctx, { refreshTokenId, data }) => {
|
|
363
|
-
await ctx.db.patch(refreshTokenId, data);
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
/** Get child tokens that were created by exchanging a specific parent token. */
|
|
367
|
-
const refreshTokenGetChildren = query({
|
|
368
|
-
args: {
|
|
369
|
-
sessionId: v.id("session"),
|
|
370
|
-
parentRefreshTokenId: v.id("token")
|
|
371
|
-
},
|
|
372
|
-
handler: async (ctx, { sessionId, parentRefreshTokenId }) => {
|
|
373
|
-
return await ctx.db.query("token").withIndex("sessionIdAndParentRefreshTokenId", (q) => q.eq("sessionId", sessionId).eq("parentRefreshTokenId", parentRefreshTokenId)).collect();
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
/** List all refresh tokens for a session. */
|
|
377
|
-
const refreshTokenListBySession = query({
|
|
378
|
-
args: { sessionId: v.id("session") },
|
|
379
|
-
handler: async (ctx, { sessionId }) => {
|
|
380
|
-
return await ctx.db.query("token").withIndex("sessionIdAndParentRefreshTokenId", (q) => q.eq("sessionId", sessionId)).collect();
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
/** Delete all refresh tokens for a session. */
|
|
384
|
-
const refreshTokenDeleteAll = mutation({
|
|
385
|
-
args: { sessionId: v.id("session") },
|
|
386
|
-
handler: async (ctx, { sessionId }) => {
|
|
387
|
-
const tokens = await ctx.db.query("token").withIndex("sessionIdAndParentRefreshTokenId", (q) => q.eq("sessionId", sessionId)).collect();
|
|
388
|
-
await Promise.all(tokens.map((token) => ctx.db.delete(token._id)));
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
/** Get the active (unused) refresh token for a session. */
|
|
392
|
-
const refreshTokenGetActive = query({
|
|
393
|
-
args: { sessionId: v.id("session") },
|
|
394
|
-
handler: async (ctx, { sessionId }) => {
|
|
395
|
-
return await ctx.db.query("token").withIndex("sessionId", (q) => q.eq("sessionId", sessionId)).filter((q) => q.eq(q.field("firstUsedTime"), void 0)).order("desc").first();
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
/** Store a new passkey credential for a user. */
|
|
399
|
-
const passkeyInsert = mutation({
|
|
400
|
-
args: {
|
|
401
|
-
userId: v.id("user"),
|
|
402
|
-
credentialId: v.string(),
|
|
403
|
-
publicKey: v.bytes(),
|
|
404
|
-
algorithm: v.number(),
|
|
405
|
-
counter: v.number(),
|
|
406
|
-
transports: v.optional(v.array(v.string())),
|
|
407
|
-
deviceType: v.string(),
|
|
408
|
-
backedUp: v.boolean(),
|
|
409
|
-
name: v.optional(v.string()),
|
|
410
|
-
createdAt: v.number()
|
|
411
|
-
},
|
|
412
|
-
handler: async (ctx, args) => {
|
|
413
|
-
return await ctx.db.insert("passkey", args);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
/** Look up a passkey by its credential ID. */
|
|
417
|
-
const passkeyGetByCredentialId = query({
|
|
418
|
-
args: { credentialId: v.string() },
|
|
419
|
-
handler: async (ctx, { credentialId }) => {
|
|
420
|
-
return await ctx.db.query("passkey").withIndex("credentialId", (q) => q.eq("credentialId", credentialId)).unique();
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
/** List all passkeys for a user. */
|
|
424
|
-
const passkeyListByUserId = query({
|
|
425
|
-
args: { userId: v.id("user") },
|
|
426
|
-
handler: async (ctx, { userId }) => {
|
|
427
|
-
return await ctx.db.query("passkey").withIndex("userId", (q) => q.eq("userId", userId)).collect();
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
/** Update a passkey's counter and last used timestamp after authentication. */
|
|
431
|
-
const passkeyUpdateCounter = mutation({
|
|
432
|
-
args: {
|
|
433
|
-
passkeyId: v.id("passkey"),
|
|
434
|
-
counter: v.number(),
|
|
435
|
-
lastUsedAt: v.number()
|
|
436
|
-
},
|
|
437
|
-
handler: async (ctx, { passkeyId, counter, lastUsedAt }) => {
|
|
438
|
-
await ctx.db.patch(passkeyId, {
|
|
439
|
-
counter,
|
|
440
|
-
lastUsedAt
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
/** Update a passkey's metadata (name). */
|
|
445
|
-
const passkeyUpdateMeta = mutation({
|
|
446
|
-
args: {
|
|
447
|
-
passkeyId: v.id("passkey"),
|
|
448
|
-
data: v.any()
|
|
449
|
-
},
|
|
450
|
-
handler: async (ctx, { passkeyId, data }) => {
|
|
451
|
-
await ctx.db.patch(passkeyId, data);
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
/** Delete a passkey credential. */
|
|
455
|
-
const passkeyDelete = mutation({
|
|
456
|
-
args: { passkeyId: v.id("passkey") },
|
|
457
|
-
handler: async (ctx, { passkeyId }) => {
|
|
458
|
-
await ctx.db.delete(passkeyId);
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
/** Store a new TOTP enrollment for a user. */
|
|
462
|
-
const totpInsert = mutation({
|
|
463
|
-
args: {
|
|
464
|
-
userId: v.id("user"),
|
|
465
|
-
secret: v.bytes(),
|
|
466
|
-
digits: v.number(),
|
|
467
|
-
period: v.number(),
|
|
468
|
-
verified: v.boolean(),
|
|
469
|
-
name: v.optional(v.string()),
|
|
470
|
-
createdAt: v.number()
|
|
471
|
-
},
|
|
472
|
-
handler: async (ctx, args) => {
|
|
473
|
-
return await ctx.db.insert("totp", args);
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
/** Get a verified TOTP enrollment for a user (returns first match). */
|
|
477
|
-
const totpGetVerifiedByUserId = query({
|
|
478
|
-
args: { userId: v.id("user") },
|
|
479
|
-
handler: async (ctx, { userId }) => {
|
|
480
|
-
return await ctx.db.query("totp").withIndex("userId", (q) => q.eq("userId", userId)).filter((q) => q.eq(q.field("verified"), true)).first();
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
/** List all TOTP enrollments for a user. */
|
|
484
|
-
const totpListByUserId = query({
|
|
485
|
-
args: { userId: v.id("user") },
|
|
486
|
-
handler: async (ctx, { userId }) => {
|
|
487
|
-
return await ctx.db.query("totp").withIndex("userId", (q) => q.eq("userId", userId)).collect();
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
/** Get a TOTP enrollment by its ID. */
|
|
491
|
-
const totpGetById = query({
|
|
492
|
-
args: { totpId: v.id("totp") },
|
|
493
|
-
handler: async (ctx, { totpId }) => {
|
|
494
|
-
return await ctx.db.get(totpId);
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
/** Mark a TOTP enrollment as verified (setup complete). */
|
|
498
|
-
const totpMarkVerified = mutation({
|
|
499
|
-
args: {
|
|
500
|
-
totpId: v.id("totp"),
|
|
501
|
-
lastUsedAt: v.number()
|
|
502
|
-
},
|
|
503
|
-
handler: async (ctx, { totpId, lastUsedAt }) => {
|
|
504
|
-
await ctx.db.patch(totpId, {
|
|
505
|
-
verified: true,
|
|
506
|
-
lastUsedAt
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
/** Update a TOTP enrollment's last used timestamp. */
|
|
511
|
-
const totpUpdateLastUsed = mutation({
|
|
512
|
-
args: {
|
|
513
|
-
totpId: v.id("totp"),
|
|
514
|
-
lastUsedAt: v.number()
|
|
515
|
-
},
|
|
516
|
-
handler: async (ctx, { totpId, lastUsedAt }) => {
|
|
517
|
-
await ctx.db.patch(totpId, { lastUsedAt });
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
/** Delete a TOTP enrollment. */
|
|
521
|
-
const totpDelete = mutation({
|
|
522
|
-
args: { totpId: v.id("totp") },
|
|
523
|
-
handler: async (ctx, { totpId }) => {
|
|
524
|
-
await ctx.db.delete(totpId);
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
/** Look up a rate limit entry by its identifier. */
|
|
528
|
-
const rateLimitGet = query({
|
|
529
|
-
args: { identifier: v.string() },
|
|
530
|
-
handler: async (ctx, { identifier }) => {
|
|
531
|
-
return await ctx.db.query("limit").withIndex("identifier", (q) => q.eq("identifier", identifier)).unique();
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
/** Create a new rate limit entry. */
|
|
535
|
-
const rateLimitCreate = mutation({
|
|
536
|
-
args: {
|
|
537
|
-
identifier: v.string(),
|
|
538
|
-
attemptsLeft: v.number(),
|
|
539
|
-
lastAttemptTime: v.number()
|
|
540
|
-
},
|
|
541
|
-
handler: async (ctx, args) => {
|
|
542
|
-
return await ctx.db.insert("limit", args);
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
/** Patch a rate limit entry with partial data. */
|
|
546
|
-
const rateLimitPatch = mutation({
|
|
547
|
-
args: {
|
|
548
|
-
rateLimitId: v.id("limit"),
|
|
549
|
-
data: v.any()
|
|
550
|
-
},
|
|
551
|
-
handler: async (ctx, { rateLimitId, data }) => {
|
|
552
|
-
await ctx.db.patch(rateLimitId, data);
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
/** Delete a rate limit entry. */
|
|
556
|
-
const rateLimitDelete = mutation({
|
|
557
|
-
args: { rateLimitId: v.id("limit") },
|
|
558
|
-
handler: async (ctx, { rateLimitId }) => {
|
|
559
|
-
await ctx.db.delete(rateLimitId);
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
/**
|
|
563
|
-
* Create a new group. Groups are hierarchical — set `parentGroupId` to nest
|
|
564
|
-
* under an existing group, or omit it to create a root-level group.
|
|
565
|
-
*
|
|
566
|
-
* @returns The ID of the newly created group.
|
|
567
|
-
*/
|
|
568
|
-
const groupCreate = mutation({
|
|
569
|
-
args: {
|
|
570
|
-
name: v.string(),
|
|
571
|
-
slug: v.optional(v.string()),
|
|
572
|
-
type: v.optional(v.string()),
|
|
573
|
-
parentGroupId: v.optional(v.id("group")),
|
|
574
|
-
tags: v.optional(v.array(vTag)),
|
|
575
|
-
extend: v.optional(v.any())
|
|
576
|
-
},
|
|
577
|
-
handler: async (ctx, args) => {
|
|
578
|
-
const { tags: rawTags, ...rest } = args;
|
|
579
|
-
const normalizedTags = rawTags ? normalizeTags(rawTags) : void 0;
|
|
580
|
-
const groupId = await ctx.db.insert("group", {
|
|
581
|
-
...rest,
|
|
582
|
-
tags: normalizedTags
|
|
583
|
-
});
|
|
584
|
-
if (normalizedTags) for (const tag of normalizedTags) await ctx.db.insert("groupTag", {
|
|
585
|
-
groupId,
|
|
586
|
-
key: tag.key,
|
|
587
|
-
value: tag.value
|
|
588
|
-
});
|
|
589
|
-
return groupId;
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
/** Retrieve a group by its document ID. Returns `null` if not found. */
|
|
593
|
-
const groupGet = query({
|
|
594
|
-
args: { groupId: v.id("group") },
|
|
595
|
-
handler: async (ctx, { groupId }) => {
|
|
596
|
-
return await ctx.db.get(groupId);
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
/**
|
|
600
|
-
* List groups with optional filtering, sorting, and pagination.
|
|
601
|
-
*
|
|
602
|
-
* Returns `{ items, nextCursor }`. Empty `where` returns **all** groups.
|
|
603
|
-
*/
|
|
604
|
-
const groupList = query({
|
|
605
|
-
args: {
|
|
606
|
-
where: v.optional(v.object({
|
|
607
|
-
slug: v.optional(v.string()),
|
|
608
|
-
type: v.optional(v.string()),
|
|
609
|
-
parentGroupId: v.optional(v.id("group")),
|
|
610
|
-
name: v.optional(v.string()),
|
|
611
|
-
isRoot: v.optional(v.boolean()),
|
|
612
|
-
tagsAll: v.optional(v.array(vTag)),
|
|
613
|
-
tagsAny: v.optional(v.array(vTag))
|
|
614
|
-
})),
|
|
615
|
-
limit: v.optional(v.number()),
|
|
616
|
-
cursor: v.optional(v.union(v.string(), v.null())),
|
|
617
|
-
orderBy: v.optional(v.union(v.literal("_creationTime"), v.literal("name"), v.literal("slug"), v.literal("type"))),
|
|
618
|
-
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
619
|
-
},
|
|
620
|
-
handler: async (ctx, args) => {
|
|
621
|
-
const where = args.where ?? {};
|
|
622
|
-
const limit = Math.min(Math.max(args.limit ?? 50, 1), 100);
|
|
623
|
-
const order = args.order ?? "desc";
|
|
624
|
-
let tagFilteredIds = null;
|
|
625
|
-
if (where.tagsAll && where.tagsAll.length > 0) {
|
|
626
|
-
let allSet = null;
|
|
627
|
-
for (const rawTag of where.tagsAll) {
|
|
628
|
-
const t = normalizeTag(rawTag);
|
|
629
|
-
const rows = await ctx.db.query("groupTag").withIndex("by_key_value", (idx) => idx.eq("key", t.key).eq("value", t.value)).collect();
|
|
630
|
-
const ids = new Set(rows.map((r) => r.groupId));
|
|
631
|
-
if (allSet === null) allSet = ids;
|
|
632
|
-
else for (const id of allSet) if (!ids.has(id)) allSet.delete(id);
|
|
633
|
-
if (allSet.size === 0) break;
|
|
634
|
-
}
|
|
635
|
-
tagFilteredIds = allSet ?? /* @__PURE__ */ new Set();
|
|
636
|
-
}
|
|
637
|
-
if (where.tagsAny && where.tagsAny.length > 0) {
|
|
638
|
-
const anySet = /* @__PURE__ */ new Set();
|
|
639
|
-
for (const rawTag of where.tagsAny) {
|
|
640
|
-
const t = normalizeTag(rawTag);
|
|
641
|
-
const rows = await ctx.db.query("groupTag").withIndex("by_key_value", (idx) => idx.eq("key", t.key).eq("value", t.value)).collect();
|
|
642
|
-
for (const r of rows) anySet.add(r.groupId);
|
|
643
|
-
}
|
|
644
|
-
if (tagFilteredIds !== null) {
|
|
645
|
-
for (const id of tagFilteredIds) if (!anySet.has(id)) tagFilteredIds.delete(id);
|
|
646
|
-
} else tagFilteredIds = anySet;
|
|
647
|
-
}
|
|
648
|
-
let q;
|
|
649
|
-
if (where.type !== void 0 && where.parentGroupId !== void 0) q = ctx.db.query("group").withIndex("typeAndParentGroupId", (idx) => idx.eq("type", where.type).eq("parentGroupId", where.parentGroupId));
|
|
650
|
-
else if (where.slug !== void 0) q = ctx.db.query("group").withIndex("slug", (idx) => idx.eq("slug", where.slug));
|
|
651
|
-
else if (where.type !== void 0) q = ctx.db.query("group").withIndex("type", (idx) => idx.eq("type", where.type));
|
|
652
|
-
else if (where.parentGroupId !== void 0) q = ctx.db.query("group").withIndex("parentGroupId", (idx) => idx.eq("parentGroupId", where.parentGroupId));
|
|
653
|
-
else q = ctx.db.query("group");
|
|
654
|
-
if (where.name !== void 0) q = q.filter((f) => f.eq(f.field("name"), where.name));
|
|
655
|
-
if (where.isRoot === true) q = q.filter((f) => f.eq(f.field("parentGroupId"), void 0));
|
|
656
|
-
else if (where.isRoot === false) q = q.filter((f) => f.neq(f.field("parentGroupId"), void 0));
|
|
657
|
-
if (where.slug !== void 0 && where.type !== void 0) q = q.filter((f) => f.eq(f.field("slug"), where.slug));
|
|
658
|
-
q = q.order(order);
|
|
659
|
-
let all = await q.collect();
|
|
660
|
-
if (tagFilteredIds !== null) all = all.filter((doc) => tagFilteredIds.has(doc._id));
|
|
661
|
-
let startIdx = 0;
|
|
662
|
-
if (args.cursor) {
|
|
663
|
-
const cursorIdx = all.findIndex((doc) => doc._id === args.cursor);
|
|
664
|
-
if (cursorIdx !== -1) startIdx = cursorIdx + 1;
|
|
665
|
-
}
|
|
666
|
-
const page = all.slice(startIdx, startIdx + limit + 1);
|
|
667
|
-
const hasMore = page.length > limit;
|
|
668
|
-
const items = hasMore ? page.slice(0, limit) : page;
|
|
669
|
-
return {
|
|
670
|
-
items,
|
|
671
|
-
nextCursor: hasMore ? items[items.length - 1]._id : null
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
/** Update a group's fields (name, slug, tags, extend, parentGroupId). */
|
|
676
|
-
const groupUpdate = mutation({
|
|
677
|
-
args: {
|
|
678
|
-
groupId: v.id("group"),
|
|
679
|
-
data: v.any()
|
|
680
|
-
},
|
|
681
|
-
handler: async (ctx, { groupId, data }) => {
|
|
682
|
-
if (data.tags !== void 0) {
|
|
683
|
-
const normalizedTags = Array.isArray(data.tags) ? normalizeTags(data.tags) : [];
|
|
684
|
-
const existingTags = await ctx.db.query("groupTag").withIndex("by_group", (idx) => idx.eq("groupId", groupId)).collect();
|
|
685
|
-
for (const existing of existingTags) await ctx.db.delete(existing._id);
|
|
686
|
-
for (const tag of normalizedTags) await ctx.db.insert("groupTag", {
|
|
687
|
-
groupId,
|
|
688
|
-
key: tag.key,
|
|
689
|
-
value: tag.value
|
|
690
|
-
});
|
|
691
|
-
await ctx.db.patch(groupId, {
|
|
692
|
-
...data,
|
|
693
|
-
tags: normalizedTags.length > 0 ? normalizedTags : void 0
|
|
694
|
-
});
|
|
695
|
-
} else await ctx.db.patch(groupId, data);
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
/**
|
|
699
|
-
* Delete a group and all of its descendants. This cascades to:
|
|
700
|
-
* - All child groups (recursively)
|
|
701
|
-
* - All members of this group and its descendants
|
|
702
|
-
* - All invites for this group and its descendants
|
|
703
|
-
*/
|
|
704
|
-
const groupDelete = mutation({
|
|
705
|
-
args: { groupId: v.id("group") },
|
|
706
|
-
handler: async (ctx, { groupId }) => {
|
|
707
|
-
const deleteGroup = async (id) => {
|
|
708
|
-
const children = await ctx.db.query("group").withIndex("parentGroupId", (q) => q.eq("parentGroupId", id)).collect();
|
|
709
|
-
for (const child of children) await deleteGroup(child._id);
|
|
710
|
-
const members = await ctx.db.query("member").withIndex("groupId", (q) => q.eq("groupId", id)).collect();
|
|
711
|
-
for (const member of members) await ctx.db.delete(member._id);
|
|
712
|
-
const invites = await ctx.db.query("invite").withIndex("groupId", (q) => q.eq("groupId", id)).collect();
|
|
713
|
-
for (const invite of invites) await ctx.db.delete(invite._id);
|
|
714
|
-
const tags = await ctx.db.query("groupTag").withIndex("by_group", (q) => q.eq("groupId", id)).collect();
|
|
715
|
-
for (const tag of tags) await ctx.db.delete(tag._id);
|
|
716
|
-
await ctx.db.delete(id);
|
|
717
|
-
};
|
|
718
|
-
await deleteGroup(groupId);
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
/**
|
|
722
|
-
* Add a user as a member of a group.
|
|
723
|
-
*
|
|
724
|
-
* The `role` field is an application-defined string (e.g. "owner", "admin",
|
|
725
|
-
* "member", "viewer"). The auth component stores it but does not enforce
|
|
726
|
-
* access control — your application defines what each role means.
|
|
727
|
-
*
|
|
728
|
-
* Throws `ConvexError` with code `DUPLICATE_MEMBERSHIP` when the user is
|
|
729
|
-
* already a member of the target group.
|
|
730
|
-
*
|
|
731
|
-
* @returns The ID of the new member record.
|
|
732
|
-
*/
|
|
733
|
-
const memberAdd = mutation({
|
|
734
|
-
args: {
|
|
735
|
-
groupId: v.id("group"),
|
|
736
|
-
userId: v.id("user"),
|
|
737
|
-
role: v.optional(v.string()),
|
|
738
|
-
status: v.optional(v.string()),
|
|
739
|
-
extend: v.optional(v.any())
|
|
740
|
-
},
|
|
741
|
-
handler: async (ctx, args) => {
|
|
742
|
-
const existingMembership = await ctx.db.query("member").withIndex("groupIdAndUserId", (q) => q.eq("groupId", args.groupId).eq("userId", args.userId)).unique();
|
|
743
|
-
if (existingMembership !== null) throw new ConvexError({
|
|
744
|
-
code: "DUPLICATE_MEMBERSHIP",
|
|
745
|
-
message: "User is already a member of this group",
|
|
746
|
-
groupId: args.groupId,
|
|
747
|
-
userId: args.userId,
|
|
748
|
-
existingMemberId: existingMembership._id
|
|
749
|
-
});
|
|
750
|
-
return await ctx.db.insert("member", args);
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
/** Retrieve a member record by its document ID. Returns `null` if not found. */
|
|
754
|
-
const memberGet = query({
|
|
755
|
-
args: { memberId: v.id("member") },
|
|
756
|
-
handler: async (ctx, { memberId }) => {
|
|
757
|
-
return await ctx.db.get(memberId);
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
/**
|
|
761
|
-
* List members with optional filtering, sorting, and pagination.
|
|
762
|
-
*
|
|
763
|
-
* Returns `{ items, nextCursor }`. Supports filtering by `groupId`,
|
|
764
|
-
* `userId`, `role`, and `status`.
|
|
765
|
-
*/
|
|
766
|
-
const memberList = query({
|
|
767
|
-
args: {
|
|
768
|
-
where: v.optional(v.object({
|
|
769
|
-
groupId: v.optional(v.id("group")),
|
|
770
|
-
userId: v.optional(v.id("user")),
|
|
771
|
-
role: v.optional(v.string()),
|
|
772
|
-
status: v.optional(v.string())
|
|
773
|
-
})),
|
|
774
|
-
limit: v.optional(v.number()),
|
|
775
|
-
cursor: v.optional(v.union(v.string(), v.null())),
|
|
776
|
-
orderBy: v.optional(v.union(v.literal("_creationTime"), v.literal("role"), v.literal("status"))),
|
|
777
|
-
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
778
|
-
},
|
|
779
|
-
handler: async (ctx, args) => {
|
|
780
|
-
const where = args.where ?? {};
|
|
781
|
-
const limit = Math.min(Math.max(args.limit ?? 50, 1), 100);
|
|
782
|
-
const order = args.order ?? "desc";
|
|
783
|
-
let q;
|
|
784
|
-
if (where.groupId !== void 0 && where.userId !== void 0) q = ctx.db.query("member").withIndex("groupIdAndUserId", (idx) => idx.eq("groupId", where.groupId).eq("userId", where.userId));
|
|
785
|
-
else if (where.groupId !== void 0) q = ctx.db.query("member").withIndex("groupId", (idx) => idx.eq("groupId", where.groupId));
|
|
786
|
-
else if (where.userId !== void 0) q = ctx.db.query("member").withIndex("userId", (idx) => idx.eq("userId", where.userId));
|
|
787
|
-
else q = ctx.db.query("member");
|
|
788
|
-
if (where.role !== void 0) q = q.filter((f) => f.eq(f.field("role"), where.role));
|
|
789
|
-
if (where.status !== void 0) q = q.filter((f) => f.eq(f.field("status"), where.status));
|
|
790
|
-
q = q.order(order);
|
|
791
|
-
const all = await q.collect();
|
|
792
|
-
let startIdx = 0;
|
|
793
|
-
if (args.cursor) {
|
|
794
|
-
const cursorIdx = all.findIndex((doc) => doc._id === args.cursor);
|
|
795
|
-
if (cursorIdx !== -1) startIdx = cursorIdx + 1;
|
|
796
|
-
}
|
|
797
|
-
const page = all.slice(startIdx, startIdx + limit + 1);
|
|
798
|
-
const hasMore = page.length > limit;
|
|
799
|
-
const items = hasMore ? page.slice(0, limit) : page;
|
|
800
|
-
return {
|
|
801
|
-
items,
|
|
802
|
-
nextCursor: hasMore ? items[items.length - 1]._id : null
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
});
|
|
806
|
-
/**
|
|
807
|
-
* @deprecated Use `memberList` with `where: { userId }` instead.
|
|
808
|
-
* Kept for backward compatibility with generated component types.
|
|
809
|
-
*/
|
|
810
|
-
const memberListByUser = query({
|
|
811
|
-
args: { userId: v.id("user") },
|
|
812
|
-
handler: async (ctx, { userId }) => {
|
|
813
|
-
return await ctx.db.query("member").withIndex("userId", (q) => q.eq("userId", userId)).collect();
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
/**
|
|
817
|
-
* Look up a specific user's membership in a specific group.
|
|
818
|
-
* Returns `null` if the user is not a member of the group.
|
|
819
|
-
*/
|
|
820
|
-
const memberGetByGroupAndUser = query({
|
|
821
|
-
args: {
|
|
822
|
-
groupId: v.id("group"),
|
|
823
|
-
userId: v.id("user")
|
|
824
|
-
},
|
|
825
|
-
handler: async (ctx, { groupId, userId }) => {
|
|
826
|
-
return await ctx.db.query("member").withIndex("groupIdAndUserId", (q) => q.eq("groupId", groupId).eq("userId", userId)).unique();
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
/** Remove a member from a group by deleting the member record. */
|
|
830
|
-
const memberRemove = mutation({
|
|
831
|
-
args: { memberId: v.id("member") },
|
|
832
|
-
handler: async (ctx, { memberId }) => {
|
|
833
|
-
await ctx.db.delete(memberId);
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
/**
|
|
837
|
-
* Update a member record's fields (role, status, extend).
|
|
838
|
-
*
|
|
839
|
-
* Common usage: `memberUpdate({ memberId, data: { role: "admin" } })`
|
|
840
|
-
*/
|
|
841
|
-
const memberUpdate = mutation({
|
|
842
|
-
args: {
|
|
843
|
-
memberId: v.id("member"),
|
|
844
|
-
data: v.any()
|
|
845
|
-
},
|
|
846
|
-
handler: async (ctx, { memberId, data }) => {
|
|
847
|
-
await ctx.db.patch(memberId, data);
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
/**
|
|
851
|
-
* Create a new platform-level invitation. Optionally set `groupId` to tie
|
|
852
|
-
* the invite to a specific group. The invitation is sent to an email address
|
|
853
|
-
* and includes a hashed token for secure acceptance.
|
|
854
|
-
*
|
|
855
|
-
* Throws `ConvexError` with code `DUPLICATE_INVITE` when a pending invite
|
|
856
|
-
* already exists for the same email and scope:
|
|
857
|
-
* - group invite: same `email` + same `groupId`
|
|
858
|
-
* - platform invite: same `email` with no `groupId`
|
|
859
|
-
*
|
|
860
|
-
* @returns The ID of the new invite record.
|
|
861
|
-
*/
|
|
862
|
-
const inviteCreate = mutation({
|
|
863
|
-
args: {
|
|
864
|
-
groupId: v.optional(v.id("group")),
|
|
865
|
-
invitedByUserId: v.optional(v.id("user")),
|
|
866
|
-
email: v.optional(v.string()),
|
|
867
|
-
tokenHash: v.string(),
|
|
868
|
-
role: v.optional(v.string()),
|
|
869
|
-
status: v.union(v.literal("pending"), v.literal("accepted"), v.literal("revoked"), v.literal("expired")),
|
|
870
|
-
expiresTime: v.optional(v.number()),
|
|
871
|
-
extend: v.optional(v.any())
|
|
872
|
-
},
|
|
873
|
-
handler: async (ctx, args) => {
|
|
874
|
-
if (args.email !== void 0) if (args.groupId !== void 0) {
|
|
875
|
-
const existingGroupInvite = await ctx.db.query("invite").withIndex("groupIdAndStatus", (q) => q.eq("groupId", args.groupId).eq("status", "pending")).filter((q) => q.eq(q.field("email"), args.email)).first();
|
|
876
|
-
if (existingGroupInvite !== null) throw new ConvexError({
|
|
877
|
-
code: "DUPLICATE_INVITE",
|
|
878
|
-
message: "A pending invite already exists for this email in this group",
|
|
879
|
-
email: args.email,
|
|
880
|
-
groupId: args.groupId,
|
|
881
|
-
existingInviteId: existingGroupInvite._id
|
|
882
|
-
});
|
|
883
|
-
} else {
|
|
884
|
-
const existingPlatformInvite = await ctx.db.query("invite").withIndex("emailAndStatus", (q) => q.eq("email", args.email).eq("status", "pending")).filter((q) => q.eq(q.field("groupId"), void 0)).first();
|
|
885
|
-
if (existingPlatformInvite !== null) throw new ConvexError({
|
|
886
|
-
code: "DUPLICATE_INVITE",
|
|
887
|
-
message: "A pending platform invite already exists for this email",
|
|
888
|
-
email: args.email,
|
|
889
|
-
existingInviteId: existingPlatformInvite._id
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
return await ctx.db.insert("invite", args);
|
|
893
|
-
}
|
|
894
|
-
});
|
|
895
|
-
/** Retrieve an invite by its document ID. Returns `null` if not found. */
|
|
896
|
-
const inviteGet = query({
|
|
897
|
-
args: { inviteId: v.id("invite") },
|
|
898
|
-
handler: async (ctx, { inviteId }) => {
|
|
899
|
-
return await ctx.db.get(inviteId);
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
/**
|
|
903
|
-
* List invites with optional filtering, sorting, and pagination.
|
|
904
|
-
*
|
|
905
|
-
* Returns `{ items, nextCursor }`. Supports filtering by `groupId`,
|
|
906
|
-
* `status`, `email`, `invitedByUserId`, `role`, `acceptedByUserId`, and `tokenHash`.
|
|
907
|
-
*/
|
|
908
|
-
const inviteList = query({
|
|
909
|
-
args: {
|
|
910
|
-
where: v.optional(v.object({
|
|
911
|
-
tokenHash: v.optional(v.string()),
|
|
912
|
-
groupId: v.optional(v.id("group")),
|
|
913
|
-
status: v.optional(v.union(v.literal("pending"), v.literal("accepted"), v.literal("revoked"), v.literal("expired"))),
|
|
914
|
-
email: v.optional(v.string()),
|
|
915
|
-
invitedByUserId: v.optional(v.id("user")),
|
|
916
|
-
role: v.optional(v.string()),
|
|
917
|
-
acceptedByUserId: v.optional(v.id("user"))
|
|
918
|
-
})),
|
|
919
|
-
limit: v.optional(v.number()),
|
|
920
|
-
cursor: v.optional(v.union(v.string(), v.null())),
|
|
921
|
-
orderBy: v.optional(v.union(v.literal("_creationTime"), v.literal("status"), v.literal("email"), v.literal("expiresTime"), v.literal("acceptedTime"))),
|
|
922
|
-
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
923
|
-
},
|
|
924
|
-
handler: async (ctx, args) => {
|
|
925
|
-
const where = args.where ?? {};
|
|
926
|
-
const limit = Math.min(Math.max(args.limit ?? 50, 1), 100);
|
|
927
|
-
const order = args.order ?? "desc";
|
|
928
|
-
let q;
|
|
929
|
-
if (where.tokenHash !== void 0) q = ctx.db.query("invite").withIndex("tokenHash", (idx) => idx.eq("tokenHash", where.tokenHash));
|
|
930
|
-
else if (where.role !== void 0 && where.status !== void 0 && where.acceptedByUserId !== void 0) q = ctx.db.query("invite").withIndex("roleAndStatusAndAcceptedByUserId", (idx) => idx.eq("role", where.role).eq("status", where.status).eq("acceptedByUserId", where.acceptedByUserId));
|
|
931
|
-
else if (where.groupId !== void 0 && where.status !== void 0) q = ctx.db.query("invite").withIndex("groupIdAndStatus", (idx) => idx.eq("groupId", where.groupId).eq("status", where.status));
|
|
932
|
-
else if (where.email !== void 0 && where.status !== void 0) q = ctx.db.query("invite").withIndex("emailAndStatus", (idx) => idx.eq("email", where.email).eq("status", where.status));
|
|
933
|
-
else if (where.invitedByUserId !== void 0 && where.status !== void 0) q = ctx.db.query("invite").withIndex("invitedByUserIdAndStatus", (idx) => idx.eq("invitedByUserId", where.invitedByUserId).eq("status", where.status));
|
|
934
|
-
else if (where.groupId !== void 0) q = ctx.db.query("invite").withIndex("groupId", (idx) => idx.eq("groupId", where.groupId));
|
|
935
|
-
else if (where.status !== void 0) q = ctx.db.query("invite").withIndex("status", (idx) => idx.eq("status", where.status));
|
|
936
|
-
else q = ctx.db.query("invite");
|
|
937
|
-
if (where.groupId !== void 0) q = q.filter((f) => f.eq(f.field("groupId"), where.groupId));
|
|
938
|
-
if (where.status !== void 0) q = q.filter((f) => f.eq(f.field("status"), where.status));
|
|
939
|
-
if (where.email !== void 0) q = q.filter((f) => f.eq(f.field("email"), where.email));
|
|
940
|
-
if (where.invitedByUserId !== void 0) q = q.filter((f) => f.eq(f.field("invitedByUserId"), where.invitedByUserId));
|
|
941
|
-
if (where.role !== void 0) q = q.filter((f) => f.eq(f.field("role"), where.role));
|
|
942
|
-
if (where.acceptedByUserId !== void 0) q = q.filter((f) => f.eq(f.field("acceptedByUserId"), where.acceptedByUserId));
|
|
943
|
-
if (where.tokenHash !== void 0) q = q.filter((f) => f.eq(f.field("tokenHash"), where.tokenHash));
|
|
944
|
-
q = q.order(order);
|
|
945
|
-
const all = await q.collect();
|
|
946
|
-
let startIdx = 0;
|
|
947
|
-
if (args.cursor) {
|
|
948
|
-
const cursorIdx = all.findIndex((doc) => doc._id === args.cursor);
|
|
949
|
-
if (cursorIdx !== -1) startIdx = cursorIdx + 1;
|
|
950
|
-
}
|
|
951
|
-
const page = all.slice(startIdx, startIdx + limit + 1);
|
|
952
|
-
const hasMore = page.length > limit;
|
|
953
|
-
const items = hasMore ? page.slice(0, limit) : page;
|
|
954
|
-
return {
|
|
955
|
-
items,
|
|
956
|
-
nextCursor: hasMore ? items[items.length - 1]._id : null
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
/**
|
|
961
|
-
* Accept a pending invitation.
|
|
962
|
-
*
|
|
963
|
-
* Marks the invite as "accepted" and records the acceptance timestamp.
|
|
964
|
-
* Throws a structured `ConvexError` when the invite doesn't exist or is not
|
|
965
|
-
* currently pending.
|
|
966
|
-
*
|
|
967
|
-
* The caller is responsible for creating the corresponding member record.
|
|
968
|
-
*/
|
|
969
|
-
const inviteAccept = mutation({
|
|
970
|
-
args: {
|
|
971
|
-
inviteId: v.id("invite"),
|
|
972
|
-
acceptedByUserId: v.optional(v.id("user"))
|
|
973
|
-
},
|
|
974
|
-
handler: async (ctx, { inviteId, acceptedByUserId }) => {
|
|
975
|
-
const invite = await ctx.db.get(inviteId);
|
|
976
|
-
if (invite === null) throw new ConvexError({
|
|
977
|
-
code: "INVITE_NOT_FOUND",
|
|
978
|
-
message: "Invite not found",
|
|
979
|
-
inviteId
|
|
980
|
-
});
|
|
981
|
-
if (invite.status !== "pending") throw new ConvexError({
|
|
982
|
-
code: "INVITE_NOT_PENDING",
|
|
983
|
-
message: `Cannot accept invite with status "${invite.status}"`,
|
|
984
|
-
inviteId,
|
|
985
|
-
currentStatus: invite.status
|
|
986
|
-
});
|
|
987
|
-
await ctx.db.patch(inviteId, {
|
|
988
|
-
status: "accepted",
|
|
989
|
-
acceptedTime: Date.now(),
|
|
990
|
-
...acceptedByUserId ? { acceptedByUserId } : {}
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
/**
|
|
995
|
-
* Revoke a pending invitation.
|
|
996
|
-
*
|
|
997
|
-
* Marks the invite as "revoked". Throws a structured `ConvexError` when the
|
|
998
|
-
* invite doesn't exist or is not currently pending.
|
|
999
|
-
*/
|
|
1000
|
-
const inviteRevoke = mutation({
|
|
1001
|
-
args: { inviteId: v.id("invite") },
|
|
1002
|
-
handler: async (ctx, { inviteId }) => {
|
|
1003
|
-
const invite = await ctx.db.get(inviteId);
|
|
1004
|
-
if (invite === null) throw new ConvexError({
|
|
1005
|
-
code: "INVITE_NOT_FOUND",
|
|
1006
|
-
message: "Invite not found",
|
|
1007
|
-
inviteId
|
|
1008
|
-
});
|
|
1009
|
-
if (invite.status !== "pending") throw new ConvexError({
|
|
1010
|
-
code: "INVITE_NOT_PENDING",
|
|
1011
|
-
message: `Cannot revoke invite with status "${invite.status}"`,
|
|
1012
|
-
inviteId,
|
|
1013
|
-
currentStatus: invite.status
|
|
1014
|
-
});
|
|
1015
|
-
await ctx.db.patch(inviteId, { status: "revoked" });
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
/**
|
|
1019
|
-
* Insert a new API key record.
|
|
1020
|
-
*
|
|
1021
|
-
* The caller is responsible for hashing the raw key before passing it here —
|
|
1022
|
-
* this function only stores the hash and metadata.
|
|
1023
|
-
*/
|
|
1024
|
-
const keyInsert = mutation({
|
|
1025
|
-
args: {
|
|
1026
|
-
userId: v.id("user"),
|
|
1027
|
-
prefix: v.string(),
|
|
1028
|
-
hashedKey: v.string(),
|
|
1029
|
-
name: v.string(),
|
|
1030
|
-
scopes: v.array(v.object({
|
|
1031
|
-
resource: v.string(),
|
|
1032
|
-
actions: v.array(v.string())
|
|
1033
|
-
})),
|
|
1034
|
-
rateLimit: v.optional(v.object({
|
|
1035
|
-
maxRequests: v.number(),
|
|
1036
|
-
windowMs: v.number()
|
|
1037
|
-
})),
|
|
1038
|
-
expiresAt: v.optional(v.number())
|
|
1039
|
-
},
|
|
1040
|
-
handler: async (ctx, args) => {
|
|
1041
|
-
return await ctx.db.insert("key", {
|
|
1042
|
-
...args,
|
|
1043
|
-
createdAt: Date.now(),
|
|
1044
|
-
revoked: false
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
/**
|
|
1049
|
-
* Look up an API key by its SHA-256 hash.
|
|
1050
|
-
*
|
|
1051
|
-
* Used during Bearer token verification. Returns the full key record
|
|
1052
|
-
* (including rate limit state) or `null` if not found.
|
|
1053
|
-
*/
|
|
1054
|
-
const keyGetByHashedKey = query({
|
|
1055
|
-
args: { hashedKey: v.string() },
|
|
1056
|
-
handler: async (ctx, { hashedKey }) => {
|
|
1057
|
-
return await ctx.db.query("key").withIndex("hashedKey", (q) => q.eq("hashedKey", hashedKey)).first();
|
|
1058
|
-
}
|
|
1059
|
-
});
|
|
1060
|
-
/**
|
|
1061
|
-
* @deprecated Use `keyList` with `where: { userId }` instead.
|
|
1062
|
-
* Kept for backward compatibility with generated component types.
|
|
1063
|
-
*/
|
|
1064
|
-
const keyListByUserId = query({
|
|
1065
|
-
args: { userId: v.id("user") },
|
|
1066
|
-
handler: async (ctx, { userId }) => {
|
|
1067
|
-
return await ctx.db.query("key").withIndex("userId", (q) => q.eq("userId", userId)).collect();
|
|
1068
|
-
}
|
|
1069
|
-
});
|
|
1070
|
-
/**
|
|
1071
|
-
* List API keys with optional filtering, sorting, and pagination.
|
|
1072
|
-
*
|
|
1073
|
-
* Returns `{ items, nextCursor }`. Supports filtering by `userId`,
|
|
1074
|
-
* `revoked`, `name`, and `prefix`.
|
|
1075
|
-
*/
|
|
1076
|
-
const keyList = query({
|
|
1077
|
-
args: {
|
|
1078
|
-
where: v.optional(v.object({
|
|
1079
|
-
userId: v.optional(v.id("user")),
|
|
1080
|
-
revoked: v.optional(v.boolean()),
|
|
1081
|
-
name: v.optional(v.string()),
|
|
1082
|
-
prefix: v.optional(v.string())
|
|
1083
|
-
})),
|
|
1084
|
-
limit: v.optional(v.number()),
|
|
1085
|
-
cursor: v.optional(v.union(v.string(), v.null())),
|
|
1086
|
-
orderBy: v.optional(v.union(v.literal("_creationTime"), v.literal("name"), v.literal("lastUsedAt"), v.literal("expiresAt"), v.literal("revoked"))),
|
|
1087
|
-
order: v.optional(v.union(v.literal("asc"), v.literal("desc")))
|
|
1088
|
-
},
|
|
1089
|
-
handler: async (ctx, args) => {
|
|
1090
|
-
const where = args.where ?? {};
|
|
1091
|
-
const limit = Math.min(Math.max(args.limit ?? 50, 1), 100);
|
|
1092
|
-
const order = args.order ?? "desc";
|
|
1093
|
-
let q;
|
|
1094
|
-
if (where.userId !== void 0) q = ctx.db.query("key").withIndex("userId", (idx) => idx.eq("userId", where.userId));
|
|
1095
|
-
else q = ctx.db.query("key");
|
|
1096
|
-
if (where.revoked !== void 0) q = q.filter((f) => f.eq(f.field("revoked"), where.revoked));
|
|
1097
|
-
if (where.name !== void 0) q = q.filter((f) => f.eq(f.field("name"), where.name));
|
|
1098
|
-
if (where.prefix !== void 0) q = q.filter((f) => f.eq(f.field("prefix"), where.prefix));
|
|
1099
|
-
q = q.order(order);
|
|
1100
|
-
const all = await q.collect();
|
|
1101
|
-
let startIdx = 0;
|
|
1102
|
-
if (args.cursor) {
|
|
1103
|
-
const cursorIdx = all.findIndex((doc) => doc._id === args.cursor);
|
|
1104
|
-
if (cursorIdx !== -1) startIdx = cursorIdx + 1;
|
|
1105
|
-
}
|
|
1106
|
-
const page = all.slice(startIdx, startIdx + limit + 1);
|
|
1107
|
-
const hasMore = page.length > limit;
|
|
1108
|
-
const items = hasMore ? page.slice(0, limit) : page;
|
|
1109
|
-
return {
|
|
1110
|
-
items,
|
|
1111
|
-
nextCursor: hasMore ? items[items.length - 1]._id : null
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
/** Get a single API key by document ID. */
|
|
1116
|
-
const keyGetById = query({
|
|
1117
|
-
args: { keyId: v.id("key") },
|
|
1118
|
-
handler: async (ctx, { keyId }) => {
|
|
1119
|
-
return await ctx.db.get(keyId);
|
|
1120
|
-
}
|
|
1121
|
-
});
|
|
1122
|
-
/**
|
|
1123
|
-
* Patch an API key record. Used for updating name, scopes, rate limit config,
|
|
1124
|
-
* revocation, and lastUsedAt / rate limit state tracking.
|
|
1125
|
-
*/
|
|
1126
|
-
const keyPatch = mutation({
|
|
1127
|
-
args: {
|
|
1128
|
-
keyId: v.id("key"),
|
|
1129
|
-
data: v.object({
|
|
1130
|
-
name: v.optional(v.string()),
|
|
1131
|
-
scopes: v.optional(v.array(v.object({
|
|
1132
|
-
resource: v.string(),
|
|
1133
|
-
actions: v.array(v.string())
|
|
1134
|
-
}))),
|
|
1135
|
-
rateLimit: v.optional(v.object({
|
|
1136
|
-
maxRequests: v.number(),
|
|
1137
|
-
windowMs: v.number()
|
|
1138
|
-
})),
|
|
1139
|
-
rateLimitState: v.optional(v.object({
|
|
1140
|
-
attemptsLeft: v.number(),
|
|
1141
|
-
lastAttemptTime: v.number()
|
|
1142
|
-
})),
|
|
1143
|
-
revoked: v.optional(v.boolean()),
|
|
1144
|
-
lastUsedAt: v.optional(v.number())
|
|
1145
|
-
})
|
|
1146
|
-
},
|
|
1147
|
-
handler: async (ctx, { keyId, data }) => {
|
|
1148
|
-
if (await ctx.db.get(keyId) === null) throw new ConvexError({
|
|
1149
|
-
code: "KEY_NOT_FOUND",
|
|
1150
|
-
message: "API key not found",
|
|
1151
|
-
keyId
|
|
1152
|
-
});
|
|
1153
|
-
await ctx.db.patch(keyId, data);
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
/** Hard delete an API key record. */
|
|
1157
|
-
const keyDelete = mutation({
|
|
1158
|
-
args: { keyId: v.id("key") },
|
|
1159
|
-
handler: async (ctx, { keyId }) => {
|
|
1160
|
-
if (await ctx.db.get(keyId) === null) throw new ConvexError({
|
|
1161
|
-
code: "KEY_NOT_FOUND",
|
|
1162
|
-
message: "API key not found",
|
|
1163
|
-
keyId
|
|
1164
|
-
});
|
|
1165
|
-
await ctx.db.delete(keyId);
|
|
1166
|
-
}
|
|
1167
|
-
});
|
|
1168
|
-
/** Insert a new device authorization record. */
|
|
1169
|
-
const deviceInsert = mutation({
|
|
1170
|
-
args: {
|
|
1171
|
-
deviceCodeHash: v.string(),
|
|
1172
|
-
userCode: v.string(),
|
|
1173
|
-
expiresAt: v.number(),
|
|
1174
|
-
interval: v.number(),
|
|
1175
|
-
status: v.union(v.literal("pending"), v.literal("authorized"), v.literal("denied"))
|
|
1176
|
-
},
|
|
1177
|
-
handler: async (ctx, args) => {
|
|
1178
|
-
return await ctx.db.insert("device", args);
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
/** Look up a device authorization by its hashed device code. */
|
|
1182
|
-
const deviceGetByCodeHash = query({
|
|
1183
|
-
args: { deviceCodeHash: v.string() },
|
|
1184
|
-
handler: async (ctx, { deviceCodeHash }) => {
|
|
1185
|
-
return await ctx.db.query("device").withIndex("deviceCodeHash", (q) => q.eq("deviceCodeHash", deviceCodeHash)).first();
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
/** Look up a pending device authorization by its user code. */
|
|
1189
|
-
const deviceGetByUserCode = query({
|
|
1190
|
-
args: { userCode: v.string() },
|
|
1191
|
-
handler: async (ctx, { userCode }) => {
|
|
1192
|
-
return await ctx.db.query("device").withIndex("userCode", (q) => q.eq("userCode", userCode).eq("status", "pending")).first();
|
|
1193
|
-
}
|
|
1194
|
-
});
|
|
1195
|
-
/** Authorize a device code — link it to a user and session. */
|
|
1196
|
-
const deviceAuthorize = mutation({
|
|
1197
|
-
args: {
|
|
1198
|
-
deviceId: v.id("device"),
|
|
1199
|
-
userId: v.id("user"),
|
|
1200
|
-
sessionId: v.id("session")
|
|
1201
|
-
},
|
|
1202
|
-
handler: async (ctx, { deviceId, userId, sessionId }) => {
|
|
1203
|
-
await ctx.db.patch(deviceId, {
|
|
1204
|
-
status: "authorized",
|
|
1205
|
-
userId,
|
|
1206
|
-
sessionId
|
|
1207
|
-
});
|
|
1208
|
-
}
|
|
1209
|
-
});
|
|
1210
|
-
/** Update the last-polled timestamp on a device authorization record. */
|
|
1211
|
-
const deviceUpdateLastPolled = mutation({
|
|
1212
|
-
args: {
|
|
1213
|
-
deviceId: v.id("device"),
|
|
1214
|
-
lastPolledAt: v.number()
|
|
1215
|
-
},
|
|
1216
|
-
handler: async (ctx, { deviceId, lastPolledAt }) => {
|
|
1217
|
-
await ctx.db.patch(deviceId, { lastPolledAt });
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
/** Delete a device authorization record (cleanup after use or expiry). */
|
|
1221
|
-
const deviceDelete = mutation({
|
|
1222
|
-
args: { deviceId: v.id("device") },
|
|
1223
|
-
handler: async (ctx, { deviceId }) => {
|
|
1224
|
-
await ctx.db.delete(deviceId);
|
|
1225
|
-
}
|
|
1226
|
-
});
|
|
1227
|
-
|
|
1228
|
-
//#endregion
|
|
1229
|
-
export { accountDelete, accountGet, accountGetById, accountInsert, accountListByUser, accountPatch, deviceAuthorize, deviceDelete, deviceGetByCodeHash, deviceGetByUserCode, deviceInsert, deviceUpdateLastPolled, groupCreate, groupDelete, groupGet, groupList, groupUpdate, inviteAccept, inviteCreate, inviteGet, inviteList, inviteRevoke, keyDelete, keyGetByHashedKey, keyGetById, keyInsert, keyList, keyListByUserId, keyPatch, memberAdd, memberGet, memberGetByGroupAndUser, memberList, memberListByUser, memberRemove, memberUpdate, passkeyDelete, passkeyGetByCredentialId, passkeyInsert, passkeyListByUserId, passkeyUpdateCounter, passkeyUpdateMeta, rateLimitCreate, rateLimitDelete, rateLimitGet, rateLimitPatch, refreshTokenCreate, refreshTokenDeleteAll, refreshTokenGetActive, refreshTokenGetById, refreshTokenGetChildren, refreshTokenListBySession, refreshTokenPatch, sessionCreate, sessionDelete, sessionGetById, sessionList, sessionListByUser, totpDelete, totpGetById, totpGetVerifiedByUserId, totpInsert, totpListByUserId, totpMarkVerified, totpUpdateLastUsed, userFindByVerifiedEmail, userFindByVerifiedPhone, userGetById, userInsert, userList, userPatch, userUpsert, verificationCodeCreate, verificationCodeDelete, verificationCodeGetByAccountId, verificationCodeGetByCode, verifierCreate, verifierDelete, verifierGetById, verifierGetBySignature, verifierPatch };
|
|
1230
|
-
//# sourceMappingURL=public.js.map
|
|
22
|
+
export { accountDelete, accountGet, accountGetById, accountInsert, accountListByUser, accountPatch, deviceAuthorize, deviceDelete, deviceGetByCodeHash, deviceGetByUserCode, deviceInsert, deviceUpdateLastPolled, enterpriseAuditEventCreate, enterpriseAuditEventList, enterpriseCreate, enterpriseDelete, enterpriseDomainAdd, enterpriseDomainDelete, enterpriseDomainList, enterpriseDomainVerificationDelete, enterpriseDomainVerificationGet, enterpriseDomainVerificationUpsert, enterpriseDomainVerify, enterpriseGet, enterpriseGetByDomain, enterpriseGetByGroup, enterpriseList, enterpriseScimConfigGetByEnterprise, enterpriseScimConfigGetByTokenHash, enterpriseScimConfigUpsert, enterpriseScimIdentityDelete, enterpriseScimIdentityGet, enterpriseScimIdentityGetByEnterpriseAndUser, enterpriseScimIdentityGetByMappedGroup, enterpriseScimIdentityGetByUser, enterpriseScimIdentityListByEnterprise, enterpriseScimIdentityUpsert, enterpriseSecretDelete, enterpriseSecretGet, enterpriseSecretUpsert, enterpriseUpdate, enterpriseWebhookDeliveryEnqueue, enterpriseWebhookDeliveryList, enterpriseWebhookDeliveryListReady, enterpriseWebhookDeliveryPatch, enterpriseWebhookEndpointCreate, enterpriseWebhookEndpointGet, enterpriseWebhookEndpointList, enterpriseWebhookEndpointUpdate, groupCreate, groupDelete, groupGet, groupList, groupUpdate, inviteAccept, inviteAcceptByToken, inviteCreate, inviteGet, inviteGetByTokenHash, inviteList, inviteRevoke, keyDelete, keyGetByHashedKey, keyGetById, keyInsert, keyList, keyPatch, memberAdd, memberGet, memberGetByGroupAndUser, memberList, memberRemove, memberResolve, memberUpdate, passkeyDelete, passkeyGetByCredentialId, passkeyInsert, passkeyListByUserId, passkeyUpdateCounter, passkeyUpdateMeta, rateLimitCreate, rateLimitDelete, rateLimitGet, rateLimitPatch, refreshTokenCreate, refreshTokenDeleteAll, refreshTokenGetActive, refreshTokenGetById, refreshTokenGetChildren, refreshTokenListBySession, refreshTokenPatch, sessionCreate, sessionDelete, sessionGetById, sessionList, sessionListByUser, totpDelete, totpGetById, totpGetVerifiedByUserId, totpInsert, totpListByUserId, totpMarkVerified, totpUpdateLastUsed, userDelete, userFindByVerifiedEmail, userFindByVerifiedPhone, userGetById, userInsert, userList, userPatch, userUpsert, verificationCodeCreate, verificationCodeDelete, verificationCodeGetByAccountId, verificationCodeGetByCode, verifierCreate, verifierDelete, verifierGetById, verifierGetBySignature, verifierPatch };
|