@sd-jwt/crypto-nodejs 0.7.2 → 0.8.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/CHANGELOG.md +8 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/index.mjs +5 -1
- package/package.json +2 -2
- package/src/crypto.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.8.0](https://github.com/openwallet-foundation-labs/sd-jwt-js/compare/v0.7.2...v0.8.0) (2024-11-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @sd-jwt/crypto-nodejs
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.7.2](https://github.com/openwallet-foundation-labs/sd-jwt-js/compare/v0.7.1...v0.7.2) (2024-07-19)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @sd-jwt/crypto-nodejs
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as crypto from 'crypto';
|
|
2
2
|
|
|
3
3
|
declare const generateSalt: (length: number) => string;
|
|
4
|
-
declare const digest: (data: string, algorithm?: string) => Uint8Array;
|
|
4
|
+
declare const digest: (data: string | ArrayBuffer, algorithm?: string) => Uint8Array;
|
|
5
5
|
declare const ES256: {
|
|
6
6
|
alg: string;
|
|
7
7
|
generateKeyPair(): Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as crypto from 'crypto';
|
|
2
2
|
|
|
3
3
|
declare const generateSalt: (length: number) => string;
|
|
4
|
-
declare const digest: (data: string, algorithm?: string) => Uint8Array;
|
|
4
|
+
declare const digest: (data: string | ArrayBuffer, algorithm?: string) => Uint8Array;
|
|
5
5
|
declare const ES256: {
|
|
6
6
|
alg: string;
|
|
7
7
|
generateKeyPair(): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -59,7 +59,11 @@ var generateSalt = (length) => {
|
|
|
59
59
|
var digest = (data, algorithm = "SHA-256") => {
|
|
60
60
|
const nodeAlg = toNodeCryptoAlg(algorithm);
|
|
61
61
|
const hash = (0, import_node_crypto.createHash)(nodeAlg);
|
|
62
|
-
|
|
62
|
+
if (typeof data === "string") {
|
|
63
|
+
hash.update(data);
|
|
64
|
+
} else {
|
|
65
|
+
hash.update(Buffer.from(data));
|
|
66
|
+
}
|
|
63
67
|
const hashBuffer = hash.digest();
|
|
64
68
|
return new Uint8Array(hashBuffer);
|
|
65
69
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,11 @@ var generateSalt = (length) => {
|
|
|
32
32
|
var digest = (data, algorithm = "SHA-256") => {
|
|
33
33
|
const nodeAlg = toNodeCryptoAlg(algorithm);
|
|
34
34
|
const hash = createHash(nodeAlg);
|
|
35
|
-
|
|
35
|
+
if (typeof data === "string") {
|
|
36
|
+
hash.update(data);
|
|
37
|
+
} else {
|
|
38
|
+
hash.update(Buffer.from(data));
|
|
39
|
+
}
|
|
36
40
|
const hashBuffer = hash.digest();
|
|
37
41
|
return new Uint8Array(hashBuffer);
|
|
38
42
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/crypto-nodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "sd-jwt draft 7 implementation in typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"esm"
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "0d9742cd87d643079c7828ac3689d39ac4f6f21d"
|
|
56
56
|
}
|
package/src/crypto.ts
CHANGED
|
@@ -9,10 +9,17 @@ export const generateSalt = (length: number): string => {
|
|
|
9
9
|
return salt.substring(0, length);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const digest = (
|
|
12
|
+
export const digest = (
|
|
13
|
+
data: string | ArrayBuffer,
|
|
14
|
+
algorithm = 'SHA-256',
|
|
15
|
+
): Uint8Array => {
|
|
13
16
|
const nodeAlg = toNodeCryptoAlg(algorithm);
|
|
14
17
|
const hash = createHash(nodeAlg);
|
|
15
|
-
|
|
18
|
+
if (typeof data === 'string') {
|
|
19
|
+
hash.update(data);
|
|
20
|
+
} else {
|
|
21
|
+
hash.update(Buffer.from(data));
|
|
22
|
+
}
|
|
16
23
|
const hashBuffer = hash.digest();
|
|
17
24
|
return new Uint8Array(hashBuffer);
|
|
18
25
|
};
|