This file contains hidden or 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 email_detector_ruleset = ruleset([ | |
// Inputs that could be email fields: | |
rule(dom("input[type=text],input[type=\"\"],input:not([type])").when(isVisible), type("email")), | |
// Look for exact matches of "email"-like keywords in some attributes of the <input> | |
rule( | |
type("email"), | |
score(fnode => attrsMatch(fnode.element, ["id", "name", "autocomplete"], emailRegexMatchLine)), | |
{name: "inputAttrsMatchEmailExactly"} | |
), |
This file contains hidden or 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 enLocaleArgs = { | |
hash: args.hash, data: {root: {req: {supportedLocales: ["en"]} } }, | |
}; | |
const bannerOpeningDivDataset = microSurveyResponseIds.reduce((datasetStr, id) => { | |
datasetStr + `data-${id}-translated="${getString(id, args)}" data-${id}-english="${getString(id, enLocaleArgs)}" `; | |
console.log(`datasetStr: ${datasetStr}`); | |
return datasetStr; | |
}); |
This file contains hidden or 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
def time_if_enabled(func): | |
def timing_decorator(name): | |
def func_wrapper(name): | |
ctx_manager = (request.timings(name) if settings.STATSD_ENABLED | |
else contextlib.suppress()) | |
with ctx_manager: | |
func() | |
return func_wrapper | |
return timing_decorator |
This file contains hidden or 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
import requests | |
from django.apps import AppConfig | |
from django.conf import settings | |
class PrivateRelayConfig(AppConfig): | |
name = 'privaterelay' | |
def __init__(self, app_name, app_module): |
This file contains hidden or 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
import requests | |
from jwt import jwk_from_dict | |
from django.apps import AppConfig | |
from django.conf import settings | |
class PrivateRelayConfig(AppConfig): | |
name = 'privaterelay' |
This file contains hidden or 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
logger.info({ | |
'event_type': 'email_relay', | |
'relay_address_id': relay_address.id, | |
'relay_address': sha256(local_portion.encode('utf-8')).hexdigest(), | |
'real_address': sha256( | |
relay_address.user.email.encode('utf-8') | |
).hexdigest(), | |
}) |
This file contains hidden or 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
if (AppConstants.NODE_ENV === "dev") { | |
knex.on("query", async (queryData) => { | |
debugger; | |
console.log(queryData); | |
}); | |
knex.on("query-response", async (response, obj, builder) => { | |
debugger; | |
const explainSql = `EXPLAIN VERBOSE ${builder}`; | |
const res = await knex.raw(explainSql); | |
}); |
This file contains hidden or 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 crypto = require("crypto"); | |
const express = require("express"); | |
const app = express(); | |
const port = 3000; | |
app.get("/browser/oauth/state", (req, res) => { | |
console.log("state token request"); | |
const state = crypto.randomBytes(32).toString("hex"); | |
res.status(201).json({ |
This file contains hidden or 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
// Helps handle errors for all async route controllers | |
// See https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 | |
function asyncMiddleware (fn) { | |
return (req, res, next) => { | |
Promise.resolve(fn(req, res, next)).catch(next); | |
}; | |
} |
NewerOlder