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,557 @@
|
|
|
1
|
+
import { Logger } from "../log";
|
|
2
|
+
import {
|
|
3
|
+
C,
|
|
4
|
+
IncomingRequestMessage,
|
|
5
|
+
NameAddrHeader,
|
|
6
|
+
OutgoingRequestMessage,
|
|
7
|
+
OutgoingSubscribeRequest,
|
|
8
|
+
OutgoingSubscribeRequestDelegate,
|
|
9
|
+
RequestOptions
|
|
10
|
+
} from "../messages";
|
|
11
|
+
import { Subscription, SubscriptionDelegate, SubscriptionState } from "../subscription";
|
|
12
|
+
import { Timers } from "../timers";
|
|
13
|
+
import { AllowedMethods } from "../user-agent-core/allowed-methods";
|
|
14
|
+
import { UserAgentCore } from "../user-agent-core/user-agent-core";
|
|
15
|
+
import { NotifyUserAgentServer } from "../user-agents/notify-user-agent-server";
|
|
16
|
+
import { ReSubscribeUserAgentClient } from "../user-agents/re-subscribe-user-agent-client";
|
|
17
|
+
import { Dialog } from "./dialog";
|
|
18
|
+
import { DialogState } from "./dialog-state";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Subscription Dialog.
|
|
22
|
+
* @remarks
|
|
23
|
+
* SIP-Specific Event Notification
|
|
24
|
+
*
|
|
25
|
+
* Abstract
|
|
26
|
+
*
|
|
27
|
+
* This document describes an extension to the Session Initiation
|
|
28
|
+
* Protocol (SIP) defined by RFC 3261. The purpose of this extension is
|
|
29
|
+
* to provide an extensible framework by which SIP nodes can request
|
|
30
|
+
* notification from remote nodes indicating that certain events have
|
|
31
|
+
* occurred.
|
|
32
|
+
*
|
|
33
|
+
* Note that the event notification mechanisms defined herein are NOT
|
|
34
|
+
* intended to be a general-purpose infrastructure for all classes of
|
|
35
|
+
* event subscription and notification.
|
|
36
|
+
*
|
|
37
|
+
* This document represents a backwards-compatible improvement on the
|
|
38
|
+
* original mechanism described by RFC 3265, taking into account several
|
|
39
|
+
* years of implementation experience. Accordingly, this document
|
|
40
|
+
* obsoletes RFC 3265. This document also updates RFC 4660 slightly to
|
|
41
|
+
* accommodate some small changes to the mechanism that were discussed
|
|
42
|
+
* in that document.
|
|
43
|
+
*
|
|
44
|
+
* https://tools.ietf.org/html/rfc6665
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export class SubscriptionDialog extends Dialog implements Subscription {
|
|
48
|
+
public delegate: SubscriptionDelegate | undefined;
|
|
49
|
+
|
|
50
|
+
private _autoRefresh: boolean;
|
|
51
|
+
private _subscriptionEvent: string;
|
|
52
|
+
private _subscriptionExpires: number;
|
|
53
|
+
private _subscriptionExpiresInitial: number;
|
|
54
|
+
private _subscriptionExpiresLastSet: number;
|
|
55
|
+
private _subscriptionRefresh: number | undefined;
|
|
56
|
+
private _subscriptionRefreshLastSet: number | undefined;
|
|
57
|
+
private _subscriptionState: SubscriptionState;
|
|
58
|
+
|
|
59
|
+
private logger: Logger;
|
|
60
|
+
private N: number | undefined;
|
|
61
|
+
private refreshTimer: number | undefined;
|
|
62
|
+
|
|
63
|
+
constructor(
|
|
64
|
+
subscriptionEvent: string,
|
|
65
|
+
subscriptionExpires: number,
|
|
66
|
+
subscriptionState: SubscriptionState,
|
|
67
|
+
core: UserAgentCore,
|
|
68
|
+
state: DialogState,
|
|
69
|
+
delegate?: SubscriptionDelegate
|
|
70
|
+
) {
|
|
71
|
+
super(core, state);
|
|
72
|
+
this.delegate = delegate;
|
|
73
|
+
this._autoRefresh = false;
|
|
74
|
+
this._subscriptionEvent = subscriptionEvent;
|
|
75
|
+
this._subscriptionExpires = subscriptionExpires;
|
|
76
|
+
this._subscriptionExpiresInitial = subscriptionExpires;
|
|
77
|
+
this._subscriptionExpiresLastSet = Math.floor(Date.now() / 1000);
|
|
78
|
+
this._subscriptionRefresh = undefined;
|
|
79
|
+
this._subscriptionRefreshLastSet = undefined;
|
|
80
|
+
this._subscriptionState = subscriptionState;
|
|
81
|
+
this.logger = core.loggerFactory.getLogger("sip.subscribe-dialog");
|
|
82
|
+
this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* When a UAC receives a response that establishes a dialog, it
|
|
87
|
+
* constructs the state of the dialog. This state MUST be maintained
|
|
88
|
+
* for the duration of the dialog.
|
|
89
|
+
* https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
90
|
+
* @param outgoingRequestMessage - Outgoing request message for dialog.
|
|
91
|
+
* @param incomingResponseMessage - Incoming response message creating dialog.
|
|
92
|
+
*/
|
|
93
|
+
public static initialDialogStateForSubscription(
|
|
94
|
+
outgoingSubscribeRequestMessage: OutgoingRequestMessage,
|
|
95
|
+
incomingNotifyRequestMessage: IncomingRequestMessage
|
|
96
|
+
): DialogState {
|
|
97
|
+
// If the request was sent over TLS, and the Request-URI contained a
|
|
98
|
+
// SIPS URI, the "secure" flag is set to TRUE.
|
|
99
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
100
|
+
const secure = false; // FIXME: Currently no support for TLS.
|
|
101
|
+
|
|
102
|
+
// The route set MUST be set to the list of URIs in the Record-Route
|
|
103
|
+
// header field from the response, taken in reverse order and preserving
|
|
104
|
+
// all URI parameters. If no Record-Route header field is present in
|
|
105
|
+
// the response, the route set MUST be set to the empty set. This route
|
|
106
|
+
// set, even if empty, overrides any pre-existing route set for future
|
|
107
|
+
// requests in this dialog. The remote target MUST be set to the URI
|
|
108
|
+
// from the Contact header field of the response.
|
|
109
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
110
|
+
const routeSet = incomingNotifyRequestMessage.getHeaders("record-route");
|
|
111
|
+
const contact = incomingNotifyRequestMessage.parseHeader("contact");
|
|
112
|
+
if (!contact) {
|
|
113
|
+
// TODO: Review to make sure this will never happen
|
|
114
|
+
throw new Error("Contact undefined.");
|
|
115
|
+
}
|
|
116
|
+
if (!(contact instanceof NameAddrHeader)) {
|
|
117
|
+
throw new Error("Contact not instance of NameAddrHeader.");
|
|
118
|
+
}
|
|
119
|
+
const remoteTarget = contact.uri;
|
|
120
|
+
|
|
121
|
+
// The local sequence number MUST be set to the value of the sequence
|
|
122
|
+
// number in the CSeq header field of the request. The remote sequence
|
|
123
|
+
// number MUST be empty (it is established when the remote UA sends a
|
|
124
|
+
// request within the dialog). The call identifier component of the
|
|
125
|
+
// dialog ID MUST be set to the value of the Call-ID in the request.
|
|
126
|
+
// The local tag component of the dialog ID MUST be set to the tag in
|
|
127
|
+
// the From field in the request, and the remote tag component of the
|
|
128
|
+
// dialog ID MUST be set to the tag in the To field of the response. A
|
|
129
|
+
// UAC MUST be prepared to receive a response without a tag in the To
|
|
130
|
+
// field, in which case the tag is considered to have a value of null.
|
|
131
|
+
//
|
|
132
|
+
// This is to maintain backwards compatibility with RFC 2543, which
|
|
133
|
+
// did not mandate To tags.
|
|
134
|
+
//
|
|
135
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
136
|
+
const localSequenceNumber = outgoingSubscribeRequestMessage.cseq;
|
|
137
|
+
const remoteSequenceNumber = undefined;
|
|
138
|
+
const callId = outgoingSubscribeRequestMessage.callId;
|
|
139
|
+
const localTag = outgoingSubscribeRequestMessage.fromTag;
|
|
140
|
+
const remoteTag = incomingNotifyRequestMessage.fromTag;
|
|
141
|
+
if (!callId) {
|
|
142
|
+
// TODO: Review to make sure this will never happen
|
|
143
|
+
throw new Error("Call id undefined.");
|
|
144
|
+
}
|
|
145
|
+
if (!localTag) {
|
|
146
|
+
// TODO: Review to make sure this will never happen
|
|
147
|
+
throw new Error("From tag undefined.");
|
|
148
|
+
}
|
|
149
|
+
if (!remoteTag) {
|
|
150
|
+
// TODO: Review to make sure this will never happen
|
|
151
|
+
throw new Error("To tag undefined."); // FIXME: No backwards compatibility with RFC 2543
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// The remote URI MUST be set to the URI in the To field, and the local
|
|
155
|
+
// URI MUST be set to the URI in the From field.
|
|
156
|
+
// https://tools.ietf.org/html/rfc3261#section-12.1.2
|
|
157
|
+
if (!outgoingSubscribeRequestMessage.from) {
|
|
158
|
+
// TODO: Review to make sure this will never happen
|
|
159
|
+
throw new Error("From undefined.");
|
|
160
|
+
}
|
|
161
|
+
if (!outgoingSubscribeRequestMessage.to) {
|
|
162
|
+
// TODO: Review to make sure this will never happen
|
|
163
|
+
throw new Error("To undefined.");
|
|
164
|
+
}
|
|
165
|
+
const localURI = outgoingSubscribeRequestMessage.from.uri;
|
|
166
|
+
const remoteURI = outgoingSubscribeRequestMessage.to.uri;
|
|
167
|
+
|
|
168
|
+
// A dialog can also be in the "early" state, which occurs when it is
|
|
169
|
+
// created with a provisional response, and then transition to the
|
|
170
|
+
// "confirmed" state when a 2xx final response arrives.
|
|
171
|
+
// https://tools.ietf.org/html/rfc3261#section-12
|
|
172
|
+
const early = false;
|
|
173
|
+
|
|
174
|
+
const dialogState: DialogState = {
|
|
175
|
+
id: callId + localTag + remoteTag,
|
|
176
|
+
early,
|
|
177
|
+
callId,
|
|
178
|
+
localTag,
|
|
179
|
+
remoteTag,
|
|
180
|
+
localSequenceNumber,
|
|
181
|
+
remoteSequenceNumber,
|
|
182
|
+
localURI,
|
|
183
|
+
remoteURI,
|
|
184
|
+
remoteTarget,
|
|
185
|
+
routeSet,
|
|
186
|
+
secure
|
|
187
|
+
};
|
|
188
|
+
return dialogState;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public dispose(): void {
|
|
192
|
+
super.dispose();
|
|
193
|
+
if (this.N) {
|
|
194
|
+
clearTimeout(this.N);
|
|
195
|
+
this.N = undefined;
|
|
196
|
+
}
|
|
197
|
+
this.refreshTimerClear();
|
|
198
|
+
this.logger.log(`SUBSCRIBE dialog ${this.id} destroyed`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
get autoRefresh(): boolean {
|
|
202
|
+
return this._autoRefresh;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
set autoRefresh(autoRefresh: boolean) {
|
|
206
|
+
this._autoRefresh = true;
|
|
207
|
+
this.refreshTimerSet();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
get subscriptionEvent(): string {
|
|
211
|
+
return this._subscriptionEvent;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Number of seconds until subscription expires. */
|
|
215
|
+
get subscriptionExpires(): number {
|
|
216
|
+
const secondsSinceLastSet = Math.floor(Date.now() / 1000) - this._subscriptionExpiresLastSet;
|
|
217
|
+
const secondsUntilExpires = this._subscriptionExpires - secondsSinceLastSet;
|
|
218
|
+
return Math.max(secondsUntilExpires, 0);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
set subscriptionExpires(expires: number) {
|
|
222
|
+
if (expires < 0) {
|
|
223
|
+
throw new Error("Expires must be greater than or equal to zero.");
|
|
224
|
+
}
|
|
225
|
+
this._subscriptionExpires = expires;
|
|
226
|
+
this._subscriptionExpiresLastSet = Math.floor(Date.now() / 1000);
|
|
227
|
+
if (this.autoRefresh) {
|
|
228
|
+
const refresh = this.subscriptionRefresh;
|
|
229
|
+
if (refresh === undefined || refresh >= expires) {
|
|
230
|
+
this.refreshTimerSet();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
get subscriptionExpiresInitial(): number {
|
|
236
|
+
return this._subscriptionExpiresInitial;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Number of seconds until subscription auto refresh. */
|
|
240
|
+
get subscriptionRefresh(): number | undefined {
|
|
241
|
+
if (this._subscriptionRefresh === undefined || this._subscriptionRefreshLastSet === undefined) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
const secondsSinceLastSet = Math.floor(Date.now() / 1000) - this._subscriptionRefreshLastSet;
|
|
245
|
+
const secondsUntilExpires = this._subscriptionRefresh - secondsSinceLastSet;
|
|
246
|
+
return Math.max(secondsUntilExpires, 0);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
get subscriptionState(): SubscriptionState {
|
|
250
|
+
return this._subscriptionState;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Receive in dialog request message from transport.
|
|
255
|
+
* @param message - The incoming request message.
|
|
256
|
+
*/
|
|
257
|
+
public receiveRequest(message: IncomingRequestMessage): void {
|
|
258
|
+
this.logger.log(`SUBSCRIBE dialog ${this.id} received ${message.method} request`);
|
|
259
|
+
|
|
260
|
+
// Request within a dialog out of sequence guard.
|
|
261
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
262
|
+
if (!this.sequenceGuard(message)) {
|
|
263
|
+
this.logger.log(`SUBSCRIBE dialog ${this.id} rejected out of order ${message.method} request.`);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Request within a dialog common processing.
|
|
268
|
+
// https://tools.ietf.org/html/rfc3261#section-12.2.2
|
|
269
|
+
super.receiveRequest(message);
|
|
270
|
+
|
|
271
|
+
// Switch on method and then delegate.
|
|
272
|
+
switch (message.method) {
|
|
273
|
+
case C.NOTIFY:
|
|
274
|
+
this.onNotify(message);
|
|
275
|
+
break;
|
|
276
|
+
default:
|
|
277
|
+
this.logger.log(`SUBSCRIBE dialog ${this.id} received unimplemented ${message.method} request`);
|
|
278
|
+
this.core.replyStateless(message, { statusCode: 501 });
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 4.1.2.2. Refreshing of Subscriptions
|
|
285
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
286
|
+
*/
|
|
287
|
+
public refresh(): OutgoingSubscribeRequest {
|
|
288
|
+
const allowHeader = "Allow: " + AllowedMethods.toString();
|
|
289
|
+
const options: RequestOptions = {};
|
|
290
|
+
options.extraHeaders = (options.extraHeaders || []).slice();
|
|
291
|
+
options.extraHeaders.push(allowHeader);
|
|
292
|
+
options.extraHeaders.push("Event: " + this.subscriptionEvent);
|
|
293
|
+
options.extraHeaders.push("Expires: " + this.subscriptionExpiresInitial);
|
|
294
|
+
options.extraHeaders.push("Contact: " + this.core.configuration.contact.toString());
|
|
295
|
+
return this.subscribe(undefined, options);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 4.1.2.2. Refreshing of Subscriptions
|
|
300
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
301
|
+
* @param delegate - Delegate to handle responses.
|
|
302
|
+
* @param options - Options bucket.
|
|
303
|
+
*/
|
|
304
|
+
public subscribe(
|
|
305
|
+
delegate?: OutgoingSubscribeRequestDelegate,
|
|
306
|
+
options: RequestOptions = {}
|
|
307
|
+
): OutgoingSubscribeRequest {
|
|
308
|
+
if (this.subscriptionState !== SubscriptionState.Pending && this.subscriptionState !== SubscriptionState.Active) {
|
|
309
|
+
// FIXME: This needs to be a proper exception
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);
|
|
315
|
+
const uac = new ReSubscribeUserAgentClient(this, delegate, options);
|
|
316
|
+
// Abort any outstanding timer (as it would otherwise become guaranteed to terminate us).
|
|
317
|
+
if (this.N) {
|
|
318
|
+
clearTimeout(this.N);
|
|
319
|
+
this.N = undefined;
|
|
320
|
+
}
|
|
321
|
+
// When refreshing a subscription, a subscriber starts Timer N, set to
|
|
322
|
+
// 64*T1, when it sends the SUBSCRIBE request.
|
|
323
|
+
// https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
324
|
+
this.N = window.setTimeout(() => this.timerN(), Timers.TIMER_N);
|
|
325
|
+
return uac;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 4.4.1. Dialog Creation and Termination
|
|
330
|
+
* A subscription is destroyed after a notifier sends a NOTIFY request
|
|
331
|
+
* with a "Subscription-State" of "terminated", or in certain error
|
|
332
|
+
* situations described elsewhere in this document.
|
|
333
|
+
* https://tools.ietf.org/html/rfc6665#section-4.4.1
|
|
334
|
+
*/
|
|
335
|
+
public terminate(): void {
|
|
336
|
+
this.stateTransition(SubscriptionState.Terminated);
|
|
337
|
+
this.onTerminated();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 4.1.2.3. Unsubscribing
|
|
342
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.3
|
|
343
|
+
*/
|
|
344
|
+
public unsubscribe(): OutgoingSubscribeRequest {
|
|
345
|
+
const allowHeader = "Allow: " + AllowedMethods.toString();
|
|
346
|
+
const options: RequestOptions = {};
|
|
347
|
+
options.extraHeaders = (options.extraHeaders || []).slice();
|
|
348
|
+
options.extraHeaders.push(allowHeader);
|
|
349
|
+
options.extraHeaders.push("Event: " + this.subscriptionEvent);
|
|
350
|
+
options.extraHeaders.push("Expires: 0");
|
|
351
|
+
options.extraHeaders.push("Contact: " + this.core.configuration.contact.toString());
|
|
352
|
+
return this.subscribe(undefined, options);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Handle in dialog NOTIFY requests.
|
|
357
|
+
* This does not include the first NOTIFY which created the dialog.
|
|
358
|
+
* @param message - The incoming NOTIFY request message.
|
|
359
|
+
*/
|
|
360
|
+
private onNotify(message: IncomingRequestMessage): void {
|
|
361
|
+
// If, for some reason, the event package designated in the "Event"
|
|
362
|
+
// header field of the NOTIFY request is not supported, the subscriber
|
|
363
|
+
// will respond with a 489 (Bad Event) response.
|
|
364
|
+
// https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
365
|
+
const event: string = message.parseHeader("Event").event;
|
|
366
|
+
if (!event || event !== this.subscriptionEvent) {
|
|
367
|
+
this.core.replyStateless(message, { statusCode: 489 });
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// In the state diagram, "Re-subscription times out" means that an
|
|
372
|
+
// attempt to refresh or update the subscription using a new SUBSCRIBE
|
|
373
|
+
// request does not result in a NOTIFY request before the corresponding
|
|
374
|
+
// Timer N expires.
|
|
375
|
+
// https://tools.ietf.org/html/rfc6665#section-4.1.2
|
|
376
|
+
if (this.N) {
|
|
377
|
+
clearTimeout(this.N);
|
|
378
|
+
this.N = undefined;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// NOTIFY requests MUST contain "Subscription-State" header fields that
|
|
382
|
+
// indicate the status of the subscription.
|
|
383
|
+
// https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
384
|
+
const subscriptionState = message.parseHeader("Subscription-State");
|
|
385
|
+
if (!subscriptionState || !subscriptionState.state) {
|
|
386
|
+
this.core.replyStateless(message, { statusCode: 489 });
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const state: "pending" | "active" | "terminated" = subscriptionState.state;
|
|
390
|
+
const expires = subscriptionState.expires ? Math.max(subscriptionState.expires, 0) : undefined;
|
|
391
|
+
|
|
392
|
+
// Update our state and expiration.
|
|
393
|
+
switch (state) {
|
|
394
|
+
case "pending":
|
|
395
|
+
this.stateTransition(SubscriptionState.Pending, expires);
|
|
396
|
+
break;
|
|
397
|
+
case "active":
|
|
398
|
+
this.stateTransition(SubscriptionState.Active, expires);
|
|
399
|
+
break;
|
|
400
|
+
case "terminated":
|
|
401
|
+
this.stateTransition(SubscriptionState.Terminated, expires);
|
|
402
|
+
break;
|
|
403
|
+
default:
|
|
404
|
+
this.logger.warn("Unrecognized subscription state.");
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Delegate remainder of NOTIFY handling.
|
|
409
|
+
const uas = new NotifyUserAgentServer(this, message);
|
|
410
|
+
if (this.delegate && this.delegate.onNotify) {
|
|
411
|
+
this.delegate.onNotify(uas);
|
|
412
|
+
} else {
|
|
413
|
+
uas.accept();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
private onRefresh(request: OutgoingSubscribeRequest): void {
|
|
418
|
+
if (this.delegate && this.delegate.onRefresh) {
|
|
419
|
+
this.delegate.onRefresh(request);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
private onTerminated(): void {
|
|
424
|
+
if (this.delegate && this.delegate.onTerminated) {
|
|
425
|
+
this.delegate.onTerminated();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private refreshTimerClear(): void {
|
|
430
|
+
if (this.refreshTimer) {
|
|
431
|
+
clearTimeout(this.refreshTimer);
|
|
432
|
+
this.refreshTimer = undefined;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private refreshTimerSet(): void {
|
|
437
|
+
this.refreshTimerClear();
|
|
438
|
+
if (this.autoRefresh && this.subscriptionExpires > 0) {
|
|
439
|
+
const refresh = this.subscriptionExpires * 900;
|
|
440
|
+
this._subscriptionRefresh = Math.floor(refresh / 1000);
|
|
441
|
+
this._subscriptionRefreshLastSet = Math.floor(Date.now() / 1000);
|
|
442
|
+
this.refreshTimer = window.setTimeout(() => {
|
|
443
|
+
this.refreshTimer = undefined;
|
|
444
|
+
this._subscriptionRefresh = undefined;
|
|
445
|
+
this._subscriptionRefreshLastSet = undefined;
|
|
446
|
+
this.onRefresh(this.refresh());
|
|
447
|
+
}, refresh);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
private stateTransition(newState: SubscriptionState, newExpires?: number): void {
|
|
452
|
+
// Assert valid state transitions.
|
|
453
|
+
const invalidStateTransition = (): void => {
|
|
454
|
+
this.logger.warn(`Invalid subscription state transition from ${this.subscriptionState} to ${newState}`);
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
switch (newState) {
|
|
458
|
+
case SubscriptionState.Initial:
|
|
459
|
+
invalidStateTransition();
|
|
460
|
+
return;
|
|
461
|
+
case SubscriptionState.NotifyWait:
|
|
462
|
+
invalidStateTransition();
|
|
463
|
+
return;
|
|
464
|
+
case SubscriptionState.Pending:
|
|
465
|
+
if (
|
|
466
|
+
this.subscriptionState !== SubscriptionState.NotifyWait &&
|
|
467
|
+
this.subscriptionState !== SubscriptionState.Pending
|
|
468
|
+
) {
|
|
469
|
+
invalidStateTransition();
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
case SubscriptionState.Active:
|
|
474
|
+
if (
|
|
475
|
+
this.subscriptionState !== SubscriptionState.NotifyWait &&
|
|
476
|
+
this.subscriptionState !== SubscriptionState.Pending &&
|
|
477
|
+
this.subscriptionState !== SubscriptionState.Active
|
|
478
|
+
) {
|
|
479
|
+
invalidStateTransition();
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
case SubscriptionState.Terminated:
|
|
484
|
+
if (
|
|
485
|
+
this.subscriptionState !== SubscriptionState.NotifyWait &&
|
|
486
|
+
this.subscriptionState !== SubscriptionState.Pending &&
|
|
487
|
+
this.subscriptionState !== SubscriptionState.Active
|
|
488
|
+
) {
|
|
489
|
+
invalidStateTransition();
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
break;
|
|
493
|
+
default:
|
|
494
|
+
invalidStateTransition();
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// If the "Subscription-State" value is "pending", the subscription has
|
|
499
|
+
// been received by the notifier, but there is insufficient policy
|
|
500
|
+
// information to grant or deny the subscription yet. If the header
|
|
501
|
+
// field also contains an "expires" parameter, the subscriber SHOULD
|
|
502
|
+
// take it as the authoritative subscription duration and adjust
|
|
503
|
+
// accordingly. No further action is necessary on the part of the
|
|
504
|
+
// subscriber. The "retry-after" and "reason" parameters have no
|
|
505
|
+
// semantics for "pending".
|
|
506
|
+
// https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
507
|
+
if (newState === SubscriptionState.Pending) {
|
|
508
|
+
if (newExpires) {
|
|
509
|
+
this.subscriptionExpires = newExpires;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// If the "Subscription-State" header field value is "active", it means
|
|
514
|
+
// that the subscription has been accepted and (in general) has been
|
|
515
|
+
// authorized. If the header field also contains an "expires"
|
|
516
|
+
// parameter, the subscriber SHOULD take it as the authoritative
|
|
517
|
+
// subscription duration and adjust accordingly. The "retry-after" and
|
|
518
|
+
// "reason" parameters have no semantics for "active".
|
|
519
|
+
// https://tools.ietf.org/html/rfc6665#section-4.1.3
|
|
520
|
+
if (newState === SubscriptionState.Active) {
|
|
521
|
+
if (newExpires) {
|
|
522
|
+
this.subscriptionExpires = newExpires;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// If the "Subscription-State" value is "terminated", the subscriber
|
|
527
|
+
// MUST consider the subscription terminated. The "expires" parameter
|
|
528
|
+
// has no semantics for "terminated" -- notifiers SHOULD NOT include an
|
|
529
|
+
// "expires" parameter on a "Subscription-State" header field with a
|
|
530
|
+
// value of "terminated", and subscribers MUST ignore any such
|
|
531
|
+
// parameter, if present.
|
|
532
|
+
if (newState === SubscriptionState.Terminated) {
|
|
533
|
+
this.dispose();
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
this._subscriptionState = newState;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* When refreshing a subscription, a subscriber starts Timer N, set to
|
|
541
|
+
* 64*T1, when it sends the SUBSCRIBE request. If this Timer N expires
|
|
542
|
+
* prior to the receipt of a NOTIFY request, the subscriber considers
|
|
543
|
+
* the subscription terminated. If the subscriber receives a success
|
|
544
|
+
* response to the SUBSCRIBE request that indicates that no NOTIFY
|
|
545
|
+
* request will be generated -- such as the 204 response defined for use
|
|
546
|
+
* with the optional extension described in [RFC5839] -- then it MUST
|
|
547
|
+
* cancel Timer N.
|
|
548
|
+
* https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
549
|
+
*/
|
|
550
|
+
private timerN(): void {
|
|
551
|
+
this.logger.warn(`Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY.`);
|
|
552
|
+
if (this.subscriptionState !== SubscriptionState.Terminated) {
|
|
553
|
+
this.stateTransition(SubscriptionState.Terminated);
|
|
554
|
+
this.onTerminated();
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An Exception is considered a condition that a reasonable application may wish to catch.
|
|
3
|
+
* An Error indicates serious problems that a reasonable application should not try to catch.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export abstract class Exception extends Error {
|
|
7
|
+
protected constructor(message?: string) {
|
|
8
|
+
super(message); // 'Error' breaks prototype chain here
|
|
9
|
+
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exception } from "./exception";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Indicates that the operation could not be completed given the current transaction state.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class TransactionStateError extends Exception {
|
|
8
|
+
constructor(message?: string) {
|
|
9
|
+
super(message ? message : "Transaction state error.");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A core library implementing low level SIP protocol elements.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Directories
|
|
7
|
+
export * from "./dialogs";
|
|
8
|
+
export * from "./exceptions";
|
|
9
|
+
export * from "./log";
|
|
10
|
+
export * from "./messages";
|
|
11
|
+
export * from "./session";
|
|
12
|
+
export * from "./subscription";
|
|
13
|
+
export * from "./transactions";
|
|
14
|
+
export * from "./user-agent-core";
|
|
15
|
+
export * from "./user-agents";
|
|
16
|
+
|
|
17
|
+
// Files
|
|
18
|
+
export * from "./timers";
|
|
19
|
+
export * from "./transport";
|