Skip to content

Commit

Permalink
fix: remove http dep to fix app dir support (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus authored Dec 18, 2023
1 parent a7f94b1 commit 564e273
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [16.6.8] - 2023-12-18

- Fix App dir support by removing the import of the "http" module

## [16.6.7] - 2023-12-18

- Adds facebook user data by checking the scopes provided in the config
Expand Down
40 changes: 14 additions & 26 deletions lib/build/framework/custom/nodeHeaders.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
"use strict";
// @ts-nocheck This is basically plain JS from another lib
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromRawHeaders = void 0;
/* From https://github.com/lquixada/node-fetch/blob/master/src/headers.js */
Expand All @@ -21,27 +16,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/
const util_1 = require("util");
const http_1 = __importDefault(require("http"));
const validateHeaderName =
typeof http_1.default.validateHeaderName === "function"
? http_1.default.validateHeaderName
: (name) => {
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
const err = new TypeError(`Header name must be a valid HTTP token [${name}]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
throw err;
}
};
const validateHeaderValue =
typeof http_1.default.validateHeaderValue === "function"
? http_1.default.validateHeaderValue
: (name, value) => {
if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
const err = new TypeError(`Invalid character in header content ["${name}"]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_CHAR" });
throw err;
}
};
const validateHeaderName = (name) => {
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
const err = new TypeError(`Header name must be a valid HTTP token [${name}]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
throw err;
}
};
const validateHeaderValue = (name, value) => {
if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
const err = new TypeError(`Invalid character in header content ["${name}"]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_CHAR" });
throw err;
}
};
/**
* @typedef {Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>} HeadersInit
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/build/version.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/build/version.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 16 additions & 23 deletions lib/ts/framework/custom/nodeHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,22 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/

import { types } from "util";
import http from "http";

const validateHeaderName =
typeof http.validateHeaderName === "function"
? http.validateHeaderName
: (name) => {
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
const err = new TypeError(`Header name must be a valid HTTP token [${name}]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
throw err;
}
};

const validateHeaderValue =
typeof http.validateHeaderValue === "function"
? http.validateHeaderValue
: (name, value) => {
if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
const err = new TypeError(`Invalid character in header content ["${name}"]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_CHAR" });
throw err;
}
};

const validateHeaderName = (name) => {
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
const err = new TypeError(`Header name must be a valid HTTP token [${name}]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
throw err;
}
};

const validateHeaderValue = (name, value) => {
if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
const err = new TypeError(`Invalid character in header content ["${name}"]`);
Object.defineProperty(err, "code", { value: "ERR_INVALID_CHAR" });
throw err;
}
};

/**
* @typedef {Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>} HeadersInit
Expand Down
2 changes: 1 addition & 1 deletion lib/ts/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
export const version = "16.6.7";
export const version = "16.6.8";

export const cdiSupported = ["4.0"];

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supertokens-node",
"version": "16.6.7",
"version": "16.6.8",
"description": "NodeJS driver for SuperTokens core",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 564e273

Please sign in to comment.