• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PeculiarVentures / xmldsigjs / 16903405456

12 Aug 2025 08:29AM UTC coverage: 89.156% (+5.9%) from 83.278%
16903405456

push

github

web-flow
Merge pull request #82 from PeculiarVentures/monorepo

952 of 1192 branches covered (79.87%)

5433 of 6095 new or added lines in 92 files covered. (89.14%)

5443 of 6105 relevant lines covered (89.16%)

1565.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/packages/xmldsig/src/algorithm.factory.ts
1
import { XE, XmlError } from 'xml-core';
1✔
2
import { algorithmRegistry } from './algorithm.registry.js';
1✔
3
import { SignatureMethod } from './xml/index.js';
4
import { IHashAlgorithm, ISignatureAlgorithm } from './algorithm.js';
5

6
export class AlgorithmFactory {
1✔
7
  static createHashAlgorithmFromNamespace(namespace: string): IHashAlgorithm {
1✔
8
    for (const [uri, { type, algorithm }] of algorithmRegistry) {
149✔
9
      if (type === 'hash' && uri === namespace) {
2,868✔
10
        return new algorithm();
149✔
11
      }
149✔
12
    }
2,868!
NEW
13
    throw new XmlError(XE.ALGORITHM_NOT_SUPPORTED, namespace);
×
14
  }
149✔
15

16
  static createSignatureAlgorithmFromMethod(method: SignatureMethod): ISignatureAlgorithm {
1✔
17
    for (const [namespaceURI, { type, algorithm: ctor }] of algorithmRegistry) {
211✔
18
      if (type === 'signature' && method.Algorithm === namespaceURI) {
893✔
19
        const signatureAlgorithm = new ctor();
211✔
20

21
        if (signatureAlgorithm.fromMethod) {
211✔
22
          signatureAlgorithm.fromMethod(method);
45✔
23
        }
45✔
24

25
        return signatureAlgorithm;
211✔
26
      }
211✔
27
    }
893!
NEW
28
    throw new XmlError(XE.ALGORITHM_NOT_SUPPORTED, method.Algorithm);
×
29
  }
211✔
30

31
  static createHashAlgorithmFromAlgorithm(alg: Algorithm): IHashAlgorithm {
1✔
32
    for (const [, { type, algorithm: ctor }] of algorithmRegistry) {
90✔
33
      if (type === 'hash') {
1,734✔
34
        const hashAlgorithm = new ctor();
204✔
35
        if (hashAlgorithm.algorithm.name.toUpperCase() === alg.name.toUpperCase()) {
204✔
36
          return hashAlgorithm;
90✔
37
        }
90✔
38
      }
204✔
39
    }
1,734!
40

NEW
41
    throw new XmlError(XE.ALGORITHM_NOT_SUPPORTED, alg.name);
×
42
  }
90✔
43

44
  static createSignatureAlgorithmFromAlgorithm(alg: Algorithm): ISignatureAlgorithm {
1✔
45
    for (const [, { type, algorithm: ctor }] of algorithmRegistry) {
61✔
46
      if (type === 'signature') {
233✔
47
        const signatureAlgorithm = ctor.fromAlgorithm(alg);
233✔
48
        if (signatureAlgorithm) {
233✔
49
          return signatureAlgorithm;
61✔
50
        }
61✔
51
      }
233✔
52
    }
233!
53

NEW
54
    throw new XmlError(XE.ALGORITHM_NOT_SUPPORTED, alg.name);
×
55
  }
61✔
56
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc