interface
RiduAuth
Authentication operations for one client. Calls that act on an auth collection use the client's auth.collection unless they name one.
Properties
| Property | Type | Description |
|---|---|---|
session | SessionFor< | The latest session snapshot held by the configured token store, or null. It is reactive
when the store is, as in @riducms/sveltekit. It is a display hint; call getSession() to
verify with Ridu. |
login | < | Start a session. With a token store the token is persisted before this resolves, so an immediate navigation is already authenticated. |
getSession | (options?: RequestOptions) => Promise< | Verify the current credential with Ridu. Resolves null when there is no valid session,
including a session from another auth collection than a configured auth.collection. An
unavailable server still rejects, so an outage never looks like a logout. |
rotate | (options?: RequestOptions) => Promise< | Replace the current bearer token without extending the session. The old token stops working immediately, so never call this automatically from concurrent tabs or server renders. |
logout | (options?: RequestOptions) => Promise< | Revoke the current session. A token store forgets its token even if revocation fails. |
logoutAll | (options?: RequestOptions) => Promise< | Revoke every session belonging to the current actor. |
sessions | (options?: RequestOptions) => Promise< | List active sessions belonging to the current actor. |
revokeSession | (id: string, | Revoke one session belonging to the current actor. |
changePassword | (input: { currentPassword: string; password: string; }, | Change the current actor's password. Every session, including this one, is revoked. |
createUser | { < | Create a user in an auth-enabled collection, including sign-up and managed-user flows. Explicit publication requires the complete generated user data contract. |
bootstrap | < | Check whether an auth collection still permits its first bootstrap user. |
requestPasswordReset | < | Request a password-reset message. The response never reveals whether the account exists. |
resetPassword | < | Replace a password using a valid password-reset token. |
requestVerification | < | Request an email-verification message. |
verifyEmail | < | Verify an email address with a valid verification token. |
forceUnlock | < | Clear a user's login-attempt lock when the current actor is allowed to do so. |
createAPIKey | (input: CreateAPIKeyInput, | Create an API key and return its secret, which later listings omit. |
apiKeys | (options?: RequestOptions) => Promise< | List API-key metadata for the current actor without returning key secrets. |
revokeAPIKey | (id: string, | Revoke one API key belonging to the current actor. |
Full signature
interface RiduAuth<
Config extends RiduConfigShape = RiduConfigShape,
DefaultAuth extends AuthCollectionSlug<Config> = never,
> { ... }Methods
RiduAuth.login()Start a session. With a token store the token is persisted before this resolves.
RiduAuth.getSession()Verify the current credential; resolves null without a valid session and rejects on an outage.
RiduAuth.rotate()Replace the current bearer token without extending the session.
RiduAuth.logout()End the current session.
RiduAuth.logoutAll()End every session owned by the current user.
RiduAuth.sessions()List the current user’s active sessions.
RiduAuth.revokeSession()Revoke one owned session by ID.
RiduAuth.requestPasswordReset()Request a password-reset token through the configured delivery hook.
RiduAuth.resetPassword()Consume a password-reset token.
RiduAuth.bootstrap()Check whether an auth collection still permits its first bootstrap user.
RiduAuth.createUser()Create a user in an auth-enabled collection, including sign-up.
RiduAuth.requestVerification()Request an email-verification token through the configured delivery hook.
RiduAuth.verifyEmail()Consume an email-verification token.
RiduAuth.changePassword()Change the current user’s password.
RiduAuth.createAPIKey()Create an API key; its secret is returned only once.
RiduAuth.apiKeys()List API-key metadata without secrets.
RiduAuth.revokeAPIKey()Revoke one API key.
RiduAuth.forceUnlock()Clear lockout state for an auth user when authorized.