Skip to content

Commit aeb1938

Browse files
authored
feat: passkey support (#315)
* feat: add onload js setup * chore: bump ory elements
1 parent d45c7f1 commit aeb1938

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"prettier": "ory-prettier-styles",
2929
"dependencies": {
3030
"@ory/client": "1.2.10",
31-
"@ory/elements-markup": "0.1.0-beta.14",
31+
"@ory/elements-markup": "0.1.0-beta.15",
3232
"@ory/integrations": "1.1.5",
3333
"accept-language-parser": "1.5.0",
3434
"axios": "1.2.6",

views/login.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{{{card}}}
33

44
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_login_trigger"}}
5+
{{> js_setup nodes=nodes}}
56
{{#if extraPartial }}
67
{{> (extraPartial) }}
78
{{/if}}

views/partials/js_setup.hbs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{! This partial sets up the onclick and onload event handlers for each passkey node.}}
2+
<script type="text/javascript">
3+
// register onclick and onload event handlers for each passkey node.
4+
window.addEventListener("load", () => {
5+
{{#each (onlyNodes nodes "passkey" "")}}
6+
{{#if attributes.onclick}}
7+
// onclick for {{attributes.name}}
8+
document.getElementsByName("{{attributes.name}}").forEach((el) => {
9+
el.addEventListener("click", () => { {{{attributes.onclick}}} })
10+
})
11+
{{/if}}
12+
{{#if attributes.onload}}
13+
// onload for {{attributes.name}}
14+
{{{attributes.onload}}}
15+
{{/if}}
16+
{{/each}}
17+
})
18+
</script>

views/registration.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{{{card}}}
44

55
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
6+
{{> js_setup nodes=nodes}}
67
{{#if extraPartial }}
78
{{> (extraPartial) }}
89
{{/if}}

views/settings.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
</div>
66

77
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
8-
8+
{{> js_setup nodes=nodes}}
99
</div>

0 commit comments

Comments
 (0)