@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.d.cts
CHANGED
|
@@ -779,8 +779,19 @@ interface RouteTargetObject {
|
|
|
779
779
|
nextHop?: string;
|
|
780
780
|
/** Headers injected on this attempt's B-leg INVITE. */
|
|
781
781
|
headers?: Record<string, string>;
|
|
782
|
-
/**
|
|
782
|
+
/**
|
|
783
|
+
* Per-target ring timeout in seconds. It bounds the wait for this carrier to
|
|
784
|
+
* show progress (a 101-199), not the wait for its answer.
|
|
785
|
+
*/
|
|
783
786
|
timeout?: number;
|
|
787
|
+
/**
|
|
788
|
+
* Fail this carrier over at its ring timeout even after it has shown
|
|
789
|
+
* progress. By default a carrier that has sent a 180/183 keeps the call past
|
|
790
|
+
* `timeout`, and the call then fails with 408 rather than trying the next
|
|
791
|
+
* target; `true` is for a carrier that plays its own ringback before it has
|
|
792
|
+
* reached anyone. Default `false`, which is never sent.
|
|
793
|
+
*/
|
|
794
|
+
rerouteAfterProgress?: boolean;
|
|
784
795
|
}
|
|
785
796
|
/**
|
|
786
797
|
* One entry in a {@link Call.route} target list: a bare URI string, or a
|
|
@@ -792,6 +803,91 @@ type RouteTarget = string | RouteTargetObject;
|
|
|
792
803
|
* path, an rtpengine media-DB id, or an inline blob. A blob is base64-encoded on
|
|
793
804
|
* the wire (the control rail is JSON text).
|
|
794
805
|
*/
|
|
806
|
+
/**
|
|
807
|
+
* The media plan for {@link SipClient.originate} — what the outbound INVITE
|
|
808
|
+
* offers.
|
|
809
|
+
*
|
|
810
|
+
* Required, and a union, because the server requires exactly one plan and
|
|
811
|
+
* rejects every combination of the raw `sdp` / `body` / `media` arguments that
|
|
812
|
+
* names none or more than one. Expressed this way those errors cannot be
|
|
813
|
+
* written down.
|
|
814
|
+
*/
|
|
815
|
+
type OriginateMedia =
|
|
816
|
+
/** Offerless INVITE: siphon anchors the leg on the media engine. */
|
|
817
|
+
{
|
|
818
|
+
anchor: true;
|
|
819
|
+
profile?: string;
|
|
820
|
+
wsUri?: string;
|
|
821
|
+
}
|
|
822
|
+
/** Your own SDP offer (`application/sdp` by definition). */
|
|
823
|
+
| {
|
|
824
|
+
sdp: string;
|
|
825
|
+
}
|
|
826
|
+
/** Your own body with its own content type. */
|
|
827
|
+
| {
|
|
828
|
+
body: string;
|
|
829
|
+
contentType: string;
|
|
830
|
+
};
|
|
831
|
+
/**
|
|
832
|
+
* Who refreshes each dialog of an originated call where the RFC 4028 negotiation
|
|
833
|
+
* leaves siphon the choice (§7.1): the UAC of each dialog, the UAS of each, or
|
|
834
|
+
* siphon on both.
|
|
835
|
+
*/
|
|
836
|
+
type SessionRefresher = "uac" | "uas" | "b2bua";
|
|
837
|
+
/**
|
|
838
|
+
* The RFC 4028 session timer siphon runs on an originated call, over its
|
|
839
|
+
* `session_timer:` block. A field left out takes the server's default, as in the
|
|
840
|
+
* script API's `call.session_timer()`: 1800 s, a `Min-SE` of 90 s, and `b2bua`.
|
|
841
|
+
*/
|
|
842
|
+
interface SessionTimer {
|
|
843
|
+
/** The session interval, in seconds. */
|
|
844
|
+
expires?: number;
|
|
845
|
+
/** The smallest session interval siphon accepts, in seconds. */
|
|
846
|
+
minSe?: number;
|
|
847
|
+
/** Who refreshes where the negotiation leaves siphon the choice. */
|
|
848
|
+
refresher?: SessionRefresher;
|
|
849
|
+
}
|
|
850
|
+
/** Optional shaping for {@link SipClient.originate}. */
|
|
851
|
+
interface OriginateOptions {
|
|
852
|
+
/** From-URI to place the call as. */
|
|
853
|
+
from?: string;
|
|
854
|
+
/** From display name. */
|
|
855
|
+
fromDisplay?: string;
|
|
856
|
+
/** To display name. */
|
|
857
|
+
toDisplay?: string;
|
|
858
|
+
/** Route the INVITE here while keeping `to` as the R-URI. */
|
|
859
|
+
nextHop?: string;
|
|
860
|
+
/** P-Asserted-Identity to assert (RFC 3325). */
|
|
861
|
+
pAssertedIdentity?: string;
|
|
862
|
+
/** Caller-identity presentation (RFC 3323 §4.1). */
|
|
863
|
+
privacy?: "allowed" | "restricted";
|
|
864
|
+
/** Extra headers on the outbound INVITE. */
|
|
865
|
+
headers?: Record<string, string>;
|
|
866
|
+
/** Ring timeout in seconds. */
|
|
867
|
+
timeout?: number;
|
|
868
|
+
/** Control-loss policy for the created channel. */
|
|
869
|
+
onLost?: string;
|
|
870
|
+
/** Per-call variables carried on the channel. */
|
|
871
|
+
vars?: Record<string, string>;
|
|
872
|
+
/**
|
|
873
|
+
* The RFC 4028 session timer to run on the call; left out, the one the server
|
|
874
|
+
* has configured runs, if any.
|
|
875
|
+
*/
|
|
876
|
+
sessionTimer?: SessionTimer;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* What the server answers an accepted `originate` with: the call is `calling`,
|
|
880
|
+
* not answered — the answer arrives later as an event on the channel.
|
|
881
|
+
*/
|
|
882
|
+
interface Originated {
|
|
883
|
+
/** The caller-supplied channel id the call is addressed by. */
|
|
884
|
+
channel: string;
|
|
885
|
+
/** siphon's internal call id. */
|
|
886
|
+
callId?: string;
|
|
887
|
+
/** The SIP Call-ID on the wire, for joining CDR / HEP. */
|
|
888
|
+
sipCallId?: string;
|
|
889
|
+
}
|
|
890
|
+
declare function originateArgs(channel: string, to: string, media: OriginateMedia, options?: OriginateOptions): Record<string, unknown>;
|
|
795
891
|
type PlaySource = {
|
|
796
892
|
file: string;
|
|
797
893
|
} | {
|
|
@@ -931,7 +1027,9 @@ declare class Call {
|
|
|
931
1027
|
*
|
|
932
1028
|
* `targets` is a non-empty list of carriers tried cheapest-first: each entry
|
|
933
1029
|
* is a bare URI string or a {@link RouteTargetObject}
|
|
934
|
-
* (`{uri, nextHop?, headers?, timeout?}`).
|
|
1030
|
+
* (`{uri, nextHop?, headers?, timeout?, rerouteAfterProgress?}`). A target
|
|
1031
|
+
* that has shown progress keeps the call past its `timeout` unless it sets
|
|
1032
|
+
* `rerouteAfterProgress`. `strategy` defaults to
|
|
935
1033
|
* `"sequential"` (v1 supports only sequential/single — anything else rejects
|
|
936
1034
|
* with `code === "unsupported_verb"`). `headers` is applied to every
|
|
937
1035
|
* attempt's B-leg INVITE.
|
|
@@ -1141,6 +1239,24 @@ declare class SipClient {
|
|
|
1141
1239
|
run(): Promise<void>;
|
|
1142
1240
|
/** Fetch the registered adapters' schema (`describe`). */
|
|
1143
1241
|
describe(): Promise<unknown>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Place an outbound call under a caller-supplied channel id.
|
|
1244
|
+
*
|
|
1245
|
+
* The one verb that *creates* a channel rather than addressing one, which is
|
|
1246
|
+
* why it lives here and not on {@link Call}. It resolves as soon as the
|
|
1247
|
+
* INVITE is on the wire — the call is `calling`, and the answer, failure or
|
|
1248
|
+
* timeout arrives later as an event on the channel.
|
|
1249
|
+
*
|
|
1250
|
+
* ```ts
|
|
1251
|
+
* const call = await client.originate(
|
|
1252
|
+
* "wake-up-42",
|
|
1253
|
+
* "sip:1001@pbx.example",
|
|
1254
|
+
* { anchor: true },
|
|
1255
|
+
* { from: "sip:alarm@pbx.example", timeout: 20 },
|
|
1256
|
+
* );
|
|
1257
|
+
* ```
|
|
1258
|
+
*/
|
|
1259
|
+
originate(channel: string, to: string, media: OriginateMedia, options?: OriginateOptions): Promise<Originated>;
|
|
1144
1260
|
/** Send a raw command on any module (the generic escape hatch). */
|
|
1145
1261
|
command(module: string | null, verb: string, target: unknown, args: unknown): Promise<unknown>;
|
|
1146
1262
|
/** Stop the client. */
|
|
@@ -1167,4 +1283,4 @@ declare class SipServer {
|
|
|
1167
1283
|
close(): Promise<void>;
|
|
1168
1284
|
}
|
|
1169
1285
|
|
|
1170
|
-
export { type AcceptReferOptions, type AnchoredAnswerOptions, type BridgeFailedPayload, type BridgeOptions, type BridgeRole, type BridgeStage, Call, type CallEvent, type CallHandler, CallStream, type ChannelBridgedPayload, type ChannelDtmfPayload, type ChannelSnapshot, type ChannelUnbridgedPayload, type ClientConfig, type ClientEvent, type CommandTransport, type ConnectionEventSink, ControlClient, ControlError, type ControlErrorCode, type ControlErrorKind, ControlServer, DESCRIBE, type DtmfOptions, type EventFrame, type EventSink, EventStream, type FrameType, GET_VAR, HELLO, type HelloArgs, type HelloResult, MODULE_SIP, MODULE_SMPP, MODULE_SS7, PROTOCOL_VERSION, type PeerHangupPolicy, type PlayFinishedPayload, type PlayOptions, type PlaySource, type PlayStartedPayload, RESYNC, type ReferReplaces, type ReplyError, type ReplyFrame, type ReplyStatus, type ResponseOptions, type ResyncResult, type RouteTarget, type RouteTargetObject, SET_VAR, SUBPROTOCOL, type ServerConfig, SipClient, type SipEventKind, SipServer, SipVerb, type SipVerbToken, type StreamOptions, type TransferOutcomePayload, type TransferReplaces, type TransferRequestedPayload, type TransferStage, type WsBridgeEndedPayload, type WsBridgeStartedPayload, type WsTeeEndedPayload, type WsTeeStartedPayload, encodeCommand, isBridgeFinal, isTransferFinal, parseInboundFrame, sipEventKind, transferOutcome };
|
|
1286
|
+
export { type AcceptReferOptions, type AnchoredAnswerOptions, type BridgeFailedPayload, type BridgeOptions, type BridgeRole, type BridgeStage, Call, type CallEvent, type CallHandler, CallStream, type ChannelBridgedPayload, type ChannelDtmfPayload, type ChannelSnapshot, type ChannelUnbridgedPayload, type ClientConfig, type ClientEvent, type CommandTransport, type ConnectionEventSink, ControlClient, ControlError, type ControlErrorCode, type ControlErrorKind, ControlServer, DESCRIBE, type DtmfOptions, type EventFrame, type EventSink, EventStream, type FrameType, GET_VAR, HELLO, type HelloArgs, type HelloResult, MODULE_SIP, MODULE_SMPP, MODULE_SS7, type OriginateMedia, type OriginateOptions, type Originated, PROTOCOL_VERSION, type PeerHangupPolicy, type PlayFinishedPayload, type PlayOptions, type PlaySource, type PlayStartedPayload, RESYNC, type ReferReplaces, type ReplyError, type ReplyFrame, type ReplyStatus, type ResponseOptions, type ResyncResult, type RouteTarget, type RouteTargetObject, SET_VAR, SUBPROTOCOL, type ServerConfig, type SessionRefresher, type SessionTimer, SipClient, type SipEventKind, SipServer, SipVerb, type SipVerbToken, type StreamOptions, type TransferOutcomePayload, type TransferReplaces, type TransferRequestedPayload, type TransferStage, type WsBridgeEndedPayload, type WsBridgeStartedPayload, type WsTeeEndedPayload, type WsTeeStartedPayload, encodeCommand, isBridgeFinal, isTransferFinal, originateArgs, parseInboundFrame, sipEventKind, transferOutcome };
|
package/dist/index.d.ts
CHANGED
|
@@ -779,8 +779,19 @@ interface RouteTargetObject {
|
|
|
779
779
|
nextHop?: string;
|
|
780
780
|
/** Headers injected on this attempt's B-leg INVITE. */
|
|
781
781
|
headers?: Record<string, string>;
|
|
782
|
-
/**
|
|
782
|
+
/**
|
|
783
|
+
* Per-target ring timeout in seconds. It bounds the wait for this carrier to
|
|
784
|
+
* show progress (a 101-199), not the wait for its answer.
|
|
785
|
+
*/
|
|
783
786
|
timeout?: number;
|
|
787
|
+
/**
|
|
788
|
+
* Fail this carrier over at its ring timeout even after it has shown
|
|
789
|
+
* progress. By default a carrier that has sent a 180/183 keeps the call past
|
|
790
|
+
* `timeout`, and the call then fails with 408 rather than trying the next
|
|
791
|
+
* target; `true` is for a carrier that plays its own ringback before it has
|
|
792
|
+
* reached anyone. Default `false`, which is never sent.
|
|
793
|
+
*/
|
|
794
|
+
rerouteAfterProgress?: boolean;
|
|
784
795
|
}
|
|
785
796
|
/**
|
|
786
797
|
* One entry in a {@link Call.route} target list: a bare URI string, or a
|
|
@@ -792,6 +803,91 @@ type RouteTarget = string | RouteTargetObject;
|
|
|
792
803
|
* path, an rtpengine media-DB id, or an inline blob. A blob is base64-encoded on
|
|
793
804
|
* the wire (the control rail is JSON text).
|
|
794
805
|
*/
|
|
806
|
+
/**
|
|
807
|
+
* The media plan for {@link SipClient.originate} — what the outbound INVITE
|
|
808
|
+
* offers.
|
|
809
|
+
*
|
|
810
|
+
* Required, and a union, because the server requires exactly one plan and
|
|
811
|
+
* rejects every combination of the raw `sdp` / `body` / `media` arguments that
|
|
812
|
+
* names none or more than one. Expressed this way those errors cannot be
|
|
813
|
+
* written down.
|
|
814
|
+
*/
|
|
815
|
+
type OriginateMedia =
|
|
816
|
+
/** Offerless INVITE: siphon anchors the leg on the media engine. */
|
|
817
|
+
{
|
|
818
|
+
anchor: true;
|
|
819
|
+
profile?: string;
|
|
820
|
+
wsUri?: string;
|
|
821
|
+
}
|
|
822
|
+
/** Your own SDP offer (`application/sdp` by definition). */
|
|
823
|
+
| {
|
|
824
|
+
sdp: string;
|
|
825
|
+
}
|
|
826
|
+
/** Your own body with its own content type. */
|
|
827
|
+
| {
|
|
828
|
+
body: string;
|
|
829
|
+
contentType: string;
|
|
830
|
+
};
|
|
831
|
+
/**
|
|
832
|
+
* Who refreshes each dialog of an originated call where the RFC 4028 negotiation
|
|
833
|
+
* leaves siphon the choice (§7.1): the UAC of each dialog, the UAS of each, or
|
|
834
|
+
* siphon on both.
|
|
835
|
+
*/
|
|
836
|
+
type SessionRefresher = "uac" | "uas" | "b2bua";
|
|
837
|
+
/**
|
|
838
|
+
* The RFC 4028 session timer siphon runs on an originated call, over its
|
|
839
|
+
* `session_timer:` block. A field left out takes the server's default, as in the
|
|
840
|
+
* script API's `call.session_timer()`: 1800 s, a `Min-SE` of 90 s, and `b2bua`.
|
|
841
|
+
*/
|
|
842
|
+
interface SessionTimer {
|
|
843
|
+
/** The session interval, in seconds. */
|
|
844
|
+
expires?: number;
|
|
845
|
+
/** The smallest session interval siphon accepts, in seconds. */
|
|
846
|
+
minSe?: number;
|
|
847
|
+
/** Who refreshes where the negotiation leaves siphon the choice. */
|
|
848
|
+
refresher?: SessionRefresher;
|
|
849
|
+
}
|
|
850
|
+
/** Optional shaping for {@link SipClient.originate}. */
|
|
851
|
+
interface OriginateOptions {
|
|
852
|
+
/** From-URI to place the call as. */
|
|
853
|
+
from?: string;
|
|
854
|
+
/** From display name. */
|
|
855
|
+
fromDisplay?: string;
|
|
856
|
+
/** To display name. */
|
|
857
|
+
toDisplay?: string;
|
|
858
|
+
/** Route the INVITE here while keeping `to` as the R-URI. */
|
|
859
|
+
nextHop?: string;
|
|
860
|
+
/** P-Asserted-Identity to assert (RFC 3325). */
|
|
861
|
+
pAssertedIdentity?: string;
|
|
862
|
+
/** Caller-identity presentation (RFC 3323 §4.1). */
|
|
863
|
+
privacy?: "allowed" | "restricted";
|
|
864
|
+
/** Extra headers on the outbound INVITE. */
|
|
865
|
+
headers?: Record<string, string>;
|
|
866
|
+
/** Ring timeout in seconds. */
|
|
867
|
+
timeout?: number;
|
|
868
|
+
/** Control-loss policy for the created channel. */
|
|
869
|
+
onLost?: string;
|
|
870
|
+
/** Per-call variables carried on the channel. */
|
|
871
|
+
vars?: Record<string, string>;
|
|
872
|
+
/**
|
|
873
|
+
* The RFC 4028 session timer to run on the call; left out, the one the server
|
|
874
|
+
* has configured runs, if any.
|
|
875
|
+
*/
|
|
876
|
+
sessionTimer?: SessionTimer;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* What the server answers an accepted `originate` with: the call is `calling`,
|
|
880
|
+
* not answered — the answer arrives later as an event on the channel.
|
|
881
|
+
*/
|
|
882
|
+
interface Originated {
|
|
883
|
+
/** The caller-supplied channel id the call is addressed by. */
|
|
884
|
+
channel: string;
|
|
885
|
+
/** siphon's internal call id. */
|
|
886
|
+
callId?: string;
|
|
887
|
+
/** The SIP Call-ID on the wire, for joining CDR / HEP. */
|
|
888
|
+
sipCallId?: string;
|
|
889
|
+
}
|
|
890
|
+
declare function originateArgs(channel: string, to: string, media: OriginateMedia, options?: OriginateOptions): Record<string, unknown>;
|
|
795
891
|
type PlaySource = {
|
|
796
892
|
file: string;
|
|
797
893
|
} | {
|
|
@@ -931,7 +1027,9 @@ declare class Call {
|
|
|
931
1027
|
*
|
|
932
1028
|
* `targets` is a non-empty list of carriers tried cheapest-first: each entry
|
|
933
1029
|
* is a bare URI string or a {@link RouteTargetObject}
|
|
934
|
-
* (`{uri, nextHop?, headers?, timeout?}`).
|
|
1030
|
+
* (`{uri, nextHop?, headers?, timeout?, rerouteAfterProgress?}`). A target
|
|
1031
|
+
* that has shown progress keeps the call past its `timeout` unless it sets
|
|
1032
|
+
* `rerouteAfterProgress`. `strategy` defaults to
|
|
935
1033
|
* `"sequential"` (v1 supports only sequential/single — anything else rejects
|
|
936
1034
|
* with `code === "unsupported_verb"`). `headers` is applied to every
|
|
937
1035
|
* attempt's B-leg INVITE.
|
|
@@ -1141,6 +1239,24 @@ declare class SipClient {
|
|
|
1141
1239
|
run(): Promise<void>;
|
|
1142
1240
|
/** Fetch the registered adapters' schema (`describe`). */
|
|
1143
1241
|
describe(): Promise<unknown>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Place an outbound call under a caller-supplied channel id.
|
|
1244
|
+
*
|
|
1245
|
+
* The one verb that *creates* a channel rather than addressing one, which is
|
|
1246
|
+
* why it lives here and not on {@link Call}. It resolves as soon as the
|
|
1247
|
+
* INVITE is on the wire — the call is `calling`, and the answer, failure or
|
|
1248
|
+
* timeout arrives later as an event on the channel.
|
|
1249
|
+
*
|
|
1250
|
+
* ```ts
|
|
1251
|
+
* const call = await client.originate(
|
|
1252
|
+
* "wake-up-42",
|
|
1253
|
+
* "sip:1001@pbx.example",
|
|
1254
|
+
* { anchor: true },
|
|
1255
|
+
* { from: "sip:alarm@pbx.example", timeout: 20 },
|
|
1256
|
+
* );
|
|
1257
|
+
* ```
|
|
1258
|
+
*/
|
|
1259
|
+
originate(channel: string, to: string, media: OriginateMedia, options?: OriginateOptions): Promise<Originated>;
|
|
1144
1260
|
/** Send a raw command on any module (the generic escape hatch). */
|
|
1145
1261
|
command(module: string | null, verb: string, target: unknown, args: unknown): Promise<unknown>;
|
|
1146
1262
|
/** Stop the client. */
|
|
@@ -1167,4 +1283,4 @@ declare class SipServer {
|
|
|
1167
1283
|
close(): Promise<void>;
|
|
1168
1284
|
}
|
|
1169
1285
|
|
|
1170
|
-
export { type AcceptReferOptions, type AnchoredAnswerOptions, type BridgeFailedPayload, type BridgeOptions, type BridgeRole, type BridgeStage, Call, type CallEvent, type CallHandler, CallStream, type ChannelBridgedPayload, type ChannelDtmfPayload, type ChannelSnapshot, type ChannelUnbridgedPayload, type ClientConfig, type ClientEvent, type CommandTransport, type ConnectionEventSink, ControlClient, ControlError, type ControlErrorCode, type ControlErrorKind, ControlServer, DESCRIBE, type DtmfOptions, type EventFrame, type EventSink, EventStream, type FrameType, GET_VAR, HELLO, type HelloArgs, type HelloResult, MODULE_SIP, MODULE_SMPP, MODULE_SS7, PROTOCOL_VERSION, type PeerHangupPolicy, type PlayFinishedPayload, type PlayOptions, type PlaySource, type PlayStartedPayload, RESYNC, type ReferReplaces, type ReplyError, type ReplyFrame, type ReplyStatus, type ResponseOptions, type ResyncResult, type RouteTarget, type RouteTargetObject, SET_VAR, SUBPROTOCOL, type ServerConfig, SipClient, type SipEventKind, SipServer, SipVerb, type SipVerbToken, type StreamOptions, type TransferOutcomePayload, type TransferReplaces, type TransferRequestedPayload, type TransferStage, type WsBridgeEndedPayload, type WsBridgeStartedPayload, type WsTeeEndedPayload, type WsTeeStartedPayload, encodeCommand, isBridgeFinal, isTransferFinal, parseInboundFrame, sipEventKind, transferOutcome };
|
|
1286
|
+
export { type AcceptReferOptions, type AnchoredAnswerOptions, type BridgeFailedPayload, type BridgeOptions, type BridgeRole, type BridgeStage, Call, type CallEvent, type CallHandler, CallStream, type ChannelBridgedPayload, type ChannelDtmfPayload, type ChannelSnapshot, type ChannelUnbridgedPayload, type ClientConfig, type ClientEvent, type CommandTransport, type ConnectionEventSink, ControlClient, ControlError, type ControlErrorCode, type ControlErrorKind, ControlServer, DESCRIBE, type DtmfOptions, type EventFrame, type EventSink, EventStream, type FrameType, GET_VAR, HELLO, type HelloArgs, type HelloResult, MODULE_SIP, MODULE_SMPP, MODULE_SS7, type OriginateMedia, type OriginateOptions, type Originated, PROTOCOL_VERSION, type PeerHangupPolicy, type PlayFinishedPayload, type PlayOptions, type PlaySource, type PlayStartedPayload, RESYNC, type ReferReplaces, type ReplyError, type ReplyFrame, type ReplyStatus, type ResponseOptions, type ResyncResult, type RouteTarget, type RouteTargetObject, SET_VAR, SUBPROTOCOL, type ServerConfig, type SessionRefresher, type SessionTimer, SipClient, type SipEventKind, SipServer, SipVerb, type SipVerbToken, type StreamOptions, type TransferOutcomePayload, type TransferReplaces, type TransferRequestedPayload, type TransferStage, type WsBridgeEndedPayload, type WsBridgeStartedPayload, type WsTeeEndedPayload, type WsTeeStartedPayload, encodeCommand, isBridgeFinal, isTransferFinal, originateArgs, parseInboundFrame, sipEventKind, transferOutcome };
|
package/dist/index.js
CHANGED
|
@@ -625,6 +625,9 @@ function routeTargetToWire(target) {
|
|
|
625
625
|
if (target.timeout !== void 0) {
|
|
626
626
|
object.timeout = target.timeout;
|
|
627
627
|
}
|
|
628
|
+
if (target.rerouteAfterProgress === true) {
|
|
629
|
+
object.reroute_after_progress = true;
|
|
630
|
+
}
|
|
628
631
|
return object;
|
|
629
632
|
}
|
|
630
633
|
function stringValue(result) {
|
|
@@ -636,6 +639,41 @@ function stringValue(result) {
|
|
|
636
639
|
}
|
|
637
640
|
return null;
|
|
638
641
|
}
|
|
642
|
+
function originateArgs(channel, to, media, options) {
|
|
643
|
+
const args = { channel, to };
|
|
644
|
+
if ("anchor" in media) {
|
|
645
|
+
args.media = true;
|
|
646
|
+
if (media.profile !== void 0) args.profile = media.profile;
|
|
647
|
+
if (media.wsUri !== void 0) args.ws_uri = media.wsUri;
|
|
648
|
+
} else if ("sdp" in media) {
|
|
649
|
+
args.sdp = media.sdp;
|
|
650
|
+
} else {
|
|
651
|
+
args.body = media.body;
|
|
652
|
+
args.content_type = media.contentType;
|
|
653
|
+
}
|
|
654
|
+
if (!options) return args;
|
|
655
|
+
if (options.from !== void 0) args.from = options.from;
|
|
656
|
+
if (options.fromDisplay !== void 0) args.from_display = options.fromDisplay;
|
|
657
|
+
if (options.toDisplay !== void 0) args.to_display = options.toDisplay;
|
|
658
|
+
if (options.nextHop !== void 0) args.next_hop = options.nextHop;
|
|
659
|
+
if (options.pAssertedIdentity !== void 0) {
|
|
660
|
+
args.p_asserted_identity = options.pAssertedIdentity;
|
|
661
|
+
}
|
|
662
|
+
if (options.privacy !== void 0) args.privacy = options.privacy;
|
|
663
|
+
if (options.headers !== void 0) args.headers = options.headers;
|
|
664
|
+
if (options.timeout !== void 0) args.timeout = options.timeout;
|
|
665
|
+
if (options.onLost !== void 0) args.on_lost = options.onLost;
|
|
666
|
+
if (options.vars !== void 0) args.vars = options.vars;
|
|
667
|
+
if (options.sessionTimer !== void 0) {
|
|
668
|
+
const timer = {};
|
|
669
|
+
const { expires, minSe, refresher } = options.sessionTimer;
|
|
670
|
+
if (expires !== void 0) timer.expires = expires;
|
|
671
|
+
if (minSe !== void 0) timer.min_se = minSe;
|
|
672
|
+
if (refresher !== void 0) timer.refresher = refresher;
|
|
673
|
+
args.session_timer = timer;
|
|
674
|
+
}
|
|
675
|
+
return args;
|
|
676
|
+
}
|
|
639
677
|
function playArgs(source, options) {
|
|
640
678
|
const args = {};
|
|
641
679
|
if ("file" in source) {
|
|
@@ -817,7 +855,9 @@ var Call = class {
|
|
|
817
855
|
*
|
|
818
856
|
* `targets` is a non-empty list of carriers tried cheapest-first: each entry
|
|
819
857
|
* is a bare URI string or a {@link RouteTargetObject}
|
|
820
|
-
* (`{uri, nextHop?, headers?, timeout?}`).
|
|
858
|
+
* (`{uri, nextHop?, headers?, timeout?, rerouteAfterProgress?}`). A target
|
|
859
|
+
* that has shown progress keeps the call past its `timeout` unless it sets
|
|
860
|
+
* `rerouteAfterProgress`. `strategy` defaults to
|
|
821
861
|
* `"sequential"` (v1 supports only sequential/single — anything else rejects
|
|
822
862
|
* with `code === "unsupported_verb"`). `headers` is applied to every
|
|
823
863
|
* attempt's B-leg INVITE.
|
|
@@ -1198,6 +1238,42 @@ var SipClient = class _SipClient {
|
|
|
1198
1238
|
describe() {
|
|
1199
1239
|
return this.client.describe();
|
|
1200
1240
|
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Place an outbound call under a caller-supplied channel id.
|
|
1243
|
+
*
|
|
1244
|
+
* The one verb that *creates* a channel rather than addressing one, which is
|
|
1245
|
+
* why it lives here and not on {@link Call}. It resolves as soon as the
|
|
1246
|
+
* INVITE is on the wire — the call is `calling`, and the answer, failure or
|
|
1247
|
+
* timeout arrives later as an event on the channel.
|
|
1248
|
+
*
|
|
1249
|
+
* ```ts
|
|
1250
|
+
* const call = await client.originate(
|
|
1251
|
+
* "wake-up-42",
|
|
1252
|
+
* "sip:1001@pbx.example",
|
|
1253
|
+
* { anchor: true },
|
|
1254
|
+
* { from: "sip:alarm@pbx.example", timeout: 20 },
|
|
1255
|
+
* );
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
async originate(channel, to, media, options) {
|
|
1259
|
+
const result = await this.client.command(
|
|
1260
|
+
MODULE_SIP,
|
|
1261
|
+
"originate",
|
|
1262
|
+
null,
|
|
1263
|
+
originateArgs(channel, to, media, options)
|
|
1264
|
+
);
|
|
1265
|
+
const text = (name) => {
|
|
1266
|
+
const value = result?.[name];
|
|
1267
|
+
return typeof value === "string" ? value : void 0;
|
|
1268
|
+
};
|
|
1269
|
+
return {
|
|
1270
|
+
// The server echoes the id back; fall back to the one we asked for
|
|
1271
|
+
// rather than returning an empty channel a caller cannot address.
|
|
1272
|
+
channel: text("channel") ?? channel,
|
|
1273
|
+
callId: text("call_id"),
|
|
1274
|
+
sipCallId: text("sip_call_id")
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1201
1277
|
/** Send a raw command on any module (the generic escape hatch). */
|
|
1202
1278
|
command(module, verb, target, args) {
|
|
1203
1279
|
return this.client.command(module, verb, target, args);
|
|
@@ -1246,6 +1322,6 @@ var SipServer = class _SipServer {
|
|
|
1246
1322
|
}
|
|
1247
1323
|
};
|
|
1248
1324
|
|
|
1249
|
-
export { Call, CallStream, ControlClient, ControlError, ControlServer, DESCRIBE, EventStream, GET_VAR, HELLO, MODULE_SIP, MODULE_SMPP, MODULE_SS7, PROTOCOL_VERSION, RESYNC, SET_VAR, SUBPROTOCOL, SipClient, SipServer, SipVerb, encodeCommand, isBridgeFinal, isTransferFinal, parseInboundFrame, sipEventKind, transferOutcome };
|
|
1325
|
+
export { Call, CallStream, ControlClient, ControlError, ControlServer, DESCRIBE, EventStream, GET_VAR, HELLO, MODULE_SIP, MODULE_SMPP, MODULE_SS7, PROTOCOL_VERSION, RESYNC, SET_VAR, SUBPROTOCOL, SipClient, SipServer, SipVerb, encodeCommand, isBridgeFinal, isTransferFinal, originateArgs, parseInboundFrame, sipEventKind, transferOutcome };
|
|
1250
1326
|
//# sourceMappingURL=index.js.map
|
|
1251
1327
|
//# sourceMappingURL=index.js.map
|