• 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

92.68
/src/edge-agent/didcomm/HandleOOBInvitation.ts
1
import * as Domain from "../../domain";
1✔
2
import { asArray, isNil, notNil } from "../../utils";
1✔
3
import { Task } from "../../utils/tasks";
1✔
4
import { OutOfBandInvitation } from "../protocols/invitation/v2/OutOfBandInvitation";
5
import { AgentContext } from "./Context";
6
import { CreatePeerDID } from "./CreatePeerDID";
1✔
7
import { HandshakeRequest } from "../protocols/connection/HandshakeRequest";
1✔
8
import { ListenerKey } from "../types";
1✔
9
import { Connection } from "../connections";
1✔
10
import { DIDCommConnection } from "../connections/didcomm";
1✔
11

12
/**
13
 * Create a connection from an OutOfBandInvitation
14
 * unless the Invitation has Attachments, then we parse and store those
15
 */
16

17
interface Args {
18
  invitation: OutOfBandInvitation;
19
  alias?: string;
20
}
21

22
export class HandleOOBInvitation extends Task<void, Args> {
1✔
23
  async run(ctx: AgentContext) {
1✔
24
    const attachment = asArray(this.args.invitation.attachments).at(0);
3✔
25
    // ?? make peerDID an arg - so we dont always create a new one
26
    const peerDID = await ctx.run(new CreatePeerDID({ services: [], updateMediator: true }));
3✔
27
    const attachedMsg = notNil(attachment)
3✔
28
      ? Domain.Message.fromJson({ ...attachment.payload, to: peerDID.toString() })
1✔
29
      : null;
2✔
30

31
    if (isNil(attachedMsg)) {
3✔
32
      if (isNil(ctx.Connections.mediator)) {
2!
33
        throw new Domain.AgentError.NoMediatorAvailableError();
×
UNCOV
34
      }
×
35

36
      const request = HandshakeRequest.fromOutOfBand(this.args.invitation, peerDID);
2✔
37
      const alias = this.args.alias ?? "OOBConn";
2✔
38
      const pair = new Domain.DIDPair(peerDID, request.to, alias);
2✔
39
      const connection = new DIDCommConnection(pair.receiver.toString(), pair.host.toString(), alias);
2✔
40
      ctx.Connections.add(connection);
2✔
41

42
      // [ ] investigate response https://github.com/hyperledger-identus/sdk-ts/issues/392
43
      await connection.send(request.makeMessage(), ctx);
2✔
44
      await ctx.Pluto.storeDIDPair(pair.host, pair.receiver, pair.name);
2✔
45
      connection.state = Connection.State.GRANTED;
2✔
46
      // ??? update events to use Connections not pairs
47
      ctx.Events.emit(ListenerKey.CONNECTION, pair);
2✔
48
    }
2✔
49
    else {
1✔
50
      await ctx.Pluto.storeMessage(attachedMsg);
1✔
51
      await ctx.Events.emit(ListenerKey.MESSAGE, [attachedMsg]);
1✔
52
    }
1✔
53
  }
3✔
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