@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 CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  The MIT License
3
3
 
4
- Copyright (c) 2021 Check Digit, LLC
4
+ Copyright (c) 2021-2023 Check Digit, LLC
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/hash","version":"1.0.0-PR.12-6300","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":">=12.18","npm":">=6.14"},"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.5.0","@checkdigit/jest-config":"^2.1.0","@checkdigit/prettier-config":"^3.2.0","@checkdigit/typescript-config":"^3.2.0","@types/uuid":"^9.0.1","rimraf":"^4.4.0","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":"eslint -f unix --ext .js,.ts 'src/**/*.ts'","lint:fix":"eslint -f unix --ext .js,.ts 'src/**/*.ts' --fix","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":"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
@@ -1,7 +1,7 @@
1
1
  // hash.ts
2
2
 
3
3
  /*
4
- * Copyright (c) 2021 Check Digit, LLC
4
+ * Copyright (c) 2021-2023 Check Digit, LLC
5
5
  *
6
6
  * This code is licensed under the MIT license (see LICENSE.txt for details).
7
7
  */
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // index.ts
2
2
 
3
3
  /*
4
- * Copyright (c) 2021 Check Digit, LLC
4
+ * Copyright (c) 2021-2023 Check Digit, LLC
5
5
  *
6
6
  * This code is licensed under the MIT license (see LICENSE.txt for details).
7
7
  */
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
- buffer[6] = ((buffer[6] as number) & 0x0f) | 0x50;
70
- buffer[8] = ((buffer[8] as number) & 0x3f) | 0x80;
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('-')