Skip to content

Commit f1432e7

Browse files
authored
Event dispatch payloads for WebAuthn failure cases (#675)
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.
1 parent 281025e commit f1432e7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/stimulus/assets/dist/controller.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class default_1 extends Controller {
4747
}
4848
}
4949
catch (e) {
50-
this._dispatchEvent('webauthn:assertion:failure', {exception: e});
50+
this._dispatchEvent('webauthn:assertion:failure', { exception: e, assertionResponse: null });
5151
return;
5252
}
5353
}
@@ -70,7 +70,7 @@ class default_1 extends Controller {
7070
}
7171
}
7272
catch (e) {
73-
this._dispatchEvent('webauthn:attestation:failure', {exception: e});
73+
this._dispatchEvent('webauthn:attestation:failure', { exception: e, assertionResponse: null });
7474
return;
7575
}
7676
}
@@ -120,7 +120,7 @@ class default_1 extends Controller {
120120
body: JSON.stringify(data)
121121
});
122122
if (!optionsResponse.ok) {
123-
this._dispatchEvent('webauthn:options:failure', {});
123+
this._dispatchEvent('webauthn:options:failure', { exception: null, optionsResponse });
124124
return false;
125125
}
126126
const options = await optionsResponse.json();

src/stimulus/assets/src/controller.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class extends Controller {
9191
window.location.replace(this.requestSuccessRedirectUriValue);
9292
}
9393
} catch (e) {
94-
this._dispatchEvent('webauthn:assertion:failure', {exception: e});
94+
this._dispatchEvent('webauthn:assertion:failure', {exception: e, assertionResponse: null});
9595
return;
9696
}
9797
}
@@ -117,7 +117,7 @@ export default class extends Controller {
117117
window.location.replace(this.creationSuccessRedirectUriValue);
118118
}
119119
} catch (e) {
120-
this._dispatchEvent('webauthn:attestation:failure', {exception: e});
120+
this._dispatchEvent('webauthn:attestation:failure', {exception: e, assertionResponse: null});
121121
return;
122122
}
123123
}
@@ -178,7 +178,7 @@ export default class extends Controller {
178178
body: JSON.stringify(data)
179179
});
180180
if (!optionsResponse.ok) {
181-
this._dispatchEvent('webauthn:options:failure', {});
181+
this._dispatchEvent('webauthn:options:failure', {exception: null, optionsResponse});
182182
return false;
183183
}
184184

0 commit comments

Comments
 (0)