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

@divine/headers

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@divine/headers - npm Package Compare versions

Comparing version 1.3.3 to 2.0.0

8

build/src/auth-headers.d.ts
export interface AuthHeaderParams {
[name: string]: {
name: string;
value: string;

@@ -10,13 +11,14 @@ quoted?: boolean;

static split(unparsed: string): string[];
readonly scheme: string;
private _scheme;
readonly credentials?: string;
readonly params: AuthHeaderParams;
protected constructor(unparsed: string | AuthHeader, headerName: string);
get scheme(): string;
get realm(): string | undefined;
param(name: string): string | undefined;
param(name: string, fallback: string): string;
setParam(name: string, value: string | number | undefined, quoted?: boolean): this;
get realm(): string | undefined;
toString(): string;
isProxyHeader(): boolean;
protected formatParams(): string;
protected _formatParams(): string;
}

@@ -23,0 +25,0 @@ export declare class Authorization extends AuthHeader {

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

// const AUTH_HEADER = RegExp(`${AUTH_SCHEME.source}(?:(?<params>(?:${AUTH_PARAM.source})+)|${AUTH_TOKEN68.source})?`);
// This library must work in old browsers, so named capture groups :(
// This library must work in old browsers, so no named capture groups :(
const AUTH_SCHEME = /\s*([^,\s]+)/;

@@ -23,7 +23,6 @@ const AUTH_PARAM = /\s*([^=\s]+)\s*=\s*(?:"((?:\\(?:\\\\)*"|[^"])*)"|([^=,\s]+))\s*,?/;

constructor(unparsed, headerName) {
var _a;
this.headerName = headerName;
this.params = {};
if (unparsed instanceof AuthHeader) {
this.scheme = unparsed.scheme;
this._scheme = unparsed._scheme;
this.credentials = unparsed.credentials;

@@ -35,7 +34,7 @@ this.params = JSON.parse(JSON.stringify(unparsed.params));

const groups = parsed && headerGroups(parsed);
const scheme = (_a = groups === null || groups === void 0 ? void 0 : groups.scheme) === null || _a === void 0 ? void 0 : _a.toLowerCase();
const scheme = groups === null || groups === void 0 ? void 0 : groups.scheme;
if (!scheme || !groups /* make TS/ESLint happy */) {
throw new TypeError(`Failed to parse AuthHeader '${unparsed}': Invalid format`);
}
this.scheme = scheme;
this._scheme = scheme;
this.credentials = groups.token68;

@@ -46,3 +45,3 @@ if (groups.params) {

const quoted = groups.qvalue !== undefined;
this.params[groups.param] = { value: quoted ? groups.qvalue.replace(/\\(.)/g, '$1') : groups.value, quoted };
this.params[groups.param.toLowerCase()] = { name: groups.param, value: quoted ? groups.qvalue.replace(/\\(.)/g, '$1') : groups.value, quoted };
}

@@ -58,21 +57,24 @@ }

}
get scheme() {
return this._scheme.toLowerCase();
}
get realm() {
return this.param('realm');
}
param(name, fallback) {
var _a, _b;
return (_b = (_a = this.params[name]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : fallback;
return (_b = (_a = this.params[name.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : fallback;
}
setParam(name, value, quoted) {
if (value !== undefined) {
this.params[name] = { value: String(value), quoted };
this.params[name.toLowerCase()] = { name, value: String(value), quoted };
}
else {
delete this.params[name];
delete this.params[name.toLowerCase()];
}
return this;
}
get realm() {
return this.param('realm');
}
toString() {
var _a;
return `${this.scheme} ${(_a = this.credentials) !== null && _a !== void 0 ? _a : this.formatParams()}`;
return `${this._scheme} ${(_a = this.credentials) !== null && _a !== void 0 ? _a : this._formatParams()}`;
}

@@ -82,8 +84,8 @@ isProxyHeader() {

}
formatParams() {
_formatParams() {
return Object.entries(this.params)
.map(([param, info]) => {
var _a;
return ((_a = info.quoted) !== null && _a !== void 0 ? _a : (!/^[-!#$%&'*+.0-9=A-Z^_`a-z|~]+$/.test(info.value) || param === 'realm' /* [sic!] */)) ? `${param}="${info.value.replace(/([\\"])/g, '\\$1')}"`
: `${param}=${info.value}`;
return ((_a = info.quoted) !== null && _a !== void 0 ? _a : (!/^[-!#$%&'*+.0-9=A-Z^_`a-z|~]+$/.test(info.value) || param === 'realm' /* [sic!] */)) ? `${info.name}="${info.value.replace(/([\\"])/g, '\\$1')}"`
: `${info.name}=${info.value}`;
})

@@ -138,2 +140,2 @@ .join(', ');

exports.WWWAuthenticate = WWWAuthenticate;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC1oZWFkZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2F1dGgtaGVhZGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFJQSxvQ0FBb0M7QUFDcEMsZ0RBQWdEO0FBQ2hELHFIQUFxSDtBQUNySCxtRUFBbUU7QUFDbkUsd0hBQXdIO0FBRXhILHFFQUFxRTtBQUNyRSxNQUFNLFdBQVcsR0FBSSxjQUFjLENBQUM7QUFDcEMsTUFBTSxVQUFVLEdBQUssbUVBQW1FLENBQUM7QUFDekYsTUFBTSxZQUFZLEdBQUcsZ0NBQWdDLENBQUM7QUFDdEQsTUFBTSxXQUFXLEdBQUksTUFBTSxDQUFDLEdBQUcsV0FBVyxDQUFDLE1BQU0sVUFBVSxVQUFVLENBQUMsTUFBTSxPQUFPLFlBQVksQ0FBQyxNQUFNLElBQUksQ0FBQyxDQUFDO0FBRTVHLFNBQVMsZUFBZSxDQUFDLE1BQXdCO0lBQzdDLE9BQU8sRUFBRSxLQUFLLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxFQUFFLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsS0FBSyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDO0FBQ3JFLENBQUM7QUFFRCxTQUFTLFlBQVksQ0FBQyxPQUF5QjtJQUMzQyxPQUFPLEVBQUUsTUFBTSxFQUFFLE9BQU8sQ0FBQyxDQUFDLENBQUMsRUFBRSxNQUFNLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQyxFQUFFLEtBQUssRUFBRSxPQUFPLENBQUMsQ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kFBa0IsQ0FBQyxDQUFDO0lBQ3ZFLENBQUM7Q0FDSjtBQWxCRCwwQ0FrQkMifQ==

@@ -1,7 +0,13 @@

import { KVPairs } from './common';
export declare class ContentHeader {
export interface ContentHeaderParams {
[name: string]: {
name: string;
value: string;
} | undefined;
}
export declare abstract class ContentHeader {
readonly headerName?: string | undefined;
readonly type: string;
readonly params: KVPairs;
private _type;
readonly params: ContentHeaderParams;
constructor(unparsed: string | ContentHeader, headerName?: string | undefined);
get type(): string;
param(name: string): string | undefined;

@@ -8,0 +14,0 @@ param(name: string, fallback: string): string;

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

if (unparsed instanceof ContentHeader) {
this.type = unparsed.type;
this._type = unparsed._type;
this.params = JSON.parse(JSON.stringify(unparsed.params));

@@ -15,5 +15,5 @@ return;

const [, type, params] = /\s*([^\s;]*)\s*(.*)/.exec(unparsed);
this.type = type;
this._type = type;
for (let pr = /;\s*([^\s=]*)\s*=\s*(?:([^";]+)|"((?:[^"\\]|\\.)*)")[^;]*/g, param = pr.exec(params); param; param = pr.exec(params)) {
let name = param[1].toLowerCase();
let name = param[1];
let value = param[2] !== undefined ? param[2] : param[3].replace(/\\(.)/g, '$1');

@@ -34,19 +34,22 @@ if (name.endsWith('*')) {

name = name.substr(0, name.length - 1);
delete this.params[name];
delete this.params[name.toLowerCase()];
}
if (this.params[name] === undefined) {
this.params[name] = value;
if (this.params[name.toLowerCase()] === undefined) {
this.params[name.toLowerCase()] = { name, value };
}
}
}
get type() {
return this._type.toLowerCase();
}
param(name, fallback) {
var _a;
return (_a = this.params[name]) !== null && _a !== void 0 ? _a : fallback;
var _a, _b;
return (_b = (_a = this.params[name.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : fallback;
}
setParam(name, value) {
if (value !== undefined) {
this.params[name] = String(value);
this.params[name.toLowerCase()] = { name, value: String(value) };
}
else {
delete this.params[name];
delete this.params[name.toLowerCase()];
}

@@ -57,7 +60,7 @@ return this;

let params = '';
for (const [name, value] of Object.entries(this.params)) {
const safe = value.replace(/[^\u0020-\u007e]/g, '_');
params += `;${name}="${safe.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
if (safe !== value) {
params += `;${name}*=utf-8''${percentEncode(value)}`;
for (const param of Object.values(this.params)) {
const safe = param.value.replace(/[^\u0020-\u007e]/g, '_');
params += `;${param.name}="${safe.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
if (safe !== param.value) {
params += `;${param.name}*=utf-8''${percentEncode(param.value)}`;
}

@@ -132,2 +135,2 @@ }

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGVudC1oZWFkZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRlbnQtaGVhZGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxNQUFhLGFBQWE7SUFJdEIsWUFBWSxRQUFnQyxFQUFrQixVQUFtQjtRQUFuQixlQUFVLEdBQVYsVUFBVSxDQUFTO1FBRnhFLFdBQU0sR0FBWSxFQUFFLENBQUM7UUFHMUIsSUFBSSxRQUFRLFlBQVksYUFBYSxFQUFFO1lBQ25DLElBQUksQ0FBQyxJQUFJLEdBQUssUUFBUSxDQUFDLElBQUksQ0FBQztZQUM1QixJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztZQUMxRCxPQUFPO1NBQ1Y7UUFFRCxNQUFNLENBQUMsRUFBRSxJQUFJLEVBQUUsTUFBTSxDQUFDLEdBQUcscUJBQXFCLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBRSxDQUFDO1FBRS9ELElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBRWpCLEtBQUssSUFBSSxFQU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sU0FBUyxFQUFFLENBQUMsQ0FBQyxFQUFFLENBQUMsR0FBRyxHQUFHLENBQUMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7QUFDbkYsQ0FBQyJ9
export * from './auth-headers';
export * from './common';
export * from './content-headers';
//# sourceMappingURL=index.d.ts.map

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

tslib_1.__exportStar(require("./auth-headers"), exports);
tslib_1.__exportStar(require("./common"), exports);
tslib_1.__exportStar(require("./content-headers"), exports);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEseURBQStCO0FBQy9CLG1EQUF5QjtBQUN6Qiw0REFBa0MifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEseURBQStCO0FBQy9CLDREQUFrQyJ9
{
"name": "@divine/headers",
"version": "1.3.3",
"version": "2.0.0",
"description": "The Divine HTTP Header Library",

@@ -24,6 +24,4 @@ "author": "Martin Blom <martin@blom.org>",

"dependencies": {
"tslib": "^2.1.0"
},
"devDependencies": {
"tslib": "^2.3.1"
}
}
}
export interface AuthHeaderParams {
[name: string]: { value: string, quoted?: boolean } | undefined;
[name: string]: { name: string, value: string, quoted?: boolean } | undefined;
}

@@ -11,3 +11,3 @@

// This library must work in old browsers, so named capture groups :(
// This library must work in old browsers, so no named capture groups :(
const AUTH_SCHEME = /\s*([^,\s]+)/;

@@ -37,3 +37,3 @@ const AUTH_PARAM = /\s*([^=\s]+)\s*=\s*(?:"((?:\\(?:\\\\)*"|[^"])*)"|([^=,\s]+))\s*,?/;

readonly scheme!: string;
private _scheme!: string;
readonly credentials?: string;

@@ -44,3 +44,3 @@ readonly params: AuthHeaderParams = {};

if (unparsed instanceof AuthHeader) {
this.scheme = unparsed.scheme;
this._scheme = unparsed._scheme;
this.credentials = unparsed.credentials;

@@ -53,3 +53,3 @@ this.params = JSON.parse(JSON.stringify(unparsed.params));

const groups = parsed && headerGroups(parsed);
const scheme = groups?.scheme?.toLowerCase();
const scheme = groups?.scheme;

@@ -60,3 +60,3 @@ if (!scheme || !groups /* make TS/ESLint happy */) {

this.scheme = scheme;
this._scheme = scheme;
this.credentials = groups.token68;

@@ -69,3 +69,3 @@

this.params[groups.param] = { value: quoted ? groups.qvalue.replace(/\\(.)/g, '$1') : groups.value, quoted };
this.params[groups.param.toLowerCase()] = { name: groups.param, value: quoted ? groups.qvalue.replace(/\\(.)/g, '$1') : groups.value, quoted };
}

@@ -75,6 +75,14 @@ }

get scheme(): string {
return this._scheme.toLowerCase();
}
get realm(): string | undefined {
return this.param('realm');
}
param(name: string): string | undefined;
param(name: string, fallback: string): string;
param(name: string, fallback?: string): string | undefined {
return this.params[name]?.value ?? fallback;
return this.params[name.toLowerCase()]?.value ?? fallback;
}

@@ -84,6 +92,6 @@

if (value !== undefined) {
this.params[name] = { value: String(value), quoted };
this.params[name.toLowerCase()] = { name, value: String(value), quoted };
}
else {
delete this.params[name];
delete this.params[name.toLowerCase()];
}

@@ -94,10 +102,6 @@

get realm(): string | undefined {
return this.param('realm');
toString(): string {
return `${this._scheme} ${this.credentials ?? this._formatParams()}`;
}
toString() {
return `${this.scheme} ${this.credentials ?? this.formatParams()}`;
}
isProxyHeader(): boolean {

@@ -107,7 +111,7 @@ return this.headerName.startsWith('proxy-');

protected formatParams() {
protected _formatParams(): string {
return Object.entries(this.params)
.map(([param, info]) => info!.quoted ?? (!/^[-!#$%&'*+.0-9=A-Z^_`a-z|~]+$/.test(info!.value) || param === 'realm' /* [sic!] */)
? `${param}="${info!.value.replace(/([\\"])/g, '\\$1')}"`
: `${param}=${info!.value}`)
? `${info!.name}="${info!.value.replace(/([\\"])/g, '\\$1')}"`
: `${info!.name}=${info!.value}`)
.join(', ');

@@ -114,0 +118,0 @@ }

@@ -1,10 +0,12 @@

import { KVPairs } from './common';
export interface ContentHeaderParams {
[name: string]: { name: string, value: string } | undefined;
}
export class ContentHeader {
readonly type: string;
readonly params: KVPairs = {};
export abstract class ContentHeader {
private _type: string;
readonly params: ContentHeaderParams = {};
constructor(unparsed: string | ContentHeader, public readonly headerName?: string) {
if (unparsed instanceof ContentHeader) {
this.type = unparsed.type;
this._type = unparsed._type;
this.params = JSON.parse(JSON.stringify(unparsed.params));

@@ -16,6 +18,6 @@ return;

this.type = type;
this._type = type;
for (let pr = /;\s*([^\s=]*)\s*=\s*(?:([^";]+)|"((?:[^"\\]|\\.)*)")[^;]*/g, param = pr.exec(params); param; param = pr.exec(params)) {
let name = param[1].toLowerCase();
let name = param[1];
let value = param[2] !== undefined ? param[2] : param[3].replace(/\\(.)/g, '$1');

@@ -39,7 +41,7 @@

name = name.substr(0, name.length - 1);
delete this.params[name];
delete this.params[name.toLowerCase()];
}
if (this.params[name] === undefined) {
this.params[name] = value;
if (this.params[name.toLowerCase()] === undefined) {
this.params[name.toLowerCase()] = { name, value };
}

@@ -49,6 +51,10 @@ }

get type(): string {
return this._type.toLowerCase();
}
param(name: string): string | undefined;
param(name: string, fallback: string): string;
param(name: string, fallback?: string): string | undefined {
return this.params[name] ?? fallback;
return this.params[name.toLowerCase()]?.value ?? fallback;
}

@@ -58,6 +64,6 @@

if (value !== undefined) {
this.params[name] = String(value);
this.params[name.toLowerCase()] = { name, value: String(value) };
}
else {
delete this.params[name];
delete this.params[name.toLowerCase()];
}

@@ -71,9 +77,9 @@

for (const [name, value] of Object.entries(this.params)) {
const safe = value!.replace(/[^\u0020-\u007e]/g, '_');
for (const param of Object.values(this.params)) {
const safe = param!.value.replace(/[^\u0020-\u007e]/g, '_');
params += `;${name}="${safe.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
params += `;${param!.name}="${safe.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
if (safe !== value) {
params += `;${name}*=utf-8''${percentEncode(value!)}`;
if (safe !== param!.value) {
params += `;${param!.name}*=utf-8''${percentEncode(param!.value!)}`;
}

@@ -91,5 +97,5 @@ }

export class ContentDisposition extends ContentHeader {
static get attachment() { return new ContentDisposition('attachment'); }
static get inline() { return new ContentDisposition('inline'); }
static get formData() { return new ContentDisposition('form-data'); }
static get attachment() : ContentDisposition { return new ContentDisposition('attachment'); }
static get inline() : ContentDisposition { return new ContentDisposition('inline'); }
static get formData() : ContentDisposition { return new ContentDisposition('form-data'); }

@@ -118,12 +124,12 @@ static create(cd: string | ContentDisposition | null | undefined, fallback?: string | ContentDisposition | null): ContentDisposition {

export class ContentType extends ContentHeader {
static get bytes() { return new ContentType('application/octet-stream'); }
static get csv() { return new ContentType('text/csv'); }
static get dir() { return new ContentType('application/vnd.esxx.directory+json'); }
static get formData() { return new ContentType('multipart/form-data'); }
static get html() { return new ContentType('text/html'); }
static get json() { return new ContentType('application/json'); }
static get stream() { return new ContentType('application/vnd.esxx.octet-stream'); }
static get text() { return new ContentType('text/plain'); }
static get urlencoded() { return new ContentType('application/x-www-form-urlencoded'); }
static get xml() { return new ContentType('application/xml'); }
static get bytes() : ContentType { return new ContentType('application/octet-stream'); }
static get csv() : ContentType { return new ContentType('text/csv'); }
static get dir() : ContentType { return new ContentType('application/vnd.esxx.directory+json'); }
static get formData() : ContentType { return new ContentType('multipart/form-data'); }
static get html() : ContentType { return new ContentType('text/html'); }
static get json() : ContentType { return new ContentType('application/json'); }
static get stream() : ContentType { return new ContentType('application/vnd.esxx.octet-stream'); }
static get text() : ContentType { return new ContentType('text/plain'); }
static get urlencoded() : ContentType { return new ContentType('application/x-www-form-urlencoded'); }
static get xml() : ContentType { return new ContentType('application/xml'); }

@@ -130,0 +136,0 @@ static create(ct: string | ContentType | null | undefined, fallback?: string | ContentType | null): ContentType {

export * from './auth-headers';
export * from './common';
export * from './content-headers';

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