@checkdigit/hash 2.0.0-PR.14-130d → 2.0.0

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 CHANGED
@@ -1 +1,75 @@
1
- {"name":"@checkdigit/hash","version":"2.0.0-PR.14-130d","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-types/index.d.ts","require":"./dist-cjs/index.cjs","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-cjs","dist-mjs","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-cjs/**/*.test.cjs","!dist-cjs/**/*.spec.cjs","!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.5.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-types && npm run build:dist-cjs && npm run build:dist-esm","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","build:dist-cjs":"rimraf dist-cjs && npx builder --type=commonjs --sourceMap --outDir=dist-cjs","build:dist-esm":"rimraf dist-esm && npx builder --type=module --sourceMap --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"}}
1
+ {
2
+ "name": "@checkdigit/hash",
3
+ "version": "2.0.0",
4
+ "description": "Hash is a small function for Check Digit services to create a uuid derived from a hash generated from a given value.",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist-types/index.d.ts",
8
+ "require": "./dist-cjs/index.cjs",
9
+ "import": "./dist-mjs/index.mjs",
10
+ "default": "./dist-mjs/index.mjs"
11
+ }
12
+ },
13
+ "files": [
14
+ "src",
15
+ "dist-types",
16
+ "dist-cjs",
17
+ "dist-mjs",
18
+ "!src/**/*.test.ts",
19
+ "!src/**/*.spec.ts",
20
+ "!dist-types/**/*.test.d.ts",
21
+ "!dist-types/**/*.spec.d.ts",
22
+ "!dist-cjs/**/*.test.cjs",
23
+ "!dist-cjs/**/*.spec.cjs",
24
+ "!dist-mjs/**/*.test.mjs",
25
+ "!dist-mjs/**/*.spec.mjs",
26
+ "SECURITY.md"
27
+ ],
28
+ "prettier": "@checkdigit/prettier-config",
29
+ "engines": {
30
+ "node": ">=16"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/checkdigit/hash.git"
35
+ },
36
+ "author": "Check Digit, LLC",
37
+ "license": "MIT",
38
+ "bugs": {
39
+ "url": "https://github.com/checkdigit/hash/issues"
40
+ },
41
+ "homepage": "https://github.com/checkdigit/hash#readme",
42
+ "devDependencies": {
43
+ "@checkdigit/eslint-config": "^7.8.0",
44
+ "@checkdigit/jest-config": "^2.2.1",
45
+ "@checkdigit/prettier-config": "^3.4.0",
46
+ "@checkdigit/typescript-config": "^3.5.0",
47
+ "@types/uuid": "^9.0.1",
48
+ "rimraf": "^5.0.1",
49
+ "uuid": "^9.0.0"
50
+ },
51
+ "eslintConfig": {
52
+ "extends": [
53
+ "@checkdigit/eslint-config"
54
+ ]
55
+ },
56
+ "jest": {
57
+ "preset": "@checkdigit/jest-config"
58
+ },
59
+ "scripts": {
60
+ "prepublishOnly": "npm run build:dist-types && npm run build:dist-cjs && npm run build:dist-esm",
61
+ "build:dist-types": "rimraf dist-types && npx builder --type=types --outDir=dist-types",
62
+ "build:dist-cjs": "rimraf dist-cjs && npx builder --type=commonjs --sourceMap --outDir=dist-cjs",
63
+ "build:dist-esm": "rimraf dist-esm && npx builder --type=module --sourceMap --outDir=dist-mjs",
64
+ "prettier": "prettier --ignore-path .gitignore --list-different .",
65
+ "prettier:fix": "prettier --ignore-path .gitignore --write .",
66
+ "lint:fix": "eslint -f unix --ext .ts,.mts src --fix",
67
+ "lint": "eslint -f unix --ext .ts,.mts src",
68
+ "test": "npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style",
69
+ "ci:compile": "tsc --noEmit",
70
+ "ci:test": "jest --coverage=false",
71
+ "ci:coverage": "jest --coverage=true",
72
+ "ci:lint": "npm run lint",
73
+ "ci:style": "npm run prettier"
74
+ }
75
+ }
package/src/hash.spec.ts DELETED
@@ -1,37 +0,0 @@
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
- });
@@ -1,66 +0,0 @@
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
- });