@siphon-project/control 0.2.0 → 0.3.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.
- package/dist/index.cjs +78 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -3
- package/dist/index.d.ts +119 -3
- package/dist/index.js +78 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -631,6 +631,9 @@ function routeTargetToWire(target) {
|
|
|
631
631
|
if (target.timeout !== void 0) {
|
|
632
632
|
object.timeout = target.timeout;
|
|
633
633
|
}
|
|
634
|
+
if (target.rerouteAfterProgress === true) {
|
|
635
|
+
object.reroute_after_progress = true;
|
|
636
|
+
}
|
|
634
637
|
return object;
|
|
635
638
|
}
|
|
636
639
|
function stringValue(result) {
|
|
@@ -642,6 +645,41 @@ function stringValue(result) {
|
|
|
642
645
|
}
|
|
643
646
|
return null;
|
|
644
647
|
}
|
|
648
|
+
function originateArgs(channel, to, media, options) {
|
|
649
|
+
const args = { channel, to };
|
|
650
|
+
if ("anchor" in media) {
|
|
651
|
+
args.media = true;
|
|
652
|
+
if (media.profile !== void 0) args.profile = media.profile;
|
|
653
|
+
if (media.wsUri !== void 0) args.ws_uri = media.wsUri;
|
|
654
|
+
} else if ("sdp" in media) {
|
|
655
|
+
args.sdp = media.sdp;
|
|
656
|
+
} else {
|
|
657
|
+
args.body = media.body;
|
|
658
|
+
args.content_type = media.contentType;
|
|
659
|
+
}
|
|
660
|
+
if (!options) return args;
|
|
661
|
+
if (options.from !== void 0) args.from = options.from;
|
|
662
|
+
if (options.fromDisplay !== void 0) args.from_display = options.fromDisplay;
|
|
663
|
+
if (options.toDisplay !== void 0) args.to_display = options.toDisplay;
|
|
664
|
+
if (options.nextHop !== void 0) args.next_hop = options.nextHop;
|
|
665
|
+
if (options.pAssertedIdentity !== void 0) {
|
|
666
|
+
args.p_asserted_identity = options.pAssertedIdentity;
|
|
667
|
+
}
|
|
668
|
+
if (options.privacy !== void 0) args.privacy = options.privacy;
|
|
669
|
+
if (options.headers !== void 0) args.headers = options.headers;
|
|
670
|
+
if (options.timeout !== void 0) args.timeout = options.timeout;
|
|
671
|
+
if (options.onLost !== void 0) args.on_lost = options.onLost;
|
|
672
|
+
if (options.vars !== void 0) args.vars = options.vars;
|
|
673
|
+
if (options.sessionTimer !== void 0) {
|
|
674
|
+
const timer = {};
|
|
675
|
+
const { expires, minSe, refresher } = options.sessionTimer;
|
|
676
|
+
if (expires !== void 0) timer.expires = expires;
|
|
677
|
+
if (minSe !== void 0) timer.min_se = minSe;
|
|
678
|
+
if (refresher !== void 0) timer.refresher = refresher;
|
|
679
|
+
args.session_timer = timer;
|
|
680
|
+
}
|
|
681
|
+
return args;
|
|
682
|
+
}
|
|
645
683
|
function playArgs(source, options) {
|
|
646
684
|
const args = {};
|
|
647
685
|
if ("file" in source) {
|
|
@@ -823,7 +861,9 @@ var Call = class {
|
|
|
823
861
|
*
|
|
824
862
|
* `targets` is a non-empty list of carriers tried cheapest-first: each entry
|
|
825
863
|
* is a bare URI string or a {@link RouteTargetObject}
|
|
826
|
-
* (`{uri, nextHop?, headers?, timeout?}`).
|
|
864
|
+
* (`{uri, nextHop?, headers?, timeout?, rerouteAfterProgress?}`). A target
|
|
865
|
+
* that has shown progress keeps the call past its `timeout` unless it sets
|
|
866
|
+
* `rerouteAfterProgress`. `strategy` defaults to
|
|
827
867
|
* `"sequential"` (v1 supports only sequential/single — anything else rejects
|
|
828
868
|
* with `code === "unsupported_verb"`). `headers` is applied to every
|
|
829
869
|
* attempt's B-leg INVITE.
|
|
@@ -1204,6 +1244,42 @@ var SipClient = class _SipClient {
|
|
|
1204
1244
|
describe() {
|
|
1205
1245
|
return this.client.describe();
|
|
1206
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Place an outbound call under a caller-supplied channel id.
|
|
1249
|
+
*
|
|
1250
|
+
* The one verb that *creates* a channel rather than addressing one, which is
|
|
1251
|
+
* why it lives here and not on {@link Call}. It resolves as soon as the
|
|
1252
|
+
* INVITE is on the wire — the call is `calling`, and the answer, failure or
|
|
1253
|
+
* timeout arrives later as an event on the channel.
|
|
1254
|
+
*
|
|
1255
|
+
* ```ts
|
|
1256
|
+
* const call = await client.originate(
|
|
1257
|
+
* "wake-up-42",
|
|
1258
|
+
* "sip:1001@pbx.example",
|
|
1259
|
+
* { anchor: true },
|
|
1260
|
+
* { from: "sip:alarm@pbx.example", timeout: 20 },
|
|
1261
|
+
* );
|
|
1262
|
+
* ```
|
|
1263
|
+
*/
|
|
1264
|
+
async originate(channel, to, media, options) {
|
|
1265
|
+
const result = await this.client.command(
|
|
1266
|
+
MODULE_SIP,
|
|
1267
|
+
"originate",
|
|
1268
|
+
null,
|
|
1269
|
+
originateArgs(channel, to, media, options)
|
|
1270
|
+
);
|
|
1271
|
+
const text = (name) => {
|
|
1272
|
+
const value = result?.[name];
|
|
1273
|
+
return typeof value === "string" ? value : void 0;
|
|
1274
|
+
};
|
|
1275
|
+
return {
|
|
1276
|
+
// The server echoes the id back; fall back to the one we asked for
|
|
1277
|
+
// rather than returning an empty channel a caller cannot address.
|
|
1278
|
+
channel: text("channel") ?? channel,
|
|
1279
|
+
callId: text("call_id"),
|
|
1280
|
+
sipCallId: text("sip_call_id")
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1207
1283
|
/** Send a raw command on any module (the generic escape hatch). */
|
|
1208
1284
|
command(module, verb, target, args) {
|
|
1209
1285
|
return this.client.command(module, verb, target, args);
|
|
@@ -1274,6 +1350,7 @@ exports.SipVerb = SipVerb;
|
|
|
1274
1350
|
exports.encodeCommand = encodeCommand;
|
|
1275
1351
|
exports.isBridgeFinal = isBridgeFinal;
|
|
1276
1352
|
exports.isTransferFinal = isTransferFinal;
|
|
1353
|
+
exports.originateArgs = originateArgs;
|
|
1277
1354
|
exports.parseInboundFrame = parseInboundFrame;
|
|
1278
1355
|
exports.sipEventKind = sipEventKind;
|
|
1279
1356
|
exports.transferOutcome = transferOutcome;
|