Skip to content

Commit f986b45

Browse files
authored
Use node:buffer explicitly (#835)
While it works without explicit [`node:buffer`](https://github.com/nodejs/node/blob/main/doc/api/buffer.md) in a Node.js environment, it won't work in environments compatible with Node.js. There's no downside to explicitly using `node:buffer`. This change supports that.
1 parent 15f1770 commit f986b45

File tree

7 files changed

+7
-2
lines changed

7 files changed

+7
-2
lines changed

lib/http-fetch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Buffer } from "node:buffer";
12
import { Readable } from "node:stream";
23
import { HTTPFetchError } from "./exceptions.js";
34
import { USER_AGENT } from "./version.js";

lib/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as http from "node:http";
2+
import { Buffer } from "node:buffer";
23
import { JSONParseError, SignatureValidationFailed } from "./exceptions.js";
34
import * as Types from "./types.js";
45
import validateSignature from "./validate-signature.js";

lib/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Buffer } from "node:buffer";
12
import { JSONParseError } from "./exceptions.js";
23

34
export function toArray<T>(maybeArr: T | T[]): T[] {

lib/validate-signature.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Buffer } from "node:buffer";
12
import { createHmac, timingSafeEqual } from "node:crypto";
23

34
function s2b(str: string, encoding: BufferEncoding): Buffer {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"types": "./dist/cjs/index.d.ts",
2020
"default": "./dist/cjs/index.js"
2121
},
22-
"default": "./dist/cjs/index.js"
22+
"default": "./dist/cjs/index.js"
2323
},
2424
"./package.json": "./package.json"
2525
},
@@ -47,7 +47,6 @@
4747
"docs:preview": "vitepress preview docs",
4848
"docs:deploy": "./scripts/deploy-docs.sh",
4949
"apidocs": "typedoc --excludePrivate --plugin typedoc-plugin-markdown --out docs/apidocs lib/index.ts",
50-
"generate-changelog": "ts-node ./scripts/generate-changelog.ts",
5150
"release": "npm run build && npm publish --access public"
5251
},
5352
"repository": {

test/client.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readFileSync } from "node:fs";
2+
import { Buffer } from "node:buffer";
23
import { join } from "node:path";
34
import { deepEqual, equal, ok, strictEqual } from "node:assert";
45
import { URL } from "node:url";

test/helpers/test-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as bodyParser from "body-parser";
2+
import { Buffer } from "node:buffer";
23
import express from "express";
34
import { Server } from "node:http";
45
import { join } from "node:path";

0 commit comments

Comments
 (0)