ue-softphone-sdk 2.2.3 → 2.2.5
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 +49 -26
- package/src/lib/socket.io.esm.min.js +7 -0
- package/src/main.ts +26 -0
- package/src/new-index.ts +2486 -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,174 @@
|
|
|
1
|
+
import { Body } from "./body";
|
|
2
|
+
import { IncomingRequestMessage } from "./incoming-request-message";
|
|
3
|
+
import { getReasonPhrase, newTag, utf8Length } from "./utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A SIP message sent from a local server to a remote client.
|
|
7
|
+
* @remarks
|
|
8
|
+
* For indicating the status of a request sent from the client to the server.
|
|
9
|
+
* https://tools.ietf.org/html/rfc3261#section-7.2
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface OutgoingResponse {
|
|
13
|
+
/** The outgoing message. */
|
|
14
|
+
readonly message: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Response options bucket.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface ResponseOptions {
|
|
22
|
+
/** Status code of the response. */
|
|
23
|
+
statusCode: number;
|
|
24
|
+
/** Reason phrase of the response. */
|
|
25
|
+
reasonPhrase?: string;
|
|
26
|
+
/** To tag of the response. If not provided, one is generated. */
|
|
27
|
+
toTag?: string;
|
|
28
|
+
/** User agent string for User-Agent header. */
|
|
29
|
+
userAgent?: string;
|
|
30
|
+
/** Support options tags for Supported header. */
|
|
31
|
+
supported?: Array<string>;
|
|
32
|
+
/** Extra headers to include in the message. */
|
|
33
|
+
extraHeaders?: Array<string>;
|
|
34
|
+
/** Body to include in the message. */
|
|
35
|
+
body?: Body;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* When a UAS wishes to construct a response to a request, it follows
|
|
40
|
+
* the general procedures detailed in the following subsections.
|
|
41
|
+
* Additional behaviors specific to the response code in question, which
|
|
42
|
+
* are not detailed in this section, may also be required.
|
|
43
|
+
* https://tools.ietf.org/html/rfc3261#section-8.2.6
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export function constructOutgoingResponse(message: IncomingRequestMessage, options: ResponseOptions): OutgoingResponse {
|
|
47
|
+
const CRLF = "\r\n";
|
|
48
|
+
|
|
49
|
+
if (options.statusCode < 100 || options.statusCode > 699) {
|
|
50
|
+
throw new TypeError("Invalid statusCode: " + options.statusCode);
|
|
51
|
+
}
|
|
52
|
+
const reasonPhrase = options.reasonPhrase ? options.reasonPhrase : getReasonPhrase(options.statusCode);
|
|
53
|
+
|
|
54
|
+
// SIP responses are distinguished from requests by having a Status-Line
|
|
55
|
+
// as their start-line. A Status-Line consists of the protocol version
|
|
56
|
+
// followed by a numeric Status-Code and its associated textual phrase,
|
|
57
|
+
// with each element separated by a single SP character.
|
|
58
|
+
// https://tools.ietf.org/html/rfc3261#section-7.2
|
|
59
|
+
let response = "SIP/2.0 " + options.statusCode + " " + reasonPhrase + CRLF;
|
|
60
|
+
|
|
61
|
+
// One largely non-method-specific guideline for the generation of
|
|
62
|
+
// responses is that UASs SHOULD NOT issue a provisional response for a
|
|
63
|
+
// non-INVITE request. Rather, UASs SHOULD generate a final response to
|
|
64
|
+
// a non-INVITE request as soon as possible.
|
|
65
|
+
// https://tools.ietf.org/html/rfc3261#section-8.2.6.1
|
|
66
|
+
if (options.statusCode >= 100 && options.statusCode < 200) {
|
|
67
|
+
// TODO
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// When a 100 (Trying) response is generated, any Timestamp header field
|
|
71
|
+
// present in the request MUST be copied into this 100 (Trying)
|
|
72
|
+
// response. If there is a delay in generating the response, the UAS
|
|
73
|
+
// SHOULD add a delay value into the Timestamp value in the response.
|
|
74
|
+
// This value MUST contain the difference between the time of sending of
|
|
75
|
+
// the response and receipt of the request, measured in seconds.
|
|
76
|
+
// https://tools.ietf.org/html/rfc3261#section-8.2.6.1
|
|
77
|
+
if (options.statusCode === 100) {
|
|
78
|
+
// TODO
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The From field of the response MUST equal the From header field of
|
|
82
|
+
// the request. The Call-ID header field of the response MUST equal the
|
|
83
|
+
// Call-ID header field of the request. The CSeq header field of the
|
|
84
|
+
// response MUST equal the CSeq field of the request. The Via header
|
|
85
|
+
// field values in the response MUST equal the Via header field values
|
|
86
|
+
// in the request and MUST maintain the same ordering.
|
|
87
|
+
// https://tools.ietf.org/html/rfc3261#section-8.2.6.2
|
|
88
|
+
const fromHeader = "From: " + message.getHeader("From") + CRLF;
|
|
89
|
+
const callIdHeader = "Call-ID: " + message.callId + CRLF;
|
|
90
|
+
const cSeqHeader = "CSeq: " + message.cseq + " " + message.method + CRLF;
|
|
91
|
+
const viaHeaders = message.getHeaders("via").reduce((previous, current) => {
|
|
92
|
+
return previous + "Via: " + current + CRLF;
|
|
93
|
+
}, "");
|
|
94
|
+
|
|
95
|
+
// If a request contained a To tag in the request, the To header field
|
|
96
|
+
// in the response MUST equal that of the request. However, if the To
|
|
97
|
+
// header field in the request did not contain a tag, the URI in the To
|
|
98
|
+
// header field in the response MUST equal the URI in the To header
|
|
99
|
+
// field; additionally, the UAS MUST add a tag to the To header field in
|
|
100
|
+
// the response (with the exception of the 100 (Trying) response, in
|
|
101
|
+
// which a tag MAY be present). This serves to identify the UAS that is
|
|
102
|
+
// responding, possibly resulting in a component of a dialog ID. The
|
|
103
|
+
// same tag MUST be used for all responses to that request, both final
|
|
104
|
+
// and provisional (again excepting the 100 (Trying)).
|
|
105
|
+
// https://tools.ietf.org/html/rfc3261#section-8.2.6.2
|
|
106
|
+
let toHeader = "To: " + message.getHeader("to");
|
|
107
|
+
if (options.statusCode > 100 && !message.parseHeader("to").hasParam("tag")) {
|
|
108
|
+
let toTag = options.toTag;
|
|
109
|
+
if (!toTag) {
|
|
110
|
+
// Stateless UAS Behavior...
|
|
111
|
+
// o To header tags MUST be generated for responses in a stateless
|
|
112
|
+
// manner - in a manner that will generate the same tag for the
|
|
113
|
+
// same request consistently. For information on tag construction
|
|
114
|
+
// see Section 19.3.
|
|
115
|
+
// https://tools.ietf.org/html/rfc3261#section-8.2.7
|
|
116
|
+
toTag = newTag(); // FIXME: newTag() currently generates random tags
|
|
117
|
+
}
|
|
118
|
+
toHeader += ";tag=" + toTag;
|
|
119
|
+
}
|
|
120
|
+
toHeader += CRLF;
|
|
121
|
+
|
|
122
|
+
// FIXME: TODO: needs review... moved to InviteUserAgentServer (as it is specific to that)
|
|
123
|
+
// let recordRouteHeaders = "";
|
|
124
|
+
// if (request.method === C.INVITE && statusCode > 100 && statusCode <= 200) {
|
|
125
|
+
// recordRouteHeaders = request.getHeaders("record-route").reduce((previous, current) => {
|
|
126
|
+
// return previous + "Record-Route: " + current + CRLF;
|
|
127
|
+
// }, "");
|
|
128
|
+
// }
|
|
129
|
+
|
|
130
|
+
// FIXME: TODO: needs review...
|
|
131
|
+
let supportedHeader = "";
|
|
132
|
+
if (options.supported) {
|
|
133
|
+
supportedHeader = "Supported: " + options.supported.join(", ") + CRLF;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// FIXME: TODO: needs review...
|
|
137
|
+
let userAgentHeader = "";
|
|
138
|
+
if (options.userAgent) {
|
|
139
|
+
userAgentHeader = "User-Agent: " + options.userAgent + CRLF;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let extensionHeaders = "";
|
|
143
|
+
if (options.extraHeaders) {
|
|
144
|
+
extensionHeaders = options.extraHeaders.reduce((previous, current) => {
|
|
145
|
+
return previous + current.trim() + CRLF;
|
|
146
|
+
}, "");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// The relative order of header fields with different field names is not
|
|
150
|
+
// significant. However, it is RECOMMENDED that header fields which are
|
|
151
|
+
// needed for proxy processing (Via, Route, Record-Route, Proxy-Require,
|
|
152
|
+
// Max-Forwards, and Proxy-Authorization, for example) appear towards
|
|
153
|
+
// the top of the message to facilitate rapid parsing.
|
|
154
|
+
// https://tools.ietf.org/html/rfc3261#section-7.3.1
|
|
155
|
+
// response += recordRouteHeaders;
|
|
156
|
+
response += viaHeaders;
|
|
157
|
+
response += fromHeader;
|
|
158
|
+
response += toHeader;
|
|
159
|
+
response += cSeqHeader;
|
|
160
|
+
response += callIdHeader;
|
|
161
|
+
response += supportedHeader;
|
|
162
|
+
response += userAgentHeader;
|
|
163
|
+
response += extensionHeaders;
|
|
164
|
+
|
|
165
|
+
if (options.body) {
|
|
166
|
+
response += "Content-Type: " + options.body.contentType + CRLF;
|
|
167
|
+
response += "Content-Length: " + utf8Length(options.body.content) + CRLF + CRLF;
|
|
168
|
+
response += options.body.content;
|
|
169
|
+
} else {
|
|
170
|
+
response += "Content-Length: " + 0 + CRLF + CRLF;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return { message: response };
|
|
174
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/* eslint-disable no-inner-declarations */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
import { Grammar } from "../../grammar";
|
|
4
|
+
import { Logger } from "../log/logger";
|
|
5
|
+
import { IncomingRequestMessage } from "./incoming-request-message";
|
|
6
|
+
import { IncomingResponseMessage } from "./incoming-response-message";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Extract and parse every header of a SIP message.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export namespace Parser {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
export function getHeader(data: any, headerStart: number): number {
|
|
15
|
+
// 'start' position of the header.
|
|
16
|
+
let start: number = headerStart;
|
|
17
|
+
// 'end' position of the header.
|
|
18
|
+
let end = 0;
|
|
19
|
+
// 'partial end' position of the header.
|
|
20
|
+
let partialEnd = 0;
|
|
21
|
+
|
|
22
|
+
// End of message.
|
|
23
|
+
if (data.substring(start, start + 2).match(/(^\r\n)/)) {
|
|
24
|
+
return -2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
while (end === 0) {
|
|
28
|
+
// Partial End of Header.
|
|
29
|
+
partialEnd = data.indexOf("\r\n", start);
|
|
30
|
+
|
|
31
|
+
// 'indexOf' returns -1 if the value to be found never occurs.
|
|
32
|
+
if (partialEnd === -1) {
|
|
33
|
+
return partialEnd;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
!data.substring(partialEnd + 2, partialEnd + 4).match(/(^\r\n)/) &&
|
|
38
|
+
data.charAt(partialEnd + 2).match(/(^\s+)/)
|
|
39
|
+
) {
|
|
40
|
+
// Not the end of the message. Continue from the next position.
|
|
41
|
+
start = partialEnd + 2;
|
|
42
|
+
} else {
|
|
43
|
+
end = partialEnd;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return end;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function parseHeader(
|
|
51
|
+
message: IncomingRequestMessage | IncomingResponseMessage,
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
data: any,
|
|
54
|
+
headerStart: number,
|
|
55
|
+
headerEnd: number
|
|
56
|
+
): boolean | { error: string } {
|
|
57
|
+
const hcolonIndex: number = data.indexOf(":", headerStart);
|
|
58
|
+
const headerName: string = data.substring(headerStart, hcolonIndex).trim();
|
|
59
|
+
const headerValue: string = data.substring(hcolonIndex + 1, headerEnd).trim();
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
let parsed: any;
|
|
63
|
+
// If header-field is well-known, parse it.
|
|
64
|
+
switch (headerName.toLowerCase()) {
|
|
65
|
+
case "via":
|
|
66
|
+
case "v":
|
|
67
|
+
message.addHeader("via", headerValue);
|
|
68
|
+
if (message.getHeaders("via").length === 1) {
|
|
69
|
+
parsed = message.parseHeader("Via");
|
|
70
|
+
if (parsed) {
|
|
71
|
+
message.via = parsed;
|
|
72
|
+
message.viaBranch = parsed.branch;
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
parsed = 0;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case "from":
|
|
79
|
+
case "f":
|
|
80
|
+
message.setHeader("from", headerValue);
|
|
81
|
+
parsed = message.parseHeader("from");
|
|
82
|
+
if (parsed) {
|
|
83
|
+
message.from = parsed;
|
|
84
|
+
message.fromTag = parsed.getParam("tag");
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case "to":
|
|
88
|
+
case "t":
|
|
89
|
+
message.setHeader("to", headerValue);
|
|
90
|
+
parsed = message.parseHeader("to");
|
|
91
|
+
if (parsed) {
|
|
92
|
+
message.to = parsed;
|
|
93
|
+
message.toTag = parsed.getParam("tag");
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case "record-route":
|
|
97
|
+
parsed = Grammar.parse(headerValue, "Record_Route");
|
|
98
|
+
|
|
99
|
+
if (parsed === -1) {
|
|
100
|
+
parsed = undefined;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (!(parsed instanceof Array)) {
|
|
104
|
+
parsed = undefined;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
parsed.forEach((header) => {
|
|
109
|
+
message.addHeader("record-route", headerValue.substring(header.position, header.offset));
|
|
110
|
+
message.headers["Record-Route"][message.getHeaders("record-route").length - 1].parsed = header.parsed;
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
case "call-id":
|
|
114
|
+
case "i":
|
|
115
|
+
message.setHeader("call-id", headerValue);
|
|
116
|
+
parsed = message.parseHeader("call-id");
|
|
117
|
+
if (parsed) {
|
|
118
|
+
message.callId = headerValue;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case "contact":
|
|
122
|
+
case "m":
|
|
123
|
+
parsed = Grammar.parse(headerValue, "Contact");
|
|
124
|
+
|
|
125
|
+
if (parsed === -1) {
|
|
126
|
+
parsed = undefined;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (!(parsed instanceof Array)) {
|
|
130
|
+
parsed = undefined;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
parsed.forEach((header) => {
|
|
135
|
+
message.addHeader("contact", headerValue.substring(header.position, header.offset));
|
|
136
|
+
message.headers.Contact[message.getHeaders("contact").length - 1].parsed = header.parsed;
|
|
137
|
+
});
|
|
138
|
+
break;
|
|
139
|
+
case "content-length":
|
|
140
|
+
case "l":
|
|
141
|
+
message.setHeader("content-length", headerValue);
|
|
142
|
+
parsed = message.parseHeader("content-length");
|
|
143
|
+
break;
|
|
144
|
+
case "content-type":
|
|
145
|
+
case "c":
|
|
146
|
+
message.setHeader("content-type", headerValue);
|
|
147
|
+
parsed = message.parseHeader("content-type");
|
|
148
|
+
break;
|
|
149
|
+
case "cseq":
|
|
150
|
+
message.setHeader("cseq", headerValue);
|
|
151
|
+
parsed = message.parseHeader("cseq");
|
|
152
|
+
if (parsed) {
|
|
153
|
+
message.cseq = parsed.value;
|
|
154
|
+
}
|
|
155
|
+
if (message instanceof IncomingResponseMessage) {
|
|
156
|
+
message.method = parsed.method;
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case "max-forwards":
|
|
160
|
+
message.setHeader("max-forwards", headerValue);
|
|
161
|
+
parsed = message.parseHeader("max-forwards");
|
|
162
|
+
break;
|
|
163
|
+
case "www-authenticate":
|
|
164
|
+
message.setHeader("www-authenticate", headerValue);
|
|
165
|
+
parsed = message.parseHeader("www-authenticate");
|
|
166
|
+
break;
|
|
167
|
+
case "proxy-authenticate":
|
|
168
|
+
message.setHeader("proxy-authenticate", headerValue);
|
|
169
|
+
parsed = message.parseHeader("proxy-authenticate");
|
|
170
|
+
break;
|
|
171
|
+
case "refer-to":
|
|
172
|
+
case "r":
|
|
173
|
+
message.setHeader("refer-to", headerValue);
|
|
174
|
+
parsed = message.parseHeader("refer-to");
|
|
175
|
+
if (parsed) {
|
|
176
|
+
message.referTo = parsed;
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
// Do not parse this header.
|
|
181
|
+
message.addHeader(headerName.toLowerCase(), headerValue);
|
|
182
|
+
parsed = 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (parsed === undefined) {
|
|
186
|
+
return {
|
|
187
|
+
error: "error parsing header '" + headerName + "'"
|
|
188
|
+
};
|
|
189
|
+
} else {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function parseMessage(
|
|
195
|
+
data: string,
|
|
196
|
+
logger: Logger
|
|
197
|
+
): IncomingRequestMessage | IncomingResponseMessage | undefined {
|
|
198
|
+
let headerStart = 0;
|
|
199
|
+
let headerEnd: number = data.indexOf("\r\n");
|
|
200
|
+
|
|
201
|
+
if (headerEnd === -1) {
|
|
202
|
+
logger.warn("no CRLF found, not a SIP message, discarded");
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Parse first line. Check if it is a Request or a Reply.
|
|
207
|
+
const firstLine: string = data.substring(0, headerEnd);
|
|
208
|
+
const parsed = Grammar.parse(firstLine, "Request_Response");
|
|
209
|
+
let message: IncomingRequestMessage | IncomingResponseMessage;
|
|
210
|
+
|
|
211
|
+
if (parsed === -1) {
|
|
212
|
+
logger.warn('error parsing first line of SIP message: "' + firstLine + '"');
|
|
213
|
+
return;
|
|
214
|
+
} else if (!parsed.status_code) {
|
|
215
|
+
message = new IncomingRequestMessage();
|
|
216
|
+
message.method = parsed.method;
|
|
217
|
+
message.ruri = parsed.uri;
|
|
218
|
+
} else {
|
|
219
|
+
message = new IncomingResponseMessage();
|
|
220
|
+
message.statusCode = parsed.status_code;
|
|
221
|
+
message.reasonPhrase = parsed.reason_phrase;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
message.data = data;
|
|
225
|
+
headerStart = headerEnd + 2;
|
|
226
|
+
|
|
227
|
+
// Loop over every line in data. Detect the end of each header and parse
|
|
228
|
+
// it or simply add to the headers collection.
|
|
229
|
+
let bodyStart: number;
|
|
230
|
+
// eslint-disable-next-line no-constant-condition
|
|
231
|
+
while (true) {
|
|
232
|
+
headerEnd = getHeader(data, headerStart);
|
|
233
|
+
|
|
234
|
+
// The SIP message has normally finished.
|
|
235
|
+
if (headerEnd === -2) {
|
|
236
|
+
bodyStart = headerStart + 2;
|
|
237
|
+
break;
|
|
238
|
+
} else if (headerEnd === -1) {
|
|
239
|
+
// data.indexOf returned -1 due to a malformed message.
|
|
240
|
+
logger.error("malformed message");
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const parsedHeader = parseHeader(message, data, headerStart, headerEnd);
|
|
245
|
+
|
|
246
|
+
if (parsedHeader && parsedHeader !== true) {
|
|
247
|
+
logger.error(parsedHeader.error);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
headerStart = headerEnd + 2;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// RFC3261 18.3.
|
|
255
|
+
// If there are additional bytes in the transport packet
|
|
256
|
+
// beyond the end of the body, they MUST be discarded.
|
|
257
|
+
if (message.hasHeader("content-length")) {
|
|
258
|
+
message.body = data.substr(bodyStart, Number(message.getHeader("content-length")));
|
|
259
|
+
} else {
|
|
260
|
+
message.body = data.substring(bodyStart);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return message;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIP Response Reasons
|
|
3
|
+
* DOC: http://www.iana.org/assignments/sip-parameters
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
const REASON_PHRASE: { [code: number]: string } = {
|
|
7
|
+
100: "Trying",
|
|
8
|
+
180: "Ringing",
|
|
9
|
+
181: "Call Is Being Forwarded",
|
|
10
|
+
182: "Queued",
|
|
11
|
+
183: "Session Progress",
|
|
12
|
+
199: "Early Dialog Terminated", // draft-ietf-sipcore-199
|
|
13
|
+
200: "OK",
|
|
14
|
+
202: "Accepted", // RFC 3265
|
|
15
|
+
204: "No Notification", // RFC 5839
|
|
16
|
+
300: "Multiple Choices",
|
|
17
|
+
301: "Moved Permanently",
|
|
18
|
+
302: "Moved Temporarily",
|
|
19
|
+
305: "Use Proxy",
|
|
20
|
+
380: "Alternative Service",
|
|
21
|
+
400: "Bad Request",
|
|
22
|
+
401: "Unauthorized",
|
|
23
|
+
402: "Payment Required",
|
|
24
|
+
403: "Forbidden",
|
|
25
|
+
404: "Not Found",
|
|
26
|
+
405: "Method Not Allowed",
|
|
27
|
+
406: "Not Acceptable",
|
|
28
|
+
407: "Proxy Authentication Required",
|
|
29
|
+
408: "Request Timeout",
|
|
30
|
+
410: "Gone",
|
|
31
|
+
412: "Conditional Request Failed", // RFC 3903
|
|
32
|
+
413: "Request Entity Too Large",
|
|
33
|
+
414: "Request-URI Too Long",
|
|
34
|
+
415: "Unsupported Media Type",
|
|
35
|
+
416: "Unsupported URI Scheme",
|
|
36
|
+
417: "Unknown Resource-Priority", // RFC 4412
|
|
37
|
+
420: "Bad Extension",
|
|
38
|
+
421: "Extension Required",
|
|
39
|
+
422: "Session Interval Too Small", // RFC 4028
|
|
40
|
+
423: "Interval Too Brief",
|
|
41
|
+
428: "Use Identity Header", // RFC 4474
|
|
42
|
+
429: "Provide Referrer Identity", // RFC 3892
|
|
43
|
+
430: "Flow Failed", // RFC 5626
|
|
44
|
+
433: "Anonymity Disallowed", // RFC 5079
|
|
45
|
+
436: "Bad Identity-Info", // RFC 4474
|
|
46
|
+
437: "Unsupported Certificate", // RFC 4744
|
|
47
|
+
438: "Invalid Identity Header", // RFC 4744
|
|
48
|
+
439: "First Hop Lacks Outbound Support", // RFC 5626
|
|
49
|
+
440: "Max-Breadth Exceeded", // RFC 5393
|
|
50
|
+
469: "Bad Info Package", // draft-ietf-sipcore-info-events
|
|
51
|
+
470: "Consent Needed", // RFC 5360
|
|
52
|
+
478: "Unresolvable Destination", // Custom code copied from Kamailio.
|
|
53
|
+
480: "Temporarily Unavailable",
|
|
54
|
+
481: "Call/Transaction Does Not Exist",
|
|
55
|
+
482: "Loop Detected",
|
|
56
|
+
483: "Too Many Hops",
|
|
57
|
+
484: "Address Incomplete",
|
|
58
|
+
485: "Ambiguous",
|
|
59
|
+
486: "Busy Here",
|
|
60
|
+
487: "Request Terminated",
|
|
61
|
+
488: "Not Acceptable Here",
|
|
62
|
+
489: "Bad Event", // RFC 3265
|
|
63
|
+
491: "Request Pending",
|
|
64
|
+
493: "Undecipherable",
|
|
65
|
+
494: "Security Agreement Required", // RFC 3329
|
|
66
|
+
500: "Internal Server Error",
|
|
67
|
+
501: "Not Implemented",
|
|
68
|
+
502: "Bad Gateway",
|
|
69
|
+
503: "Service Unavailable",
|
|
70
|
+
504: "Server Time-out",
|
|
71
|
+
505: "Version Not Supported",
|
|
72
|
+
513: "Message Too Large",
|
|
73
|
+
580: "Precondition Failure", // RFC 3312
|
|
74
|
+
600: "Busy Everywhere",
|
|
75
|
+
603: "Decline",
|
|
76
|
+
604: "Does Not Exist Anywhere",
|
|
77
|
+
606: "Not Acceptable"
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param size -
|
|
82
|
+
* @param base -
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
export function createRandomToken(size: number, base = 32): string {
|
|
86
|
+
let token = "";
|
|
87
|
+
for (let i = 0; i < size; i++) {
|
|
88
|
+
const r: number = Math.floor(Math.random() * base);
|
|
89
|
+
token += r.toString(base);
|
|
90
|
+
}
|
|
91
|
+
return token;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
export function getReasonPhrase(code: number): string {
|
|
98
|
+
return REASON_PHRASE[code] || "";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
export function newTag(): string {
|
|
105
|
+
return createRandomToken(10);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param str -
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export function headerize(str: string): string {
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const exceptions: any = {
|
|
115
|
+
"Call-Id": "Call-ID",
|
|
116
|
+
Cseq: "CSeq",
|
|
117
|
+
"Min-Se": "Min-SE",
|
|
118
|
+
Rack: "RAck",
|
|
119
|
+
Rseq: "RSeq",
|
|
120
|
+
"Www-Authenticate": "WWW-Authenticate"
|
|
121
|
+
};
|
|
122
|
+
const name: Array<string> = str.toLowerCase().replace(/_/g, "-").split("-");
|
|
123
|
+
const parts: number = name.length;
|
|
124
|
+
let hname = "";
|
|
125
|
+
|
|
126
|
+
for (let part = 0; part < parts; part++) {
|
|
127
|
+
if (part !== 0) {
|
|
128
|
+
hname += "-";
|
|
129
|
+
}
|
|
130
|
+
hname += name[part].charAt(0).toUpperCase() + name[part].substring(1);
|
|
131
|
+
}
|
|
132
|
+
if (exceptions[hname]) {
|
|
133
|
+
hname = exceptions[hname];
|
|
134
|
+
}
|
|
135
|
+
return hname;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param str -
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
export function utf8Length(str: string): number {
|
|
143
|
+
return encodeURIComponent(str).replace(/%[A-F\d]{2}/g, "U").length;
|
|
144
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IncomingAckRequest,
|
|
3
|
+
IncomingByeRequest,
|
|
4
|
+
IncomingInfoRequest,
|
|
5
|
+
IncomingInviteRequest,
|
|
6
|
+
IncomingMessageRequest,
|
|
7
|
+
IncomingNotifyRequest,
|
|
8
|
+
IncomingPrackRequest,
|
|
9
|
+
IncomingReferRequest
|
|
10
|
+
} from "../messages";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Session delegate.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface SessionDelegate {
|
|
17
|
+
/**
|
|
18
|
+
* Receive ACK request.
|
|
19
|
+
* @param request - Incoming ACK request.
|
|
20
|
+
* @returns
|
|
21
|
+
* The callback MUST return a promise if it asynchronously handles answers.
|
|
22
|
+
* For example, an ACK with an answer (offer in the 200 Ok) may require
|
|
23
|
+
* asynchronous processing in which case the callback MUST return a Promise
|
|
24
|
+
* which resolves when the answer handling is complete.
|
|
25
|
+
* @privateRemarks
|
|
26
|
+
* Unlike INVITE handling where we can rely on the generation of a response
|
|
27
|
+
* to indicate when offer/answer processing has been completed, ACK handling
|
|
28
|
+
* requires some indication from the handler that answer processing is complete
|
|
29
|
+
* so that we can avoid some race conditions (see comments in code for more details).
|
|
30
|
+
* Having the handler return a Promise provides said indication.
|
|
31
|
+
*/
|
|
32
|
+
onAck?(request: IncomingAckRequest): Promise<void> | void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Timeout waiting for ACK request.
|
|
36
|
+
* If no handler is provided the Session will terminated with a BYE.
|
|
37
|
+
* https://tools.ietf.org/html/rfc3261#section-13.3.1.4
|
|
38
|
+
*/
|
|
39
|
+
onAckTimeout?(): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Receive BYE request.
|
|
43
|
+
* https://tools.ietf.org/html/rfc3261#section-15.1.2
|
|
44
|
+
* @param request - Incoming BYE request.
|
|
45
|
+
*/
|
|
46
|
+
onBye?(request: IncomingByeRequest): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Receive INFO request.
|
|
50
|
+
* @param request - Incoming INFO request.
|
|
51
|
+
*/
|
|
52
|
+
onInfo?(request: IncomingInfoRequest): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Receive re-INVITE request.
|
|
56
|
+
* https://tools.ietf.org/html/rfc3261#section-14.2
|
|
57
|
+
* @param request - Incoming INVITE request.
|
|
58
|
+
*/
|
|
59
|
+
onInvite?(request: IncomingInviteRequest): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Receive MESSAGE request.
|
|
63
|
+
* https://tools.ietf.org/html/rfc3428#section-7
|
|
64
|
+
* @param request - Incoming MESSAGE request.
|
|
65
|
+
*/
|
|
66
|
+
onMessage?(request: IncomingMessageRequest): void;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Receive NOTIFY request.
|
|
70
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
71
|
+
* @param request - Incoming NOTIFY request.
|
|
72
|
+
*/
|
|
73
|
+
onNotify?(request: IncomingNotifyRequest): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Receive PRACK request.
|
|
77
|
+
* https://tools.ietf.org/html/rfc3262#section-3
|
|
78
|
+
* @param request - Incoming PRACK request.
|
|
79
|
+
*/
|
|
80
|
+
onPrack?(request: IncomingPrackRequest): void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Receive REFER request.
|
|
84
|
+
* https://tools.ietf.org/html/rfc3515#section-2.4.2
|
|
85
|
+
* @param request - Incoming REFER request.
|
|
86
|
+
*/
|
|
87
|
+
onRefer?(request: IncomingReferRequest): void;
|
|
88
|
+
}
|