const Passport = require("passport");
const jwt = require("passport-jwt");
function cookieExtractor(req) {
if (req && req.cookies) return req.cookies["token"];
return null;
}
passport = Passport.use(
new jwt.Strategy(
{
jwtFromRequest: jwt.ExtractJwt.fromExtractors([
jwt.ExtractJwt.fromAuthHeaderAsBearerToken(),
cookieExtractor
]),
secretOrKey: config.jwt
},
async (payload, next) => {
const { username } = payload;
try {
next(null, await db.User.findOne({ where: { username } }));
} catch (e) {
l.error("error finding user for session", e);
next(null, { username: "guest" });
}
}
)
);
auth = passport.authenticate("jwt", { session: false });
app.use(passport.initialize());
m method='get'>
blob: bec6ebc602e9ab6547e947e556666aff056c885b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
BitcoinCore = require("bitcoin-core");
fs = require("fs");
config = require("./config");
bc = new BitcoinCore(config.bitcoin);
l = require("pino")();
require("./db");
console.log(db.Payment);
(async () => {
payments = (
await db.Payment.findAll({
attributes: ["hash"],
})
).map((p) => p.hash);
const transactions = await bc.listTransactions("*", 1000);
var stream = fs.createWriteStream("exceptions", {
flags: "a",
emitClose: true,
});
transactions.map((tx) => {
if (!payments.includes(tx.txid)) {
l.info("writing", tx.txid);
stream.write(tx.txid + "\n");
}
});
stream.end();
stream.on("close", () => {
l.info("done");
process.exit();
});
})();
|