Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mercuryworkshop/bare-as-module3

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mercuryworkshop/bare-as-module3 - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

10

dist/BareTypes.d.ts

@@ -1,3 +0,3 @@

export type BareMethod = 'GET' | 'POST' | 'DELETE' | 'OPTIONS' | 'PUT' | 'PATCH' | 'UPDATE' | string;
export type BareCache = 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached' | string;
export type BareMethod = "GET" | "POST" | "DELETE" | "OPTIONS" | "PUT" | "PATCH" | "UPDATE" | string;
export type BareCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache" | "only-if-cached" | string;
export interface BareWebSocketMeta {

@@ -7,4 +7,4 @@ protocol: string;

}
export type BareHTTPProtocol = 'blob:' | 'http:' | 'https:' | string;
export type BareWSProtocol = 'ws:' | 'wss:' | string;
export type BareHTTPProtocol = "blob:" | "http:" | "https:" | string;
export type BareWSProtocol = "ws:" | "wss:" | string;
export declare const maxRedirects = 20;

@@ -37,3 +37,3 @@ export type BareHeaders = Record<string, string | string[]>;

}
export type BareLanguage = 'NodeJS' | 'ServiceWorker' | 'Deno' | 'Java' | 'PHP' | 'Rust' | 'C' | 'C++' | 'C#' | 'Ruby' | 'Go' | 'Crystal' | 'Shell' | string;
export type BareLanguage = "NodeJS" | "ServiceWorker" | "Deno" | "Java" | "PHP" | "Rust" | "C" | "C++" | "C#" | "Ruby" | "Go" | "Crystal" | "Shell" | string;
export interface BareManifest {

@@ -40,0 +40,0 @@ maintainer?: BareMaintainer;

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

import type { BareHeaders, BareWebSocketMeta } from './BareTypes.js';
import type { BareHeaders, BareWebSocketMeta } from "./BareTypes.js";
export declare const statusEmpty: number[];

@@ -3,0 +3,0 @@ export declare const statusRedirect: number[];

@@ -256,3 +256,3 @@ (function (global, factory) {

function binl2rstr(input) {
let output = '';
let output = "";
const length32 = input.length * 32;

@@ -293,23 +293,2 @@ for (let i = 0; i < length32; i += 8) {

/**
* Calculates the HMAC-MD5 of a key and some data (raw strings)
*
* @param key HMAC key
* @param data Raw input string
* @returns Raw MD5 string
*/
function rstrHMACMD5(key, data) {
let bkey = rstr2binl(key);
const ipad = [];
const opad = [];
if (bkey.length > 16) {
bkey = binlMD5(bkey, key.length * 8);
}
for (let i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5c5c5c5c;
}
const hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));
}
/**
* Convert a raw string to a hex string

@@ -321,4 +300,4 @@ *

function rstr2hex(input) {
const hexTab = '0123456789abcdef';
let output = '';
const hexTab = "0123456789abcdef";
let output = "";
for (let i = 0; i < input.length; i += 1) {

@@ -358,22 +337,2 @@ const x = input.charCodeAt(i);

/**
* Calculates the raw HMAC-MD5 for the given key and data
*
* @param k HMAC key
* @param d Input string
* @returns Raw MD5 string
*/
function rawHMACMD5(k, d) {
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
}
/**
* Calculates the Hex encoded HMAC-MD5 for the given key and data
*
* @param k HMAC key
* @param d Input string
* @returns Raw MD5 string
*/
function hexHMACMD5(k, d) {
return rstr2hex(rawHMACMD5(k, d));
}
/**
* Calculates MD5 value for a given string.

@@ -389,12 +348,7 @@ * If a key is provided, calculates the HMAC-MD5 value.

function md5(string, key, raw) {
if (!key) {
if (!raw) {
{
{
return hexMD5(string);
}
return rawMD5(string);
}
if (!raw) {
return hexHMACMD5(key, string);
}
return rawHMACMD5(key, string);
}

@@ -411,6 +365,6 @@

const output = new Headers(headers);
if (headers.has('x-bare-headers')) {
const value = headers.get('x-bare-headers');
if (headers.has("x-bare-headers")) {
const value = headers.get("x-bare-headers");
if (value.length > MAX_HEADER_VALUE) {
output.delete('x-bare-headers');
output.delete("x-bare-headers");
let split = 0;

@@ -433,3 +387,3 @@ for (let i = 0; i < value.length; i += MAX_HEADER_VALUE) {

const output = new Headers(headers);
const prefix = 'x-bare-headers';
const prefix = "x-bare-headers";
if (headers.has(`${prefix}-0`)) {

@@ -441,7 +395,7 @@ const join = [];

}
if (!value.startsWith(';')) {
if (!value.startsWith(";")) {
throw new BareError(400, {
code: 'INVALID_BARE_HEADER',
code: "INVALID_BARE_HEADER",
id: `request.headers.${header}`,
message: `Value didn't begin with semi-colon.`,
message: "Value didn't begin with semi-colon.",
});

@@ -453,3 +407,3 @@ }

}
output.set(prefix, join.join(''));
output.set(prefix, join.join(""));
}

@@ -469,7 +423,7 @@ return output;

this.http = new URL(this.base);
if (this.ws.protocol === 'https:') {
this.ws.protocol = 'wss:';
if (this.ws.protocol === "https:") {
this.ws.protocol = "wss:";
}
else {
this.ws.protocol = 'ws:';
this.ws.protocol = "ws:";
}

@@ -484,18 +438,14 @@ }

const cleanup = () => {
ws.removeEventListener('close', closeListener);
ws.removeEventListener('message', messageListener);
ws.removeEventListener("close", closeListener);
ws.removeEventListener("message", messageListener);
};
const closeListener = (event) => {
onclose(event.code, event.reason);
cleanup();
};
const messageListener = (event) => {
cleanup();
// ws.binaryType is irrelevant when sending text
if (typeof event.data !== 'string')
throw new TypeError('the first websocket message was not a text frame');
if (typeof event.data !== "string")
throw new TypeError("the first websocket message was not a text frame");
const message = JSON.parse(event.data);
// finally
if (message.type !== 'open')
throw new TypeError('message was not of open type');
if (message.type !== "open")
throw new TypeError("message was not of open type");
// onMeta({

@@ -506,14 +456,19 @@ // protocol: message.protocol,

onopen(message.protocol);
// TODO
ws.addEventListener("message", (ev) => {
onmessage(ev.data);
});
ws.addEventListener("close", (ev) => {
onclose(ev.code, ev.reason);
});
};
ws.addEventListener('close', closeListener);
ws.addEventListener('message', messageListener);
const closeListener = (event) => {
onclose(event.code, event.reason);
cleanup();
};
ws.addEventListener("message", messageListener);
ws.addEventListener("close", closeListener);
// CONNECTED TO THE BARE SERVER, NOT THE REMOTE
ws.addEventListener('open', (event) => {
// getRequestHeaders().then((headers:any) =>
ws.addEventListener("open", (event) => {
WebSocketFields.prototype.send.call(ws, JSON.stringify({
type: 'connect',
type: "connect",
remote: url.toString(),

@@ -524,3 +479,2 @@ protocols,

}));
// );
},

@@ -533,3 +487,3 @@ // only block the open event once

const options = {
credentials: 'omit',
credentials: "omit",
method: method,

@@ -544,15 +498,4 @@ signal,

options.headers = this.createBareHeaders(remote, headers);
const response = await fetch(this.http + '?cache=' + md5(remote.toString()), options);
const response = await fetch(this.http + "?cache=" + md5(remote.toString()), options);
const readResponse = await this.readBareResponse(response);
// const result: Response & Partial<BareResponse> = new Response(
// statusEmpty.includes(readResponse.status!) ? undefined : response.body,
// {
// status: readResponse.status,
// statusText: readResponse.statusText ?? undefined,
// headers: new Headers(readResponse.headers as HeadersInit),
// }
// );
//
// result.rawHeaders = readResponse.headers;
// result.rawResponse = response;
return {

@@ -571,9 +514,9 @@ body: response.body,

const result = {};
const xBareStatus = responseHeaders.get('x-bare-status');
const xBareStatus = responseHeaders.get("x-bare-status");
if (xBareStatus !== null)
result.status = parseInt(xBareStatus);
const xBareStatusText = responseHeaders.get('x-bare-status-text');
const xBareStatusText = responseHeaders.get("x-bare-status-text");
if (xBareStatusText !== null)
result.statusText = xBareStatusText;
const xBareHeaders = responseHeaders.get('x-bare-headers');
const xBareHeaders = responseHeaders.get("x-bare-headers");
if (xBareHeaders !== null)

@@ -585,12 +528,12 @@ result.headers = JSON.parse(xBareHeaders);

const headers = new Headers();
headers.set('x-bare-url', remote.toString());
headers.set('x-bare-headers', JSON.stringify(bareHeaders));
headers.set("x-bare-url", remote.toString());
headers.set("x-bare-headers", JSON.stringify(bareHeaders));
for (const header of forwardHeaders) {
headers.append('x-bare-forward-headers', header);
headers.append("x-bare-forward-headers", header);
}
for (const header of passHeaders) {
headers.append('x-bare-pass-headers', header);
headers.append("x-bare-pass-headers", header);
}
for (const status of passStatus) {
headers.append('x-bare-pass-status', status.toString());
headers.append("x-bare-pass-status", status.toString());
}

@@ -597,0 +540,0 @@ splitHeaders(headers);

@@ -1,3 +0,3 @@

import type { BareHeaders, BareMethod } from './BareTypes.js';
import { Client } from './Client.js';
import type { BareHeaders, BareMethod } from "./BareTypes.js";
import { Client } from "./Client.js";
import type { BareTransport, TransferrableResponse } from "@mercuryworkshop/bare-mux";

@@ -4,0 +4,0 @@ export default class ClientV3 extends Client implements BareTransport {

{
"name": "@mercuryworkshop/bare-as-module3",
"version": "2.2.2",
"main": "./dist/index.js",
"homepage": "https://github.com/MercuryWorkshop/bare-as-module3",
"bugs": {
"url": "https://github.com/MercuryWorkshop/bare-as-module3/issues",
"email": "support@mercurywork.shop"
},
"repository": {
"type": "git",
"url": "https://github.com/MercuryWorkshop/bare-as-module3.git"
},
"author": {
"name": "Mercury Workshop",
"email": "support@mercurywork.shop",
"url": "https://mercurywork.shop"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -cw",
"prepublish": "npm run build"
},
"type": "module",
"license": "LGPL-3.0",
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^3.7.2",
"@mercuryworkshop/bare-mux": "^2.0.1",
"@rollup/plugin-inject": "^5.0.3",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"eslint": "^8.41.0",
"prettier": "^2.8.8",
"rollup": "^3.23.0",
"rollup-plugin-typescript2": "^0.34.1"
},
"files": [
"dist",
"lib"
],
"exports": {
".": {
"browser": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"node": {
"require": "./lib/index.cjs",
"import": "./lib/index.cjs"
}
}
},
"dependencies": {
"typescript": "^5.5.3"
}
}
"name": "@mercuryworkshop/bare-as-module3",
"version": "2.2.3",
"main": "./dist/index.js",
"homepage": "https://github.com/MercuryWorkshop/bare-as-module3",
"bugs": {
"url": "https://github.com/MercuryWorkshop/bare-as-module3/issues",
"email": "support@mercurywork.shop"
},
"repository": {
"type": "git",
"url": "https://github.com/MercuryWorkshop/bare-as-module3.git"
},
"author": {
"name": "Mercury Workshop",
"email": "support@mercurywork.shop",
"url": "https://mercurywork.shop"
},
"type": "module",
"license": "LGPL-3.0",
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@mercuryworkshop/bare-mux": "^2.1.2",
"@rollup/plugin-inject": "^5.0.5",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"eslint": "^9.12.0",
"prettier": "^3.3.3",
"rollup": "^4.24.0",
"rollup-plugin-typescript2": "^0.36.0"
},
"files": [
"dist",
"lib"
],
"exports": {
".": {
"browser": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"node": {
"require": "./lib/index.cjs",
"import": "./lib/index.cjs"
}
}
},
"dependencies": {
"typescript": "^5.6.3"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -cw",
"format": "prettier --config .prettierrc.js --write .",
"lint": "eslint ./src/",
"lint:fix": "eslint ./src/ --fix"
}
}

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