stytch_codecs
Types
Response from Stytch when attempting to autenticate with any method.
pub type AuthenticateResponse {
AuthenticateResponse(
status_code: Int,
request_id: String,
user_id: String,
method_id: String,
session_token: String,
session_jwt: String,
)
}
Constructors
-
AuthenticateResponse( status_code: Int, request_id: String, user_id: String, method_id: String, session_token: String, session_jwt: String, )
Email identifying a user. Stytch separates email_id (not PII) from email and indicates whether the user has verified that they can access that address.
pub type Email {
Email(email_id: String, email: String, verified: Bool)
}
Constructors
-
Email(email_id: String, email: String, verified: Bool)
Response to a request to create or log into an account.
Used by both magic links and OTP login_or_create
pub type LoginOrCreateResponse {
LoginOrCreateResponse(
status_code: Int,
request_id: String,
user_id: String,
email_id: String,
)
}
Constructors
-
LoginOrCreateResponse( status_code: Int, request_id: String, user_id: String, email_id: String, )
Request to create a magic link. When stytch receives this request, it will send an e-mail, authenticate the user in the clicked link, and redirect back to somewhere in your service.
pub type MagicLinkLoginOrCreateRequest {
MagicLinkLoginOrCreateRequest(email: String)
}
Constructors
-
MagicLinkLoginOrCreateRequest(email: String)
Name identifying a user.
pub type Name {
Name(
first_name: String,
middle_name: String,
last_name: String,
)
}
Constructors
-
Name(first_name: String, middle_name: String, last_name: String)
pub type PasscodeAuthenticateRequest {
PasscodeAuthenticateRequest(
code: String,
method_id: String,
session_duration_minutes: Int,
)
}
Constructors
-
PasscodeAuthenticateRequest( code: String, method_id: String, session_duration_minutes: Int, )
Request to log in with a passcode. When stytch receives this it will send a passcode to the user’s e-mail address. It is up to you to process the passcode and authenticate it with stytch.
pub type PasscodeLoginOrCreateRequest {
PasscodeLoginOrCreateRequest(email: String)
}
Constructors
-
PasscodeLoginOrCreateRequest(email: String)
Complete passkey authentication, passing the credential returned by the
browser’s navigator.credentials.get() call as a JSON string.
pub type PasskeyAuthenticateRequest {
PasskeyAuthenticateRequest(
public_key_credential: String,
session_duration_minutes: Int,
)
}
Constructors
-
PasskeyAuthenticateRequest( public_key_credential: String, session_duration_minutes: Int, )
Start authenticating with a passkey. No user_id is supplied; the browser’s passkey picker identifies the user via discoverable credentials.
pub type PasskeyAuthenticateStartRequest {
PasskeyAuthenticateStartRequest(
domain: String,
use_base64_url_encoding: Bool,
return_passkey_credential_options: Bool,
)
}
Constructors
-
PasskeyAuthenticateStartRequest( domain: String, use_base64_url_encoding: Bool, return_passkey_credential_options: Bool, )
Response to a request to start passkey authentication.
pub type PasskeyAuthenticateStartResponse {
PasskeyAuthenticateStartResponse(
request_id: String,
user_id: String,
public_key_credential_request_options: String,
status_code: Int,
)
}
Constructors
-
PasskeyAuthenticateStartResponse( request_id: String, user_id: String, public_key_credential_request_options: String, status_code: Int, )
Payload sent by a browser after a WebAuthn ceremony. The server is responsible for adding the authenticated user’s id and session policy before forwarding to Stytch — the browser must not assert identity.
pub type PasskeyCredentialPayload {
PasskeyCredentialPayload(public_key_credential: String)
}
Constructors
-
PasskeyCredentialPayload(public_key_credential: String)
Complete registering a new passkey, passing the credential created by the
browser’s navigator.credentials.create() call as a JSON string.
pub type PasskeyRegisterFinishRequest {
PasskeyRegisterFinishRequest(
user_id: String,
public_key_credential: String,
session_duration_minutes: Int,
)
}
Constructors
-
PasskeyRegisterFinishRequest( user_id: String, public_key_credential: String, session_duration_minutes: Int, )
Start registering a new passkey for a user with a known id.
pub type PasskeyRegisterStartRequest {
PasskeyRegisterStartRequest(
user_id: String,
domain: String,
use_base64_url_encoding: Bool,
return_passkey_credential_options: Bool,
user_agent: option.Option(String),
)
}
Constructors
-
PasskeyRegisterStartRequest( user_id: String, domain: String, use_base64_url_encoding: Bool, return_passkey_credential_options: Bool, user_agent: option.Option(String), )
Response to a request to register a new passkey for an authenticated user.
pub type PasskeyRegisterStartResponse {
PasskeyRegisterStartResponse(
request_id: String,
user_id: String,
public_key_credential_creation_options: String,
status_code: Int,
)
}
Constructors
-
PasskeyRegisterStartResponse( request_id: String, user_id: String, public_key_credential_creation_options: String, status_code: Int, )
Response to a completed passkey registration or authentication. Both Stytch endpoints return the same shape: session credentials plus the full user.
pub type PasskeySessionResponse {
PasskeySessionResponse(
request_id: String,
user_id: String,
webauthn_registration_id: String,
session_token: String,
session_jwt: String,
user: StytchUser,
status_code: Int,
)
}
Constructors
-
PasskeySessionResponse( request_id: String, user_id: String, webauthn_registration_id: String, session_token: String, session_jwt: String, user: StytchUser, status_code: Int, )
pub type SessionAuthenticateResponse {
SessionAuthenticateResponse(
status_code: Int,
request_id: String,
user: StytchUser,
session_token: String,
session_jwt: String,
)
}
Constructors
-
SessionAuthenticateResponse( status_code: Int, request_id: String, user: StytchUser, session_token: String, session_jwt: String, )
Request to revoke a session.
Use for signout.
pub type SessionRevokeRequest {
SessionRevokeRequest(session_token: String)
}
Constructors
-
SessionRevokeRequest(session_token: String)
Response from stytch to a request to revoke a given session token.
pub type SessionRevokeResponse {
SessionRevokeResponse(request_id: String, status_code: Int)
}
Constructors
-
SessionRevokeResponse(request_id: String, status_code: Int)
pub type SessionTokenAuthenticateRequest {
SessionTokenAuthenticateRequest(
session_token: String,
session_duration_minutes: Int,
)
}
Constructors
-
SessionTokenAuthenticateRequest( session_token: String, session_duration_minutes: Int, )
Error messages received from the stytch service
pub type StytchClientError {
StytchClientError(
status_code: Int,
request_id: String,
error_type: String,
error_message: String,
error_url: String,
)
}
Constructors
-
StytchClientError( status_code: Int, request_id: String, error_type: String, error_message: String, error_url: String, )
pub type StytchUser {
StytchUser(
user_id: String,
name: Name,
emails: List(Email),
webauthn_registrations: List(WebAuthnRegistration),
)
}
Constructors
-
StytchUser( user_id: String, name: Name, emails: List(Email), webauthn_registrations: List(WebAuthnRegistration), )
Request to authenticate a stytch token returned from login.
pub type TokenAuthenticateRequest {
TokenAuthenticateRequest(
token: String,
session_duration_minutes: Int,
)
}
Constructors
-
TokenAuthenticateRequest( token: String, session_duration_minutes: Int, )
A passkey or WebAuthn registration associated with a user.
pub type WebAuthnRegistration {
WebAuthnRegistration(
webauthn_registration_id: String,
domain: String,
user_agent: String,
verified: Bool,
authenticator_type: String,
name: String,
)
}
Constructors
-
WebAuthnRegistration( webauthn_registration_id: String, domain: String, user_agent: String, verified: Bool, authenticator_type: String, name: String, )
Values
pub fn authenticate_response_decoder() -> decode.Decoder(
AuthenticateResponse,
)
pub fn authenticate_response_to_json(
magic_link_authenticate_response: AuthenticateResponse,
) -> json.Json
pub fn email_decoder() -> decode.Decoder(Email)
pub fn login_or_create_response_decoder() -> decode.Decoder(
LoginOrCreateResponse,
)
pub fn login_or_create_response_to_json(
magic_link_login_or_create_response: LoginOrCreateResponse,
) -> json.Json
pub fn magic_link_login_or_create_request_decoder() -> decode.Decoder(
MagicLinkLoginOrCreateRequest,
)
pub fn magic_link_login_or_create_request_to_json(
magic_link_login_or_create_request: MagicLinkLoginOrCreateRequest,
) -> json.Json
pub fn name_decoder() -> decode.Decoder(Name)
pub fn passcode_authenticate_request_decoder() -> decode.Decoder(
PasscodeAuthenticateRequest,
)
pub fn passcode_authenticate_request_to_json(
passcode_authenticate_request: PasscodeAuthenticateRequest,
) -> json.Json
pub fn passcode_login_or_create_request_decoder() -> decode.Decoder(
PasscodeLoginOrCreateRequest,
)
pub fn passcode_login_or_create_request_to_json(
passcode_login_or_create_request: PasscodeLoginOrCreateRequest,
) -> json.Json
pub fn passkey_authenticate_request_decoder() -> decode.Decoder(
PasskeyAuthenticateRequest,
)
pub fn passkey_authenticate_request_to_json(
passkey_authenticate_request: PasskeyAuthenticateRequest,
) -> json.Json
pub fn passkey_authenticate_start_request_decoder() -> decode.Decoder(
PasskeyAuthenticateStartRequest,
)
pub fn passkey_authenticate_start_request_to_json(
passkey_authenticate_start_request: PasskeyAuthenticateStartRequest,
) -> json.Json
pub fn passkey_authenticate_start_response_decoder() -> decode.Decoder(
PasskeyAuthenticateStartResponse,
)
pub fn passkey_authenticate_start_response_to_json(
passkey_authenticate_start_response: PasskeyAuthenticateStartResponse,
) -> json.Json
pub fn passkey_credential_payload_decoder() -> decode.Decoder(
PasskeyCredentialPayload,
)
pub fn passkey_credential_payload_to_json(
passkey_credential_payload: PasskeyCredentialPayload,
) -> json.Json
pub fn passkey_register_finish_request_decoder() -> decode.Decoder(
PasskeyRegisterFinishRequest,
)
pub fn passkey_register_finish_request_to_json(
passkey_register_finish_request: PasskeyRegisterFinishRequest,
) -> json.Json
pub fn passkey_register_start_request_decoder() -> decode.Decoder(
PasskeyRegisterStartRequest,
)
pub fn passkey_register_start_request_to_json(
passkey_register_start_request: PasskeyRegisterStartRequest,
) -> json.Json
pub fn passkey_register_start_response_decoder() -> decode.Decoder(
PasskeyRegisterStartResponse,
)
pub fn passkey_register_start_response_to_json(
passkey_register_start_response: PasskeyRegisterStartResponse,
) -> json.Json
pub fn passkey_session_response_decoder() -> decode.Decoder(
PasskeySessionResponse,
)
pub fn passkey_session_response_to_json(
passkey_session_response: PasskeySessionResponse,
) -> json.Json
pub fn session_authenticate_response_decoder() -> decode.Decoder(
SessionAuthenticateResponse,
)
pub fn session_authenticate_response_to_json(
session_authenticate_response: SessionAuthenticateResponse,
) -> json.Json
pub fn session_revoke_request_decoder() -> decode.Decoder(
SessionRevokeRequest,
)
pub fn session_revoke_request_to_json(
session_revoke_request: SessionRevokeRequest,
) -> json.Json
pub fn session_revoke_response_decoder() -> decode.Decoder(
SessionRevokeResponse,
)
pub fn session_revoke_response_to_json(
session_revoke_response: SessionRevokeResponse,
) -> json.Json
pub fn session_token_authenticate_request_decoder() -> decode.Decoder(
SessionTokenAuthenticateRequest,
)
pub fn session_token_authenticate_request_to_json(
session_token_authenticate_request: SessionTokenAuthenticateRequest,
) -> json.Json
pub fn stytch_client_error_decoder() -> decode.Decoder(
StytchClientError,
)
pub fn stytch_client_error_to_json(
stytch_client_error: StytchClientError,
) -> json.Json
pub fn stytch_user_decoder() -> decode.Decoder(StytchUser)
pub fn stytch_user_to_json(stytch_user: StytchUser) -> json.Json
pub fn token_authenticate_request_decoder() -> decode.Decoder(
TokenAuthenticateRequest,
)
pub fn token_authenticate_request_to_json(
token_authenticate_request: TokenAuthenticateRequest,
) -> json.Json
pub fn webauthn_registration_decoder() -> decode.Decoder(
WebAuthnRegistration,
)
pub fn webauthn_registration_to_json(
webauthn_registration: WebAuthnRegistration,
) -> json.Json