@road-labs/ocmf 0.0.4 → 0.0.5

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const signature_1 = require("./signature");
4
4
  const parse_1 = require("./parse");
5
5
  const errors_1 = require("./errors");
6
+ const defaultSignatureMethodId = 'ECDSA-secp256r1-SHA256';
6
7
  class Verifier {
7
8
  crypto;
8
9
  constructor(crypto) {
@@ -12,7 +13,8 @@ class Verifier {
12
13
  const sections = (0, parse_1.decomposeValue)(rawSignedData);
13
14
  const signedData = (0, parse_1.parseSections)(sections);
14
15
  const { signature } = signedData;
15
- const signatureMethod = (0, signature_1.signatureMethodFromId)(signature.SA);
16
+ const signatureMethodId = signature.SA || defaultSignatureMethodId;
17
+ const signatureMethod = (0, signature_1.signatureMethodFromId)(signatureMethodId);
16
18
  if (signatureMethod.curve !== publicKey.getCurve()) {
17
19
  throw new errors_1.CurveMismatchError(`Expected ${publicKey.getCurve()}, actual ${signatureMethod.curve}`);
18
20
  }
@@ -1,6 +1,7 @@
1
1
  import { signatureMethodFromId } from './signature';
2
2
  import { decomposeValue, parseSections } from './parse';
3
3
  import { CurveMismatchError, UnknownSignatureEncoding, UnknownSignatureMimeType, } from './errors';
4
+ const defaultSignatureMethodId = 'ECDSA-secp256r1-SHA256';
4
5
  export default class Verifier {
5
6
  crypto;
6
7
  constructor(crypto) {
@@ -10,7 +11,8 @@ export default class Verifier {
10
11
  const sections = decomposeValue(rawSignedData);
11
12
  const signedData = parseSections(sections);
12
13
  const { signature } = signedData;
13
- const signatureMethod = signatureMethodFromId(signature.SA);
14
+ const signatureMethodId = signature.SA || defaultSignatureMethodId;
15
+ const signatureMethod = signatureMethodFromId(signatureMethodId);
14
16
  if (signatureMethod.curve !== publicKey.getCurve()) {
15
17
  throw new CurveMismatchError(`Expected ${publicKey.getCurve()}, actual ${signatureMethod.curve}`);
16
18
  }
@@ -55,7 +55,7 @@ export interface PayloadData {
55
55
  }[];
56
56
  }
57
57
  export interface Signature {
58
- SA: SignatureMethodId;
58
+ SA?: SignatureMethodId;
59
59
  SE?: 'hex';
60
60
  SM?: 'application/x-der';
61
61
  SD: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@road-labs/ocmf",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "main": "build/cjs/index.js",
5
5
  "module": "build/es2022/index.js",
6
6
  "types": "build/types/index.d.ts",
@@ -25,12 +25,12 @@
25
25
  "rimraf": "^6.0.1",
26
26
  "ts-jest": "^29.4.0",
27
27
  "ts-node": "^10.9.2",
28
- "typescript": "^5.8.3",
28
+ "typescript": "5.8.3",
29
29
  "jest-mock-extended": "^4.0.0",
30
30
  "test-commons": "0.0.1"
31
31
  },
32
32
  "dependencies": {
33
- "@road-labs/ocmf-crypto": "0.0.4"
33
+ "@road-labs/ocmf-crypto": "0.0.5"
34
34
  },
35
35
  "scripts": {
36
36
  "clear": "rimraf build",