add README.md
authorJustin Wind <justin.wind+git@gmail.com>
Sat, 9 Mar 2024 00:42:15 +0000 (16:42 -0800)
committerJustin Wind <justin.wind+git@gmail.com>
Sat, 9 Mar 2024 00:42:15 +0000 (16:42 -0800)
README.md [new file with mode: 0644]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..98ceeb9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,24 @@
+# @squeep/totp
+
+Simple helpers for dealing with One-Time Passwords.
+
+## API
+
+```javascript
+const { TOTP } = require('@squeep/totp');
+
+const key = await TOTP.createKey(); // defaults create a hex-encoded sha1 key
+
+const {
+  secret, // key encoded as base32
+  uri, // key and metadata encoded as an otpauth URI
+  svg, // otpauthg URI encoded as QR code
+} = TOTP.createKeySVG({ accountname: 'test@example.com', issuer: 'Squeep', }, key, 'hex');
+
+const totp = new TOTP({
+  key,
+  keyEncoding: 'hex',
+});
+
+const token = totp.generate(); // The current token for the key.
+```