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

PropertyTypeDescription
sessionSessionFor<Config, SessionCollection<Config, DefaultAuth>> | nullThe 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<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(credentials: LoginInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<SessionFor<Config, Slug>>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<SessionFor<Config, SessionCollection<Config, DefaultAuth>> | null>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<SessionFor<Config, SessionCollection<Config, DefaultAuth>>>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<LogoutEnvelope>Revoke the current session. A token store forgets its token even if revocation fails.
logoutAll(options?: RequestOptions) => Promise<LogoutEnvelope>Revoke every session belonging to the current actor.
sessions(options?: RequestOptions) => Promise<AuthSessionInfo[]>List active sessions belonging to the current actor.
revokeSession(id: string, options?: RequestOptions) => Promise<DeleteEnvelope>Revoke one session belonging to the current actor.
changePassword(input: { currentPassword: string; password: string; }, options?: RequestOptions) => Promise<AuthActionEnvelope>Change the current actor's password. Every session, including this one, is revoked.
createUser{ <Slug extends Extract<AuthCollectionSlug<Config>, DraftCollectionSlug<Config>> = Extract<SessionCollection<Config, DefaultAuth>, DraftCollectionSlug<Config>>>(input: [Slug] extends [never] ? never : { data: DraftCreateFor<Config, Slug>; password: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: CreateOptions<LocaleFor<Config>, true, true> & { draft?: true; }): Promise<OutputFor<Config, Slug>>; <Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: { data: CreateFor<Config, Slug>; password: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: CreateOptions<LocaleFor<Config>, CollectionVersionsFor<Config, Slug>, CollectionDraftsFor<Config, Slug>>): Promise<OutputFor<Config, Slug>>; }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<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: AuthCollectionInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<AuthBootstrapEnvelope>Check whether an auth collection still permits its first bootstrap user.
requestPasswordReset<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: { email: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<AuthActionEnvelope>Request a password-reset message. The response never reveals whether the account exists.
resetPassword<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: { token: string; password: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<AuthActionEnvelope>Replace a password using a valid password-reset token.
requestVerification<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: { email: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<AuthActionEnvelope>Request an email-verification message.
verifyEmail<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: { token: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<AuthActionEnvelope>Verify an email address with a valid verification token.
forceUnlock<Slug extends AuthCollectionSlug<Config> = SessionCollection<Config, DefaultAuth>>(input: { id: string; } & AuthCollectionInput<DefaultAuth, Slug>, options?: RequestOptions) => Promise<AuthActionEnvelope>Clear a user's login-attempt lock when the current actor is allowed to do so.
createAPIKey(input: CreateAPIKeyInput, options?: RequestOptions) => Promise<APIKey>Create an API key and return its secret, which later listings omit.
apiKeys(options?: RequestOptions) => Promise<APIKeyInfo[]>List API-key metadata for the current actor without returning key secrets.
revokeAPIKey(id: string, options?: RequestOptions) => Promise<DeleteEnvelope>Revoke one API key belonging to the current actor.

Full signature

interface RiduAuth< Config extends RiduConfigShape = RiduConfigShape, DefaultAuth extends AuthCollectionSlug<Config> = never, > { ... }

Source packages/sdk/src/index.ts:21

Methods