Skip to content

Commit

Permalink
Merge pull request #30 from deibertf/1.x
Browse files Browse the repository at this point in the history
Update webauthn.js to prevent wrong request urls
  • Loading branch information
DarkGhostHunter authored Feb 16, 2023
2 parents 3291c57 + 73502ce commit 2e420ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion resources/js/webauthn.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ class WebAuthn {
* @returns {Promise<Response>}
*/
#fetch(data, route, headers = {}) {
return fetch(route, {
const url = new URL(route, window.location.origin).href;

return fetch(url, {
method: "POST",
credentials: this.#includeCredentials ? "include" : "same-origin",
redirect: "error",
Expand Down Expand Up @@ -313,6 +315,7 @@ class WebAuthn {
const publicKeyCredential = this.#parseOutgoingCredentials(credentials);

Object.assign(publicKeyCredential, response);
Object.assign(publicKeyCredential, request);

return await this.#fetch(publicKeyCredential, this.#routes.register).then(WebAuthn.#handleResponse);
}
Expand Down

0 comments on commit 2e420ba

Please sign in to comment.