Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Add support for crossOrigin/topOrigin verification during credential registration and authentication. [#486](https://github.com/cedarcode/webauthn-ruby/pull/486) [@nicolastemciuc]
- Add support for the `hints` option in `WebAuthn::Credential.options_for_create` and `WebAuthn::Credential.options_for_get`. [#513](https://github.com/cedarcode/webauthn-ruby/pull/513) [@santiagorodriguez96]

## [v3.4.3](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.2...v3.4.3/) - 2025-10-23

Expand Down
7 changes: 4 additions & 3 deletions lib/webauthn/public_key_credential/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ class Options

CHALLENGE_LENGTH = 32

attr_reader :timeout, :extensions, :relying_party
attr_reader :timeout, :extensions, :hints, :relying_party

def initialize(timeout: nil, extensions: nil, relying_party: WebAuthn.configuration.relying_party)
def initialize(timeout: nil, extensions: nil, hints: nil, relying_party: WebAuthn.configuration.relying_party)
@relying_party = relying_party
@timeout = timeout || default_timeout
@extensions = default_extensions.merge(extensions || {})
@hints = hints
end

def challenge
Expand All @@ -24,7 +25,7 @@ def challenge
private

def attributes
[:challenge, :timeout, :extensions]
[:challenge, :timeout, :extensions, :hints]
end

def encoder
Expand Down
3 changes: 3 additions & 0 deletions spec/webauthn/public_key_credential/creation_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
user_verification: "required"
},
attestation: "direct",
hints: ["security-key", "hybrid"],
extensions: { whatever: "whatever" },
)

Expand All @@ -126,6 +127,7 @@
authenticatorAttachment: "cross-platform", residentKey: "required", userVerification: "required"
)
expect(hash[:attestation]).to eq("direct")
expect(hash[:hints]).to eq(["security-key", "hybrid"])
expect(hash[:extensions]).to eq(whatever: "whatever")
expect(hash[:challenge]).to be_truthy
end
Expand Down Expand Up @@ -153,6 +155,7 @@
expect(hash).not_to have_key(:excludeCredentials)
expect(hash).not_to have_key(:authenticatorSelection)
expect(hash).not_to have_key(:attestation)
expect(hash).not_to have_key(:hints)
end

it "accepts shorthand for exclude_credentials" do
Expand Down
3 changes: 3 additions & 0 deletions spec/webauthn/public_key_credential/request_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
timeout: 10_000,
allow_credentials: [{ type: "public-key", id: "credential-id", transports: ["usb", "nfc"] }],
user_verification: "required",
hints: ["client-device"],
extensions: { whatever: "whatever" },
)

Expand All @@ -63,6 +64,7 @@
expect(hash[:timeout]).to eq(10_000)
expect(hash[:allowCredentials]).to eq([{ type: "public-key", id: "credential-id", transports: ["usb", "nfc"] }])
expect(hash[:userVerification]).to eq("required")
expect(hash[:hints]).to eq(["client-device"])
expect(hash[:extensions]).to eq(whatever: "whatever")
expect(hash[:challenge]).to be_truthy
end
Expand All @@ -78,6 +80,7 @@
expect(hash[:challenge]).to be_truthy
expect(hash).not_to have_key(:userVerification)
expect(hash).not_to have_key(:rpId)
expect(hash).not_to have_key(:hints)
end

it "accepts shorthand for allow_credentials" do
Expand Down
Loading