class Stytch::WebAuthn
def authenticate(
See [GET sessions](https://stytch.com/docs/api/session-get) for complete response fields.
If you initiate a Session, by including `session_duration_minutes` in your authenticate call, you'll receive a full Session object in the response.
session::
The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +User+ (+object+).
The `user` object affected by this API call. See the [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
user::
The type of this field is +String+.
The JSON Web Token (JWT) for a given Stytch Session.
session_jwt::
The type of this field is +String+.
A secret token for a given Stytch Session.
session_token::
The type of this field is +String+.
The unique ID for the WebAuthn registration.
webauthn_registration_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:
The type of this field is nilable +object+.
Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.
Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To delete a key, supply a null value.
session_custom_claims::
The type of this field is nilable +String+.
The `session_jwt` associated with a User's existing Session.
session_jwt::
The type of this field is nilable +Integer+.
If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
five minutes regardless of the underlying session duration, and will need to be refreshed over time.
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
session_duration_minutes::
The type of this field is nilable +String+.
The `session_token` associated with a User's existing Session.
session_token::
The type of this field is +String+.
The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
public_key_credential::
== Parameters:
If the [webauthn-json](https://github.com/github/webauthn-json) library's `get()` method was used, the response can be passed directly to the [authenticate endpoint](https://stytch.com/docs/api/webauthn-authenticate). If not some fields from the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) response will need to be converted from array buffers to strings and marshalled into JSON.
Complete the authentication of a WebAuthn registration by passing the response from the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request to the authenticate endpoint.
def authenticate( public_key_credential:, session_token: nil, session_duration_minutes: nil, session_jwt: nil, session_custom_claims: nil ) request = { public_key_credential: public_key_credential } request[:session_token] = session_token unless session_token.nil? request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil? post_request('/v1/webauthn/authenticate', request) end
def authenticate_start(
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
Options used for WebAuthn authentication.
public_key_credential_request_options::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:
The type of this field is +String+.
The domain for WebAuthn. Defaults to `window.location.hostname`.
domain::
The type of this field is +String+.
The `user_id` of an active user the WebAuthn registration should be tied to.
user_id::
== Parameters:
If you are not using the [webauthn-json](https://github.com/github/webauthn-json) library, `the public_key_credential_request_options` will need to be converted to a suitable public key by unmarshalling the JSON and converting some the fields to array buffers.
Initiate the authentication of a WebAuthn registration. After calling this endpoint, the browser will need to call [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) with the data from `public_key_credential_request_options` passed to the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request via the public key argument. We recommend using the `get()` wrapper provided by the webauthn-json library.
def authenticate_start( user_id:, domain: ) request = { user_id: user_id, domain: domain } post_request('/v1/webauthn/authenticate/start', request) end
def initialize(connection)
def initialize(connection) @connection = connection end
def register(
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
The unique ID for the WebAuthn registration.
webauthn_registration_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:
The type of this field is +String+.
The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
public_key_credential::
The type of this field is +String+.
The `user_id` of an active user the WebAuthn registration should be tied to.
user_id::
== Parameters:
If the [webauthn-json](https://github.com/github/webauthn-json) library's `create()` method was used, the response can be passed directly to the [register endpoint](https://stytch.com/docs/api/webauthn-register). If not, some fields (the client data and the attestation object) from the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) response will need to be converted from array buffers to strings and marshalled into JSON.
Complete the creation of a WebAuthn registration by passing the response from the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) request to this endpoint as the `public_key_credential` parameter.
def register( user_id:, public_key_credential: ) request = { user_id: user_id, public_key_credential: public_key_credential } post_request('/v1/webauthn/register', request) end
def register_start(
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
Options used for WebAuthn registration.
public_key_credential_creation_options::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:
The type of this field is nilable +String+.
The requested authenticator type of the WebAuthn device. The two valid value are platform and cross-platform. If no value passed, we assume both values are allowed.
authenticator_type::
The type of this field is nilable +String+.
The user agent of the User.
user_agent::
The type of this field is +String+.
The domain for WebAuthn. Defaults to `window.location.hostname`.
domain::
The type of this field is +String+.
The `user_id` of an active user the WebAuthn registration should be tied to.
user_id::
== Parameters:
If you are not using the [webauthn-json](https://github.com/github/webauthn-json) library, the `public_key_credential_creation_options` will need to be converted to a suitable public key by unmarshalling the JSON, base64 decoding the user ID field, and converting user ID and the challenge fields into an array buffer.
Initiate the process of creating a new WebAuthn registration. After calling this endpoint, the browser will need to call [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) with the data from [public_key_credential_creation_options](https://w3c.github.io/webauthn/#dictionary-makecredentialoptions) passed to the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) request via the public key argument. We recommend using the `create()` wrapper provided by the webauthn-json library.
def register_start( user_id:, domain:, user_agent: nil, authenticator_type: nil ) request = { user_id: user_id, domain: domain } request[:user_agent] = user_agent unless user_agent.nil? request[:authenticator_type] = authenticator_type unless authenticator_type.nil? post_request('/v1/webauthn/register/start', request) end