@sd-jwt/hash 0.15.2-next.8 → 0.15.2-next.9
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -4
- package/dist/index.mjs +3 -4
- package/package.json +6 -6
- package/src/sha.ts +3 -6
- package/src/test/sha.spec.ts +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,6 @@ declare const sha256: (text: string | ArrayBuffer) => Uint8Array;
|
|
|
2
2
|
declare const sha384: (text: string | ArrayBuffer) => Uint8Array;
|
|
3
3
|
declare const sha512: (text: string | ArrayBuffer) => Uint8Array;
|
|
4
4
|
type HasherAlgorithm = 'sha256' | 'sha384' | 'sha512' | (string & {});
|
|
5
|
-
declare const hasher: (data: string | ArrayBuffer, algorithm?: HasherAlgorithm) => Uint8Array
|
|
5
|
+
declare const hasher: (data: string | ArrayBuffer, algorithm?: HasherAlgorithm) => Uint8Array<ArrayBufferLike>;
|
|
6
6
|
|
|
7
7
|
export { hasher, sha256, sha384, sha512 };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ declare const sha256: (text: string | ArrayBuffer) => Uint8Array;
|
|
|
2
2
|
declare const sha384: (text: string | ArrayBuffer) => Uint8Array;
|
|
3
3
|
declare const sha512: (text: string | ArrayBuffer) => Uint8Array;
|
|
4
4
|
type HasherAlgorithm = 'sha256' | 'sha384' | 'sha512' | (string & {});
|
|
5
|
-
declare const hasher: (data: string | ArrayBuffer, algorithm?: HasherAlgorithm) => Uint8Array
|
|
5
|
+
declare const hasher: (data: string | ArrayBuffer, algorithm?: HasherAlgorithm) => Uint8Array<ArrayBufferLike>;
|
|
6
6
|
|
|
7
7
|
export { hasher, sha256, sha384, sha512 };
|
package/dist/index.js
CHANGED
|
@@ -46,15 +46,14 @@ var sha512 = (text) => {
|
|
|
46
46
|
return hashBytes;
|
|
47
47
|
};
|
|
48
48
|
var hasher = (data, algorithm = "sha256") => {
|
|
49
|
-
const msg = typeof data === "string" ? toUTF8Array(data) : new Uint8Array(data);
|
|
50
49
|
const alg = toCryptoAlg(algorithm);
|
|
51
50
|
switch (alg) {
|
|
52
51
|
case "sha256":
|
|
53
|
-
return sha256(
|
|
52
|
+
return sha256(data);
|
|
54
53
|
case "sha384":
|
|
55
|
-
return sha384(
|
|
54
|
+
return sha384(data);
|
|
56
55
|
case "sha512":
|
|
57
|
-
return sha512(
|
|
56
|
+
return sha512(data);
|
|
58
57
|
default:
|
|
59
58
|
throw new import_utils.SDJWTException(`Unsupported algorithm: ${algorithm}`);
|
|
60
59
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -21,15 +21,14 @@ var sha512 = (text) => {
|
|
|
21
21
|
return hashBytes;
|
|
22
22
|
};
|
|
23
23
|
var hasher = (data, algorithm = "sha256") => {
|
|
24
|
-
const msg = typeof data === "string" ? toUTF8Array(data) : new Uint8Array(data);
|
|
25
24
|
const alg = toCryptoAlg(algorithm);
|
|
26
25
|
switch (alg) {
|
|
27
26
|
case "sha256":
|
|
28
|
-
return sha256(
|
|
27
|
+
return sha256(data);
|
|
29
28
|
case "sha384":
|
|
30
|
-
return sha384(
|
|
29
|
+
return sha384(data);
|
|
31
30
|
case "sha512":
|
|
32
|
-
return sha512(
|
|
31
|
+
return sha512(data);
|
|
33
32
|
default:
|
|
34
33
|
throw new SDJWTException(`Unsupported algorithm: ${algorithm}`);
|
|
35
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/hash",
|
|
3
|
-
"version": "0.15.2-next.
|
|
3
|
+
"version": "0.15.2-next.9+75d5780",
|
|
4
4
|
"description": "sd-jwt draft 7 implementation in typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"sd-jwt-vc"
|
|
26
26
|
],
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
28
|
+
"node": ">=20"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"url": "https://github.com/openwallet-foundation/sd-jwt-js"
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
},
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@sd-jwt/crypto-nodejs": "0.15.2-next.
|
|
40
|
+
"@sd-jwt/crypto-nodejs": "0.15.2-next.9+75d5780"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@noble/hashes": "^
|
|
44
|
-
"@sd-jwt/utils": "0.15.2-next.
|
|
43
|
+
"@noble/hashes": "^2.0.1",
|
|
44
|
+
"@sd-jwt/utils": "0.15.2-next.9+75d5780"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"esm"
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "75d5780fb53c5e2c886537b283503fc6fb088a4a"
|
|
63
63
|
}
|
package/src/sha.ts
CHANGED
|
@@ -32,18 +32,15 @@ export const hasher = (
|
|
|
32
32
|
data: string | ArrayBuffer,
|
|
33
33
|
algorithm: HasherAlgorithm = 'sha256',
|
|
34
34
|
) => {
|
|
35
|
-
const msg =
|
|
36
|
-
typeof data === 'string' ? toUTF8Array(data) : new Uint8Array(data);
|
|
37
|
-
|
|
38
35
|
const alg = toCryptoAlg(algorithm);
|
|
39
36
|
|
|
40
37
|
switch (alg) {
|
|
41
38
|
case 'sha256':
|
|
42
|
-
return sha256(
|
|
39
|
+
return sha256(data);
|
|
43
40
|
case 'sha384':
|
|
44
|
-
return sha384(
|
|
41
|
+
return sha384(data);
|
|
45
42
|
case 'sha512':
|
|
46
|
-
return sha512(
|
|
43
|
+
return sha512(data);
|
|
47
44
|
default:
|
|
48
45
|
throw new SDJWTException(`Unsupported algorithm: ${algorithm}`);
|
|
49
46
|
}
|
package/src/test/sha.spec.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { bytesToHex } from '@noble/hashes/utils.js';
|
|
1
3
|
import { digest } from '@sd-jwt/crypto-nodejs';
|
|
2
|
-
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
|
-
import { hasher, sha256 } from '../index';
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
|
-
import {
|
|
5
|
+
import { hasher, sha256 } from '../index';
|
|
6
6
|
|
|
7
7
|
describe('hashing tests', () => {
|
|
8
8
|
test('test#1', async () => {
|
|
@@ -119,7 +119,7 @@ describe('hashing tests', () => {
|
|
|
119
119
|
|
|
120
120
|
test('Hasher failed', async () => {
|
|
121
121
|
try {
|
|
122
|
-
|
|
122
|
+
hasher('test', 'sha-512');
|
|
123
123
|
} catch (e) {
|
|
124
124
|
expect(e).toBeInstanceOf(Error);
|
|
125
125
|
}
|