summaryrefslogtreecommitdiffhomepage
path: root/example/example-server.d.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-11-16 21:21:28 -0800
committerGitHub <noreply@github.com>2020-11-16 21:21:28 -0800
commit0f0a2d9b85ca549f3ebcb8cc4678085779dbf92c (patch)
tree8d03baba70c4969118647c361882c76443b114f9 /example/example-server.d.ts
parent79b8188f5a7dab3dc70234e20216cd3b24267c9a (diff)
parent5a05e786ced984f9b41a791cfa7d734d7a5b21e5 (diff)
Merge pull request #71 from MasterKale/feat/port-example-to-ts
feat/port-example-to-ts
Diffstat (limited to 'example/example-server.d.ts')
-rw-r--r--example/example-server.d.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/example/example-server.d.ts b/example/example-server.d.ts
new file mode 100644
index 0000000..6d1dfb8
--- /dev/null
+++ b/example/example-server.d.ts
@@ -0,0 +1,39 @@
+import type { AuthenticatorDevice } from '@simplewebauthn/typescript-types';
+
+/**
+ * You'll need a database to store a few things:
+ *
+ * 1. Users
+ *
+ * You'll need to be able to associate attestation and assertions challenges, and authenticators to
+ * a specific user. See `LoggedInUser` below for an idea of the minimum amount of info you'll need to
+ * track for a specific user during these flows.
+ *
+ * 2. Challenges
+ *
+ * The totally-random-unique-every-time values you pass into every execution of
+ * `generateAttestationOptions()` or `generateAssertionOptions()` MUST be stored until
+ * `verifyAttestationResponse()` or `verifyAssertionResponse()` (respectively) is called to verify
+ * that the response contains the signed challenge.
+ *
+ * These values only need to be persisted for `timeout` number of milliseconds (see the `generate`
+ * methods and their optional `timeout` parameter)
+ *
+ * 3. Authenticator Devices
+ *
+ * After an attestation, you'll need to store three things about the authenticator:
+ *
+ * - Base64-encoded "Credential ID" (varchar)
+ * - Base64-encoded "Public Key" (varchar)
+ * - Counter (int)
+ *
+ * Each authenticator must also be associated to a user so that you can generate a list of
+ * authenticator credential IDs to pass into `generateAssertionOptions()`, from which one is
+ * expected to generate an assertion response.
+ */
+interface LoggedInUser {
+ id: string;
+ username: string;
+ devices: AuthenticatorDevice[];
+ currentChallenge?: string;
+}