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

hyperledger-identus / sdk-ts / 14536530200

18 Apr 2025 02:17PM UTC coverage: 82.802% (+7.3%) from 75.544%
14536530200

Pull #419

github

web-flow
Merge d20157089 into 0bddae204
Pull Request #419: test: chai and sinon removal

1711 of 2060 branches covered (83.06%)

Branch coverage included in aggregate %.

1 of 4 new or added lines in 1 file covered. (25.0%)

1047 existing lines in 114 files now uncovered.

9401 of 11360 relevant lines covered (82.76%)

33.67 hits per line

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

93.33
/src/edge-agent/didcomm/ParseOOBInvitation.ts
1
import * as Domain from "../../domain";
1✔
2
import { JsonObj, asArray, asJsonObj, isArray, isObject, notEmptyString } from "../../utils";
1✔
3
import { Task } from "../../utils/tasks";
1✔
4
import { InvitationIsInvalidError } from "../../domain/models/errors/Agent";
1✔
5
import { OutOfBandInvitation } from "../protocols/invitation/v2/OutOfBandInvitation";
1✔
6
import { ProtocolType } from "../protocols/ProtocolTypes";
1✔
7

8
/**
9
 * parse OOB invitation
10
 */
11

12
interface Args {
13
  value: string | JsonObj;
14
}
15

16
export class ParseOOBInvitation extends Task<OutOfBandInvitation, Args> {
1✔
17
  async run() {
1✔
18
    const invitation = this.safeParseBody();
6✔
19

20
    if (invitation.isExpired) {
6✔
21
      throw new InvitationIsInvalidError('expired');
2✔
22
    }
2✔
23

24
    return invitation;
4✔
25
  }
6✔
26

27
  private safeParseBody(): OutOfBandInvitation {
1✔
28
    const msg = asJsonObj(this.args.value);
6✔
29
    const valid = (
6✔
30
      msg.type === ProtocolType.Didcomminvitation
6✔
31
      && notEmptyString(msg.id)
6✔
32
      && notEmptyString(msg.from)
6✔
33
      && isObject(msg.body)
6✔
34
      && isArray(msg.body.accept)
6✔
35
      && msg.body.accept.every(notEmptyString)
6✔
36
    );
37

38
    if (valid === false) {
6!
39
      throw new InvitationIsInvalidError();
×
UNCOV
40
    }
×
41

42
    const attachments = asArray(msg.attachments).map((attachment) =>
6✔
43
      Domain.AttachmentDescriptor.build(attachment.data, attachment.id, attachment.mediaType)
2✔
44
    );
6✔
45

46
    return new OutOfBandInvitation(
6✔
47
      msg.body,
6✔
48
      msg.from,
6✔
49
      msg.id,
6✔
50
      attachments,
6✔
51
      msg.expires_time
6✔
52
    );
6✔
53
  }
6✔
54
}
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

© 2025 Coveralls, Inc