New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ulixee/commons

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ulixee/commons - npm Package Compare versions

Comparing version 2.0.0-alpha.18 to 2.0.0-alpha.19

25

CHANGELOG.md

@@ -6,2 +6,27 @@ # Change Log

# [2.0.0-alpha.19](https://github.com/ulixee/shared/compare/v2.0.0-alpha.18...v2.0.0-alpha.19) (2023-02-25)
### Bug Fixes
* **commons:** allow clearing sourcemap paths ([4d14167](https://github.com/ulixee/shared/commit/4d141673bd34e22d556539e6eb7bf8e63d9c9c3e))
* **commons:** no unhandled timeouts ([5428d4a](https://github.com/ulixee/shared/commit/5428d4a2856c7c86dd4737522280a05b8f5d8c8e))
* **commons:** remove memory for once events ([e9b70ac](https://github.com/ulixee/shared/commit/e9b70ac08ab94c46bd00baa43d56a0b1820f78b1))
* **commons:** serialize objects named error too ([a915057](https://github.com/ulixee/shared/commit/a9150577b51572a25d3f3ca8144680ff87bf8b0b))
* **commons:** typo ([38eba49](https://github.com/ulixee/shared/commit/38eba496ada28165dc5e99acc48b0ec81040569c))
* **commons:** wait to register hosts listener ([02fcddb](https://github.com/ulixee/shared/commit/02fcddbf508c7392143c536707721a611c8b0205))
* **commons:** watch not available on linux ([cbd982b](https://github.com/ulixee/shared/commit/cbd982bec27c6f9b9c794ff99d01ee50c553ff59))
* **net:** default to ws transport over actual wire ([cbc0adc](https://github.com/ulixee/shared/commit/cbc0adcf0c899bfdc4d24ca5beccae7daf24869e))
### Features
* **commons:** host file monitoring ([01d1e53](https://github.com/ulixee/shared/commit/01d1e53b5087b2b80f96a0bfc504323172adbb81))
* **commons:** read embedded sourcemap content ([a20db0c](https://github.com/ulixee/shared/commit/a20db0c3c400939ef403a4c7c779f4a49811c92f))
* **net:** emit request, response and event ([9ed0201](https://github.com/ulixee/shared/commit/9ed02013579ee3bc206182cfce85def3c0271034))
# [2.0.0-alpha.18](https://github.com/ulixee/shared/compare/v2.0.0-alpha.17...v2.0.0-alpha.18) (2023-01-17)

@@ -8,0 +33,0 @@

7

config/hosts.d.ts

@@ -1,2 +0,6 @@

export default class UlixeeHostsConfig {
import { TypedEventEmitter } from '../lib/eventUtils';
export default class UlixeeHostsConfig extends TypedEventEmitter<{
change: void;
}> {
#private;
readonly directoryPath: string;

@@ -11,2 +15,3 @@ static global: UlixeeHostsConfig;

checkLocalVersionHost(version: string, host: string): Promise<string>;
private reload;
private save;

@@ -13,0 +18,0 @@ }

47

config/hosts.js
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _UlixeeHostsConfig_watchHandle;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,18 +15,21 @@ const Fs = require("fs");

const utils_1 = require("../lib/utils");
class UlixeeHostsConfig {
const eventUtils_1 = require("../lib/eventUtils");
class UlixeeHostsConfig extends eventUtils_1.TypedEventEmitter {
constructor(directoryPath) {
super();
this.directoryPath = directoryPath;
this.hostByVersion = {};
if (Fs.existsSync(this.configPath)) {
for (const file of Fs.readdirSync(this.configPath)) {
if (file.endsWith('.json')) {
const versionPath = Path.join(this.configPath, file);
const version = file.replace('.json', '');
this.hostByVersion[version] = JSON.parse(Fs.readFileSync(versionPath, 'utf8'));
}
}
}
else {
_UlixeeHostsConfig_watchHandle.set(this, void 0);
if (!Fs.existsSync(this.configPath)) {
Fs.mkdirSync(this.configPath, { recursive: true });
}
// not supported on linux!
this.onEventListenerAdded = event => {
if (event !== 'change')
return;
if (process.platform === 'win32' || process.platform === 'darwin') {
__classPrivateFieldSet(this, _UlixeeHostsConfig_watchHandle, Fs.watch(this.configPath, { recursive: true, persistent: false }, this.reload.bind(this, true)), "f");
}
};
this.reload();
}

@@ -73,2 +83,16 @@ get configPath() {

}
reload(checkForChange = false) {
const prev = checkForChange ? JSON.stringify(this.hostByVersion) : '';
this.hostByVersion = {};
for (const file of Fs.readdirSync(this.configPath)) {
if (file.endsWith('.json')) {
const versionPath = Path.join(this.configPath, file);
const version = file.replace('.json', '');
this.hostByVersion[version] = JSON.parse(Fs.readFileSync(versionPath, 'utf8'));
}
}
if (checkForChange && prev !== JSON.stringify(this.hostByVersion)) {
this.emit('change');
}
}
save(version) {

@@ -89,3 +113,4 @@ const versionPath = Path.join(this.configPath, `${version}.json`);

exports.default = UlixeeHostsConfig;
_UlixeeHostsConfig_watchHandle = new WeakMap();
UlixeeHostsConfig.global = new UlixeeHostsConfig(Path.join((0, dirUtils_1.getCacheDirectory)(), 'ulixee'));
//# sourceMappingURL=hosts.js.map
export default interface ILog extends IBoundLog<ILogData> {
level: string;
flush(): any;
level?: string;
flush?(): any;
}

@@ -5,0 +5,0 @@ export interface IBoundLog<Base = any> {

@@ -10,2 +10,3 @@ export default interface ITypedEventEmitter<T> {

prependOnceListener<K extends keyof T & (string | symbol)>(event: K, listener: (this: this, event?: T[K]) => void, includeUnhandledEvents?: boolean): this;
removeAllListeners(event?: string | symbol): this;
}

@@ -20,3 +20,4 @@ import IRegisteredEventListener, { IEventSubscriber } from '../interfaces/IRegisteredEventListener';

endGroup(name: string): void;
private removeHandlerById;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let idCounter = 0;
class EventSubscriber {

@@ -10,3 +11,4 @@ constructor() {

emitter.on(eventName, handler, includeUnhandledEvents);
const registeredEvent = { emitter, eventName, handler };
const id = idCounter++;
const registeredEvent = { id, emitter, eventName, handler };
this.registeredEventListeners.add(registeredEvent);

@@ -16,4 +18,9 @@ return registeredEvent;

once(emitter, eventName, handler, includeUnhandledEvents) {
emitter.once(eventName, handler, includeUnhandledEvents);
const registeredEvent = { emitter, eventName, handler };
const id = idCounter++;
const finalHandler = (...args) => {
this.removeHandlerById(id);
return handler(...args);
};
const registeredEvent = { id, emitter, eventName, handler: finalHandler };
emitter.once(eventName, finalHandler, includeUnhandledEvents);
this.registeredEventListeners.add(registeredEvent);

@@ -24,2 +31,4 @@ return registeredEvent;

for (const listener of listeners) {
if (!listener.emitter)
continue;
listener.emitter.off(listener.eventName, listener.handler);

@@ -51,4 +60,12 @@ this.registeredEventListeners.delete(listener);

}
removeHandlerById(id) {
for (const listener of this.registeredEventListeners) {
if (listener.id === id) {
this.registeredEventListeners.delete(listener);
break;
}
}
}
}
exports.default = EventSubscriber;
//# sourceMappingURL=EventSubscriber.js.map
/// <reference types="node" />
export declare const hashMessagePrefix = "\u0018Ulixee Signed Message:\n";
export declare function sha3(data: Buffer | string): Buffer;
export declare function sha256(data: Buffer | string): Buffer;
export declare function sortedJsonStringify<T>(obj: T | null, ignoreProperties?: (keyof T)[]): string;

@@ -5,0 +5,0 @@ export declare function hashObject<T>(obj: T, options?: {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hashObject = exports.sortedJsonStringify = exports.sha3 = exports.hashMessagePrefix = void 0;
exports.hashObject = exports.sortedJsonStringify = exports.sha256 = exports.hashMessagePrefix = void 0;
const crypto_1 = require("crypto");
const TypeSerializer_1 = require("./TypeSerializer");
exports.hashMessagePrefix = '\x18Ulixee Signed Message:\n';
function sha3(data) {
return (0, crypto_1.createHash)('sha3-256').update(data).digest();
function sha256(data) {
return (0, crypto_1.createHash)('sha256').update(data).digest();
}
exports.sha3 = sha3;
exports.sha256 = sha256;
function sortedJsonStringify(obj, ignoreProperties = []) {

@@ -27,5 +27,5 @@ if (!obj) {

buffer = Buffer.concat([options.prefix, buffer]);
return (0, crypto_1.createHash)('sha3-256').update(buffer).digest();
return sha256(buffer);
}
exports.hashObject = hashObject;
//# sourceMappingURL=hashUtils.js.map

@@ -265,8 +265,11 @@ "use strict";

if (ns.includes('ulx:*') || ns.includes('ulx*') || ns === '*') {
active.push(/^apps[/-]chromealive*/, /hero[/-].*/, /agent\/.*/, /plugins\/.*/, /net\/.*/, /datastore[/-].*/, /mainchain[/-].*/, /sidechain[/-].*/, /ramps[/-].*/, /DevtoolsSessionLogger/);
active.push(/desktop[/-]?.*/, /hero[/-].*/, /agent\/.*/, /plugins\/.*/, /net\/.*/, /datastore[/-].*/, /mainchain[/-].*/, /sidechain[/-].*/, /ramps[/-].*/, /DevtoolsSessionLogger/);
}
else if (ns === 'ulx') {
active.push(/hero[/-].*/, /agent\/.*/, /plugins\/.*/, /net\/.*/, /datastore[/-].*/, /mainchain[/-].*/, /sidechain[/-].*/, /ramps[/-].*/);
skip.push(/^apps[/-]chromealive*/, /DevtoolsSessionLogger/);
skip.push(/desktop[/-]?.*/, /DevtoolsSessionLogger/);
}
else if (ns.includes('ulx:desktop')) {
active.push(/desktop[/-]?.*/);
}
else if (ns === 'ulx:mitm') {

@@ -273,0 +276,0 @@ active.push(/agent[/-]mitm.*/);

@@ -75,3 +75,3 @@ "use strict";

error.stack = `TimeoutError: ${message}\n${this.stack}`;
this.reject(error);
this.reject(error, true);
}

@@ -78,0 +78,0 @@ }

@@ -17,14 +17,12 @@ "use strict";

return null;
codeLocation = SourceMapSupport_1.SourceMapSupport.getOriginalSourcePosition(codeLocation);
if (!this.sourceLines[codeLocation.filename]) {
const file = this.getFileContents(codeLocation.filename);
const sourcePosition = SourceMapSupport_1.SourceMapSupport.getOriginalSourcePosition(codeLocation, true);
const code = sourcePosition.content;
if (!this.sourceLines[sourcePosition.filename]) {
const file = code || this.getFileContents(sourcePosition.filename);
if (!file)
return null;
this.sourceLines[codeLocation.filename] = file.split(/\r?\n/);
this.sourceLines[sourcePosition.filename] = file.split(/\r?\n/);
}
const code = this.sourceLines[codeLocation.filename][codeLocation.line - 1];
return {
code,
...codeLocation,
};
sourcePosition.code = this.sourceLines[sourcePosition.filename][sourcePosition.line - 1];
return sourcePosition;
}

@@ -31,0 +29,0 @@ static getFileContents(filepath, cache = true) {

@@ -6,2 +6,4 @@ import { SourceMapConsumer } from 'source-map-js';

private static resolvedPathCache;
private static stackPathsToClear;
static clearStackPath(stackPath: string): void;
static resetCache(): void;

@@ -12,4 +14,5 @@ static clearCache(filepath: string): void;

static getSourceFilePaths(filename: string): string[];
static getOriginalSourcePosition(position: ISourceCodeLocation): ISourceCodeLocation & {
static getOriginalSourcePosition(position: ISourceCodeLocation, includeContent?: boolean): ISourceCodeLocation & {
name?: string;
content?: string;
};

@@ -16,0 +19,0 @@ static retrieveSourceMap(source: string): {

@@ -12,2 +12,5 @@ "use strict";

class SourceMapSupport {
static clearStackPath(stackPath) {
this.stackPathsToClear.add(stackPath);
}
static resetCache() {

@@ -58,3 +61,3 @@ this.sourceMapCache = {};

}
static getOriginalSourcePosition(position) {
static getOriginalSourcePosition(position, includeContent = false) {
var _a, _b;

@@ -67,7 +70,13 @@ (_a = this.sourceMapCache)[_b = position.filename] ?? (_a[_b] = this.retrieveSourceMap(position.filename));

if (originalPosition.source) {
let content = null;
const filename = this.resolvePath(sourceMap.url, originalPosition.source);
if (includeContent) {
content = sourceMap.map.sourceContentFor(originalPosition.source, true);
}
return {
filename: this.resolvePath(sourceMap.url, originalPosition.source),
filename,
column: originalPosition.column,
line: originalPosition.line,
name: originalPosition.name,
content,
};

@@ -134,2 +143,7 @@ }

const fnName = containingFnName ?? frame.getFunctionName();
for (const toReplace of this.stackPathsToClear) {
if (position.filename.startsWith(toReplace)) {
position.filename = position.filename.replace(toReplace, '');
}
}
containingFnName = position.name;

@@ -180,2 +194,3 @@ frame = new Proxy(frame, {

SourceMapSupport.resolvedPathCache = {};
SourceMapSupport.stackPathsToClear = new Set();
SourceMapSupport.install();

@@ -182,0 +197,0 @@ // Converted from the V8 source code at:

@@ -10,2 +10,3 @@ /// <reference types="node" />

EventTypes: T;
onEventListenerAdded?: <K extends keyof T & (string | symbol)>(event: K) => void;
private pendingIdCounter;

@@ -12,0 +13,0 @@ private pendingWaitEventsById;

@@ -92,2 +92,3 @@ "use strict";

super.on(eventType, listenerFn);
this.onEventListenerAdded?.(eventType);
return this.replayOrClearMissedEvents(includeUnhandledEvents, eventType);

@@ -100,2 +101,3 @@ }

super.once(eventType, listenerFn);
this.onEventListenerAdded?.(eventType);
return this.replayOrClearMissedEvents(includeUnhandledEvents, eventType);

@@ -102,0 +104,0 @@ }

@@ -107,3 +107,4 @@ "use strict";

}
if (value instanceof Error) {
if (value instanceof Error ||
('stack' in value && 'name' in value && value.name?.endsWith?.('Error'))) {
const { name, message, stack, ...data } = value;

@@ -110,0 +111,0 @@ const extras = this.replace(data, options);

{
"name": "@ulixee/commons",
"version": "2.0.0-alpha.18",
"version": "2.0.0-alpha.19",
"description": "Common utilities for Ulixee",

@@ -19,3 +19,3 @@ "license": "MIT",

},
"gitHead": "e6056d23170596355dd1596931cd0de8b8730e5b"
"gitHead": "af8c0da6fa1440f18dcaf99c24461cce0990e838"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc