@checkdigit/hash 2.0.0-PR.14-adca → 2.0.0-PR.14-b2e8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist-cjs/hash.spec.cjs +0 -49
- package/dist-cjs/uuid-v5.spec.cjs +0 -74
- package/dist-mjs/hash.spec.mjs +0 -25
- package/dist-mjs/uuid-v5.spec.mjs +0 -50
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/hash","version":"2.0.0-PR.14-
|
|
1
|
+
{"name":"@checkdigit/hash","version":"2.0.0-PR.14-b2e8","description":"Hash is a small function for Check Digit services to create a uuid derived from a hash generated from a given value.","exports":{".":{"types":"./dist-mjs/index.d.ts","require":"./dist-cjs/index.cjs","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["dist-cjs","!dist-cjs/**/*.test.cjs","!dist-cjs/**/*.spec.cjs","dist-mjs","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md","/src/"],"prettier":"@checkdigit/prettier-config","engines":{"node":">=16"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/hash.git"},"author":"Check Digit, LLC","license":"MIT","bugs":{"url":"https://github.com/checkdigit/hash/issues"},"homepage":"https://github.com/checkdigit/hash#readme","devDependencies":{"@checkdigit/eslint-config":"^7.8.0","@checkdigit/jest-config":"^2.2.1","@checkdigit/prettier-config":"^3.4.0","@checkdigit/typescript-config":"^3.4.0","@types/uuid":"^9.0.1","rimraf":"^5.0.1","uuid":"^9.0.0"},"eslintConfig":{"extends":["@checkdigit/eslint-config"]},"jest":{"preset":"@checkdigit/jest-config"},"scripts":{"prepublishOnly":"npm run build:dist-cjs && npm run build:dist-esm && rimraf .github tsconfig.json","build:dist-cjs":"rimraf dist-cjs && npx builder --type=commonjs --outDir=dist-cjs","build:dist-esm":"rimraf dist-esm && npx builder --type=module --outDir=dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","lint:fix":"eslint -f unix --ext .ts,.mts src --fix","lint":"eslint -f unix --ext .ts,.mts src","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style","ci:compile":"tsc --noEmit","ci:test":"jest --coverage=false","ci:coverage":"jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier"}}
|
package/dist-cjs/hash.spec.cjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
|
|
25
|
-
// src/hash.spec.ts
|
|
26
|
-
var import_node_assert = require("node:assert");
|
|
27
|
-
var import_uuid = require("uuid");
|
|
28
|
-
var import_hash = __toESM(require("./hash.cjs"));
|
|
29
|
-
describe("hash", () => {
|
|
30
|
-
it("returns a uuid derived from hash of value", () => {
|
|
31
|
-
const result1 = (0, import_hash.default)("string to be hashed into a uuid");
|
|
32
|
-
const result2 = (0, import_hash.default)("string to be hashed into a uuid");
|
|
33
|
-
import_node_assert.strict.ok((0, import_uuid.validate)(result1) && (0, import_uuid.validate)(result2));
|
|
34
|
-
import_node_assert.strict.equal(result1, result2);
|
|
35
|
-
});
|
|
36
|
-
it("hash always returns the same value", () => {
|
|
37
|
-
import_node_assert.strict.equal((0, import_hash.default)("Hello World!"), "74caf525-c85a-5a3c-9d53-bef0507c21e4");
|
|
38
|
-
import_node_assert.strict.equal((0, import_hash.default)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55"), "14abff19-2c5f-5408-af3d-3c6526ebea73");
|
|
39
|
-
import_node_assert.strict.equal((0, import_hash.default)("R\xE5ma Ghant\xE5"), "8a28bfef-8fa2-52de-b9c5-1d5a6d7ba5fe");
|
|
40
|
-
import_node_assert.strict.equal(
|
|
41
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
42
|
-
(0, import_hash.default)("/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1"),
|
|
43
|
-
"7cb123ec-2c42-5a8a-b358-adf113ee088d"
|
|
44
|
-
);
|
|
45
|
-
import_node_assert.strict.equal((0, import_hash.default)("nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE="), "e90938db-61fb-55b4-8ebe-4e1518e4fe97");
|
|
46
|
-
import_node_assert.strict.equal((0, import_hash.default)("5111111111111118"), "87e25c4b-c395-585e-9ecf-43d190f6e62f");
|
|
47
|
-
import_node_assert.strict.equal((0, import_hash.default)("https://checkdigit.com"), "2c391f52-ec24-5945-8c28-88f74d12b55d");
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
|
|
25
|
-
// src/uuid-v5.spec.ts
|
|
26
|
-
var import_node_assert = require("node:assert");
|
|
27
|
-
var import_uuid = require("uuid");
|
|
28
|
-
var import_hash = require("./hash.cjs");
|
|
29
|
-
var import_uuid_v5 = __toESM(require("./uuid-v5.cjs"));
|
|
30
|
-
describe("uuidV5", () => {
|
|
31
|
-
it("uuidV5 result matches v5(https://github.com/uuidjs/uuid) result", () => {
|
|
32
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("Hello World!", import_hash.HASH_NAMESPACE), (0, import_uuid.v5)("Hello World!", import_hash.HASH_NAMESPACE));
|
|
33
|
-
import_node_assert.strict.equal(
|
|
34
|
-
(0, import_uuid_v5.default)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55", import_hash.HASH_NAMESPACE),
|
|
35
|
-
(0, import_uuid.v5)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55", import_hash.HASH_NAMESPACE)
|
|
36
|
-
);
|
|
37
|
-
import_node_assert.strict.equal(
|
|
38
|
-
(0, import_uuid_v5.default)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz", import_hash.HASH_NAMESPACE),
|
|
39
|
-
(0, import_uuid.v5)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz", import_hash.HASH_NAMESPACE)
|
|
40
|
-
);
|
|
41
|
-
import_node_assert.strict.equal(
|
|
42
|
-
(0, import_uuid_v5.default)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC", import_hash.HASH_NAMESPACE),
|
|
43
|
-
(0, import_uuid.v5)("d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC", import_hash.HASH_NAMESPACE)
|
|
44
|
-
);
|
|
45
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("R\xE5ma Ghant\xE5", import_hash.HASH_NAMESPACE), (0, import_uuid.v5)("R\xE5ma Ghant\xE5", import_hash.HASH_NAMESPACE));
|
|
46
|
-
import_node_assert.strict.equal(
|
|
47
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
48
|
-
(0, import_uuid_v5.default)("/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1", import_hash.HASH_NAMESPACE),
|
|
49
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
50
|
-
(0, import_uuid.v5)("/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1", import_hash.HASH_NAMESPACE)
|
|
51
|
-
);
|
|
52
|
-
import_node_assert.strict.equal(
|
|
53
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
54
|
-
(0, import_uuid_v5.default)("nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=", import_hash.HASH_NAMESPACE),
|
|
55
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
56
|
-
(0, import_uuid.v5)("nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=", import_hash.HASH_NAMESPACE)
|
|
57
|
-
);
|
|
58
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("5111111111111118", import_hash.HASH_NAMESPACE), (0, import_uuid.v5)("5111111111111118", import_hash.HASH_NAMESPACE));
|
|
59
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("https://checkdigit.com", import_hash.HASH_NAMESPACE), (0, import_uuid.v5)("https://checkdigit.com", import_hash.HASH_NAMESPACE));
|
|
60
|
-
});
|
|
61
|
-
it("v5 - from https://github.com/uuidjs/uuid testing", () => {
|
|
62
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("hello.example.com", import_uuid.v5.DNS), "fdda765f-fc57-5604-a269-52a7df8164ec");
|
|
63
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("http://example.com/hello", import_uuid.v5.URL), "3bbcee75-cecc-5b56-8031-b6641c1ed1f1");
|
|
64
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("hello", "0f5abcd1-c194-47f3-905b-2df7263a084b"), "90123e1c-7512-523e-bb28-76fab9f2f73d");
|
|
65
|
-
});
|
|
66
|
-
it("v5 namespace.toUpperCase - from https://github.com/uuidjs/uuid testing", () => {
|
|
67
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("hello.example.com", import_uuid.v5.DNS.toUpperCase()), "fdda765f-fc57-5604-a269-52a7df8164ec");
|
|
68
|
-
import_node_assert.strict.equal((0, import_uuid_v5.default)("http://example.com/hello", import_uuid.v5.URL.toUpperCase()), "3bbcee75-cecc-5b56-8031-b6641c1ed1f1");
|
|
69
|
-
import_node_assert.strict.equal(
|
|
70
|
-
(0, import_uuid_v5.default)("hello", "0f5abcd1-c194-47f3-905b-2df7263a084b".toUpperCase()),
|
|
71
|
-
"90123e1c-7512-523e-bb28-76fab9f2f73d"
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
});
|
package/dist-mjs/hash.spec.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/hash.spec.ts
|
|
2
|
-
import { strict as assert } from "node:assert";
|
|
3
|
-
import { validate } from "uuid";
|
|
4
|
-
import hash from "./hash.mjs";
|
|
5
|
-
describe("hash", () => {
|
|
6
|
-
it("returns a uuid derived from hash of value", () => {
|
|
7
|
-
const result1 = hash("string to be hashed into a uuid");
|
|
8
|
-
const result2 = hash("string to be hashed into a uuid");
|
|
9
|
-
assert.ok(validate(result1) && validate(result2));
|
|
10
|
-
assert.equal(result1, result2);
|
|
11
|
-
});
|
|
12
|
-
it("hash always returns the same value", () => {
|
|
13
|
-
assert.equal(hash("Hello World!"), "74caf525-c85a-5a3c-9d53-bef0507c21e4");
|
|
14
|
-
assert.equal(hash("d1253ec1-14bc-4c56-8e09-4450ab4c8a55"), "14abff19-2c5f-5408-af3d-3c6526ebea73");
|
|
15
|
-
assert.equal(hash("R\xE5ma Ghant\xE5"), "8a28bfef-8fa2-52de-b9c5-1d5a6d7ba5fe");
|
|
16
|
-
assert.equal(
|
|
17
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
18
|
-
hash("/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1"),
|
|
19
|
-
"7cb123ec-2c42-5a8a-b358-adf113ee088d"
|
|
20
|
-
);
|
|
21
|
-
assert.equal(hash("nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE="), "e90938db-61fb-55b4-8ebe-4e1518e4fe97");
|
|
22
|
-
assert.equal(hash("5111111111111118"), "87e25c4b-c395-585e-9ecf-43d190f6e62f");
|
|
23
|
-
assert.equal(hash("https://checkdigit.com"), "2c391f52-ec24-5945-8c28-88f74d12b55d");
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// src/uuid-v5.spec.ts
|
|
2
|
-
import { strict as assert } from "node:assert";
|
|
3
|
-
import { v5 } from "uuid";
|
|
4
|
-
import { HASH_NAMESPACE } from "./hash.mjs";
|
|
5
|
-
import uuidV5 from "./uuid-v5.mjs";
|
|
6
|
-
describe("uuidV5", () => {
|
|
7
|
-
it("uuidV5 result matches v5(https://github.com/uuidjs/uuid) result", () => {
|
|
8
|
-
assert.equal(uuidV5("Hello World!", HASH_NAMESPACE), v5("Hello World!", HASH_NAMESPACE));
|
|
9
|
-
assert.equal(
|
|
10
|
-
uuidV5("d1253ec1-14bc-4c56-8e09-4450ab4c8a55", HASH_NAMESPACE),
|
|
11
|
-
v5("d1253ec1-14bc-4c56-8e09-4450ab4c8a55", HASH_NAMESPACE)
|
|
12
|
-
);
|
|
13
|
-
assert.equal(
|
|
14
|
-
uuidV5("d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz", HASH_NAMESPACE),
|
|
15
|
-
v5("d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz", HASH_NAMESPACE)
|
|
16
|
-
);
|
|
17
|
-
assert.equal(
|
|
18
|
-
uuidV5("d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC", HASH_NAMESPACE),
|
|
19
|
-
v5("d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC", HASH_NAMESPACE)
|
|
20
|
-
);
|
|
21
|
-
assert.equal(uuidV5("R\xE5ma Ghant\xE5", HASH_NAMESPACE), v5("R\xE5ma Ghant\xE5", HASH_NAMESPACE));
|
|
22
|
-
assert.equal(
|
|
23
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
24
|
-
uuidV5("/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1", HASH_NAMESPACE),
|
|
25
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
26
|
-
v5("/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1", HASH_NAMESPACE)
|
|
27
|
-
);
|
|
28
|
-
assert.equal(
|
|
29
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
30
|
-
uuidV5("nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=", HASH_NAMESPACE),
|
|
31
|
-
// eslint-disable-next-line no-secrets/no-secrets
|
|
32
|
-
v5("nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=", HASH_NAMESPACE)
|
|
33
|
-
);
|
|
34
|
-
assert.equal(uuidV5("5111111111111118", HASH_NAMESPACE), v5("5111111111111118", HASH_NAMESPACE));
|
|
35
|
-
assert.equal(uuidV5("https://checkdigit.com", HASH_NAMESPACE), v5("https://checkdigit.com", HASH_NAMESPACE));
|
|
36
|
-
});
|
|
37
|
-
it("v5 - from https://github.com/uuidjs/uuid testing", () => {
|
|
38
|
-
assert.equal(uuidV5("hello.example.com", v5.DNS), "fdda765f-fc57-5604-a269-52a7df8164ec");
|
|
39
|
-
assert.equal(uuidV5("http://example.com/hello", v5.URL), "3bbcee75-cecc-5b56-8031-b6641c1ed1f1");
|
|
40
|
-
assert.equal(uuidV5("hello", "0f5abcd1-c194-47f3-905b-2df7263a084b"), "90123e1c-7512-523e-bb28-76fab9f2f73d");
|
|
41
|
-
});
|
|
42
|
-
it("v5 namespace.toUpperCase - from https://github.com/uuidjs/uuid testing", () => {
|
|
43
|
-
assert.equal(uuidV5("hello.example.com", v5.DNS.toUpperCase()), "fdda765f-fc57-5604-a269-52a7df8164ec");
|
|
44
|
-
assert.equal(uuidV5("http://example.com/hello", v5.URL.toUpperCase()), "3bbcee75-cecc-5b56-8031-b6641c1ed1f1");
|
|
45
|
-
assert.equal(
|
|
46
|
-
uuidV5("hello", "0f5abcd1-c194-47f3-905b-2df7263a084b".toUpperCase()),
|
|
47
|
-
"90123e1c-7512-523e-bb28-76fab9f2f73d"
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
});
|