ue-softphone-sdk 2.2.2 → 2.2.4
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/api/bye.d.ts +16 -0
- package/dist/api/dtmf.d.ts +15 -0
- package/dist/api/emitter.d.ts +88 -0
- package/dist/api/exceptions/content-type-unsupported.d.ts +8 -0
- package/dist/api/exceptions/index.d.ts +5 -0
- package/dist/api/exceptions/request-pending.d.ts +9 -0
- package/dist/api/exceptions/session-description-handler.d.ts +8 -0
- package/dist/api/exceptions/session-terminated.d.ts +8 -0
- package/dist/api/exceptions/state-transition.d.ts +8 -0
- package/dist/api/index.d.ts +58 -0
- package/dist/api/info.d.ts +16 -0
- package/dist/api/invitation-accept-options.d.ts +19 -0
- package/dist/api/invitation-progress-options.d.ts +38 -0
- package/dist/api/invitation-reject-options.d.ts +25 -0
- package/dist/api/invitation.d.ts +179 -0
- package/dist/api/inviter-cancel-options.d.ts +9 -0
- package/dist/api/inviter-invite-options.d.ts +28 -0
- package/dist/api/inviter-options.d.ts +43 -0
- package/dist/api/inviter.d.ts +236 -0
- package/dist/api/message.d.ts +16 -0
- package/dist/api/messager-message-options.d.ts +11 -0
- package/dist/api/messager-options.d.ts +17 -0
- package/dist/api/messager.d.ts +26 -0
- package/dist/api/notification.d.ts +16 -0
- package/dist/api/notifier.d.ts +8 -0
- package/dist/api/publisher-options.d.ts +33 -0
- package/dist/api/publisher-publish-options.d.ts +6 -0
- package/dist/api/publisher-state.d.ts +21 -0
- package/dist/api/publisher-unpublish-options.d.ts +6 -0
- package/dist/api/publisher.d.ts +65 -0
- package/dist/api/referral.d.ts +38 -0
- package/dist/api/registerer-options.d.ts +46 -0
- package/dist/api/registerer-register-options.d.ts +11 -0
- package/dist/api/registerer-state.d.ts +21 -0
- package/dist/api/registerer-unregister-options.d.ts +16 -0
- package/dist/api/registerer.d.ts +144 -0
- package/dist/api/session-bye-options.d.ts +11 -0
- package/dist/api/session-delegate.d.ts +73 -0
- package/dist/api/session-description-handler-factory.d.ts +15 -0
- package/dist/api/session-description-handler.d.ts +74 -0
- package/dist/api/session-info-options.d.ts +11 -0
- package/dist/api/session-invite-options.d.ts +28 -0
- package/dist/api/session-message-options.d.ts +11 -0
- package/dist/api/session-options.d.ts +8 -0
- package/dist/api/session-refer-options.d.ts +14 -0
- package/dist/api/session-state.d.ts +45 -0
- package/dist/api/session.d.ts +359 -0
- package/dist/api/subscriber-options.d.ts +11 -0
- package/dist/api/subscriber-subscribe-options.d.ts +6 -0
- package/dist/api/subscriber.d.ts +94 -0
- package/dist/api/subscription-delegate.d.ts +12 -0
- package/dist/api/subscription-options.d.ts +8 -0
- package/dist/api/subscription-state.d.ts +19 -0
- package/dist/api/subscription-subscribe-options.d.ts +6 -0
- package/dist/api/subscription-unsubscribe-options.d.ts +6 -0
- package/dist/api/subscription.d.ts +84 -0
- package/dist/api/transport-state.d.ts +37 -0
- package/dist/api/transport.d.ts +159 -0
- package/dist/api/user-agent-delegate.d.ts +84 -0
- package/dist/api/user-agent-options.d.ts +253 -0
- package/dist/api/user-agent-state.d.ts +14 -0
- package/dist/api/user-agent.d.ts +200 -0
- package/dist/core/dialogs/dialog-state.d.ts +34 -0
- package/dist/core/dialogs/dialog.d.ts +161 -0
- package/dist/core/dialogs/index.d.ts +4 -0
- package/dist/core/dialogs/session-dialog.d.ts +196 -0
- package/dist/core/dialogs/subscription-dialog.d.ts +120 -0
- package/dist/core/exceptions/exception.d.ts +8 -0
- package/dist/core/exceptions/index.d.ts +3 -0
- package/dist/core/exceptions/transaction-state-error.d.ts +8 -0
- package/dist/core/exceptions/transport-error.d.ts +8 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/log/index.d.ts +3 -0
- package/dist/core/log/levels.d.ts +10 -0
- package/dist/core/log/logger-factory.d.ts +21 -0
- package/dist/core/log/logger.d.ts +19 -0
- package/dist/core/messages/body.d.ts +64 -0
- package/dist/core/messages/digest-authentication.d.ts +51 -0
- package/dist/core/messages/incoming-message.d.ts +79 -0
- package/dist/core/messages/incoming-request-message.d.ts +10 -0
- package/dist/core/messages/incoming-request.d.ts +67 -0
- package/dist/core/messages/incoming-response-message.d.ts +10 -0
- package/dist/core/messages/incoming-response.d.ts +12 -0
- package/dist/core/messages/index.d.ts +13 -0
- package/dist/core/messages/md5.d.ts +32 -0
- package/dist/core/messages/methods/ack.d.ts +18 -0
- package/dist/core/messages/methods/bye.d.ts +21 -0
- package/dist/core/messages/methods/cancel.d.ts +21 -0
- package/dist/core/messages/methods/constants.d.ts +20 -0
- package/dist/core/messages/methods/index.d.ts +13 -0
- package/dist/core/messages/methods/info.d.ts +21 -0
- package/dist/core/messages/methods/invite.d.ts +86 -0
- package/dist/core/messages/methods/message.d.ts +21 -0
- package/dist/core/messages/methods/notify.d.ts +21 -0
- package/dist/core/messages/methods/prack.d.ts +21 -0
- package/dist/core/messages/methods/publish.d.ts +21 -0
- package/dist/core/messages/methods/refer.d.ts +21 -0
- package/dist/core/messages/methods/register.d.ts +21 -0
- package/dist/core/messages/methods/subscribe.d.ts +54 -0
- package/dist/core/messages/outgoing-request-message.d.ts +94 -0
- package/dist/core/messages/outgoing-request.d.ts +67 -0
- package/dist/core/messages/outgoing-response.d.ts +42 -0
- package/dist/core/messages/parser.d.ts +14 -0
- package/dist/core/messages/utils.d.ts +24 -0
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/session-delegate.d.ts +70 -0
- package/dist/core/session/session.d.ts +134 -0
- package/dist/core/subscription/index.d.ts +2 -0
- package/dist/core/subscription/subscription-delegate.d.ts +27 -0
- package/dist/core/subscription/subscription.d.ts +55 -0
- package/dist/core/timers.d.ts +20 -0
- package/dist/core/transactions/client-transaction.d.ts +45 -0
- package/dist/core/transactions/index.d.ts +10 -0
- package/dist/core/transactions/invite-client-transaction.d.ts +116 -0
- package/dist/core/transactions/invite-server-transaction.d.ts +127 -0
- package/dist/core/transactions/non-invite-client-transaction.d.ts +69 -0
- package/dist/core/transactions/non-invite-server-transaction.d.ts +57 -0
- package/dist/core/transactions/server-transaction.d.ts +35 -0
- package/dist/core/transactions/transaction-state.d.ts +13 -0
- package/dist/core/transactions/transaction-user.d.ts +72 -0
- package/dist/core/transactions/transaction.d.ts +79 -0
- package/dist/core/transport.d.ts +31 -0
- package/dist/core/user-agent-core/allowed-methods.d.ts +4 -0
- package/dist/core/user-agent-core/index.d.ts +3 -0
- package/dist/core/user-agent-core/user-agent-core-configuration.d.ts +99 -0
- package/dist/core/user-agent-core/user-agent-core-delegate.d.ts +37 -0
- package/dist/core/user-agent-core/user-agent-core.d.ts +179 -0
- package/dist/core/user-agents/bye-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/bye-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/cancel-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/index.d.ts +26 -0
- package/dist/core/user-agents/info-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/info-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/invite-user-agent-client.d.ts +35 -0
- package/dist/core/user-agents/invite-user-agent-server.d.ts +77 -0
- package/dist/core/user-agents/message-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/message-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/notify-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/notify-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/prack-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/prack-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/publish-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/re-invite-user-agent-client.d.ts +18 -0
- package/dist/core/user-agents/re-invite-user-agent-server.d.ts +41 -0
- package/dist/core/user-agents/re-subscribe-user-agent-client.d.ts +17 -0
- package/dist/core/user-agents/re-subscribe-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/refer-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/refer-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/register-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/register-user-agent-server.d.ts +11 -0
- package/dist/core/user-agents/subscribe-user-agent-client.d.ts +65 -0
- package/dist/core/user-agents/subscribe-user-agent-server.d.ts +11 -0
- package/dist/core/user-agents/user-agent-client.d.ts +103 -0
- package/dist/core/user-agents/user-agent-server.d.ts +79 -0
- package/dist/grammar/grammar.d.ts +26 -0
- package/dist/grammar/index.d.ts +4 -0
- package/dist/grammar/name-addr-header.d.ts +24 -0
- package/dist/grammar/parameters.d.ts +16 -0
- package/dist/grammar/pegjs/dist/grammar.d.ts +50 -0
- package/dist/grammar/uri.d.ts +62 -0
- package/dist/{types/index.d.ts → index.d.ts} +7 -3
- package/dist/main.d.ts +9 -0
- package/dist/new-index.d.ts +199 -0
- package/dist/platform/web/index.d.ts +4 -0
- package/dist/platform/web/modifiers/index.d.ts +5 -0
- package/dist/platform/web/modifiers/modifiers.d.ts +41 -0
- package/dist/platform/web/session-description-handler/index.d.ts +14 -0
- package/dist/platform/web/session-description-handler/media-stream-factory-default.d.ts +6 -0
- package/dist/platform/web/session-description-handler/media-stream-factory.d.ts +6 -0
- package/dist/platform/web/session-description-handler/peer-connection-configuration-default.d.ts +5 -0
- package/dist/platform/web/session-description-handler/peer-connection-delegate.d.ts +63 -0
- package/dist/platform/web/session-description-handler/session-description-handler-configuration.d.ts +16 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory-default.d.ts +11 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory-options.d.ts +9 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory.d.ts +16 -0
- package/dist/platform/web/session-description-handler/session-description-handler-options.d.ts +47 -0
- package/dist/platform/web/session-description-handler/session-description-handler.d.ts +212 -0
- package/dist/platform/web/simple-user/index.d.ts +7 -0
- package/dist/platform/web/simple-user/simple-user-delegate.d.ts +72 -0
- package/dist/platform/web/simple-user/simple-user-options.d.ts +90 -0
- package/dist/platform/web/simple-user/simple-user.d.ts +226 -0
- package/dist/platform/web/transport/index.d.ts +6 -0
- package/dist/platform/web/transport/transport-options.d.ts +30 -0
- package/dist/platform/web/transport/transport.d.ts +125 -0
- package/dist/ue-softphone-sdk.js +2 -1
- package/dist/ue-softphone-sdk.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/webPhoneSdk.d.ts +24 -0
- package/dist/webrtc.d.ts +17 -0
- package/{rollup-new.config.mjs → new-rollup.config.mjs} +1 -1
- package/package.json +6 -6
- package/rollup.config.js +15 -14
- package/src/api/api-extractor.json +358 -0
- package/src/api/bye.ts +27 -0
- package/src/api/dtmf.ts +27 -0
- package/src/api/emitter.ts +110 -0
- package/src/api/exceptions/content-type-unsupported.ts +11 -0
- package/src/api/exceptions/index.ts +5 -0
- package/src/api/exceptions/request-pending.ts +12 -0
- package/src/api/exceptions/session-description-handler.ts +11 -0
- package/src/api/exceptions/session-terminated.ts +11 -0
- package/src/api/exceptions/state-transition.ts +11 -0
- package/src/api/index.ts +58 -0
- package/src/api/info.ts +27 -0
- package/src/api/invitation-accept-options.ts +20 -0
- package/src/api/invitation-progress-options.ts +36 -0
- package/src/api/invitation-reject-options.ts +22 -0
- package/src/api/invitation.ts +816 -0
- package/src/api/inviter-cancel-options.ts +9 -0
- package/src/api/inviter-invite-options.ts +29 -0
- package/src/api/inviter-options.ts +44 -0
- package/src/api/inviter.ts +1126 -0
- package/src/api/message.ts +27 -0
- package/src/api/messager-message-options.ts +12 -0
- package/src/api/messager-options.ts +18 -0
- package/src/api/messager.ts +89 -0
- package/src/api/notification.ts +27 -0
- package/src/api/notifier.ts +7 -0
- package/src/api/publisher-options.ts +34 -0
- package/src/api/publisher-publish-options.ts +6 -0
- package/src/api/publisher-state.ts +21 -0
- package/src/api/publisher-unpublish-options.ts +6 -0
- package/src/api/publisher.ts +418 -0
- package/src/api/referral.ts +89 -0
- package/src/api/registerer-options.ts +55 -0
- package/src/api/registerer-register-options.ts +12 -0
- package/src/api/registerer-state.ts +21 -0
- package/src/api/registerer-unregister-options.ts +17 -0
- package/src/api/registerer.ts +814 -0
- package/src/api/session-bye-options.ts +12 -0
- package/src/api/session-delegate.ts +80 -0
- package/src/api/session-description-handler-factory.ts +16 -0
- package/src/api/session-description-handler.ts +89 -0
- package/src/api/session-info-options.ts +12 -0
- package/src/api/session-invite-options.ts +29 -0
- package/src/api/session-message-options.ts +12 -0
- package/src/api/session-options.ts +8 -0
- package/src/api/session-refer-options.ts +15 -0
- package/src/api/session-state.ts +45 -0
- package/src/api/session.ts +1448 -0
- package/src/api/subscriber-options.ts +12 -0
- package/src/api/subscriber-subscribe-options.ts +6 -0
- package/src/api/subscriber.ts +536 -0
- package/src/api/subscription-delegate.ts +13 -0
- package/src/api/subscription-options.ts +8 -0
- package/src/api/subscription-state.ts +19 -0
- package/src/api/subscription-subscribe-options.ts +6 -0
- package/src/api/subscription-unsubscribe-options.ts +6 -0
- package/src/api/subscription.ts +161 -0
- package/src/api/transport-state.ts +37 -0
- package/src/api/transport.ts +169 -0
- package/src/api/user-agent-delegate.ts +95 -0
- package/src/api/user-agent-options.ts +322 -0
- package/src/api/user-agent-state.ts +14 -0
- package/src/api/user-agent.ts +1014 -0
- package/src/core/api-extractor.json +358 -0
- package/src/core/dialogs/dialog-state.ts +35 -0
- package/src/core/dialogs/dialog.ts +605 -0
- package/src/core/dialogs/index.ts +4 -0
- package/src/core/dialogs/session-dialog.ts +996 -0
- package/src/core/dialogs/subscription-dialog.ts +557 -0
- package/src/core/exceptions/exception.ts +11 -0
- package/src/core/exceptions/index.ts +3 -0
- package/src/core/exceptions/transaction-state-error.ts +11 -0
- package/src/core/exceptions/transport-error.ts +11 -0
- package/src/core/index.ts +19 -0
- package/src/core/log/index.ts +3 -0
- package/src/core/log/levels.ts +10 -0
- package/src/core/log/logger-factory.ts +119 -0
- package/src/core/log/logger.ts +42 -0
- package/src/core/messages/body.ts +171 -0
- package/src/core/messages/digest-authentication.ts +190 -0
- package/src/core/messages/incoming-message.ts +152 -0
- package/src/core/messages/incoming-request-message.ts +14 -0
- package/src/core/messages/incoming-request.ts +75 -0
- package/src/core/messages/incoming-response-message.ts +14 -0
- package/src/core/messages/incoming-response.ts +13 -0
- package/src/core/messages/index.ts +18 -0
- package/src/core/messages/md5.ts +437 -0
- package/src/core/messages/methods/ack.ts +22 -0
- package/src/core/messages/methods/bye.ts +22 -0
- package/src/core/messages/methods/cancel.ts +22 -0
- package/src/core/messages/methods/constants.ts +21 -0
- package/src/core/messages/methods/index.ts +13 -0
- package/src/core/messages/methods/info.ts +22 -0
- package/src/core/messages/methods/invite.ts +104 -0
- package/src/core/messages/methods/message.ts +22 -0
- package/src/core/messages/methods/notify.ts +22 -0
- package/src/core/messages/methods/prack.ts +22 -0
- package/src/core/messages/methods/publish.ts +22 -0
- package/src/core/messages/methods/refer.ts +22 -0
- package/src/core/messages/methods/register.ts +22 -0
- package/src/core/messages/methods/subscribe.ts +59 -0
- package/src/core/messages/outgoing-request-message.ts +299 -0
- package/src/core/messages/outgoing-request.ts +77 -0
- package/src/core/messages/outgoing-response.ts +174 -0
- package/src/core/messages/parser.ts +265 -0
- package/src/core/messages/utils.ts +144 -0
- package/src/core/session/index.ts +2 -0
- package/src/core/session/session-delegate.ts +88 -0
- package/src/core/session/session.ts +158 -0
- package/src/core/subscription/index.ts +2 -0
- package/src/core/subscription/subscription-delegate.ts +30 -0
- package/src/core/subscription/subscription.ts +61 -0
- package/src/core/timers.ts +24 -0
- package/src/core/transactions/client-transaction.ts +78 -0
- package/src/core/transactions/index.ts +10 -0
- package/src/core/transactions/invite-client-transaction.ts +504 -0
- package/src/core/transactions/invite-server-transaction.ts +432 -0
- package/src/core/transactions/non-invite-client-transaction.ts +257 -0
- package/src/core/transactions/non-invite-server-transaction.ts +241 -0
- package/src/core/transactions/server-transaction.ts +47 -0
- package/src/core/transactions/transaction-state.ts +13 -0
- package/src/core/transactions/transaction-user.ts +82 -0
- package/src/core/transactions/transaction.ts +149 -0
- package/src/core/transport.ts +32 -0
- package/src/core/user-agent-core/allowed-methods.ts +19 -0
- package/src/core/user-agent-core/index.ts +3 -0
- package/src/core/user-agent-core/user-agent-core-configuration.ts +111 -0
- package/src/core/user-agent-core/user-agent-core-delegate.ts +50 -0
- package/src/core/user-agent-core/user-agent-core.ts +905 -0
- package/src/core/user-agents/bye-user-agent-client.ts +16 -0
- package/src/core/user-agents/bye-user-agent-server.ts +14 -0
- package/src/core/user-agents/cancel-user-agent-client.ts +14 -0
- package/src/core/user-agents/index.ts +26 -0
- package/src/core/user-agents/info-user-agent-client.ts +15 -0
- package/src/core/user-agents/info-user-agent-server.ts +14 -0
- package/src/core/user-agents/invite-user-agent-client.ts +405 -0
- package/src/core/user-agents/invite-user-agent-server.ts +269 -0
- package/src/core/user-agents/message-user-agent-client.ts +14 -0
- package/src/core/user-agents/message-user-agent-server.ts +14 -0
- package/src/core/user-agents/notify-user-agent-client.ts +15 -0
- package/src/core/user-agents/notify-user-agent-server.ts +30 -0
- package/src/core/user-agents/prack-user-agent-client.ts +16 -0
- package/src/core/user-agents/prack-user-agent-server.ts +37 -0
- package/src/core/user-agents/publish-user-agent-client.ts +14 -0
- package/src/core/user-agents/re-invite-user-agent-client.ts +127 -0
- package/src/core/user-agents/re-invite-user-agent-server.ts +109 -0
- package/src/core/user-agents/re-subscribe-user-agent-client.ts +78 -0
- package/src/core/user-agents/re-subscribe-user-agent-server.ts +14 -0
- package/src/core/user-agents/refer-user-agent-client.ts +15 -0
- package/src/core/user-agents/refer-user-agent-server.ts +30 -0
- package/src/core/user-agents/register-user-agent-client.ts +14 -0
- package/src/core/user-agents/register-user-agent-server.ts +14 -0
- package/src/core/user-agents/subscribe-user-agent-client.ts +341 -0
- package/src/core/user-agents/subscribe-user-agent-server.ts +14 -0
- package/src/core/user-agents/user-agent-client.ts +378 -0
- package/src/core/user-agents/user-agent-server.ts +276 -0
- package/src/grammar/grammar.ts +55 -0
- package/src/grammar/index.ts +4 -0
- package/src/grammar/name-addr-header.ts +58 -0
- package/src/grammar/parameters.ts +45 -0
- package/src/grammar/pegjs/README.md +9 -0
- package/src/grammar/pegjs/dist/grammar.ts +1557 -0
- package/src/grammar/pegjs/src/grammar.pegjs +1009 -0
- package/src/grammar/uri.ts +370 -0
- package/src/index.ts +59 -28
- package/src/lib/socket.io.esm.min.js +7 -0
- package/src/main.ts +26 -0
- package/src/new-index.ts +2478 -0
- package/src/platform/react/README.md +1 -0
- package/src/platform/web/index.ts +4 -0
- package/src/platform/web/modifiers/index.ts +5 -0
- package/src/platform/web/modifiers/modifiers.ts +180 -0
- package/src/platform/web/session-description-handler/api-extractor.json +358 -0
- package/src/platform/web/session-description-handler/index.ts +14 -0
- package/src/platform/web/session-description-handler/media-stream-factory-default.ts +22 -0
- package/src/platform/web/session-description-handler/media-stream-factory.ts +10 -0
- package/src/platform/web/session-description-handler/peer-connection-configuration-default.ts +17 -0
- package/src/platform/web/session-description-handler/peer-connection-delegate.ts +72 -0
- package/src/platform/web/session-description-handler/session-description-handler-configuration.ts +17 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory-default.ts +45 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory-options.ts +10 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory.ts +17 -0
- package/src/platform/web/session-description-handler/session-description-handler-options.ts +56 -0
- package/src/platform/web/session-description-handler/session-description-handler.ts +938 -0
- package/src/platform/web/simple-user/api-extractor.json +358 -0
- package/src/platform/web/simple-user/index.ts +7 -0
- package/src/platform/web/simple-user/simple-user-delegate.ts +82 -0
- package/src/platform/web/simple-user/simple-user-options.ts +102 -0
- package/src/platform/web/simple-user/simple-user.ts +1099 -0
- package/src/platform/web/transport/api-extractor.json +358 -0
- package/src/platform/web/transport/index.ts +6 -0
- package/src/platform/web/transport/transport-options.ts +34 -0
- package/src/platform/web/transport/transport.ts +742 -0
- package/src/version.ts +8 -0
- package/src/webPhoneSdk.ts +67 -0
- package/src/webrtc.ts +318 -0
- package/tsconfig.json +26 -10
- /package/dist/{types/config.d.ts → config.d.ts} +0 -0
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
C,
|
|
4
|
+
IncomingRequestMessage,
|
|
5
|
+
IncomingResponseMessage,
|
|
6
|
+
NameAddrHeader,
|
|
7
|
+
OutgoingRequestMessage,
|
|
8
|
+
URI
|
|
9
|
+
} from "../messages";
|
|
10
|
+
import { UserAgentCore } from "../user-agent-core";
|
|
11
|
+
import { DialogState } from "./dialog-state";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Dialog.
|
|
15
|
+
* @remarks
|
|
16
|
+
* A key concept for a user agent is that of a dialog. A dialog
|
|
17
|
+
* represents a peer-to-peer SIP relationship between two user agents
|
|
18
|
+
* that persists for some time. The dialog facilitates sequencing of
|
|
19
|
+
* messages between the user agents and proper routing of requests
|
|
20
|
+
* between both of them. The dialog represents a context in which to
|
|
21
|
+
* interpret SIP messages.
|
|
22
|
+
* https://tools.ietf.org/html/rfc3261#section-12
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export class Dialog {
|
|
26
|
+
/**
|
|
27
|
+
* Dialog constructor.
|
|
28
|
+
* @param core - User agent core.
|
|
29
|
+
* @param dialogState - Initial dialog state.
|
|
30
|
+
*/
|
|
31
|
+
protected constructor(protected core: UserAgentCore, protected dialogState: DialogState) {
|
|
32
|
+
this.core.dialogs.set(this.id, this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* When a UAC receives a response that establishes a dialog, it
|
|
37
|
+
* constructs the state of the dialog. This state MUST be maintained
|
|
38
|
+
* for the duration of the dialog.
|
|
39
|
+
* https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
40
|
+
* @param outgoingRequestMessage - Outgoing request message for dialog.
|
|
41
|
+
* @param incomingResponseMessage - Incoming response message creating dialog.
|
|
42
|
+
*/
|
|
43
|
+
public static initialDialogStateForUserAgentClient(
|
|
44
|
+
outgoingRequestMessage: OutgoingRequestMessage,
|
|
45
|
+
incomingResponseMessage: IncomingResponseMessage
|
|
46
|
+
): DialogState {
|
|
47
|
+
// If the request was sent over TLS, and the Request-URI contained a
|
|
48
|
+
// SIPS URI, the "secure" flag is set to TRUE.
|
|
49
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
50
|
+
const secure = false; // FIXME: Currently no support for TLS.
|
|
51
|
+
|
|
52
|
+
// The route set MUST be set to the list of URIs in the Record-Route
|
|
53
|
+
// header field from the response, taken in reverse order and preserving
|
|
54
|
+
// all URI parameters. If no Record-Route header field is present in
|
|
55
|
+
// the response, the route set MUST be set to the empty set. This route
|
|
56
|
+
// set, even if empty, overrides any pre-existing route set for future
|
|
57
|
+
// requests in this dialog. The remote target MUST be set to the URI
|
|
58
|
+
// from the Contact header field of the response.
|
|
59
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
60
|
+
const routeSet = incomingResponseMessage.getHeaders("record-route").reverse();
|
|
61
|
+
|
|
62
|
+
// When a UAS responds to a request with a response that establishes a
|
|
63
|
+
// dialog (such as a 2xx to INVITE), the UAS MUST copy all Record-Route
|
|
64
|
+
// header field values from the request into the response (including the
|
|
65
|
+
// URIs, URI parameters, and any Record-Route header field parameters,
|
|
66
|
+
// whether they are known or unknown to the UAS) and MUST maintain the
|
|
67
|
+
// order of those values. The UAS MUST add a Contact header field to
|
|
68
|
+
// the response.
|
|
69
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
70
|
+
const contact = incomingResponseMessage.parseHeader("contact");
|
|
71
|
+
if (!contact) {
|
|
72
|
+
// TODO: Review to make sure this will never happen
|
|
73
|
+
throw new Error("Contact undefined.");
|
|
74
|
+
}
|
|
75
|
+
if (!(contact instanceof NameAddrHeader)) {
|
|
76
|
+
throw new Error("Contact not instance of NameAddrHeader.");
|
|
77
|
+
}
|
|
78
|
+
const remoteTarget = contact.uri;
|
|
79
|
+
|
|
80
|
+
// The local sequence number MUST be set to the value of the sequence
|
|
81
|
+
// number in the CSeq header field of the request. The remote sequence
|
|
82
|
+
// number MUST be empty (it is established when the remote UA sends a
|
|
83
|
+
// request within the dialog). The call identifier component of the
|
|
84
|
+
// dialog ID MUST be set to the value of the Call-ID in the request.
|
|
85
|
+
// The local tag component of the dialog ID MUST be set to the tag in
|
|
86
|
+
// the From field in the request, and the remote tag component of the
|
|
87
|
+
// dialog ID MUST be set to the tag in the To field of the response. A
|
|
88
|
+
// UAC MUST be prepared to receive a response without a tag in the To
|
|
89
|
+
// field, in which case the tag is considered to have a value of null.
|
|
90
|
+
//
|
|
91
|
+
// This is to maintain backwards compatibility with RFC 2543, which
|
|
92
|
+
// did not mandate To tags.
|
|
93
|
+
//
|
|
94
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
95
|
+
const localSequenceNumber = outgoingRequestMessage.cseq;
|
|
96
|
+
const remoteSequenceNumber = undefined;
|
|
97
|
+
const callId = outgoingRequestMessage.callId;
|
|
98
|
+
const localTag = outgoingRequestMessage.fromTag;
|
|
99
|
+
const remoteTag = incomingResponseMessage.toTag;
|
|
100
|
+
if (!callId) {
|
|
101
|
+
// TODO: Review to make sure this will never happen
|
|
102
|
+
throw new Error("Call id undefined.");
|
|
103
|
+
}
|
|
104
|
+
if (!localTag) {
|
|
105
|
+
// TODO: Review to make sure this will never happen
|
|
106
|
+
throw new Error("From tag undefined.");
|
|
107
|
+
}
|
|
108
|
+
if (!remoteTag) {
|
|
109
|
+
// TODO: Review to make sure this will never happen
|
|
110
|
+
throw new Error("To tag undefined."); // FIXME: No backwards compatibility with RFC 2543
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// The remote URI MUST be set to the URI in the To field, and the local
|
|
114
|
+
// URI MUST be set to the URI in the From field.
|
|
115
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
116
|
+
if (!outgoingRequestMessage.from) {
|
|
117
|
+
// TODO: Review to make sure this will never happen
|
|
118
|
+
throw new Error("From undefined.");
|
|
119
|
+
}
|
|
120
|
+
if (!outgoingRequestMessage.to) {
|
|
121
|
+
// TODO: Review to make sure this will never happen
|
|
122
|
+
throw new Error("To undefined.");
|
|
123
|
+
}
|
|
124
|
+
const localURI = outgoingRequestMessage.from.uri;
|
|
125
|
+
const remoteURI = outgoingRequestMessage.to.uri;
|
|
126
|
+
|
|
127
|
+
// A dialog can also be in the "early" state, which occurs when it is
|
|
128
|
+
// created with a provisional response, and then transition to the
|
|
129
|
+
// "confirmed" state when a 2xx final response arrives.
|
|
130
|
+
// https://tools.ietf.org/html/rfc3261#section-12
|
|
131
|
+
if (!incomingResponseMessage.statusCode) {
|
|
132
|
+
throw new Error("Incoming response status code undefined.");
|
|
133
|
+
}
|
|
134
|
+
const early = incomingResponseMessage.statusCode < 200 ? true : false;
|
|
135
|
+
|
|
136
|
+
const dialogState: DialogState = {
|
|
137
|
+
id: callId + localTag + remoteTag,
|
|
138
|
+
early,
|
|
139
|
+
callId,
|
|
140
|
+
localTag,
|
|
141
|
+
remoteTag,
|
|
142
|
+
localSequenceNumber,
|
|
143
|
+
remoteSequenceNumber,
|
|
144
|
+
localURI,
|
|
145
|
+
remoteURI,
|
|
146
|
+
remoteTarget,
|
|
147
|
+
routeSet,
|
|
148
|
+
secure
|
|
149
|
+
};
|
|
150
|
+
return dialogState;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The UAS then constructs the state of the dialog. This state MUST be
|
|
155
|
+
* maintained for the duration of the dialog.
|
|
156
|
+
* https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
157
|
+
* @param incomingRequestMessage - Incoming request message creating dialog.
|
|
158
|
+
* @param toTag - Tag in the To field in the response to the incoming request.
|
|
159
|
+
*/
|
|
160
|
+
public static initialDialogStateForUserAgentServer(
|
|
161
|
+
incomingRequestMessage: IncomingRequestMessage,
|
|
162
|
+
toTag: string,
|
|
163
|
+
early = false
|
|
164
|
+
): DialogState {
|
|
165
|
+
// If the request arrived over TLS, and the Request-URI contained a SIPS
|
|
166
|
+
// URI, the "secure" flag is set to TRUE.
|
|
167
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
168
|
+
const secure = false; // FIXME: Currently no support for TLS.
|
|
169
|
+
|
|
170
|
+
// The route set MUST be set to the list of URIs in the Record-Route
|
|
171
|
+
// header field from the request, taken in order and preserving all URI
|
|
172
|
+
// parameters. If no Record-Route header field is present in the
|
|
173
|
+
// request, the route set MUST be set to the empty set. This route set,
|
|
174
|
+
// even if empty, overrides any pre-existing route set for future
|
|
175
|
+
// requests in this dialog. The remote target MUST be set to the URI
|
|
176
|
+
// from the Contact header field of the request.
|
|
177
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
178
|
+
const routeSet = incomingRequestMessage.getHeaders("record-route");
|
|
179
|
+
const contact = incomingRequestMessage.parseHeader("contact");
|
|
180
|
+
if (!contact) {
|
|
181
|
+
// TODO: Review to make sure this will never happen
|
|
182
|
+
throw new Error("Contact undefined.");
|
|
183
|
+
}
|
|
184
|
+
if (!(contact instanceof NameAddrHeader)) {
|
|
185
|
+
throw new Error("Contact not instance of NameAddrHeader.");
|
|
186
|
+
}
|
|
187
|
+
const remoteTarget = contact.uri;
|
|
188
|
+
|
|
189
|
+
// The remote sequence number MUST be set to the value of the sequence
|
|
190
|
+
// number in the CSeq header field of the request. The local sequence
|
|
191
|
+
// number MUST be empty. The call identifier component of the dialog ID
|
|
192
|
+
// MUST be set to the value of the Call-ID in the request. The local
|
|
193
|
+
// tag component of the dialog ID MUST be set to the tag in the To field
|
|
194
|
+
// in the response to the request (which always includes a tag), and the
|
|
195
|
+
// remote tag component of the dialog ID MUST be set to the tag from the
|
|
196
|
+
// From field in the request. A UAS MUST be prepared to receive a
|
|
197
|
+
// request without a tag in the From field, in which case the tag is
|
|
198
|
+
// considered to have a value of null.
|
|
199
|
+
//
|
|
200
|
+
// This is to maintain backwards compatibility with RFC 2543, which
|
|
201
|
+
// did not mandate From tags.
|
|
202
|
+
//
|
|
203
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
204
|
+
const remoteSequenceNumber = incomingRequestMessage.cseq;
|
|
205
|
+
const localSequenceNumber = undefined;
|
|
206
|
+
const callId = incomingRequestMessage.callId;
|
|
207
|
+
const localTag = toTag;
|
|
208
|
+
const remoteTag = incomingRequestMessage.fromTag;
|
|
209
|
+
|
|
210
|
+
// The remote URI MUST be set to the URI in the From field, and the
|
|
211
|
+
// local URI MUST be set to the URI in the To field.
|
|
212
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.1
|
|
213
|
+
const remoteURI = incomingRequestMessage.from.uri;
|
|
214
|
+
const localURI = incomingRequestMessage.to.uri;
|
|
215
|
+
|
|
216
|
+
const dialogState: DialogState = {
|
|
217
|
+
id: callId + localTag + remoteTag,
|
|
218
|
+
early,
|
|
219
|
+
callId,
|
|
220
|
+
localTag,
|
|
221
|
+
remoteTag,
|
|
222
|
+
localSequenceNumber,
|
|
223
|
+
remoteSequenceNumber,
|
|
224
|
+
localURI,
|
|
225
|
+
remoteURI,
|
|
226
|
+
remoteTarget,
|
|
227
|
+
routeSet,
|
|
228
|
+
secure
|
|
229
|
+
};
|
|
230
|
+
return dialogState;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Destructor. */
|
|
234
|
+
public dispose(): void {
|
|
235
|
+
this.core.dialogs.delete(this.id);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A dialog is identified at each UA with a dialog ID, which consists of
|
|
240
|
+
* a Call-ID value, a local tag and a remote tag. The dialog ID at each
|
|
241
|
+
* UA involved in the dialog is not the same. Specifically, the local
|
|
242
|
+
* tag at one UA is identical to the remote tag at the peer UA. The
|
|
243
|
+
* tags are opaque tokens that facilitate the generation of unique
|
|
244
|
+
* dialog IDs.
|
|
245
|
+
* https://tools.ietf.org/html/rfc3261#section-12
|
|
246
|
+
*/
|
|
247
|
+
public get id(): string {
|
|
248
|
+
return this.dialogState.id;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* A dialog can also be in the "early" state, which occurs when it is
|
|
253
|
+
* created with a provisional response, and then it transition to the
|
|
254
|
+
* "confirmed" state when a 2xx final response received or is sent.
|
|
255
|
+
*
|
|
256
|
+
* Note: RFC 3261 is concise on when a dialog is "confirmed", but it
|
|
257
|
+
* can be a point of confusion if an INVITE dialog is "confirmed" after
|
|
258
|
+
* a 2xx is sent or after receiving the ACK for the 2xx response.
|
|
259
|
+
* With careful reading it can be inferred a dialog is always is
|
|
260
|
+
* "confirmed" when the 2xx is sent (regardless of type of dialog).
|
|
261
|
+
* However a INVITE dialog does have additional considerations
|
|
262
|
+
* when it is confirmed but an ACK has not yet been received (in
|
|
263
|
+
* particular with regard to a callee sending BYE requests).
|
|
264
|
+
*/
|
|
265
|
+
public get early(): boolean {
|
|
266
|
+
return this.dialogState.early;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Call identifier component of the dialog id. */
|
|
270
|
+
public get callId(): string {
|
|
271
|
+
return this.dialogState.callId;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Local tag component of the dialog id. */
|
|
275
|
+
public get localTag(): string {
|
|
276
|
+
return this.dialogState.localTag;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Remote tag component of the dialog id. */
|
|
280
|
+
public get remoteTag(): string {
|
|
281
|
+
return this.dialogState.remoteTag;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Local sequence number (used to order requests from the UA to its peer). */
|
|
285
|
+
public get localSequenceNumber(): number | undefined {
|
|
286
|
+
return this.dialogState.localSequenceNumber;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Remote sequence number (used to order requests from its peer to the UA). */
|
|
290
|
+
public get remoteSequenceNumber(): number | undefined {
|
|
291
|
+
return this.dialogState.remoteSequenceNumber;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** Local URI. */
|
|
295
|
+
public get localURI(): URI {
|
|
296
|
+
return this.dialogState.localURI;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** Remote URI. */
|
|
300
|
+
public get remoteURI(): URI {
|
|
301
|
+
return this.dialogState.remoteURI;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Remote target. */
|
|
305
|
+
public get remoteTarget(): URI {
|
|
306
|
+
return this.dialogState.remoteTarget;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Route set, which is an ordered list of URIs. The route set is the
|
|
311
|
+
* list of servers that need to be traversed to send a request to the peer.
|
|
312
|
+
*/
|
|
313
|
+
public get routeSet(): Array<string> {
|
|
314
|
+
return this.dialogState.routeSet;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* If the request was sent over TLS, and the Request-URI contained
|
|
319
|
+
* a SIPS URI, the "secure" flag is set to true. *NOT IMPLEMENTED*
|
|
320
|
+
*/
|
|
321
|
+
public get secure(): boolean {
|
|
322
|
+
return this.dialogState.secure;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** The user agent core servicing this dialog. */
|
|
326
|
+
public get userAgentCore(): UserAgentCore {
|
|
327
|
+
return this.core;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Confirm the dialog. Only matters if dialog is currently early. */
|
|
331
|
+
public confirm(): void {
|
|
332
|
+
this.dialogState.early = false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Requests sent within a dialog, as any other requests, are atomic. If
|
|
337
|
+
* a particular request is accepted by the UAS, all the state changes
|
|
338
|
+
* associated with it are performed. If the request is rejected, none
|
|
339
|
+
* of the state changes are performed.
|
|
340
|
+
*
|
|
341
|
+
* Note that some requests, such as INVITEs, affect several pieces of
|
|
342
|
+
* state.
|
|
343
|
+
*
|
|
344
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
345
|
+
* @param message - Incoming request message within this dialog.
|
|
346
|
+
*/
|
|
347
|
+
public receiveRequest(message: IncomingRequestMessage): void {
|
|
348
|
+
// ACK guard.
|
|
349
|
+
// By convention, the handling of ACKs is the responsibility
|
|
350
|
+
// the particular dialog implementation. For example, see SessionDialog.
|
|
351
|
+
// Furthermore, ACKs have same sequence number as the associated INVITE.
|
|
352
|
+
if (message.method === C.ACK) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// If the remote sequence number was not empty, but the sequence number
|
|
357
|
+
// of the request is lower than the remote sequence number, the request
|
|
358
|
+
// is out of order and MUST be rejected with a 500 (Server Internal
|
|
359
|
+
// Error) response. If the remote sequence number was not empty, and
|
|
360
|
+
// the sequence number of the request is greater than the remote
|
|
361
|
+
// sequence number, the request is in order. It is possible for the
|
|
362
|
+
// CSeq sequence number to be higher than the remote sequence number by
|
|
363
|
+
// more than one. This is not an error condition, and a UAS SHOULD be
|
|
364
|
+
// prepared to receive and process requests with CSeq values more than
|
|
365
|
+
// one higher than the previous received request. The UAS MUST then set
|
|
366
|
+
// the remote sequence number to the value of the sequence number in the
|
|
367
|
+
// CSeq header field value in the request.
|
|
368
|
+
//
|
|
369
|
+
// If a proxy challenges a request generated by the UAC, the UAC has
|
|
370
|
+
// to resubmit the request with credentials. The resubmitted request
|
|
371
|
+
// will have a new CSeq number. The UAS will never see the first
|
|
372
|
+
// request, and thus, it will notice a gap in the CSeq number space.
|
|
373
|
+
// Such a gap does not represent any error condition.
|
|
374
|
+
//
|
|
375
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
376
|
+
if (this.remoteSequenceNumber) {
|
|
377
|
+
if (message.cseq <= this.remoteSequenceNumber) {
|
|
378
|
+
throw new Error("Out of sequence in dialog request. Did you forget to call sequenceGuard()?");
|
|
379
|
+
}
|
|
380
|
+
this.dialogState.remoteSequenceNumber = message.cseq;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// If the remote sequence number is empty, it MUST be set to the value
|
|
384
|
+
// of the sequence number in the CSeq header field value in the request.
|
|
385
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
386
|
+
if (!this.remoteSequenceNumber) {
|
|
387
|
+
this.dialogState.remoteSequenceNumber = message.cseq;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// When a UAS receives a target refresh request, it MUST replace the
|
|
391
|
+
// dialog's remote target URI with the URI from the Contact header field
|
|
392
|
+
// in that request, if present.
|
|
393
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
394
|
+
// Note: "target refresh request" processing delegated to sub-class.
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* If the dialog identifier in the 2xx response matches the dialog
|
|
399
|
+
* identifier of an existing dialog, the dialog MUST be transitioned to
|
|
400
|
+
* the "confirmed" state, and the route set for the dialog MUST be
|
|
401
|
+
* recomputed based on the 2xx response using the procedures of Section
|
|
402
|
+
* 12.2.1.2. Otherwise, a new dialog in the "confirmed" state MUST be
|
|
403
|
+
* constructed using the procedures of Section 12.1.2.
|
|
404
|
+
*
|
|
405
|
+
* Note that the only piece of state that is recomputed is the route
|
|
406
|
+
* set. Other pieces of state such as the highest sequence numbers
|
|
407
|
+
* (remote and local) sent within the dialog are not recomputed. The
|
|
408
|
+
* route set only is recomputed for backwards compatibility. RFC
|
|
409
|
+
* 2543 did not mandate mirroring of the Record-Route header field in
|
|
410
|
+
* a 1xx, only 2xx. However, we cannot update the entire state of
|
|
411
|
+
* the dialog, since mid-dialog requests may have been sent within
|
|
412
|
+
* the early dialog, modifying the sequence numbers, for example.
|
|
413
|
+
*
|
|
414
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.2.4
|
|
415
|
+
*/
|
|
416
|
+
public recomputeRouteSet(message: IncomingResponseMessage): void {
|
|
417
|
+
this.dialogState.routeSet = message.getHeaders("record-route").reverse();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* A request within a dialog is constructed by using many of the
|
|
422
|
+
* components of the state stored as part of the dialog.
|
|
423
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2.1.1
|
|
424
|
+
* @param method - Outgoing request method.
|
|
425
|
+
*/
|
|
426
|
+
public createOutgoingRequestMessage(
|
|
427
|
+
method: string,
|
|
428
|
+
options?: {
|
|
429
|
+
cseq?: number;
|
|
430
|
+
extraHeaders?: Array<string>;
|
|
431
|
+
body?: Body;
|
|
432
|
+
}
|
|
433
|
+
): OutgoingRequestMessage {
|
|
434
|
+
// The URI in the To field of the request MUST be set to the remote URI
|
|
435
|
+
// from the dialog state. The tag in the To header field of the request
|
|
436
|
+
// MUST be set to the remote tag of the dialog ID. The From URI of the
|
|
437
|
+
// request MUST be set to the local URI from the dialog state. The tag
|
|
438
|
+
// in the From header field of the request MUST be set to the local tag
|
|
439
|
+
// of the dialog ID. If the value of the remote or local tags is null,
|
|
440
|
+
// the tag parameter MUST be omitted from the To or From header fields,
|
|
441
|
+
// respectively.
|
|
442
|
+
//
|
|
443
|
+
// Usage of the URI from the To and From fields in the original
|
|
444
|
+
// request within subsequent requests is done for backwards
|
|
445
|
+
// compatibility with RFC 2543, which used the URI for dialog
|
|
446
|
+
// identification. In this specification, only the tags are used for
|
|
447
|
+
// dialog identification. It is expected that mandatory reflection
|
|
448
|
+
// of the original To and From URI in mid-dialog requests will be
|
|
449
|
+
// deprecated in a subsequent revision of this specification.
|
|
450
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.1.1
|
|
451
|
+
const toUri = this.remoteURI;
|
|
452
|
+
const toTag = this.remoteTag;
|
|
453
|
+
const fromUri = this.localURI;
|
|
454
|
+
const fromTag = this.localTag;
|
|
455
|
+
|
|
456
|
+
// The Call-ID of the request MUST be set to the Call-ID of the dialog.
|
|
457
|
+
// Requests within a dialog MUST contain strictly monotonically
|
|
458
|
+
// increasing and contiguous CSeq sequence numbers (increasing-by-one)
|
|
459
|
+
// in each direction (excepting ACK and CANCEL of course, whose numbers
|
|
460
|
+
// equal the requests being acknowledged or cancelled). Therefore, if
|
|
461
|
+
// the local sequence number is not empty, the value of the local
|
|
462
|
+
// sequence number MUST be incremented by one, and this value MUST be
|
|
463
|
+
// placed into the CSeq header field. If the local sequence number is
|
|
464
|
+
// empty, an initial value MUST be chosen using the guidelines of
|
|
465
|
+
// Section 8.1.1.5. The method field in the CSeq header field value
|
|
466
|
+
// MUST match the method of the request.
|
|
467
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.1.1
|
|
468
|
+
const callId = this.callId;
|
|
469
|
+
let cseq: number;
|
|
470
|
+
if (options && options.cseq) {
|
|
471
|
+
cseq = options.cseq;
|
|
472
|
+
} else if (!this.dialogState.localSequenceNumber) {
|
|
473
|
+
cseq = this.dialogState.localSequenceNumber = 1; // https://tools.ietf.org/html/rfc3261#section-8.1.1.5
|
|
474
|
+
} else {
|
|
475
|
+
cseq = this.dialogState.localSequenceNumber += 1;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// The UAC uses the remote target and route set to build the Request-URI
|
|
479
|
+
// and Route header field of the request.
|
|
480
|
+
//
|
|
481
|
+
// If the route set is empty, the UAC MUST place the remote target URI
|
|
482
|
+
// into the Request-URI. The UAC MUST NOT add a Route header field to
|
|
483
|
+
// the request.
|
|
484
|
+
//
|
|
485
|
+
// If the route set is not empty, and the first URI in the route set
|
|
486
|
+
// contains the lr parameter (see Section 19.1.1), the UAC MUST place
|
|
487
|
+
// the remote target URI into the Request-URI and MUST include a Route
|
|
488
|
+
// header field containing the route set values in order, including all
|
|
489
|
+
// parameters.
|
|
490
|
+
//
|
|
491
|
+
// If the route set is not empty, and its first URI does not contain the
|
|
492
|
+
// lr parameter, the UAC MUST place the first URI from the route set
|
|
493
|
+
// into the Request-URI, stripping any parameters that are not allowed
|
|
494
|
+
// in a Request-URI. The UAC MUST add a Route header field containing
|
|
495
|
+
// the remainder of the route set values in order, including all
|
|
496
|
+
// parameters. The UAC MUST then place the remote target URI into the
|
|
497
|
+
// Route header field as the last value.
|
|
498
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.1.1
|
|
499
|
+
|
|
500
|
+
// The lr parameter, when present, indicates that the element
|
|
501
|
+
// responsible for this resource implements the routing mechanisms
|
|
502
|
+
// specified in this document. This parameter will be used in the
|
|
503
|
+
// URIs proxies place into Record-Route header field values, and
|
|
504
|
+
// may appear in the URIs in a pre-existing route set.
|
|
505
|
+
//
|
|
506
|
+
// This parameter is used to achieve backwards compatibility with
|
|
507
|
+
// systems implementing the strict-routing mechanisms of RFC 2543
|
|
508
|
+
// and the rfc2543bis drafts up to bis-05. An element preparing
|
|
509
|
+
// to send a request based on a URI not containing this parameter
|
|
510
|
+
// can assume the receiving element implements strict-routing and
|
|
511
|
+
// reformat the message to preserve the information in the
|
|
512
|
+
// Request-URI.
|
|
513
|
+
// https://tools.ietf.org/html/rfc3261#section-19.1.1
|
|
514
|
+
|
|
515
|
+
// NOTE: Not backwards compatible with RFC 2543 (no support for strict-routing).
|
|
516
|
+
const ruri = this.remoteTarget;
|
|
517
|
+
const routeSet = this.routeSet;
|
|
518
|
+
|
|
519
|
+
const extraHeaders = options && options.extraHeaders;
|
|
520
|
+
const body = options && options.body;
|
|
521
|
+
|
|
522
|
+
// The relative order of header fields with different field names is not
|
|
523
|
+
// significant. However, it is RECOMMENDED that header fields which are
|
|
524
|
+
// needed for proxy processing (Via, Route, Record-Route, Proxy-Require,
|
|
525
|
+
// Max-Forwards, and Proxy-Authorization, for example) appear towards
|
|
526
|
+
// the top of the message to facilitate rapid parsing.
|
|
527
|
+
// https://tools.ietf.org/html/rfc3261#section-7.3.1
|
|
528
|
+
const message = this.userAgentCore.makeOutgoingRequestMessage(
|
|
529
|
+
method,
|
|
530
|
+
ruri,
|
|
531
|
+
fromUri,
|
|
532
|
+
toUri,
|
|
533
|
+
{
|
|
534
|
+
callId,
|
|
535
|
+
cseq,
|
|
536
|
+
fromTag,
|
|
537
|
+
toTag,
|
|
538
|
+
routeSet
|
|
539
|
+
},
|
|
540
|
+
extraHeaders,
|
|
541
|
+
body
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
return message;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Increment the local sequence number by one.
|
|
549
|
+
* It feels like this should be protected, but the current authentication handling currently
|
|
550
|
+
* needs this to keep the dialog in sync when "auto re-sends" request messages.
|
|
551
|
+
* @internal
|
|
552
|
+
*/
|
|
553
|
+
public incrementLocalSequenceNumber(): void {
|
|
554
|
+
if (!this.dialogState.localSequenceNumber) {
|
|
555
|
+
throw new Error("Local sequence number undefined.");
|
|
556
|
+
}
|
|
557
|
+
this.dialogState.localSequenceNumber += 1;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* If the remote sequence number was not empty, but the sequence number
|
|
562
|
+
* of the request is lower than the remote sequence number, the request
|
|
563
|
+
* is out of order and MUST be rejected with a 500 (Server Internal
|
|
564
|
+
* Error) response.
|
|
565
|
+
* https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
566
|
+
* @param request - Incoming request to guard.
|
|
567
|
+
* @returns True if the program execution is to continue in the branch in question.
|
|
568
|
+
* Otherwise a 500 Server Internal Error was stateless sent and request processing must stop.
|
|
569
|
+
*/
|
|
570
|
+
protected sequenceGuard(message: IncomingRequestMessage): boolean {
|
|
571
|
+
// ACK guard.
|
|
572
|
+
// By convention, handling of unexpected ACKs is responsibility
|
|
573
|
+
// the particular dialog implementation. For example, see SessionDialog.
|
|
574
|
+
// Furthermore, we cannot reply to an "out of sequence" ACK.
|
|
575
|
+
if (message.method === C.ACK) {
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Note: We are rejecting on "less than or equal to" the remote
|
|
580
|
+
// sequence number (excepting ACK whose numbers equal the requests
|
|
581
|
+
// being acknowledged or cancelled), which is the correct thing to
|
|
582
|
+
// do in our case. The only time a request with the same sequence number
|
|
583
|
+
// will show up here if is a) it is a very late retransmission of a
|
|
584
|
+
// request we already handled or b) it is a different request with the
|
|
585
|
+
// same sequence number which would be violation of the standard.
|
|
586
|
+
// Request retransmissions are absorbed by the transaction layer,
|
|
587
|
+
// so any request with a duplicate sequence number getting here
|
|
588
|
+
// would have to be a retransmission after the transaction terminated
|
|
589
|
+
// or a broken request (with unique via branch value).
|
|
590
|
+
|
|
591
|
+
// Requests within a dialog MUST contain strictly monotonically
|
|
592
|
+
// increasing and contiguous CSeq sequence numbers (increasing-by-one)
|
|
593
|
+
// in each direction (excepting ACK and CANCEL of course, whose numbers
|
|
594
|
+
// equal the requests being acknowledged or cancelled). Therefore, if
|
|
595
|
+
// the local sequence number is not empty, the value of the local
|
|
596
|
+
// sequence number MUST be incremented by one, and this value MUST be
|
|
597
|
+
// placed into the CSeq header field.
|
|
598
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.1.1
|
|
599
|
+
if (this.remoteSequenceNumber && message.cseq <= this.remoteSequenceNumber) {
|
|
600
|
+
this.core.replyStateless(message, { statusCode: 500 });
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
return true;
|
|
604
|
+
}
|
|
605
|
+
}
|