@ajna-inc/webrtc 0.1.0 → 0.2.0

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.
Files changed (45) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +143 -17
  3. package/build/index.d.ts +6 -2
  4. package/build/index.js +5 -1
  5. package/build/index.js.map +1 -1
  6. package/build/webrtc/WebRTCApi.d.ts +94 -5
  7. package/build/webrtc/WebRTCApi.js +107 -4
  8. package/build/webrtc/WebRTCApi.js.map +1 -1
  9. package/build/webrtc/WebRTCEvents.d.ts +87 -5
  10. package/build/webrtc/WebRTCEvents.js +8 -0
  11. package/build/webrtc/WebRTCEvents.js.map +1 -1
  12. package/build/webrtc/WebRTCModule.d.ts +50 -0
  13. package/build/webrtc/WebRTCModule.js +17 -2
  14. package/build/webrtc/WebRTCModule.js.map +1 -1
  15. package/build/webrtc/handlers/RenegotiateHandler.d.ts +9 -0
  16. package/build/webrtc/handlers/RenegotiateHandler.js +31 -0
  17. package/build/webrtc/handlers/RenegotiateHandler.js.map +1 -0
  18. package/build/webrtc/handlers/index.d.ts +1 -0
  19. package/build/webrtc/handlers/index.js +1 -0
  20. package/build/webrtc/handlers/index.js.map +1 -1
  21. package/build/webrtc/messages/AnswerMessage.d.ts +9 -0
  22. package/build/webrtc/messages/AnswerMessage.js +11 -1
  23. package/build/webrtc/messages/AnswerMessage.js.map +1 -1
  24. package/build/webrtc/messages/EndMessage.d.ts +1 -0
  25. package/build/webrtc/messages/EndMessage.js +1 -1
  26. package/build/webrtc/messages/EndMessage.js.map +1 -1
  27. package/build/webrtc/messages/IceMessage.d.ts +1 -0
  28. package/build/webrtc/messages/IceMessage.js +1 -1
  29. package/build/webrtc/messages/IceMessage.js.map +1 -1
  30. package/build/webrtc/messages/OfferMessage.d.ts +29 -1
  31. package/build/webrtc/messages/OfferMessage.js +37 -2
  32. package/build/webrtc/messages/OfferMessage.js.map +1 -1
  33. package/build/webrtc/messages/ProposeMessage.d.ts +51 -0
  34. package/build/webrtc/messages/ProposeMessage.js +48 -2
  35. package/build/webrtc/messages/ProposeMessage.js.map +1 -1
  36. package/build/webrtc/messages/RenegotiateMessage.d.ts +52 -0
  37. package/build/webrtc/messages/RenegotiateMessage.js +65 -0
  38. package/build/webrtc/messages/RenegotiateMessage.js.map +1 -0
  39. package/build/webrtc/messages/index.d.ts +1 -0
  40. package/build/webrtc/messages/index.js +1 -0
  41. package/build/webrtc/messages/index.js.map +1 -1
  42. package/build/webrtc/services/WebRTCService.d.ts +66 -5
  43. package/build/webrtc/services/WebRTCService.js +123 -15
  44. package/build/webrtc/services/WebRTCService.js.map +1 -1
  45. package/package.json +6 -7
@@ -1,14 +1,34 @@
1
1
  import { AgentMessage } from '@credo-ts/core';
2
+ /**
3
+ * ICE policy for NAT traversal
4
+ * - 'all': Use all available candidates (host, srflx, relay)
5
+ * - 'relay-preferred': Prefer relay candidates but allow others
6
+ * - 'relay-only': Only use relay (TURN) candidates - best for strict NAT/firewall
7
+ */
8
+ export type IcePolicy = 'all' | 'relay-preferred' | 'relay-only';
2
9
  export declare class IceServerConfig {
3
- urls: string;
10
+ /**
11
+ * STUN/TURN server URL(s). Can be a single URL or array of URLs.
12
+ * Examples: 'stun:stun.example.org:3478', ['turn:turn.example.org:3478', 'turns:turn.example.org:5349']
13
+ */
14
+ urls?: string | string[];
15
+ url?: string;
4
16
  username?: string;
5
17
  credential?: string;
18
+ credentialType?: 'password' | 'oauth';
19
+ /**
20
+ * Get URLs as array (handles both urls and legacy url field)
21
+ */
22
+ getUrls(): string[];
6
23
  }
7
24
  export interface OfferMessageOptions {
8
25
  id?: string;
9
26
  threadId: string;
27
+ parentThreadId?: string;
10
28
  sdp: string;
11
29
  iceServers?: IceServerConfig[];
30
+ policy?: IcePolicy;
31
+ trickle?: boolean;
12
32
  jws?: Record<string, unknown>;
13
33
  }
14
34
  export declare class OfferMessage extends AgentMessage {
@@ -17,5 +37,13 @@ export declare class OfferMessage extends AgentMessage {
17
37
  static readonly type: import("@credo-ts/core").ParsedMessageType;
18
38
  sdp: string;
19
39
  iceServers?: IceServerConfig[];
40
+ /**
41
+ * ICE policy for NAT traversal
42
+ */
43
+ policy?: IcePolicy;
44
+ /**
45
+ * Whether trickle ICE is supported/requested
46
+ */
47
+ trickle?: boolean;
20
48
  jws?: Record<string, unknown>;
21
49
  }
@@ -14,12 +14,30 @@ const core_1 = require("@credo-ts/core");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const class_transformer_1 = require("class-transformer");
16
16
  class IceServerConfig {
17
+ /**
18
+ * Get URLs as array (handles both urls and legacy url field)
19
+ */
20
+ getUrls() {
21
+ if (this.urls) {
22
+ return Array.isArray(this.urls) ? this.urls : [this.urls];
23
+ }
24
+ if (this.url) {
25
+ return [this.url];
26
+ }
27
+ return [];
28
+ }
17
29
  }
18
30
  exports.IceServerConfig = IceServerConfig;
19
31
  __decorate([
32
+ (0, class_validator_1.IsOptional)(),
20
33
  (0, class_validator_1.IsString)(),
21
- __metadata("design:type", String)
34
+ __metadata("design:type", Object)
22
35
  ], IceServerConfig.prototype, "urls", void 0);
36
+ __decorate([
37
+ (0, class_validator_1.IsOptional)(),
38
+ (0, class_validator_1.IsString)(),
39
+ __metadata("design:type", String)
40
+ ], IceServerConfig.prototype, "url", void 0);
23
41
  __decorate([
24
42
  (0, class_validator_1.IsOptional)(),
25
43
  (0, class_validator_1.IsString)(),
@@ -30,6 +48,11 @@ __decorate([
30
48
  (0, class_validator_1.IsString)(),
31
49
  __metadata("design:type", String)
32
50
  ], IceServerConfig.prototype, "credential", void 0);
51
+ __decorate([
52
+ (0, class_validator_1.IsOptional)(),
53
+ (0, class_validator_1.IsString)(),
54
+ __metadata("design:type", String)
55
+ ], IceServerConfig.prototype, "credentialType", void 0);
33
56
  class OfferMessage extends core_1.AgentMessage {
34
57
  constructor(options) {
35
58
  super();
@@ -38,8 +61,10 @@ class OfferMessage extends core_1.AgentMessage {
38
61
  this.id = options.id ?? this.generateId();
39
62
  this.sdp = options.sdp;
40
63
  this.iceServers = options.iceServers;
64
+ this.policy = options.policy;
65
+ this.trickle = options.trickle;
41
66
  this.jws = options.jws;
42
- this.setThread({ threadId: options.threadId });
67
+ this.setThread({ threadId: options.threadId, parentThreadId: options.parentThreadId });
43
68
  }
44
69
  }
45
70
  }
@@ -60,6 +85,16 @@ __decorate([
60
85
  (0, class_validator_1.IsArray)(),
61
86
  __metadata("design:type", Array)
62
87
  ], OfferMessage.prototype, "iceServers", void 0);
88
+ __decorate([
89
+ (0, class_validator_1.IsOptional)(),
90
+ (0, class_validator_1.IsString)(),
91
+ __metadata("design:type", String)
92
+ ], OfferMessage.prototype, "policy", void 0);
93
+ __decorate([
94
+ (0, class_validator_1.IsOptional)(),
95
+ (0, class_validator_1.IsBoolean)(),
96
+ __metadata("design:type", Boolean)
97
+ ], OfferMessage.prototype, "trickle", void 0);
63
98
  __decorate([
64
99
  (0, class_validator_1.IsOptional)(),
65
100
  (0, class_validator_1.IsObject)(),
@@ -1 +1 @@
1
- {"version":3,"file":"OfferMessage.js","sourceRoot":"","sources":["../../../src/webrtc/messages/OfferMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAmF;AACnF,qDAAyF;AACzF,yDAAwC;AAExC,MAAa,eAAe;CAW3B;AAXD,0CAWC;AATQ;IADN,IAAA,0BAAQ,GAAE;;6CACS;AAIb;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;iDACa;AAIjB;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACe;AAW5B,MAAa,YAAa,SAAQ,mBAAY;IAC5C,YAAmB,OAA4B;QAC7C,KAAK,EAAE,CAAA;QAWO,SAAI,GAAG,YAAY,CAAC,IAAI,CAAC,cAAc,CAAA;QAVrD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,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N,IAAA,4BAAU,GAAE;IACZ,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,eAAe,CAAC;IAC3B,IAAA,yBAAO,GAAE;;gDAC2B;AAO9B;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;4CACc;AAOlB;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;6CACY;AAIjB;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;yCACyB"}
@@ -1,12 +1,63 @@
1
1
  import { AgentMessage } from '@credo-ts/core';
2
+ import { IceServerConfig, IcePolicy } from './OfferMessage';
3
+ /**
4
+ * Media types that can be requested in a call
5
+ */
6
+ export type MediaType = 'audio' | 'video';
2
7
  export interface ProposeMessageOptions {
3
8
  id?: string;
4
9
  threadId?: string;
10
+ parentThreadId?: string;
11
+ /** Requested media types */
12
+ media?: MediaType[];
13
+ /** Whether data channel is requested */
14
+ data?: boolean;
15
+ /** Topology hint: 'mesh' for P2P */
16
+ topology?: 'mesh' | 'sfu';
17
+ /** Whether trickle ICE is supported */
18
+ trickle?: boolean;
19
+ /** ICE policy for NAT traversal */
20
+ policy?: IcePolicy;
21
+ /** ICE servers (STUN/TURN) for NAT traversal */
22
+ iceServers?: IceServerConfig[];
23
+ /** Optional reason/context for the call */
5
24
  reason?: string;
6
25
  }
26
+ /**
27
+ * ProposeMessage - Caller initiates a WebRTC session request
28
+ * This message is sent before the offer to negotiate capabilities and share ICE servers
29
+ */
7
30
  export declare class ProposeMessage extends AgentMessage {
8
31
  constructor(options: ProposeMessageOptions);
9
32
  readonly type: string;
10
33
  static readonly type: import("@credo-ts/core").ParsedMessageType;
34
+ /**
35
+ * Requested media types: ['audio'], ['video'], or ['audio', 'video']
36
+ */
37
+ media?: MediaType[];
38
+ /**
39
+ * Whether a data channel is requested
40
+ */
41
+ data?: boolean;
42
+ /**
43
+ * Topology: 'mesh' for P2P, 'sfu' for server-mediated
44
+ */
45
+ topology?: 'mesh' | 'sfu';
46
+ /**
47
+ * Whether trickle ICE is supported
48
+ */
49
+ trickle?: boolean;
50
+ /**
51
+ * ICE policy for NAT traversal
52
+ */
53
+ policy?: IcePolicy;
54
+ /**
55
+ * ICE servers (STUN/TURN) for NAT traversal
56
+ * Shared early so callee can configure RTCPeerConnection before receiving offer
57
+ */
58
+ iceServers?: IceServerConfig[];
59
+ /**
60
+ * Optional reason/context for the call
61
+ */
11
62
  reason?: string;
12
63
  }
@@ -12,15 +12,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProposeMessage = void 0;
13
13
  const core_1 = require("@credo-ts/core");
14
14
  const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ const OfferMessage_1 = require("./OfferMessage");
17
+ /**
18
+ * ProposeMessage - Caller initiates a WebRTC session request
19
+ * This message is sent before the offer to negotiate capabilities and share ICE servers
20
+ */
15
21
  class ProposeMessage extends core_1.AgentMessage {
16
22
  constructor(options) {
17
23
  super();
18
24
  this.type = ProposeMessage.type.messageTypeUri;
19
25
  if (options) {
20
26
  this.id = options.id ?? this.generateId();
27
+ this.media = options.media;
28
+ this.data = options.data;
29
+ this.topology = options.topology ?? 'mesh';
30
+ this.trickle = options.trickle ?? true;
31
+ this.policy = options.policy;
32
+ this.iceServers = options.iceServers;
21
33
  this.reason = options.reason;
22
- if (options.threadId)
23
- this.setThread({ threadId: options.threadId });
34
+ if (options.threadId) {
35
+ this.setThread({ threadId: options.threadId, parentThreadId: options.parentThreadId });
36
+ }
24
37
  }
25
38
  }
26
39
  }
@@ -30,6 +43,39 @@ __decorate([
30
43
  (0, core_1.IsValidMessageType)(ProposeMessage.type),
31
44
  __metadata("design:type", Object)
32
45
  ], ProposeMessage.prototype, "type", void 0);
46
+ __decorate([
47
+ (0, class_validator_1.IsOptional)(),
48
+ (0, class_validator_1.IsArray)(),
49
+ (0, class_validator_1.IsString)({ each: true }),
50
+ __metadata("design:type", Array)
51
+ ], ProposeMessage.prototype, "media", void 0);
52
+ __decorate([
53
+ (0, class_validator_1.IsOptional)(),
54
+ (0, class_validator_1.IsBoolean)(),
55
+ __metadata("design:type", Boolean)
56
+ ], ProposeMessage.prototype, "data", void 0);
57
+ __decorate([
58
+ (0, class_validator_1.IsOptional)(),
59
+ (0, class_validator_1.IsString)(),
60
+ __metadata("design:type", String)
61
+ ], ProposeMessage.prototype, "topology", void 0);
62
+ __decorate([
63
+ (0, class_validator_1.IsOptional)(),
64
+ (0, class_validator_1.IsBoolean)(),
65
+ __metadata("design:type", Boolean)
66
+ ], ProposeMessage.prototype, "trickle", void 0);
67
+ __decorate([
68
+ (0, class_validator_1.IsOptional)(),
69
+ (0, class_validator_1.IsString)(),
70
+ __metadata("design:type", String)
71
+ ], ProposeMessage.prototype, "policy", void 0);
72
+ __decorate([
73
+ (0, class_validator_1.IsOptional)(),
74
+ (0, class_validator_1.ValidateNested)({ each: true }),
75
+ (0, class_transformer_1.Type)(() => OfferMessage_1.IceServerConfig),
76
+ (0, class_validator_1.IsArray)(),
77
+ __metadata("design:type", Array)
78
+ ], ProposeMessage.prototype, "iceServers", void 0);
33
79
  __decorate([
34
80
  (0, class_validator_1.IsOptional)(),
35
81
  (0, class_validator_1.IsString)(),
@@ -1 +1 @@
1
- {"version":3,"file":"ProposeMessage.js","sourceRoot":"","sources":["../../../src/webrtc/messages/ProposeMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAmF;AACnF,qDAAsD;AAQtD,MAAa,cAAe,SAAQ,mBAAY;IAC9C,YAAmB,OAA8B;QAC/C,KAAK,EAAE,CAAA;QASO,SAAI,GAAG,cAAc,CAAC,IAAI,CAAC,cAAc,CAAA;QARvD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,IAA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,CAAA;YAC5B,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;YACxF,CAAC;QACH,CAAC;IACH,CAAC;;AAhBH,wCA0EC;AAtDwB,mBAAI,GAAG,IAAA,uBAAgB,EAAC,wCAAwC,CAAC,AAA7D,CAA6D;AADxE;IADf,IAAA,yBAAkB,EAAC,cAAc,CAAC,IAAI,CAAC;;4CACiB;AASlD;IAHN,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;6CACC;AAOnB;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;4CACS;AAOd;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;gDACqB;AAOzB;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;+CACY;AAOjB;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;8CACc;AAUlB;IAJN,IAAA,4BAAU,GAAE;IACZ,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,8BAAe,CAAC;IAC3B,IAAA,yBAAO,GAAE;;kDAC2B;AAO9B;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;8CACW"}
@@ -0,0 +1,52 @@
1
+ import { AgentMessage } from '@credo-ts/core';
2
+ import { IceServerConfig, IcePolicy } from './OfferMessage';
3
+ /**
4
+ * Reasons for renegotiation
5
+ */
6
+ export type RenegotiateReason = 'add-track' | 'remove-track' | 'add-screenshare' | 'remove-screenshare' | 'ice-restart' | 'codec-change' | 'bandwidth-change' | 'other';
7
+ export interface RenegotiateMessageOptions {
8
+ id?: string;
9
+ threadId: string;
10
+ parentThreadId?: string;
11
+ /** Reason for renegotiation */
12
+ reason: RenegotiateReason | string;
13
+ /** Whether to perform an ICE restart (required for recovering failed connections) */
14
+ iceRestart?: boolean;
15
+ /** New ICE servers to use (useful when switching networks) */
16
+ iceServers?: IceServerConfig[];
17
+ /** Updated ICE policy */
18
+ policy?: IcePolicy;
19
+ }
20
+ /**
21
+ * RenegotiateMessage - Request to renegotiate the WebRTC session
22
+ * Used for:
23
+ * - Adding/removing media tracks (screenshare, camera switch)
24
+ * - ICE restart when connection fails (critical for NAT/firewall recovery)
25
+ * - Changing codecs or bandwidth constraints
26
+ */
27
+ export declare class RenegotiateMessage extends AgentMessage {
28
+ constructor(options: RenegotiateMessageOptions);
29
+ readonly type: string;
30
+ static readonly type: import("@credo-ts/core").ParsedMessageType;
31
+ /**
32
+ * Reason for renegotiation
33
+ */
34
+ reason: RenegotiateReason | string;
35
+ /**
36
+ * Whether to perform an ICE restart
37
+ * Set to true when:
38
+ * - ICE connection state is 'failed' or 'disconnected'
39
+ * - Network change detected (WiFi to cellular, etc.)
40
+ * - NAT binding expired
41
+ */
42
+ iceRestart?: boolean;
43
+ /**
44
+ * New ICE servers to use
45
+ * Useful when switching networks or when original servers are unreachable
46
+ */
47
+ iceServers?: IceServerConfig[];
48
+ /**
49
+ * Updated ICE policy
50
+ */
51
+ policy?: IcePolicy;
52
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RenegotiateMessage = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ const OfferMessage_1 = require("./OfferMessage");
17
+ /**
18
+ * RenegotiateMessage - Request to renegotiate the WebRTC session
19
+ * Used for:
20
+ * - Adding/removing media tracks (screenshare, camera switch)
21
+ * - ICE restart when connection fails (critical for NAT/firewall recovery)
22
+ * - Changing codecs or bandwidth constraints
23
+ */
24
+ class RenegotiateMessage extends core_1.AgentMessage {
25
+ constructor(options) {
26
+ super();
27
+ this.type = RenegotiateMessage.type.messageTypeUri;
28
+ if (options) {
29
+ this.id = options.id ?? this.generateId();
30
+ this.reason = options.reason;
31
+ this.iceRestart = options.iceRestart ?? false;
32
+ this.iceServers = options.iceServers;
33
+ this.policy = options.policy;
34
+ this.setThread({ threadId: options.threadId, parentThreadId: options.parentThreadId });
35
+ }
36
+ }
37
+ }
38
+ exports.RenegotiateMessage = RenegotiateMessage;
39
+ RenegotiateMessage.type = (0, core_1.parseMessageType)('https://didcomm.org/webrtc/1.0/renegotiate');
40
+ __decorate([
41
+ (0, core_1.IsValidMessageType)(RenegotiateMessage.type),
42
+ __metadata("design:type", Object)
43
+ ], RenegotiateMessage.prototype, "type", void 0);
44
+ __decorate([
45
+ (0, class_validator_1.IsString)(),
46
+ __metadata("design:type", String)
47
+ ], RenegotiateMessage.prototype, "reason", void 0);
48
+ __decorate([
49
+ (0, class_validator_1.IsOptional)(),
50
+ (0, class_validator_1.IsBoolean)(),
51
+ __metadata("design:type", Boolean)
52
+ ], RenegotiateMessage.prototype, "iceRestart", void 0);
53
+ __decorate([
54
+ (0, class_validator_1.IsOptional)(),
55
+ (0, class_validator_1.ValidateNested)({ each: true }),
56
+ (0, class_transformer_1.Type)(() => OfferMessage_1.IceServerConfig),
57
+ (0, class_validator_1.IsArray)(),
58
+ __metadata("design:type", Array)
59
+ ], RenegotiateMessage.prototype, "iceServers", void 0);
60
+ __decorate([
61
+ (0, class_validator_1.IsOptional)(),
62
+ (0, class_validator_1.IsString)(),
63
+ __metadata("design:type", String)
64
+ ], RenegotiateMessage.prototype, "policy", void 0);
65
+ //# sourceMappingURL=RenegotiateMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenegotiateMessage.js","sourceRoot":"","sources":["../../../src/webrtc/messages/RenegotiateMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAmF;AACnF,qDAA0F;AAC1F,yDAAwC;AAExC,iDAA2D;AA6B3D;;;;;;GAMG;AACH,MAAa,kBAAmB,SAAQ,mBAAY;IAClD,YAAmB,OAAkC;QACnD,KAAK,EAAE,CAAA;QAYO,SAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAA;QAX3D,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAA;YACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;YAC5B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAA;YAC7C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;YACpC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;YAC5B,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;QACxF,CAAC;IACH,CAAC;;AAXH,gDAkDC;AAnCwB,uBAAI,GAAG,IAAA,uBAAgB,EAAC,4CAA4C,CAAC,AAAjE,CAAiE;AAD5E;IADf,IAAA,yBAAkB,EAAC,kBAAkB,CAAC,IAAI,CAAC;;gDACiB;AAOtD;IADN,IAAA,0BAAQ,GAAE;;kDAC+B;AAWnC;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;sDACe;AAUpB;IAJN,IAAA,4BAAU,GAAE;IACZ,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,8BAAe,CAAC;IAC3B,IAAA,yBAAO,GAAE;;sDAC2B;AAO9B;IAFN,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACc"}
@@ -2,4 +2,5 @@ export * from './ProposeMessage';
2
2
  export * from './OfferMessage';
3
3
  export * from './AnswerMessage';
4
4
  export * from './IceMessage';
5
+ export * from './RenegotiateMessage';
5
6
  export * from './EndMessage';
@@ -18,5 +18,6 @@ __exportStar(require("./ProposeMessage"), exports);
18
18
  __exportStar(require("./OfferMessage"), exports);
19
19
  __exportStar(require("./AnswerMessage"), exports);
20
20
  __exportStar(require("./IceMessage"), exports);
21
+ __exportStar(require("./RenegotiateMessage"), exports);
21
22
  __exportStar(require("./EndMessage"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webrtc/messages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,iDAA8B;AAC9B,kDAA+B;AAC/B,+CAA4B;AAC5B,+CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webrtc/messages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,iDAA8B;AAC9B,kDAA+B;AAC/B,+CAA4B;AAC5B,uDAAoC;AACpC,+CAA4B"}
@@ -1,25 +1,86 @@
1
1
  import type { AgentContext, InboundMessageContext } from '@credo-ts/core';
2
2
  import type { ConnectionRecord } from '@credo-ts/core';
3
3
  import { EventEmitter } from '@credo-ts/core';
4
- import { AnswerMessage, EndMessage, IceMessage, OfferMessage, ProposeMessage } from '../messages';
4
+ import { AnswerMessage, EndMessage, IceMessage, OfferMessage, ProposeMessage, RenegotiateMessage } from '../messages';
5
+ import type { IcePolicy, IceServerConfig } from '../messages/OfferMessage';
6
+ import type { MediaType } from '../messages/ProposeMessage';
7
+ import type { RenegotiateReason } from '../messages/RenegotiateMessage';
5
8
  import { WebRTCCallRecord } from '../repository/WebRTCCallRecord';
6
9
  import { WebRTCCallRepository } from '../repository/WebRTCCallRepository';
7
10
  export declare class WebRTCService {
8
11
  private repo;
9
12
  private events;
10
13
  constructor(repo: WebRTCCallRepository, events: EventEmitter);
11
- createOffer(agentContext: AgentContext, connection: ConnectionRecord, threadId: string, sdp: string, iceServers?: OfferMessage['iceServers']): {
14
+ /**
15
+ * Create a propose message to initiate a call
16
+ */
17
+ createPropose(options: {
18
+ threadId?: string;
19
+ parentThreadId?: string;
20
+ media?: MediaType[];
21
+ data?: boolean;
22
+ topology?: 'mesh' | 'sfu';
23
+ trickle?: boolean;
24
+ policy?: IcePolicy;
25
+ iceServers?: IceServerConfig[];
26
+ reason?: string;
27
+ }): {
28
+ message: ProposeMessage;
29
+ };
30
+ /**
31
+ * Create an offer message with SDP
32
+ */
33
+ createOffer(agentContext: AgentContext, connection: ConnectionRecord, threadId: string, parentThreadId: string | undefined, sdp: string, iceServers?: IceServerConfig[], policy?: IcePolicy, trickle?: boolean): {
12
34
  message: OfferMessage;
13
35
  record: WebRTCCallRecord;
14
36
  };
15
- createAnswer(agentContext: AgentContext, connection: ConnectionRecord, threadId: string, sdp: string): {
37
+ /**
38
+ * Create an answer message with SDP
39
+ */
40
+ createAnswer(agentContext: AgentContext, connection: ConnectionRecord, threadId: string, parentThreadId: string | undefined, sdp: string, iceServers?: IceServerConfig[]): {
16
41
  message: AnswerMessage;
17
42
  };
18
- createIce(threadId: string, candidate: Record<string, unknown> | undefined, endOfCandidates?: boolean): IceMessage;
19
- createEnd(threadId: string, reason?: string): EndMessage;
43
+ /**
44
+ * Create an ICE candidate message
45
+ */
46
+ createIce(threadId: string, parentThreadId: string | undefined, candidate: Record<string, unknown> | undefined, endOfCandidates?: boolean): IceMessage;
47
+ /**
48
+ * Create a renegotiate message (for ICE restart, track changes, etc.)
49
+ */
50
+ createRenegotiate(options: {
51
+ threadId: string;
52
+ parentThreadId?: string;
53
+ reason: RenegotiateReason | string;
54
+ iceRestart?: boolean;
55
+ iceServers?: IceServerConfig[];
56
+ policy?: IcePolicy;
57
+ }): RenegotiateMessage;
58
+ /**
59
+ * Create an end call message
60
+ */
61
+ createEnd(threadId: string, parentThreadId: string | undefined, reason?: string): EndMessage;
62
+ /**
63
+ * Process incoming propose message
64
+ */
20
65
  processPropose(messageContext: InboundMessageContext<ProposeMessage>): Promise<void>;
66
+ /**
67
+ * Process incoming offer message
68
+ */
21
69
  processOffer(messageContext: InboundMessageContext<OfferMessage>): Promise<void>;
70
+ /**
71
+ * Process incoming answer message
72
+ */
22
73
  processAnswer(messageContext: InboundMessageContext<AnswerMessage>): Promise<void>;
74
+ /**
75
+ * Process incoming ICE candidate message
76
+ */
23
77
  processIce(messageContext: InboundMessageContext<IceMessage>): Promise<void>;
78
+ /**
79
+ * Process incoming renegotiate message
80
+ */
81
+ processRenegotiate(messageContext: InboundMessageContext<RenegotiateMessage>): Promise<void>;
82
+ /**
83
+ * Process incoming end call message
84
+ */
24
85
  processEnd(messageContext: InboundMessageContext<EndMessage>): Promise<void>;
25
86
  }