This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
........ | |
router.post("/response", async (req, res, next) => { | |
if ( | |
!req.body || | |
!req.body.id || | |
!req.body.rawId || | |
!req.body.response || | |
!req.body.type || | |
req.body.type !== "public-key" | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const router = express.Router(); | |
const webauthnTools = require("./tools"); | |
const base64url = require("base64url"); | |
const { User } = require("../../model/users"); | |
router.post("/", async (req, res, next) => { | |
const name = req.user.name; | |
const username = req.user.email; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get("/", (req, res) => { | |
getPerson(req.query.name).then(data => res.json(data)); | |
}); | |
// The Async below: | |
app.get("/", async (req, res) => { | |
let data = await getPerson(req.query.name); | |
res.json(data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.sub = (pubSubEvent, context) => { | |
return new Promise(function(resolve, reject) { | |
processMsg(msgTxt) | |
.then(result => { | |
save(result) | |
.then(data => { | |
sendPub(data) | |
.then(() => { | |
return resolve(); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.sub = async (pubSubEvent, context) => { | |
try { | |
let result = await processMsg(msgTxt); | |
let data = await save(result); | |
await sendPub(data); | |
} catch (err) { | |
console.error(err); | |
return reject(err); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require("mongoose"); | |
const uri = "DB_URI"; | |
mongoose | |
.connect(uri, { useNewUrlParser: true }) | |
.then(() => { | |
console.log("connected"); | |
}) | |
.then(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
challenge: randomBase64URLBuffer(32), | |
rp: { | |
name: "YOUR WEB APP NAME" | |
}, | |
user: { | |
id: id, | |
name: username, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const crypto = require("crypto"); | |
const base64url = require("base64url"); | |
const cbor = require("cbor"); | |
const { Certificate } = require("@fidm/x509"); | |
const iso_3166_1 = require("iso-3166-1"); | |
/** | |
* U2F Presence constant | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NODE_ENV=dev | |
DB_URL="YOUR_MONGODB_LINK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webauthnSchema = new Schema({ | |
active: { default: false, type: Boolean, required: true }, | |
authenticators: [], | |
id: { type: String, required: false } | |
}); | |
const userSchema = new Schema({ | |
username: { type: String, required: true }, | |
name: { type: String, required: true }, | |
email: { type: String, required: true }, |
NewerOlder