ue-softphone-sdk 2.1.9 → 2.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.
- package/dist/{index.d.ts → types/index.d.ts} +3 -7
- package/dist/ue-softphone-sdk.js +1 -2
- package/package.json +6 -6
- package/{new-rollup.config.mjs → rollup-new.config.mjs} +1 -1
- package/rollup.config.js +14 -15
- package/src/index.ts +22 -49
- package/tsconfig.json +10 -26
- package/dist/api/bye.d.ts +0 -16
- package/dist/api/dtmf.d.ts +0 -15
- package/dist/api/emitter.d.ts +0 -88
- package/dist/api/exceptions/content-type-unsupported.d.ts +0 -8
- package/dist/api/exceptions/index.d.ts +0 -5
- package/dist/api/exceptions/request-pending.d.ts +0 -9
- package/dist/api/exceptions/session-description-handler.d.ts +0 -8
- package/dist/api/exceptions/session-terminated.d.ts +0 -8
- package/dist/api/exceptions/state-transition.d.ts +0 -8
- package/dist/api/index.d.ts +0 -58
- package/dist/api/info.d.ts +0 -16
- package/dist/api/invitation-accept-options.d.ts +0 -19
- package/dist/api/invitation-progress-options.d.ts +0 -38
- package/dist/api/invitation-reject-options.d.ts +0 -25
- package/dist/api/invitation.d.ts +0 -179
- package/dist/api/inviter-cancel-options.d.ts +0 -9
- package/dist/api/inviter-invite-options.d.ts +0 -28
- package/dist/api/inviter-options.d.ts +0 -43
- package/dist/api/inviter.d.ts +0 -236
- package/dist/api/message.d.ts +0 -16
- package/dist/api/messager-message-options.d.ts +0 -11
- package/dist/api/messager-options.d.ts +0 -17
- package/dist/api/messager.d.ts +0 -26
- package/dist/api/notification.d.ts +0 -16
- package/dist/api/notifier.d.ts +0 -8
- package/dist/api/publisher-options.d.ts +0 -33
- package/dist/api/publisher-publish-options.d.ts +0 -6
- package/dist/api/publisher-state.d.ts +0 -21
- package/dist/api/publisher-unpublish-options.d.ts +0 -6
- package/dist/api/publisher.d.ts +0 -65
- package/dist/api/referral.d.ts +0 -38
- package/dist/api/registerer-options.d.ts +0 -46
- package/dist/api/registerer-register-options.d.ts +0 -11
- package/dist/api/registerer-state.d.ts +0 -21
- package/dist/api/registerer-unregister-options.d.ts +0 -16
- package/dist/api/registerer.d.ts +0 -144
- package/dist/api/session-bye-options.d.ts +0 -11
- package/dist/api/session-delegate.d.ts +0 -73
- package/dist/api/session-description-handler-factory.d.ts +0 -15
- package/dist/api/session-description-handler.d.ts +0 -74
- package/dist/api/session-info-options.d.ts +0 -11
- package/dist/api/session-invite-options.d.ts +0 -28
- package/dist/api/session-message-options.d.ts +0 -11
- package/dist/api/session-options.d.ts +0 -8
- package/dist/api/session-refer-options.d.ts +0 -14
- package/dist/api/session-state.d.ts +0 -45
- package/dist/api/session.d.ts +0 -359
- package/dist/api/subscriber-options.d.ts +0 -11
- package/dist/api/subscriber-subscribe-options.d.ts +0 -6
- package/dist/api/subscriber.d.ts +0 -94
- package/dist/api/subscription-delegate.d.ts +0 -12
- package/dist/api/subscription-options.d.ts +0 -8
- package/dist/api/subscription-state.d.ts +0 -19
- package/dist/api/subscription-subscribe-options.d.ts +0 -6
- package/dist/api/subscription-unsubscribe-options.d.ts +0 -6
- package/dist/api/subscription.d.ts +0 -84
- package/dist/api/transport-state.d.ts +0 -37
- package/dist/api/transport.d.ts +0 -159
- package/dist/api/user-agent-delegate.d.ts +0 -84
- package/dist/api/user-agent-options.d.ts +0 -253
- package/dist/api/user-agent-state.d.ts +0 -14
- package/dist/api/user-agent.d.ts +0 -200
- package/dist/core/dialogs/dialog-state.d.ts +0 -34
- package/dist/core/dialogs/dialog.d.ts +0 -161
- package/dist/core/dialogs/index.d.ts +0 -4
- package/dist/core/dialogs/session-dialog.d.ts +0 -196
- package/dist/core/dialogs/subscription-dialog.d.ts +0 -120
- package/dist/core/exceptions/exception.d.ts +0 -8
- package/dist/core/exceptions/index.d.ts +0 -3
- package/dist/core/exceptions/transaction-state-error.d.ts +0 -8
- package/dist/core/exceptions/transport-error.d.ts +0 -8
- package/dist/core/index.d.ts +0 -15
- package/dist/core/log/index.d.ts +0 -3
- package/dist/core/log/levels.d.ts +0 -10
- package/dist/core/log/logger-factory.d.ts +0 -21
- package/dist/core/log/logger.d.ts +0 -19
- package/dist/core/messages/body.d.ts +0 -64
- package/dist/core/messages/digest-authentication.d.ts +0 -51
- package/dist/core/messages/incoming-message.d.ts +0 -79
- package/dist/core/messages/incoming-request-message.d.ts +0 -10
- package/dist/core/messages/incoming-request.d.ts +0 -67
- package/dist/core/messages/incoming-response-message.d.ts +0 -10
- package/dist/core/messages/incoming-response.d.ts +0 -12
- package/dist/core/messages/index.d.ts +0 -13
- package/dist/core/messages/md5.d.ts +0 -32
- package/dist/core/messages/methods/ack.d.ts +0 -18
- package/dist/core/messages/methods/bye.d.ts +0 -21
- package/dist/core/messages/methods/cancel.d.ts +0 -21
- package/dist/core/messages/methods/constants.d.ts +0 -20
- package/dist/core/messages/methods/index.d.ts +0 -13
- package/dist/core/messages/methods/info.d.ts +0 -21
- package/dist/core/messages/methods/invite.d.ts +0 -86
- package/dist/core/messages/methods/message.d.ts +0 -21
- package/dist/core/messages/methods/notify.d.ts +0 -21
- package/dist/core/messages/methods/prack.d.ts +0 -21
- package/dist/core/messages/methods/publish.d.ts +0 -21
- package/dist/core/messages/methods/refer.d.ts +0 -21
- package/dist/core/messages/methods/register.d.ts +0 -21
- package/dist/core/messages/methods/subscribe.d.ts +0 -54
- package/dist/core/messages/outgoing-request-message.d.ts +0 -94
- package/dist/core/messages/outgoing-request.d.ts +0 -67
- package/dist/core/messages/outgoing-response.d.ts +0 -42
- package/dist/core/messages/parser.d.ts +0 -14
- package/dist/core/messages/utils.d.ts +0 -24
- package/dist/core/session/index.d.ts +0 -2
- package/dist/core/session/session-delegate.d.ts +0 -70
- package/dist/core/session/session.d.ts +0 -134
- package/dist/core/subscription/index.d.ts +0 -2
- package/dist/core/subscription/subscription-delegate.d.ts +0 -27
- package/dist/core/subscription/subscription.d.ts +0 -55
- package/dist/core/timers.d.ts +0 -20
- package/dist/core/transactions/client-transaction.d.ts +0 -45
- package/dist/core/transactions/index.d.ts +0 -10
- package/dist/core/transactions/invite-client-transaction.d.ts +0 -116
- package/dist/core/transactions/invite-server-transaction.d.ts +0 -127
- package/dist/core/transactions/non-invite-client-transaction.d.ts +0 -69
- package/dist/core/transactions/non-invite-server-transaction.d.ts +0 -57
- package/dist/core/transactions/server-transaction.d.ts +0 -35
- package/dist/core/transactions/transaction-state.d.ts +0 -13
- package/dist/core/transactions/transaction-user.d.ts +0 -72
- package/dist/core/transactions/transaction.d.ts +0 -79
- package/dist/core/transport.d.ts +0 -31
- package/dist/core/user-agent-core/allowed-methods.d.ts +0 -4
- package/dist/core/user-agent-core/index.d.ts +0 -3
- package/dist/core/user-agent-core/user-agent-core-configuration.d.ts +0 -99
- package/dist/core/user-agent-core/user-agent-core-delegate.d.ts +0 -37
- package/dist/core/user-agent-core/user-agent-core.d.ts +0 -179
- package/dist/core/user-agents/bye-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/bye-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/cancel-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/index.d.ts +0 -26
- package/dist/core/user-agents/info-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/info-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/invite-user-agent-client.d.ts +0 -35
- package/dist/core/user-agents/invite-user-agent-server.d.ts +0 -77
- package/dist/core/user-agents/message-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/message-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/notify-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/notify-user-agent-server.d.ts +0 -16
- package/dist/core/user-agents/prack-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/prack-user-agent-server.d.ts +0 -16
- package/dist/core/user-agents/publish-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/re-invite-user-agent-client.d.ts +0 -18
- package/dist/core/user-agents/re-invite-user-agent-server.d.ts +0 -41
- package/dist/core/user-agents/re-subscribe-user-agent-client.d.ts +0 -17
- package/dist/core/user-agents/re-subscribe-user-agent-server.d.ts +0 -10
- package/dist/core/user-agents/refer-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/refer-user-agent-server.d.ts +0 -16
- package/dist/core/user-agents/register-user-agent-client.d.ts +0 -10
- package/dist/core/user-agents/register-user-agent-server.d.ts +0 -11
- package/dist/core/user-agents/subscribe-user-agent-client.d.ts +0 -65
- package/dist/core/user-agents/subscribe-user-agent-server.d.ts +0 -11
- package/dist/core/user-agents/user-agent-client.d.ts +0 -103
- package/dist/core/user-agents/user-agent-server.d.ts +0 -79
- package/dist/grammar/grammar.d.ts +0 -26
- package/dist/grammar/index.d.ts +0 -4
- package/dist/grammar/name-addr-header.d.ts +0 -24
- package/dist/grammar/parameters.d.ts +0 -16
- package/dist/grammar/pegjs/dist/grammar.d.ts +0 -50
- package/dist/grammar/uri.d.ts +0 -62
- package/dist/main.d.ts +0 -9
- package/dist/new-index.d.ts +0 -199
- package/dist/platform/web/index.d.ts +0 -4
- package/dist/platform/web/modifiers/index.d.ts +0 -5
- package/dist/platform/web/modifiers/modifiers.d.ts +0 -41
- package/dist/platform/web/session-description-handler/index.d.ts +0 -14
- package/dist/platform/web/session-description-handler/media-stream-factory-default.d.ts +0 -6
- package/dist/platform/web/session-description-handler/media-stream-factory.d.ts +0 -6
- package/dist/platform/web/session-description-handler/peer-connection-configuration-default.d.ts +0 -5
- package/dist/platform/web/session-description-handler/peer-connection-delegate.d.ts +0 -63
- package/dist/platform/web/session-description-handler/session-description-handler-configuration.d.ts +0 -16
- package/dist/platform/web/session-description-handler/session-description-handler-factory-default.d.ts +0 -11
- package/dist/platform/web/session-description-handler/session-description-handler-factory-options.d.ts +0 -9
- package/dist/platform/web/session-description-handler/session-description-handler-factory.d.ts +0 -16
- package/dist/platform/web/session-description-handler/session-description-handler-options.d.ts +0 -47
- package/dist/platform/web/session-description-handler/session-description-handler.d.ts +0 -212
- package/dist/platform/web/simple-user/index.d.ts +0 -7
- package/dist/platform/web/simple-user/simple-user-delegate.d.ts +0 -72
- package/dist/platform/web/simple-user/simple-user-options.d.ts +0 -90
- package/dist/platform/web/simple-user/simple-user.d.ts +0 -226
- package/dist/platform/web/transport/index.d.ts +0 -6
- package/dist/platform/web/transport/transport-options.d.ts +0 -30
- package/dist/platform/web/transport/transport.d.ts +0 -125
- package/dist/ue-softphone-sdk.js.map +0 -1
- package/dist/version.d.ts +0 -1
- package/dist/webPhoneSdk.d.ts +0 -24
- package/dist/webrtc.d.ts +0 -17
- package/src/api/api-extractor.json +0 -358
- package/src/api/bye.ts +0 -27
- package/src/api/dtmf.ts +0 -27
- package/src/api/emitter.ts +0 -110
- package/src/api/exceptions/content-type-unsupported.ts +0 -11
- package/src/api/exceptions/index.ts +0 -5
- package/src/api/exceptions/request-pending.ts +0 -12
- package/src/api/exceptions/session-description-handler.ts +0 -11
- package/src/api/exceptions/session-terminated.ts +0 -11
- package/src/api/exceptions/state-transition.ts +0 -11
- package/src/api/index.ts +0 -58
- package/src/api/info.ts +0 -27
- package/src/api/invitation-accept-options.ts +0 -20
- package/src/api/invitation-progress-options.ts +0 -36
- package/src/api/invitation-reject-options.ts +0 -22
- package/src/api/invitation.ts +0 -816
- package/src/api/inviter-cancel-options.ts +0 -9
- package/src/api/inviter-invite-options.ts +0 -29
- package/src/api/inviter-options.ts +0 -44
- package/src/api/inviter.ts +0 -1126
- package/src/api/message.ts +0 -27
- package/src/api/messager-message-options.ts +0 -12
- package/src/api/messager-options.ts +0 -18
- package/src/api/messager.ts +0 -89
- package/src/api/notification.ts +0 -27
- package/src/api/notifier.ts +0 -7
- package/src/api/publisher-options.ts +0 -34
- package/src/api/publisher-publish-options.ts +0 -6
- package/src/api/publisher-state.ts +0 -21
- package/src/api/publisher-unpublish-options.ts +0 -6
- package/src/api/publisher.ts +0 -418
- package/src/api/referral.ts +0 -89
- package/src/api/registerer-options.ts +0 -55
- package/src/api/registerer-register-options.ts +0 -12
- package/src/api/registerer-state.ts +0 -21
- package/src/api/registerer-unregister-options.ts +0 -17
- package/src/api/registerer.ts +0 -814
- package/src/api/session-bye-options.ts +0 -12
- package/src/api/session-delegate.ts +0 -80
- package/src/api/session-description-handler-factory.ts +0 -16
- package/src/api/session-description-handler.ts +0 -89
- package/src/api/session-info-options.ts +0 -12
- package/src/api/session-invite-options.ts +0 -29
- package/src/api/session-message-options.ts +0 -12
- package/src/api/session-options.ts +0 -8
- package/src/api/session-refer-options.ts +0 -15
- package/src/api/session-state.ts +0 -45
- package/src/api/session.ts +0 -1448
- package/src/api/subscriber-options.ts +0 -12
- package/src/api/subscriber-subscribe-options.ts +0 -6
- package/src/api/subscriber.ts +0 -536
- package/src/api/subscription-delegate.ts +0 -13
- package/src/api/subscription-options.ts +0 -8
- package/src/api/subscription-state.ts +0 -19
- package/src/api/subscription-subscribe-options.ts +0 -6
- package/src/api/subscription-unsubscribe-options.ts +0 -6
- package/src/api/subscription.ts +0 -161
- package/src/api/transport-state.ts +0 -37
- package/src/api/transport.ts +0 -169
- package/src/api/user-agent-delegate.ts +0 -95
- package/src/api/user-agent-options.ts +0 -322
- package/src/api/user-agent-state.ts +0 -14
- package/src/api/user-agent.ts +0 -1014
- package/src/core/api-extractor.json +0 -358
- package/src/core/dialogs/dialog-state.ts +0 -35
- package/src/core/dialogs/dialog.ts +0 -605
- package/src/core/dialogs/index.ts +0 -4
- package/src/core/dialogs/session-dialog.ts +0 -996
- package/src/core/dialogs/subscription-dialog.ts +0 -557
- package/src/core/exceptions/exception.ts +0 -11
- package/src/core/exceptions/index.ts +0 -3
- package/src/core/exceptions/transaction-state-error.ts +0 -11
- package/src/core/exceptions/transport-error.ts +0 -11
- package/src/core/index.ts +0 -19
- package/src/core/log/index.ts +0 -3
- package/src/core/log/levels.ts +0 -10
- package/src/core/log/logger-factory.ts +0 -119
- package/src/core/log/logger.ts +0 -42
- package/src/core/messages/body.ts +0 -171
- package/src/core/messages/digest-authentication.ts +0 -190
- package/src/core/messages/incoming-message.ts +0 -152
- package/src/core/messages/incoming-request-message.ts +0 -14
- package/src/core/messages/incoming-request.ts +0 -75
- package/src/core/messages/incoming-response-message.ts +0 -14
- package/src/core/messages/incoming-response.ts +0 -13
- package/src/core/messages/index.ts +0 -18
- package/src/core/messages/md5.ts +0 -437
- package/src/core/messages/methods/ack.ts +0 -22
- package/src/core/messages/methods/bye.ts +0 -22
- package/src/core/messages/methods/cancel.ts +0 -22
- package/src/core/messages/methods/constants.ts +0 -21
- package/src/core/messages/methods/index.ts +0 -13
- package/src/core/messages/methods/info.ts +0 -22
- package/src/core/messages/methods/invite.ts +0 -104
- package/src/core/messages/methods/message.ts +0 -22
- package/src/core/messages/methods/notify.ts +0 -22
- package/src/core/messages/methods/prack.ts +0 -22
- package/src/core/messages/methods/publish.ts +0 -22
- package/src/core/messages/methods/refer.ts +0 -22
- package/src/core/messages/methods/register.ts +0 -22
- package/src/core/messages/methods/subscribe.ts +0 -59
- package/src/core/messages/outgoing-request-message.ts +0 -299
- package/src/core/messages/outgoing-request.ts +0 -77
- package/src/core/messages/outgoing-response.ts +0 -174
- package/src/core/messages/parser.ts +0 -265
- package/src/core/messages/utils.ts +0 -144
- package/src/core/session/index.ts +0 -2
- package/src/core/session/session-delegate.ts +0 -88
- package/src/core/session/session.ts +0 -158
- package/src/core/subscription/index.ts +0 -2
- package/src/core/subscription/subscription-delegate.ts +0 -30
- package/src/core/subscription/subscription.ts +0 -61
- package/src/core/timers.ts +0 -24
- package/src/core/transactions/client-transaction.ts +0 -78
- package/src/core/transactions/index.ts +0 -10
- package/src/core/transactions/invite-client-transaction.ts +0 -504
- package/src/core/transactions/invite-server-transaction.ts +0 -432
- package/src/core/transactions/non-invite-client-transaction.ts +0 -257
- package/src/core/transactions/non-invite-server-transaction.ts +0 -241
- package/src/core/transactions/server-transaction.ts +0 -47
- package/src/core/transactions/transaction-state.ts +0 -13
- package/src/core/transactions/transaction-user.ts +0 -82
- package/src/core/transactions/transaction.ts +0 -149
- package/src/core/transport.ts +0 -32
- package/src/core/user-agent-core/allowed-methods.ts +0 -19
- package/src/core/user-agent-core/index.ts +0 -3
- package/src/core/user-agent-core/user-agent-core-configuration.ts +0 -111
- package/src/core/user-agent-core/user-agent-core-delegate.ts +0 -50
- package/src/core/user-agent-core/user-agent-core.ts +0 -905
- package/src/core/user-agents/bye-user-agent-client.ts +0 -16
- package/src/core/user-agents/bye-user-agent-server.ts +0 -14
- package/src/core/user-agents/cancel-user-agent-client.ts +0 -14
- package/src/core/user-agents/index.ts +0 -26
- package/src/core/user-agents/info-user-agent-client.ts +0 -15
- package/src/core/user-agents/info-user-agent-server.ts +0 -14
- package/src/core/user-agents/invite-user-agent-client.ts +0 -405
- package/src/core/user-agents/invite-user-agent-server.ts +0 -269
- package/src/core/user-agents/message-user-agent-client.ts +0 -14
- package/src/core/user-agents/message-user-agent-server.ts +0 -14
- package/src/core/user-agents/notify-user-agent-client.ts +0 -15
- package/src/core/user-agents/notify-user-agent-server.ts +0 -30
- package/src/core/user-agents/prack-user-agent-client.ts +0 -16
- package/src/core/user-agents/prack-user-agent-server.ts +0 -37
- package/src/core/user-agents/publish-user-agent-client.ts +0 -14
- package/src/core/user-agents/re-invite-user-agent-client.ts +0 -127
- package/src/core/user-agents/re-invite-user-agent-server.ts +0 -109
- package/src/core/user-agents/re-subscribe-user-agent-client.ts +0 -78
- package/src/core/user-agents/re-subscribe-user-agent-server.ts +0 -14
- package/src/core/user-agents/refer-user-agent-client.ts +0 -15
- package/src/core/user-agents/refer-user-agent-server.ts +0 -30
- package/src/core/user-agents/register-user-agent-client.ts +0 -14
- package/src/core/user-agents/register-user-agent-server.ts +0 -14
- package/src/core/user-agents/subscribe-user-agent-client.ts +0 -341
- package/src/core/user-agents/subscribe-user-agent-server.ts +0 -14
- package/src/core/user-agents/user-agent-client.ts +0 -378
- package/src/core/user-agents/user-agent-server.ts +0 -276
- package/src/grammar/grammar.ts +0 -55
- package/src/grammar/index.ts +0 -4
- package/src/grammar/name-addr-header.ts +0 -58
- package/src/grammar/parameters.ts +0 -45
- package/src/grammar/pegjs/README.md +0 -9
- package/src/grammar/pegjs/dist/grammar.ts +0 -1557
- package/src/grammar/pegjs/src/grammar.pegjs +0 -1009
- package/src/grammar/uri.ts +0 -370
- package/src/lib/socket.io.esm.min.js +0 -7
- package/src/main.ts +0 -26
- package/src/new-index.ts +0 -2478
- package/src/platform/react/README.md +0 -1
- package/src/platform/web/index.ts +0 -4
- package/src/platform/web/modifiers/index.ts +0 -5
- package/src/platform/web/modifiers/modifiers.ts +0 -180
- package/src/platform/web/session-description-handler/api-extractor.json +0 -358
- package/src/platform/web/session-description-handler/index.ts +0 -14
- package/src/platform/web/session-description-handler/media-stream-factory-default.ts +0 -22
- package/src/platform/web/session-description-handler/media-stream-factory.ts +0 -10
- package/src/platform/web/session-description-handler/peer-connection-configuration-default.ts +0 -17
- package/src/platform/web/session-description-handler/peer-connection-delegate.ts +0 -72
- package/src/platform/web/session-description-handler/session-description-handler-configuration.ts +0 -17
- package/src/platform/web/session-description-handler/session-description-handler-factory-default.ts +0 -45
- package/src/platform/web/session-description-handler/session-description-handler-factory-options.ts +0 -10
- package/src/platform/web/session-description-handler/session-description-handler-factory.ts +0 -17
- package/src/platform/web/session-description-handler/session-description-handler-options.ts +0 -56
- package/src/platform/web/session-description-handler/session-description-handler.ts +0 -938
- package/src/platform/web/simple-user/api-extractor.json +0 -358
- package/src/platform/web/simple-user/index.ts +0 -7
- package/src/platform/web/simple-user/simple-user-delegate.ts +0 -82
- package/src/platform/web/simple-user/simple-user-options.ts +0 -102
- package/src/platform/web/simple-user/simple-user.ts +0 -1099
- package/src/platform/web/transport/api-extractor.json +0 -358
- package/src/platform/web/transport/index.ts +0 -6
- package/src/platform/web/transport/transport-options.ts +0 -34
- package/src/platform/web/transport/transport.ts +0 -742
- package/src/version.ts +0 -8
- package/src/webPhoneSdk.ts +0 -67
- package/src/webrtc.ts +0 -318
- /package/dist/{config.d.ts → types/config.d.ts} +0 -0
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { Dialog } from "../dialogs";
|
|
2
|
-
import { TransportError } from "../exceptions";
|
|
3
|
-
import { Logger, LoggerFactory } from "../log";
|
|
4
|
-
import {
|
|
5
|
-
C,
|
|
6
|
-
IncomingResponseMessage,
|
|
7
|
-
OutgoingRequest,
|
|
8
|
-
OutgoingRequestDelegate,
|
|
9
|
-
OutgoingRequestMessage,
|
|
10
|
-
RequestOptions
|
|
11
|
-
} from "../messages";
|
|
12
|
-
import {
|
|
13
|
-
ClientTransaction,
|
|
14
|
-
ClientTransactionUser,
|
|
15
|
-
NonInviteClientTransaction,
|
|
16
|
-
TransactionState
|
|
17
|
-
} from "../transactions";
|
|
18
|
-
import { Transport } from "../transport";
|
|
19
|
-
import { UserAgentCore } from "../user-agent-core";
|
|
20
|
-
|
|
21
|
-
type ClientTransactionConstructor = new (
|
|
22
|
-
message: OutgoingRequestMessage,
|
|
23
|
-
transport: Transport,
|
|
24
|
-
user: ClientTransactionUser
|
|
25
|
-
) => ClientTransaction;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* User Agent Client (UAC).
|
|
29
|
-
* @remarks
|
|
30
|
-
* A user agent client is a logical entity
|
|
31
|
-
* that creates a new request, and then uses the client
|
|
32
|
-
* transaction state machinery to send it. The role of UAC lasts
|
|
33
|
-
* only for the duration of that transaction. In other words, if
|
|
34
|
-
* a piece of software initiates a request, it acts as a UAC for
|
|
35
|
-
* the duration of that transaction. If it receives a request
|
|
36
|
-
* later, it assumes the role of a user agent server for the
|
|
37
|
-
* processing of that transaction.
|
|
38
|
-
* https://tools.ietf.org/html/rfc3261#section-6
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
export class UserAgentClient implements OutgoingRequest {
|
|
42
|
-
protected logger: Logger;
|
|
43
|
-
|
|
44
|
-
private _transaction: ClientTransaction | undefined;
|
|
45
|
-
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
private credentials: any;
|
|
48
|
-
private challenged = false;
|
|
49
|
-
private stale = false;
|
|
50
|
-
|
|
51
|
-
constructor(
|
|
52
|
-
private transactionConstructor: ClientTransactionConstructor,
|
|
53
|
-
protected core: UserAgentCore,
|
|
54
|
-
public message: OutgoingRequestMessage,
|
|
55
|
-
public delegate?: OutgoingRequestDelegate
|
|
56
|
-
) {
|
|
57
|
-
this.logger = this.loggerFactory.getLogger("sip.user-agent-client");
|
|
58
|
-
this.init();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public dispose(): void {
|
|
62
|
-
this.transaction.dispose();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get loggerFactory(): LoggerFactory {
|
|
66
|
-
return this.core.loggerFactory;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** The transaction associated with this request. */
|
|
70
|
-
get transaction(): ClientTransaction {
|
|
71
|
-
if (!this._transaction) {
|
|
72
|
-
throw new Error("Transaction undefined.");
|
|
73
|
-
}
|
|
74
|
-
return this._transaction;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Since requests other than INVITE are responded to immediately, sending a
|
|
79
|
-
* CANCEL for a non-INVITE request would always create a race condition.
|
|
80
|
-
* A CANCEL request SHOULD NOT be sent to cancel a request other than INVITE.
|
|
81
|
-
* https://tools.ietf.org/html/rfc3261#section-9.1
|
|
82
|
-
* @param options - Cancel options bucket.
|
|
83
|
-
*/
|
|
84
|
-
public cancel(reason?: string, options: RequestOptions = {}): OutgoingRequestMessage {
|
|
85
|
-
if (!this.transaction) {
|
|
86
|
-
throw new Error("Transaction undefined.");
|
|
87
|
-
}
|
|
88
|
-
if (!this.message.to) {
|
|
89
|
-
throw new Error("To undefined.");
|
|
90
|
-
}
|
|
91
|
-
if (!this.message.from) {
|
|
92
|
-
throw new Error("From undefined.");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// The following procedures are used to construct a CANCEL request. The
|
|
96
|
-
// Request-URI, Call-ID, To, the numeric part of CSeq, and From header
|
|
97
|
-
// fields in the CANCEL request MUST be identical to those in the
|
|
98
|
-
// request being cancelled, including tags. A CANCEL constructed by a
|
|
99
|
-
// client MUST have only a single Via header field value matching the
|
|
100
|
-
// top Via value in the request being cancelled. Using the same values
|
|
101
|
-
// for these header fields allows the CANCEL to be matched with the
|
|
102
|
-
// request it cancels (Section 9.2 indicates how such matching occurs).
|
|
103
|
-
// However, the method part of the CSeq header field MUST have a value
|
|
104
|
-
// of CANCEL. This allows it to be identified and processed as a
|
|
105
|
-
// transaction in its own right (See Section 17).
|
|
106
|
-
// https://tools.ietf.org/html/rfc3261#section-9.1
|
|
107
|
-
const message = this.core.makeOutgoingRequestMessage(
|
|
108
|
-
C.CANCEL,
|
|
109
|
-
this.message.ruri,
|
|
110
|
-
this.message.from.uri,
|
|
111
|
-
this.message.to.uri,
|
|
112
|
-
{
|
|
113
|
-
toTag: this.message.toTag,
|
|
114
|
-
fromTag: this.message.fromTag,
|
|
115
|
-
callId: this.message.callId,
|
|
116
|
-
cseq: this.message.cseq
|
|
117
|
-
},
|
|
118
|
-
options.extraHeaders
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
// TODO: Revisit this.
|
|
122
|
-
// The CANCEL needs to use the same branch parameter so that
|
|
123
|
-
// it matches the INVITE transaction, but this is a hacky way to do this.
|
|
124
|
-
// Or at the very least not well documented. If the the branch parameter
|
|
125
|
-
// is set on the outgoing request, the transaction will use it.
|
|
126
|
-
// Otherwise the transaction will make a new one.
|
|
127
|
-
message.branch = this.message.branch;
|
|
128
|
-
|
|
129
|
-
if (this.message.headers.Route) {
|
|
130
|
-
message.headers.Route = this.message.headers.Route;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (reason) {
|
|
134
|
-
message.setHeader("Reason", reason);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// If no provisional response has been received, the CANCEL request MUST
|
|
138
|
-
// NOT be sent; rather, the client MUST wait for the arrival of a
|
|
139
|
-
// provisional response before sending the request. If the original
|
|
140
|
-
// request has generated a final response, the CANCEL SHOULD NOT be
|
|
141
|
-
// sent, as it is an effective no-op, since CANCEL has no effect on
|
|
142
|
-
// requests that have already generated a final response.
|
|
143
|
-
// https://tools.ietf.org/html/rfc3261#section-9.1
|
|
144
|
-
if (this.transaction.state === TransactionState.Proceeding) {
|
|
145
|
-
new UserAgentClient(NonInviteClientTransaction, this.core, message);
|
|
146
|
-
} else {
|
|
147
|
-
this.transaction.addStateChangeListener(
|
|
148
|
-
() => {
|
|
149
|
-
if (this.transaction && this.transaction.state === TransactionState.Proceeding) {
|
|
150
|
-
new UserAgentClient(NonInviteClientTransaction, this.core, message);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
{ once: true }
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return message;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
|
|
162
|
-
* response is received, the UAC SHOULD follow the authorization
|
|
163
|
-
* procedures of Section 22.2 and Section 22.3 to retry the request with
|
|
164
|
-
* credentials.
|
|
165
|
-
* https://tools.ietf.org/html/rfc3261#section-8.1.3.5
|
|
166
|
-
* 22 Usage of HTTP Authentication
|
|
167
|
-
* https://tools.ietf.org/html/rfc3261#section-22
|
|
168
|
-
* 22.1 Framework
|
|
169
|
-
* https://tools.ietf.org/html/rfc3261#section-22.1
|
|
170
|
-
* 22.2 User-to-User Authentication
|
|
171
|
-
* https://tools.ietf.org/html/rfc3261#section-22.2
|
|
172
|
-
* 22.3 Proxy-to-User Authentication
|
|
173
|
-
* https://tools.ietf.org/html/rfc3261#section-22.3
|
|
174
|
-
*
|
|
175
|
-
* FIXME: This "guard for and retry the request with credentials"
|
|
176
|
-
* implementation is not complete and at best minimally passable.
|
|
177
|
-
* @param response - The incoming response to guard.
|
|
178
|
-
* @param dialog - If defined, the dialog within which the response was received.
|
|
179
|
-
* @returns True if the program execution is to continue in the branch in question.
|
|
180
|
-
* Otherwise the request is retried with credentials and current request processing must stop.
|
|
181
|
-
*/
|
|
182
|
-
protected authenticationGuard(message: IncomingResponseMessage, dialog?: Dialog): boolean {
|
|
183
|
-
const statusCode = message.statusCode;
|
|
184
|
-
if (!statusCode) {
|
|
185
|
-
throw new Error("Response status code undefined.");
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// If a 401 (Unauthorized) or 407 (Proxy Authentication Required)
|
|
189
|
-
// response is received, the UAC SHOULD follow the authorization
|
|
190
|
-
// procedures of Section 22.2 and Section 22.3 to retry the request with
|
|
191
|
-
// credentials.
|
|
192
|
-
// https://tools.ietf.org/html/rfc3261#section-8.1.3.5
|
|
193
|
-
if (statusCode !== 401 && statusCode !== 407) {
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Get and parse the appropriate WWW-Authenticate or Proxy-Authenticate header.
|
|
198
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
199
|
-
let challenge: any;
|
|
200
|
-
let authorizationHeaderName: string;
|
|
201
|
-
if (statusCode === 401) {
|
|
202
|
-
challenge = message.parseHeader("www-authenticate");
|
|
203
|
-
authorizationHeaderName = "authorization";
|
|
204
|
-
} else {
|
|
205
|
-
challenge = message.parseHeader("proxy-authenticate");
|
|
206
|
-
authorizationHeaderName = "proxy-authorization";
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Verify it seems a valid challenge.
|
|
210
|
-
if (!challenge) {
|
|
211
|
-
this.logger.warn(statusCode + " with wrong or missing challenge, cannot authenticate");
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Avoid infinite authentications.
|
|
216
|
-
if (this.challenged && (this.stale || challenge.stale !== true)) {
|
|
217
|
-
this.logger.warn(statusCode + " apparently in authentication loop, cannot authenticate");
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Get credentials.
|
|
222
|
-
if (!this.credentials) {
|
|
223
|
-
this.credentials = this.core.configuration.authenticationFactory();
|
|
224
|
-
if (!this.credentials) {
|
|
225
|
-
this.logger.warn("Unable to obtain credentials, cannot authenticate");
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Verify that the challenge is really valid.
|
|
231
|
-
if (!this.credentials.authenticate(this.message, challenge)) {
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
this.challenged = true;
|
|
236
|
-
if (challenge.stale) {
|
|
237
|
-
this.stale = true;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// If response to out of dialog request, assume incrementing the CSeq will suffice.
|
|
241
|
-
let cseq = (this.message.cseq += 1);
|
|
242
|
-
|
|
243
|
-
// If response to in dialog request, get a valid next CSeq number.
|
|
244
|
-
if (dialog && dialog.localSequenceNumber) {
|
|
245
|
-
dialog.incrementLocalSequenceNumber();
|
|
246
|
-
cseq = this.message.cseq = dialog.localSequenceNumber;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
this.message.setHeader("cseq", cseq + " " + this.message.method);
|
|
250
|
-
this.message.setHeader(authorizationHeaderName, this.credentials.toString());
|
|
251
|
-
|
|
252
|
-
// Calling init (again) will swap out our existing client transaction with a new one.
|
|
253
|
-
// FIXME: HACK: An assumption is being made here that there is nothing that needs to
|
|
254
|
-
// be cleaned up beyond the client transaction which is being replaced. For example,
|
|
255
|
-
// it is assumed that no early dialogs have been created.
|
|
256
|
-
this.init();
|
|
257
|
-
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* 8.1.3.1 Transaction Layer Errors
|
|
263
|
-
* In some cases, the response returned by the transaction layer will
|
|
264
|
-
* not be a SIP message, but rather a transaction layer error. When a
|
|
265
|
-
* timeout error is received from the transaction layer, it MUST be
|
|
266
|
-
* treated as if a 408 (Request Timeout) status code has been received.
|
|
267
|
-
* If a fatal transport error is reported by the transport layer
|
|
268
|
-
* (generally, due to fatal ICMP errors in UDP or connection failures in
|
|
269
|
-
* TCP), the condition MUST be treated as a 503 (Service Unavailable)
|
|
270
|
-
* status code.
|
|
271
|
-
* https://tools.ietf.org/html/rfc3261#section-8.1.3.1
|
|
272
|
-
*/
|
|
273
|
-
protected onRequestTimeout(): void {
|
|
274
|
-
this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");
|
|
275
|
-
const message = new IncomingResponseMessage();
|
|
276
|
-
message.statusCode = 408;
|
|
277
|
-
message.reasonPhrase = "Request Timeout";
|
|
278
|
-
this.receiveResponse(message);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* 8.1.3.1 Transaction Layer Errors
|
|
284
|
-
* In some cases, the response returned by the transaction layer will
|
|
285
|
-
* not be a SIP message, but rather a transaction layer error. When a
|
|
286
|
-
* timeout error is received from the transaction layer, it MUST be
|
|
287
|
-
* treated as if a 408 (Request Timeout) status code has been received.
|
|
288
|
-
* If a fatal transport error is reported by the transport layer
|
|
289
|
-
* (generally, due to fatal ICMP errors in UDP or connection failures in
|
|
290
|
-
* TCP), the condition MUST be treated as a 503 (Service Unavailable)
|
|
291
|
-
* status code.
|
|
292
|
-
* https://tools.ietf.org/html/rfc3261#section-8.1.3.1
|
|
293
|
-
* @param error - Transport error
|
|
294
|
-
*/
|
|
295
|
-
protected onTransportError(error: TransportError): void {
|
|
296
|
-
this.logger.error(error.message);
|
|
297
|
-
this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");
|
|
298
|
-
const message = new IncomingResponseMessage();
|
|
299
|
-
message.statusCode = 503;
|
|
300
|
-
message.reasonPhrase = "Service Unavailable";
|
|
301
|
-
this.receiveResponse(message);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Receive a response from the transaction layer.
|
|
306
|
-
* @param message - Incoming response message.
|
|
307
|
-
*/
|
|
308
|
-
protected receiveResponse(message: IncomingResponseMessage): void {
|
|
309
|
-
if (!this.authenticationGuard(message)) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const statusCode = message.statusCode ? message.statusCode.toString() : "";
|
|
314
|
-
if (!statusCode) {
|
|
315
|
-
throw new Error("Response status code undefined.");
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
switch (true) {
|
|
319
|
-
case /^100$/.test(statusCode):
|
|
320
|
-
if (this.delegate && this.delegate.onTrying) {
|
|
321
|
-
this.delegate.onTrying({ message });
|
|
322
|
-
}
|
|
323
|
-
break;
|
|
324
|
-
case /^1[0-9]{2}$/.test(statusCode):
|
|
325
|
-
if (this.delegate && this.delegate.onProgress) {
|
|
326
|
-
this.delegate.onProgress({ message });
|
|
327
|
-
}
|
|
328
|
-
break;
|
|
329
|
-
case /^2[0-9]{2}$/.test(statusCode):
|
|
330
|
-
if (this.delegate && this.delegate.onAccept) {
|
|
331
|
-
this.delegate.onAccept({ message });
|
|
332
|
-
}
|
|
333
|
-
break;
|
|
334
|
-
case /^3[0-9]{2}$/.test(statusCode):
|
|
335
|
-
if (this.delegate && this.delegate.onRedirect) {
|
|
336
|
-
this.delegate.onRedirect({ message });
|
|
337
|
-
}
|
|
338
|
-
break;
|
|
339
|
-
case /^[4-6][0-9]{2}$/.test(statusCode):
|
|
340
|
-
if (this.delegate && this.delegate.onReject) {
|
|
341
|
-
this.delegate.onReject({ message });
|
|
342
|
-
}
|
|
343
|
-
break;
|
|
344
|
-
default:
|
|
345
|
-
throw new Error(`Invalid status code ${statusCode}`);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private init(): void {
|
|
350
|
-
// We are the transaction user.
|
|
351
|
-
const user: ClientTransactionUser = {
|
|
352
|
-
loggerFactory: this.loggerFactory,
|
|
353
|
-
onRequestTimeout: () => this.onRequestTimeout(),
|
|
354
|
-
onStateChange: (newState) => {
|
|
355
|
-
if (newState === TransactionState.Terminated) {
|
|
356
|
-
// Remove the terminated transaction from the core.
|
|
357
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
358
|
-
this.core.userAgentClients.delete(userAgentClientId);
|
|
359
|
-
// FIXME: HACK: Our transaction may have been swapped out with a new one
|
|
360
|
-
// post authentication (see above), so make sure to only to dispose of
|
|
361
|
-
// ourselves if this terminating transaction is our current transaction.
|
|
362
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
363
|
-
if (transaction === this._transaction) {
|
|
364
|
-
this.dispose();
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
onTransportError: (error) => this.onTransportError(error),
|
|
369
|
-
receiveResponse: (message) => this.receiveResponse(message)
|
|
370
|
-
};
|
|
371
|
-
// Create a new transaction with us as the user.
|
|
372
|
-
const transaction = new this.transactionConstructor(this.message, this.core.transport, user);
|
|
373
|
-
this._transaction = transaction;
|
|
374
|
-
// Add the new transaction to the core.
|
|
375
|
-
const userAgentClientId = transaction.id + transaction.request.method;
|
|
376
|
-
this.core.userAgentClients.set(userAgentClientId, this);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { TransactionStateError } from "../exceptions";
|
|
2
|
-
import { Logger, LoggerFactory } from "../log";
|
|
3
|
-
import {
|
|
4
|
-
constructOutgoingResponse,
|
|
5
|
-
IncomingRequest,
|
|
6
|
-
IncomingRequestDelegate,
|
|
7
|
-
IncomingRequestMessage,
|
|
8
|
-
OutgoingResponse,
|
|
9
|
-
ResponseOptions,
|
|
10
|
-
URI
|
|
11
|
-
} from "../messages";
|
|
12
|
-
import { newTag } from "../messages/utils";
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
InviteServerTransaction,
|
|
16
|
-
NonInviteServerTransaction,
|
|
17
|
-
ServerTransaction,
|
|
18
|
-
ServerTransactionUser,
|
|
19
|
-
TransactionState
|
|
20
|
-
} from "../transactions";
|
|
21
|
-
import { Transport } from "../transport";
|
|
22
|
-
import { UserAgentCore } from "../user-agent-core";
|
|
23
|
-
|
|
24
|
-
type ServerTransactionConstructor = new (
|
|
25
|
-
message: IncomingRequestMessage,
|
|
26
|
-
transport: Transport,
|
|
27
|
-
user: ServerTransactionUser
|
|
28
|
-
) => ServerTransaction;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* User Agent Server (UAS).
|
|
32
|
-
* @remarks
|
|
33
|
-
* A user agent server is a logical entity
|
|
34
|
-
* that generates a response to a SIP request. The response
|
|
35
|
-
* accepts, rejects, or redirects the request. This role lasts
|
|
36
|
-
* only for the duration of that transaction. In other words, if
|
|
37
|
-
* a piece of software responds to a request, it acts as a UAS for
|
|
38
|
-
* the duration of that transaction. If it generates a request
|
|
39
|
-
* later, it assumes the role of a user agent client for the
|
|
40
|
-
* processing of that transaction.
|
|
41
|
-
* https://tools.ietf.org/html/rfc3261#section-6
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export class UserAgentServer implements IncomingRequest {
|
|
45
|
-
protected logger: Logger;
|
|
46
|
-
protected toTag: string;
|
|
47
|
-
|
|
48
|
-
private _transaction: ServerTransaction | undefined;
|
|
49
|
-
|
|
50
|
-
constructor(
|
|
51
|
-
private transactionConstructor: ServerTransactionConstructor,
|
|
52
|
-
protected core: UserAgentCore,
|
|
53
|
-
public message: IncomingRequestMessage,
|
|
54
|
-
public delegate?: IncomingRequestDelegate
|
|
55
|
-
) {
|
|
56
|
-
this.logger = this.loggerFactory.getLogger("sip.user-agent-server");
|
|
57
|
-
this.toTag = message.toTag ? message.toTag : newTag();
|
|
58
|
-
this.init();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public dispose(): void {
|
|
62
|
-
this.transaction.dispose();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get loggerFactory(): LoggerFactory {
|
|
66
|
-
return this.core.loggerFactory;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** The transaction associated with this request. */
|
|
70
|
-
get transaction(): ServerTransaction {
|
|
71
|
-
if (!this._transaction) {
|
|
72
|
-
throw new Error("Transaction undefined.");
|
|
73
|
-
}
|
|
74
|
-
return this._transaction;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public accept(options: ResponseOptions = { statusCode: 200 }): OutgoingResponse {
|
|
78
|
-
if (!this.acceptable) {
|
|
79
|
-
throw new TransactionStateError(`${this.message.method} not acceptable in state ${this.transaction.state}.`);
|
|
80
|
-
}
|
|
81
|
-
const statusCode = options.statusCode;
|
|
82
|
-
if (statusCode < 200 || statusCode > 299) {
|
|
83
|
-
throw new TypeError(`Invalid statusCode: ${statusCode}`);
|
|
84
|
-
}
|
|
85
|
-
const response = this.reply(options);
|
|
86
|
-
return response;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public progress(options: ResponseOptions = { statusCode: 180 }): OutgoingResponse {
|
|
90
|
-
if (!this.progressable) {
|
|
91
|
-
throw new TransactionStateError(`${this.message.method} not progressable in state ${this.transaction.state}.`);
|
|
92
|
-
}
|
|
93
|
-
const statusCode = options.statusCode;
|
|
94
|
-
if (statusCode < 101 || statusCode > 199) {
|
|
95
|
-
throw new TypeError(`Invalid statusCode: ${statusCode}`);
|
|
96
|
-
}
|
|
97
|
-
const response = this.reply(options);
|
|
98
|
-
return response;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public redirect(contacts: Array<URI>, options: ResponseOptions = { statusCode: 302 }): OutgoingResponse {
|
|
102
|
-
if (!this.redirectable) {
|
|
103
|
-
throw new TransactionStateError(`${this.message.method} not redirectable in state ${this.transaction.state}.`);
|
|
104
|
-
}
|
|
105
|
-
const statusCode = options.statusCode;
|
|
106
|
-
if (statusCode < 300 || statusCode > 399) {
|
|
107
|
-
throw new TypeError(`Invalid statusCode: ${statusCode}`);
|
|
108
|
-
}
|
|
109
|
-
const contactHeaders = new Array<string>();
|
|
110
|
-
contacts.forEach((contact) => contactHeaders.push(`Contact: ${contact.toString()}`));
|
|
111
|
-
options.extraHeaders = (options.extraHeaders || []).concat(contactHeaders);
|
|
112
|
-
const response = this.reply(options);
|
|
113
|
-
return response;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public reject(options: ResponseOptions = { statusCode: 480 }): OutgoingResponse {
|
|
117
|
-
if (!this.rejectable) {
|
|
118
|
-
throw new TransactionStateError(`${this.message.method} not rejectable in state ${this.transaction.state}.`);
|
|
119
|
-
}
|
|
120
|
-
const statusCode = options.statusCode;
|
|
121
|
-
if (statusCode < 400 || statusCode > 699) {
|
|
122
|
-
throw new TypeError(`Invalid statusCode: ${statusCode}`);
|
|
123
|
-
}
|
|
124
|
-
const response = this.reply(options);
|
|
125
|
-
return response;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
129
|
-
public trying(options?: ResponseOptions): OutgoingResponse {
|
|
130
|
-
if (!this.tryingable) {
|
|
131
|
-
throw new TransactionStateError(`${this.message.method} not tryingable in state ${this.transaction.state}.`);
|
|
132
|
-
}
|
|
133
|
-
const response = this.reply({ statusCode: 100 });
|
|
134
|
-
return response;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* If the UAS did not find a matching transaction for the CANCEL
|
|
139
|
-
* according to the procedure above, it SHOULD respond to the CANCEL
|
|
140
|
-
* with a 481 (Call Leg/Transaction Does Not Exist). If the transaction
|
|
141
|
-
* for the original request still exists, the behavior of the UAS on
|
|
142
|
-
* receiving a CANCEL request depends on whether it has already sent a
|
|
143
|
-
* final response for the original request. If it has, the CANCEL
|
|
144
|
-
* request has no effect on the processing of the original request, no
|
|
145
|
-
* effect on any session state, and no effect on the responses generated
|
|
146
|
-
* for the original request. If the UAS has not issued a final response
|
|
147
|
-
* for the original request, its behavior depends on the method of the
|
|
148
|
-
* original request. If the original request was an INVITE, the UAS
|
|
149
|
-
* SHOULD immediately respond to the INVITE with a 487 (Request
|
|
150
|
-
* Terminated). A CANCEL request has no impact on the processing of
|
|
151
|
-
* transactions with any other method defined in this specification.
|
|
152
|
-
* https://tools.ietf.org/html/rfc3261#section-9.2
|
|
153
|
-
* @param request - Incoming CANCEL request.
|
|
154
|
-
*/
|
|
155
|
-
public receiveCancel(message: IncomingRequestMessage): void {
|
|
156
|
-
// Note: Currently CANCEL is being handled as a special case.
|
|
157
|
-
// No UAS is created to handle the CANCEL and the response to
|
|
158
|
-
// it CANCEL is being handled statelessly by the user agent core.
|
|
159
|
-
// As such, there is currently no way to externally impact the
|
|
160
|
-
// response to the a CANCEL request.
|
|
161
|
-
if (this.delegate && this.delegate.onCancel) {
|
|
162
|
-
this.delegate.onCancel(message);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
protected get acceptable(): boolean {
|
|
167
|
-
if (this.transaction instanceof InviteServerTransaction) {
|
|
168
|
-
return (
|
|
169
|
-
this.transaction.state === TransactionState.Proceeding || this.transaction.state === TransactionState.Accepted
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
if (this.transaction instanceof NonInviteServerTransaction) {
|
|
173
|
-
return (
|
|
174
|
-
this.transaction.state === TransactionState.Trying || this.transaction.state === TransactionState.Proceeding
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
throw new Error("Unknown transaction type.");
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
protected get progressable(): boolean {
|
|
181
|
-
if (this.transaction instanceof InviteServerTransaction) {
|
|
182
|
-
return this.transaction.state === TransactionState.Proceeding;
|
|
183
|
-
}
|
|
184
|
-
if (this.transaction instanceof NonInviteServerTransaction) {
|
|
185
|
-
return false; // https://tools.ietf.org/html/rfc4320#section-4.1
|
|
186
|
-
}
|
|
187
|
-
throw new Error("Unknown transaction type.");
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
protected get redirectable(): boolean {
|
|
191
|
-
if (this.transaction instanceof InviteServerTransaction) {
|
|
192
|
-
return this.transaction.state === TransactionState.Proceeding;
|
|
193
|
-
}
|
|
194
|
-
if (this.transaction instanceof NonInviteServerTransaction) {
|
|
195
|
-
return (
|
|
196
|
-
this.transaction.state === TransactionState.Trying || this.transaction.state === TransactionState.Proceeding
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
throw new Error("Unknown transaction type.");
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
protected get rejectable(): boolean {
|
|
203
|
-
if (this.transaction instanceof InviteServerTransaction) {
|
|
204
|
-
return this.transaction.state === TransactionState.Proceeding;
|
|
205
|
-
}
|
|
206
|
-
if (this.transaction instanceof NonInviteServerTransaction) {
|
|
207
|
-
return (
|
|
208
|
-
this.transaction.state === TransactionState.Trying || this.transaction.state === TransactionState.Proceeding
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
throw new Error("Unknown transaction type.");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
protected get tryingable(): boolean {
|
|
215
|
-
if (this.transaction instanceof InviteServerTransaction) {
|
|
216
|
-
return this.transaction.state === TransactionState.Proceeding;
|
|
217
|
-
}
|
|
218
|
-
if (this.transaction instanceof NonInviteServerTransaction) {
|
|
219
|
-
return this.transaction.state === TransactionState.Trying;
|
|
220
|
-
}
|
|
221
|
-
throw new Error("Unknown transaction type.");
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* When a UAS wishes to construct a response to a request, it follows
|
|
226
|
-
* the general procedures detailed in the following subsections.
|
|
227
|
-
* Additional behaviors specific to the response code in question, which
|
|
228
|
-
* are not detailed in this section, may also be required.
|
|
229
|
-
*
|
|
230
|
-
* Once all procedures associated with the creation of a response have
|
|
231
|
-
* been completed, the UAS hands the response back to the server
|
|
232
|
-
* transaction from which it received the request.
|
|
233
|
-
* https://tools.ietf.org/html/rfc3261#section-8.2.6
|
|
234
|
-
* @param statusCode - Status code to reply with.
|
|
235
|
-
* @param options - Reply options bucket.
|
|
236
|
-
*/
|
|
237
|
-
private reply(options: ResponseOptions): OutgoingResponse {
|
|
238
|
-
if (!options.toTag && options.statusCode !== 100) {
|
|
239
|
-
options.toTag = this.toTag;
|
|
240
|
-
}
|
|
241
|
-
options.userAgent = options.userAgent || this.core.configuration.userAgentHeaderFieldValue;
|
|
242
|
-
options.supported = options.supported || this.core.configuration.supportedOptionTagsResponse;
|
|
243
|
-
const response = constructOutgoingResponse(this.message, options);
|
|
244
|
-
this.transaction.receiveResponse(options.statusCode, response.message);
|
|
245
|
-
return response;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
private init(): void {
|
|
249
|
-
// We are the transaction user.
|
|
250
|
-
const user: ServerTransactionUser = {
|
|
251
|
-
loggerFactory: this.loggerFactory,
|
|
252
|
-
onStateChange: (newState) => {
|
|
253
|
-
if (newState === TransactionState.Terminated) {
|
|
254
|
-
// Remove the terminated transaction from the core.
|
|
255
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
256
|
-
this.core.userAgentServers.delete(userAgentServerId);
|
|
257
|
-
this.dispose();
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
onTransportError: (error) => {
|
|
261
|
-
this.logger.error(error.message);
|
|
262
|
-
if (this.delegate && this.delegate.onTransportError) {
|
|
263
|
-
this.delegate.onTransportError(error);
|
|
264
|
-
} else {
|
|
265
|
-
this.logger.error("User agent server response transport error.");
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
// Create a new transaction with us as the user.
|
|
270
|
-
const transaction = new this.transactionConstructor(this.message, this.core.transport, user);
|
|
271
|
-
this._transaction = transaction;
|
|
272
|
-
// Add the new transaction to the core.
|
|
273
|
-
const userAgentServerId = transaction.id;
|
|
274
|
-
this.core.userAgentServers.set(transaction.id, this);
|
|
275
|
-
}
|
|
276
|
-
}
|