@@ -20,14 +20,20 @@ npm install --save @github/webauthn-json
20
20
Then:
21
21
22
22
``` typescript
23
- import { create } from " @github/webauthn-json" ;
23
+ import {
24
+ create ,
25
+ parseCreationOptionsFromJSON ,
26
+ } from " @github/webauthn-json/browser-ponyfill" ;
24
27
25
28
const request = fetch (" ..." );
26
- async createCredential () {
27
- const response = await create ((await request ).json ());
28
- await fetch (" ..." , {
29
+
30
+ async function createCredential() {
31
+ const json = await (await request ).json ();
32
+ const options = parseCreationOptionsFromJSON (json );
33
+ const response = await create (options );
34
+ fetch (" ..." , {
29
35
method: " POST" ,
30
- body: JSON .stringify (response )
36
+ body: JSON .stringify (response . toJSON ()),
31
37
});
32
38
}
33
39
```
@@ -46,11 +52,11 @@ function supported(): boolean;
46
52
function parseCreationOptionsFromJSON(json : JSON ): CredentialCreationOptions ;
47
53
function parseRequestOptionsFromJSON(json : JSON ): CredentialRequestOptions ;
48
54
49
- // Can call `.toJSON()` on the result.
55
+ // You can call `.toJSON()` on the result.
50
56
function create(
51
57
options : CredentialCreationOptions ,
52
58
): Promise <PublicKeyCredential >;
53
- // Can call `.toJSON()` on the result.
59
+ // You can call `.toJSON()` on the result.
54
60
function get(options : CredentialRequestOptions ): Promise <PublicKeyCredential >;
55
61
```
56
62
0 commit comments