From b7582e54efdac5cb435eb4810c08b611c58c1a40 Mon Sep 17 00:00:00 2001 From: Santiago Rodriguez <46354312+santiagorodriguez96@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:55:53 -0300 Subject: [PATCH 1/2] build: remove deprecated `webauthn-json` dependency --- app/javascript/credential.js | 14 ++++++++------ config/importmap.rb | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/javascript/credential.js b/app/javascript/credential.js index dcb292e..2b07a89 100644 --- a/app/javascript/credential.js +++ b/app/javascript/credential.js @@ -1,5 +1,3 @@ -import * as WebAuthnJSON from "@github/webauthn-json" - function getCSRFToken() { var CSRFSelector = document.querySelector('meta[name="csrf-token"]') if (CSRFSelector) { @@ -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); @@ -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); diff --git a/config/importmap.rb b/config/importmap.rb index 1ed3103..4e184d7 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -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 From 04cbf1e97722ec01e4945ce32a26fc08d416101c Mon Sep 17 00:00:00 2001 From: Santiago Rodriguez <46354312+santiagorodriguez96@users.noreply.github.com> Date: Mon, 1 Dec 2025 18:33:34 -0300 Subject: [PATCH 2/2] build: remove vendored `webauthn-json` package --- vendor/javascript/@github--webauthn-json.js | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 vendor/javascript/@github--webauthn-json.js diff --git a/vendor/javascript/@github--webauthn-json.js b/vendor/javascript/@github--webauthn-json.js deleted file mode 100644 index d76e045..0000000 --- a/vendor/javascript/@github--webauthn-json.js +++ /dev/null @@ -1,4 +0,0 @@ -// @github/webauthn-json@2.1.1 downloaded from https://ga.jspm.io/npm:@github/webauthn-json@2.1.1/dist/esm/webauthn-json.js - -function base64urlToBuffer(e){const r="==".slice(0,(4-e.length%4)%4);const t=e.replace(/-/g,"+").replace(/_/g,"/")+r;const n=atob(t);const i=new ArrayBuffer(n.length);const o=new Uint8Array(i);for(let e=0;econvert(t,n[0],e)));if(n instanceof Object){const e={};for(const[r,o]of Object.entries(n)){if(o.derive){const e=o.derive(i);void 0!==e&&(i[r]=e)}if(r in i)null!=i[r]?e[r]=convert(t,o.schema,i[r]):e[r]=null;else if(o.required)throw new Error(`Missing key: ${r}`)}return e}}function derived(e,r){return{required:true,schema:e,derive:r}}function required(e){return{required:true,schema:e}}function optional(e){return{required:false,schema:e}}var t={type:required(e),id:required(r),transports:optional(e)};var n={appid:optional(e),appidExclude:optional(e),credProps:optional(e)};var i={appid:optional(e),appidExclude:optional(e),credProps:optional(e)};var o={publicKey:required({rp:required(e),user:required({id:required(r),name:required(e),displayName:required(e)}),challenge:required(r),pubKeyCredParams:required(e),timeout:optional(e),excludeCredentials:optional([t]),authenticatorSelection:optional(e),attestation:optional(e),extensions:optional(n)}),signal:optional(e)};var a={type:required(e),id:required(e),rawId:required(r),authenticatorAttachment:optional(e),response:required({clientDataJSON:required(r),attestationObject:required(r),transports:derived(e,(e=>{var r;return(null==(r=e.getTransports)?void 0:r.call(e))||[]}))}),clientExtensionResults:derived(i,(e=>e.getClientExtensionResults()))};var u={mediation:optional(e),publicKey:required({challenge:required(r),timeout:optional(e),rpId:optional(e),allowCredentials:optional([t]),userVerification:optional(e),extensions:optional(n)}),signal:optional(e)};var s={type:required(e),id:required(e),rawId:required(r),authenticatorAttachment:optional(e),response:required({clientDataJSON:required(r),authenticatorData:required(r),signature:required(r),userHandle:required(r)}),clientExtensionResults:derived(i,(e=>e.getClientExtensionResults()))};var c={credentialCreationOptions:o,publicKeyCredentialWithAttestation:a,credentialRequestOptions:u,publicKeyCredentialWithAssertion:s};function createRequestFromJSON(e){return convert(base64urlToBuffer,o,e)}function createResponseToJSON(e){return convert(bufferToBase64url,a,e)}async function create(e){const r=await navigator.credentials.create(createRequestFromJSON(e));return createResponseToJSON(r)}function getRequestFromJSON(e){return convert(base64urlToBuffer,u,e)}function getResponseToJSON(e){return convert(bufferToBase64url,s,e)}async function get(e){const r=await navigator.credentials.get(getRequestFromJSON(e));return getResponseToJSON(r)}function supported(){return!!(navigator.credentials&&navigator.credentials.create&&navigator.credentials.get&&window.PublicKeyCredential)}export{create,get,c as schema,supported}; -