@checkdigit/hash 2.0.0-PR.14-2bb3 → 2.0.0-PR.14-adca

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.
@@ -0,0 +1,46 @@
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/hash.ts
31
+ var hash_exports = {};
32
+ __export(hash_exports, {
33
+ HASH_NAMESPACE: () => HASH_NAMESPACE,
34
+ default: () => hash_default
35
+ });
36
+ module.exports = __toCommonJS(hash_exports);
37
+ var import_node_crypto = require("node:crypto");
38
+ var import_uuid_v5 = __toESM(require("./uuid-v5.cjs"));
39
+ var HASH_NAMESPACE = "f25d4515-fea7-44c7-8baf-f3ca50865e66";
40
+ function hash_default(value) {
41
+ return (0, import_uuid_v5.default)((0, import_node_crypto.createHash)("sha512").update(value).digest("base64"), HASH_NAMESPACE);
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ HASH_NAMESPACE
46
+ });
@@ -3,4 +3,3 @@ export declare const HASH_NAMESPACE = "f25d4515-fea7-44c7-8baf-f3ca50865e66";
3
3
  * @param value - a string to be hashed and converted into a derived uuid
4
4
  */
5
5
  export default function (value: string): string;
6
- //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1,49 @@
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
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ HASH_NAMESPACE: () => import_hash2.HASH_NAMESPACE,
34
+ default: () => import_hash.default,
35
+ hash: () => import_hash2.default
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+ var import_hash = __toESM(require("./hash.cjs"));
39
+ var import_hash2 = __toESM(require("./hash.cjs"));
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ HASH_NAMESPACE,
43
+ hash
44
+ });
@@ -1,3 +1,2 @@
1
1
  export { default } from './hash';
2
2
  export { default as hash, HASH_NAMESPACE } from './hash';
3
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/uuid-v5.ts
21
+ var uuid_v5_exports = {};
22
+ __export(uuid_v5_exports, {
23
+ default: () => uuid_v5_default
24
+ });
25
+ module.exports = __toCommonJS(uuid_v5_exports);
26
+ var import_node_crypto = require("node:crypto");
27
+ function parse(namespace) {
28
+ let value;
29
+ const intArray = new Uint8Array(16);
30
+ intArray[0] = (value = Number.parseInt(namespace.slice(0, 8), 16)) >>> 24;
31
+ intArray[1] = value >>> 16 & 255;
32
+ intArray[2] = value >>> 8 & 255;
33
+ intArray[3] = value & 255;
34
+ intArray[4] = (value = Number.parseInt(namespace.slice(9, 13), 16)) >>> 8;
35
+ intArray[5] = value & 255;
36
+ intArray[6] = (value = Number.parseInt(namespace.slice(14, 18), 16)) >>> 8;
37
+ intArray[7] = value & 255;
38
+ intArray[8] = (value = Number.parseInt(namespace.slice(19, 23), 16)) >>> 8;
39
+ intArray[9] = value & 255;
40
+ intArray[10] = (value = Number.parseInt(namespace.slice(24, 36), 16)) / 1099511627776 & 255;
41
+ intArray[11] = value / 4294967296 & 255;
42
+ intArray[12] = value >>> 24 & 255;
43
+ intArray[13] = value >>> 16 & 255;
44
+ intArray[14] = value >>> 8 & 255;
45
+ intArray[15] = value & 255;
46
+ return intArray;
47
+ }
48
+ function uuid_v5_default(value, namespace) {
49
+ const buffer = (0, import_node_crypto.createHash)("sha1").update(parse(namespace)).update(value).digest();
50
+ buffer[6] = (buffer[6] ?? 0) & 15 | 80;
51
+ buffer[8] = (buffer[8] ?? 0) & 63 | 128;
52
+ const hex = buffer.toString("hex", 0, 16);
53
+ return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)].join("-").toLowerCase();
54
+ }
@@ -1,2 +1 @@
1
1
  export default function (value: string, namespace: string): string;
2
- //# sourceMappingURL=uuid-v5.d.ts.map
@@ -0,0 +1,74 @@
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
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const HASH_NAMESPACE = "f25d4515-fea7-44c7-8baf-f3ca50865e66";
2
+ /**
3
+ * @param value - a string to be hashed and converted into a derived uuid
4
+ */
5
+ export default function (value: string): string;
@@ -0,0 +1,11 @@
1
+ // src/hash.ts
2
+ import { createHash } from "node:crypto";
3
+ import uuidV5 from "./uuid-v5.mjs";
4
+ var HASH_NAMESPACE = "f25d4515-fea7-44c7-8baf-f3ca50865e66";
5
+ function hash_default(value) {
6
+ return uuidV5(createHash("sha512").update(value).digest("base64"), HASH_NAMESPACE);
7
+ }
8
+ export {
9
+ HASH_NAMESPACE,
10
+ hash_default as default
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
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
+ });
@@ -0,0 +1,2 @@
1
+ export { default } from './hash';
2
+ export { default as hash, HASH_NAMESPACE } from './hash';
@@ -0,0 +1,8 @@
1
+ // src/index.ts
2
+ import { default as default2 } from "./hash.mjs";
3
+ import { default as default3, HASH_NAMESPACE } from "./hash.mjs";
4
+ export {
5
+ HASH_NAMESPACE,
6
+ default2 as default,
7
+ default3 as hash
8
+ };
@@ -0,0 +1 @@
1
+ export default function (value: string, namespace: string): string;
@@ -0,0 +1,33 @@
1
+ // src/uuid-v5.ts
2
+ import { createHash } from "node:crypto";
3
+ function parse(namespace) {
4
+ let value;
5
+ const intArray = new Uint8Array(16);
6
+ intArray[0] = (value = Number.parseInt(namespace.slice(0, 8), 16)) >>> 24;
7
+ intArray[1] = value >>> 16 & 255;
8
+ intArray[2] = value >>> 8 & 255;
9
+ intArray[3] = value & 255;
10
+ intArray[4] = (value = Number.parseInt(namespace.slice(9, 13), 16)) >>> 8;
11
+ intArray[5] = value & 255;
12
+ intArray[6] = (value = Number.parseInt(namespace.slice(14, 18), 16)) >>> 8;
13
+ intArray[7] = value & 255;
14
+ intArray[8] = (value = Number.parseInt(namespace.slice(19, 23), 16)) >>> 8;
15
+ intArray[9] = value & 255;
16
+ intArray[10] = (value = Number.parseInt(namespace.slice(24, 36), 16)) / 1099511627776 & 255;
17
+ intArray[11] = value / 4294967296 & 255;
18
+ intArray[12] = value >>> 24 & 255;
19
+ intArray[13] = value >>> 16 & 255;
20
+ intArray[14] = value >>> 8 & 255;
21
+ intArray[15] = value & 255;
22
+ return intArray;
23
+ }
24
+ function uuid_v5_default(value, namespace) {
25
+ const buffer = createHash("sha1").update(parse(namespace)).update(value).digest();
26
+ buffer[6] = (buffer[6] ?? 0) & 15 | 80;
27
+ buffer[8] = (buffer[8] ?? 0) & 63 | 128;
28
+ const hex = buffer.toString("hex", 0, 16);
29
+ return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)].join("-").toLowerCase();
30
+ }
31
+ export {
32
+ uuid_v5_default as default
33
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
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
+ });
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/hash","version":"2.0.0-PR.14-2bb3","description":"Hash is a small function for Check Digit services to create a uuid derived from a hash generated from a given value.","typings":"./dist/index.d.ts","main":"./dist/index.js","files":["dist","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":{"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"}}
1
+ {"name":"@checkdigit/hash","version":"2.0.0-PR.14-adca","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-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"}}
@@ -0,0 +1,37 @@
1
+ // hash.spec.ts
2
+
3
+ /*
4
+ * Copyright (c) 2021-2023 Check Digit, LLC
5
+ *
6
+ * This code is licensed under the MIT license (see LICENSE.txt for details).
7
+ */
8
+
9
+ import { strict as assert } from 'node:assert';
10
+ import { validate } from 'uuid';
11
+
12
+ import hash from './hash';
13
+
14
+ describe('hash', () => {
15
+ it('returns a uuid derived from hash of value', () => {
16
+ const result1 = hash('string to be hashed into a uuid');
17
+ const result2 = hash('string to be hashed into a uuid');
18
+ assert.ok(validate(result1) && validate(result2));
19
+ assert.equal(result1, result2);
20
+ });
21
+
22
+ it('hash always returns the same value', () => {
23
+ assert.equal(hash('Hello World!'), '74caf525-c85a-5a3c-9d53-bef0507c21e4');
24
+ assert.equal(hash('d1253ec1-14bc-4c56-8e09-4450ab4c8a55'), '14abff19-2c5f-5408-af3d-3c6526ebea73');
25
+ assert.equal(hash('Råma Ghantå'), '8a28bfef-8fa2-52de-b9c5-1d5a6d7ba5fe');
26
+ assert.equal(
27
+ // eslint-disable-next-line no-secrets/no-secrets
28
+ hash('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1'),
29
+ '7cb123ec-2c42-5a8a-b358-adf113ee088d'
30
+ );
31
+ // eslint-disable-next-line no-secrets/no-secrets
32
+ assert.equal(hash('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE='), 'e90938db-61fb-55b4-8ebe-4e1518e4fe97');
33
+ // eslint-disable-next-line @checkdigit/no-card-numbers
34
+ assert.equal(hash('5111111111111118'), '87e25c4b-c395-585e-9ecf-43d190f6e62f');
35
+ assert.equal(hash('https://checkdigit.com'), '2c391f52-ec24-5945-8c28-88f74d12b55d');
36
+ });
37
+ });
@@ -0,0 +1,66 @@
1
+ // uuid-v5.spec.ts
2
+
3
+ /*
4
+ * Copyright (c) 2021-2023 Check Digit, LLC
5
+ *
6
+ * This code is licensed under the MIT license (see LICENSE.txt for details).
7
+ */
8
+
9
+ import { strict as assert } from 'node:assert';
10
+ import { v5 } from 'uuid';
11
+
12
+ import { HASH_NAMESPACE } from './hash';
13
+ import uuidV5 from './uuid-v5';
14
+
15
+ describe('uuidV5', () => {
16
+ it('uuidV5 result matches v5(https://github.com/uuidjs/uuid) result', () => {
17
+ assert.equal(uuidV5('Hello World!', HASH_NAMESPACE), v5('Hello World!', HASH_NAMESPACE));
18
+ assert.equal(
19
+ uuidV5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55', HASH_NAMESPACE),
20
+ v5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55', HASH_NAMESPACE)
21
+ );
22
+ assert.equal(
23
+ uuidV5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz', HASH_NAMESPACE),
24
+ v5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz', HASH_NAMESPACE)
25
+ );
26
+ assert.equal(
27
+ uuidV5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC', HASH_NAMESPACE),
28
+ v5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC', HASH_NAMESPACE)
29
+ );
30
+ assert.equal(uuidV5('Råma Ghantå', HASH_NAMESPACE), v5('Råma Ghantå', HASH_NAMESPACE));
31
+ assert.equal(
32
+ // eslint-disable-next-line no-secrets/no-secrets
33
+ uuidV5('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1', HASH_NAMESPACE),
34
+ // eslint-disable-next-line no-secrets/no-secrets
35
+ v5('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1', HASH_NAMESPACE)
36
+ );
37
+ assert.equal(
38
+ // eslint-disable-next-line no-secrets/no-secrets
39
+ uuidV5('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=', HASH_NAMESPACE),
40
+ // eslint-disable-next-line no-secrets/no-secrets
41
+ v5('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=', HASH_NAMESPACE)
42
+ );
43
+ // eslint-disable-next-line @checkdigit/no-card-numbers
44
+ assert.equal(uuidV5('5111111111111118', HASH_NAMESPACE), v5('5111111111111118', HASH_NAMESPACE));
45
+ assert.equal(uuidV5('https://checkdigit.com', HASH_NAMESPACE), v5('https://checkdigit.com', HASH_NAMESPACE));
46
+ });
47
+
48
+ it('v5 - from https://github.com/uuidjs/uuid testing', () => {
49
+ assert.equal(uuidV5('hello.example.com', v5.DNS), 'fdda765f-fc57-5604-a269-52a7df8164ec');
50
+
51
+ assert.equal(uuidV5('http://example.com/hello', v5.URL), '3bbcee75-cecc-5b56-8031-b6641c1ed1f1');
52
+
53
+ assert.equal(uuidV5('hello', '0f5abcd1-c194-47f3-905b-2df7263a084b'), '90123e1c-7512-523e-bb28-76fab9f2f73d');
54
+ });
55
+
56
+ it('v5 namespace.toUpperCase - from https://github.com/uuidjs/uuid testing', () => {
57
+ assert.equal(uuidV5('hello.example.com', v5.DNS.toUpperCase()), 'fdda765f-fc57-5604-a269-52a7df8164ec');
58
+
59
+ assert.equal(uuidV5('http://example.com/hello', v5.URL.toUpperCase()), '3bbcee75-cecc-5b56-8031-b6641c1ed1f1');
60
+
61
+ assert.equal(
62
+ uuidV5('hello', '0f5abcd1-c194-47f3-905b-2df7263a084b'.toUpperCase()),
63
+ '90123e1c-7512-523e-bb28-76fab9f2f73d'
64
+ );
65
+ });
66
+ });
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc,yCAAyC,CAAC;AAErE;;GAEG;AAEH,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C"}
package/dist/hash.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- // hash.ts
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.HASH_NAMESPACE = void 0;
8
- /*
9
- * Copyright (c) 2021-2023 Check Digit, LLC
10
- *
11
- * This code is licensed under the MIT license (see LICENSE.txt for details).
12
- */
13
- const node_crypto_1 = require("node:crypto");
14
- const uuid_v5_1 = __importDefault(require("./uuid-v5"));
15
- // eslint-disable-next-line @checkdigit/no-uuid
16
- exports.HASH_NAMESPACE = 'f25d4515-fea7-44c7-8baf-f3ca50865e66';
17
- /**
18
- * @param value - a string to be hashed and converted into a derived uuid
19
- */
20
- function default_1(value) {
21
- return (0, uuid_v5_1.default)((0, node_crypto_1.createHash)('sha512').update(value).digest('base64'), exports.HASH_NAMESPACE);
22
- }
23
- exports.default = default_1;
24
- //# sourceMappingURL=hash.js.map
package/dist/hash.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":";AAAA,UAAU;;;;;;AAEV;;;;GAIG;AAEH,6CAAyC;AAEzC,wDAA+B;AAE/B,+CAA+C;AAClC,QAAA,cAAc,GAAG,sCAAsC,CAAC;AAErE;;GAEG;AAEH,mBAAyB,KAAa;IACpC,OAAO,IAAA,iBAAM,EAAC,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,sBAAc,CAAC,CAAC;AACrF,CAAC;AAFD,4BAEC","sourcesContent":["// hash.ts\n\n/*\n * Copyright (c) 2021-2023 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport { createHash } from 'node:crypto';\n\nimport uuidV5 from './uuid-v5';\n\n// eslint-disable-next-line @checkdigit/no-uuid\nexport const HASH_NAMESPACE = 'f25d4515-fea7-44c7-8baf-f3ca50865e66';\n\n/**\n * @param value - a string to be hashed and converted into a derived uuid\n */\n\nexport default function (value: string): string {\n return uuidV5(createHash('sha512').update(value).digest('base64'), HASH_NAMESPACE);\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hash.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.spec.d.ts","sourceRoot":"","sources":["../src/hash.spec.ts"],"names":[],"mappings":""}
package/dist/hash.spec.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- // hash.spec.ts
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- /*
8
- * Copyright (c) 2021-2023 Check Digit, LLC
9
- *
10
- * This code is licensed under the MIT license (see LICENSE.txt for details).
11
- */
12
- const node_assert_1 = require("node:assert");
13
- const uuid_1 = require("uuid");
14
- const hash_1 = __importDefault(require("./hash"));
15
- describe('hash', () => {
16
- it('returns a uuid derived from hash of value', () => {
17
- const result1 = (0, hash_1.default)('string to be hashed into a uuid');
18
- const result2 = (0, hash_1.default)('string to be hashed into a uuid');
19
- node_assert_1.strict.ok((0, uuid_1.validate)(result1) && (0, uuid_1.validate)(result2));
20
- node_assert_1.strict.equal(result1, result2);
21
- });
22
- it('hash always returns the same value', () => {
23
- node_assert_1.strict.equal((0, hash_1.default)('Hello World!'), '74caf525-c85a-5a3c-9d53-bef0507c21e4');
24
- node_assert_1.strict.equal((0, hash_1.default)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55'), '14abff19-2c5f-5408-af3d-3c6526ebea73');
25
- node_assert_1.strict.equal((0, hash_1.default)('Råma Ghantå'), '8a28bfef-8fa2-52de-b9c5-1d5a6d7ba5fe');
26
- node_assert_1.strict.equal(
27
- // eslint-disable-next-line no-secrets/no-secrets
28
- (0, hash_1.default)('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1'), '7cb123ec-2c42-5a8a-b358-adf113ee088d');
29
- // eslint-disable-next-line no-secrets/no-secrets
30
- node_assert_1.strict.equal((0, hash_1.default)('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE='), 'e90938db-61fb-55b4-8ebe-4e1518e4fe97');
31
- // eslint-disable-next-line @checkdigit/no-card-numbers
32
- node_assert_1.strict.equal((0, hash_1.default)('5111111111111118'), '87e25c4b-c395-585e-9ecf-43d190f6e62f');
33
- node_assert_1.strict.equal((0, hash_1.default)('https://checkdigit.com'), '2c391f52-ec24-5945-8c28-88f74d12b55d');
34
- });
35
- });
36
- //# sourceMappingURL=hash.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.spec.js","sourceRoot":"","sources":["../src/hash.spec.ts"],"names":[],"mappings":";AAAA,eAAe;;;;;AAEf;;;;GAIG;AAEH,6CAA+C;AAC/C,+BAAgC;AAEhC,kDAA0B;AAE1B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,OAAO,GAAG,IAAA,cAAI,EAAC,iCAAiC,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,IAAA,cAAI,EAAC,iCAAiC,CAAC,CAAC;QACxD,oBAAM,CAAC,EAAE,CAAC,IAAA,eAAQ,EAAC,OAAO,CAAC,IAAI,IAAA,eAAQ,EAAC,OAAO,CAAC,CAAC,CAAC;QAClD,oBAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,oBAAM,CAAC,KAAK,CAAC,IAAA,cAAI,EAAC,cAAc,CAAC,EAAE,sCAAsC,CAAC,CAAC;QAC3E,oBAAM,CAAC,KAAK,CAAC,IAAA,cAAI,EAAC,sCAAsC,CAAC,EAAE,sCAAsC,CAAC,CAAC;QACnG,oBAAM,CAAC,KAAK,CAAC,IAAA,cAAI,EAAC,aAAa,CAAC,EAAE,sCAAsC,CAAC,CAAC;QAC1E,oBAAM,CAAC,KAAK;QACV,iDAAiD;QACjD,IAAA,cAAI,EAAC,kEAAkE,CAAC,EACxE,sCAAsC,CACvC,CAAC;QACF,iDAAiD;QACjD,oBAAM,CAAC,KAAK,CAAC,IAAA,cAAI,EAAC,8CAA8C,CAAC,EAAE,sCAAsC,CAAC,CAAC;QAC3G,uDAAuD;QACvD,oBAAM,CAAC,KAAK,CAAC,IAAA,cAAI,EAAC,kBAAkB,CAAC,EAAE,sCAAsC,CAAC,CAAC;QAC/E,oBAAM,CAAC,KAAK,CAAC,IAAA,cAAI,EAAC,wBAAwB,CAAC,EAAE,sCAAsC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// hash.spec.ts\n\n/*\n * Copyright (c) 2021-2023 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport { strict as assert } from 'node:assert';\nimport { validate } from 'uuid';\n\nimport hash from './hash';\n\ndescribe('hash', () => {\n it('returns a uuid derived from hash of value', () => {\n const result1 = hash('string to be hashed into a uuid');\n const result2 = hash('string to be hashed into a uuid');\n assert.ok(validate(result1) && validate(result2));\n assert.equal(result1, result2);\n });\n\n it('hash always returns the same value', () => {\n assert.equal(hash('Hello World!'), '74caf525-c85a-5a3c-9d53-bef0507c21e4');\n assert.equal(hash('d1253ec1-14bc-4c56-8e09-4450ab4c8a55'), '14abff19-2c5f-5408-af3d-3c6526ebea73');\n assert.equal(hash('Råma Ghantå'), '8a28bfef-8fa2-52de-b9c5-1d5a6d7ba5fe');\n assert.equal(\n // eslint-disable-next-line no-secrets/no-secrets\n hash('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1'),\n '7cb123ec-2c42-5a8a-b358-adf113ee088d'\n );\n // eslint-disable-next-line no-secrets/no-secrets\n assert.equal(hash('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE='), 'e90938db-61fb-55b4-8ebe-4e1518e4fe97');\n // eslint-disable-next-line @checkdigit/no-card-numbers\n assert.equal(hash('5111111111111118'), '87e25c4b-c395-585e-9ecf-43d190f6e62f');\n assert.equal(hash('https://checkdigit.com'), '2c391f52-ec24-5945-8c28-88f74d12b55d');\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC"}
package/dist/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- // index.ts
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.HASH_NAMESPACE = exports.hash = exports.default = void 0;
8
- /*
9
- * Copyright (c) 2021-2023 Check Digit, LLC
10
- *
11
- * This code is licensed under the MIT license (see LICENSE.txt for details).
12
- */
13
- var hash_1 = require("./hash");
14
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(hash_1).default; } });
15
- var hash_2 = require("./hash");
16
- Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_2).default; } });
17
- Object.defineProperty(exports, "HASH_NAMESPACE", { enumerable: true, get: function () { return hash_2.HASH_NAMESPACE; } });
18
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,WAAW;;;;;;AAEX;;;;GAIG;AAEH,+BAAiC;AAAxB,gHAAA,OAAO,OAAA;AAChB,+BAAyD;AAAhD,6GAAA,OAAO,OAAQ;AAAE,sGAAA,cAAc,OAAA","sourcesContent":["// index.ts\n\n/*\n * Copyright (c) 2021-2023 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nexport { default } from './hash';\nexport { default as hash, HASH_NAMESPACE } from './hash';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uuid-v5.d.ts","sourceRoot":"","sources":["../src/uuid-v5.ts"],"names":[],"mappings":"AAkEA,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CASjE"}
package/dist/uuid-v5.js DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
- // uuid-v5.ts
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- /*
5
- * Copyright (c) 2021 Check Digit, LLC
6
- *
7
- * This code is derived from https://github.com/uuidjs/uuid,
8
- * licensed under the MIT license (see below for details).
9
- *
10
- * Copyright (c) 2010-2020 Robert Kieffer and other contributors
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in
20
- * all copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
- * THE SOFTWARE.
29
- */
30
- const node_crypto_1 = require("node:crypto");
31
- /* eslint-disable no-bitwise,no-magic-numbers */
32
- function parse(namespace) {
33
- let value;
34
- const intArray = new Uint8Array(16);
35
- // Parse ########-....-....-....-............
36
- intArray[0] = (value = Number.parseInt(namespace.slice(0, 8), 16)) >>> 24;
37
- intArray[1] = (value >>> 16) & 0xff;
38
- intArray[2] = (value >>> 8) & 0xff;
39
- intArray[3] = value & 0xff;
40
- // Parse ........-####-....-....-............
41
- intArray[4] = (value = Number.parseInt(namespace.slice(9, 13), 16)) >>> 8;
42
- intArray[5] = value & 0xff;
43
- // Parse ........-....-####-....-............
44
- intArray[6] = (value = Number.parseInt(namespace.slice(14, 18), 16)) >>> 8;
45
- intArray[7] = value & 0xff;
46
- // Parse ........-....-....-####-............
47
- intArray[8] = (value = Number.parseInt(namespace.slice(19, 23), 16)) >>> 8;
48
- intArray[9] = value & 0xff;
49
- // Parse ........-....-....-....-############
50
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
51
- intArray[10] = ((value = Number.parseInt(namespace.slice(24, 36), 16)) / 0x1_00_00_00_00_00) & 0xff;
52
- intArray[11] = (value / 0x1_00_00_00_00) & 0xff;
53
- intArray[12] = (value >>> 24) & 0xff;
54
- intArray[13] = (value >>> 16) & 0xff;
55
- intArray[14] = (value >>> 8) & 0xff;
56
- intArray[15] = value & 0xff;
57
- return intArray;
58
- }
59
- function default_1(value, namespace) {
60
- const buffer = (0, node_crypto_1.createHash)('sha1').update(parse(namespace)).update(value).digest();
61
- // note that undefined is treated as 0 by the & operator
62
- buffer[6] = ((buffer[6] ?? 0) & 0x0f) | 0x50;
63
- buffer[8] = ((buffer[8] ?? 0) & 0x3f) | 0x80;
64
- const hex = buffer.toString('hex', 0, 16);
65
- return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)]
66
- .join('-')
67
- .toLowerCase();
68
- }
69
- exports.default = default_1;
70
- /* eslint-enable no-bitwise,no-magic-numbers */
71
- //# sourceMappingURL=uuid-v5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uuid-v5.js","sourceRoot":"","sources":["../src/uuid-v5.ts"],"names":[],"mappings":"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","sourcesContent":["// uuid-v5.ts\n\n/*\n * Copyright (c) 2021 Check Digit, LLC\n *\n * This code is derived from https://github.com/uuidjs/uuid,\n * licensed under the MIT license (see below for details).\n *\n * Copyright (c) 2010-2020 Robert Kieffer and other contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\nimport { createHash } from 'node:crypto';\n\n/* eslint-disable no-bitwise,no-magic-numbers */\nfunction parse(namespace: string) {\n let value;\n const intArray = new Uint8Array(16);\n\n // Parse ########-....-....-....-............\n intArray[0] = (value = Number.parseInt(namespace.slice(0, 8), 16)) >>> 24;\n intArray[1] = (value >>> 16) & 0xff;\n intArray[2] = (value >>> 8) & 0xff;\n intArray[3] = value & 0xff;\n\n // Parse ........-####-....-....-............\n intArray[4] = (value = Number.parseInt(namespace.slice(9, 13), 16)) >>> 8;\n intArray[5] = value & 0xff;\n\n // Parse ........-....-####-....-............\n intArray[6] = (value = Number.parseInt(namespace.slice(14, 18), 16)) >>> 8;\n intArray[7] = value & 0xff;\n\n // Parse ........-....-....-####-............\n intArray[8] = (value = Number.parseInt(namespace.slice(19, 23), 16)) >>> 8;\n intArray[9] = value & 0xff;\n\n // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n intArray[10] = ((value = Number.parseInt(namespace.slice(24, 36), 16)) / 0x1_00_00_00_00_00) & 0xff;\n intArray[11] = (value / 0x1_00_00_00_00) & 0xff;\n intArray[12] = (value >>> 24) & 0xff;\n intArray[13] = (value >>> 16) & 0xff;\n intArray[14] = (value >>> 8) & 0xff;\n intArray[15] = value & 0xff;\n\n return intArray;\n}\n\nexport default function (value: string, namespace: string): string {\n const buffer = createHash('sha1').update(parse(namespace)).update(value).digest();\n // note that undefined is treated as 0 by the & operator\n buffer[6] = ((buffer[6] ?? 0) & 0x0f) | 0x50;\n buffer[8] = ((buffer[8] ?? 0) & 0x3f) | 0x80;\n const hex = buffer.toString('hex', 0, 16);\n return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)]\n .join('-')\n .toLowerCase();\n}\n/* eslint-enable no-bitwise,no-magic-numbers */\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=uuid-v5.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uuid-v5.spec.d.ts","sourceRoot":"","sources":["../src/uuid-v5.spec.ts"],"names":[],"mappings":""}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- // uuid-v5.spec.ts
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- /*
8
- * Copyright (c) 2021-2023 Check Digit, LLC
9
- *
10
- * This code is licensed under the MIT license (see LICENSE.txt for details).
11
- */
12
- const node_assert_1 = require("node:assert");
13
- const uuid_1 = require("uuid");
14
- const hash_1 = require("./hash");
15
- const uuid_v5_1 = __importDefault(require("./uuid-v5"));
16
- describe('uuidV5', () => {
17
- it('uuidV5 result matches v5(https://github.com/uuidjs/uuid) result', () => {
18
- node_assert_1.strict.equal((0, uuid_v5_1.default)('Hello World!', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('Hello World!', hash_1.HASH_NAMESPACE));
19
- node_assert_1.strict.equal((0, uuid_v5_1.default)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55', hash_1.HASH_NAMESPACE));
20
- node_assert_1.strict.equal((0, uuid_v5_1.default)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz', hash_1.HASH_NAMESPACE));
21
- node_assert_1.strict.equal((0, uuid_v5_1.default)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC', hash_1.HASH_NAMESPACE));
22
- node_assert_1.strict.equal((0, uuid_v5_1.default)('Råma Ghantå', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('Råma Ghantå', hash_1.HASH_NAMESPACE));
23
- node_assert_1.strict.equal(
24
- // eslint-disable-next-line no-secrets/no-secrets
25
- (0, uuid_v5_1.default)('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1', hash_1.HASH_NAMESPACE),
26
- // eslint-disable-next-line no-secrets/no-secrets
27
- (0, uuid_1.v5)('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1', hash_1.HASH_NAMESPACE));
28
- node_assert_1.strict.equal(
29
- // eslint-disable-next-line no-secrets/no-secrets
30
- (0, uuid_v5_1.default)('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=', hash_1.HASH_NAMESPACE),
31
- // eslint-disable-next-line no-secrets/no-secrets
32
- (0, uuid_1.v5)('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=', hash_1.HASH_NAMESPACE));
33
- // eslint-disable-next-line @checkdigit/no-card-numbers
34
- node_assert_1.strict.equal((0, uuid_v5_1.default)('5111111111111118', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('5111111111111118', hash_1.HASH_NAMESPACE));
35
- node_assert_1.strict.equal((0, uuid_v5_1.default)('https://checkdigit.com', hash_1.HASH_NAMESPACE), (0, uuid_1.v5)('https://checkdigit.com', hash_1.HASH_NAMESPACE));
36
- });
37
- it('v5 - from https://github.com/uuidjs/uuid testing', () => {
38
- node_assert_1.strict.equal((0, uuid_v5_1.default)('hello.example.com', uuid_1.v5.DNS), 'fdda765f-fc57-5604-a269-52a7df8164ec');
39
- node_assert_1.strict.equal((0, uuid_v5_1.default)('http://example.com/hello', uuid_1.v5.URL), '3bbcee75-cecc-5b56-8031-b6641c1ed1f1');
40
- node_assert_1.strict.equal((0, uuid_v5_1.default)('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
- node_assert_1.strict.equal((0, uuid_v5_1.default)('hello.example.com', uuid_1.v5.DNS.toUpperCase()), 'fdda765f-fc57-5604-a269-52a7df8164ec');
44
- node_assert_1.strict.equal((0, uuid_v5_1.default)('http://example.com/hello', uuid_1.v5.URL.toUpperCase()), '3bbcee75-cecc-5b56-8031-b6641c1ed1f1');
45
- node_assert_1.strict.equal((0, uuid_v5_1.default)('hello', '0f5abcd1-c194-47f3-905b-2df7263a084b'.toUpperCase()), '90123e1c-7512-523e-bb28-76fab9f2f73d');
46
- });
47
- });
48
- //# sourceMappingURL=uuid-v5.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uuid-v5.spec.js","sourceRoot":"","sources":["../src/uuid-v5.spec.ts"],"names":[],"mappings":"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","sourcesContent":["// uuid-v5.spec.ts\n\n/*\n * Copyright (c) 2021-2023 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport { strict as assert } from 'node:assert';\nimport { v5 } from 'uuid';\n\nimport { HASH_NAMESPACE } from './hash';\nimport uuidV5 from './uuid-v5';\n\ndescribe('uuidV5', () => {\n it('uuidV5 result matches v5(https://github.com/uuidjs/uuid) result', () => {\n assert.equal(uuidV5('Hello World!', HASH_NAMESPACE), v5('Hello World!', HASH_NAMESPACE));\n assert.equal(\n uuidV5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55', HASH_NAMESPACE),\n v5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55', HASH_NAMESPACE)\n );\n assert.equal(\n uuidV5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz', HASH_NAMESPACE),\n v5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55/abc/xyz', HASH_NAMESPACE)\n );\n assert.equal(\n uuidV5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC', HASH_NAMESPACE),\n v5('d1253ec1-14bc-4c56-8e09-4450ab4c8a55-ABC', HASH_NAMESPACE)\n );\n assert.equal(uuidV5('Råma Ghantå', HASH_NAMESPACE), v5('Råma Ghantå', HASH_NAMESPACE));\n assert.equal(\n // eslint-disable-next-line no-secrets/no-secrets\n uuidV5('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1', HASH_NAMESPACE),\n // eslint-disable-next-line no-secrets/no-secrets\n v5('/hYSjdEGQI0DaVHCR0vZq0KeF5JLys3jSNvU9EzBMKKlSsC97xFd3wr+nrhzHhp1', HASH_NAMESPACE)\n );\n assert.equal(\n // eslint-disable-next-line no-secrets/no-secrets\n uuidV5('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=', HASH_NAMESPACE),\n // eslint-disable-next-line no-secrets/no-secrets\n v5('nfv8yFRghIJV6ffFr2dJGi1978GPnUuc7JVi2/FPqHE=', HASH_NAMESPACE)\n );\n // eslint-disable-next-line @checkdigit/no-card-numbers\n assert.equal(uuidV5('5111111111111118', HASH_NAMESPACE), v5('5111111111111118', HASH_NAMESPACE));\n assert.equal(uuidV5('https://checkdigit.com', HASH_NAMESPACE), v5('https://checkdigit.com', HASH_NAMESPACE));\n });\n\n it('v5 - from https://github.com/uuidjs/uuid testing', () => {\n assert.equal(uuidV5('hello.example.com', v5.DNS), 'fdda765f-fc57-5604-a269-52a7df8164ec');\n\n assert.equal(uuidV5('http://example.com/hello', v5.URL), '3bbcee75-cecc-5b56-8031-b6641c1ed1f1');\n\n assert.equal(uuidV5('hello', '0f5abcd1-c194-47f3-905b-2df7263a084b'), '90123e1c-7512-523e-bb28-76fab9f2f73d');\n });\n\n it('v5 namespace.toUpperCase - from https://github.com/uuidjs/uuid testing', () => {\n assert.equal(uuidV5('hello.example.com', v5.DNS.toUpperCase()), 'fdda765f-fc57-5604-a269-52a7df8164ec');\n\n assert.equal(uuidV5('http://example.com/hello', v5.URL.toUpperCase()), '3bbcee75-cecc-5b56-8031-b6641c1ed1f1');\n\n assert.equal(\n uuidV5('hello', '0f5abcd1-c194-47f3-905b-2df7263a084b'.toUpperCase()),\n '90123e1c-7512-523e-bb28-76fab9f2f73d'\n );\n });\n});\n"]}