Codes.ts overview

The flows that send something to an address, over WorkOS: email verification, password reset and Magic Auth (WorkOS’s emailed sign-in code, served as the core’s EmailOtpService). WorkOS sends each from its dashboard templates, or, with delivery: "app", the app sends the reset link and the sign-in code through the core EmailSender on a detached fiber.

Since v0.1.0


Exports Grouped by Category


errors

DeliveryConfigError (class)

delivery: "app" without an EmailSender where the layer is built; the layer dies with it.

Signature

declare class DeliveryConfigError

Source

Since v0.1.0

layers

emailVerificationLayer

The core EmailVerificationService over WorkOS’s emailed verification code. WorkOS keeps no link tokens, so the token verifyToken takes is <userId>:<code> (parseVerificationToken), and createVerification / resendVerification answer an empty token: WorkOS sends the code itself. peekToken and burnToken (the core’s two-step verify) are refused.

Signature

declare const emailVerificationLayer: Layer.Layer<
  Auth.Email.EmailVerificationService,
  never,
  WorkOSClient | Auth.Hooks.Hooks
>

Source

Since v0.1.0

magicAuthLayer

WorkOS Magic Auth as the core EmailOtpService: send creates the code (POST /user_management/magic_auth), signIn is the magic-auth:code grant. Only the "sign-in" purpose exists; check (verify without signing in) is refused. WorkOS budgets the guesses at a code; the core’s beforeAuthenticate gate runs first, so the IP limit counts them too.

Signature

declare const magicAuthLayer: Layer.Layer<
  Auth.Email.EmailOtpService,
  never,
  WorkOSClient | WorkOSSessions | WorkOSAuthenticate | Auth.Hooks.Hooks
>

Source

Since v0.1.0

passwordResetLayer

The core PasswordResetService over WorkOS. A request for an address WorkOS does not know answers as one it does. A reset ends every WorkOS session of the user, so a cookie an attacker holds stops working.

Signature

declare const passwordResetLayer: Layer.Layer<
  Auth.Password.PasswordResetService,
  never,
  WorkOSClient | Auth.SessionService.SessionService | Auth.Hooks.Hooks
>

Source

Since v0.1.0

utils

parseVerificationToken

Parse a verification token, <userId>:<code>: the user’s id (which every sign-up answer names) and the code WorkOS emailed.

Signature

declare const parseVerificationToken: (
  token: string
) => Option.Option<{ readonly userId: string; readonly code: string }>

Source

Since v0.1.0


This site uses Just the Docs, a documentation theme for Jekyll.