Sporades SDK API
    Preparing search index...

    Type Alias ServerAuthApi

    Server-only auth management API.

    Available to trusted Capsule handlers. Lets server code update email credentials (e.g. for password reset flows) without direct access to the internal auth database.

    type ServerAuthApi = {
        confirmPasswordReset(code: string, newPassword: string): Promise<void>;
        createEmailPasswordResetLink(email: string): Promise<PasswordResetLink>;
        sendEmailPasswordResetLink(
            email: string,
            options?: PasswordResetMailOptions,
        ): Promise<void>;
        setEmailPassword(email: string, newPassword: string): Promise<void>;
        verifyPasswordResetCode(code: string): Promise<{ email: string }>;
    }
    Index
    • Spend a Reset code and set the new password. Revokes every Session for that user and does not create a new one.

      Parameters

      • code: string
      • newPassword: string

      Returns Promise<void>

    • Issue a Reset code and return its link without sending anything, for Capsules that deliver through their own mail path.

      Unlike sendEmailPasswordResetLink this throws for an unregistered email, because its whole purpose is to return a link. It is server-only: exposing its result to an unauthenticated caller reintroduces account enumeration.

      Parameters

      • email: string

      Returns Promise<PasswordResetLink>

    • Issue a Reset code and deliver it over the runtime SMTP transport.

      Resolves identically whether or not the email is registered, so it cannot be used to enumerate accounts. Throws only when mail is not configured or email auth is disabled.

      Parameters

      Returns Promise<void>

    • Update the password for an existing email credential. Throws if the email is not registered.

      Parameters

      • email: string
      • newPassword: string

      Returns Promise<void>

    • Report which account a Reset code belongs to. Does not spend the code.

      Parameters

      • code: string

      Returns Promise<{ email: string }>