Skip to content

Commit

Permalink
Event dispatch payloads for WebAuthn failure cases (#675)
Browse files Browse the repository at this point in the history
Update failure event payloads to include additional context, such as `assertionResponse` or `optionsResponse`, improving error handling consistency. This ensures downstream handlers have access to more detailed information during WebAuthn failures.
  • Loading branch information
Spomky authored Jan 18, 2025
1 parent 281025e commit f1432e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/stimulus/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class default_1 extends Controller {
}
}
catch (e) {
this._dispatchEvent('webauthn:assertion:failure', {exception: e});
this._dispatchEvent('webauthn:assertion:failure', { exception: e, assertionResponse: null });
return;
}
}
Expand All @@ -70,7 +70,7 @@ class default_1 extends Controller {
}
}
catch (e) {
this._dispatchEvent('webauthn:attestation:failure', {exception: e});
this._dispatchEvent('webauthn:attestation:failure', { exception: e, assertionResponse: null });
return;
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ class default_1 extends Controller {
body: JSON.stringify(data)
});
if (!optionsResponse.ok) {
this._dispatchEvent('webauthn:options:failure', {});
this._dispatchEvent('webauthn:options:failure', { exception: null, optionsResponse });
return false;
}
const options = await optionsResponse.json();
Expand Down
6 changes: 3 additions & 3 deletions src/stimulus/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class extends Controller {
window.location.replace(this.requestSuccessRedirectUriValue);
}
} catch (e) {
this._dispatchEvent('webauthn:assertion:failure', {exception: e});
this._dispatchEvent('webauthn:assertion:failure', {exception: e, assertionResponse: null});
return;
}
}
Expand All @@ -117,7 +117,7 @@ export default class extends Controller {
window.location.replace(this.creationSuccessRedirectUriValue);
}
} catch (e) {
this._dispatchEvent('webauthn:attestation:failure', {exception: e});
this._dispatchEvent('webauthn:attestation:failure', {exception: e, assertionResponse: null});
return;
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ export default class extends Controller {
body: JSON.stringify(data)
});
if (!optionsResponse.ok) {
this._dispatchEvent('webauthn:options:failure', {});
this._dispatchEvent('webauthn:options:failure', {exception: null, optionsResponse});
return false;
}

Expand Down

0 comments on commit f1432e7

Please # to comment.