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
14 changes: 8 additions & 6 deletions app/javascript/credential.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as WebAuthnJSON from "@github/webauthn-json"

function getCSRFToken() {
var CSRFSelector = document.querySelector('meta[name="csrf-token"]')
if (CSRFSelector) {
Expand Down Expand Up @@ -30,8 +28,10 @@ function callback(url, body) {
});
}

function create(callbackUrl, credentialOptions) {
WebAuthnJSON.create({ "publicKey": credentialOptions }).then(function(credential) {
function create(callbackUrl, data) {
const credentialOptions = PublicKeyCredential.parseCreationOptionsFromJSON(data);

navigator.credentials.create({ "publicKey": credentialOptions }).then(function(credential) {
callback(callbackUrl, credential);
}).catch(function(error) {
console.log(error);
Expand All @@ -40,8 +40,10 @@ function create(callbackUrl, credentialOptions) {
console.log("Creating new public key credential...");
}

function get(credentialOptions) {
WebAuthnJSON.get({ "publicKey": credentialOptions }).then(function(credential) {
function get(data) {
const credentialOptions = PublicKeyCredential.parseRequestOptionsFromJSON(data);

navigator.credentials.get({ "publicKey": credentialOptions }).then(function(credential) {
callback("/webauthn_credential_authentication", credential);
}).catch(function(error) {
console.log(error);
Expand Down
2 changes: 0 additions & 2 deletions config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@

pin "@rails/ujs", to: "@rails--ujs.js" # @6.0.2

pin "@github/webauthn-json", to: "@github--webauthn-json.js" # @2.1.1

pin "@material/menu", to: "@material--menu.js" # @4.0.0
pin "@material/textfield", to: "@material--textfield.js" # @4.0.0
4 changes: 0 additions & 4 deletions vendor/javascript/@github--webauthn-json.js

This file was deleted.