Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ session[:creation_challenge] = options.challenge
# If inside a Rails controller, `render json: options` will just work.
# I.e. it will encode and convert the options to JSON automatically.

# For your frontend code, you might find @github/webauthn-json npm package useful.
# Especially for handling the necessary decoding of the options, and sending the
# `PublicKeyCredential` object back to the server.
# For your frontend code, you might find the [built-in browser methods](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential) useful.
# The built-in `PublicKeyCredential.parseCreationOptionsFromJSON(options)` allows you to decode the options,
# and the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back to the server.
```

#### Verification phase

```ruby
# Assuming you're using @github/webauthn-json package to send the `PublicKeyCredential` object back
# Assuming you're using the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back
# in params[:publicKeyCredential]:
webauthn_credential = WebAuthn::Credential.from_create(params[:publicKeyCredential])

Expand Down Expand Up @@ -238,9 +238,9 @@ session[:authentication_challenge] = options.challenge
# If inside a Rails controller, `render json: options` will just work.
# I.e. it will encode and convert the options to JSON automatically.

# For your frontend code, you might find @github/webauthn-json npm package useful.
# Especially for handling the necessary decoding of the options, and sending the
# `PublicKeyCredential` object back to the server.
# For your frontend code, you might find the [built-in browser methods](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential) useful.
# The built-in `PublicKeyCredential.parseRequestOptionsFromJSON(options)` allows you to decode the options,
# and the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back to the server.
```

#### Verification phase
Expand All @@ -250,7 +250,7 @@ interface returned by the browser to the stored `credential_id`. The correspondi
attributes must be passed as keyword arguments to the `verify` method call.

```ruby
# Assuming you're using @github/webauthn-json package to send the `PublicKeyCredential` object back
# Assuming you're using the built-in `credential.toJSON()` to send the `PublicKeyCredential` object back
# in params[:publicKeyCredential]:
webauthn_credential = WebAuthn::Credential.from_get(params[:publicKeyCredential])

Expand Down
Loading