File tree Expand file tree Collapse file tree
spec/internal/app/javascript/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ import { Controller } from "@hotwired/stimulus"
33export default class extends Controller {
44 static targets = [ "credentialHiddenInput" ]
55
6- async create ( { params : { options } } ) {
6+ async create ( { params : { optionsUrl } } ) {
77 try {
8- const credentialOptions = PublicKeyCredential . parseCreationOptionsFromJSON ( options ) ;
8+ const response = await fetch ( optionsUrl ) ;
9+
10+ const credentialOptions = PublicKeyCredential . parseCreationOptionsFromJSON ( await response . json ( ) ) ;
911 const credential = await navigator . credentials . create ( { publicKey : credentialOptions } ) ;
1012
1113 this . credentialHiddenInputTarget . value = JSON . stringify ( credential ) ;
@@ -16,9 +18,11 @@ export default class extends Controller {
1618 }
1719 }
1820
19- async get ( { params : { options } } ) {
21+ async get ( { params : { optionsUrl } } ) {
2022 try {
21- const credentialOptions = PublicKeyCredential . parseRequestOptionsFromJSON ( options ) ;
23+ const response = await fetch ( optionsUrl ) ;
24+
25+ const credentialOptions = PublicKeyCredential . parseRequestOptionsFromJSON ( await response . json ( ) ) ;
2226 const credential = await navigator . credentials . get ( { publicKey : credentialOptions } ) ;
2327
2428 this . credentialHiddenInputTarget . value = JSON . stringify ( credential ) ;
You can’t perform that action at this time.
0 commit comments