@sphereon/oid4vc-common 0.16.1-next.14 → 0.16.1-next.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../lib/hasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7C,eAAO,MAAM,aAAa,EAAE,MAU3B,CAAC"}
1
+ {"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../lib/hasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7C,eAAO,MAAM,aAAa,EAAE,MAW3B,CAAC"}
package/dist/hasher.js CHANGED
@@ -7,10 +7,11 @@ exports.defaultHasher = void 0;
7
7
  const sha_js_1 = __importDefault(require("sha.js"));
8
8
  const supportedAlgorithms = ['sha256', 'sha384', 'sha512'];
9
9
  const defaultHasher = (data, algorithm) => {
10
- if (!supportedAlgorithms.includes(algorithm)) {
10
+ const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');
11
+ if (!supportedAlgorithms.includes(sanitizedAlgorithm)) {
11
12
  throw new Error(`Unsupported hashing algorithm ${algorithm}`);
12
13
  }
13
- return new Uint8Array((0, sha_js_1.default)(algorithm)
14
+ return new Uint8Array((0, sha_js_1.default)(sanitizedAlgorithm)
14
15
  .update(data)
15
16
  .digest());
16
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"hasher.js","sourceRoot":"","sources":["../lib/hasher.ts"],"names":[],"mappings":";;;;;;AACA,oDAAyB;AAEzB,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAG7D,MAAM,aAAa,GAAW,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;IACvD,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,SAAgC,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,UAAU,CACnB,IAAA,gBAAG,EAAC,SAAgC,CAAC;SAClC,MAAM,CAAC,IAAI,CAAC;SACZ,MAAM,EAAE,CACZ,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB"}
1
+ {"version":3,"file":"hasher.js","sourceRoot":"","sources":["../lib/hasher.ts"],"names":[],"mappings":";;;;;;AACA,oDAAyB;AAEzB,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAG7D,MAAM,aAAa,GAAW,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;IACvD,MAAM,kBAAkB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACxE,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,kBAAyC,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,UAAU,CACnB,IAAA,gBAAG,EAAC,kBAAyC,CAAC;SAC3C,MAAM,CAAC,IAAI,CAAC;SACZ,MAAM,EAAE,CACZ,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB"}
package/lib/hasher.ts CHANGED
@@ -5,12 +5,13 @@ const supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const;
5
5
  type SupportedAlgorithms = (typeof supportedAlgorithms)[number];
6
6
 
7
7
  export const defaultHasher: Hasher = (data, algorithm) => {
8
- if (!supportedAlgorithms.includes(algorithm as SupportedAlgorithms)) {
8
+ const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');
9
+ if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {
9
10
  throw new Error(`Unsupported hashing algorithm ${algorithm}`);
10
11
  }
11
12
 
12
13
  return new Uint8Array(
13
- sha(algorithm as SupportedAlgorithms)
14
+ sha(sanitizedAlgorithm as SupportedAlgorithms)
14
15
  .update(data)
15
16
  .digest(),
16
17
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/oid4vc-common",
3
- "version": "0.16.1-next.14+c9ff2fc",
3
+ "version": "0.16.1-next.24+f696867",
4
4
  "description": "OpenID 4 Verifiable Credentials Common",
5
5
  "source": "lib/index.ts",
6
6
  "main": "dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "build:clean": "tsc --build --clean && tsc --build"
11
11
  },
12
12
  "dependencies": {
13
- "@sphereon/ssi-types": "0.29.0",
13
+ "@sphereon/ssi-types": "0.29.1-unstable.208",
14
14
  "jwt-decode": "^4.0.0",
15
15
  "sha.js": "^2.4.11",
16
16
  "uint8arrays": "3.1.1",
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "c9ff2fc9579c80e108efa2b7fe5ca860e23c1117"
55
+ "gitHead": "f6968677ccd10c2ce8eb8484443971102547e8a2"
56
56
  }