|
1 | 1 | # SnapAuth TypeScript/JavaScript SDK
|
2 | 2 |
|
3 |
| -The official TS/JS SDK for SnapAuth 🫰 |
| 3 | +This is the official TS/JS SDK for [SnapAuth](https://www.snapauth.app/?utm_source=GitHub&utm_campaign=sdk&utm_content=sdk-typescript). |
| 4 | + |
| 5 | +SnapAuth will let you add passkey support to your web (and native) app in a snap! |
| 6 | +Add strong multi-factor authentication or go fully passwordless while maintaining a great, frictionless user experience. |
4 | 7 |
|
5 | 8 | This is for _client_ code.
|
6 | 9 | If you're looking for the _server_ integration, check out [`@snapauth/node-sdk`](https://github.com/snapauthapp/sdk-node).
|
7 | 10 |
|
| 11 | +[SnapAuth Homepage](https://www.snapauth.app?utm_source=GitHub&utm_campaign=sdk&utm_content=sdk-typescript) |
| 12 | +| [SnapAuth Docs](https://docs.snapauth.app) |
| 13 | +| [Dashboard](https://dashboard.snapauth.app) |
| 14 | +| [Github](https://github.com/snapauthapp/sdk-typescript) |
| 15 | +| [NPM](https://www.npmjs.com/package/@snapauth/sdk) |
| 16 | + |
| 17 | +[](https://github.com/snapauthapp/sdk-typescript/releases) |
| 18 | +[](https://github.com/snapauthapp/sdk-typescript/actions/workflows/test.yml) |
| 19 | + |
| 20 | + |
8 | 21 | [](https://www.npmjs.com/package/@snapauth/sdk)
|
9 | 22 | 
|
10 | 23 | 
|
11 |
| - |
12 | 24 |
|
13 |
| -- [SnapAuth Homepage](https://www.snapauth.app) |
14 |
| -- [Docs](https://docs.snapauth.app) |
15 |
| -- [Dashboard](https://dashboard.snapauth.app) |
16 |
| -- [Github](https://github.com/snapauthapp/sdk-typescript) |
17 | 25 |
|
18 | 26 | ## Installation and Setup
|
19 | 27 | ### Node
|
@@ -53,32 +61,32 @@ Browsers will ignore most WebAuthn requests that are not in response to a user g
|
53 | 61 |
|
54 | 62 | ```typescript
|
55 | 63 | // Get `name` from a field in your UI, your backend, etc.
|
56 |
| -// This is what the user will see when authenticating |
| 64 | +// This should be what the user signs in with, such as a username or email address |
57 | 65 | const registration = await snapAuth.startRegister({ name })
|
58 | 66 | if (registration.ok) {
|
59 | 67 | const token = registration.data.token
|
60 |
| - // Send token to your backend to use the /registration/attach API |
| 68 | + // Send token to your backend to use the /credential/create API |
61 | 69 | } else {
|
62 | 70 | // Inspect registration.error and decide how best to proceed
|
63 | 71 | }
|
64 | 72 | ```
|
65 | 73 |
|
66 | 74 | > [!IMPORTANT]
|
67 |
| -> You MUST send the token to the backend [`/registration/attach`](https://docs.snapauth.app/server.html#attach-registration-token) API to associate it with the user. |
| 75 | +> You MUST send the token to the backend [`/credential/create`](https://docs.snapauth.app/server.html#create-a-credential) API to associate it with the user. |
68 | 76 | > Until this is done, the user will not be able to use their new credential.
|
69 | 77 | >
|
70 | 78 | > For security, the token expires in a few minutes.
|
71 | 79 | > The response includes a `expiresAt` field indicating when this needs to be done.
|
72 | 80 |
|
73 | 81 | The `name` value is used completely locally, and _is not sent to SnapAuth's servers_.
|
74 |
| -This is commonly something like a human name, email address, or login handle. |
75 |
| -This will be visible to the user when they sign in. |
| 82 | +This is should be a login handle such as a username or email address. |
| 83 | + |
| 84 | +You may also set `displayName`, though browsers typically (counter-intuitively) ignore `displayName` in favor of `name`. |
76 | 85 |
|
77 | 86 | > [!WARNING]
|
78 | 87 | > The `name` field cannot be changed at this time - it's not supported by browsers.
|
79 | 88 | > Once browser APIs exist to modify it, we will add support to the SDK.
|
80 |
| -
|
81 |
| -You may also set `displayName`, though browsers typically (counter-intuitively) ignore `displayName` in favor of `name`. |
| 89 | +> See [#40](https://github.com/snapauthapp/sdk-typescript/issues/40) for details. |
82 | 90 |
|
83 | 91 |
|
84 | 92 | ### Authenticating
|
|
0 commit comments