ue-softphone-sdk 2.2.4 → 2.2.6
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 +7 -2
- package/package.json +5 -6
- package/{new-rollup.config.mjs → rollup-new.config.mjs} +1 -1
- package/rollup.config.js +14 -15
- package/src/index.ts +28 -53
- 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/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
package/src/api/invitation.ts
DELETED
|
@@ -1,816 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Body,
|
|
3
|
-
fromBodyLegacy,
|
|
4
|
-
getBody,
|
|
5
|
-
Grammar,
|
|
6
|
-
IncomingInviteRequest,
|
|
7
|
-
IncomingPrackRequest,
|
|
8
|
-
IncomingRequestMessage,
|
|
9
|
-
InviteUserAgentServer,
|
|
10
|
-
Logger,
|
|
11
|
-
NameAddrHeader,
|
|
12
|
-
OutgoingResponse,
|
|
13
|
-
OutgoingResponseWithSession,
|
|
14
|
-
SignalingState,
|
|
15
|
-
Timers,
|
|
16
|
-
TransactionStateError
|
|
17
|
-
} from "../core";
|
|
18
|
-
import { getReasonPhrase } from "../core/messages/utils";
|
|
19
|
-
import { ContentTypeUnsupportedError, SessionDescriptionHandlerError, SessionTerminatedError } from "./exceptions";
|
|
20
|
-
import { InvitationAcceptOptions } from "./invitation-accept-options";
|
|
21
|
-
import { InvitationProgressOptions } from "./invitation-progress-options";
|
|
22
|
-
import { InvitationRejectOptions } from "./invitation-reject-options";
|
|
23
|
-
import { Session } from "./session";
|
|
24
|
-
import { SessionState } from "./session-state";
|
|
25
|
-
import { UserAgent } from "./user-agent";
|
|
26
|
-
import { SIPExtension } from "./user-agent-options";
|
|
27
|
-
|
|
28
|
-
type ResolveFunction = () => void;
|
|
29
|
-
type RejectFunction = (reason: Error) => void;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* An invitation is an offer to establish a {@link Session} (incoming INVITE).
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
export class Invitation extends Session {
|
|
36
|
-
/**
|
|
37
|
-
* Logger.
|
|
38
|
-
*/
|
|
39
|
-
protected logger: Logger;
|
|
40
|
-
|
|
41
|
-
/** @internal */
|
|
42
|
-
protected _id: string;
|
|
43
|
-
|
|
44
|
-
/** True if dispose() has been called. */
|
|
45
|
-
private disposed = false;
|
|
46
|
-
/** INVITE will be rejected if not accepted within a certain period time. */
|
|
47
|
-
private expiresTimer: number | undefined = undefined;
|
|
48
|
-
/** True if this Session has been Terminated due to a CANCEL request. */
|
|
49
|
-
private isCanceled = false;
|
|
50
|
-
/** Are reliable provisional responses required or supported. */
|
|
51
|
-
private rel100: "none" | "required" | "supported" = "none";
|
|
52
|
-
/** The current RSeq header value. */
|
|
53
|
-
private rseq = Math.floor(Math.random() * 10000);
|
|
54
|
-
/** INVITE will be rejected if final response not sent in a certain period time. */
|
|
55
|
-
private userNoAnswerTimer: number | undefined = undefined;
|
|
56
|
-
/** True if waiting for a PRACK before sending a 200 Ok. */
|
|
57
|
-
private waitingForPrack = false;
|
|
58
|
-
/** A Promise providing a defer when waiting for a PRACK. */
|
|
59
|
-
private waitingForPrackPromise: Promise<void> | undefined;
|
|
60
|
-
/** Function to resolve when PRACK arrives. */
|
|
61
|
-
private waitingForPrackResolve: ResolveFunction | undefined;
|
|
62
|
-
/** Function to reject when PRACK never arrives. */
|
|
63
|
-
private waitingForPrackReject: RejectFunction | undefined;
|
|
64
|
-
|
|
65
|
-
/** @internal */
|
|
66
|
-
public constructor(userAgent: UserAgent, public incomingInviteRequest: IncomingInviteRequest) {
|
|
67
|
-
super(userAgent);
|
|
68
|
-
|
|
69
|
-
this.logger = userAgent.getLogger("sip.Invitation");
|
|
70
|
-
|
|
71
|
-
const incomingRequestMessage = this.incomingInviteRequest.message;
|
|
72
|
-
|
|
73
|
-
// Set 100rel if necessary
|
|
74
|
-
const requireHeader = incomingRequestMessage.getHeader("require");
|
|
75
|
-
if (requireHeader && requireHeader.toLowerCase().includes("100rel")) {
|
|
76
|
-
this.rel100 = "required";
|
|
77
|
-
}
|
|
78
|
-
const supportedHeader = incomingRequestMessage.getHeader("supported");
|
|
79
|
-
if (supportedHeader && supportedHeader.toLowerCase().includes("100rel")) {
|
|
80
|
-
this.rel100 = "supported";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// FIXME: HACK: This is a hack to port an existing behavior.
|
|
84
|
-
// Set the toTag on the incoming request message to the toTag which
|
|
85
|
-
// will be used in the response to the incoming request!!!
|
|
86
|
-
// The behavior being ported appears to be a hack itself,
|
|
87
|
-
// so this is a hack to port a hack. At least one test spec
|
|
88
|
-
// relies on it (which is yet another hack).
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
incomingRequestMessage.toTag = ((incomingInviteRequest as InviteUserAgentServer) as any).toTag;
|
|
91
|
-
if (typeof incomingRequestMessage.toTag !== "string") {
|
|
92
|
-
throw new TypeError("toTag should have been a string.");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// The following mapping values are RECOMMENDED:
|
|
96
|
-
// ...
|
|
97
|
-
// 19 no answer from the user 480 Temporarily unavailable
|
|
98
|
-
// https://tools.ietf.org/html/rfc3398#section-7.2.4.1
|
|
99
|
-
this.userNoAnswerTimer = window.setTimeout(
|
|
100
|
-
() => {
|
|
101
|
-
incomingInviteRequest.reject({ statusCode: 480 });
|
|
102
|
-
this.stateTransition(SessionState.Terminated);
|
|
103
|
-
},
|
|
104
|
-
this.userAgent.configuration.noAnswerTimeout ? this.userAgent.configuration.noAnswerTimeout * 1000 : 60000
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// 1. If the request is an INVITE that contains an Expires header
|
|
108
|
-
// field, the UAS core sets a timer for the number of seconds
|
|
109
|
-
// indicated in the header field value. When the timer fires, the
|
|
110
|
-
// invitation is considered to be expired. If the invitation
|
|
111
|
-
// expires before the UAS has generated a final response, a 487
|
|
112
|
-
// (Request Terminated) response SHOULD be generated.
|
|
113
|
-
// https://tools.ietf.org/html/rfc3261#section-13.3.1
|
|
114
|
-
if (incomingRequestMessage.hasHeader("expires")) {
|
|
115
|
-
const expires: number = Number(incomingRequestMessage.getHeader("expires") || 0) * 1000;
|
|
116
|
-
this.expiresTimer = window.setTimeout(() => {
|
|
117
|
-
if (this.state === SessionState.Initial) {
|
|
118
|
-
incomingInviteRequest.reject({ statusCode: 487 });
|
|
119
|
-
this.stateTransition(SessionState.Terminated);
|
|
120
|
-
}
|
|
121
|
-
}, expires);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Session parent properties
|
|
125
|
-
const assertedIdentity = this.request.getHeader("P-Asserted-Identity");
|
|
126
|
-
if (assertedIdentity) {
|
|
127
|
-
this._assertedIdentity = Grammar.nameAddrHeaderParse(assertedIdentity);
|
|
128
|
-
}
|
|
129
|
-
this._contact = this.userAgent.contact.toString();
|
|
130
|
-
const contentDisposition = incomingRequestMessage.parseHeader("Content-Disposition");
|
|
131
|
-
if (contentDisposition && contentDisposition.type === "render") {
|
|
132
|
-
this._renderbody = incomingRequestMessage.body;
|
|
133
|
-
this._rendertype = incomingRequestMessage.getHeader("Content-Type");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Identifier
|
|
137
|
-
this._id = incomingRequestMessage.callId + incomingRequestMessage.fromTag;
|
|
138
|
-
|
|
139
|
-
// Add to the user agent's session collection.
|
|
140
|
-
this.userAgent._sessions[this._id] = this;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Destructor.
|
|
145
|
-
*/
|
|
146
|
-
public dispose(): Promise<void> {
|
|
147
|
-
// Only run through this once. It can and does get called multiple times
|
|
148
|
-
// depending on the what the sessions state is when first called.
|
|
149
|
-
// For example, if called when "establishing" it will be called again
|
|
150
|
-
// at least once when the session transitions to "terminated".
|
|
151
|
-
// Regardless, running through this more than once is pointless.
|
|
152
|
-
if (this.disposed) {
|
|
153
|
-
return Promise.resolve();
|
|
154
|
-
}
|
|
155
|
-
this.disposed = true;
|
|
156
|
-
|
|
157
|
-
// Clear timers
|
|
158
|
-
if (this.expiresTimer) {
|
|
159
|
-
clearTimeout(this.expiresTimer);
|
|
160
|
-
this.expiresTimer = undefined;
|
|
161
|
-
}
|
|
162
|
-
if (this.userNoAnswerTimer) {
|
|
163
|
-
clearTimeout(this.userNoAnswerTimer);
|
|
164
|
-
this.userNoAnswerTimer = undefined;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// If accept() is still waiting for a PRACK, make sure it rejects
|
|
168
|
-
this.prackNeverArrived();
|
|
169
|
-
|
|
170
|
-
// If the final response for the initial INVITE not yet been sent, reject it
|
|
171
|
-
switch (this.state) {
|
|
172
|
-
case SessionState.Initial:
|
|
173
|
-
return this.reject().then(() => super.dispose());
|
|
174
|
-
case SessionState.Establishing:
|
|
175
|
-
return this.reject().then(() => super.dispose());
|
|
176
|
-
case SessionState.Established:
|
|
177
|
-
return super.dispose();
|
|
178
|
-
case SessionState.Terminating:
|
|
179
|
-
return super.dispose();
|
|
180
|
-
case SessionState.Terminated:
|
|
181
|
-
return super.dispose();
|
|
182
|
-
default:
|
|
183
|
-
throw new Error("Unknown state.");
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* If true, a first provisional response after the 100 Trying
|
|
189
|
-
* will be sent automatically. This is false it the UAC required
|
|
190
|
-
* reliable provisional responses (100rel in Require header) or
|
|
191
|
-
* the user agent configuration has specified to not send an
|
|
192
|
-
* initial response, otherwise it is true. The provisional is sent by
|
|
193
|
-
* calling `progress()` without any options.
|
|
194
|
-
*/
|
|
195
|
-
public get autoSendAnInitialProvisionalResponse(): boolean {
|
|
196
|
-
return this.rel100 !== "required" && this.userAgent.configuration.sendInitialProvisionalResponse;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Initial incoming INVITE request message body.
|
|
201
|
-
*/
|
|
202
|
-
public get body(): string | undefined {
|
|
203
|
-
return this.incomingInviteRequest.message.body;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The identity of the local user.
|
|
208
|
-
*/
|
|
209
|
-
public get localIdentity(): NameAddrHeader {
|
|
210
|
-
return this.request.to;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* The identity of the remote user.
|
|
215
|
-
*/
|
|
216
|
-
public get remoteIdentity(): NameAddrHeader {
|
|
217
|
-
return this.request.from;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Initial incoming INVITE request message.
|
|
222
|
-
*/
|
|
223
|
-
public get request(): IncomingRequestMessage {
|
|
224
|
-
return this.incomingInviteRequest.message;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Accept the invitation.
|
|
229
|
-
*
|
|
230
|
-
* @remarks
|
|
231
|
-
* Accept the incoming INVITE request to start a Session.
|
|
232
|
-
* Replies to the INVITE request with a 200 Ok response.
|
|
233
|
-
* Resolves once the response sent, otherwise rejects.
|
|
234
|
-
*
|
|
235
|
-
* This method may reject for a variety of reasons including
|
|
236
|
-
* the receipt of a CANCEL request before `accept` is able
|
|
237
|
-
* to construct a response.
|
|
238
|
-
* @param options - Options bucket.
|
|
239
|
-
*/
|
|
240
|
-
public accept(options: InvitationAcceptOptions = {}): Promise<void> {
|
|
241
|
-
this.logger.log("Invitation.accept");
|
|
242
|
-
|
|
243
|
-
// validate state
|
|
244
|
-
if (this.state !== SessionState.Initial) {
|
|
245
|
-
const error = new Error(`Invalid session state ${this.state}`);
|
|
246
|
-
this.logger.error(error.message);
|
|
247
|
-
return Promise.reject(error);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Modifiers and options for initial INVITE transaction
|
|
251
|
-
if (options.sessionDescriptionHandlerModifiers) {
|
|
252
|
-
this.sessionDescriptionHandlerModifiers = options.sessionDescriptionHandlerModifiers;
|
|
253
|
-
}
|
|
254
|
-
if (options.sessionDescriptionHandlerOptions) {
|
|
255
|
-
this.sessionDescriptionHandlerOptions = options.sessionDescriptionHandlerOptions;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// transition state
|
|
259
|
-
this.stateTransition(SessionState.Establishing);
|
|
260
|
-
|
|
261
|
-
return (
|
|
262
|
-
this.sendAccept(options)
|
|
263
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
264
|
-
.then(({ message, session }) => {
|
|
265
|
-
session.delegate = {
|
|
266
|
-
onAck: (ackRequest): Promise<void> => this.onAckRequest(ackRequest),
|
|
267
|
-
onAckTimeout: (): void => this.onAckTimeout(),
|
|
268
|
-
onBye: (byeRequest): void => this.onByeRequest(byeRequest),
|
|
269
|
-
onInfo: (infoRequest): void => this.onInfoRequest(infoRequest),
|
|
270
|
-
onInvite: (inviteRequest): void => this.onInviteRequest(inviteRequest),
|
|
271
|
-
onMessage: (messageRequest): void => this.onMessageRequest(messageRequest),
|
|
272
|
-
onNotify: (notifyRequest): void => this.onNotifyRequest(notifyRequest),
|
|
273
|
-
onPrack: (prackRequest): void => this.onPrackRequest(prackRequest),
|
|
274
|
-
onRefer: (referRequest): void => this.onReferRequest(referRequest)
|
|
275
|
-
};
|
|
276
|
-
this._dialog = session;
|
|
277
|
-
this.stateTransition(SessionState.Established);
|
|
278
|
-
|
|
279
|
-
// TODO: Reconsider this "automagic" send of a BYE to replacee behavior.
|
|
280
|
-
// This behavior has been ported forward from legacy versions.
|
|
281
|
-
if (this._replacee) {
|
|
282
|
-
this._replacee._bye();
|
|
283
|
-
}
|
|
284
|
-
})
|
|
285
|
-
.catch((error) => this.handleResponseError(error))
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Indicate progress processing the invitation.
|
|
291
|
-
*
|
|
292
|
-
* @remarks
|
|
293
|
-
* Report progress to the the caller.
|
|
294
|
-
* Replies to the INVITE request with a 1xx provisional response.
|
|
295
|
-
* Resolves once the response sent, otherwise rejects.
|
|
296
|
-
* @param options - Options bucket.
|
|
297
|
-
*/
|
|
298
|
-
public progress(options: InvitationProgressOptions = {}): Promise<void> {
|
|
299
|
-
this.logger.log("Invitation.progress");
|
|
300
|
-
|
|
301
|
-
// validate state
|
|
302
|
-
if (this.state !== SessionState.Initial) {
|
|
303
|
-
const error = new Error(`Invalid session state ${this.state}`);
|
|
304
|
-
this.logger.error(error.message);
|
|
305
|
-
return Promise.reject(error);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Ported
|
|
309
|
-
const statusCode = options.statusCode || 180;
|
|
310
|
-
if (statusCode < 100 || statusCode > 199) {
|
|
311
|
-
throw new TypeError("Invalid statusCode: " + statusCode);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Modifiers and options for initial INVITE transaction
|
|
315
|
-
if (options.sessionDescriptionHandlerModifiers) {
|
|
316
|
-
this.sessionDescriptionHandlerModifiers = options.sessionDescriptionHandlerModifiers;
|
|
317
|
-
}
|
|
318
|
-
if (options.sessionDescriptionHandlerOptions) {
|
|
319
|
-
this.sessionDescriptionHandlerOptions = options.sessionDescriptionHandlerOptions;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// After the first reliable provisional response for a request has been
|
|
323
|
-
// acknowledged, the UAS MAY send additional reliable provisional
|
|
324
|
-
// responses. The UAS MUST NOT send a second reliable provisional
|
|
325
|
-
// response until the first is acknowledged. After the first, it is
|
|
326
|
-
// RECOMMENDED that the UAS not send an additional reliable provisional
|
|
327
|
-
// response until the previous is acknowledged. The first reliable
|
|
328
|
-
// provisional response receives special treatment because it conveys
|
|
329
|
-
// the initial sequence number. If additional reliable provisional
|
|
330
|
-
// responses were sent before the first was acknowledged, the UAS could
|
|
331
|
-
// not be certain these were received in order.
|
|
332
|
-
// https://tools.ietf.org/html/rfc3262#section-3
|
|
333
|
-
if (this.waitingForPrack) {
|
|
334
|
-
this.logger.warn("Unexpected call for progress while waiting for prack, ignoring");
|
|
335
|
-
return Promise.resolve();
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Trying provisional response
|
|
339
|
-
if (options.statusCode === 100) {
|
|
340
|
-
return this.sendProgressTrying()
|
|
341
|
-
.then(() => {
|
|
342
|
-
return;
|
|
343
|
-
})
|
|
344
|
-
.catch((error) => this.handleResponseError(error));
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Standard provisional response
|
|
348
|
-
if (
|
|
349
|
-
!(this.rel100 === "required") &&
|
|
350
|
-
!(this.rel100 === "supported" && options.rel100) &&
|
|
351
|
-
!(this.rel100 === "supported" && this.userAgent.configuration.sipExtension100rel === SIPExtension.Required)
|
|
352
|
-
) {
|
|
353
|
-
return this.sendProgress(options)
|
|
354
|
-
.then(() => {
|
|
355
|
-
return;
|
|
356
|
-
})
|
|
357
|
-
.catch((error) => this.handleResponseError(error));
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Reliable provisional response
|
|
361
|
-
return this.sendProgressReliableWaitForPrack(options)
|
|
362
|
-
.then(() => {
|
|
363
|
-
return;
|
|
364
|
-
})
|
|
365
|
-
.catch((error) => this.handleResponseError(error));
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Reject the invitation.
|
|
370
|
-
*
|
|
371
|
-
* @remarks
|
|
372
|
-
* Replies to the INVITE request with a 4xx, 5xx, or 6xx final response.
|
|
373
|
-
* Resolves once the response sent, otherwise rejects.
|
|
374
|
-
*
|
|
375
|
-
* The expectation is that this method is used to reject an INVITE request.
|
|
376
|
-
* That is indeed the case - a call to `progress` followed by `reject` is
|
|
377
|
-
* a typical way to "decline" an incoming INVITE request. However it may
|
|
378
|
-
* also be called after calling `accept` (but only before it completes)
|
|
379
|
-
* which will reject the call and cause `accept` to reject.
|
|
380
|
-
* @param options - Options bucket.
|
|
381
|
-
*/
|
|
382
|
-
public reject(options: InvitationRejectOptions = {}): Promise<void> {
|
|
383
|
-
this.logger.log("Invitation.reject");
|
|
384
|
-
|
|
385
|
-
// validate state
|
|
386
|
-
if (this.state !== SessionState.Initial && this.state !== SessionState.Establishing) {
|
|
387
|
-
const error = new Error(`Invalid session state ${this.state}`);
|
|
388
|
-
this.logger.error(error.message);
|
|
389
|
-
return Promise.reject(error);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
const statusCode = options.statusCode || 480;
|
|
393
|
-
|
|
394
|
-
const reasonPhrase = options.reasonPhrase ? options.reasonPhrase : getReasonPhrase(statusCode);
|
|
395
|
-
const extraHeaders = options.extraHeaders || [];
|
|
396
|
-
|
|
397
|
-
if (statusCode < 300 || statusCode > 699) {
|
|
398
|
-
throw new TypeError("Invalid statusCode: " + statusCode);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const body = options.body ? fromBodyLegacy(options.body) : undefined;
|
|
402
|
-
|
|
403
|
-
// FIXME: Need to redirect to someplace
|
|
404
|
-
statusCode < 400
|
|
405
|
-
? this.incomingInviteRequest.redirect([], { statusCode, reasonPhrase, extraHeaders, body })
|
|
406
|
-
: this.incomingInviteRequest.reject({ statusCode, reasonPhrase, extraHeaders, body });
|
|
407
|
-
|
|
408
|
-
this.stateTransition(SessionState.Terminated);
|
|
409
|
-
|
|
410
|
-
return Promise.resolve();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Handle CANCEL request.
|
|
415
|
-
*
|
|
416
|
-
* @param message - CANCEL message.
|
|
417
|
-
* @internal
|
|
418
|
-
*/
|
|
419
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
420
|
-
public _onCancel(message: IncomingRequestMessage): void {
|
|
421
|
-
this.logger.log("Invitation._onCancel");
|
|
422
|
-
|
|
423
|
-
// validate state
|
|
424
|
-
if (this.state !== SessionState.Initial && this.state !== SessionState.Establishing) {
|
|
425
|
-
this.logger.error(`CANCEL received while in state ${this.state}, dropping request`);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// flag canceled
|
|
430
|
-
this.isCanceled = true;
|
|
431
|
-
|
|
432
|
-
// reject INVITE with 487 status code
|
|
433
|
-
this.incomingInviteRequest.reject({ statusCode: 487 });
|
|
434
|
-
|
|
435
|
-
this.stateTransition(SessionState.Terminated);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Helper function to handle offer/answer in a PRACK.
|
|
440
|
-
*/
|
|
441
|
-
private handlePrackOfferAnswer(request: IncomingPrackRequest): Promise<Body | undefined> {
|
|
442
|
-
if (!this.dialog) {
|
|
443
|
-
throw new Error("Dialog undefined.");
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// If the PRACK doesn't have an offer/answer, nothing to be done.
|
|
447
|
-
const body = getBody(request.message);
|
|
448
|
-
if (!body || body.contentDisposition !== "session") {
|
|
449
|
-
return Promise.resolve(undefined);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const options = {
|
|
453
|
-
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptions,
|
|
454
|
-
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
// If the UAC receives a reliable provisional response with an offer
|
|
458
|
-
// (this would occur if the UAC sent an INVITE without an offer, in
|
|
459
|
-
// which case the first reliable provisional response will contain the
|
|
460
|
-
// offer), it MUST generate an answer in the PRACK. If the UAC receives
|
|
461
|
-
// a reliable provisional response with an answer, it MAY generate an
|
|
462
|
-
// additional offer in the PRACK. If the UAS receives a PRACK with an
|
|
463
|
-
// offer, it MUST place the answer in the 2xx to the PRACK.
|
|
464
|
-
// https://tools.ietf.org/html/rfc3262#section-5
|
|
465
|
-
switch (this.dialog.signalingState) {
|
|
466
|
-
case SignalingState.Initial:
|
|
467
|
-
// State should never be reached as first reliable provisional response must have answer/offer.
|
|
468
|
-
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
469
|
-
case SignalingState.Stable:
|
|
470
|
-
// Receved answer.
|
|
471
|
-
return this.setAnswer(body, options).then(() => undefined);
|
|
472
|
-
case SignalingState.HaveLocalOffer:
|
|
473
|
-
// State should never be reached as local offer would be answered by this PRACK
|
|
474
|
-
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
475
|
-
case SignalingState.HaveRemoteOffer:
|
|
476
|
-
// Received offer, generate answer.
|
|
477
|
-
return this.setOfferAndGetAnswer(body, options);
|
|
478
|
-
case SignalingState.Closed:
|
|
479
|
-
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
480
|
-
default:
|
|
481
|
-
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* A handler for errors which occur while attempting to send 1xx and 2xx responses.
|
|
487
|
-
* In all cases, an attempt is made to reject the request if it is still outstanding.
|
|
488
|
-
* And while there are a variety of things which can go wrong and we log something here
|
|
489
|
-
* for all errors, there are a handful of common exceptions we pay some extra attention to.
|
|
490
|
-
* @param error - The error which occurred.
|
|
491
|
-
*/
|
|
492
|
-
private handleResponseError(error: Error): void {
|
|
493
|
-
let statusCode = 480; // "Temporarily Unavailable"
|
|
494
|
-
|
|
495
|
-
// Log Error message
|
|
496
|
-
if (error instanceof Error) {
|
|
497
|
-
this.logger.error(error.message);
|
|
498
|
-
} else {
|
|
499
|
-
// We don't actually know what a session description handler implementation might throw our way,
|
|
500
|
-
// and more generally as a last resort catch all, just assume we are getting an "unknown" and log it.
|
|
501
|
-
this.logger.error((error as unknown) as string);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
// Log Exception message
|
|
505
|
-
if (error instanceof ContentTypeUnsupportedError) {
|
|
506
|
-
this.logger.error("A session description handler occurred while sending response (content type unsupported");
|
|
507
|
-
statusCode = 415; // "Unsupported Media Type"
|
|
508
|
-
} else if (error instanceof SessionDescriptionHandlerError) {
|
|
509
|
-
this.logger.error("A session description handler occurred while sending response");
|
|
510
|
-
} else if (error instanceof SessionTerminatedError) {
|
|
511
|
-
this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)");
|
|
512
|
-
} else if (error instanceof TransactionStateError) {
|
|
513
|
-
this.logger.error("Session changed state before response could be formulated and sent");
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// Reject if still in "initial" or "establishing" state.
|
|
517
|
-
if (this.state === SessionState.Initial || this.state === SessionState.Establishing) {
|
|
518
|
-
try {
|
|
519
|
-
this.incomingInviteRequest.reject({ statusCode });
|
|
520
|
-
this.stateTransition(SessionState.Terminated);
|
|
521
|
-
} catch (e) {
|
|
522
|
-
this.logger.error("An error occurred attempting to reject the request while handling another error");
|
|
523
|
-
throw e; // This is not a good place to be...
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// FIXME: TODO:
|
|
528
|
-
// Here we are squelching the throwing of errors due to an race condition.
|
|
529
|
-
// We have an internal race between calling `accept()` and handling an incoming
|
|
530
|
-
// CANCEL request. As there is no good way currently to delegate the handling of
|
|
531
|
-
// these race errors to the caller of `accept()`, we are squelching the throwing
|
|
532
|
-
// of ALL errors when/if they occur after receiving a CANCEL to catch the ONE we know
|
|
533
|
-
// is a "normal" exceptional condition. While this is a completely reasonable approach,
|
|
534
|
-
// the decision should be left up to the library user. Furthermore, as we are eating
|
|
535
|
-
// ALL errors in this case, we are potentially (likely) hiding "real" errors which occur.
|
|
536
|
-
//
|
|
537
|
-
// Only rethrow error if the session has not been canceled.
|
|
538
|
-
if (this.isCanceled) {
|
|
539
|
-
this.logger.warn(
|
|
540
|
-
"An error occurred while attempting to formulate and send a response to an incoming INVITE." +
|
|
541
|
-
" However a CANCEL was received and processed while doing so which can (and often does) result" +
|
|
542
|
-
" in errors occurring as the session terminates in the meantime. Said error is being ignored."
|
|
543
|
-
);
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
throw error;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* Callback for when ACK for a 2xx response is never received.
|
|
552
|
-
* @param session - Session the ACK never arrived for.
|
|
553
|
-
*/
|
|
554
|
-
private onAckTimeout(): void {
|
|
555
|
-
this.logger.log("Invitation.onAckTimeout");
|
|
556
|
-
if (!this.dialog) {
|
|
557
|
-
throw new Error("Dialog undefined.");
|
|
558
|
-
}
|
|
559
|
-
this.logger.log("No ACK received for an extended period of time, terminating session");
|
|
560
|
-
this.dialog.bye();
|
|
561
|
-
this.stateTransition(SessionState.Terminated);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* A version of `accept` which resolves a session when the 200 Ok response is sent.
|
|
566
|
-
* @param options - Options bucket.
|
|
567
|
-
*/
|
|
568
|
-
private sendAccept(options: InvitationAcceptOptions = {}): Promise<OutgoingResponseWithSession> {
|
|
569
|
-
const responseOptions = {
|
|
570
|
-
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptions,
|
|
571
|
-
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
const extraHeaders = options.extraHeaders || [];
|
|
575
|
-
|
|
576
|
-
// The UAS MAY send a final response to the initial request before
|
|
577
|
-
// having received PRACKs for all unacknowledged reliable provisional
|
|
578
|
-
// responses, unless the final response is 2xx and any of the
|
|
579
|
-
// unacknowledged reliable provisional responses contained a session
|
|
580
|
-
// description. In that case, it MUST NOT send a final response until
|
|
581
|
-
// those provisional responses are acknowledged. If the UAS does send a
|
|
582
|
-
// final response when reliable responses are still unacknowledged, it
|
|
583
|
-
// SHOULD NOT continue to retransmit the unacknowledged reliable
|
|
584
|
-
// provisional responses, but it MUST be prepared to process PRACK
|
|
585
|
-
// requests for those outstanding responses. A UAS MUST NOT send new
|
|
586
|
-
// reliable provisional responses (as opposed to retransmissions of
|
|
587
|
-
// unacknowledged ones) after sending a final response to a request.
|
|
588
|
-
// https://tools.ietf.org/html/rfc3262#section-3
|
|
589
|
-
if (this.waitingForPrack) {
|
|
590
|
-
return this.waitForArrivalOfPrack()
|
|
591
|
-
.then(() => clearTimeout(this.userNoAnswerTimer)) // Ported
|
|
592
|
-
.then(() => this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions))
|
|
593
|
-
.then((body) => this.incomingInviteRequest.accept({ statusCode: 200, body, extraHeaders }));
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
clearTimeout(this.userNoAnswerTimer); // Ported
|
|
597
|
-
return this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions).then((body) =>
|
|
598
|
-
this.incomingInviteRequest.accept({ statusCode: 200, body, extraHeaders })
|
|
599
|
-
);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* A version of `progress` which resolves when the provisional response is sent.
|
|
604
|
-
* @param options - Options bucket.
|
|
605
|
-
*/
|
|
606
|
-
private sendProgress(options: InvitationProgressOptions = {}): Promise<OutgoingResponseWithSession> {
|
|
607
|
-
const statusCode = options.statusCode || 180;
|
|
608
|
-
const reasonPhrase = options.reasonPhrase;
|
|
609
|
-
const extraHeaders = (options.extraHeaders || []).slice();
|
|
610
|
-
const body = options.body ? fromBodyLegacy(options.body) : undefined;
|
|
611
|
-
|
|
612
|
-
// The 183 (Session Progress) response is used to convey information
|
|
613
|
-
// about the progress of the call that is not otherwise classified. The
|
|
614
|
-
// Reason-Phrase, header fields, or message body MAY be used to convey
|
|
615
|
-
// more details about the call progress.
|
|
616
|
-
// https://tools.ietf.org/html/rfc3261#section-21.1.5
|
|
617
|
-
|
|
618
|
-
// It is the de facto industry standard to utilize 183 with SDP to provide "early media".
|
|
619
|
-
// While it is unlikely someone would want to send a 183 without SDP, so it should be an option.
|
|
620
|
-
if (statusCode === 183 && !body) {
|
|
621
|
-
return this.sendProgressWithSDP(options);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
try {
|
|
625
|
-
const progressResponse = this.incomingInviteRequest.progress({ statusCode, reasonPhrase, extraHeaders, body });
|
|
626
|
-
this._dialog = progressResponse.session;
|
|
627
|
-
return Promise.resolve(progressResponse);
|
|
628
|
-
} catch (error) {
|
|
629
|
-
return Promise.reject(error);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
/**
|
|
634
|
-
* A version of `progress` which resolves when the provisional response with sdp is sent.
|
|
635
|
-
* @param options - Options bucket.
|
|
636
|
-
*/
|
|
637
|
-
private sendProgressWithSDP(options: InvitationProgressOptions = {}): Promise<OutgoingResponseWithSession> {
|
|
638
|
-
const responseOptions = {
|
|
639
|
-
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptions,
|
|
640
|
-
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers
|
|
641
|
-
};
|
|
642
|
-
const statusCode = options.statusCode || 183;
|
|
643
|
-
const reasonPhrase = options.reasonPhrase;
|
|
644
|
-
const extraHeaders = (options.extraHeaders || []).slice();
|
|
645
|
-
|
|
646
|
-
// Get an offer/answer and send a reply.
|
|
647
|
-
return this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions)
|
|
648
|
-
.then((body) => this.incomingInviteRequest.progress({ statusCode, reasonPhrase, extraHeaders, body }))
|
|
649
|
-
.then((progressResponse) => {
|
|
650
|
-
this._dialog = progressResponse.session;
|
|
651
|
-
return progressResponse;
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* A version of `progress` which resolves when the reliable provisional response is sent.
|
|
657
|
-
* @param options - Options bucket.
|
|
658
|
-
*/
|
|
659
|
-
private sendProgressReliable(options: InvitationProgressOptions = {}): Promise<OutgoingResponseWithSession> {
|
|
660
|
-
options.extraHeaders = (options.extraHeaders || []).slice();
|
|
661
|
-
options.extraHeaders.push("Require: 100rel");
|
|
662
|
-
options.extraHeaders.push("RSeq: " + Math.floor(Math.random() * 10000));
|
|
663
|
-
return this.sendProgressWithSDP(options);
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* A version of `progress` which resolves when the reliable provisional response is acknowledged.
|
|
668
|
-
* @param options - Options bucket.
|
|
669
|
-
*/
|
|
670
|
-
private sendProgressReliableWaitForPrack(
|
|
671
|
-
options: InvitationProgressOptions = {}
|
|
672
|
-
): Promise<{
|
|
673
|
-
prackRequest: IncomingPrackRequest;
|
|
674
|
-
prackResponse: OutgoingResponse;
|
|
675
|
-
progressResponse: OutgoingResponseWithSession;
|
|
676
|
-
}> {
|
|
677
|
-
const responseOptions = {
|
|
678
|
-
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptions,
|
|
679
|
-
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers
|
|
680
|
-
};
|
|
681
|
-
const statusCode = options.statusCode || 183;
|
|
682
|
-
const reasonPhrase = options.reasonPhrase;
|
|
683
|
-
const extraHeaders: Array<string> = (options.extraHeaders || []).slice();
|
|
684
|
-
extraHeaders.push("Require: 100rel");
|
|
685
|
-
extraHeaders.push("RSeq: " + this.rseq++);
|
|
686
|
-
let body: Body | undefined;
|
|
687
|
-
|
|
688
|
-
return new Promise((resolve, reject) => {
|
|
689
|
-
this.waitingForPrack = true;
|
|
690
|
-
this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions)
|
|
691
|
-
.then((offerAnswer) => {
|
|
692
|
-
body = offerAnswer;
|
|
693
|
-
return this.incomingInviteRequest.progress({ statusCode, reasonPhrase, extraHeaders, body });
|
|
694
|
-
})
|
|
695
|
-
.then((progressResponse) => {
|
|
696
|
-
this._dialog = progressResponse.session;
|
|
697
|
-
|
|
698
|
-
let prackRequest: IncomingPrackRequest;
|
|
699
|
-
let prackResponse: OutgoingResponse;
|
|
700
|
-
progressResponse.session.delegate = {
|
|
701
|
-
onPrack: (request): void => {
|
|
702
|
-
prackRequest = request;
|
|
703
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
704
|
-
clearTimeout(prackWaitTimeoutTimer);
|
|
705
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
706
|
-
clearTimeout(rel1xxRetransmissionTimer);
|
|
707
|
-
if (!this.waitingForPrack) {
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
this.waitingForPrack = false;
|
|
711
|
-
this.handlePrackOfferAnswer(prackRequest)
|
|
712
|
-
.then((prackResponseBody) => {
|
|
713
|
-
try {
|
|
714
|
-
prackResponse = prackRequest.accept({ statusCode: 200, body: prackResponseBody });
|
|
715
|
-
this.prackArrived();
|
|
716
|
-
resolve({ prackRequest, prackResponse, progressResponse });
|
|
717
|
-
} catch (error) {
|
|
718
|
-
reject(error);
|
|
719
|
-
}
|
|
720
|
-
})
|
|
721
|
-
.catch((error: Error) => reject(error));
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
// https://tools.ietf.org/html/rfc3262#section-3
|
|
726
|
-
const prackWaitTimeout = (): void => {
|
|
727
|
-
if (!this.waitingForPrack) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
this.waitingForPrack = false;
|
|
731
|
-
this.logger.warn("No PRACK received, rejecting INVITE.");
|
|
732
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
733
|
-
clearTimeout(rel1xxRetransmissionTimer);
|
|
734
|
-
this.reject({ statusCode: 504 })
|
|
735
|
-
.then(() => reject(new SessionTerminatedError()))
|
|
736
|
-
.catch((error: Error) => reject(error));
|
|
737
|
-
};
|
|
738
|
-
const prackWaitTimeoutTimer = window.setTimeout(prackWaitTimeout, Timers.T1 * 64);
|
|
739
|
-
|
|
740
|
-
// https://tools.ietf.org/html/rfc3262#section-3
|
|
741
|
-
const rel1xxRetransmission = (): void => {
|
|
742
|
-
try {
|
|
743
|
-
this.incomingInviteRequest.progress({ statusCode, reasonPhrase, extraHeaders, body });
|
|
744
|
-
} catch (error) {
|
|
745
|
-
this.waitingForPrack = false;
|
|
746
|
-
reject(error);
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
750
|
-
rel1xxRetransmissionTimer = window.setTimeout(rel1xxRetransmission, (timeout *= 2));
|
|
751
|
-
};
|
|
752
|
-
let timeout = Timers.T1;
|
|
753
|
-
let rel1xxRetransmissionTimer = window.setTimeout(rel1xxRetransmission, timeout);
|
|
754
|
-
})
|
|
755
|
-
.catch((error: Error) => {
|
|
756
|
-
this.waitingForPrack = false;
|
|
757
|
-
reject(error);
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
/**
|
|
763
|
-
* A version of `progress` which resolves when a 100 Trying provisional response is sent.
|
|
764
|
-
*/
|
|
765
|
-
private sendProgressTrying(): Promise<OutgoingResponse> {
|
|
766
|
-
try {
|
|
767
|
-
const progressResponse = this.incomingInviteRequest.trying();
|
|
768
|
-
return Promise.resolve(progressResponse);
|
|
769
|
-
} catch (error) {
|
|
770
|
-
return Promise.reject(error);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
/**
|
|
775
|
-
* When attempting to accept the INVITE, an invitation waits
|
|
776
|
-
* for any outstanding PRACK to arrive before sending the 200 Ok.
|
|
777
|
-
* It will be waiting on this Promise to resolve which lets it know
|
|
778
|
-
* the PRACK has arrived and it may proceed to send the 200 Ok.
|
|
779
|
-
*/
|
|
780
|
-
private waitForArrivalOfPrack(): Promise<void> {
|
|
781
|
-
if (this.waitingForPrackPromise) {
|
|
782
|
-
throw new Error("Already waiting for PRACK");
|
|
783
|
-
}
|
|
784
|
-
this.waitingForPrackPromise = new Promise<void>((resolve, reject) => {
|
|
785
|
-
this.waitingForPrackResolve = resolve;
|
|
786
|
-
this.waitingForPrackReject = reject;
|
|
787
|
-
});
|
|
788
|
-
return this.waitingForPrackPromise;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* Here we are resolving the promise which in turn will cause
|
|
793
|
-
* the accept to proceed (it may still fail for other reasons, but...).
|
|
794
|
-
*/
|
|
795
|
-
private prackArrived(): void {
|
|
796
|
-
if (this.waitingForPrackResolve) {
|
|
797
|
-
this.waitingForPrackResolve();
|
|
798
|
-
}
|
|
799
|
-
this.waitingForPrackPromise = undefined;
|
|
800
|
-
this.waitingForPrackResolve = undefined;
|
|
801
|
-
this.waitingForPrackReject = undefined;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Here we are rejecting the promise which in turn will cause
|
|
806
|
-
* the accept to fail and the session to transition to "terminated".
|
|
807
|
-
*/
|
|
808
|
-
private prackNeverArrived(): void {
|
|
809
|
-
if (this.waitingForPrackReject) {
|
|
810
|
-
this.waitingForPrackReject(new SessionTerminatedError());
|
|
811
|
-
}
|
|
812
|
-
this.waitingForPrackPromise = undefined;
|
|
813
|
-
this.waitingForPrackResolve = undefined;
|
|
814
|
-
this.waitingForPrackReject = undefined;
|
|
815
|
-
}
|
|
816
|
-
}
|