AuthKit.ts overview

AuthKit’s authorization-code flow as the core’s OAuthService and SsoService: the browser goes to /user_management/authorize (the hosted AuthKit UI, a social provider, or an SSO connection), comes back with a code, and the authorization_code grant signs the user in. The state is spent once through the core OAuthStateStore (stored as its digest), and the PKCE verifier is derived from it under the root secret, never stored.

WorkOS holds the connections, so registering one, SAML metadata and linking provider accounts by hand are refused.

Since v0.1.0


Exports Grouped by Category


constants

SOCIAL_PROVIDERS

The social providers WorkOS names, by the name an app passes to generateAuthorizationUrl.

Signature

declare const SOCIAL_PROVIDERS: {
  readonly authkit: "authkit"
  readonly google: "GoogleOAuth"
  readonly microsoft: "MicrosoftOAuth"
  readonly github: "GitHubOAuth"
  readonly apple: "AppleOAuth"
}

Source

Since v0.1.0

layers

oauthLayer

The core OAuthService over AuthKit. generateAuthorizationUrl takes a provider from SOCIAL_PROVIDERS ("authkit" for the hosted UI), connection:<id> or organization:<id>; signInWithCallback completes it. The OAuthAccount it answers names the WorkOS user and holds no provider token (accessToken is empty): WorkOS keeps them.

Signature

declare const oauthLayer: Layer.Layer<
  Auth.OAuth.OAuthService,
  never,
  | WorkOSClient
  | WorkOSSessions
  | WorkOSAuthenticate
  | Auth.Hooks.Hooks
  | Auth.OAuth.OAuthStateStore
  | Auth.RootSecret.RootSecret
  | Mac.Mac
  | SecureRandom.SecureRandom
  | Digest.Digest
>

Source

Since v0.1.0

ssoLayer

The core SsoService over WorkOS SSO. signIn takes the connection or organization id as providerId (conn_… or org_…); an email or domain alone is refused, since WorkOS routes those itself through the hosted AuthKit UI (OAuthService with "authkit"). The provider a callback answers describes the WorkOS connection, with no secret in it.

Signature

declare const ssoLayer: Layer.Layer<
  Auth.Sso.SsoService,
  never,
  | WorkOSClient
  | WorkOSSessions
  | WorkOSAuthenticate
  | Auth.Hooks.Hooks
  | Auth.OAuth.OAuthStateStore
  | Auth.RootSecret.RootSecret
  | Mac.Mac
  | SecureRandom.SecureRandom
  | Digest.Digest
>

Source

Since v0.1.0

utils

authorizeTarget

The /authorize parameter naming what to sign in with: a provider from SOCIAL_PROVIDERS, connection:<id> for an SSO connection, or organization:<id> for an organization’s connection.

Signature

declare const authorizeTarget: (provider: string) => Option.Option<Readonly<Record<string, string>>>

Source

Since v0.1.0


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