@checkdigit/hash 1.0.0-PR.12-6300 → 1.0.0-PR.14-e694
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/LICENSE.txt +1 -1
- package/package.json +1 -1
- package/src/hash.ts +1 -1
- package/src/index.ts +1 -1
- package/src/uuid-v5.ts +3 -2
package/LICENSE.txt
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/hash","version":"1.0.0-PR.
|
|
1
|
+
{"name":"@checkdigit/hash","version":"1.0.0-PR.14-e694","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":["index.js","/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"}}
|
package/src/hash.ts
CHANGED
package/src/index.ts
CHANGED
package/src/uuid-v5.ts
CHANGED
|
@@ -66,8 +66,9 @@ function parse(namespace: string) {
|
|
|
66
66
|
|
|
67
67
|
export default function (value: string, namespace: string): string {
|
|
68
68
|
const buffer = createHash('sha1').update(parse(namespace)).update(value).digest();
|
|
69
|
-
|
|
70
|
-
buffer[
|
|
69
|
+
// note that undefined is treated as 0 by the & operator
|
|
70
|
+
buffer[6] = ((buffer[6] ?? 0) & 0x0f) | 0x50;
|
|
71
|
+
buffer[8] = ((buffer[8] ?? 0) & 0x3f) | 0x80;
|
|
71
72
|
const hex = buffer.toString('hex', 0, 16);
|
|
72
73
|
return [hex.slice(0, 8), hex.slice(8, 12), hex.slice(12, 16), hex.slice(16, 20), hex.slice(20, 32)]
|
|
73
74
|
.join('-')
|