ue-softphone-sdk 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/bye.d.ts +16 -0
- package/dist/api/dtmf.d.ts +15 -0
- package/dist/api/emitter.d.ts +88 -0
- package/dist/api/exceptions/content-type-unsupported.d.ts +8 -0
- package/dist/api/exceptions/index.d.ts +5 -0
- package/dist/api/exceptions/request-pending.d.ts +9 -0
- package/dist/api/exceptions/session-description-handler.d.ts +8 -0
- package/dist/api/exceptions/session-terminated.d.ts +8 -0
- package/dist/api/exceptions/state-transition.d.ts +8 -0
- package/dist/api/index.d.ts +58 -0
- package/dist/api/info.d.ts +16 -0
- package/dist/api/invitation-accept-options.d.ts +19 -0
- package/dist/api/invitation-progress-options.d.ts +38 -0
- package/dist/api/invitation-reject-options.d.ts +25 -0
- package/dist/api/invitation.d.ts +179 -0
- package/dist/api/inviter-cancel-options.d.ts +9 -0
- package/dist/api/inviter-invite-options.d.ts +28 -0
- package/dist/api/inviter-options.d.ts +43 -0
- package/dist/api/inviter.d.ts +236 -0
- package/dist/api/message.d.ts +16 -0
- package/dist/api/messager-message-options.d.ts +11 -0
- package/dist/api/messager-options.d.ts +17 -0
- package/dist/api/messager.d.ts +26 -0
- package/dist/api/notification.d.ts +16 -0
- package/dist/api/notifier.d.ts +8 -0
- package/dist/api/publisher-options.d.ts +33 -0
- package/dist/api/publisher-publish-options.d.ts +6 -0
- package/dist/api/publisher-state.d.ts +21 -0
- package/dist/api/publisher-unpublish-options.d.ts +6 -0
- package/dist/api/publisher.d.ts +65 -0
- package/dist/api/referral.d.ts +38 -0
- package/dist/api/registerer-options.d.ts +46 -0
- package/dist/api/registerer-register-options.d.ts +11 -0
- package/dist/api/registerer-state.d.ts +21 -0
- package/dist/api/registerer-unregister-options.d.ts +16 -0
- package/dist/api/registerer.d.ts +144 -0
- package/dist/api/session-bye-options.d.ts +11 -0
- package/dist/api/session-delegate.d.ts +73 -0
- package/dist/api/session-description-handler-factory.d.ts +15 -0
- package/dist/api/session-description-handler.d.ts +74 -0
- package/dist/api/session-info-options.d.ts +11 -0
- package/dist/api/session-invite-options.d.ts +28 -0
- package/dist/api/session-message-options.d.ts +11 -0
- package/dist/api/session-options.d.ts +8 -0
- package/dist/api/session-refer-options.d.ts +14 -0
- package/dist/api/session-state.d.ts +45 -0
- package/dist/api/session.d.ts +359 -0
- package/dist/api/subscriber-options.d.ts +11 -0
- package/dist/api/subscriber-subscribe-options.d.ts +6 -0
- package/dist/api/subscriber.d.ts +94 -0
- package/dist/api/subscription-delegate.d.ts +12 -0
- package/dist/api/subscription-options.d.ts +8 -0
- package/dist/api/subscription-state.d.ts +19 -0
- package/dist/api/subscription-subscribe-options.d.ts +6 -0
- package/dist/api/subscription-unsubscribe-options.d.ts +6 -0
- package/dist/api/subscription.d.ts +84 -0
- package/dist/api/transport-state.d.ts +37 -0
- package/dist/api/transport.d.ts +159 -0
- package/dist/api/user-agent-delegate.d.ts +84 -0
- package/dist/api/user-agent-options.d.ts +253 -0
- package/dist/api/user-agent-state.d.ts +14 -0
- package/dist/api/user-agent.d.ts +200 -0
- package/dist/core/dialogs/dialog-state.d.ts +34 -0
- package/dist/core/dialogs/dialog.d.ts +161 -0
- package/dist/core/dialogs/index.d.ts +4 -0
- package/dist/core/dialogs/session-dialog.d.ts +196 -0
- package/dist/core/dialogs/subscription-dialog.d.ts +120 -0
- package/dist/core/exceptions/exception.d.ts +8 -0
- package/dist/core/exceptions/index.d.ts +3 -0
- package/dist/core/exceptions/transaction-state-error.d.ts +8 -0
- package/dist/core/exceptions/transport-error.d.ts +8 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/log/index.d.ts +3 -0
- package/dist/core/log/levels.d.ts +10 -0
- package/dist/core/log/logger-factory.d.ts +21 -0
- package/dist/core/log/logger.d.ts +19 -0
- package/dist/core/messages/body.d.ts +64 -0
- package/dist/core/messages/digest-authentication.d.ts +51 -0
- package/dist/core/messages/incoming-message.d.ts +79 -0
- package/dist/core/messages/incoming-request-message.d.ts +10 -0
- package/dist/core/messages/incoming-request.d.ts +67 -0
- package/dist/core/messages/incoming-response-message.d.ts +10 -0
- package/dist/core/messages/incoming-response.d.ts +12 -0
- package/dist/core/messages/index.d.ts +13 -0
- package/dist/core/messages/md5.d.ts +32 -0
- package/dist/core/messages/methods/ack.d.ts +18 -0
- package/dist/core/messages/methods/bye.d.ts +21 -0
- package/dist/core/messages/methods/cancel.d.ts +21 -0
- package/dist/core/messages/methods/constants.d.ts +20 -0
- package/dist/core/messages/methods/index.d.ts +13 -0
- package/dist/core/messages/methods/info.d.ts +21 -0
- package/dist/core/messages/methods/invite.d.ts +86 -0
- package/dist/core/messages/methods/message.d.ts +21 -0
- package/dist/core/messages/methods/notify.d.ts +21 -0
- package/dist/core/messages/methods/prack.d.ts +21 -0
- package/dist/core/messages/methods/publish.d.ts +21 -0
- package/dist/core/messages/methods/refer.d.ts +21 -0
- package/dist/core/messages/methods/register.d.ts +21 -0
- package/dist/core/messages/methods/subscribe.d.ts +54 -0
- package/dist/core/messages/outgoing-request-message.d.ts +94 -0
- package/dist/core/messages/outgoing-request.d.ts +67 -0
- package/dist/core/messages/outgoing-response.d.ts +42 -0
- package/dist/core/messages/parser.d.ts +14 -0
- package/dist/core/messages/utils.d.ts +24 -0
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/session-delegate.d.ts +70 -0
- package/dist/core/session/session.d.ts +134 -0
- package/dist/core/subscription/index.d.ts +2 -0
- package/dist/core/subscription/subscription-delegate.d.ts +27 -0
- package/dist/core/subscription/subscription.d.ts +55 -0
- package/dist/core/timers.d.ts +20 -0
- package/dist/core/transactions/client-transaction.d.ts +45 -0
- package/dist/core/transactions/index.d.ts +10 -0
- package/dist/core/transactions/invite-client-transaction.d.ts +116 -0
- package/dist/core/transactions/invite-server-transaction.d.ts +127 -0
- package/dist/core/transactions/non-invite-client-transaction.d.ts +69 -0
- package/dist/core/transactions/non-invite-server-transaction.d.ts +57 -0
- package/dist/core/transactions/server-transaction.d.ts +35 -0
- package/dist/core/transactions/transaction-state.d.ts +13 -0
- package/dist/core/transactions/transaction-user.d.ts +72 -0
- package/dist/core/transactions/transaction.d.ts +79 -0
- package/dist/core/transport.d.ts +31 -0
- package/dist/core/user-agent-core/allowed-methods.d.ts +4 -0
- package/dist/core/user-agent-core/index.d.ts +3 -0
- package/dist/core/user-agent-core/user-agent-core-configuration.d.ts +99 -0
- package/dist/core/user-agent-core/user-agent-core-delegate.d.ts +37 -0
- package/dist/core/user-agent-core/user-agent-core.d.ts +179 -0
- package/dist/core/user-agents/bye-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/bye-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/cancel-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/index.d.ts +26 -0
- package/dist/core/user-agents/info-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/info-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/invite-user-agent-client.d.ts +35 -0
- package/dist/core/user-agents/invite-user-agent-server.d.ts +77 -0
- package/dist/core/user-agents/message-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/message-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/notify-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/notify-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/prack-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/prack-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/publish-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/re-invite-user-agent-client.d.ts +18 -0
- package/dist/core/user-agents/re-invite-user-agent-server.d.ts +41 -0
- package/dist/core/user-agents/re-subscribe-user-agent-client.d.ts +17 -0
- package/dist/core/user-agents/re-subscribe-user-agent-server.d.ts +10 -0
- package/dist/core/user-agents/refer-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/refer-user-agent-server.d.ts +16 -0
- package/dist/core/user-agents/register-user-agent-client.d.ts +10 -0
- package/dist/core/user-agents/register-user-agent-server.d.ts +11 -0
- package/dist/core/user-agents/subscribe-user-agent-client.d.ts +65 -0
- package/dist/core/user-agents/subscribe-user-agent-server.d.ts +11 -0
- package/dist/core/user-agents/user-agent-client.d.ts +103 -0
- package/dist/core/user-agents/user-agent-server.d.ts +79 -0
- package/dist/grammar/grammar.d.ts +26 -0
- package/dist/grammar/index.d.ts +4 -0
- package/dist/grammar/name-addr-header.d.ts +24 -0
- package/dist/grammar/parameters.d.ts +16 -0
- package/dist/grammar/pegjs/dist/grammar.d.ts +50 -0
- package/dist/grammar/uri.d.ts +62 -0
- package/dist/{types/index.d.ts → index.d.ts} +7 -3
- package/dist/main.d.ts +9 -0
- package/dist/new-index.d.ts +199 -0
- package/dist/platform/web/index.d.ts +4 -0
- package/dist/platform/web/modifiers/index.d.ts +5 -0
- package/dist/platform/web/modifiers/modifiers.d.ts +41 -0
- package/dist/platform/web/session-description-handler/index.d.ts +14 -0
- package/dist/platform/web/session-description-handler/media-stream-factory-default.d.ts +6 -0
- package/dist/platform/web/session-description-handler/media-stream-factory.d.ts +6 -0
- package/dist/platform/web/session-description-handler/peer-connection-configuration-default.d.ts +5 -0
- package/dist/platform/web/session-description-handler/peer-connection-delegate.d.ts +63 -0
- package/dist/platform/web/session-description-handler/session-description-handler-configuration.d.ts +16 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory-default.d.ts +11 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory-options.d.ts +9 -0
- package/dist/platform/web/session-description-handler/session-description-handler-factory.d.ts +16 -0
- package/dist/platform/web/session-description-handler/session-description-handler-options.d.ts +47 -0
- package/dist/platform/web/session-description-handler/session-description-handler.d.ts +212 -0
- package/dist/platform/web/simple-user/index.d.ts +7 -0
- package/dist/platform/web/simple-user/simple-user-delegate.d.ts +72 -0
- package/dist/platform/web/simple-user/simple-user-options.d.ts +90 -0
- package/dist/platform/web/simple-user/simple-user.d.ts +226 -0
- package/dist/platform/web/transport/index.d.ts +6 -0
- package/dist/platform/web/transport/transport-options.d.ts +30 -0
- package/dist/platform/web/transport/transport.d.ts +125 -0
- package/dist/ue-softphone-sdk.js +2 -1
- package/dist/ue-softphone-sdk.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/webPhoneSdk.d.ts +24 -0
- package/dist/webrtc.d.ts +17 -0
- package/{rollup-new.config.mjs → new-rollup.config.mjs} +1 -1
- package/package.json +6 -6
- package/rollup.config.js +15 -14
- package/src/api/api-extractor.json +358 -0
- package/src/api/bye.ts +27 -0
- package/src/api/dtmf.ts +27 -0
- package/src/api/emitter.ts +110 -0
- package/src/api/exceptions/content-type-unsupported.ts +11 -0
- package/src/api/exceptions/index.ts +5 -0
- package/src/api/exceptions/request-pending.ts +12 -0
- package/src/api/exceptions/session-description-handler.ts +11 -0
- package/src/api/exceptions/session-terminated.ts +11 -0
- package/src/api/exceptions/state-transition.ts +11 -0
- package/src/api/index.ts +58 -0
- package/src/api/info.ts +27 -0
- package/src/api/invitation-accept-options.ts +20 -0
- package/src/api/invitation-progress-options.ts +36 -0
- package/src/api/invitation-reject-options.ts +22 -0
- package/src/api/invitation.ts +816 -0
- package/src/api/inviter-cancel-options.ts +9 -0
- package/src/api/inviter-invite-options.ts +29 -0
- package/src/api/inviter-options.ts +44 -0
- package/src/api/inviter.ts +1126 -0
- package/src/api/message.ts +27 -0
- package/src/api/messager-message-options.ts +12 -0
- package/src/api/messager-options.ts +18 -0
- package/src/api/messager.ts +89 -0
- package/src/api/notification.ts +27 -0
- package/src/api/notifier.ts +7 -0
- package/src/api/publisher-options.ts +34 -0
- package/src/api/publisher-publish-options.ts +6 -0
- package/src/api/publisher-state.ts +21 -0
- package/src/api/publisher-unpublish-options.ts +6 -0
- package/src/api/publisher.ts +418 -0
- package/src/api/referral.ts +89 -0
- package/src/api/registerer-options.ts +55 -0
- package/src/api/registerer-register-options.ts +12 -0
- package/src/api/registerer-state.ts +21 -0
- package/src/api/registerer-unregister-options.ts +17 -0
- package/src/api/registerer.ts +814 -0
- package/src/api/session-bye-options.ts +12 -0
- package/src/api/session-delegate.ts +80 -0
- package/src/api/session-description-handler-factory.ts +16 -0
- package/src/api/session-description-handler.ts +89 -0
- package/src/api/session-info-options.ts +12 -0
- package/src/api/session-invite-options.ts +29 -0
- package/src/api/session-message-options.ts +12 -0
- package/src/api/session-options.ts +8 -0
- package/src/api/session-refer-options.ts +15 -0
- package/src/api/session-state.ts +45 -0
- package/src/api/session.ts +1448 -0
- package/src/api/subscriber-options.ts +12 -0
- package/src/api/subscriber-subscribe-options.ts +6 -0
- package/src/api/subscriber.ts +536 -0
- package/src/api/subscription-delegate.ts +13 -0
- package/src/api/subscription-options.ts +8 -0
- package/src/api/subscription-state.ts +19 -0
- package/src/api/subscription-subscribe-options.ts +6 -0
- package/src/api/subscription-unsubscribe-options.ts +6 -0
- package/src/api/subscription.ts +161 -0
- package/src/api/transport-state.ts +37 -0
- package/src/api/transport.ts +169 -0
- package/src/api/user-agent-delegate.ts +95 -0
- package/src/api/user-agent-options.ts +322 -0
- package/src/api/user-agent-state.ts +14 -0
- package/src/api/user-agent.ts +1014 -0
- package/src/core/api-extractor.json +358 -0
- package/src/core/dialogs/dialog-state.ts +35 -0
- package/src/core/dialogs/dialog.ts +605 -0
- package/src/core/dialogs/index.ts +4 -0
- package/src/core/dialogs/session-dialog.ts +996 -0
- package/src/core/dialogs/subscription-dialog.ts +557 -0
- package/src/core/exceptions/exception.ts +11 -0
- package/src/core/exceptions/index.ts +3 -0
- package/src/core/exceptions/transaction-state-error.ts +11 -0
- package/src/core/exceptions/transport-error.ts +11 -0
- package/src/core/index.ts +19 -0
- package/src/core/log/index.ts +3 -0
- package/src/core/log/levels.ts +10 -0
- package/src/core/log/logger-factory.ts +119 -0
- package/src/core/log/logger.ts +42 -0
- package/src/core/messages/body.ts +171 -0
- package/src/core/messages/digest-authentication.ts +190 -0
- package/src/core/messages/incoming-message.ts +152 -0
- package/src/core/messages/incoming-request-message.ts +14 -0
- package/src/core/messages/incoming-request.ts +75 -0
- package/src/core/messages/incoming-response-message.ts +14 -0
- package/src/core/messages/incoming-response.ts +13 -0
- package/src/core/messages/index.ts +18 -0
- package/src/core/messages/md5.ts +437 -0
- package/src/core/messages/methods/ack.ts +22 -0
- package/src/core/messages/methods/bye.ts +22 -0
- package/src/core/messages/methods/cancel.ts +22 -0
- package/src/core/messages/methods/constants.ts +21 -0
- package/src/core/messages/methods/index.ts +13 -0
- package/src/core/messages/methods/info.ts +22 -0
- package/src/core/messages/methods/invite.ts +104 -0
- package/src/core/messages/methods/message.ts +22 -0
- package/src/core/messages/methods/notify.ts +22 -0
- package/src/core/messages/methods/prack.ts +22 -0
- package/src/core/messages/methods/publish.ts +22 -0
- package/src/core/messages/methods/refer.ts +22 -0
- package/src/core/messages/methods/register.ts +22 -0
- package/src/core/messages/methods/subscribe.ts +59 -0
- package/src/core/messages/outgoing-request-message.ts +299 -0
- package/src/core/messages/outgoing-request.ts +77 -0
- package/src/core/messages/outgoing-response.ts +174 -0
- package/src/core/messages/parser.ts +265 -0
- package/src/core/messages/utils.ts +144 -0
- package/src/core/session/index.ts +2 -0
- package/src/core/session/session-delegate.ts +88 -0
- package/src/core/session/session.ts +158 -0
- package/src/core/subscription/index.ts +2 -0
- package/src/core/subscription/subscription-delegate.ts +30 -0
- package/src/core/subscription/subscription.ts +61 -0
- package/src/core/timers.ts +24 -0
- package/src/core/transactions/client-transaction.ts +78 -0
- package/src/core/transactions/index.ts +10 -0
- package/src/core/transactions/invite-client-transaction.ts +504 -0
- package/src/core/transactions/invite-server-transaction.ts +432 -0
- package/src/core/transactions/non-invite-client-transaction.ts +257 -0
- package/src/core/transactions/non-invite-server-transaction.ts +241 -0
- package/src/core/transactions/server-transaction.ts +47 -0
- package/src/core/transactions/transaction-state.ts +13 -0
- package/src/core/transactions/transaction-user.ts +82 -0
- package/src/core/transactions/transaction.ts +149 -0
- package/src/core/transport.ts +32 -0
- package/src/core/user-agent-core/allowed-methods.ts +19 -0
- package/src/core/user-agent-core/index.ts +3 -0
- package/src/core/user-agent-core/user-agent-core-configuration.ts +111 -0
- package/src/core/user-agent-core/user-agent-core-delegate.ts +50 -0
- package/src/core/user-agent-core/user-agent-core.ts +905 -0
- package/src/core/user-agents/bye-user-agent-client.ts +16 -0
- package/src/core/user-agents/bye-user-agent-server.ts +14 -0
- package/src/core/user-agents/cancel-user-agent-client.ts +14 -0
- package/src/core/user-agents/index.ts +26 -0
- package/src/core/user-agents/info-user-agent-client.ts +15 -0
- package/src/core/user-agents/info-user-agent-server.ts +14 -0
- package/src/core/user-agents/invite-user-agent-client.ts +405 -0
- package/src/core/user-agents/invite-user-agent-server.ts +269 -0
- package/src/core/user-agents/message-user-agent-client.ts +14 -0
- package/src/core/user-agents/message-user-agent-server.ts +14 -0
- package/src/core/user-agents/notify-user-agent-client.ts +15 -0
- package/src/core/user-agents/notify-user-agent-server.ts +30 -0
- package/src/core/user-agents/prack-user-agent-client.ts +16 -0
- package/src/core/user-agents/prack-user-agent-server.ts +37 -0
- package/src/core/user-agents/publish-user-agent-client.ts +14 -0
- package/src/core/user-agents/re-invite-user-agent-client.ts +127 -0
- package/src/core/user-agents/re-invite-user-agent-server.ts +109 -0
- package/src/core/user-agents/re-subscribe-user-agent-client.ts +78 -0
- package/src/core/user-agents/re-subscribe-user-agent-server.ts +14 -0
- package/src/core/user-agents/refer-user-agent-client.ts +15 -0
- package/src/core/user-agents/refer-user-agent-server.ts +30 -0
- package/src/core/user-agents/register-user-agent-client.ts +14 -0
- package/src/core/user-agents/register-user-agent-server.ts +14 -0
- package/src/core/user-agents/subscribe-user-agent-client.ts +341 -0
- package/src/core/user-agents/subscribe-user-agent-server.ts +14 -0
- package/src/core/user-agents/user-agent-client.ts +378 -0
- package/src/core/user-agents/user-agent-server.ts +276 -0
- package/src/grammar/grammar.ts +55 -0
- package/src/grammar/index.ts +4 -0
- package/src/grammar/name-addr-header.ts +58 -0
- package/src/grammar/parameters.ts +45 -0
- package/src/grammar/pegjs/README.md +9 -0
- package/src/grammar/pegjs/dist/grammar.ts +1557 -0
- package/src/grammar/pegjs/src/grammar.pegjs +1009 -0
- package/src/grammar/uri.ts +370 -0
- package/src/index.ts +49 -26
- package/src/lib/socket.io.esm.min.js +7 -0
- package/src/main.ts +26 -0
- package/src/new-index.ts +2478 -0
- package/src/platform/react/README.md +1 -0
- package/src/platform/web/index.ts +4 -0
- package/src/platform/web/modifiers/index.ts +5 -0
- package/src/platform/web/modifiers/modifiers.ts +180 -0
- package/src/platform/web/session-description-handler/api-extractor.json +358 -0
- package/src/platform/web/session-description-handler/index.ts +14 -0
- package/src/platform/web/session-description-handler/media-stream-factory-default.ts +22 -0
- package/src/platform/web/session-description-handler/media-stream-factory.ts +10 -0
- package/src/platform/web/session-description-handler/peer-connection-configuration-default.ts +17 -0
- package/src/platform/web/session-description-handler/peer-connection-delegate.ts +72 -0
- package/src/platform/web/session-description-handler/session-description-handler-configuration.ts +17 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory-default.ts +45 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory-options.ts +10 -0
- package/src/platform/web/session-description-handler/session-description-handler-factory.ts +17 -0
- package/src/platform/web/session-description-handler/session-description-handler-options.ts +56 -0
- package/src/platform/web/session-description-handler/session-description-handler.ts +938 -0
- package/src/platform/web/simple-user/api-extractor.json +358 -0
- package/src/platform/web/simple-user/index.ts +7 -0
- package/src/platform/web/simple-user/simple-user-delegate.ts +82 -0
- package/src/platform/web/simple-user/simple-user-options.ts +102 -0
- package/src/platform/web/simple-user/simple-user.ts +1099 -0
- package/src/platform/web/transport/api-extractor.json +358 -0
- package/src/platform/web/transport/index.ts +6 -0
- package/src/platform/web/transport/transport-options.ts +34 -0
- package/src/platform/web/transport/transport.ts +742 -0
- package/src/version.ts +8 -0
- package/src/webPhoneSdk.ts +67 -0
- package/src/webrtc.ts +318 -0
- package/tsconfig.json +26 -10
- /package/dist/{types/config.d.ts → config.d.ts} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Levels } from "./levels";
|
|
2
|
+
import { Logger } from "./logger";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Logger.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class LoggerFactory {
|
|
9
|
+
public builtinEnabled = true;
|
|
10
|
+
|
|
11
|
+
private _level: Levels = Levels.log;
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
private _connector: ((level: string, category: string, label: string | undefined, content: any) => void) | undefined;
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
private loggers: any = {};
|
|
17
|
+
private logger: Logger;
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
this.logger = this.getLogger("sip:loggerfactory");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get level(): Levels {
|
|
24
|
+
return this._level;
|
|
25
|
+
}
|
|
26
|
+
set level(newLevel: Levels) {
|
|
27
|
+
if (newLevel >= 0 && newLevel <= 3) {
|
|
28
|
+
this._level = newLevel;
|
|
29
|
+
} else if (newLevel > 3) {
|
|
30
|
+
this._level = 3;
|
|
31
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
32
|
+
} else if (Levels.hasOwnProperty(newLevel)) {
|
|
33
|
+
this._level = newLevel;
|
|
34
|
+
} else {
|
|
35
|
+
this.logger.error("invalid 'level' parameter value: " + JSON.stringify(newLevel));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
get connector(): ((level: string, category: string, label: string | undefined, content: any) => void) | undefined {
|
|
41
|
+
return this._connector;
|
|
42
|
+
}
|
|
43
|
+
set connector(
|
|
44
|
+
value:
|
|
45
|
+
| ((
|
|
46
|
+
level: string,
|
|
47
|
+
category: string,
|
|
48
|
+
label: string | undefined,
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
content: any
|
|
51
|
+
) => void)
|
|
52
|
+
| undefined
|
|
53
|
+
) {
|
|
54
|
+
if (!value) {
|
|
55
|
+
this._connector = undefined;
|
|
56
|
+
} else if (typeof value === "function") {
|
|
57
|
+
this._connector = value;
|
|
58
|
+
} else {
|
|
59
|
+
this.logger.error("invalid 'connector' parameter value: " + JSON.stringify(value));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public getLogger(category: string, label?: string): Logger {
|
|
64
|
+
if (label && this.level === 3) {
|
|
65
|
+
return new Logger(this, category, label);
|
|
66
|
+
} else if (this.loggers[category]) {
|
|
67
|
+
return this.loggers[category];
|
|
68
|
+
} else {
|
|
69
|
+
const logger = new Logger(this, category);
|
|
70
|
+
this.loggers[category] = logger;
|
|
71
|
+
return logger;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
public genericLog(levelToLog: Levels, category: string, label: string | undefined, content: any): void {
|
|
77
|
+
if (this.level >= levelToLog) {
|
|
78
|
+
if (this.builtinEnabled) {
|
|
79
|
+
this.print(levelToLog, category, label, content);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (this.connector) {
|
|
84
|
+
this.connector(Levels[levelToLog], category, label, content);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
private print(levelToLog: Levels, category: string, label: string | undefined, content: any): void {
|
|
90
|
+
if (typeof content === "string") {
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
const prefix: Array<any> = [new Date(), category];
|
|
93
|
+
if (label) {
|
|
94
|
+
prefix.push(label);
|
|
95
|
+
}
|
|
96
|
+
content = prefix.concat(content).join(" | ");
|
|
97
|
+
}
|
|
98
|
+
switch (levelToLog) {
|
|
99
|
+
case Levels.error:
|
|
100
|
+
// eslint-disable-next-line no-console
|
|
101
|
+
console.error(content);
|
|
102
|
+
break;
|
|
103
|
+
case Levels.warn:
|
|
104
|
+
// eslint-disable-next-line no-console
|
|
105
|
+
console.warn(content);
|
|
106
|
+
break;
|
|
107
|
+
case Levels.log:
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.log(content);
|
|
110
|
+
break;
|
|
111
|
+
case Levels.debug:
|
|
112
|
+
// eslint-disable-next-line no-console
|
|
113
|
+
console.debug(content);
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Levels } from "./levels";
|
|
2
|
+
import { LoggerFactory } from "./logger-factory";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Logger.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class Logger {
|
|
9
|
+
private logger: LoggerFactory;
|
|
10
|
+
private category: string;
|
|
11
|
+
private label: string | undefined;
|
|
12
|
+
|
|
13
|
+
constructor(logger: LoggerFactory, category: string, label?: string) {
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.category = category;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public error(content: string): void {
|
|
20
|
+
this.genericLog(Levels.error, content);
|
|
21
|
+
}
|
|
22
|
+
public warn(content: string): void {
|
|
23
|
+
this.genericLog(Levels.warn, content);
|
|
24
|
+
}
|
|
25
|
+
public log(content: string): void {
|
|
26
|
+
this.genericLog(Levels.log, content);
|
|
27
|
+
}
|
|
28
|
+
public debug(content: string): void {
|
|
29
|
+
this.genericLog(Levels.debug, content);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private genericLog(level: Levels, content: string): void {
|
|
33
|
+
this.logger.genericLog(level, this.category, this.label, content);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get level(): Levels {
|
|
37
|
+
return this.logger.level;
|
|
38
|
+
}
|
|
39
|
+
set level(newLevel: Levels) {
|
|
40
|
+
this.logger.level = newLevel;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { IncomingRequestMessage } from "./incoming-request-message";
|
|
2
|
+
import { IncomingResponseMessage } from "./incoming-response-message";
|
|
3
|
+
import { OutgoingRequestMessage } from "./outgoing-request-message";
|
|
4
|
+
|
|
5
|
+
// If the Content-Disposition header field is missing, bodies of
|
|
6
|
+
// Content-Type application/sdp imply the disposition "session", while
|
|
7
|
+
// other content types imply "render".
|
|
8
|
+
// https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
9
|
+
function contentTypeToContentDisposition(contentType: string): string {
|
|
10
|
+
if (contentType === "application/sdp") {
|
|
11
|
+
return "session";
|
|
12
|
+
} else {
|
|
13
|
+
return "render";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Message body.
|
|
19
|
+
* @remarks
|
|
20
|
+
* https://tools.ietf.org/html/rfc3261#section-7.4
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface Body {
|
|
24
|
+
/**
|
|
25
|
+
* If the Content-Disposition header field is missing, bodies of
|
|
26
|
+
* Content-Type application/sdp imply the disposition "session", while
|
|
27
|
+
* other content types imply "render".
|
|
28
|
+
* https://tools.ietf.org/html/rfc3261#section-13.2.1
|
|
29
|
+
* For backward-compatibility, if the Content-Disposition header field
|
|
30
|
+
* is missing, the server SHOULD assume bodies of Content-Type
|
|
31
|
+
* application/sdp are the disposition "session", while other content
|
|
32
|
+
* types are "render".
|
|
33
|
+
* https://tools.ietf.org/html/rfc3261#section-20.11
|
|
34
|
+
*/
|
|
35
|
+
contentDisposition: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The Content-Type header field indicates the media type of the
|
|
39
|
+
* message-body sent to the recipient. The Content-Type header field
|
|
40
|
+
* MUST be present if the body is not empty. If the body is empty,
|
|
41
|
+
* and a Content-Type header field is present, it indicates that the body
|
|
42
|
+
* of the specific type has zero length (for example, an empty audio file).
|
|
43
|
+
* https://tools.ietf.org/html/rfc3261#section-20.15
|
|
44
|
+
*/
|
|
45
|
+
contentType: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Requests, including new requests defined in extensions to this
|
|
49
|
+
* specification, MAY contain message bodies unless otherwise noted.
|
|
50
|
+
* The interpretation of the body depends on the request method.
|
|
51
|
+
* For response messages, the request method and the response status
|
|
52
|
+
* code determine the type and interpretation of any message body. All
|
|
53
|
+
* responses MAY include a body.
|
|
54
|
+
* https://tools.ietf.org/html/rfc3261#section-7.4
|
|
55
|
+
*/
|
|
56
|
+
content: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create a Body given a legacy body type.
|
|
61
|
+
* @param bodyLegacy - Body Object
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export function fromBodyLegacy(bodyLegacy: string | { body: string; contentType: string }): Body {
|
|
65
|
+
const content = typeof bodyLegacy === "string" ? bodyLegacy : bodyLegacy.body;
|
|
66
|
+
const contentType = typeof bodyLegacy === "string" ? "application/sdp" : bodyLegacy.contentType;
|
|
67
|
+
const contentDisposition = contentTypeToContentDisposition(contentType);
|
|
68
|
+
const body: Body = { contentDisposition, contentType, content };
|
|
69
|
+
return body;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* User-Defined Type Guard for Body.
|
|
74
|
+
* @param body - Body to check.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
export function isBody(body: any): body is Body {
|
|
79
|
+
return body &&
|
|
80
|
+
typeof body.content === "string" &&
|
|
81
|
+
typeof body.contentType === "string" &&
|
|
82
|
+
body.contentDisposition === undefined
|
|
83
|
+
? true
|
|
84
|
+
: typeof body.contentDisposition === "string";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Given a message, get a normalized body.
|
|
89
|
+
* The content disposition is inferred if not set.
|
|
90
|
+
* @param message - The message.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export function getBody(
|
|
94
|
+
message: IncomingRequestMessage | IncomingResponseMessage | OutgoingRequestMessage | Body
|
|
95
|
+
): Body | undefined {
|
|
96
|
+
let contentDisposition: string | undefined;
|
|
97
|
+
let contentType: string | undefined;
|
|
98
|
+
let content: string | undefined;
|
|
99
|
+
|
|
100
|
+
// We're in UAS role, receiving incoming request
|
|
101
|
+
if (message instanceof IncomingRequestMessage) {
|
|
102
|
+
if (message.body) {
|
|
103
|
+
// FIXME: Parsing needs typing
|
|
104
|
+
const parse = message.parseHeader("Content-Disposition");
|
|
105
|
+
contentDisposition = parse ? parse.type : undefined;
|
|
106
|
+
contentType = message.parseHeader("Content-Type");
|
|
107
|
+
content = message.body;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// We're in UAC role, receiving incoming response
|
|
112
|
+
if (message instanceof IncomingResponseMessage) {
|
|
113
|
+
if (message.body) {
|
|
114
|
+
// FIXME: Parsing needs typing
|
|
115
|
+
const parse = message.parseHeader("Content-Disposition");
|
|
116
|
+
contentDisposition = parse ? parse.type : undefined;
|
|
117
|
+
contentType = message.parseHeader("Content-Type");
|
|
118
|
+
content = message.body;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// We're in UAC role, sending outgoing request
|
|
123
|
+
if (message instanceof OutgoingRequestMessage) {
|
|
124
|
+
if (message.body) {
|
|
125
|
+
contentDisposition = message.getHeader("Content-Disposition");
|
|
126
|
+
contentType = message.getHeader("Content-Type");
|
|
127
|
+
if (typeof message.body === "string") {
|
|
128
|
+
// FIXME: OutgoingRequest should not allow a "string" body without a "Content-Type" header.
|
|
129
|
+
if (!contentType) {
|
|
130
|
+
throw new Error("Header content type header does not equal body content type.");
|
|
131
|
+
}
|
|
132
|
+
content = message.body;
|
|
133
|
+
} else {
|
|
134
|
+
// FIXME: OutgoingRequest should not allow the "Content-Type" header not to match th body content type
|
|
135
|
+
if (contentType && contentType !== message.body.contentType) {
|
|
136
|
+
throw new Error("Header content type header does not equal body content type.");
|
|
137
|
+
}
|
|
138
|
+
contentType = message.body.contentType;
|
|
139
|
+
content = message.body.body;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// We're in UAS role, sending outgoing response
|
|
145
|
+
if (isBody(message)) {
|
|
146
|
+
contentDisposition = message.contentDisposition;
|
|
147
|
+
contentType = message.contentType;
|
|
148
|
+
content = message.content;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// No content, no body.
|
|
152
|
+
if (!content) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (contentType && !contentDisposition) {
|
|
157
|
+
contentDisposition = contentTypeToContentDisposition(contentType);
|
|
158
|
+
}
|
|
159
|
+
if (!contentDisposition) {
|
|
160
|
+
throw new Error("Content disposition undefined.");
|
|
161
|
+
}
|
|
162
|
+
if (!contentType) {
|
|
163
|
+
throw new Error("Content type undefined.");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
contentDisposition,
|
|
168
|
+
contentType,
|
|
169
|
+
content
|
|
170
|
+
};
|
|
171
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Md5 } from "./md5";
|
|
2
|
+
|
|
3
|
+
import { URI } from "../../grammar";
|
|
4
|
+
import { Logger, LoggerFactory } from "../log";
|
|
5
|
+
import { OutgoingRequestMessage } from "./outgoing-request-message";
|
|
6
|
+
import { createRandomToken } from "./utils";
|
|
7
|
+
|
|
8
|
+
function MD5(s: string): string {
|
|
9
|
+
return Md5.hashStr(s);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Digest Authentication.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export class DigestAuthentication {
|
|
17
|
+
public stale: boolean | undefined;
|
|
18
|
+
|
|
19
|
+
private logger: Logger;
|
|
20
|
+
private ha1: string | undefined;
|
|
21
|
+
private username: string | undefined;
|
|
22
|
+
private password: string | undefined;
|
|
23
|
+
private cnonce: string | undefined;
|
|
24
|
+
private nc: number;
|
|
25
|
+
private ncHex: string;
|
|
26
|
+
private response: string | undefined;
|
|
27
|
+
private algorithm: string | undefined;
|
|
28
|
+
private realm: string | undefined;
|
|
29
|
+
private nonce: string | undefined;
|
|
30
|
+
private opaque: string | undefined;
|
|
31
|
+
private qop: string | undefined;
|
|
32
|
+
private method: string | undefined;
|
|
33
|
+
private uri: string | URI | undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Constructor.
|
|
37
|
+
* @param loggerFactory - LoggerFactory.
|
|
38
|
+
* @param username - Username.
|
|
39
|
+
* @param password - Password.
|
|
40
|
+
*/
|
|
41
|
+
constructor(
|
|
42
|
+
loggerFactory: LoggerFactory,
|
|
43
|
+
ha1: string | undefined,
|
|
44
|
+
username: string | undefined,
|
|
45
|
+
password: string | undefined
|
|
46
|
+
) {
|
|
47
|
+
this.logger = loggerFactory.getLogger("sipjs.digestauthentication");
|
|
48
|
+
this.username = username;
|
|
49
|
+
this.password = password;
|
|
50
|
+
this.ha1 = ha1;
|
|
51
|
+
this.nc = 0;
|
|
52
|
+
this.ncHex = "00000000";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Performs Digest authentication given a SIP request and the challenge
|
|
57
|
+
* received in a response to that request.
|
|
58
|
+
* @param request -
|
|
59
|
+
* @param challenge -
|
|
60
|
+
* @returns true if credentials were successfully generated, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
public authenticate(request: OutgoingRequestMessage, challenge: any, body?: string): boolean {
|
|
64
|
+
// Inspect and validate the challenge.
|
|
65
|
+
|
|
66
|
+
this.algorithm = challenge.algorithm;
|
|
67
|
+
this.realm = challenge.realm;
|
|
68
|
+
this.nonce = challenge.nonce;
|
|
69
|
+
this.opaque = challenge.opaque;
|
|
70
|
+
this.stale = challenge.stale;
|
|
71
|
+
|
|
72
|
+
if (this.algorithm) {
|
|
73
|
+
if (this.algorithm !== "MD5") {
|
|
74
|
+
this.logger.warn("challenge with Digest algorithm different than 'MD5', authentication aborted");
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
this.algorithm = "MD5";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!this.realm) {
|
|
82
|
+
this.logger.warn("challenge without Digest realm, authentication aborted");
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!this.nonce) {
|
|
87
|
+
this.logger.warn("challenge without Digest nonce, authentication aborted");
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 'qop' can contain a list of values (Array). Let's choose just one.
|
|
92
|
+
if (challenge.qop) {
|
|
93
|
+
if (challenge.qop.indexOf("auth") > -1) {
|
|
94
|
+
this.qop = "auth";
|
|
95
|
+
} else if (challenge.qop.indexOf("auth-int") > -1) {
|
|
96
|
+
this.qop = "auth-int";
|
|
97
|
+
} else {
|
|
98
|
+
// Otherwise 'qop' is present but does not contain 'auth' or 'auth-int', so abort here.
|
|
99
|
+
this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted");
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
this.qop = undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Fill other attributes.
|
|
107
|
+
|
|
108
|
+
this.method = request.method;
|
|
109
|
+
this.uri = request.ruri;
|
|
110
|
+
this.cnonce = createRandomToken(12);
|
|
111
|
+
this.nc += 1;
|
|
112
|
+
this.updateNcHex();
|
|
113
|
+
|
|
114
|
+
// nc-value = 8LHEX. Max value = 'FFFFFFFF'.
|
|
115
|
+
if (this.nc === 4294967296) {
|
|
116
|
+
this.nc = 1;
|
|
117
|
+
this.ncHex = "00000001";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Calculate the Digest "response" value.
|
|
121
|
+
this.calculateResponse(body);
|
|
122
|
+
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Return the Proxy-Authorization or WWW-Authorization header value.
|
|
128
|
+
*/
|
|
129
|
+
public toString(): string {
|
|
130
|
+
const authParams: Array<string> = [];
|
|
131
|
+
|
|
132
|
+
if (!this.response) {
|
|
133
|
+
throw new Error("response field does not exist, cannot generate Authorization header");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
authParams.push("algorithm=" + this.algorithm);
|
|
137
|
+
authParams.push('username="' + this.username + '"');
|
|
138
|
+
authParams.push('realm="' + this.realm + '"');
|
|
139
|
+
authParams.push('nonce="' + this.nonce + '"');
|
|
140
|
+
authParams.push('uri="' + this.uri + '"');
|
|
141
|
+
authParams.push('response="' + this.response + '"');
|
|
142
|
+
if (this.opaque) {
|
|
143
|
+
authParams.push('opaque="' + this.opaque + '"');
|
|
144
|
+
}
|
|
145
|
+
if (this.qop) {
|
|
146
|
+
authParams.push("qop=" + this.qop);
|
|
147
|
+
authParams.push('cnonce="' + this.cnonce + '"');
|
|
148
|
+
authParams.push("nc=" + this.ncHex);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return "Digest " + authParams.join(", ");
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Generate the 'nc' value as required by Digest in this.ncHex by reading this.nc.
|
|
155
|
+
*/
|
|
156
|
+
private updateNcHex(): void {
|
|
157
|
+
const hex = Number(this.nc).toString(16);
|
|
158
|
+
this.ncHex = "00000000".substr(0, 8 - hex.length) + hex;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Generate Digest 'response' value.
|
|
163
|
+
*/
|
|
164
|
+
private calculateResponse(body?: string): void {
|
|
165
|
+
let ha1, ha2;
|
|
166
|
+
|
|
167
|
+
// HA1 = MD5(A1) = MD5(username:realm:password)
|
|
168
|
+
ha1 = this.ha1;
|
|
169
|
+
if (ha1 === "" || ha1 === undefined) {
|
|
170
|
+
ha1 = MD5(this.username + ":" + this.realm + ":" + this.password);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (this.qop === "auth") {
|
|
174
|
+
// HA2 = MD5(A2) = MD5(method:digestURI)
|
|
175
|
+
ha2 = MD5(this.method + ":" + this.uri);
|
|
176
|
+
// response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2)`
|
|
177
|
+
this.response = MD5(ha1 + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth:" + ha2);
|
|
178
|
+
} else if (this.qop === "auth-int") {
|
|
179
|
+
// HA2 = MD5(A2) = MD5(method:digestURI:MD5(entityBody))
|
|
180
|
+
ha2 = MD5(this.method + ":" + this.uri + ":" + MD5(body ? body : ""));
|
|
181
|
+
// response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2)
|
|
182
|
+
this.response = MD5(ha1 + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth-int:" + ha2);
|
|
183
|
+
} else if (this.qop === undefined) {
|
|
184
|
+
// HA2 = MD5(A2) = MD5(method:digestURI)
|
|
185
|
+
ha2 = MD5(this.method + ":" + this.uri);
|
|
186
|
+
// response = MD5(HA1:nonce:HA2)
|
|
187
|
+
this.response = MD5(ha1 + ":" + this.nonce + ":" + ha2);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Grammar, NameAddrHeader } from "../../grammar";
|
|
2
|
+
import { headerize } from "./utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Incoming message.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class IncomingMessage {
|
|
9
|
+
public viaBranch!: string;
|
|
10
|
+
public method!: string;
|
|
11
|
+
public body!: string;
|
|
12
|
+
public toTag!: string;
|
|
13
|
+
public to!: NameAddrHeader;
|
|
14
|
+
public fromTag!: string;
|
|
15
|
+
public from!: NameAddrHeader;
|
|
16
|
+
public callId!: string;
|
|
17
|
+
public cseq!: number;
|
|
18
|
+
public via!: { host: string; port: number };
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
public headers: { [name: string]: Array<{ parsed?: any; raw: string }> } = {};
|
|
21
|
+
public referTo: string | undefined;
|
|
22
|
+
public data!: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Insert a header of the given name and value into the last position of the
|
|
26
|
+
* header array.
|
|
27
|
+
* @param name - header name
|
|
28
|
+
* @param value - header value
|
|
29
|
+
*/
|
|
30
|
+
public addHeader(name: string, value: string): void {
|
|
31
|
+
const header = { raw: value };
|
|
32
|
+
name = headerize(name);
|
|
33
|
+
|
|
34
|
+
if (this.headers[name]) {
|
|
35
|
+
this.headers[name].push(header);
|
|
36
|
+
} else {
|
|
37
|
+
this.headers[name] = [header];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get the value of the given header name at the given position.
|
|
43
|
+
* @param name - header name
|
|
44
|
+
* @returns Returns the specified header, undefined if header doesn't exist.
|
|
45
|
+
*/
|
|
46
|
+
public getHeader(name: string): string | undefined {
|
|
47
|
+
const header = this.headers[headerize(name)];
|
|
48
|
+
|
|
49
|
+
if (header) {
|
|
50
|
+
if (header[0]) {
|
|
51
|
+
return header[0].raw;
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get the header/s of the given name.
|
|
60
|
+
* @param name - header name
|
|
61
|
+
* @returns Array - with all the headers of the specified name.
|
|
62
|
+
*/
|
|
63
|
+
public getHeaders(name: string): Array<string> {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
const header: Array<any> = this.headers[headerize(name)];
|
|
66
|
+
const result: Array<string> = [];
|
|
67
|
+
|
|
68
|
+
if (!header) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
for (const headerPart of header) {
|
|
72
|
+
result.push(headerPart.raw);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Verify the existence of the given header.
|
|
79
|
+
* @param name - header name
|
|
80
|
+
* @returns true if header with given name exists, false otherwise
|
|
81
|
+
*/
|
|
82
|
+
public hasHeader(name: string): boolean {
|
|
83
|
+
return !!this.headers[headerize(name)];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Parse the given header on the given index.
|
|
88
|
+
* @param name - header name
|
|
89
|
+
* @param idx - header index
|
|
90
|
+
* @returns Parsed header object, undefined if the
|
|
91
|
+
* header is not present or in case of a parsing error.
|
|
92
|
+
*/
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
public parseHeader(name: string, idx = 0): any | undefined {
|
|
95
|
+
name = headerize(name);
|
|
96
|
+
|
|
97
|
+
if (!this.headers[name]) {
|
|
98
|
+
// this.logger.log("header '" + name + "' not present");
|
|
99
|
+
return;
|
|
100
|
+
} else if (idx >= this.headers[name].length) {
|
|
101
|
+
// this.logger.log("not so many '" + name + "' headers present");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const header = this.headers[name][idx];
|
|
106
|
+
const value = header.raw;
|
|
107
|
+
|
|
108
|
+
if (header.parsed) {
|
|
109
|
+
return header.parsed;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// substitute '-' by '_' for grammar rule matching.
|
|
113
|
+
const parsed: string | -1 = Grammar.parse(value, name.replace(/-/g, "_"));
|
|
114
|
+
|
|
115
|
+
if (parsed === -1) {
|
|
116
|
+
this.headers[name].splice(idx, 1); // delete from headers
|
|
117
|
+
// this.logger.warn('error parsing "' + name + '" header field with value "' + value + '"');
|
|
118
|
+
return;
|
|
119
|
+
} else {
|
|
120
|
+
header.parsed = parsed;
|
|
121
|
+
return parsed;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Message Header attribute selector. Alias of parseHeader.
|
|
127
|
+
* @param name - header name
|
|
128
|
+
* @param idx - header index
|
|
129
|
+
* @returns Parsed header object, undefined if the
|
|
130
|
+
* header is not present or in case of a parsing error.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* message.s('via',3).port
|
|
134
|
+
*/
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
public s(name: string, idx = 0): any | undefined {
|
|
137
|
+
return this.parseHeader(name, idx);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Replace the value of the given header by the value.
|
|
142
|
+
* @param name - header name
|
|
143
|
+
* @param value - header value
|
|
144
|
+
*/
|
|
145
|
+
public setHeader(name: string, value: string): void {
|
|
146
|
+
this.headers[headerize(name)] = [{ raw: value }];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public toString(): string {
|
|
150
|
+
return this.data;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { URI } from "../messages";
|
|
2
|
+
import { IncomingMessage } from "./incoming-message";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Incoming request message.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class IncomingRequestMessage extends IncomingMessage {
|
|
9
|
+
public ruri: URI | undefined;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
}
|
|
14
|
+
}
|