code stringlengths 31 2.05k | label_name stringclasses 5
values | label int64 0 4 |
|---|---|---|
export const createBubbleIcon = ({ className, path, target }) => {
let bubbleClassName = `${className} woot-elements--${window.$chatwoot.position}`;
const bubbleIcon = document.createElementNS(
'http://www.w3.org/2000/svg',
'svg'
);
bubbleIcon.setAttributeNS(null, 'id', 'woot-widget-bubble-icon');
bub... | Base | 1 |
export const setBubbleText = bubbleText => {
if (isExpandedView(window.$chatwoot.type)) {
const textNode = document.getElementById('woot-widget--expanded__text');
textNode.innerHTML = bubbleText;
}
}; | Base | 1 |
export function defaultRenderTag(tag, params) {
// This file is in lib but it's used as a helper
let siteSettings = helperContext().siteSettings;
params = params || {};
const visibleName = escapeExpression(tag);
tag = visibleName.toLowerCase();
const classes = ["discourse-tag"];
const tagName = params.ta... | Base | 1 |
_saveDraft(channelId, draft) {
const data = { chat_channel_id: channelId };
if (draft) {
data.data = JSON.stringify(draft);
}
ajax("/chat/drafts", { type: "POST", data, ignoreUnsent: false })
.then(() => {
this.markNetworkAsReliable();
})
.catch((error) => {
if... | Base | 1 |
Auth.prototype.getRolesForUser = async function () {
//Stack all Parse.Role
const results = [];
if (this.config) {
const restWhere = {
users: {
__type: 'Pointer',
className: '_User',
objectId: this.user.id,
},
};
const RestQuery = require('./RestQuery');
await n... | Class | 2 |
var getAuthForLegacySessionToken = function ({ config, sessionToken, installationId }) {
var restOptions = {
limit: 1,
};
const RestQuery = require('./RestQuery');
var query = new RestQuery(config, master(config), '_User', { sessionToken }, restOptions);
return query.execute().then(response => {
var r... | Class | 2 |
const getAuthForSessionToken = async function ({
config,
cacheController,
sessionToken,
installationId,
}) {
cacheController = cacheController || (config && config.cacheController);
if (cacheController) {
const userJSON = await cacheController.user.get(sessionToken);
if (userJSON) {
const cach... | Class | 2 |
Auth.prototype.getRolesByIds = async function (ins) {
const results = [];
// Build an OR query across all parentRoles
if (!this.config) {
await new Parse.Query(Parse.Role)
.containedIn(
'roles',
ins.map(id => {
const role = new Parse.Object(Parse.Role);
role.id = id;
... | Class | 2 |
badgeUpdate = () => {
// Build a real RestQuery so we can use it in RestWrite
const restQuery = new RestQuery(config, master(config), '_Installation', updateWhere);
return restQuery.buildRestWhere().then(() => {
const write = new RestWrite(
config,
master(... | Class | 2 |
RestQuery.prototype.getUserAndRoleACL = function () {
if (this.auth.isMaster) {
return Promise.resolve();
}
this.findOptions.acl = ['*'];
if (this.auth.user) {
return this.auth.getUserRoles().then(roles => {
this.findOptions.acl = this.findOptions.acl.concat(roles, [this.auth.user.id]);
re... | Class | 2 |
RestQuery.prototype.denyProtectedFields = async function () {
if (this.auth.isMaster) {
return;
}
const schemaController = await this.config.database.loadSchema();
const protectedFields =
this.config.database.addProtectedFields(
schemaController,
this.className,
this.restWhere,
t... | Class | 2 |
RestQuery.prototype.handleAuthAdapters = async function () {
if (this.className !== '_User' || this.findOptions.explain) {
return;
}
await Promise.all(
this.response.results.map(result =>
this.config.authDataManager.runAfterFind(
{ config: this.config, auth: this.auth },
result.authD... | Class | 2 |
RestQuery.prototype.replaceDontSelect = function () {
var dontSelectObject = findObjectWithKey(this.restWhere, '$dontSelect');
if (!dontSelectObject) {
return;
}
// The dontSelect value must have precisely two keys - query and key
var dontSelectValue = dontSelectObject['$dontSelect'];
if (
!dontSel... | Class | 2 |
RestQuery.prototype.runCount = function () {
if (!this.doCount) {
return;
}
this.findOptions.count = true;
delete this.findOptions.skip;
delete this.findOptions.limit;
return this.config.database.find(this.className, this.restWhere, this.findOptions).then(c => {
this.response.count = c;
});
}; | Class | 2 |
RestQuery.prototype.handleIncludeAll = function () {
if (!this.includeAll) {
return;
}
return this.config.database
.loadSchema()
.then(schemaController => schemaController.getOneSchema(this.className))
.then(schema => {
const includeFields = [];
const keyFields = [];
for (const f... | Class | 2 |
RestQuery.prototype.redirectClassNameForKey = function () {
if (!this.redirectKey) {
return Promise.resolve();
}
// We need to change the class name based on the schema
return this.config.database
.redirectClassNameForKey(this.className, this.redirectKey)
.then(newClassName => {
this.classNam... | Class | 2 |
RestQuery.prototype.replaceSelect = function () {
var selectObject = findObjectWithKey(this.restWhere, '$select');
if (!selectObject) {
return;
}
// The select value must have precisely two keys - query and key
var selectValue = selectObject['$select'];
// iOS SDK don't send where if not set, let it pa... | Class | 2 |
RestQuery.prototype.each = function (callback) {
const { config, auth, className, restWhere, restOptions, clientSDK } = this;
// if the limit is set, use it
restOptions.limit = restOptions.limit || 100;
restOptions.order = 'objectId';
let finished = false;
return continueWhile(
() => {
return !fi... | Class | 2 |
RestQuery.prototype.handleExcludeKeys = function () {
if (!this.excludeKeys) {
return;
}
if (this.keys) {
this.keys = this.keys.filter(k => !this.excludeKeys.includes(k));
return;
}
return this.config.database
.loadSchema()
.then(schemaController => schemaController.getOneSchema(this.class... | Class | 2 |
RestQuery.prototype.cleanResultAuthData = function (result) {
delete result.password;
if (result.authData) {
Object.keys(result.authData).forEach(provider => {
if (result.authData[provider] === null) {
delete result.authData[provider];
}
});
if (Object.keys(result.authData).length =... | Class | 2 |
RestQuery.prototype.buildRestWhere = function () {
return Promise.resolve()
.then(() => {
return this.getUserAndRoleACL();
})
.then(() => {
return this.redirectClassNameForKey();
})
.then(() => {
return this.validateClientClassCreation();
})
.then(() => {
return thi... | Class | 2 |
RestQuery.prototype.runAfterFindTrigger = function () {
if (!this.response) {
return;
}
if (!this.runAfterFind) {
return;
}
// Avoid doing any setup for triggers if there is no 'afterFind' trigger for this class.
const hasAfterFindHook = triggers.triggerExists(
this.className,
triggers.Types... | Class | 2 |
RestQuery.prototype.handleInclude = function () {
if (this.include.length == 0) {
return;
}
var pathResponse = includePath(
this.config,
this.auth,
this.response,
this.include[0],
this.restOptions
);
if (pathResponse.then) {
return pathResponse.then(newResponse => {
this.res... | Class | 2 |
RestQuery.prototype.replaceInQuery = function () {
var inQueryObject = findObjectWithKey(this.restWhere, '$inQuery');
if (!inQueryObject) {
return;
}
// The inQuery value must have precisely two keys - where and className
var inQueryValue = inQueryObject['$inQuery'];
if (!inQueryValue.where || !inQuery... | Class | 2 |
RestQuery.prototype.replaceNotInQuery = function () {
var notInQueryObject = findObjectWithKey(this.restWhere, '$notInQuery');
if (!notInQueryObject) {
return;
}
// The notInQuery value must have precisely two keys - where and className
var notInQueryValue = notInQueryObject['$notInQuery'];
if (!notInQ... | Class | 2 |
RestQuery.prototype.replaceEquality = function () {
if (typeof this.restWhere !== 'object') {
return;
}
for (const key in this.restWhere) {
this.restWhere[key] = replaceEqualityConstraint(this.restWhere[key]);
}
}; | Class | 2 |
RestQuery.prototype.execute = function (executeOptions) {
return Promise.resolve()
.then(() => {
return this.buildRestWhere();
})
.then(() => {
return this.denyProtectedFields();
})
.then(() => {
return this.handleIncludeAll();
})
.then(() => {
return this.handleExc... | Class | 2 |
RestQuery.prototype.validateClientClassCreation = function () {
if (
this.config.allowClientClassCreation === false &&
!this.auth.isMaster &&
SchemaController.systemClasses.indexOf(this.className) === -1
) {
return this.config.database
.loadSchema()
.then(schemaController => schemaContro... | Class | 2 |
RestQuery.prototype.runFind = function (options = {}) {
if (this.findOptions.limit === 0) {
this.response = { results: [] };
return Promise.resolve();
}
const findOptions = Object.assign({}, this.findOptions);
if (this.keys) {
findOptions.keys = this.keys.map(key => {
return key.split('.')[0];... | Class | 2 |
function enforceRoleSecurity(method, className, auth) {
if (className === '_Installation' && !auth.isMaster && !auth.isMaintenance) {
if (method === 'delete' || method === 'find') {
const error = `Clients aren't allowed to perform the ${method} operation on the installation collection.`;
throw new Par... | Class | 2 |
function find(config, auth, className, restWhere, restOptions, clientSDK, context) {
enforceRoleSecurity('find', className, auth);
return triggers
.maybeRunQueryTrigger(
triggers.Types.beforeFind,
className,
restWhere,
restOptions,
config,
auth,
context
)
.then(... | Class | 2 |
const get = (config, auth, className, objectId, restOptions, clientSDK, context) => {
var restWhere = { objectId };
enforceRoleSecurity('get', className, auth);
return triggers
.maybeRunQueryTrigger(
triggers.Types.beforeFind,
className,
restWhere,
restOptions,
config,
auth... | Class | 2 |
function update(config, auth, className, restWhere, restObject, clientSDK, context) {
enforceRoleSecurity('update', className, auth);
return Promise.resolve()
.then(() => {
const hasTriggers = checkTriggers(className, config, ['beforeSave', 'afterSave']);
const hasLiveQuery = checkLiveQuery(classNa... | Class | 2 |
onCreate(instance) {
const content = instance.props.content + $("#narrow-hotkey-tooltip-template").html();
instance.setContent(parse_html(content));
}, | Base | 1 |
function isTextSearchable(text, search) {
return text && (search || isNumber(search));
} | Base | 1 |
function TuleapHighlightFilter() {
function isTextSearchable(text, search) {
return text && (search || isNumber(search));
}
return function (text, search) {
if (!isTextSearchable(text, search)) {
return text ? text.toString() : text;
}
const classifier = Classif... | Base | 1 |
export async function downloadKubectl(version: string): Promise<string> {
let cachedToolpath = toolCache.find(kubectlToolName, version);
let kubectlDownloadPath = '';
const arch = getKubectlArch();
if (!cachedToolpath) {
try {
kubectlDownloadPath = await toolCache.downloadTool(... | Class | 2 |
fastify.addHook('onRequest', async (request, reply) => {
if (request.url === bullBoardPath || request.url.startsWith(bullBoardPath + '/')) {
const token = request.cookies.token;
if (token == null) {
reply.code(401);
throw new Error('login required');
}
const user = await this.usersReposit... | Class | 2 |
super(meta, paramDef, async (ps, me) => {
const user = await this.usersRepository.findOneBy({ id: ps.userId });
if (user == null) {
throw new Error('user not found');
}
if (user.avatarId == null) return;
await this.usersRepository.update(user.id, {
avatar: null,
avatarId: null,
avat... | Class | 2 |
public getChannelService(name: string) {
switch (name) {
case 'main': return this.mainChannelService;
case 'homeTimeline': return this.homeTimelineChannelService;
case 'localTimeline': return this.localTimelineChannelService;
case 'hybridTimeline': return this.hybridTimelineChannelService;
case 'globa... | Class | 2 |
export function escape(val: Escapable | Escapable[], timeZone?: string, dialect?: string, format?: string): string;
export function format(sql: string, values: unknown[], timeZone?: string, dialect?: string): string; | Base | 1 |
export function escapeId(val: string, forbidQualified?: boolean): string;
export function escape(val: Escapable | Escapable[], timeZone?: string, dialect?: string, format?: string): string; | Base | 1 |
getTokenFromRequest: (req) => {
if (req.headers['x-csrf-token']) {
return req.headers['x-csrf-token'];
} else if (req.body.csrf_token) {
return req.body.csrf_token;
}
}, | Class | 2 |
export function splitOnFirstEquals(str: string): string[] {
// we use regex instead of "=" to ensure we split at the first
// "=" and return the following substring with it
// important for the hashed-password which looks like this
// $argon2i$v=19$m=4096,t=3,p=1$0qR/o+0t00hsbJFQCKSfdQ$oFcM4rL6o+B7oxpuA4qlXubyp... | Class | 2 |
export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, next) => {
logger.error(`${err.message} ${err.stack}`)
;(req as WebsocketRequest).ws.end()
} | Class | 2 |
function inspectFallback(val) {
const domains = Object.keys(val);
if (domains.length === 0) {
return "{}";
}
let result = "{\n";
Object.keys(val).forEach((domain, i) => {
result += formatDomain(domain, val[domain]);
if (i < domains.length - 1) {
result += ",";
}
result += "\n";
});... | Variant | 0 |
removeAllCookies(cb) {
this.idx = {};
return cb(null);
} | Variant | 0 |
function formatPath(pathName, pathValue) {
const indent = " ";
let result = `${indent}'${pathName}': {\n`;
Object.keys(pathValue).forEach((cookieName, i, cookieNames) => {
const cookie = pathValue[cookieName];
result += ` ${cookieName}: ${cookie.inspect()}`;
if (i < cookieNames.length - 1) {
... | Variant | 0 |
putCookie(cookie, cb) {
if (!this.idx[cookie.domain]) {
this.idx[cookie.domain] = {};
}
if (!this.idx[cookie.domain][cookie.path]) {
this.idx[cookie.domain][cookie.path] = {};
}
this.idx[cookie.domain][cookie.path][cookie.key] = cookie;
cb(null);
} | Variant | 0 |
constructor() {
super();
this.synchronous = true;
this.idx = {};
const customInspectSymbol = getCustomInspectSymbol();
if (customInspectSymbol) {
this[customInspectSymbol] = this.inspect;
}
} | Variant | 0 |
function formatDomain(domainName, domainValue) {
const indent = " ";
let result = `${indent}'${domainName}': {\n`;
Object.keys(domainValue).forEach((path, i, paths) => {
result += formatPath(path, domainValue[path]);
if (i < paths.length - 1) {
result += ",";
}
result += "\n";
});
resul... | Variant | 0 |
? element.boundElementIds.map((id) => ({ type: "arrow", id }))
: element.boundElements ?? [],
updated: element.updated ?? getUpdatedTimestamp(),
link: element.link ?? null,
locked: element.locked ?? false,
}; | Base | 1 |
function sameStreams(
directives1: ReadonlyArray<DirectiveNode>,
directives2: ReadonlyArray<DirectiveNode>,
): boolean {
const stream1 = getStreamDirective(directives1);
const stream2 = getStreamDirective(directives2);
if (!stream1 && !stream2) {
// both fields do not have streams
return true;
} els... | Class | 2 |
fields: args.map((argNode) => ({
kind: Kind.OBJECT_FIELD,
name: argNode.name,
value: argNode.value,
})),
}; | Class | 2 |
setCipherKey(val) {
this.cipherKey = val;
return this;
} | Base | 1 |
getVersion() {
return '7.3.3';
} | Base | 1 |
function __processMessage(modules, message) {
const { config, crypto } = modules;
if (!config.cipherKey) return message;
try {
return crypto.decrypt(message);
} catch (e) {
return message;
}
} | Base | 1 |
handleResponse: async ({ PubNubFile, config, cryptography }, res, params) => {
let { body } = res.response;
if (PubNubFile.supportsEncryptFile && (params.cipherKey ?? config.cipherKey)) {
body = await cryptography.decrypt(params.cipherKey ?? config.cipherKey, body);
}
return PubNubFile.create(... | Base | 1 |
const preparePayload = ({ crypto, config }, payload) => {
let stringifiedPayload = JSON.stringify(payload);
if (config.cipherKey) {
stringifiedPayload = crypto.encrypt(stringifiedPayload);
stringifiedPayload = JSON.stringify(stringifiedPayload);
}
return stringifiedPayload || '';
}; | Base | 1 |
function __processMessage(modules, message) {
const { config, crypto } = modules;
if (!config.cipherKey) return message;
try {
return crypto.decrypt(message);
} catch (e) {
return message;
}
} | Base | 1 |
function prepareMessagePayload(modules, messagePayload) {
const { crypto, config } = modules;
let stringifiedPayload = JSON.stringify(messagePayload);
if (config.cipherKey) {
stringifiedPayload = crypto.encrypt(stringifiedPayload);
stringifiedPayload = JSON.stringify(stringifiedPayload);
}
return st... | Base | 1 |
this.encryptFile = (key, file) => cryptography.encryptFile(key, file, this.File); | Base | 1 |
this.decryptFile = (key, file) => cryptography.decryptFile(key, file, this.File); | Base | 1 |
decryptBuffer(key, ciphertext) {
const bIv = ciphertext.slice(0, NodeCryptography.IV_LENGTH);
const bCiphertext = ciphertext.slice(NodeCryptography.IV_LENGTH);
const aes = createDecipheriv(this.algo, key, bIv);
return Buffer.concat([aes.update(bCiphertext), aes.final()]);
} | Base | 1 |
encryptStream(key, stream) {
const output = new PassThrough();
const bIv = this.getIv();
const aes = createCipheriv(this.algo, key, bIv);
output.write(bIv);
stream.pipe(aes).pipe(output);
return output;
} | Base | 1 |
async decryptArrayBuffer(key, ciphertext) {
const abIv = ciphertext.slice(0, 16);
return crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16));
} | Base | 1 |
async encryptString(key, plaintext) {
const abIv = crypto.getRandomValues(new Uint8Array(16));
const abPlaintext = Buffer.from(plaintext).buffer;
const abPayload = await crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, abPlaintext);
const ciphertext = concatArrayBuffer(abIv.buffer, abPayloa... | Base | 1 |
async encryptFile(key, file, File) {
const bKey = await this.getKey(key);
const abPlaindata = await file.toArrayBuffer();
const abCipherdata = await this.encryptArrayBuffer(bKey, abPlaindata);
return File.create({
name: file.name,
mimeType: 'application/octet-stream',
data: abCiph... | Base | 1 |
async decrypt(key, input) {
const cKey = await this.getKey(key);
if (input instanceof ArrayBuffer) {
return this.decryptArrayBuffer(cKey, input);
}
if (typeof input === 'string') {
return this.decryptString(cKey, input);
}
throw new Error('Cannot decrypt this file. In browsers fil... | Base | 1 |
async getKey(key) {
const bKey = Buffer.from(key);
const abHash = await crypto.subtle.digest('SHA-256', bKey.buffer);
const abKey = Buffer.from(Buffer.from(abHash).toString('hex').slice(0, 32), 'utf8').buffer;
return crypto.subtle.importKey('raw', abKey, 'AES-CBC', true, ['encrypt', 'decrypt']);
} | Base | 1 |
async decryptFile(key, file, File) {
const bKey = await this.getKey(key);
const abCipherdata = await file.toArrayBuffer();
const abPlaindata = await this.decryptArrayBuffer(bKey, abCipherdata);
return File.create({
name: file.name,
data: abPlaindata,
});
} | Base | 1 |
async decryptString(key, ciphertext) {
const abCiphertext = Buffer.from(ciphertext);
const abIv = abCiphertext.slice(0, 16);
const abPayload = abCiphertext.slice(16);
const abPlaintext = await crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, abPayload);
return Buffer.from(abPlaintext).t... | Base | 1 |
constructor({ stream, data, encoding, name, mimeType }) {
if (stream instanceof Readable) {
this.data = stream;
if (stream instanceof ReadStream) {
// $FlowFixMe: incomplete flow node definitions
this.name = basename(stream.path);
}
} else if (data instanceof Buffer) {
... | Base | 1 |
constructor(setup) {
// extract config.
const { listenToBrowserNetworkEvents = true } = setup;
setup.sdkFamily = 'Web';
setup.networking = new Networking({
del,
get,
post,
patch,
sendBeacon,
getfile,
postfile,
});
setup.cbor = new Cbor((arrayBuffer) =... | Base | 1 |
function pointInPolygon(testx, testy, polygon) {
let intersections = 0;
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
const [prevX, prevY] = polygon[j];
const [x, y] = polygon[i];
// count intersections
if (((y > testy) != (prevY > testy)) && (testx < (... | Base | 1 |
export function intersectLasso(markname, pixelLasso, unit) {
const { x, y, mark } = unit;
const bb = new Bounds().set(
Number.MAX_SAFE_INTEGER,
Number.MAX_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER
);
// Get bounding box around lasso
for (const [... | Base | 1 |
export function lassoAppend(lasso, x, y, minDist = 5) {
const last = lasso[lasso.length - 1];
// Add point to lasso if distance to last point exceed minDist or its the first point
if (last === undefined || Math.sqrt(((last[0] - x) ** 2) + ((last[1] - y) ** 2)) > minDist) {
lasso.push([x, y]);
... | Base | 1 |
export function lassoPath(lasso) {
return (lasso ?? []).reduce((svg, [x, y], i) => {
return svg += i == 0
? `M ${x},${y} `
: i === lasso.length - 1
? ' Z'
: `L ${x},${y} `;
}, '');
} | Base | 1 |
default: axiosDefault.mockResolvedValue({
status: 200,
statusText: 'OK',
headers: {},
data: {},
}),
})); | Base | 1 |
function handleDataChannelChat(dataMessage) {
if (!dataMessage) return;
let msgFrom = dataMessage.from;
let msgTo = dataMessage.to;
let msg = dataMessage.msg;
let msgPrivate = dataMessage.privateMsg;
let msgId = dataMessage.id;
// private message but not for me return
if (msgPrivate &&... | Base | 1 |
function addMsgerPrivateBtn(msgerPrivateBtn, msgerPrivateMsgInput, peerId) {
// add button to send private messages
msgerPrivateBtn.addEventListener('click', (e) => {
e.preventDefault();
sendPrivateMessage();
});
// Number 13 is the "Enter" key on the keyboard
msgerPrivateMsgInput.a... | Base | 1 |
function sendPrivateMessage() {
let pMsg = checkMsg(msgerPrivateMsgInput.value.trim());
if (!pMsg) {
msgerPrivateMsgInput.value = '';
isChatPasteTxt = false;
return;
}
let toPeerName = msgerPrivateBtn.value;
emitMsg(myPeerName, toPeerName, ... | Base | 1 |
fastify.register(FastifyCsrfProtection, { getUserInfo(req) {
return req.session.get('username')
}}) | Compound | 4 |
function addDummyBuildTarget(config: any = buildConfig) {
architectHost.addTarget(
{ project: 'dummy', target: 'build' },
'@angular-devkit/architect:true',
config
);
} | Class | 2 |
async function runNgsscbuild(options: Schema & JsonObject) {
// A "run" can have multiple outputs, and contains progress information.
const run = await architect.scheduleBuilder(
'angular-server-side-configuration:ngsscbuild',
options,
{ logger }
);
// The "result" member (of type B... | Class | 2 |
export async function detectVariables(context: BuilderContext): Promise<NgsscContext> {
const detector = new VariableDetector(context.logger);
const typeScriptFiles = findTypeScriptFiles(context.workspaceRoot);
let ngsscContext: NgsscContext | null = null;
for (const file of typeScriptFiles) {
const fileCon... | Class | 2 |
export async function detectVariablesAndBuildNgsscJson(
options: NgsscBuildSchema,
browserOptions: BrowserBuilderOptions,
context: BuilderContext,
multiple: boolean = false
) {
const ngsscContext = await detectVariables(context);
const outputPath = join(context.workspaceRoot, browserOptions.outputPath);
c... | Class | 2 |
function findTypeScriptFiles(root: string): string[] {
const directory = root.replace(/\\/g, '/');
return readdirSync(directory)
.map((f) => `${directory}/${f}`)
.map((f) => {
const stat = lstatSync(f);
if (stat.isDirectory()) {
return findTypeScriptFiles(f);
} else if (stat.isFile... | Class | 2 |
export function is_form_content_type(request) {
return is_content_type(request, 'application/x-www-form-urlencoded', 'multipart/form-data');
} | Compound | 4 |
constructor(options: AuthenticatorOptions = {}) {
this.key = options.key || 'passport'
this.userProperty = options.userProperty || 'user'
this.use(new SessionStrategy(this.deserializeUser.bind(this)))
this.sessionManager = new SecureSessionManager({ key: this.key }, this.serializeUser.bind(this))
} | Compound | 4 |
constructor(options: SerializeFunction | { key?: string }, serializeUser?: SerializeFunction) {
if (typeof options === 'function') {
this.serializeUser = options
this.key = 'passport'
} else if (typeof serializeUser === 'function') {
this.serializeUser = serializeUser
this.key =
... | Compound | 4 |
) => {
const { fastifyPassport, server } = getRegisteredTestServer(sessionOptions)
fastifyPassport.use(name, strategy)
return { fastifyPassport, server }
} | Compound | 4 |
export const getRegisteredTestServer = (sessionOptions: SessionOptions = null) => {
const fastifyPassport = new Authenticator()
fastifyPassport.registerUserSerializer(async (user) => JSON.stringify(user))
fastifyPassport.registerUserDeserializer(async (serialized: string) => JSON.parse(serialized))
const serve... | Compound | 4 |
export const getTestServer = (sessionOptions: SessionOptions = null) => {
const server = fastify()
loadSessionPlugins(server, sessionOptions)
server.setErrorHandler((error, request, reply) => {
console.error(error)
void reply.status(500)
void reply.send(error)
})
return server
} | Compound | 4 |
preValidation: authenticator.authenticate(strategyName, {
successRedirect: `/${namespace}`,
authInfo: false,
}),
},
() => {
return
}
)
instance.post(
`/log... | Compound | 4 |
return this.success({ namespace, id: String(counter++) })
}
this.fail()
} | Compound | 4 |
constructor(username: string, password: string) {
this.username = username;
this.password = password;
} | Class | 2 |
constructor(token: string) {
this.token = token;
} | Class | 2 |
constructor(token: string) {
this.token = token;
} | Class | 2 |
function resolveMetadataRecord(owner: object, context: Context, useMetaFromContext: boolean): MetadataRecord
{
// If registry is not to be used, it means that context.metadata is available
if (useMetaFromContext) {
return context.metadata as MetadataRecord;
}
// Obtain record from registry, or... | Variant | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.