@sd-jwt/crypto-browser 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 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-browser
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-browser
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare const generateSalt: (length: number) => string;
2
- declare function digest(data: string, algorithm?: string): Promise<Uint8Array>;
2
+ declare function digest(data: string | ArrayBuffer, algorithm?: string): Promise<Uint8Array>;
3
3
  declare const getHasher: (algorithm?: string) => (data: string) => Promise<Uint8Array>;
4
4
  declare const ES256: {
5
5
  alg: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare const generateSalt: (length: number) => string;
2
- declare function digest(data: string, algorithm?: string): Promise<Uint8Array>;
2
+ declare function digest(data: string | ArrayBuffer, algorithm?: string): Promise<Uint8Array>;
3
3
  declare const getHasher: (algorithm?: string) => (data: string) => Promise<Uint8Array>;
4
4
  declare const ES256: {
5
5
  alg: string;
package/dist/index.js CHANGED
@@ -63,7 +63,10 @@ var generateSalt = (length) => {
63
63
  function digest(data, algorithm = "SHA-256") {
64
64
  return __async(this, null, function* () {
65
65
  const ec = new TextEncoder();
66
- const digest2 = yield window.crypto.subtle.digest(algorithm, ec.encode(data));
66
+ const digest2 = yield window.crypto.subtle.digest(
67
+ algorithm,
68
+ typeof data === "string" ? ec.encode(data) : data
69
+ );
67
70
  return new Uint8Array(digest2);
68
71
  });
69
72
  }
package/dist/index.mjs CHANGED
@@ -35,7 +35,10 @@ var generateSalt = (length) => {
35
35
  function digest(data, algorithm = "SHA-256") {
36
36
  return __async(this, null, function* () {
37
37
  const ec = new TextEncoder();
38
- const digest2 = yield window.crypto.subtle.digest(algorithm, ec.encode(data));
38
+ const digest2 = yield window.crypto.subtle.digest(
39
+ algorithm,
40
+ typeof data === "string" ? ec.encode(data) : data
41
+ );
39
42
  return new Uint8Array(digest2);
40
43
  });
41
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/crypto-browser",
3
- "version": "0.7.2",
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",
@@ -49,5 +49,5 @@
49
49
  "esm"
50
50
  ]
51
51
  },
52
- "gitHead": "d3cc53b66be9ef40ede9f86a931b7a43f55dbd3a"
52
+ "gitHead": "0d9742cd87d643079c7828ac3689d39ac4f6f21d"
53
53
  }
package/src/crypto.ts CHANGED
@@ -14,11 +14,14 @@ export const generateSalt = (length: number): string => {
14
14
  };
15
15
 
16
16
  export async function digest(
17
- data: string,
17
+ data: string | ArrayBuffer,
18
18
  algorithm = 'SHA-256',
19
19
  ): Promise<Uint8Array> {
20
20
  const ec = new TextEncoder();
21
- const digest = await window.crypto.subtle.digest(algorithm, ec.encode(data));
21
+ const digest = await window.crypto.subtle.digest(
22
+ algorithm,
23
+ typeof data === 'string' ? ec.encode(data) : data,
24
+ );
22
25
  return new Uint8Array(digest);
23
26
  }
24
27