initial update
This commit is contained in:
9
node_modules/@apollo/utils.createhash/src/__tests__/createHash.test.ts
generated
vendored
Normal file
9
node_modules/@apollo/utils.createhash/src/__tests__/createHash.test.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createHash } from "..";
|
||||
|
||||
describe("createHash", () => {
|
||||
it("creates a hash", () => {
|
||||
expect(createHash("sha256").update("foo").digest("hex")).toEqual(
|
||||
"2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
||||
);
|
||||
});
|
||||
});
|
||||
6
node_modules/@apollo/utils.createhash/src/__tests__/exports.test.ts
generated
vendored
Normal file
6
node_modules/@apollo/utils.createhash/src/__tests__/exports.test.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as allExports from "..";
|
||||
|
||||
it("exports hashing functions", () => {
|
||||
expect(Object.keys(allExports).length).toBe(1);
|
||||
expect(typeof allExports.createHash).toBe("function");
|
||||
});
|
||||
5
node_modules/@apollo/utils.createhash/src/__tests__/tsconfig.json
generated
vendored
Normal file
5
node_modules/@apollo/utils.createhash/src/__tests__/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.test.base",
|
||||
"include": ["**/*"],
|
||||
"references": [{ "path": "../../" }]
|
||||
}
|
||||
16
node_modules/@apollo/utils.createhash/src/index.ts
generated
vendored
Normal file
16
node_modules/@apollo/utils.createhash/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { isNodeLike } from "@apollo/utils.isnodelike";
|
||||
|
||||
export function createHash(kind: string): import("crypto").Hash {
|
||||
// Some Node-like environments (like next.js Turbopack) apparently
|
||||
// don't have module.require, so double-check before we call it.
|
||||
// (But don't change the value of isNodeLike because other logic depends on it,
|
||||
// like Apollo Server signal handling defaults.) This does mean that
|
||||
// Turbopack will call sha.js instead of the native crypto module, but
|
||||
// it sure beats throwing because module.require does not exist.
|
||||
if (isNodeLike && module.require) {
|
||||
// Use module.require instead of just require to avoid bundling whatever
|
||||
// crypto polyfills a non-Node bundler might fall back to.
|
||||
return module.require("crypto").createHash(kind);
|
||||
}
|
||||
return require("sha.js")(kind);
|
||||
}
|
||||
Reference in New Issue
Block a user