WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
export declare enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
BlockScopedVariable = 2,
|
||||
Property = 4,
|
||||
EnumMember = 8,
|
||||
Function = 16,
|
||||
Class = 32,
|
||||
Interface = 64,
|
||||
ConstEnum = 128,
|
||||
RegularEnum = 256,
|
||||
ValueModule = 512,
|
||||
NamespaceModule = 1024,
|
||||
TypeLiteral = 2048,
|
||||
ObjectLiteral = 4096,
|
||||
Method = 8192,
|
||||
Constructor = 16384,
|
||||
GetAccessor = 32768,
|
||||
SetAccessor = 65536,
|
||||
Signature = 131072,
|
||||
TypeParameter = 262144,
|
||||
TypeAlias = 524288,
|
||||
ExportValue = 1048576,
|
||||
Alias = 2097152,
|
||||
Prototype = 4194304,
|
||||
ExportStar = 8388608,
|
||||
Optional = 16777216,
|
||||
Transient = 33554432,
|
||||
Assignment = 67108864,
|
||||
ModuleExports = 134217728,
|
||||
ConstEnumOnlyModule = 268435456,
|
||||
ReplaceableByMethod = 536870912,
|
||||
GlobalLookup = 1073741824,
|
||||
All = 536870912,
|
||||
Enum = 384,
|
||||
Variable = 3,
|
||||
Value = 111551,
|
||||
Type = 788968,
|
||||
Namespace = 1920,
|
||||
Module = 1536,
|
||||
Accessor = 98304,
|
||||
FunctionScopedVariableExcludes = 111550,
|
||||
BlockScopedVariableExcludes = 111551,
|
||||
ParameterExcludes = 111551,
|
||||
PropertyExcludes = 13243,
|
||||
EnumMemberExcludes = 900095,
|
||||
FunctionExcludes = 110991,
|
||||
ClassExcludes = 899503,
|
||||
InterfaceExcludes = 788872,
|
||||
RegularEnumExcludes = 899327,
|
||||
ConstEnumExcludes = 899967,
|
||||
ValueModuleExcludes = 110735,
|
||||
NamespaceModuleExcludes = 0,
|
||||
MethodExcludes = 103359,
|
||||
GetAccessorExcludes = 46011,
|
||||
SetAccessorExcludes = 78779,
|
||||
AccessorExcludes = 111547,
|
||||
TypeParameterExcludes = 526824,
|
||||
TypeAliasExcludes = 788968,
|
||||
AliasExcludes = 2097152,
|
||||
ModuleMember = 2623475,
|
||||
ExportHasLocal = 944,
|
||||
BlockScoped = 418,
|
||||
PropertyOrAccessor = 98308,
|
||||
ClassMember = 106500,
|
||||
ExportSupportsDefaultModifier = 112,
|
||||
ExportDoesNotSupportDefaultModifier = -113,
|
||||
Classifiable = 2885600,
|
||||
LateBindingContainer = 6256
|
||||
}
|
||||
//# sourceMappingURL=symbolFlags.enum.d.ts.map
|
||||
@@ -0,0 +1,51 @@
|
||||
declare namespace processWarning {
|
||||
export interface WarningItem {
|
||||
(a?: any, b?: any, c?: any): boolean;
|
||||
name: string;
|
||||
code: string;
|
||||
message: string;
|
||||
emitted: boolean;
|
||||
unlimited: boolean;
|
||||
format(a?: any, b?: any, c?: any): string;
|
||||
}
|
||||
|
||||
export type WarningOptions = {
|
||||
name: string;
|
||||
code: string;
|
||||
message: string;
|
||||
unlimited?: boolean;
|
||||
}
|
||||
|
||||
export type DeprecationOptions = Omit<WarningOptions, 'name'>
|
||||
|
||||
export type ProcessWarningOptions = {
|
||||
unlimited?: boolean;
|
||||
}
|
||||
|
||||
export type WarningSpyData = {
|
||||
calls: WarningCallData[],
|
||||
callCount(): number
|
||||
reset(): void
|
||||
restore(): void
|
||||
}
|
||||
|
||||
export type WarningCallData = {
|
||||
arguments: unknown[]
|
||||
result: boolean
|
||||
}
|
||||
|
||||
export type ProcessWarning = {
|
||||
createWarning(params: WarningOptions): WarningItem;
|
||||
createDeprecation(params: DeprecationOptions): WarningItem;
|
||||
spyWarning(warning: WarningItem): WarningSpyData
|
||||
}
|
||||
|
||||
export function createWarning (params: WarningOptions): WarningItem
|
||||
export function createDeprecation (params: DeprecationOptions): WarningItem
|
||||
export function spyWarning (warning: WarningItem): WarningSpyData
|
||||
|
||||
const processWarning: ProcessWarning
|
||||
export { processWarning as default }
|
||||
}
|
||||
|
||||
export = processWarning
|
||||
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
const WebSocket = require('isomorphic-ws');
|
||||
const utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Constructor for a Jayson Websocket Server
|
||||
* @name ServerWebsocket
|
||||
* @param {Server} server Server instance
|
||||
* @param {Object} [options] Options for this instance
|
||||
* @param {ws.Websocket.Server} [options.wss] When provided will not create a new ws.WebSocket.Server but use this one
|
||||
* @return {ws.WebSocket.Server}
|
||||
*/
|
||||
const ServerWebsocket = function(server, options) {
|
||||
const jaysonOptions = utils.merge(server.options, options || {});
|
||||
const wss = options.wss || new WebSocket.Server(options);
|
||||
|
||||
wss.on('connection', onConnection);
|
||||
|
||||
function onConnection (ws) {
|
||||
// every message received on the socket is handled as a JSON-RPC message
|
||||
ws.on('message', function (buf) {
|
||||
const str = Buffer.isBuffer(buf) ? buf.toString('utf8') : buf;
|
||||
utils.JSON.parse(str, jaysonOptions, function(err, request) {
|
||||
if (err) {
|
||||
return respondError(err);
|
||||
}
|
||||
|
||||
server.call(request, function(error, success) {
|
||||
const response = error || success;
|
||||
if (response) {
|
||||
utils.JSON.stringify(response, jaysonOptions, function (err, str) {
|
||||
if (err) {
|
||||
return respondError(err);
|
||||
}
|
||||
ws.send(str);
|
||||
});
|
||||
} else {
|
||||
// no response received at all, must be a notification which we do nothing about
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// writes an error message to the client
|
||||
function respondError (err) {
|
||||
const error = server.error(-32700, null, String(err));
|
||||
const response = utils.response(error, undefined, undefined, jaysonOptions.version);
|
||||
utils.JSON.stringify(response, jaysonOptions, function(err, str) {
|
||||
if(err) {
|
||||
// not much to do here, we couldn't even respond with an error
|
||||
throw err;
|
||||
}
|
||||
ws.send(str);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return wss;
|
||||
};
|
||||
|
||||
module.exports = ServerWebsocket;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getParsedConfigFile = getParsedConfigFile;
|
||||
const fs = __importStar(require("node:fs"));
|
||||
const path = __importStar(require("node:path"));
|
||||
const compilerOptions_1 = require("./compilerOptions");
|
||||
/**
|
||||
* Parses a TSConfig file using the same logic as tsserver.
|
||||
*
|
||||
* @param configFile the path to the tsconfig.json file, relative to `projectDirectory`
|
||||
* @param projectDirectory the project directory to use as the CWD, defaults to `process.cwd()`
|
||||
*/
|
||||
function getParsedConfigFile(tsserver, configFile, projectDirectory) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/internal/eqeq-nullish
|
||||
if (tsserver.sys === undefined) {
|
||||
throw new Error('`getParsedConfigFile` is only supported in a Node-like environment.');
|
||||
}
|
||||
const parsed = tsserver.getParsedCommandLineOfConfigFile(configFile, compilerOptions_1.CORE_COMPILER_OPTIONS, {
|
||||
fileExists: fs.existsSync,
|
||||
getCurrentDirectory,
|
||||
onUnRecoverableConfigFileDiagnostic: diag => {
|
||||
throw new Error(formatDiagnostics([diag])); // ensures that `parsed` is defined.
|
||||
},
|
||||
readDirectory: tsserver.sys.readDirectory,
|
||||
readFile: file => fs.readFileSync(path.isAbsolute(file) ? file : path.join(getCurrentDirectory(), file), 'utf-8'),
|
||||
useCaseSensitiveFileNames: tsserver.sys.useCaseSensitiveFileNames,
|
||||
});
|
||||
if (parsed?.errors.length) {
|
||||
throw new Error([
|
||||
"Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.",
|
||||
formatDiagnostics(parsed.errors),
|
||||
].join('\n\n'));
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
return parsed;
|
||||
function getCurrentDirectory() {
|
||||
return projectDirectory ? path.resolve(projectDirectory) : process.cwd();
|
||||
}
|
||||
function formatDiagnostics(diagnostics) {
|
||||
return tsserver.formatDiagnostics(diagnostics, {
|
||||
getCanonicalFileName: f => f,
|
||||
getCurrentDirectory,
|
||||
getNewLine: () => '\n',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "../v4/locales/index.js";
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"modifierFlags.enum.js","sourceRoot":"","sources":["../../src/enums/modifierFlags.enum.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,MAAM,CAAN,IAAY,aAwCX;AAxCD,WAAY,aAAa;IACrB,iDAAQ,CAAA;IACR,qDAAe,CAAA;IACf,uDAAgB,CAAA;IAChB,2DAAkB,CAAA;IAClB,yDAAiB,CAAA;IACjB,0DAAiB,CAAA;IACjB,sDAAe,CAAA;IACf,0DAAiB,CAAA;IACjB,yDAAgB,CAAA;IAChB,uDAAe,CAAA;IACf,2DAAiB,CAAA;IACjB,sDAAe,CAAA;IACf,0DAAiB,CAAA;IACjB,sDAAe,CAAA;IACf,gDAAY,CAAA;IACZ,mDAAa,CAAA;IACb,+DAAmB,CAAA;IACnB,iEAAoB,CAAA;IACpB,qEAAqB,CAAA;IACrB,wEAAsB,CAAA;IACtB,4EAAwB,CAAA;IACxB,0EAAuB,CAAA;IACvB,2EAAuB,CAAA;IACvB,mGAAmC,CAAA;IACnC,iFAA0B,CAAA;IAC1B,4FAA8E,CAAA;IAC9E,yFAAyH,CAAA;IACzH,iFAAuE,CAAA;IACvE,+FAAqG,CAAA;IACrG,iFAA+B,CAAA;IAC/B,wFAA+F,CAAA;IAC/F,mFAAoD,CAAA;IACpD,4FAAuE,CAAA;IACvE,qGAAoD,CAAA;IACpD,iFAA+G,CAAA;IAC/G,sEAAgC,CAAA;IAChC,oDAAwK,CAAA;IACxK,6DAA2B,CAAA;IAC3B,gEAAyD,CAAA;AAC7D,CAAC,EAxCW,aAAa,KAAb,aAAa,QAwCxB"}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TSEnumScope = void 0;
|
||||
const ScopeBase_1 = require("./ScopeBase");
|
||||
const ScopeType_1 = require("./ScopeType");
|
||||
class TSEnumScope extends ScopeBase_1.ScopeBase {
|
||||
constructor(scopeManager, upperScope, block) {
|
||||
super(scopeManager, ScopeType_1.ScopeType.tsEnum, upperScope, block, false);
|
||||
}
|
||||
}
|
||||
exports.TSEnumScope = TSEnumScope;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"nodeFlags.enum.d.ts","sourceRoot":"","sources":["../../src/enums/nodeFlags.enum.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACjB,IAAI,IAAI;IACR,GAAG,IAAS;IACZ,KAAK,IAAS;IACd,KAAK,IAAS;IACd,QAAQ,IAAS;IACjB,WAAW,KAAS;IACpB,aAAa,KAAS;IACtB,aAAa,KAAS;IACtB,YAAY,MAAS;IACrB,iBAAiB,MAAS;IAC1B,iBAAiB,MAAS;IAC1B,iBAAiB,OAAU;IAC3B,YAAY,OAAU;IACtB,gBAAgB,OAAU;IAC1B,YAAY,OAAU;IACtB,+BAA+B,QAAU;IACzC,gBAAgB,QAAU;IAC1B,cAAc,QAAU;IACxB,6BAA6B,SAAU;IACvC,iBAAiB,SAAU;IAC3B,6BAA6B,SAAU;IACvC,0BAA0B,UAAU;IACpC,QAAQ,UAAU;IAClB,KAAK,UAAU;IACf,OAAO,UAAU;IACjB,eAAe,WAAU;IACzB,QAAQ,WAAU;IAClB,6BAA6B,WAAU;IACvC,WAAW,YAAU;IACrB,0BAA0B,YAAU;IACpC,WAAW,IAAsB;IACjC,QAAQ,IAAgB;IACxB,UAAU,IAAgB;IAC1B,sBAAsB,MAAwC;IAC9D,wBAAwB,SAA6C;IACrE,YAAY,WAAoJ;IAChK,iBAAiB,QAA8B;IAC/C,8BAA8B,UAA6D;IAC3F,kCAAkC,MAAe;IACjD,4BAA4B,SAAoB;IAChD,eAAe,KAAgB;CAClC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @fileoverview Rule to enforce var declarations are only at the top of a function.
|
||||
* @author Danny Fritz
|
||||
* @author Gyandeep Singh
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Require `var` declarations be placed at the top of their containing scope",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/vars-on-top",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
messages: {
|
||||
top: "All 'var' declarations must be at the top of the function scope.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Has AST suggesting a directive.
|
||||
* @param {ASTNode} node any node
|
||||
* @returns {boolean} whether the given node structurally represents a directive
|
||||
*/
|
||||
function looksLikeDirective(node) {
|
||||
return (
|
||||
node.type === "ExpressionStatement" &&
|
||||
node.expression.type === "Literal" &&
|
||||
typeof node.expression.value === "string"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if its a ES6 import declaration
|
||||
* @param {ASTNode} node any node
|
||||
* @returns {boolean} whether the given node represents a import declaration
|
||||
*/
|
||||
function looksLikeImport(node) {
|
||||
return (
|
||||
node.type === "ImportDeclaration" ||
|
||||
node.type === "ImportSpecifier" ||
|
||||
node.type === "ImportDefaultSpecifier" ||
|
||||
node.type === "ImportNamespaceSpecifier"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given node is a variable declaration or not.
|
||||
* @param {ASTNode} node any node
|
||||
* @returns {boolean} `true` if the node is a variable declaration.
|
||||
*/
|
||||
function isVariableDeclaration(node) {
|
||||
return (
|
||||
node.type === "VariableDeclaration" ||
|
||||
(node.type === "ExportNamedDeclaration" &&
|
||||
node.declaration &&
|
||||
node.declaration.type === "VariableDeclaration")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this variable is on top of the block body
|
||||
* @param {ASTNode} node The node to check
|
||||
* @param {ASTNode[]} statements collection of ASTNodes for the parent node block
|
||||
* @returns {boolean} True if var is on top otherwise false
|
||||
*/
|
||||
function isVarOnTop(node, statements) {
|
||||
const l = statements.length;
|
||||
let i = 0;
|
||||
|
||||
// Skip over directives and imports. Static blocks don't have either.
|
||||
if (node.parent.type !== "StaticBlock") {
|
||||
for (; i < l; ++i) {
|
||||
if (
|
||||
!looksLikeDirective(statements[i]) &&
|
||||
!looksLikeImport(statements[i])
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < l; ++i) {
|
||||
if (!isVariableDeclaration(statements[i])) {
|
||||
return false;
|
||||
}
|
||||
if (statements[i] === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether variable is on top at the global level
|
||||
* @param {ASTNode} node The node to check
|
||||
* @param {ASTNode} parent Parent of the node
|
||||
* @returns {void}
|
||||
*/
|
||||
function globalVarCheck(node, parent) {
|
||||
if (!isVarOnTop(node, parent.body)) {
|
||||
context.report({ node, messageId: "top" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether variable is on top at functional block scope level
|
||||
* @param {ASTNode} node The node to check
|
||||
* @returns {void}
|
||||
*/
|
||||
function blockScopeVarCheck(node) {
|
||||
const { parent } = node;
|
||||
|
||||
if (
|
||||
parent.type === "BlockStatement" &&
|
||||
/Function/u.test(parent.parent.type) &&
|
||||
isVarOnTop(node, parent.body)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
parent.type === "StaticBlock" &&
|
||||
isVarOnTop(node, parent.body)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({ node, messageId: "top" });
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public API
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
"VariableDeclaration[kind='var']"(node) {
|
||||
if (node.parent.type === "ExportNamedDeclaration") {
|
||||
globalVarCheck(node.parent, node.parent.parent);
|
||||
} else if (node.parent.type === "Program") {
|
||||
globalVarCheck(node, node.parent);
|
||||
} else {
|
||||
blockScopeVarCheck(node);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,156 @@
|
||||
declare module 'https' {
|
||||
import { Duplex } from 'stream';
|
||||
import * as tls from 'tls';
|
||||
import * as http from 'http';
|
||||
import { URL } from 'url';
|
||||
|
||||
type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
|
||||
|
||||
type RequestOptions = http.RequestOptions & tls.SecureContextOptions & {
|
||||
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
||||
servername?: string | undefined; // SNI TLS Extension
|
||||
};
|
||||
|
||||
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
||||
rejectUnauthorized?: boolean | undefined;
|
||||
maxCachedSessions?: number | undefined;
|
||||
}
|
||||
|
||||
class Agent extends http.Agent {
|
||||
constructor(options?: AgentOptions);
|
||||
options: AgentOptions;
|
||||
}
|
||||
|
||||
interface Server extends http.Server {}
|
||||
class Server extends tls.Server {
|
||||
constructor(requestListener?: http.RequestListener);
|
||||
constructor(options: ServerOptions, requestListener?: http.RequestListener);
|
||||
|
||||
setTimeout(callback: () => void): this;
|
||||
setTimeout(msecs?: number, callback?: () => void): this;
|
||||
/**
|
||||
* Limits maximum incoming headers count. If set to 0, no limit will be applied.
|
||||
* @default 2000
|
||||
* {@link https://nodejs.org/api/http.html#http_server_maxheaderscount}
|
||||
*/
|
||||
maxHeadersCount: number | null;
|
||||
timeout: number;
|
||||
/**
|
||||
* Limit the amount of time the parser will wait to receive the complete HTTP headers.
|
||||
* @default 40000
|
||||
* {@link https://nodejs.org/api/http.html#http_server_headerstimeout}
|
||||
*/
|
||||
headersTimeout: number;
|
||||
keepAliveTimeout: number;
|
||||
addListener(event: string, listener: (...args: any[]) => void): this;
|
||||
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
addListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
||||
addListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
||||
addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: 'listening', listener: () => void): this;
|
||||
addListener(event: 'checkContinue', listener: http.RequestListener): this;
|
||||
addListener(event: 'checkExpectation', listener: http.RequestListener): this;
|
||||
addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
addListener(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
addListener(event: 'request', listener: http.RequestListener): this;
|
||||
addListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean;
|
||||
emit(event: 'OCSPRequest', certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
|
||||
emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
|
||||
emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean;
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'connection', socket: Duplex): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: 'listening'): boolean;
|
||||
emit(event: 'checkContinue', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
||||
emit(event: 'checkExpectation', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
||||
emit(event: 'clientError', err: Error, socket: Duplex): boolean;
|
||||
emit(event: 'connect', req: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
|
||||
emit(event: 'request', req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
||||
emit(event: 'upgrade', req: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
on(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
||||
on(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
||||
on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
on(event: 'close', listener: () => void): this;
|
||||
on(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'listening', listener: () => void): this;
|
||||
on(event: 'checkContinue', listener: http.RequestListener): this;
|
||||
on(event: 'checkExpectation', listener: http.RequestListener): this;
|
||||
on(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
on(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
on(event: 'request', listener: http.RequestListener): this;
|
||||
on(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
once(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
||||
once(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
||||
once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: 'listening', listener: () => void): this;
|
||||
once(event: 'checkContinue', listener: http.RequestListener): this;
|
||||
once(event: 'checkExpectation', listener: http.RequestListener): this;
|
||||
once(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
once(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
once(event: 'request', listener: http.RequestListener): this;
|
||||
once(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
prependListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
||||
prependListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
||||
prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: 'listening', listener: () => void): this;
|
||||
prependListener(event: 'checkContinue', listener: http.RequestListener): this;
|
||||
prependListener(event: 'checkExpectation', listener: http.RequestListener): this;
|
||||
prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
prependListener(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
prependListener(event: 'request', listener: http.RequestListener): this;
|
||||
prependListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
|
||||
prependOnceListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
|
||||
prependOnceListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
|
||||
prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: 'listening', listener: () => void): this;
|
||||
prependOnceListener(event: 'checkContinue', listener: http.RequestListener): this;
|
||||
prependOnceListener(event: 'checkExpectation', listener: http.RequestListener): this;
|
||||
prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
||||
prependOnceListener(event: 'connect', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
prependOnceListener(event: 'request', listener: http.RequestListener): this;
|
||||
prependOnceListener(event: 'upgrade', listener: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): this;
|
||||
}
|
||||
|
||||
function createServer(requestListener?: http.RequestListener): Server;
|
||||
function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
|
||||
function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||
function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||
function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||
function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
|
||||
let globalAgent: Agent;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
|
||||
module.exports = { urlAlphabet }
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
// @ts-ignore TS6133
|
||||
import { test } from "vitest";
|
||||
|
||||
test("masking test", () => {});
|
||||
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
// selected so (BASE - 1) * 0x100000000 + 0xffffffff is a safe integer
|
||||
var BASE = 1000000;
|
||||
|
||||
function readInt8(buffer) {
|
||||
var high = buffer.readInt32BE(0);
|
||||
var low = buffer.readUInt32BE(4);
|
||||
var sign = '';
|
||||
|
||||
if (high < 0) {
|
||||
high = ~high + (low === 0);
|
||||
low = (~low + 1) >>> 0;
|
||||
sign = '-';
|
||||
}
|
||||
|
||||
var result = '';
|
||||
var carry;
|
||||
var t;
|
||||
var digits;
|
||||
var pad;
|
||||
var l;
|
||||
var i;
|
||||
|
||||
{
|
||||
carry = high % BASE;
|
||||
high = high / BASE >>> 0;
|
||||
|
||||
t = 0x100000000 * carry + low;
|
||||
low = t / BASE >>> 0;
|
||||
digits = '' + (t - BASE * low);
|
||||
|
||||
if (low === 0 && high === 0) {
|
||||
return sign + digits + result;
|
||||
}
|
||||
|
||||
pad = '';
|
||||
l = 6 - digits.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
pad += '0';
|
||||
}
|
||||
|
||||
result = pad + digits + result;
|
||||
}
|
||||
|
||||
{
|
||||
carry = high % BASE;
|
||||
high = high / BASE >>> 0;
|
||||
|
||||
t = 0x100000000 * carry + low;
|
||||
low = t / BASE >>> 0;
|
||||
digits = '' + (t - BASE * low);
|
||||
|
||||
if (low === 0 && high === 0) {
|
||||
return sign + digits + result;
|
||||
}
|
||||
|
||||
pad = '';
|
||||
l = 6 - digits.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
pad += '0';
|
||||
}
|
||||
|
||||
result = pad + digits + result;
|
||||
}
|
||||
|
||||
{
|
||||
carry = high % BASE;
|
||||
high = high / BASE >>> 0;
|
||||
|
||||
t = 0x100000000 * carry + low;
|
||||
low = t / BASE >>> 0;
|
||||
digits = '' + (t - BASE * low);
|
||||
|
||||
if (low === 0 && high === 0) {
|
||||
return sign + digits + result;
|
||||
}
|
||||
|
||||
pad = '';
|
||||
l = 6 - digits.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
pad += '0';
|
||||
}
|
||||
|
||||
result = pad + digits + result;
|
||||
}
|
||||
|
||||
{
|
||||
carry = high % BASE;
|
||||
t = 0x100000000 * carry + low;
|
||||
digits = '' + t % BASE;
|
||||
|
||||
return sign + digits + result;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = readInt8;
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare var NodeFlags: any;
|
||||
//# sourceMappingURL=nodeFlags.d.ts.map
|
||||
@@ -0,0 +1,26 @@
|
||||
var REACT_ELEMENT_TYPE;
|
||||
function _jsx(type, props, key, children) {
|
||||
if (!REACT_ELEMENT_TYPE) {
|
||||
REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
|
||||
}
|
||||
|
||||
var defaultProps = type && type.defaultProps;
|
||||
var childrenLength = arguments.length - 3;
|
||||
|
||||
if (!props && childrenLength !== 0) props = { children: void 0 };
|
||||
if (props && defaultProps) {
|
||||
for (var propName in defaultProps) {
|
||||
if (props[propName] === void 0) props[propName] = defaultProps[propName];
|
||||
else if (!props) props = defaultProps || {};
|
||||
}
|
||||
}
|
||||
if (childrenLength === 1) props.children = children;
|
||||
else if (childrenLength > 1) {
|
||||
var childArray = new Array(childrenLength);
|
||||
for (var i = 0; i < childrenLength; i++) childArray[i] = arguments[i + 3];
|
||||
props.children = childArray;
|
||||
}
|
||||
|
||||
return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : "" + key, ref: null, props: props, _owner: null };
|
||||
}
|
||||
export { _jsx as _ };
|
||||
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.needsPrecedingSemicolon = needsPrecedingSemicolon;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const ast_utils_1 = require("@typescript-eslint/utils/ast-utils");
|
||||
// The following is adapted from `eslint`'s source code.
|
||||
// https://github.com/eslint/eslint/blob/3a4eaf921543b1cd5d1df4ea9dec02fab396af2a/lib/rules/utils/ast-utils.js#L1043-L1132
|
||||
// Could be export { isStartOfExpressionStatement } from 'eslint/lib/rules/utils/ast-utils'
|
||||
const BREAK_OR_CONTINUE = new Set([
|
||||
utils_1.AST_NODE_TYPES.BreakStatement,
|
||||
utils_1.AST_NODE_TYPES.ContinueStatement,
|
||||
]);
|
||||
// Declaration types that must contain a string Literal node at the end.
|
||||
const DECLARATIONS = new Set([
|
||||
utils_1.AST_NODE_TYPES.ExportAllDeclaration,
|
||||
utils_1.AST_NODE_TYPES.ExportNamedDeclaration,
|
||||
utils_1.AST_NODE_TYPES.ImportDeclaration,
|
||||
]);
|
||||
const IDENTIFIER_OR_KEYWORD = new Set([
|
||||
utils_1.AST_NODE_TYPES.Identifier,
|
||||
utils_1.AST_TOKEN_TYPES.Keyword,
|
||||
]);
|
||||
// Keywords that can immediately precede an ExpressionStatement node, mapped to the their node types.
|
||||
const NODE_TYPES_BY_KEYWORD = {
|
||||
__proto__: null,
|
||||
break: utils_1.AST_NODE_TYPES.BreakStatement,
|
||||
continue: utils_1.AST_NODE_TYPES.ContinueStatement,
|
||||
debugger: utils_1.AST_NODE_TYPES.DebuggerStatement,
|
||||
do: utils_1.AST_NODE_TYPES.DoWhileStatement,
|
||||
else: utils_1.AST_NODE_TYPES.IfStatement,
|
||||
return: utils_1.AST_NODE_TYPES.ReturnStatement,
|
||||
yield: utils_1.AST_NODE_TYPES.YieldExpression,
|
||||
};
|
||||
/*
|
||||
* Before an opening parenthesis, postfix `++` and `--` always trigger ASI;
|
||||
* the tokens `:`, `;`, `{` and `=>` don't expect a semicolon, as that would count as an empty statement.
|
||||
*/
|
||||
const PUNCTUATORS = new Set(['--', ';', ':', '{', '++', '=>']);
|
||||
/*
|
||||
* Statements that can contain an `ExpressionStatement` after a closing parenthesis.
|
||||
* DoWhileStatement is an exception in that it always triggers ASI after the closing parenthesis.
|
||||
*/
|
||||
const STATEMENTS = new Set([
|
||||
utils_1.AST_NODE_TYPES.DoWhileStatement,
|
||||
utils_1.AST_NODE_TYPES.ForInStatement,
|
||||
utils_1.AST_NODE_TYPES.ForOfStatement,
|
||||
utils_1.AST_NODE_TYPES.ForStatement,
|
||||
utils_1.AST_NODE_TYPES.IfStatement,
|
||||
utils_1.AST_NODE_TYPES.WhileStatement,
|
||||
utils_1.AST_NODE_TYPES.WithStatement,
|
||||
]);
|
||||
/**
|
||||
* Determines whether an opening parenthesis `(`, bracket `[` or backtick ``` ` ``` needs to be preceded by a semicolon.
|
||||
* This opening parenthesis or bracket should be at the start of an `ExpressionStatement`, a `MethodDefinition` or at
|
||||
* the start of the body of an `ArrowFunctionExpression`.
|
||||
* @param sourceCode The source code object.
|
||||
* @param node A node at the position where an opening parenthesis or bracket will be inserted.
|
||||
* @returns Whether a semicolon is required before the opening parenthesis or bracket.
|
||||
*/
|
||||
function needsPrecedingSemicolon(sourceCode, node) {
|
||||
const prevToken = sourceCode.getTokenBefore(node);
|
||||
if (!prevToken ||
|
||||
(prevToken.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
|
||||
PUNCTUATORS.has(prevToken.value))) {
|
||||
return false;
|
||||
}
|
||||
const prevNode = sourceCode.getNodeByRangeIndex(prevToken.range[0]);
|
||||
if (!prevNode) {
|
||||
return false;
|
||||
}
|
||||
if ((0, ast_utils_1.isClosingParenToken)(prevToken)) {
|
||||
return !STATEMENTS.has(prevNode.type);
|
||||
}
|
||||
if ((0, ast_utils_1.isClosingBraceToken)(prevToken)) {
|
||||
return ((prevNode.type === utils_1.AST_NODE_TYPES.BlockStatement &&
|
||||
prevNode.parent.type === utils_1.AST_NODE_TYPES.FunctionExpression &&
|
||||
prevNode.parent.parent.type !== utils_1.AST_NODE_TYPES.MethodDefinition) ||
|
||||
(prevNode.type === utils_1.AST_NODE_TYPES.ClassBody &&
|
||||
prevNode.parent.type === utils_1.AST_NODE_TYPES.ClassExpression) ||
|
||||
prevNode.type === utils_1.AST_NODE_TYPES.ObjectExpression);
|
||||
}
|
||||
if (!prevNode.parent) {
|
||||
return false;
|
||||
}
|
||||
if (IDENTIFIER_OR_KEYWORD.has(prevToken.type)) {
|
||||
if (BREAK_OR_CONTINUE.has(prevNode.parent.type)) {
|
||||
return false;
|
||||
}
|
||||
const keyword = prevToken.value;
|
||||
const nodeType = NODE_TYPES_BY_KEYWORD[keyword];
|
||||
return prevNode.type !== nodeType;
|
||||
}
|
||||
if (prevToken.type === utils_1.AST_TOKEN_TYPES.String) {
|
||||
return !DECLARATIONS.has(prevNode.parent.type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @fileoverview Universal module importer
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Imports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const { createRequire } = require("module");
|
||||
const { pathToFileURL } = require("url");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const SLASHES = new Set(["/", "\\"]);
|
||||
|
||||
/**
|
||||
* Normalizes directories to have a trailing slash.
|
||||
* Resolve is pretty finicky -- if the directory name doesn't have
|
||||
* a trailing slash then it tries to look in the parent directory.
|
||||
* i.e., if the directory is "/usr/nzakas/foo" it will start the
|
||||
* search in /usr/nzakas. However, if the directory is "/user/nzakas/foo/",
|
||||
* then it will start the search in /user/nzakas/foo.
|
||||
* @param {string} directory The directory to check.
|
||||
* @returns {string} The normalized directory.
|
||||
*/
|
||||
function normalizeDirectory(directory) {
|
||||
if (!SLASHES.has(directory[directory.length-1])) {
|
||||
return directory + "/";
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class for importing both CommonJS and ESM modules in Node.js.
|
||||
*/
|
||||
exports.ModuleImporter = class ModuleImporter {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} [cwd] The current working directory to resolve from.
|
||||
*/
|
||||
constructor(cwd = process.cwd()) {
|
||||
|
||||
/**
|
||||
* The base directory from which paths should be resolved.
|
||||
* @type {string}
|
||||
*/
|
||||
this.cwd = normalizeDirectory(cwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a module based on its name or location.
|
||||
* @param {string} specifier Either an npm package name or
|
||||
* relative file path.
|
||||
* @returns {string|undefined} The location of the import.
|
||||
* @throws {Error} If specifier cannot be located.
|
||||
*/
|
||||
resolve(specifier) {
|
||||
const require = createRequire(this.cwd);
|
||||
return require.resolve(specifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a module based on its name or location.
|
||||
* @param {string} specifier Either an npm package name or
|
||||
* relative file path.
|
||||
* @returns {Promise<object>} The module's object.
|
||||
*/
|
||||
import(specifier) {
|
||||
const location = this.resolve(specifier);
|
||||
return import(pathToFileURL(location).href);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_get_prototype_of.cjs",
|
||||
"module": "../../esm/_get_prototype_of.js"
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* @fileoverview Rule to check for "block scoped" variables by binding context
|
||||
* @author Matt DuVall <http://www.mattduvall.com>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint-scope").Definition} Definition */
|
||||
/** @typedef {import("eslint-scope").Reference} Reference */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce the use of variables within the scope they are defined",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/block-scoped-var",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
outOfScope:
|
||||
"'{{name}}' declared on line {{definitionLine}} column {{definitionColumn}} is used outside of binding context.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
let stack = [];
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Makes a block scope.
|
||||
* @param {ASTNode} node A node of a scope.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterScope(node) {
|
||||
stack.push(node.range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops the last block scope.
|
||||
* @returns {void}
|
||||
*/
|
||||
function exitScope() {
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports a given reference.
|
||||
* @param {Reference} reference A reference to report.
|
||||
* @param {Definition} definition A definition for which to report reference.
|
||||
* @returns {void}
|
||||
*/
|
||||
function report(reference, definition) {
|
||||
const identifier = reference.identifier;
|
||||
const definitionPosition = definition.name.loc.start;
|
||||
|
||||
context.report({
|
||||
node: identifier,
|
||||
messageId: "outOfScope",
|
||||
data: {
|
||||
name: identifier.name,
|
||||
definitionLine: definitionPosition.line,
|
||||
definitionColumn: definitionPosition.column + 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and reports references which are outside of valid scopes.
|
||||
* @param {ASTNode} node A node to get variables.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkForVariables(node) {
|
||||
if (node.kind !== "var") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Defines a predicate to check whether or not a given reference is outside of valid scope.
|
||||
const scopeRange = stack.at(-1);
|
||||
|
||||
/**
|
||||
* Check if a reference is out of scope
|
||||
* @param {ASTNode} reference node to examine
|
||||
* @returns {boolean} True is its outside the scope
|
||||
* @private
|
||||
*/
|
||||
function isOutsideOfScope(reference) {
|
||||
const idRange = reference.identifier.range;
|
||||
|
||||
return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1];
|
||||
}
|
||||
|
||||
// Gets declared variables, and checks its references.
|
||||
const variables = sourceCode.getDeclaredVariables(node);
|
||||
|
||||
for (let i = 0; i < variables.length; ++i) {
|
||||
// Reports.
|
||||
variables[i].references.filter(isOutsideOfScope).forEach(ref =>
|
||||
report(
|
||||
ref,
|
||||
variables[i].defs.find(def => def.parent === node),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
Program(node) {
|
||||
stack = [node.range];
|
||||
},
|
||||
|
||||
// Manages scopes.
|
||||
BlockStatement: enterScope,
|
||||
"BlockStatement:exit": exitScope,
|
||||
ForStatement: enterScope,
|
||||
"ForStatement:exit": exitScope,
|
||||
ForInStatement: enterScope,
|
||||
"ForInStatement:exit": exitScope,
|
||||
ForOfStatement: enterScope,
|
||||
"ForOfStatement:exit": exitScope,
|
||||
SwitchStatement: enterScope,
|
||||
"SwitchStatement:exit": exitScope,
|
||||
CatchClause: enterScope,
|
||||
"CatchClause:exit": exitScope,
|
||||
StaticBlock: enterScope,
|
||||
"StaticBlock:exit": exitScope,
|
||||
|
||||
// Finds and reports references which are outside of valid scope.
|
||||
VariableDeclaration: checkForVariables,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,211 @@
|
||||
'use strict'
|
||||
|
||||
// Node.js test comparing @pinojs/redact vs fast-redact for multiple wildcard patterns
|
||||
// This test validates that @pinojs/redact correctly handles 3+ consecutive wildcards
|
||||
// matching the behavior of fast-redact
|
||||
|
||||
const { test } = require('node:test')
|
||||
const { strict: assert } = require('node:assert')
|
||||
const fastRedact = require('fast-redact')
|
||||
const slowRedact = require('../index.js')
|
||||
|
||||
// Helper function to test redaction and track which values were censored
|
||||
function testRedactDirect (library, pattern, testData = {}) {
|
||||
const matches = []
|
||||
const redactor = library === '@pinojs/redact' ? slowRedact : fastRedact
|
||||
|
||||
try {
|
||||
const redact = redactor({
|
||||
paths: [pattern],
|
||||
censor: (value, path) => {
|
||||
if (
|
||||
value !== undefined &&
|
||||
value !== null &&
|
||||
typeof value === 'string' &&
|
||||
value.includes('secret')
|
||||
) {
|
||||
matches.push({
|
||||
value,
|
||||
path: path ? path.join('.') : 'unknown'
|
||||
})
|
||||
}
|
||||
return '[REDACTED]'
|
||||
}
|
||||
})
|
||||
|
||||
redact(JSON.parse(JSON.stringify(testData)))
|
||||
|
||||
return {
|
||||
library,
|
||||
pattern,
|
||||
matches,
|
||||
success: true,
|
||||
testData
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
library,
|
||||
pattern,
|
||||
matches: [],
|
||||
success: false,
|
||||
error: error.message,
|
||||
testData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testSlowRedactDirect (pattern, testData) {
|
||||
return testRedactDirect('@pinojs/redact', pattern, testData)
|
||||
}
|
||||
|
||||
function testFastRedactDirect (pattern, testData) {
|
||||
return testRedactDirect('fast-redact', pattern, testData)
|
||||
}
|
||||
|
||||
test('@pinojs/redact: *.password (2 levels)', () => {
|
||||
const result = testSlowRedactDirect('*.password', {
|
||||
simple: { password: 'secret-2-levels' }
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-2-levels')
|
||||
})
|
||||
|
||||
test('@pinojs/redact: *.*.password (3 levels)', () => {
|
||||
const result = testSlowRedactDirect('*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } }
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-3-levels')
|
||||
})
|
||||
|
||||
test('@pinojs/redact: *.*.*.password (4 levels)', () => {
|
||||
const result = testSlowRedactDirect('*.*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } },
|
||||
nested: { deep: { auth: { password: 'secret-4-levels' } } }
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-4-levels')
|
||||
})
|
||||
|
||||
test('@pinojs/redact: *.*.*.*.password (5 levels)', () => {
|
||||
const result = testSlowRedactDirect('*.*.*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } },
|
||||
nested: { deep: { auth: { password: 'secret-4-levels' } } },
|
||||
config: {
|
||||
user: { auth: { settings: { password: 'secret-5-levels' } } }
|
||||
}
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-5-levels')
|
||||
})
|
||||
|
||||
test('@pinojs/redact: *.*.*.*.*.password (6 levels)', () => {
|
||||
const result = testSlowRedactDirect('*.*.*.*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } },
|
||||
nested: { deep: { auth: { password: 'secret-4-levels' } } },
|
||||
config: {
|
||||
user: { auth: { settings: { password: 'secret-5-levels' } } }
|
||||
},
|
||||
data: {
|
||||
reqConfig: {
|
||||
data: {
|
||||
credentials: {
|
||||
settings: {
|
||||
password: 'real-secret-6-levels'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'real-secret-6-levels')
|
||||
})
|
||||
|
||||
test('fast-redact: *.password (2 levels)', () => {
|
||||
const result = testFastRedactDirect('*.password', {
|
||||
simple: { password: 'secret-2-levels' }
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-2-levels')
|
||||
})
|
||||
|
||||
test('fast-redact: *.*.password (3 levels)', () => {
|
||||
const result = testFastRedactDirect('*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } }
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-3-levels')
|
||||
})
|
||||
|
||||
test('fast-redact: *.*.*.password (4 levels)', () => {
|
||||
const result = testFastRedactDirect('*.*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } },
|
||||
nested: { deep: { auth: { password: 'secret-4-levels' } } }
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-4-levels')
|
||||
})
|
||||
|
||||
test('fast-redact: *.*.*.*.password (5 levels)', () => {
|
||||
const result = testFastRedactDirect('*.*.*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } },
|
||||
nested: { deep: { auth: { password: 'secret-4-levels' } } },
|
||||
config: {
|
||||
user: { auth: { settings: { password: 'secret-5-levels' } } }
|
||||
}
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'secret-5-levels')
|
||||
})
|
||||
|
||||
test('fast-redact: *.*.*.*.*.password (6 levels)', () => {
|
||||
const result = testFastRedactDirect('*.*.*.*.*.password', {
|
||||
simple: { password: 'secret-2-levels' },
|
||||
user: { auth: { password: 'secret-3-levels' } },
|
||||
nested: { deep: { auth: { password: 'secret-4-levels' } } },
|
||||
config: {
|
||||
user: { auth: { settings: { password: 'secret-5-levels' } } }
|
||||
},
|
||||
data: {
|
||||
reqConfig: {
|
||||
data: {
|
||||
credentials: {
|
||||
settings: {
|
||||
password: 'real-secret-6-levels'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
assert.strictEqual(result.success, true)
|
||||
assert.strictEqual(result.matches.length, 1)
|
||||
assert.strictEqual(result.matches[0].value, 'real-secret-6-levels')
|
||||
})
|
||||
@@ -0,0 +1,65 @@
|
||||
import rng from './rng.js';
|
||||
import { unsafeStringify } from './stringify.js';
|
||||
const _state = {};
|
||||
function v7(options, buf, offset) {
|
||||
let bytes;
|
||||
if (options) {
|
||||
bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
|
||||
}
|
||||
else {
|
||||
const now = Date.now();
|
||||
const rnds = rng();
|
||||
updateV7State(_state, now, rnds);
|
||||
bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
|
||||
}
|
||||
return buf ?? unsafeStringify(bytes);
|
||||
}
|
||||
export function updateV7State(state, now, rnds) {
|
||||
state.msecs ??= -Infinity;
|
||||
state.seq ??= 0;
|
||||
if (now > state.msecs) {
|
||||
state.seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
||||
state.msecs = now;
|
||||
}
|
||||
else {
|
||||
state.seq = (state.seq + 1) | 0;
|
||||
if (state.seq === 0) {
|
||||
state.msecs++;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
||||
if (rnds.length < 16) {
|
||||
throw new Error('Random bytes length must be >= 16');
|
||||
}
|
||||
if (!buf) {
|
||||
buf = new Uint8Array(16);
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
if (offset < 0 || offset + 16 > buf.length) {
|
||||
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
||||
}
|
||||
}
|
||||
msecs ??= Date.now();
|
||||
seq ??= ((rnds[6] * 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
||||
buf[offset++] = (msecs / 0x10000000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x100000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x1000000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x10000) & 0xff;
|
||||
buf[offset++] = (msecs / 0x100) & 0xff;
|
||||
buf[offset++] = msecs & 0xff;
|
||||
buf[offset++] = 0x70 | ((seq >>> 28) & 0x0f);
|
||||
buf[offset++] = (seq >>> 20) & 0xff;
|
||||
buf[offset++] = 0x80 | ((seq >>> 14) & 0x3f);
|
||||
buf[offset++] = (seq >>> 6) & 0xff;
|
||||
buf[offset++] = ((seq << 2) & 0xff) | (rnds[10] & 0x03);
|
||||
buf[offset++] = rnds[11];
|
||||
buf[offset++] = rnds[12];
|
||||
buf[offset++] = rnds[13];
|
||||
buf[offset++] = rnds[14];
|
||||
buf[offset++] = rnds[15];
|
||||
return buf;
|
||||
}
|
||||
export default v7;
|
||||
Reference in New Issue
Block a user