diff options
Diffstat (limited to 'example/index.js')
-rw-r--r-- | example/index.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/example/index.js b/example/index.js index 574bd8c..2c274e1 100644 --- a/example/index.js +++ b/example/index.js @@ -1,4 +1,6 @@ -const path = require('path'); +const https = require('https'); +const fs = require('fs'); + const express = require('express'); const { @@ -12,26 +14,26 @@ const { const app = express(); const host = '0.0.0.0'; -const port = 80; +const port = 443; app.use(express.static('./public/')); app.use(express.json()); // Domain where the WebAuthn interactions are expected to occur -const origin = 'dev.millerti.me:3000'; +const origin = 'dev.dontneeda.pw'; // GENERATE A NEW VALUE FOR THIS EVERY TIME! The server needs to temporarily remember this value, // so don't lose it until after you verify const randomChallenge = 'totallyUniqueValueEveryTime'; // Your internal, _unique_ ID for the user (uuid, etc...). Avoid using identifying information here, // like an email address -const userId = 'internalUserId'; +const userId = 'webauthntineInternalUserId'; // A username for the user const username = 'user@webauthntine.foo'; app.get('/generate-attestation-options', (req, res) => { res.send(generateAttestationOptions( 'WebAuthntine Example', - 'dev.millerti.me:3000', + origin, randomChallenge, userId, username, @@ -42,6 +44,9 @@ app.post('/verify-registration', (req, res) => { const { body } = req; }); -app.listen(port, host, () => { - console.log(`🚀 Server ready at http://${host}:${port}`); +https.createServer({ + key: fs.readFileSync('./dev.dontneeda.pw.key'), + cert: fs.readFileSync('./dev.dontneeda.pw.crt'), +}, app).listen(port, host, () => { + console.log(`🚀 Server ready at https://${host}:${port}`); }); |