orb-billing
Advanced tools
Comparing version 1.34.0 to 1.34.1
# Changelog | ||
## 1.34.1 (2024-01-04) | ||
Full Changelog: [v1.34.0...v1.34.1](https://github.com/orbcorp/orb-node/compare/v1.34.0...v1.34.1) | ||
### Bug Fixes | ||
* **headers:** always send lowercase headers and strip undefined (BREAKING in rare cases) ([#69](https://github.com/orbcorp/orb-node/issues/69)) ([b05815f](https://github.com/orbcorp/orb-node/commit/b05815fe17d2596b65f32af0c5e095b2a27af6f6)) | ||
## 1.34.0 (2024-01-01) | ||
@@ -4,0 +12,0 @@ |
@@ -105,2 +105,3 @@ | ||
}; | ||
private buildHeaders; | ||
/** | ||
@@ -107,0 +108,0 @@ * Used as a callback for mutating the given `RequestInit` object. |
50
core.js
@@ -207,13 +207,3 @@ "use strict"; | ||
} | ||
const reqHeaders = { | ||
...(contentLength && { 'Content-Length': contentLength }), | ||
...this.defaultHeaders(options), | ||
...headers, | ||
}; | ||
// let builtin fetch set the Content-Type for multipart bodies | ||
if ((0, uploads_1.isMultipartBody)(options.body) && index_1.kind !== 'node') { | ||
delete reqHeaders['Content-Type']; | ||
} | ||
// Strip any headers being explicitly omitted with null | ||
Object.keys(reqHeaders).forEach((key) => reqHeaders[key] === null && delete reqHeaders[key]); | ||
const reqHeaders = this.buildHeaders({ options, headers, contentLength }); | ||
const req = { | ||
@@ -228,5 +218,19 @@ method, | ||
}; | ||
this.validateHeaders(reqHeaders, headers); | ||
return { req, url, timeout }; | ||
} | ||
buildHeaders({ options, headers, contentLength, }) { | ||
const reqHeaders = {}; | ||
if (contentLength) { | ||
reqHeaders['content-length'] = contentLength; | ||
} | ||
const defaultHeaders = this.defaultHeaders(options); | ||
applyHeadersMut(reqHeaders, defaultHeaders); | ||
applyHeadersMut(reqHeaders, headers); | ||
// let builtin fetch set the Content-Type for multipart bodies | ||
if ((0, uploads_1.isMultipartBody)(options.body) && index_1.kind !== 'node') { | ||
delete reqHeaders['content-type']; | ||
} | ||
this.validateHeaders(reqHeaders, headers); | ||
return reqHeaders; | ||
} | ||
/** | ||
@@ -752,2 +756,24 @@ * Used as a callback for mutating the given `RequestInit` object. | ||
exports.hasOwn = hasOwn; | ||
/** | ||
* Copies headers from "newHeaders" onto "targetHeaders", | ||
* using lower-case for all properties, | ||
* ignoring any keys with undefined values, | ||
* and deleting any keys with null values. | ||
*/ | ||
function applyHeadersMut(targetHeaders, newHeaders) { | ||
for (const k in newHeaders) { | ||
if (!hasOwn(newHeaders, k)) | ||
continue; | ||
const lowerKey = k.toLowerCase(); | ||
if (!lowerKey) | ||
continue; | ||
const val = newHeaders[k]; | ||
if (val === null) { | ||
delete targetHeaders[lowerKey]; | ||
} | ||
else if (val !== undefined) { | ||
targetHeaders[lowerKey] = val; | ||
} | ||
} | ||
} | ||
function debug(action, ...args) { | ||
@@ -754,0 +780,0 @@ if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') { |
{ | ||
"name": "orb-billing", | ||
"version": "1.34.0", | ||
"version": "1.34.1", | ||
"description": "The official TypeScript library for the Orb API", | ||
@@ -5,0 +5,0 @@ "author": "Orb <team@withorb.com>", |
@@ -295,15 +295,4 @@ import { VERSION } from './version'; | ||
const reqHeaders: Record<string, string> = { | ||
...(contentLength && { 'Content-Length': contentLength }), | ||
...this.defaultHeaders(options), | ||
...headers, | ||
}; | ||
// let builtin fetch set the Content-Type for multipart bodies | ||
if (isMultipartBody(options.body) && shimsKind !== 'node') { | ||
delete reqHeaders['Content-Type']; | ||
} | ||
const reqHeaders = this.buildHeaders({ options, headers, contentLength }); | ||
// Strip any headers being explicitly omitted with null | ||
Object.keys(reqHeaders).forEach((key) => reqHeaders[key] === null && delete reqHeaders[key]); | ||
const req: RequestInit = { | ||
@@ -319,5 +308,31 @@ method, | ||
return { req, url, timeout }; | ||
} | ||
private buildHeaders({ | ||
options, | ||
headers, | ||
contentLength, | ||
}: { | ||
options: FinalRequestOptions; | ||
headers: Record<string, string | null | undefined>; | ||
contentLength: string | null | undefined; | ||
}): Record<string, string> { | ||
const reqHeaders: Record<string, string> = {}; | ||
if (contentLength) { | ||
reqHeaders['content-length'] = contentLength; | ||
} | ||
const defaultHeaders = this.defaultHeaders(options); | ||
applyHeadersMut(reqHeaders, defaultHeaders); | ||
applyHeadersMut(reqHeaders, headers); | ||
// let builtin fetch set the Content-Type for multipart bodies | ||
if (isMultipartBody(options.body) && shimsKind !== 'node') { | ||
delete reqHeaders['content-type']; | ||
} | ||
this.validateHeaders(reqHeaders, headers); | ||
return { req, url, timeout }; | ||
return reqHeaders; | ||
} | ||
@@ -1009,2 +1024,24 @@ | ||
/** | ||
* Copies headers from "newHeaders" onto "targetHeaders", | ||
* using lower-case for all properties, | ||
* ignoring any keys with undefined values, | ||
* and deleting any keys with null values. | ||
*/ | ||
function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void { | ||
for (const k in newHeaders) { | ||
if (!hasOwn(newHeaders, k)) continue; | ||
const lowerKey = k.toLowerCase(); | ||
if (!lowerKey) continue; | ||
const val = newHeaders[k]; | ||
if (val === null) { | ||
delete targetHeaders[lowerKey]; | ||
} else if (val !== undefined) { | ||
targetHeaders[lowerKey] = val; | ||
} | ||
} | ||
} | ||
export function debug(action: string, ...args: any[]) { | ||
@@ -1011,0 +1048,0 @@ if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') { |
@@ -1,1 +0,1 @@ | ||
export const VERSION = '1.34.0'; // x-release-please-version | ||
export const VERSION = '1.34.1'; // x-release-please-version |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.34.0"; | ||
export declare const VERSION = "1.34.1"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = '1.34.0'; // x-release-please-version | ||
exports.VERSION = '1.34.1'; // x-release-please-version | ||
//# sourceMappingURL=version.js.map |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2351778
44093
3