Skip to content

Commit

Permalink
Get webauthn working again with importmap
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Jan 26, 2024
1 parent f0d06f4 commit 85de9b0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 29 deletions.
2 changes: 2 additions & 0 deletions app/javascript/controllers/webauthn_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Controller } from "@hotwired/stimulus"
import $ from "jquery"
import { bufferToBase64url, base64urlToBuffer } from "webauthn-json"

export default class extends Controller {
connect() {
Expand Down
23 changes: 0 additions & 23 deletions app/javascript/handle_click.js

This file was deleted.

4 changes: 0 additions & 4 deletions app/javascript/jquery_tmp.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/multifactor_auths/_webauthn_prompt.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="t-body">
<p><%= t("multifactor_auths.prompt.webauthn_credential_note") %></p>
</div>
<%= form_tag @webauthn_verification_url, method: :post, class: "js-webauthn-session--form", data: { options: @webauthn_options.to_json } do %>
<%= form_tag @webauthn_verification_url, method: :post, class: "js-webauthn-session--form", data: { controller: "webauthn", options: @webauthn_options.to_json } do %>
<div class="form_bottom">
<p hidden class="l-text-red-600 js-webauthn-session--error"></p>

Expand Down
2 changes: 1 addition & 1 deletion app/views/webauthn_verifications/prompt.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<p><%= t("settings.edit.webauthn_credential_note") %></p>
</div>

<%= form_tag @webauthn_verification_url, method: :post, class: "js-webauthn-session-cli--form", data: { options: @webauthn_options.to_json } do %>
<%= form_tag @webauthn_verification_url, method: :post, class: "js-webauthn-session-cli--form", data: { controller: "webauthn", options: @webauthn_options.to_json } do %>
<div class="form_bottom">
<p hidden class="l-text-red-600 js-webauthn-session-cli--error"></p>

Expand Down
6 changes: 6 additions & 0 deletions vendor/javascript/webauthn-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ var bufferToBase64url = function (buffer) {
.replace(/=/g, "")
return base64urlString
}

// This is a modified version that adds these exports:
export {
base64urlToBuffer,
bufferToBase64url
}

0 comments on commit 85de9b0

Please sign in to comment.