@unwanted/matrix-sdk-mini 34.12.0-1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5910 -0
- package/LICENSE +177 -0
- package/README.md +459 -0
- package/git-revision.txt +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +14 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.js +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +1 -0
- package/lib/@types/IIdentityServerProvider.d.ts +9 -0
- package/lib/@types/IIdentityServerProvider.d.ts.map +1 -0
- package/lib/@types/IIdentityServerProvider.js +1 -0
- package/lib/@types/IIdentityServerProvider.js.map +1 -0
- package/lib/@types/PushRules.d.ts +140 -0
- package/lib/@types/PushRules.d.ts.map +1 -0
- package/lib/@types/PushRules.js +94 -0
- package/lib/@types/PushRules.js.map +1 -0
- package/lib/@types/another-json.d.js +0 -0
- package/lib/@types/another-json.d.js.map +1 -0
- package/lib/@types/auth.d.ts +208 -0
- package/lib/@types/auth.d.ts.map +1 -0
- package/lib/@types/auth.js +99 -0
- package/lib/@types/auth.js.map +1 -0
- package/lib/@types/beacon.d.ts +106 -0
- package/lib/@types/beacon.d.ts.map +1 -0
- package/lib/@types/beacon.js +119 -0
- package/lib/@types/beacon.js.map +1 -0
- package/lib/@types/common.d.ts +9 -0
- package/lib/@types/common.d.ts.map +1 -0
- package/lib/@types/common.js +1 -0
- package/lib/@types/common.js.map +1 -0
- package/lib/@types/crypto.d.ts +47 -0
- package/lib/@types/crypto.d.ts.map +1 -0
- package/lib/@types/crypto.js +1 -0
- package/lib/@types/crypto.js.map +1 -0
- package/lib/@types/event.d.ts +258 -0
- package/lib/@types/event.d.ts.map +1 -0
- package/lib/@types/event.js +239 -0
- package/lib/@types/event.js.map +1 -0
- package/lib/@types/events.d.ts +92 -0
- package/lib/@types/events.d.ts.map +1 -0
- package/lib/@types/events.js +1 -0
- package/lib/@types/events.js.map +1 -0
- package/lib/@types/extensible_events.d.ts +98 -0
- package/lib/@types/extensible_events.d.ts.map +1 -0
- package/lib/@types/extensible_events.js +116 -0
- package/lib/@types/extensible_events.js.map +1 -0
- package/lib/@types/global.d.js +20 -0
- package/lib/@types/global.d.js.map +1 -0
- package/lib/@types/local_notifications.d.ts +4 -0
- package/lib/@types/local_notifications.d.ts.map +1 -0
- package/lib/@types/local_notifications.js +1 -0
- package/lib/@types/local_notifications.js.map +1 -0
- package/lib/@types/location.d.ts +60 -0
- package/lib/@types/location.d.ts.map +1 -0
- package/lib/@types/location.js +67 -0
- package/lib/@types/location.js.map +1 -0
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +1 -0
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -0
- package/lib/@types/media.d.ts +220 -0
- package/lib/@types/media.d.ts.map +1 -0
- package/lib/@types/media.js +1 -0
- package/lib/@types/media.js.map +1 -0
- package/lib/@types/membership.d.ts +41 -0
- package/lib/@types/membership.d.ts.map +1 -0
- package/lib/@types/membership.js +37 -0
- package/lib/@types/membership.js.map +1 -0
- package/lib/@types/oidc-client-ts.d.js +18 -0
- package/lib/@types/oidc-client-ts.d.js.map +1 -0
- package/lib/@types/partials.d.ts +39 -0
- package/lib/@types/partials.d.ts.map +1 -0
- package/lib/@types/partials.js +53 -0
- package/lib/@types/partials.js.map +1 -0
- package/lib/@types/polls.d.ts +88 -0
- package/lib/@types/polls.d.ts.map +1 -0
- package/lib/@types/polls.js +86 -0
- package/lib/@types/polls.js.map +1 -0
- package/lib/@types/read_receipts.d.ts +36 -0
- package/lib/@types/read_receipts.d.ts.map +1 -0
- package/lib/@types/read_receipts.js +27 -0
- package/lib/@types/read_receipts.js.map +1 -0
- package/lib/@types/registration.d.ts +85 -0
- package/lib/@types/registration.d.ts.map +1 -0
- package/lib/@types/registration.js +1 -0
- package/lib/@types/registration.js.map +1 -0
- package/lib/@types/requests.d.ts +241 -0
- package/lib/@types/requests.d.ts.map +1 -0
- package/lib/@types/requests.js +28 -0
- package/lib/@types/requests.js.map +1 -0
- package/lib/@types/search.d.ts +90 -0
- package/lib/@types/search.d.ts.map +1 -0
- package/lib/@types/search.js +30 -0
- package/lib/@types/search.js.map +1 -0
- package/lib/@types/signed.d.ts +9 -0
- package/lib/@types/signed.d.ts.map +1 -0
- package/lib/@types/signed.js +1 -0
- package/lib/@types/signed.js.map +1 -0
- package/lib/@types/spaces.d.ts +16 -0
- package/lib/@types/spaces.d.ts.map +1 -0
- package/lib/@types/spaces.js +1 -0
- package/lib/@types/spaces.js.map +1 -0
- package/lib/@types/state_events.d.ts +116 -0
- package/lib/@types/state_events.d.ts.map +1 -0
- package/lib/@types/state_events.js +1 -0
- package/lib/@types/state_events.js.map +1 -0
- package/lib/@types/synapse.d.ts +19 -0
- package/lib/@types/synapse.d.ts.map +1 -0
- package/lib/@types/synapse.js +1 -0
- package/lib/@types/synapse.js.map +1 -0
- package/lib/@types/sync.d.ts +8 -0
- package/lib/@types/sync.d.ts.map +1 -0
- package/lib/@types/sync.js +25 -0
- package/lib/@types/sync.js.map +1 -0
- package/lib/@types/threepids.d.ts +12 -0
- package/lib/@types/threepids.d.ts.map +1 -0
- package/lib/@types/threepids.js +24 -0
- package/lib/@types/threepids.js.map +1 -0
- package/lib/@types/topic.d.ts +48 -0
- package/lib/@types/topic.d.ts.map +1 -0
- package/lib/@types/topic.js +57 -0
- package/lib/@types/topic.js.map +1 -0
- package/lib/@types/uia.d.ts +12 -0
- package/lib/@types/uia.d.ts.map +1 -0
- package/lib/@types/uia.js +1 -0
- package/lib/@types/uia.js.map +1 -0
- package/lib/NamespacedValue.d.ts +33 -0
- package/lib/NamespacedValue.d.ts.map +1 -0
- package/lib/NamespacedValue.js +113 -0
- package/lib/NamespacedValue.js.map +1 -0
- package/lib/ReEmitter.d.ts +15 -0
- package/lib/ReEmitter.d.ts.map +1 -0
- package/lib/ReEmitter.js +87 -0
- package/lib/ReEmitter.js.map +1 -0
- package/lib/ToDeviceMessageQueue.d.ts +28 -0
- package/lib/ToDeviceMessageQueue.d.ts.map +1 -0
- package/lib/ToDeviceMessageQueue.js +135 -0
- package/lib/ToDeviceMessageQueue.js.map +1 -0
- package/lib/autodiscovery.d.ts +136 -0
- package/lib/autodiscovery.d.ts.map +1 -0
- package/lib/autodiscovery.js +464 -0
- package/lib/autodiscovery.js.map +1 -0
- package/lib/base64.d.ts +28 -0
- package/lib/base64.d.ts.map +1 -0
- package/lib/base64.js +88 -0
- package/lib/base64.js.map +1 -0
- package/lib/browser-index.d.ts +8 -0
- package/lib/browser-index.d.ts.map +1 -0
- package/lib/browser-index.js +35 -0
- package/lib/browser-index.js.map +1 -0
- package/lib/client.d.ts +4232 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +8622 -0
- package/lib/client.js.map +1 -0
- package/lib/common-crypto/CryptoBackend.d.ts +240 -0
- package/lib/common-crypto/CryptoBackend.d.ts.map +1 -0
- package/lib/common-crypto/CryptoBackend.js +73 -0
- package/lib/common-crypto/CryptoBackend.js.map +1 -0
- package/lib/common-crypto/key-passphrase.d.ts +14 -0
- package/lib/common-crypto/key-passphrase.d.ts.map +1 -0
- package/lib/common-crypto/key-passphrase.js +33 -0
- package/lib/common-crypto/key-passphrase.js.map +1 -0
- package/lib/content-helpers.d.ts +90 -0
- package/lib/content-helpers.d.ts.map +1 -0
- package/lib/content-helpers.js +250 -0
- package/lib/content-helpers.js.map +1 -0
- package/lib/content-repo.d.ts +24 -0
- package/lib/content-repo.d.ts.map +1 -0
- package/lib/content-repo.js +104 -0
- package/lib/content-repo.js.map +1 -0
- package/lib/crypto/CrossSigning.d.ts +184 -0
- package/lib/crypto/CrossSigning.d.ts.map +1 -0
- package/lib/crypto/CrossSigning.js +718 -0
- package/lib/crypto/CrossSigning.js.map +1 -0
- package/lib/crypto/DeviceList.d.ts +216 -0
- package/lib/crypto/DeviceList.d.ts.map +1 -0
- package/lib/crypto/DeviceList.js +892 -0
- package/lib/crypto/DeviceList.js.map +1 -0
- package/lib/crypto/EncryptionSetup.d.ts +152 -0
- package/lib/crypto/EncryptionSetup.d.ts.map +1 -0
- package/lib/crypto/EncryptionSetup.js +356 -0
- package/lib/crypto/EncryptionSetup.js.map +1 -0
- package/lib/crypto/OlmDevice.d.ts +457 -0
- package/lib/crypto/OlmDevice.d.ts.map +1 -0
- package/lib/crypto/OlmDevice.js +1241 -0
- package/lib/crypto/OlmDevice.js.map +1 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +109 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +1 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +415 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +1 -0
- package/lib/crypto/RoomList.d.ts +26 -0
- package/lib/crypto/RoomList.d.ts.map +1 -0
- package/lib/crypto/RoomList.js +71 -0
- package/lib/crypto/RoomList.js.map +1 -0
- package/lib/crypto/SecretSharing.d.ts +24 -0
- package/lib/crypto/SecretSharing.d.ts.map +1 -0
- package/lib/crypto/SecretSharing.js +194 -0
- package/lib/crypto/SecretSharing.js.map +1 -0
- package/lib/crypto/SecretStorage.d.ts +55 -0
- package/lib/crypto/SecretStorage.d.ts.map +1 -0
- package/lib/crypto/SecretStorage.js +118 -0
- package/lib/crypto/SecretStorage.js.map +1 -0
- package/lib/crypto/aes.d.ts +6 -0
- package/lib/crypto/aes.d.ts.map +1 -0
- package/lib/crypto/aes.js +24 -0
- package/lib/crypto/aes.js.map +1 -0
- package/lib/crypto/algorithms/base.d.ts +156 -0
- package/lib/crypto/algorithms/base.d.ts.map +1 -0
- package/lib/crypto/algorithms/base.js +187 -0
- package/lib/crypto/algorithms/base.js.map +1 -0
- package/lib/crypto/algorithms/index.d.ts +4 -0
- package/lib/crypto/algorithms/index.d.ts.map +1 -0
- package/lib/crypto/algorithms/index.js +20 -0
- package/lib/crypto/algorithms/index.js.map +1 -0
- package/lib/crypto/algorithms/megolm.d.ts +385 -0
- package/lib/crypto/algorithms/megolm.d.ts.map +1 -0
- package/lib/crypto/algorithms/megolm.js +1822 -0
- package/lib/crypto/algorithms/megolm.js.map +1 -0
- package/lib/crypto/algorithms/olm.d.ts +5 -0
- package/lib/crypto/algorithms/olm.d.ts.map +1 -0
- package/lib/crypto/algorithms/olm.js +299 -0
- package/lib/crypto/algorithms/olm.js.map +1 -0
- package/lib/crypto/api.d.ts +32 -0
- package/lib/crypto/api.d.ts.map +1 -0
- package/lib/crypto/api.js +22 -0
- package/lib/crypto/api.js.map +1 -0
- package/lib/crypto/backup.d.ts +227 -0
- package/lib/crypto/backup.d.ts.map +1 -0
- package/lib/crypto/backup.js +824 -0
- package/lib/crypto/backup.js.map +1 -0
- package/lib/crypto/crypto.d.ts +3 -0
- package/lib/crypto/crypto.d.ts.map +1 -0
- package/lib/crypto/crypto.js +19 -0
- package/lib/crypto/crypto.js.map +1 -0
- package/lib/crypto/dehydration.d.ts +34 -0
- package/lib/crypto/dehydration.d.ts.map +1 -0
- package/lib/crypto/dehydration.js +252 -0
- package/lib/crypto/dehydration.js.map +1 -0
- package/lib/crypto/device-converter.d.ts +9 -0
- package/lib/crypto/device-converter.d.ts.map +1 -0
- package/lib/crypto/device-converter.js +42 -0
- package/lib/crypto/device-converter.js.map +1 -0
- package/lib/crypto/deviceinfo.d.ts +99 -0
- package/lib/crypto/deviceinfo.d.ts.map +1 -0
- package/lib/crypto/deviceinfo.js +148 -0
- package/lib/crypto/deviceinfo.js.map +1 -0
- package/lib/crypto/index.d.ts +1209 -0
- package/lib/crypto/index.d.ts.map +1 -0
- package/lib/crypto/index.js +4097 -0
- package/lib/crypto/index.js.map +1 -0
- package/lib/crypto/key_passphrase.d.ts +14 -0
- package/lib/crypto/key_passphrase.d.ts.map +1 -0
- package/lib/crypto/key_passphrase.js +44 -0
- package/lib/crypto/key_passphrase.js.map +1 -0
- package/lib/crypto/keybackup.d.ts +18 -0
- package/lib/crypto/keybackup.d.ts.map +1 -0
- package/lib/crypto/keybackup.js +1 -0
- package/lib/crypto/keybackup.js.map +1 -0
- package/lib/crypto/olmlib.d.ts +129 -0
- package/lib/crypto/olmlib.d.ts.map +1 -0
- package/lib/crypto/olmlib.js +492 -0
- package/lib/crypto/olmlib.js.map +1 -0
- package/lib/crypto/recoverykey.d.ts +2 -0
- package/lib/crypto/recoverykey.d.ts.map +1 -0
- package/lib/crypto/recoverykey.js +19 -0
- package/lib/crypto/recoverykey.js.map +1 -0
- package/lib/crypto/store/base.d.ts +252 -0
- package/lib/crypto/store/base.d.ts.map +1 -0
- package/lib/crypto/store/base.js +64 -0
- package/lib/crypto/store/base.js.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +187 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +1145 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +432 -0
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store.js +728 -0
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -0
- package/lib/crypto/store/localStorage-crypto-store.d.ts +119 -0
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/localStorage-crypto-store.js +531 -0
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -0
- package/lib/crypto/store/memory-crypto-store.d.ts +215 -0
- package/lib/crypto/store/memory-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/memory-crypto-store.js +622 -0
- package/lib/crypto/store/memory-crypto-store.js.map +1 -0
- package/lib/crypto/verification/Base.d.ts +105 -0
- package/lib/crypto/verification/Base.d.ts.map +1 -0
- package/lib/crypto/verification/Base.js +372 -0
- package/lib/crypto/verification/Base.js.map +1 -0
- package/lib/crypto/verification/Error.d.ts +35 -0
- package/lib/crypto/verification/Error.d.ts.map +1 -0
- package/lib/crypto/verification/Error.js +86 -0
- package/lib/crypto/verification/Error.js.map +1 -0
- package/lib/crypto/verification/IllegalMethod.d.ts +15 -0
- package/lib/crypto/verification/IllegalMethod.d.ts.map +1 -0
- package/lib/crypto/verification/IllegalMethod.js +43 -0
- package/lib/crypto/verification/IllegalMethod.js.map +1 -0
- package/lib/crypto/verification/QRCode.d.ts +51 -0
- package/lib/crypto/verification/QRCode.d.ts.map +1 -0
- package/lib/crypto/verification/QRCode.js +277 -0
- package/lib/crypto/verification/QRCode.js.map +1 -0
- package/lib/crypto/verification/SAS.d.ts +27 -0
- package/lib/crypto/verification/SAS.d.ts.map +1 -0
- package/lib/crypto/verification/SAS.js +485 -0
- package/lib/crypto/verification/SAS.js.map +1 -0
- package/lib/crypto/verification/SASDecimal.d.ts +8 -0
- package/lib/crypto/verification/SASDecimal.d.ts.map +1 -0
- package/lib/crypto/verification/SASDecimal.js +34 -0
- package/lib/crypto/verification/SASDecimal.js.map +1 -0
- package/lib/crypto/verification/request/Channel.d.ts +18 -0
- package/lib/crypto/verification/request/Channel.d.ts.map +1 -0
- package/lib/crypto/verification/request/Channel.js +1 -0
- package/lib/crypto/verification/request/Channel.js.map +1 -0
- package/lib/crypto/verification/request/InRoomChannel.d.ts +113 -0
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +1 -0
- package/lib/crypto/verification/request/InRoomChannel.js +351 -0
- package/lib/crypto/verification/request/InRoomChannel.js.map +1 -0
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +105 -0
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +1 -0
- package/lib/crypto/verification/request/ToDeviceChannel.js +328 -0
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +1 -0
- package/lib/crypto/verification/request/VerificationRequest.d.ts +227 -0
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +1 -0
- package/lib/crypto/verification/request/VerificationRequest.js +937 -0
- package/lib/crypto/verification/request/VerificationRequest.js.map +1 -0
- package/lib/crypto-api/CryptoEvent.d.ts +69 -0
- package/lib/crypto-api/CryptoEvent.d.ts.map +1 -0
- package/lib/crypto-api/CryptoEvent.js +33 -0
- package/lib/crypto-api/CryptoEvent.js.map +1 -0
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +16 -0
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +1 -0
- package/lib/crypto-api/CryptoEventHandlerMap.js +22 -0
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +1 -0
- package/lib/crypto-api/index.d.ts +978 -0
- package/lib/crypto-api/index.d.ts.map +1 -0
- package/lib/crypto-api/index.js +304 -0
- package/lib/crypto-api/index.js.map +1 -0
- package/lib/crypto-api/key-passphrase.d.ts +11 -0
- package/lib/crypto-api/key-passphrase.d.ts.map +1 -0
- package/lib/crypto-api/key-passphrase.js +51 -0
- package/lib/crypto-api/key-passphrase.js.map +1 -0
- package/lib/crypto-api/keybackup.d.ts +88 -0
- package/lib/crypto-api/keybackup.d.ts.map +1 -0
- package/lib/crypto-api/keybackup.js +1 -0
- package/lib/crypto-api/keybackup.js.map +1 -0
- package/lib/crypto-api/recovery-key.d.ts +11 -0
- package/lib/crypto-api/recovery-key.d.ts.map +1 -0
- package/lib/crypto-api/recovery-key.js +65 -0
- package/lib/crypto-api/recovery-key.js.map +1 -0
- package/lib/crypto-api/verification.d.ts +344 -0
- package/lib/crypto-api/verification.d.ts.map +1 -0
- package/lib/crypto-api/verification.js +91 -0
- package/lib/crypto-api/verification.js.map +1 -0
- package/lib/digest.d.ts +10 -0
- package/lib/digest.d.ts.map +1 -0
- package/lib/digest.js +40 -0
- package/lib/digest.js.map +1 -0
- package/lib/embedded.d.ts +143 -0
- package/lib/embedded.d.ts.map +1 -0
- package/lib/embedded.js +567 -0
- package/lib/embedded.js.map +1 -0
- package/lib/errors.d.ts +24 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +51 -0
- package/lib/errors.js.map +1 -0
- package/lib/event-mapper.d.ts +10 -0
- package/lib/event-mapper.d.ts.map +1 -0
- package/lib/event-mapper.js +81 -0
- package/lib/event-mapper.js.map +1 -0
- package/lib/extensible_events_v1/ExtensibleEvent.d.ts +38 -0
- package/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/ExtensibleEvent.js +57 -0
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -0
- package/lib/extensible_events_v1/InvalidEventError.d.ts +7 -0
- package/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -0
- package/lib/extensible_events_v1/InvalidEventError.js +25 -0
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -0
- package/lib/extensible_events_v1/MessageEvent.d.ts +45 -0
- package/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/MessageEvent.js +134 -0
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollEndEvent.d.ts +33 -0
- package/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollEndEvent.js +88 -0
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.d.ts +49 -0
- package/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.js +135 -0
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollStartEvent.d.ts +71 -0
- package/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollStartEvent.js +185 -0
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -0
- package/lib/extensible_events_v1/utilities.d.ts +14 -0
- package/lib/extensible_events_v1/utilities.d.ts.map +1 -0
- package/lib/extensible_events_v1/utilities.js +34 -0
- package/lib/extensible_events_v1/utilities.js.map +1 -0
- package/lib/feature.d.ts +20 -0
- package/lib/feature.d.ts.map +1 -0
- package/lib/feature.js +85 -0
- package/lib/feature.js.map +1 -0
- package/lib/filter-component.d.ts +64 -0
- package/lib/filter-component.d.ts.map +1 -0
- package/lib/filter-component.js +167 -0
- package/lib/filter-component.js.map +1 -0
- package/lib/filter.d.ts +97 -0
- package/lib/filter.d.ts.map +1 -0
- package/lib/filter.js +207 -0
- package/lib/filter.js.map +1 -0
- package/lib/http-api/errors.d.ts +80 -0
- package/lib/http-api/errors.d.ts.map +1 -0
- package/lib/http-api/errors.js +185 -0
- package/lib/http-api/errors.js.map +1 -0
- package/lib/http-api/fetch.d.ts +114 -0
- package/lib/http-api/fetch.d.ts.map +1 -0
- package/lib/http-api/fetch.js +346 -0
- package/lib/http-api/fetch.js.map +1 -0
- package/lib/http-api/index.d.ts +33 -0
- package/lib/http-api/index.d.ts.map +1 -0
- package/lib/http-api/index.js +180 -0
- package/lib/http-api/index.js.map +1 -0
- package/lib/http-api/interface.d.ts +142 -0
- package/lib/http-api/interface.d.ts.map +1 -0
- package/lib/http-api/interface.js +35 -0
- package/lib/http-api/interface.js.map +1 -0
- package/lib/http-api/method.d.ts +10 -0
- package/lib/http-api/method.d.ts.map +1 -0
- package/lib/http-api/method.js +27 -0
- package/lib/http-api/method.js.map +1 -0
- package/lib/http-api/prefix.d.ts +31 -0
- package/lib/http-api/prefix.d.ts.map +1 -0
- package/lib/http-api/prefix.js +32 -0
- package/lib/http-api/prefix.js.map +1 -0
- package/lib/http-api/utils.d.ts +37 -0
- package/lib/http-api/utils.d.ts.map +1 -0
- package/lib/http-api/utils.js +178 -0
- package/lib/http-api/utils.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/indexeddb-helpers.d.ts +10 -0
- package/lib/indexeddb-helpers.d.ts.map +1 -0
- package/lib/indexeddb-helpers.js +51 -0
- package/lib/indexeddb-helpers.js.map +1 -0
- package/lib/indexeddb-worker.d.ts +7 -0
- package/lib/indexeddb-worker.d.ts.map +1 -0
- package/lib/indexeddb-worker.js +25 -0
- package/lib/indexeddb-worker.js.map +1 -0
- package/lib/interactive-auth.d.ts +337 -0
- package/lib/interactive-auth.d.ts.map +1 -0
- package/lib/interactive-auth.js +557 -0
- package/lib/interactive-auth.js.map +1 -0
- package/lib/logger.d.ts +81 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +139 -0
- package/lib/logger.js.map +1 -0
- package/lib/matrix.d.ts +118 -0
- package/lib/matrix.d.ts.map +1 -0
- package/lib/matrix.js +146 -0
- package/lib/matrix.js.map +1 -0
- package/lib/matrixrtc/CallMembership.d.ts +66 -0
- package/lib/matrixrtc/CallMembership.d.ts.map +1 -0
- package/lib/matrixrtc/CallMembership.js +197 -0
- package/lib/matrixrtc/CallMembership.js.map +1 -0
- package/lib/matrixrtc/LivekitFocus.d.ts +16 -0
- package/lib/matrixrtc/LivekitFocus.d.ts.map +1 -0
- package/lib/matrixrtc/LivekitFocus.js +20 -0
- package/lib/matrixrtc/LivekitFocus.js.map +1 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts +295 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -0
- package/lib/matrixrtc/MatrixRTCSession.js +1043 -0
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +40 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.js +146 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -0
- package/lib/matrixrtc/focus.d.ts +10 -0
- package/lib/matrixrtc/focus.d.ts.map +1 -0
- package/lib/matrixrtc/focus.js +1 -0
- package/lib/matrixrtc/focus.js.map +1 -0
- package/lib/matrixrtc/index.d.ts +7 -0
- package/lib/matrixrtc/index.d.ts.map +1 -0
- package/lib/matrixrtc/index.js +21 -0
- package/lib/matrixrtc/index.js.map +1 -0
- package/lib/matrixrtc/types.d.ts +19 -0
- package/lib/matrixrtc/types.d.ts.map +1 -0
- package/lib/matrixrtc/types.js +1 -0
- package/lib/matrixrtc/types.js.map +1 -0
- package/lib/models/MSC3089Branch.d.ts +98 -0
- package/lib/models/MSC3089Branch.d.ts.map +1 -0
- package/lib/models/MSC3089Branch.js +240 -0
- package/lib/models/MSC3089Branch.js.map +1 -0
- package/lib/models/MSC3089TreeSpace.d.ts +165 -0
- package/lib/models/MSC3089TreeSpace.d.ts.map +1 -0
- package/lib/models/MSC3089TreeSpace.js +520 -0
- package/lib/models/MSC3089TreeSpace.js.map +1 -0
- package/lib/models/ToDeviceMessage.d.ts +17 -0
- package/lib/models/ToDeviceMessage.d.ts.map +1 -0
- package/lib/models/ToDeviceMessage.js +1 -0
- package/lib/models/ToDeviceMessage.js.map +1 -0
- package/lib/models/beacon.d.ts +53 -0
- package/lib/models/beacon.d.ts.map +1 -0
- package/lib/models/beacon.js +174 -0
- package/lib/models/beacon.js.map +1 -0
- package/lib/models/compare-event-ordering.d.ts +24 -0
- package/lib/models/compare-event-ordering.d.ts.map +1 -0
- package/lib/models/compare-event-ordering.js +120 -0
- package/lib/models/compare-event-ordering.js.map +1 -0
- package/lib/models/device.d.ts +45 -0
- package/lib/models/device.d.ts.map +1 -0
- package/lib/models/device.js +77 -0
- package/lib/models/device.js.map +1 -0
- package/lib/models/event-context.d.ts +62 -0
- package/lib/models/event-context.d.ts.map +1 -0
- package/lib/models/event-context.js +113 -0
- package/lib/models/event-context.js.map +1 -0
- package/lib/models/event-status.d.ts +19 -0
- package/lib/models/event-status.d.ts.map +1 -0
- package/lib/models/event-status.js +30 -0
- package/lib/models/event-status.js.map +1 -0
- package/lib/models/event-timeline-set.d.ts +312 -0
- package/lib/models/event-timeline-set.d.ts.map +1 -0
- package/lib/models/event-timeline-set.js +813 -0
- package/lib/models/event-timeline-set.js.map +1 -0
- package/lib/models/event-timeline.d.ts +219 -0
- package/lib/models/event-timeline.d.ts.map +1 -0
- package/lib/models/event-timeline.js +455 -0
- package/lib/models/event-timeline.js.map +1 -0
- package/lib/models/event.d.ts +811 -0
- package/lib/models/event.d.ts.map +1 -0
- package/lib/models/event.js +1520 -0
- package/lib/models/event.js.map +1 -0
- package/lib/models/invites-ignorer.d.ts +136 -0
- package/lib/models/invites-ignorer.d.ts.map +1 -0
- package/lib/models/invites-ignorer.js +382 -0
- package/lib/models/invites-ignorer.js.map +1 -0
- package/lib/models/poll.d.ts +67 -0
- package/lib/models/poll.d.ts.map +1 -0
- package/lib/models/poll.js +241 -0
- package/lib/models/poll.js.map +1 -0
- package/lib/models/profile-keys.d.ts +8 -0
- package/lib/models/profile-keys.d.ts.map +1 -0
- package/lib/models/profile-keys.js +8 -0
- package/lib/models/profile-keys.js.map +1 -0
- package/lib/models/read-receipt.d.ts +115 -0
- package/lib/models/read-receipt.d.ts.map +1 -0
- package/lib/models/read-receipt.js +366 -0
- package/lib/models/read-receipt.js.map +1 -0
- package/lib/models/related-relations.d.ts +11 -0
- package/lib/models/related-relations.d.ts.map +1 -0
- package/lib/models/related-relations.js +33 -0
- package/lib/models/related-relations.js.map +1 -0
- package/lib/models/relations-container.d.ts +44 -0
- package/lib/models/relations-container.d.ts.map +1 -0
- package/lib/models/relations-container.js +132 -0
- package/lib/models/relations-container.js.map +1 -0
- package/lib/models/relations.d.ts +114 -0
- package/lib/models/relations.d.ts.map +1 -0
- package/lib/models/relations.js +354 -0
- package/lib/models/relations.js.map +1 -0
- package/lib/models/room-member.d.ts +204 -0
- package/lib/models/room-member.d.ts.map +1 -0
- package/lib/models/room-member.js +360 -0
- package/lib/models/room-member.js.map +1 -0
- package/lib/models/room-receipts.d.ts +39 -0
- package/lib/models/room-receipts.d.ts.map +1 -0
- package/lib/models/room-receipts.js +392 -0
- package/lib/models/room-receipts.js.map +1 -0
- package/lib/models/room-state.d.ts +468 -0
- package/lib/models/room-state.d.ts.map +1 -0
- package/lib/models/room-state.js +984 -0
- package/lib/models/room-state.js.map +1 -0
- package/lib/models/room-summary.d.ts +29 -0
- package/lib/models/room-summary.d.ts.map +1 -0
- package/lib/models/room-summary.js +28 -0
- package/lib/models/room-summary.js.map +1 -0
- package/lib/models/room.d.ts +1203 -0
- package/lib/models/room.d.ts.map +1 -0
- package/lib/models/room.js +3336 -0
- package/lib/models/room.js.map +1 -0
- package/lib/models/search-result.d.ts +20 -0
- package/lib/models/search-result.d.ts.map +1 -0
- package/lib/models/search-result.js +52 -0
- package/lib/models/search-result.js.map +1 -0
- package/lib/models/thread.d.ts +246 -0
- package/lib/models/thread.d.ts.map +1 -0
- package/lib/models/thread.js +861 -0
- package/lib/models/thread.js.map +1 -0
- package/lib/models/typed-event-emitter.d.ts +157 -0
- package/lib/models/typed-event-emitter.d.ts.map +1 -0
- package/lib/models/typed-event-emitter.js +227 -0
- package/lib/models/typed-event-emitter.js.map +1 -0
- package/lib/models/user.d.ts +195 -0
- package/lib/models/user.d.ts.map +1 -0
- package/lib/models/user.js +218 -0
- package/lib/models/user.js.map +1 -0
- package/lib/oidc/authorize.d.ts +90 -0
- package/lib/oidc/authorize.d.ts.map +1 -0
- package/lib/oidc/authorize.js +278 -0
- package/lib/oidc/authorize.js.map +1 -0
- package/lib/oidc/discovery.d.ts +14 -0
- package/lib/oidc/discovery.d.ts.map +1 -0
- package/lib/oidc/discovery.js +66 -0
- package/lib/oidc/discovery.js.map +1 -0
- package/lib/oidc/error.d.ts +18 -0
- package/lib/oidc/error.d.ts.map +1 -0
- package/lib/oidc/error.js +35 -0
- package/lib/oidc/error.js.map +1 -0
- package/lib/oidc/index.d.ts +17 -0
- package/lib/oidc/index.d.ts.map +1 -0
- package/lib/oidc/index.js +29 -0
- package/lib/oidc/index.js.map +1 -0
- package/lib/oidc/register.d.ts +43 -0
- package/lib/oidc/register.d.ts.map +1 -0
- package/lib/oidc/register.js +96 -0
- package/lib/oidc/register.js.map +1 -0
- package/lib/oidc/tokenRefresher.d.ts +69 -0
- package/lib/oidc/tokenRefresher.d.ts.map +1 -0
- package/lib/oidc/tokenRefresher.js +148 -0
- package/lib/oidc/tokenRefresher.js.map +1 -0
- package/lib/oidc/validate.d.ts +90 -0
- package/lib/oidc/validate.d.ts.map +1 -0
- package/lib/oidc/validate.js +194 -0
- package/lib/oidc/validate.js.map +1 -0
- package/lib/pushprocessor.d.ts +128 -0
- package/lib/pushprocessor.d.ts.map +1 -0
- package/lib/pushprocessor.js +685 -0
- package/lib/pushprocessor.js.map +1 -0
- package/lib/randomstring.d.ts +5 -0
- package/lib/randomstring.d.ts.map +1 -0
- package/lib/randomstring.js +43 -0
- package/lib/randomstring.js.map +1 -0
- package/lib/realtime-callbacks.d.ts +18 -0
- package/lib/realtime-callbacks.d.ts.map +1 -0
- package/lib/realtime-callbacks.js +177 -0
- package/lib/realtime-callbacks.js.map +1 -0
- package/lib/receipt-accumulator.d.ts +51 -0
- package/lib/receipt-accumulator.d.ts.map +1 -0
- package/lib/receipt-accumulator.js +164 -0
- package/lib/receipt-accumulator.js.map +1 -0
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +112 -0
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -0
- package/lib/rendezvous/MSC4108SignInWithQR.js +392 -0
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -0
- package/lib/rendezvous/RendezvousChannel.d.ts +27 -0
- package/lib/rendezvous/RendezvousChannel.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousChannel.js +1 -0
- package/lib/rendezvous/RendezvousChannel.js.map +1 -0
- package/lib/rendezvous/RendezvousCode.d.ts +9 -0
- package/lib/rendezvous/RendezvousCode.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousCode.js +1 -0
- package/lib/rendezvous/RendezvousCode.js.map +1 -0
- package/lib/rendezvous/RendezvousError.d.ts +6 -0
- package/lib/rendezvous/RendezvousError.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousError.js +23 -0
- package/lib/rendezvous/RendezvousError.js.map +1 -0
- package/lib/rendezvous/RendezvousFailureReason.d.ts +31 -0
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousFailureReason.js +38 -0
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -0
- package/lib/rendezvous/RendezvousIntent.d.ts +5 -0
- package/lib/rendezvous/RendezvousIntent.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousIntent.js +22 -0
- package/lib/rendezvous/RendezvousIntent.js.map +1 -0
- package/lib/rendezvous/RendezvousTransport.d.ts +36 -0
- package/lib/rendezvous/RendezvousTransport.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousTransport.js +1 -0
- package/lib/rendezvous/RendezvousTransport.js.map +1 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +58 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +246 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -0
- package/lib/rendezvous/channels/index.d.ts +2 -0
- package/lib/rendezvous/channels/index.d.ts.map +1 -0
- package/lib/rendezvous/channels/index.js +18 -0
- package/lib/rendezvous/channels/index.js.map +1 -0
- package/lib/rendezvous/index.d.ts +10 -0
- package/lib/rendezvous/index.d.ts.map +1 -0
- package/lib/rendezvous/index.js +23 -0
- package/lib/rendezvous/index.js.map +1 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +61 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +253 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -0
- package/lib/rendezvous/transports/index.d.ts +2 -0
- package/lib/rendezvous/transports/index.d.ts.map +1 -0
- package/lib/rendezvous/transports/index.js +18 -0
- package/lib/rendezvous/transports/index.js.map +1 -0
- package/lib/room-hierarchy.d.ts +35 -0
- package/lib/room-hierarchy.d.ts.map +1 -0
- package/lib/room-hierarchy.js +136 -0
- package/lib/room-hierarchy.js.map +1 -0
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +33 -0
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -0
- package/lib/rust-crypto/CrossSigningIdentity.js +157 -0
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -0
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +98 -0
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -0
- package/lib/rust-crypto/DehydratedDeviceManager.js +285 -0
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -0
- package/lib/rust-crypto/KeyClaimManager.d.ts +33 -0
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -0
- package/lib/rust-crypto/KeyClaimManager.js +82 -0
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +43 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.js +195 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -0
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +47 -0
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -0
- package/lib/rust-crypto/OutgoingRequestsManager.js +148 -0
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +120 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +467 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -0
- package/lib/rust-crypto/RoomEncryptor.d.ts +98 -0
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -0
- package/lib/rust-crypto/RoomEncryptor.js +299 -0
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -0
- package/lib/rust-crypto/backup.d.ts +254 -0
- package/lib/rust-crypto/backup.d.ts.map +1 -0
- package/lib/rust-crypto/backup.js +837 -0
- package/lib/rust-crypto/backup.js.map +1 -0
- package/lib/rust-crypto/constants.d.ts +3 -0
- package/lib/rust-crypto/constants.d.ts.map +1 -0
- package/lib/rust-crypto/constants.js +19 -0
- package/lib/rust-crypto/constants.js.map +1 -0
- package/lib/rust-crypto/device-converter.d.ts +28 -0
- package/lib/rust-crypto/device-converter.d.ts.map +1 -0
- package/lib/rust-crypto/device-converter.js +123 -0
- package/lib/rust-crypto/device-converter.js.map +1 -0
- package/lib/rust-crypto/index.d.ts +61 -0
- package/lib/rust-crypto/index.d.ts.map +1 -0
- package/lib/rust-crypto/index.js +152 -0
- package/lib/rust-crypto/index.js.map +1 -0
- package/lib/rust-crypto/libolm_migration.d.ts +81 -0
- package/lib/rust-crypto/libolm_migration.d.ts.map +1 -0
- package/lib/rust-crypto/libolm_migration.js +459 -0
- package/lib/rust-crypto/libolm_migration.js.map +1 -0
- package/lib/rust-crypto/rust-crypto.d.ts +556 -0
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -0
- package/lib/rust-crypto/rust-crypto.js +2016 -0
- package/lib/rust-crypto/rust-crypto.js.map +1 -0
- package/lib/rust-crypto/secret-storage.d.ts +22 -0
- package/lib/rust-crypto/secret-storage.d.ts.map +1 -0
- package/lib/rust-crypto/secret-storage.js +63 -0
- package/lib/rust-crypto/secret-storage.js.map +1 -0
- package/lib/rust-crypto/verification.d.ts +319 -0
- package/lib/rust-crypto/verification.d.ts.map +1 -0
- package/lib/rust-crypto/verification.js +816 -0
- package/lib/rust-crypto/verification.js.map +1 -0
- package/lib/scheduler.d.ts +132 -0
- package/lib/scheduler.d.ts.map +1 -0
- package/lib/scheduler.js +259 -0
- package/lib/scheduler.js.map +1 -0
- package/lib/secret-storage.d.ts +370 -0
- package/lib/secret-storage.d.ts.map +1 -0
- package/lib/secret-storage.js +466 -0
- package/lib/secret-storage.js.map +1 -0
- package/lib/serverCapabilities.d.ts +72 -0
- package/lib/serverCapabilities.d.ts.map +1 -0
- package/lib/serverCapabilities.js +105 -0
- package/lib/serverCapabilities.js.map +1 -0
- package/lib/service-types.d.ts +5 -0
- package/lib/service-types.d.ts.map +1 -0
- package/lib/service-types.js +22 -0
- package/lib/service-types.js.map +1 -0
- package/lib/sliding-sync-sdk.d.ts +107 -0
- package/lib/sliding-sync-sdk.d.ts.map +1 -0
- package/lib/sliding-sync-sdk.js +903 -0
- package/lib/sliding-sync-sdk.js.map +1 -0
- package/lib/sliding-sync.d.ts +343 -0
- package/lib/sliding-sync.d.ts.map +1 -0
- package/lib/sliding-sync.js +817 -0
- package/lib/sliding-sync.js.map +1 -0
- package/lib/store/index.d.ts +201 -0
- package/lib/store/index.d.ts.map +1 -0
- package/lib/store/index.js +1 -0
- package/lib/store/index.js.map +1 -0
- package/lib/store/indexeddb-backend.d.ts +24 -0
- package/lib/store/indexeddb-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-backend.js +1 -0
- package/lib/store/indexeddb-backend.js.map +1 -0
- package/lib/store/indexeddb-local-backend.d.ts +129 -0
- package/lib/store/indexeddb-local-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-local-backend.js +597 -0
- package/lib/store/indexeddb-local-backend.js.map +1 -0
- package/lib/store/indexeddb-remote-backend.d.ts +79 -0
- package/lib/store/indexeddb-remote-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-remote-backend.js +210 -0
- package/lib/store/indexeddb-remote-backend.js.map +1 -0
- package/lib/store/indexeddb-store-worker.d.ts +35 -0
- package/lib/store/indexeddb-store-worker.d.ts.map +1 -0
- package/lib/store/indexeddb-store-worker.js +146 -0
- package/lib/store/indexeddb-store-worker.js.map +1 -0
- package/lib/store/indexeddb.d.ts +142 -0
- package/lib/store/indexeddb.d.ts.map +1 -0
- package/lib/store/indexeddb.js +347 -0
- package/lib/store/indexeddb.js.map +1 -0
- package/lib/store/local-storage-events-emitter.d.ts +30 -0
- package/lib/store/local-storage-events-emitter.d.ts.map +1 -0
- package/lib/store/local-storage-events-emitter.js +37 -0
- package/lib/store/local-storage-events-emitter.js.map +1 -0
- package/lib/store/memory.d.ts +209 -0
- package/lib/store/memory.d.ts.map +1 -0
- package/lib/store/memory.js +432 -0
- package/lib/store/memory.js.map +1 -0
- package/lib/store/stub.d.ts +161 -0
- package/lib/store/stub.d.ts.map +1 -0
- package/lib/store/stub.js +268 -0
- package/lib/store/stub.js.map +1 -0
- package/lib/sync-accumulator.d.ts +172 -0
- package/lib/sync-accumulator.d.ts.map +1 -0
- package/lib/sync-accumulator.js +532 -0
- package/lib/sync-accumulator.js.map +1 -0
- package/lib/sync.d.ts +260 -0
- package/lib/sync.d.ts.map +1 -0
- package/lib/sync.js +1686 -0
- package/lib/sync.js.map +1 -0
- package/lib/testing.d.ts +81 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +162 -0
- package/lib/testing.js.map +1 -0
- package/lib/thread-utils.d.ts +10 -0
- package/lib/thread-utils.d.ts.map +1 -0
- package/lib/thread-utils.js +31 -0
- package/lib/thread-utils.js.map +1 -0
- package/lib/timeline-window.d.ts +168 -0
- package/lib/timeline-window.d.ts.map +1 -0
- package/lib/timeline-window.js +494 -0
- package/lib/timeline-window.js.map +1 -0
- package/lib/types.d.ts +33 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +33 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/decryptAESSecretStorageItem.d.ts +12 -0
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +1 -0
- package/lib/utils/decryptAESSecretStorageItem.js +50 -0
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -0
- package/lib/utils/encryptAESSecretStorageItem.d.ts +16 -0
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +1 -0
- package/lib/utils/encryptAESSecretStorageItem.js +68 -0
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -0
- package/lib/utils/internal/deriveKeys.d.ts +10 -0
- package/lib/utils/internal/deriveKeys.d.ts.map +1 -0
- package/lib/utils/internal/deriveKeys.js +60 -0
- package/lib/utils/internal/deriveKeys.js.map +1 -0
- package/lib/utils.d.ts +267 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +749 -0
- package/lib/utils.js.map +1 -0
- package/lib/version-support.d.ts +19 -0
- package/lib/version-support.d.ts.map +1 -0
- package/lib/version-support.js +37 -0
- package/lib/version-support.js.map +1 -0
- package/lib/webrtc/audioContext.d.ts +15 -0
- package/lib/webrtc/audioContext.d.ts.map +1 -0
- package/lib/webrtc/audioContext.js +46 -0
- package/lib/webrtc/audioContext.js.map +1 -0
- package/lib/webrtc/call.d.ts +560 -0
- package/lib/webrtc/call.d.ts.map +1 -0
- package/lib/webrtc/call.js +2541 -0
- package/lib/webrtc/call.js.map +1 -0
- package/lib/webrtc/callEventHandler.d.ts +37 -0
- package/lib/webrtc/callEventHandler.d.ts.map +1 -0
- package/lib/webrtc/callEventHandler.js +344 -0
- package/lib/webrtc/callEventHandler.js.map +1 -0
- package/lib/webrtc/callEventTypes.d.ts +73 -0
- package/lib/webrtc/callEventTypes.d.ts.map +1 -0
- package/lib/webrtc/callEventTypes.js +13 -0
- package/lib/webrtc/callEventTypes.js.map +1 -0
- package/lib/webrtc/callFeed.d.ts +128 -0
- package/lib/webrtc/callFeed.d.ts.map +1 -0
- package/lib/webrtc/callFeed.js +289 -0
- package/lib/webrtc/callFeed.js.map +1 -0
- package/lib/webrtc/groupCall.d.ts +323 -0
- package/lib/webrtc/groupCall.d.ts.map +1 -0
- package/lib/webrtc/groupCall.js +1337 -0
- package/lib/webrtc/groupCall.js.map +1 -0
- package/lib/webrtc/groupCallEventHandler.d.ts +31 -0
- package/lib/webrtc/groupCallEventHandler.d.ts.map +1 -0
- package/lib/webrtc/groupCallEventHandler.js +178 -0
- package/lib/webrtc/groupCallEventHandler.js.map +1 -0
- package/lib/webrtc/mediaHandler.d.ts +89 -0
- package/lib/webrtc/mediaHandler.d.ts.map +1 -0
- package/lib/webrtc/mediaHandler.js +437 -0
- package/lib/webrtc/mediaHandler.js.map +1 -0
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +8 -0
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -0
- package/lib/webrtc/stats/callFeedStatsReporter.js +82 -0
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -0
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +25 -0
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -0
- package/lib/webrtc/stats/callStatsReportGatherer.js +199 -0
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +17 -0
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.js +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.js.map +1 -0
- package/lib/webrtc/stats/connectionStats.d.ts +28 -0
- package/lib/webrtc/stats/connectionStats.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStats.js +26 -0
- package/lib/webrtc/stats/connectionStats.js.map +1 -0
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +5 -0
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStatsBuilder.js +27 -0
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +7 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +121 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -0
- package/lib/webrtc/stats/groupCallStats.d.ts +22 -0
- package/lib/webrtc/stats/groupCallStats.d.ts.map +1 -0
- package/lib/webrtc/stats/groupCallStats.js +78 -0
- package/lib/webrtc/stats/groupCallStats.js.map +1 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +10 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +57 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +12 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.js +62 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +86 -0
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStats.js +142 -0
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +22 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +76 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -0
- package/lib/webrtc/stats/statsReport.d.ts +99 -0
- package/lib/webrtc/stats/statsReport.d.ts.map +1 -0
- package/lib/webrtc/stats/statsReport.js +32 -0
- package/lib/webrtc/stats/statsReport.js.map +1 -0
- package/lib/webrtc/stats/statsReportEmitter.d.ts +15 -0
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -0
- package/lib/webrtc/stats/statsReportEmitter.js +33 -0
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +16 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +116 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -0
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +19 -0
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/trackStatsBuilder.js +168 -0
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/transportStats.d.ts +11 -0
- package/lib/webrtc/stats/transportStats.d.ts.map +1 -0
- package/lib/webrtc/stats/transportStats.js +1 -0
- package/lib/webrtc/stats/transportStats.js.map +1 -0
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +5 -0
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/transportStatsBuilder.js +34 -0
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/valueFormatter.d.ts +4 -0
- package/lib/webrtc/stats/valueFormatter.d.ts.map +1 -0
- package/lib/webrtc/stats/valueFormatter.js +25 -0
- package/lib/webrtc/stats/valueFormatter.js.map +1 -0
- package/package.json +134 -0
- package/src/@types/AESEncryptedSecretStoragePayload.ts +29 -0
- package/src/@types/IIdentityServerProvider.ts +24 -0
- package/src/@types/PushRules.ts +209 -0
- package/src/@types/another-json.d.ts +19 -0
- package/src/@types/auth.ts +252 -0
- package/src/@types/beacon.ts +140 -0
- package/src/@types/common.ts +22 -0
- package/src/@types/crypto.ts +73 -0
- package/src/@types/event.ts +370 -0
- package/src/@types/events.ts +119 -0
- package/src/@types/extensible_events.ts +150 -0
- package/src/@types/global.d.ts +70 -0
- package/src/@types/local_notifications.ts +19 -0
- package/src/@types/location.ts +92 -0
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +44 -0
- package/src/@types/media.ts +245 -0
- package/src/@types/membership.ts +57 -0
- package/src/@types/oidc-client-ts.d.ts +24 -0
- package/src/@types/partials.ts +67 -0
- package/src/@types/polls.ts +119 -0
- package/src/@types/read_receipts.ts +61 -0
- package/src/@types/registration.ts +102 -0
- package/src/@types/requests.ts +314 -0
- package/src/@types/search.ts +119 -0
- package/src/@types/signed.ts +25 -0
- package/src/@types/spaces.ts +37 -0
- package/src/@types/state_events.ts +147 -0
- package/src/@types/synapse.ts +40 -0
- package/src/@types/sync.ts +27 -0
- package/src/@types/threepids.ts +29 -0
- package/src/@types/topic.ts +63 -0
- package/src/@types/uia.ts +29 -0
- package/src/NamespacedValue.ts +123 -0
- package/src/ReEmitter.ts +93 -0
- package/src/ToDeviceMessageQueue.ts +153 -0
- package/src/autodiscovery.ts +505 -0
- package/src/base64.ts +88 -0
- package/src/browser-index.ts +44 -0
- package/src/client.ts +10474 -0
- package/src/common-crypto/CryptoBackend.ts +302 -0
- package/src/common-crypto/README.md +4 -0
- package/src/common-crypto/key-passphrase.ts +43 -0
- package/src/content-helpers.ts +288 -0
- package/src/content-repo.ts +117 -0
- package/src/crypto/CrossSigning.ts +773 -0
- package/src/crypto/DeviceList.ts +989 -0
- package/src/crypto/EncryptionSetup.ts +351 -0
- package/src/crypto/OlmDevice.ts +1500 -0
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +485 -0
- package/src/crypto/RoomList.ts +70 -0
- package/src/crypto/SecretSharing.ts +240 -0
- package/src/crypto/SecretStorage.ts +136 -0
- package/src/crypto/aes.ts +23 -0
- package/src/crypto/algorithms/base.ts +236 -0
- package/src/crypto/algorithms/index.ts +20 -0
- package/src/crypto/algorithms/megolm.ts +2216 -0
- package/src/crypto/algorithms/olm.ts +381 -0
- package/src/crypto/api.ts +70 -0
- package/src/crypto/backup.ts +922 -0
- package/src/crypto/crypto.ts +18 -0
- package/src/crypto/dehydration.ts +272 -0
- package/src/crypto/device-converter.ts +45 -0
- package/src/crypto/deviceinfo.ts +158 -0
- package/src/crypto/index.ts +4414 -0
- package/src/crypto/key_passphrase.ts +42 -0
- package/src/crypto/keybackup.ts +47 -0
- package/src/crypto/olmlib.ts +539 -0
- package/src/crypto/recoverykey.ts +18 -0
- package/src/crypto/store/base.ts +348 -0
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +1250 -0
- package/src/crypto/store/indexeddb-crypto-store.ts +845 -0
- package/src/crypto/store/localStorage-crypto-store.ts +579 -0
- package/src/crypto/store/memory-crypto-store.ts +680 -0
- package/src/crypto/verification/Base.ts +409 -0
- package/src/crypto/verification/Error.ts +76 -0
- package/src/crypto/verification/IllegalMethod.ts +50 -0
- package/src/crypto/verification/QRCode.ts +310 -0
- package/src/crypto/verification/SAS.ts +494 -0
- package/src/crypto/verification/SASDecimal.ts +37 -0
- package/src/crypto/verification/request/Channel.ts +34 -0
- package/src/crypto/verification/request/InRoomChannel.ts +371 -0
- package/src/crypto/verification/request/ToDeviceChannel.ts +354 -0
- package/src/crypto/verification/request/VerificationRequest.ts +976 -0
- package/src/crypto-api/CryptoEvent.ts +93 -0
- package/src/crypto-api/CryptoEventHandlerMap.ts +32 -0
- package/src/crypto-api/index.ts +1175 -0
- package/src/crypto-api/key-passphrase.ts +58 -0
- package/src/crypto-api/keybackup.ts +115 -0
- package/src/crypto-api/recovery-key.ts +69 -0
- package/src/crypto-api/verification.ts +408 -0
- package/src/digest.ts +34 -0
- package/src/embedded.ts +631 -0
- package/src/errors.ts +54 -0
- package/src/event-mapper.ts +97 -0
- package/src/extensible_events_v1/ExtensibleEvent.ts +58 -0
- package/src/extensible_events_v1/InvalidEventError.ts +24 -0
- package/src/extensible_events_v1/MessageEvent.ts +145 -0
- package/src/extensible_events_v1/PollEndEvent.ts +97 -0
- package/src/extensible_events_v1/PollResponseEvent.ts +148 -0
- package/src/extensible_events_v1/PollStartEvent.ts +207 -0
- package/src/extensible_events_v1/utilities.ts +35 -0
- package/src/feature.ts +87 -0
- package/src/filter-component.ts +207 -0
- package/src/filter.ts +245 -0
- package/src/http-api/errors.ts +199 -0
- package/src/http-api/fetch.ts +383 -0
- package/src/http-api/index.ts +191 -0
- package/src/http-api/interface.ts +178 -0
- package/src/http-api/method.ts +25 -0
- package/src/http-api/prefix.ts +48 -0
- package/src/http-api/utils.ts +200 -0
- package/src/index.ts +25 -0
- package/src/indexeddb-helpers.ts +50 -0
- package/src/indexeddb-worker.ts +24 -0
- package/src/interactive-auth.ts +694 -0
- package/src/logger.ts +185 -0
- package/src/matrix.ts +177 -0
- package/src/matrixrtc/CallMembership.ts +247 -0
- package/src/matrixrtc/LivekitFocus.ts +39 -0
- package/src/matrixrtc/MatrixRTCSession.ts +1319 -0
- package/src/matrixrtc/MatrixRTCSessionManager.ts +166 -0
- package/src/matrixrtc/focus.ts +25 -0
- package/src/matrixrtc/index.ts +22 -0
- package/src/matrixrtc/types.ts +36 -0
- package/src/models/MSC3089Branch.ts +272 -0
- package/src/models/MSC3089TreeSpace.ts +565 -0
- package/src/models/ToDeviceMessage.ts +38 -0
- package/src/models/beacon.ts +214 -0
- package/src/models/compare-event-ordering.ts +139 -0
- package/src/models/device.ts +85 -0
- package/src/models/event-context.ts +110 -0
- package/src/models/event-status.ts +39 -0
- package/src/models/event-timeline-set.ts +979 -0
- package/src/models/event-timeline.ts +476 -0
- package/src/models/event.ts +1751 -0
- package/src/models/invites-ignorer.ts +376 -0
- package/src/models/poll.ts +285 -0
- package/src/models/profile-keys.ts +7 -0
- package/src/models/read-receipt.ts +422 -0
- package/src/models/related-relations.ts +39 -0
- package/src/models/relations-container.ts +149 -0
- package/src/models/relations.ts +368 -0
- package/src/models/room-member.ts +457 -0
- package/src/models/room-receipts.ts +439 -0
- package/src/models/room-state.ts +1130 -0
- package/src/models/room-summary.ts +47 -0
- package/src/models/room.ts +3822 -0
- package/src/models/search-result.ts +57 -0
- package/src/models/thread.ts +923 -0
- package/src/models/typed-event-emitter.ts +246 -0
- package/src/models/user.ts +302 -0
- package/src/oidc/authorize.ts +274 -0
- package/src/oidc/discovery.ts +60 -0
- package/src/oidc/error.ts +33 -0
- package/src/oidc/index.ts +34 -0
- package/src/oidc/register.ts +123 -0
- package/src/oidc/tokenRefresher.ts +149 -0
- package/src/oidc/validate.ts +282 -0
- package/src/pushprocessor.ts +837 -0
- package/src/randomstring.ts +51 -0
- package/src/realtime-callbacks.ts +191 -0
- package/src/receipt-accumulator.ts +189 -0
- package/src/rendezvous/MSC4108SignInWithQR.ts +444 -0
- package/src/rendezvous/RendezvousChannel.ts +48 -0
- package/src/rendezvous/RendezvousCode.ts +25 -0
- package/src/rendezvous/RendezvousError.ts +26 -0
- package/src/rendezvous/RendezvousFailureReason.ts +49 -0
- package/src/rendezvous/RendezvousIntent.ts +20 -0
- package/src/rendezvous/RendezvousTransport.ts +58 -0
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +270 -0
- package/src/rendezvous/channels/index.ts +17 -0
- package/src/rendezvous/index.ts +25 -0
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +270 -0
- package/src/rendezvous/transports/index.ts +17 -0
- package/src/room-hierarchy.ts +152 -0
- package/src/rust-crypto/CrossSigningIdentity.ts +183 -0
- package/src/rust-crypto/DehydratedDeviceManager.ts +306 -0
- package/src/rust-crypto/KeyClaimManager.ts +86 -0
- package/src/rust-crypto/OutgoingRequestProcessor.ts +236 -0
- package/src/rust-crypto/OutgoingRequestsManager.ts +143 -0
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +501 -0
- package/src/rust-crypto/RoomEncryptor.ts +352 -0
- package/src/rust-crypto/backup.ts +881 -0
- package/src/rust-crypto/constants.ts +18 -0
- package/src/rust-crypto/device-converter.ts +128 -0
- package/src/rust-crypto/index.ts +237 -0
- package/src/rust-crypto/libolm_migration.ts +530 -0
- package/src/rust-crypto/rust-crypto.ts +2205 -0
- package/src/rust-crypto/secret-storage.ts +60 -0
- package/src/rust-crypto/verification.ts +830 -0
- package/src/scheduler.ts +309 -0
- package/src/secret-storage.ts +693 -0
- package/src/serverCapabilities.ts +139 -0
- package/src/service-types.ts +20 -0
- package/src/sliding-sync-sdk.ts +1026 -0
- package/src/sliding-sync.ts +965 -0
- package/src/store/index.ts +261 -0
- package/src/store/indexeddb-backend.ts +41 -0
- package/src/store/indexeddb-local-backend.ts +610 -0
- package/src/store/indexeddb-remote-backend.ts +213 -0
- package/src/store/indexeddb-store-worker.ts +157 -0
- package/src/store/indexeddb.ts +397 -0
- package/src/store/local-storage-events-emitter.ts +46 -0
- package/src/store/memory.ts +448 -0
- package/src/store/stub.ts +280 -0
- package/src/sync-accumulator.ts +689 -0
- package/src/sync.ts +1920 -0
- package/src/testing.ts +191 -0
- package/src/thread-utils.ts +31 -0
- package/src/timeline-window.ts +536 -0
- package/src/types.ts +59 -0
- package/src/utils/decryptAESSecretStorageItem.ts +54 -0
- package/src/utils/encryptAESSecretStorageItem.ts +73 -0
- package/src/utils/internal/deriveKeys.ts +63 -0
- package/src/utils.ts +763 -0
- package/src/version-support.ts +36 -0
- package/src/webrtc/audioContext.ts +44 -0
- package/src/webrtc/call.ts +3074 -0
- package/src/webrtc/callEventHandler.ts +425 -0
- package/src/webrtc/callEventTypes.ts +93 -0
- package/src/webrtc/callFeed.ts +364 -0
- package/src/webrtc/groupCall.ts +1735 -0
- package/src/webrtc/groupCallEventHandler.ts +234 -0
- package/src/webrtc/mediaHandler.ts +484 -0
- package/src/webrtc/stats/callFeedStatsReporter.ts +94 -0
- package/src/webrtc/stats/callStatsReportGatherer.ts +219 -0
- package/src/webrtc/stats/callStatsReportSummary.ts +30 -0
- package/src/webrtc/stats/connectionStats.ts +47 -0
- package/src/webrtc/stats/connectionStatsBuilder.ts +28 -0
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +140 -0
- package/src/webrtc/stats/groupCallStats.ts +93 -0
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +57 -0
- package/src/webrtc/stats/media/mediaTrackHandler.ts +76 -0
- package/src/webrtc/stats/media/mediaTrackStats.ts +176 -0
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +90 -0
- package/src/webrtc/stats/statsReport.ts +133 -0
- package/src/webrtc/stats/statsReportEmitter.ts +49 -0
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +148 -0
- package/src/webrtc/stats/trackStatsBuilder.ts +207 -0
- package/src/webrtc/stats/transportStats.ts +26 -0
- package/src/webrtc/stats/transportStatsBuilder.ts +48 -0
- package/src/webrtc/stats/valueFormatter.ts +27 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"call.js","names":["v4","uuidv4","parse","parseSdp","write","writeSdp","logger","checkObjectHasKeys","isNullOrUndefined","recursivelyAssign","EventType","ToDeviceMessageId","randomString","SDPStreamMetadataPurpose","SDPStreamMetadataKey","CallFeed","EventEmitterEvents","TypedEventEmitter","DeviceInfo","GroupCallUnknownDeviceError","MatrixError","MediaType","CodecName","CallState","CallType","CallDirection","CallParty","CallEvent","CallErrorCode","VOIP_PROTO_VERSION","FALLBACK_ICE_SERVER","CALL_TIMEOUT_MS","CALL_LENGTH_INTERVAL","ICE_DISCONNECTED_TIMEOUT","ICE_RECONNECTING_TIMEOUT","CallError","Error","constructor","code","msg","err","_defineProperty","genCallID","Date","now","toString","getCodecParamMods","isPtt","mods","mediaType","codec","enableDtx","maxAverageBitrate","undefined","getTransceiverKey","purpose","kind","MatrixCall","opts","_this","_opts$forceTURN","this","Fledgling","Map","event","candidate","candidatesEnded","warn","concat","callId","debug","sdpMid","callHasEnded","queueCandidate","_this$peerConn","peerConn","iceGatheringState","error","emit","LocalOfferFailed","terminate","Local","successor","getUserMediaFailed","NoUserMedia","placeCallFailed","IceFailed","_this$peerConn2","_this$peerConn3","_this$peerConn$iceCon","_this$peerConn4","_this$peerConn5","_this$peerConn8","iceConnectionState","connectionState","includes","clearTimeout","iceDisconnectedTimeout","iceReconnectionTimeOut","state","Connected","callLengthInterval","callStartTime","setInterval","LengthChanged","Math","round","_this$peerConn6","restartIce","_this$peerConn7","info","hangup","setTimeout","_this$peerConn9","_this$peerConn10","_this$peerConn11","Connecting","feed","getRemoteFeeds","setAudioVideoMuted","_this$peerConn12","signalingState","ev","streams","length","track","stream","pushRemoteFeed","removeTrackListeners","has","onRemoveTrack","getTracks","id","deleteFeedByStream","removeEventListener","delete","addEventListener","set","DataChannel","channel","_asyncToGenerator","CreateOffer","opponentVersion","queueGotLocalOffer","partyIdMatches","Ringing","Remote","reason","UserHangup","party_id","opponentPartyId","shouldTerminate","InviteSent","direction","Inbound","AnsweredElsewhere","roomId","invitee","client","deviceId","forceTURN","ourPartyId","opponentDeviceId","opponentSessionId","groupCallId","turnServers","isFallbackICEServerAllowed","push","urls","server","isOnlyDataChannelAllowed","isVoipWithNoMediaAllowed","placeVoiceCall","_this2","placeCall","placeVideoCall","_this3","createDataChannel","label","options","dataChannel","getOpponentMember","opponentMember","getOpponentDeviceId","getOpponentSessionId","opponentCanBeTransferred","Boolean","opponentCaps","opponentSupportsDTMF","getRemoteAssertedIdentity","remoteAssertedIdentity","_state","oldState","State","type","hasUserMediaVideoSender","hasRemoteUserMediaVideoTrack","Video","Voice","hasLocalUserMediaVideoTrack","_this$localUsermediaS","localUsermediaStream","getVideoTracks","some","_feed$stream","Usermedia","hasLocalUserMediaAudioTrack","_this$localUsermediaS2","getAudioTracks","hasRemoteUserMediaAudioTrack","_feed$stream2","hasUserMediaAudioSender","_this$transceivers$ge","transceivers","get","sender","_this$transceivers$ge2","localUsermediaFeed","getLocalFeeds","find","localScreensharingFeed","Screenshare","_this$localUsermediaF","localScreensharingStream","_this$localScreenshar","remoteUsermediaFeed","remoteScreensharingFeed","remoteUsermediaStream","_this$remoteUsermedia","remoteScreensharingStream","_this$remoteScreensha","getFeedByStreamId","streamId","getFeeds","feeds","filter","isLocal","initOpponentCrypto","_this4","_this4$getOpponentMem","_deviceInfoMap$get","getUseE2eForGroupCall","isCryptoEnabled","opponentDeviceInfo","crypto","userId","deviceInfoMap","deviceList","downloadKeys","getLocalSDPStreamMetadata","updateStreamIds","arguments","metadata","localFeed","sdpMetadataStreamId","audio_muted","isAudioMuted","video_muted","isVideoMuted","noIncomingFeeds","opponentSupportsSDPStreamMetadata","pushRemoteFeedWithoutMetadata","remoteSDPStreamMetadata","audioMuted","videoMuted","call","FeedsChanged","active","_this$feeds$find","oldRemoteStream","pushNewLocalFeed","addToPeerConnection","getUserId","setTracksEnabled","pushLocalFeed","callFeed","_this5","_loop","enabled","tKey","transceiver","replaceTrack","newSender","addTrack","newTransceiver","getTransceivers","t","removeLocalFeed","audioTransceiverKey","videoTransceiverKey","transceiverKey","removeTrack","getMediaHandler","stopScreensharingStream","deleteFeed","deleteAllFeeds","dispose","splice","indexOf","getCurrentCallStats","_this6","callStatsAtEnd","collectCallStats","_this7","statsReport","getStats","stats","forEach","item","initWithInvite","_this8","_this8$feeds$find","invite","getContent","haveTurnCreds","checkTurnServers","sdpStreamMetadata","updateRemoteSDPStreamMetadata","createPeerConnection","PeerConnectionCreated","chooseOpponent","setRemoteDescription","offer","addBufferedIceCandidates","e","SetRemoteDescription","remoteStream","getLocalAge","ringingTimer","_this8$stats","hangupParty","Ended","stopAllMedia","close","removeStatsReportGatherer","Hangup","lifetime","onState","off","on","initWithHangup","shouldAnswerWithMediaType","wantedValue","valueOfTheOtherSide","answer","audio","video","_this9","inviteOrAnswerSent","waitForLocalAVStream","prevState","answerWithAudio","answerWithVideo","WaitLocalMedia","_this9$client$getDevi","getUserMediaStream","usermediaFeed","getDeviceId","answerWithCallFeeds","callFeeds","queueGotCallFeedsForAnswer","replacedBy","newCall","Outbound","map","clone","Replaced","suppressEvent","content","sendVoipEvent","CallHangup","reject","CallReject","upgradeCall","_this10","getAudio","getVideo","updateLocalUsermediaStream","isScreensharing","setScreensharingEnabled","_this11","setScreensharingEnabledWithoutMetadataSupport","getScreensharingStream","audioTransceiver","videoTransceiver","_this12","_this12$transceivers$","_this12$localUsermedi","_this12$transceivers$2","_arguments","_this13","forceAudio","forceVideo","audioEnabled","remoteOnHold","videoEnabled","log","stop","_loop2","oldSender","added","setLocalVideoMuted","muted","_this14","_this14$localUsermedi2","stopVideoTrackTimer","hasVideoDevice","isLocalVideoMuted","_this14$localUsermedi","updateMuteStatus","sendMetadataUpdate","_this$localUsermediaF2","_this$localUsermediaF3","setMicrophoneMuted","_this15","_this15$localUsermedi","hasAudioDevice","isMicrophoneMuted","_this$localUsermediaF4","_this$localUsermediaF5","isRemoteOnHold","setRemoteOnHold","onHold","RemoteHoldUnhold","isLocalOnHold","callOnHold","trackOnHold","currentDirection","sendDtmfDigit","digit","getSenders","_sender$track","dtmf","insertDTMF","micShouldBeMuted","vidShouldBeMuted","_this16","CallSDPStreamMetadataChangedPrefix","gotCallFeedsForInvite","requestScreenshareFeed","addTransceiver","sendAnswer","_this17","answerContent","sdp","localDescription","capabilities","supportsCallTransfer","discardCount","discardDuplicateCandidates","CallAnswer","cancelPendingEvent","SendAnswer","message","name","UnknownDevices","sendCandidateQueue","responsePromiseChain","then","gotCallFeedsForAnswer","mungeSdp","description","media","payloadTypeToCodecMap","codecToPayloadTypeMap","rtp","payload","mod","extraConfig","found","fmtp","config","join","createOffer","_this18","createAnswer","_this19","_this20","CreateAnswer","getRidOfRTXCodecs","setLocalDescription","Promise","resolve","SetLocalDescription","onRemoteIceCandidatesReceived","_this21","candidates","fromPartyId","version","bufferedCandidates","remoteCandidateBuffer","addIceCandidates","onAnswerReceived","_this22","isSettingRemoteAnswerPending","CallSelectAnswer","selected_party_id","onSelectAnswerReceived","_this23","selectedPartyId","onNegotiateReceived","_this24","polite","readyForOffer","makingOffer","offerCollision","ignoreOffer","prevLocalOnHold","_localDescription","CallNegotiate","toJSON","newLocalOnHold","LocalHoldUnhold","HoldUnhold","_streamId","onSDPStreamMetadataChangedReceived","onAssertedIdentityReceived","_this25","asserted_identity","displayName","display_name","AssertedIdentityChanged","wrappedGotLocalOffer","_this26","gotLocalOffer","getLocalOfferFailed","_this27","eventType","CallInvite","_localDescription2","_localDescription3","SignallingFailed","SendInvite","inviteTimeout","InviteTimeout","RTCRtpReceiver","getCapabilities","RTCRtpSender","screenshareVideoTransceiver","setCodecPreferences","recvCodecs","codecs","sendCodecs","mimeType","pop","_this28","realContent","_objectSpread","call_id","conf_id","_this28$getOpponentMe","toDeviceSeq","device_id","sender_session_id","getSessionId","dest_session_id","seq","SendVoipEvent","encryptAndSendToDevices","deviceInfo","sendToDevice","_this28$getOpponentMe2","sendEvent","candidateSendQueue","delay","candidateSendTries","newQueue","i","transfer","targetUserId","_this29","profileInfo","getProfileInfo","replacementId","body","replacement_id","target_user","displayname","avatar_url","create_call","CallReplaces","Transferred","transferToCall","transferTargetCall","_this30","_transferTargetCall$g","_this30$getOpponentMe","targetProfileInfo","opponentUserId","transfereeProfileInfo","newCallId","bodyToTransferTarget","await_call","bodyToTransferee","hangupReason","shouldEmit","_this31","_this31$stats","clearInterval","listener","clear","callEventHandler","calls","stopUserMediaStream","checkForErrorListener","listeners","_this32","CallCandidates","delayMs","pow","_this33","_this33$client$getDev","placeCallWithCallFeeds","_arguments2","_this34","_this$stats","pc","window","RTCPeerConnection","iceTransportPolicy","iceServers","iceCandidatePoolSize","bundlePolicy","onIceConnectionStateChanged","onSignallingStateChanged","gotLocalIceCandidate","onIceGatheringStateChange","onTrack","onNegotiationNeeded","onDataChannel","opponentMemberId","addStatsReportGatherer","msgPartyId","_getMember","getRoom","getMember","getSender","_this$stats2","updateOpponentMember","_this35","_this36","sdpMLineIndex","addIceCandidate","hasPeerConnection","initStats","peerId","start","tracks","supportsMatrixCall","document","supported","RTCSessionDescription","RTCIceCandidate","navigator","mediaDevices","process","env","NODE_ENV","createNewMatrixCall","optionsForceTURN","getTurnServers","reEmitter","reEmit","Object","values"],"sources":["../../src/webrtc/call.ts"],"sourcesContent":["/*\nCopyright 2015, 2016 OpenMarket Ltd\nCopyright 2017 New Vector Ltd\nCopyright 2019, 2020 The Matrix.org Foundation C.I.C.\nCopyright 2021 - 2022 Šimon Brandner <simon.bra.ag@gmail.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * This is an internal module. See {@link createNewMatrixCall} for the public API.\n */\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport { parse as parseSdp, write as writeSdp } from \"sdp-transform\";\n\nimport { logger } from \"../logger.ts\";\nimport { checkObjectHasKeys, isNullOrUndefined, recursivelyAssign } from \"../utils.ts\";\nimport { MatrixEvent } from \"../models/event.ts\";\nimport { EventType, TimelineEvents, ToDeviceMessageId } from \"../@types/event.ts\";\nimport { RoomMember } from \"../models/room-member.ts\";\nimport { randomString } from \"../randomstring.ts\";\nimport {\n MCallReplacesEvent,\n MCallAnswer,\n MCallInviteNegotiate,\n CallCapabilities,\n SDPStreamMetadataPurpose,\n SDPStreamMetadata,\n SDPStreamMetadataKey,\n MCallSDPStreamMetadataChanged,\n MCallSelectAnswer,\n MCAllAssertedIdentity,\n MCallCandidates,\n MCallBase,\n MCallHangupReject,\n} from \"./callEventTypes.ts\";\nimport { CallFeed } from \"./callFeed.ts\";\nimport { MatrixClient } from \"../client.ts\";\nimport { EventEmitterEvents, TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { DeviceInfo } from \"../crypto/deviceinfo.ts\";\nimport { GroupCallUnknownDeviceError } from \"./groupCall.ts\";\nimport { IScreensharingOpts } from \"./mediaHandler.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { GroupCallStats } from \"./stats/groupCallStats.ts\";\n\ninterface CallOpts {\n // The room ID for this call.\n roomId: string;\n invitee?: string;\n // The Matrix Client instance to send events to.\n client: MatrixClient;\n /**\n * Whether relay through TURN should be forced.\n * @deprecated use opts.forceTURN when creating the matrix client\n * since it's only possible to set this option on outbound calls.\n */\n forceTURN?: boolean;\n // A list of TURN servers.\n turnServers?: Array<TurnServer>;\n opponentDeviceId?: string;\n opponentSessionId?: string;\n groupCallId?: string;\n}\n\ninterface TurnServer {\n urls: Array<string>;\n username?: string;\n password?: string;\n ttl?: number;\n}\n\ninterface AssertedIdentity {\n id: string;\n displayName: string;\n}\n\nenum MediaType {\n AUDIO = \"audio\",\n VIDEO = \"video\",\n}\n\nenum CodecName {\n OPUS = \"opus\",\n // add more as needed\n}\n\n// Used internally to specify modifications to codec parameters in SDP\ninterface CodecParamsMod {\n mediaType: MediaType;\n codec: CodecName;\n enableDtx?: boolean; // true to enable discontinuous transmission, false to disable, undefined to leave as-is\n maxAverageBitrate?: number; // sets the max average bitrate, or undefined to leave as-is\n}\n\nexport enum CallState {\n Fledgling = \"fledgling\",\n InviteSent = \"invite_sent\",\n WaitLocalMedia = \"wait_local_media\",\n CreateOffer = \"create_offer\",\n CreateAnswer = \"create_answer\",\n Connecting = \"connecting\",\n Connected = \"connected\",\n Ringing = \"ringing\",\n Ended = \"ended\",\n}\n\nexport enum CallType {\n Voice = \"voice\",\n Video = \"video\",\n}\n\nexport enum CallDirection {\n Inbound = \"inbound\",\n Outbound = \"outbound\",\n}\n\nexport enum CallParty {\n Local = \"local\",\n Remote = \"remote\",\n}\n\nexport enum CallEvent {\n Hangup = \"hangup\",\n State = \"state\",\n Error = \"error\",\n Replaced = \"replaced\",\n\n // The value of isLocalOnHold() has changed\n LocalHoldUnhold = \"local_hold_unhold\",\n // The value of isRemoteOnHold() has changed\n RemoteHoldUnhold = \"remote_hold_unhold\",\n // backwards compat alias for LocalHoldUnhold: remove in a major version bump\n HoldUnhold = \"hold_unhold\",\n // Feeds have changed\n FeedsChanged = \"feeds_changed\",\n\n AssertedIdentityChanged = \"asserted_identity_changed\",\n\n LengthChanged = \"length_changed\",\n\n DataChannel = \"datachannel\",\n\n SendVoipEvent = \"send_voip_event\",\n\n // When the call instantiates its peer connection\n // For apps that want to access the underlying peer connection, eg for debugging\n PeerConnectionCreated = \"peer_connection_created\",\n}\n\nexport enum CallErrorCode {\n /** The user chose to end the call */\n UserHangup = \"user_hangup\",\n\n /** An error code when the local client failed to create an offer. */\n LocalOfferFailed = \"local_offer_failed\",\n /**\n * An error code when there is no local mic/camera to use. This may be because\n * the hardware isn't plugged in, or the user has explicitly denied access.\n */\n NoUserMedia = \"no_user_media\",\n\n /**\n * Error code used when a call event failed to send\n * because unknown devices were present in the room\n */\n UnknownDevices = \"unknown_devices\",\n\n /**\n * Error code used when we fail to send the invite\n * for some reason other than there being unknown devices\n */\n SendInvite = \"send_invite\",\n\n /**\n * An answer could not be created\n */\n CreateAnswer = \"create_answer\",\n\n /**\n * An offer could not be created\n */\n CreateOffer = \"create_offer\",\n\n /**\n * Error code used when we fail to send the answer\n * for some reason other than there being unknown devices\n */\n SendAnswer = \"send_answer\",\n\n /**\n * The session description from the other side could not be set\n */\n SetRemoteDescription = \"set_remote_description\",\n\n /**\n * The session description from this side could not be set\n */\n SetLocalDescription = \"set_local_description\",\n\n /**\n * A different device answered the call\n */\n AnsweredElsewhere = \"answered_elsewhere\",\n\n /**\n * No media connection could be established to the other party\n */\n IceFailed = \"ice_failed\",\n\n /**\n * The invite timed out whilst waiting for an answer\n */\n InviteTimeout = \"invite_timeout\",\n\n /**\n * The call was replaced by another call\n */\n Replaced = \"replaced\",\n\n /**\n * Signalling for the call could not be sent (other than the initial invite)\n */\n SignallingFailed = \"signalling_timeout\",\n\n /**\n * The remote party is busy\n */\n UserBusy = \"user_busy\",\n\n /**\n * We transferred the call off to somewhere else\n */\n Transferred = \"transferred\",\n\n /**\n * A call from the same user was found with a new session id\n */\n NewSession = \"new_session\",\n}\n\n/**\n * The version field that we set in m.call.* events\n */\nconst VOIP_PROTO_VERSION = \"1\";\n\n/** The fallback ICE server to use for STUN or TURN protocols. */\nexport const FALLBACK_ICE_SERVER = \"stun:turn.matrix.org\";\n\n/** The length of time a call can be ringing for. */\nconst CALL_TIMEOUT_MS = 60 * 1000; // ms\n/** The time after which we increment callLength */\nconst CALL_LENGTH_INTERVAL = 1000; // ms\n/** The time after which we end the call, if ICE got disconnected */\nconst ICE_DISCONNECTED_TIMEOUT = 30 * 1000; // ms\n/** The time after which we try a ICE restart, if ICE got disconnected */\nconst ICE_RECONNECTING_TIMEOUT = 2 * 1000; // ms\nexport class CallError extends Error {\n public readonly code: string;\n\n public constructor(code: CallErrorCode, msg: string, err: Error) {\n // Still don't think there's any way to have proper nested errors\n super(msg + \": \" + err);\n\n this.code = code;\n }\n}\n\nexport function genCallID(): string {\n return Date.now().toString() + randomString(16);\n}\n\nfunction getCodecParamMods(isPtt: boolean): CodecParamsMod[] {\n const mods = [\n {\n mediaType: \"audio\",\n codec: \"opus\",\n enableDtx: true,\n maxAverageBitrate: isPtt ? 12000 : undefined,\n },\n ] as CodecParamsMod[];\n\n return mods;\n}\n\ntype CallEventType =\n | EventType.CallReplaces\n | EventType.CallAnswer\n | EventType.CallSelectAnswer\n | EventType.CallNegotiate\n | EventType.CallInvite\n | EventType.CallCandidates\n | EventType.CallHangup\n | EventType.CallReject\n | EventType.CallSDPStreamMetadataChangedPrefix;\n\nexport interface VoipEvent {\n type: \"toDevice\" | \"sendEvent\";\n eventType: string;\n userId?: string;\n opponentDeviceId?: string;\n roomId?: string;\n content: TimelineEvents[CallEventType];\n}\n\n/**\n * These now all have the call object as an argument. Why? Well, to know which call a given event is\n * about you have three options:\n * 1. Use a closure as the callback that remembers what call it's listening to. This can be\n * a pain because you need to pass the listener function again when you remove the listener,\n * which might be somewhere else.\n * 2. Use not-very-well-known fact that EventEmitter sets 'this' to the emitter object in the\n * callback. This doesn't really play well with modern Typescript and eslint and doesn't work\n * with our pattern of re-emitting events.\n * 3. Pass the object in question as an argument to the callback.\n *\n * Now that we have group calls which have to deal with multiple call objects, this will\n * become more important, and I think methods 1 and 2 are just going to cause issues.\n */\nexport type CallEventHandlerMap = {\n [CallEvent.DataChannel]: (channel: RTCDataChannel, call: MatrixCall) => void;\n [CallEvent.FeedsChanged]: (feeds: CallFeed[], call: MatrixCall) => void;\n [CallEvent.Replaced]: (newCall: MatrixCall, oldCall: MatrixCall) => void;\n [CallEvent.Error]: (error: CallError, call: MatrixCall) => void;\n [CallEvent.RemoteHoldUnhold]: (onHold: boolean, call: MatrixCall) => void;\n [CallEvent.LocalHoldUnhold]: (onHold: boolean, call: MatrixCall) => void;\n [CallEvent.LengthChanged]: (length: number, call: MatrixCall) => void;\n [CallEvent.State]: (state: CallState, oldState: CallState, call: MatrixCall) => void;\n [CallEvent.Hangup]: (call: MatrixCall) => void;\n [CallEvent.AssertedIdentityChanged]: (call: MatrixCall) => void;\n /* @deprecated */\n [CallEvent.HoldUnhold]: (onHold: boolean) => void;\n [CallEvent.SendVoipEvent]: (event: VoipEvent, call: MatrixCall) => void;\n [CallEvent.PeerConnectionCreated]: (peerConn: RTCPeerConnection, call: MatrixCall) => void;\n};\n\n// The key of the transceiver map (purpose + media type, separated by ':')\ntype TransceiverKey = string;\n\n// generates keys for the map of transceivers\n// kind is unfortunately a string rather than MediaType as this is the type of\n// track.kind\nfunction getTransceiverKey(purpose: SDPStreamMetadataPurpose, kind: TransceiverKey): string {\n return purpose + \":\" + kind;\n}\n\nexport class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap> {\n public roomId: string;\n public callId: string;\n public invitee?: string;\n public hangupParty?: CallParty;\n public hangupReason?: string;\n public direction?: CallDirection;\n public ourPartyId: string;\n public peerConn?: RTCPeerConnection;\n public toDeviceSeq = 0;\n\n // whether this call should have push-to-talk semantics\n // This should be set by the consumer on incoming & outgoing calls.\n public isPtt = false;\n\n private _state = CallState.Fledgling;\n private readonly client: MatrixClient;\n private readonly forceTURN?: boolean;\n private readonly turnServers: Array<TurnServer>;\n // A queue for candidates waiting to go out.\n // We try to amalgamate candidates into a single candidate message where\n // possible\n private candidateSendQueue: Array<RTCIceCandidate> = [];\n private candidateSendTries = 0;\n private candidatesEnded = false;\n private feeds: Array<CallFeed> = [];\n\n // our transceivers for each purpose and type of media\n private transceivers = new Map<TransceiverKey, RTCRtpTransceiver>();\n\n private inviteOrAnswerSent = false;\n private waitForLocalAVStream = false;\n private successor?: MatrixCall;\n private opponentMember?: RoomMember;\n private opponentVersion?: number | string;\n // The party ID of the other side: undefined if we haven't chosen a partner\n // yet, null if we have but they didn't send a party ID.\n private opponentPartyId: string | null | undefined;\n private opponentCaps?: CallCapabilities;\n private iceDisconnectedTimeout?: ReturnType<typeof setTimeout>;\n private iceReconnectionTimeOut?: ReturnType<typeof setTimeout> | undefined;\n private inviteTimeout?: ReturnType<typeof setTimeout>;\n private readonly removeTrackListeners = new Map<MediaStream, () => void>();\n\n // The logic of when & if a call is on hold is nontrivial and explained in is*OnHold\n // This flag represents whether we want the other party to be on hold\n private remoteOnHold = false;\n\n // the stats for the call at the point it ended. We can't get these after we\n // tear the call down, so we just grab a snapshot before we stop the call.\n // The typescript definitions have this type as 'any' :(\n private callStatsAtEnd?: any[];\n\n // Perfect negotiation state: https://www.w3.org/TR/webrtc/#perfect-negotiation-example\n private makingOffer = false;\n private ignoreOffer = false;\n private isSettingRemoteAnswerPending = false;\n\n private responsePromiseChain?: Promise<void>;\n\n // If candidates arrive before we've picked an opponent (which, in particular,\n // will happen if the opponent sends candidates eagerly before the user answers\n // the call) we buffer them up here so we can then add the ones from the party we pick\n private remoteCandidateBuffer = new Map<string, MCallCandidates[\"candidates\"]>();\n\n private remoteAssertedIdentity?: AssertedIdentity;\n private remoteSDPStreamMetadata?: SDPStreamMetadata;\n\n private callLengthInterval?: ReturnType<typeof setInterval>;\n private callStartTime?: number;\n\n private opponentDeviceId?: string;\n private opponentDeviceInfo?: DeviceInfo;\n private opponentSessionId?: string;\n public groupCallId?: string;\n\n // Used to keep the timer for the delay before actually stopping our\n // video track after muting (see setLocalVideoMuted)\n private stopVideoTrackTimer?: ReturnType<typeof setTimeout>;\n // Used to allow connection without Video and Audio. To establish a webrtc connection without media a Data channel is\n // needed At the moment this property is true if we allow MatrixClient with isVoipWithNoMediaAllowed = true\n private readonly isOnlyDataChannelAllowed: boolean;\n private stats: GroupCallStats | undefined;\n\n /**\n * Construct a new Matrix Call.\n * @param opts - Config options.\n */\n public constructor(opts: CallOpts) {\n super();\n\n this.roomId = opts.roomId;\n this.invitee = opts.invitee;\n this.client = opts.client;\n\n if (!this.client.deviceId) throw new Error(\"Client must have a device ID to start calls\");\n\n this.forceTURN = opts.forceTURN ?? false;\n this.ourPartyId = this.client.deviceId;\n this.opponentDeviceId = opts.opponentDeviceId;\n this.opponentSessionId = opts.opponentSessionId;\n this.groupCallId = opts.groupCallId;\n // Array of Objects with urls, username, credential keys\n this.turnServers = opts.turnServers || [];\n if (this.turnServers.length === 0 && this.client.isFallbackICEServerAllowed()) {\n this.turnServers.push({\n urls: [FALLBACK_ICE_SERVER],\n });\n }\n for (const server of this.turnServers) {\n checkObjectHasKeys(server, [\"urls\"]);\n }\n this.callId = genCallID();\n // If the Client provides calls without audio and video we need a datachannel for a webrtc connection\n this.isOnlyDataChannelAllowed = this.client.isVoipWithNoMediaAllowed;\n }\n\n /**\n * Place a voice call to this room.\n * @throws If you have not specified a listener for 'error' events.\n */\n public async placeVoiceCall(): Promise<void> {\n await this.placeCall(true, false);\n }\n\n /**\n * Place a video call to this room.\n * @throws If you have not specified a listener for 'error' events.\n */\n public async placeVideoCall(): Promise<void> {\n await this.placeCall(true, true);\n }\n\n /**\n * Create a datachannel using this call's peer connection.\n * @param label - A human readable label for this datachannel\n * @param options - An object providing configuration options for the data channel.\n */\n public createDataChannel(label: string, options: RTCDataChannelInit | undefined): RTCDataChannel {\n const dataChannel = this.peerConn!.createDataChannel(label, options);\n this.emit(CallEvent.DataChannel, dataChannel, this);\n return dataChannel;\n }\n\n public getOpponentMember(): RoomMember | undefined {\n return this.opponentMember;\n }\n\n public getOpponentDeviceId(): string | undefined {\n return this.opponentDeviceId;\n }\n\n public getOpponentSessionId(): string | undefined {\n return this.opponentSessionId;\n }\n\n public opponentCanBeTransferred(): boolean {\n return Boolean(this.opponentCaps && this.opponentCaps[\"m.call.transferee\"]);\n }\n\n public opponentSupportsDTMF(): boolean {\n return Boolean(this.opponentCaps && this.opponentCaps[\"m.call.dtmf\"]);\n }\n\n public getRemoteAssertedIdentity(): AssertedIdentity | undefined {\n return this.remoteAssertedIdentity;\n }\n\n public get state(): CallState {\n return this._state;\n }\n\n private set state(state: CallState) {\n const oldState = this._state;\n this._state = state;\n this.emit(CallEvent.State, state, oldState, this);\n }\n\n public get type(): CallType {\n // we may want to look for a video receiver here rather than a track to match the\n // sender behaviour, although in practice they should be the same thing\n return this.hasUserMediaVideoSender || this.hasRemoteUserMediaVideoTrack ? CallType.Video : CallType.Voice;\n }\n\n public get hasLocalUserMediaVideoTrack(): boolean {\n return !!this.localUsermediaStream?.getVideoTracks().length;\n }\n\n public get hasRemoteUserMediaVideoTrack(): boolean {\n return this.getRemoteFeeds().some((feed) => {\n return feed.purpose === SDPStreamMetadataPurpose.Usermedia && feed.stream?.getVideoTracks().length;\n });\n }\n\n public get hasLocalUserMediaAudioTrack(): boolean {\n return !!this.localUsermediaStream?.getAudioTracks().length;\n }\n\n public get hasRemoteUserMediaAudioTrack(): boolean {\n return this.getRemoteFeeds().some((feed) => {\n return feed.purpose === SDPStreamMetadataPurpose.Usermedia && !!feed.stream?.getAudioTracks().length;\n });\n }\n\n private get hasUserMediaAudioSender(): boolean {\n return Boolean(this.transceivers.get(getTransceiverKey(SDPStreamMetadataPurpose.Usermedia, \"audio\"))?.sender);\n }\n\n private get hasUserMediaVideoSender(): boolean {\n return Boolean(this.transceivers.get(getTransceiverKey(SDPStreamMetadataPurpose.Usermedia, \"video\"))?.sender);\n }\n\n public get localUsermediaFeed(): CallFeed | undefined {\n return this.getLocalFeeds().find((feed) => feed.purpose === SDPStreamMetadataPurpose.Usermedia);\n }\n\n public get localScreensharingFeed(): CallFeed | undefined {\n return this.getLocalFeeds().find((feed) => feed.purpose === SDPStreamMetadataPurpose.Screenshare);\n }\n\n public get localUsermediaStream(): MediaStream | undefined {\n return this.localUsermediaFeed?.stream;\n }\n\n public get localScreensharingStream(): MediaStream | undefined {\n return this.localScreensharingFeed?.stream;\n }\n\n public get remoteUsermediaFeed(): CallFeed | undefined {\n return this.getRemoteFeeds().find((feed) => feed.purpose === SDPStreamMetadataPurpose.Usermedia);\n }\n\n public get remoteScreensharingFeed(): CallFeed | undefined {\n return this.getRemoteFeeds().find((feed) => feed.purpose === SDPStreamMetadataPurpose.Screenshare);\n }\n\n public get remoteUsermediaStream(): MediaStream | undefined {\n return this.remoteUsermediaFeed?.stream;\n }\n\n public get remoteScreensharingStream(): MediaStream | undefined {\n return this.remoteScreensharingFeed?.stream;\n }\n\n private getFeedByStreamId(streamId: string): CallFeed | undefined {\n return this.getFeeds().find((feed) => feed.stream.id === streamId);\n }\n\n /**\n * Returns an array of all CallFeeds\n * @returns CallFeeds\n */\n public getFeeds(): Array<CallFeed> {\n return this.feeds;\n }\n\n /**\n * Returns an array of all local CallFeeds\n * @returns local CallFeeds\n */\n public getLocalFeeds(): Array<CallFeed> {\n return this.feeds.filter((feed) => feed.isLocal());\n }\n\n /**\n * Returns an array of all remote CallFeeds\n * @returns remote CallFeeds\n */\n public getRemoteFeeds(): Array<CallFeed> {\n return this.feeds.filter((feed) => !feed.isLocal());\n }\n\n private async initOpponentCrypto(): Promise<void> {\n if (!this.opponentDeviceId) return;\n if (!this.client.getUseE2eForGroupCall()) return;\n // It's possible to want E2EE and yet not have the means to manage E2EE\n // ourselves (for example if the client is a RoomWidgetClient)\n if (!this.client.isCryptoEnabled()) {\n // All we know is the device ID\n this.opponentDeviceInfo = new DeviceInfo(this.opponentDeviceId);\n return;\n }\n // if we've got to this point, we do want to init crypto, so throw if we can't\n if (!this.client.crypto) throw new Error(\"Crypto is not initialised.\");\n\n const userId = this.invitee || this.getOpponentMember()?.userId;\n\n if (!userId) throw new Error(\"Couldn't find opponent user ID to init crypto\");\n\n const deviceInfoMap = await this.client.crypto.deviceList.downloadKeys([userId], false);\n this.opponentDeviceInfo = deviceInfoMap.get(userId)?.get(this.opponentDeviceId);\n if (this.opponentDeviceInfo === undefined) {\n throw new GroupCallUnknownDeviceError(userId);\n }\n }\n\n /**\n * Generates and returns localSDPStreamMetadata\n * @returns localSDPStreamMetadata\n */\n private getLocalSDPStreamMetadata(updateStreamIds = false): SDPStreamMetadata {\n const metadata: SDPStreamMetadata = {};\n for (const localFeed of this.getLocalFeeds()) {\n if (updateStreamIds) {\n localFeed.sdpMetadataStreamId = localFeed.stream.id;\n }\n\n metadata[localFeed.sdpMetadataStreamId] = {\n purpose: localFeed.purpose,\n audio_muted: localFeed.isAudioMuted(),\n video_muted: localFeed.isVideoMuted(),\n };\n }\n return metadata;\n }\n\n /**\n * Returns true if there are no incoming feeds,\n * otherwise returns false\n * @returns no incoming feeds\n */\n public noIncomingFeeds(): boolean {\n return !this.feeds.some((feed) => !feed.isLocal());\n }\n\n private pushRemoteFeed(stream: MediaStream): void {\n // Fallback to old behavior if the other side doesn't support SDPStreamMetadata\n if (!this.opponentSupportsSDPStreamMetadata()) {\n this.pushRemoteFeedWithoutMetadata(stream);\n return;\n }\n\n const userId = this.getOpponentMember()!.userId;\n const purpose = this.remoteSDPStreamMetadata![stream.id].purpose;\n const audioMuted = this.remoteSDPStreamMetadata![stream.id].audio_muted;\n const videoMuted = this.remoteSDPStreamMetadata![stream.id].video_muted;\n\n if (!purpose) {\n logger.warn(\n `Call ${this.callId} pushRemoteFeed() ignoring stream because we didn't get any metadata about it (streamId=${stream.id})`,\n );\n return;\n }\n\n if (this.getFeedByStreamId(stream.id)) {\n logger.warn(\n `Call ${this.callId} pushRemoteFeed() ignoring stream because we already have a feed for it (streamId=${stream.id})`,\n );\n return;\n }\n\n this.feeds.push(\n new CallFeed({\n client: this.client,\n call: this,\n roomId: this.roomId,\n userId,\n deviceId: this.getOpponentDeviceId(),\n stream,\n purpose,\n audioMuted,\n videoMuted,\n }),\n );\n\n this.emit(CallEvent.FeedsChanged, this.feeds, this);\n\n logger.info(\n `Call ${this.callId} pushRemoteFeed() pushed stream (streamId=${stream.id}, active=${stream.active}, purpose=${purpose})`,\n );\n }\n\n /**\n * This method is used ONLY if the other client doesn't support sending SDPStreamMetadata\n */\n private pushRemoteFeedWithoutMetadata(stream: MediaStream): void {\n const userId = this.getOpponentMember()!.userId;\n // We can guess the purpose here since the other client can only send one stream\n const purpose = SDPStreamMetadataPurpose.Usermedia;\n const oldRemoteStream = this.feeds.find((feed) => !feed.isLocal())?.stream;\n\n // Note that we check by ID and always set the remote stream: Chrome appears\n // to make new stream objects when transceiver directionality is changed and the 'active'\n // status of streams change - Dave\n // If we already have a stream, check this stream has the same id\n if (oldRemoteStream && stream.id !== oldRemoteStream.id) {\n logger.warn(\n `Call ${this.callId} pushRemoteFeedWithoutMetadata() ignoring new stream because we already have stream (streamId=${stream.id})`,\n );\n return;\n }\n\n if (this.getFeedByStreamId(stream.id)) {\n logger.warn(\n `Call ${this.callId} pushRemoteFeedWithoutMetadata() ignoring stream because we already have a feed for it (streamId=${stream.id})`,\n );\n return;\n }\n\n this.feeds.push(\n new CallFeed({\n client: this.client,\n call: this,\n roomId: this.roomId,\n audioMuted: false,\n videoMuted: false,\n userId,\n deviceId: this.getOpponentDeviceId(),\n stream,\n purpose,\n }),\n );\n\n this.emit(CallEvent.FeedsChanged, this.feeds, this);\n\n logger.info(\n `Call ${this.callId} pushRemoteFeedWithoutMetadata() pushed stream (streamId=${stream.id}, active=${stream.active})`,\n );\n }\n\n private pushNewLocalFeed(stream: MediaStream, purpose: SDPStreamMetadataPurpose, addToPeerConnection = true): void {\n const userId = this.client.getUserId()!;\n\n // Tracks don't always start off enabled, eg. chrome will give a disabled\n // audio track if you ask for user media audio and already had one that\n // you'd set to disabled (presumably because it clones them internally).\n setTracksEnabled(stream.getAudioTracks(), true);\n setTracksEnabled(stream.getVideoTracks(), true);\n\n if (this.getFeedByStreamId(stream.id)) {\n logger.warn(\n `Call ${this.callId} pushNewLocalFeed() ignoring stream because we already have a feed for it (streamId=${stream.id})`,\n );\n return;\n }\n\n this.pushLocalFeed(\n new CallFeed({\n client: this.client,\n roomId: this.roomId,\n audioMuted: false,\n videoMuted: false,\n userId,\n deviceId: this.getOpponentDeviceId(),\n stream,\n purpose,\n }),\n addToPeerConnection,\n );\n }\n\n /**\n * Pushes supplied feed to the call\n * @param callFeed - to push\n * @param addToPeerConnection - whether to add the tracks to the peer connection\n */\n public pushLocalFeed(callFeed: CallFeed, addToPeerConnection = true): void {\n if (this.feeds.some((feed) => callFeed.stream.id === feed.stream.id)) {\n logger.info(\n `Call ${this.callId} pushLocalFeed() ignoring duplicate local stream (streamId=${callFeed.stream.id})`,\n );\n return;\n }\n\n this.feeds.push(callFeed);\n\n if (addToPeerConnection) {\n for (const track of callFeed.stream.getTracks()) {\n logger.info(\n `Call ${this.callId} pushLocalFeed() adding track to peer connection (id=${track.id}, kind=${track.kind}, streamId=${callFeed.stream.id}, streamPurpose=${callFeed.purpose}, enabled=${track.enabled})`,\n );\n\n const tKey = getTransceiverKey(callFeed.purpose, track.kind);\n if (this.transceivers.has(tKey)) {\n // we already have a sender, so we re-use it. We try to re-use transceivers as much\n // as possible because they can't be removed once added, so otherwise they just\n // accumulate which makes the SDP very large very quickly: in fact it only takes\n // about 6 video tracks to exceed the maximum size of an Olm-encrypted\n // Matrix event.\n const transceiver = this.transceivers.get(tKey)!;\n\n transceiver.sender.replaceTrack(track);\n // set the direction to indicate we're going to start sending again\n // (this will trigger the re-negotiation)\n transceiver.direction = transceiver.direction === \"inactive\" ? \"sendonly\" : \"sendrecv\";\n } else {\n // create a new one. We need to use addTrack rather addTransceiver for this because firefox\n // doesn't yet implement RTCRTPSender.setStreams()\n // (https://bugzilla.mozilla.org/show_bug.cgi?id=1510802) so we'd have no way to group the\n // two tracks together into a stream.\n const newSender = this.peerConn!.addTrack(track, callFeed.stream);\n\n // now go & fish for the new transceiver\n const newTransceiver = this.peerConn!.getTransceivers().find((t) => t.sender === newSender);\n if (newTransceiver) {\n this.transceivers.set(tKey, newTransceiver);\n } else {\n logger.warn(\n `Call ${this.callId} pushLocalFeed() didn't find a matching transceiver after adding track!`,\n );\n }\n }\n }\n }\n\n logger.info(\n `Call ${this.callId} pushLocalFeed() pushed stream (id=${callFeed.stream.id}, active=${callFeed.stream.active}, purpose=${callFeed.purpose})`,\n );\n\n this.emit(CallEvent.FeedsChanged, this.feeds, this);\n }\n\n /**\n * Removes local call feed from the call and its tracks from the peer\n * connection\n * @param callFeed - to remove\n */\n public removeLocalFeed(callFeed: CallFeed): void {\n const audioTransceiverKey = getTransceiverKey(callFeed.purpose, \"audio\");\n const videoTransceiverKey = getTransceiverKey(callFeed.purpose, \"video\");\n\n for (const transceiverKey of [audioTransceiverKey, videoTransceiverKey]) {\n // this is slightly mixing the track and transceiver API but is basically just shorthand.\n // There is no way to actually remove a transceiver, so this just sets it to inactive\n // (or recvonly) and replaces the source with nothing.\n if (this.transceivers.has(transceiverKey)) {\n const transceiver = this.transceivers.get(transceiverKey)!;\n if (transceiver.sender) this.peerConn!.removeTrack(transceiver.sender);\n }\n }\n\n if (callFeed.purpose === SDPStreamMetadataPurpose.Screenshare) {\n this.client.getMediaHandler().stopScreensharingStream(callFeed.stream);\n }\n\n this.deleteFeed(callFeed);\n }\n\n private deleteAllFeeds(): void {\n for (const feed of this.feeds) {\n if (!feed.isLocal() || !this.groupCallId) {\n feed.dispose();\n }\n }\n\n this.feeds = [];\n this.emit(CallEvent.FeedsChanged, this.feeds, this);\n }\n\n private deleteFeedByStream(stream: MediaStream): void {\n const feed = this.getFeedByStreamId(stream.id);\n if (!feed) {\n logger.warn(\n `Call ${this.callId} deleteFeedByStream() didn't find the feed to delete (streamId=${stream.id})`,\n );\n return;\n }\n this.deleteFeed(feed);\n }\n\n private deleteFeed(feed: CallFeed): void {\n feed.dispose();\n this.feeds.splice(this.feeds.indexOf(feed), 1);\n this.emit(CallEvent.FeedsChanged, this.feeds, this);\n }\n\n // The typescript definitions have this type as 'any' :(\n public async getCurrentCallStats(): Promise<any[] | undefined> {\n if (this.callHasEnded()) {\n return this.callStatsAtEnd;\n }\n\n return this.collectCallStats();\n }\n\n private async collectCallStats(): Promise<any[] | undefined> {\n // This happens when the call fails before it starts.\n // For example when we fail to get capture sources\n if (!this.peerConn) return;\n\n const statsReport = await this.peerConn.getStats();\n const stats: any[] = [];\n statsReport.forEach((item) => {\n stats.push(item);\n });\n\n return stats;\n }\n\n /**\n * Configure this call from an invite event. Used by MatrixClient.\n * @param event - The m.call.invite event\n */\n public async initWithInvite(event: MatrixEvent): Promise<void> {\n const invite = event.getContent<MCallInviteNegotiate>();\n this.direction = CallDirection.Inbound;\n\n // make sure we have valid turn creds. Unless something's gone wrong, it should\n // poll and keep the credentials valid so this should be instant.\n const haveTurnCreds = await this.client.checkTurnServers();\n if (!haveTurnCreds) {\n logger.warn(\n `Call ${this.callId} initWithInvite() failed to get TURN credentials! Proceeding with call anyway...`,\n );\n }\n\n const sdpStreamMetadata = invite[SDPStreamMetadataKey];\n if (sdpStreamMetadata) {\n this.updateRemoteSDPStreamMetadata(sdpStreamMetadata);\n } else {\n logger.debug(\n `Call ${this.callId} initWithInvite() did not get any SDPStreamMetadata! Can not send/receive multiple streams`,\n );\n }\n\n this.peerConn = this.createPeerConnection();\n this.emit(CallEvent.PeerConnectionCreated, this.peerConn, this);\n // we must set the party ID before await-ing on anything: the call event\n // handler will start giving us more call events (eg. candidates) so if\n // we haven't set the party ID, we'll ignore them.\n this.chooseOpponent(event);\n await this.initOpponentCrypto();\n try {\n await this.peerConn.setRemoteDescription(invite.offer);\n logger.debug(`Call ${this.callId} initWithInvite() set remote description: ${invite.offer.type}`);\n await this.addBufferedIceCandidates();\n } catch (e) {\n logger.debug(`Call ${this.callId} initWithInvite() failed to set remote description`, e);\n this.terminate(CallParty.Local, CallErrorCode.SetRemoteDescription, false);\n return;\n }\n\n const remoteStream = this.feeds.find((feed) => !feed.isLocal())?.stream;\n\n // According to previous comments in this file, firefox at some point did not\n // add streams until media started arriving on them. Testing latest firefox\n // (81 at time of writing), this is no longer a problem, so let's do it the correct way.\n //\n // For example in case of no media webrtc connections like screen share only call we have to allow webrtc\n // connections without remote media. In this case we always use a data channel. At the moment we allow as well\n // only data channel as media in the WebRTC connection with this setup here.\n if (!this.isOnlyDataChannelAllowed && (!remoteStream || remoteStream.getTracks().length === 0)) {\n logger.error(\n `Call ${this.callId} initWithInvite() no remote stream or no tracks after setting remote description!`,\n );\n this.terminate(CallParty.Local, CallErrorCode.SetRemoteDescription, false);\n return;\n }\n\n this.state = CallState.Ringing;\n\n if (event.getLocalAge()) {\n // Time out the call if it's ringing for too long\n const ringingTimer = setTimeout(() => {\n if (this.state == CallState.Ringing) {\n logger.debug(`Call ${this.callId} initWithInvite() invite has expired. Hanging up.`);\n this.hangupParty = CallParty.Remote; // effectively\n this.state = CallState.Ended;\n this.stopAllMedia();\n if (this.peerConn!.signalingState != \"closed\") {\n this.peerConn!.close();\n }\n this.stats?.removeStatsReportGatherer(this.callId);\n this.emit(CallEvent.Hangup, this);\n }\n }, invite.lifetime - event.getLocalAge());\n\n const onState = (state: CallState): void => {\n if (state !== CallState.Ringing) {\n clearTimeout(ringingTimer);\n this.off(CallEvent.State, onState);\n }\n };\n this.on(CallEvent.State, onState);\n }\n }\n\n /**\n * Configure this call from a hangup or reject event. Used by MatrixClient.\n * @param event - The m.call.hangup event\n */\n public initWithHangup(event: MatrixEvent): void {\n // perverse as it may seem, sometimes we want to instantiate a call with a\n // hangup message (because when getting the state of the room on load, events\n // come in reverse order and we want to remember that a call has been hung up)\n this.state = CallState.Ended;\n }\n\n private shouldAnswerWithMediaType(\n wantedValue: boolean | undefined,\n valueOfTheOtherSide: boolean,\n type: \"audio\" | \"video\",\n ): boolean {\n if (wantedValue && !valueOfTheOtherSide) {\n // TODO: Figure out how to do this\n logger.warn(\n `Call ${this.callId} shouldAnswerWithMediaType() unable to answer with ${type} because the other side isn't sending it either.`,\n );\n return false;\n } else if (\n !isNullOrUndefined(wantedValue) &&\n wantedValue !== valueOfTheOtherSide &&\n !this.opponentSupportsSDPStreamMetadata()\n ) {\n logger.warn(\n `Call ${this.callId} shouldAnswerWithMediaType() unable to answer with ${type}=${wantedValue} because the other side doesn't support it. Answering with ${type}=${valueOfTheOtherSide}.`,\n );\n return valueOfTheOtherSide!;\n }\n return wantedValue ?? valueOfTheOtherSide!;\n }\n\n /**\n * Answer a call.\n */\n public async answer(audio?: boolean, video?: boolean): Promise<void> {\n if (this.inviteOrAnswerSent) return;\n // TODO: Figure out how to do this\n if (audio === false && video === false) throw new Error(\"You CANNOT answer a call without media\");\n\n if (!this.localUsermediaStream && !this.waitForLocalAVStream) {\n const prevState = this.state;\n const answerWithAudio = this.shouldAnswerWithMediaType(audio, this.hasRemoteUserMediaAudioTrack, \"audio\");\n const answerWithVideo = this.shouldAnswerWithMediaType(video, this.hasRemoteUserMediaVideoTrack, \"video\");\n\n this.state = CallState.WaitLocalMedia;\n this.waitForLocalAVStream = true;\n\n try {\n const stream = await this.client.getMediaHandler().getUserMediaStream(answerWithAudio, answerWithVideo);\n this.waitForLocalAVStream = false;\n const usermediaFeed = new CallFeed({\n client: this.client,\n roomId: this.roomId,\n userId: this.client.getUserId()!,\n deviceId: this.client.getDeviceId() ?? undefined,\n stream,\n purpose: SDPStreamMetadataPurpose.Usermedia,\n audioMuted: false,\n videoMuted: false,\n });\n\n const feeds = [usermediaFeed];\n\n if (this.localScreensharingFeed) {\n feeds.push(this.localScreensharingFeed);\n }\n\n this.answerWithCallFeeds(feeds);\n } catch (e) {\n if (answerWithVideo) {\n // Try to answer without video\n logger.warn(\n `Call ${this.callId} answer() failed to getUserMedia(), trying to getUserMedia() without video`,\n );\n this.state = prevState;\n this.waitForLocalAVStream = false;\n await this.answer(answerWithAudio, false);\n } else {\n this.getUserMediaFailed(<Error>e);\n return;\n }\n }\n } else if (this.waitForLocalAVStream) {\n this.state = CallState.WaitLocalMedia;\n }\n }\n\n public answerWithCallFeeds(callFeeds: CallFeed[]): void {\n if (this.inviteOrAnswerSent) return;\n\n this.queueGotCallFeedsForAnswer(callFeeds);\n }\n\n /**\n * Replace this call with a new call, e.g. for glare resolution. Used by\n * MatrixClient.\n * @param newCall - The new call.\n */\n public replacedBy(newCall: MatrixCall): void {\n logger.debug(`Call ${this.callId} replacedBy() running (newCallId=${newCall.callId})`);\n if (this.state === CallState.WaitLocalMedia) {\n logger.debug(\n `Call ${this.callId} replacedBy() telling new call to wait for local media (newCallId=${newCall.callId})`,\n );\n newCall.waitForLocalAVStream = true;\n } else if ([CallState.CreateOffer, CallState.InviteSent].includes(this.state)) {\n if (newCall.direction === CallDirection.Outbound) {\n newCall.queueGotCallFeedsForAnswer([]);\n } else {\n logger.debug(\n `Call ${this.callId} replacedBy() handing local stream to new call(newCallId=${newCall.callId})`,\n );\n newCall.queueGotCallFeedsForAnswer(this.getLocalFeeds().map((feed) => feed.clone()));\n }\n }\n this.successor = newCall;\n this.emit(CallEvent.Replaced, newCall, this);\n this.hangup(CallErrorCode.Replaced, true);\n }\n\n /**\n * Hangup a call.\n * @param reason - The reason why the call is being hung up.\n * @param suppressEvent - True to suppress emitting an event.\n */\n public hangup(reason: CallErrorCode, suppressEvent: boolean): void {\n if (this.callHasEnded()) return;\n\n logger.debug(`Call ${this.callId} hangup() ending call (reason=${reason})`);\n this.terminate(CallParty.Local, reason, !suppressEvent);\n // We don't want to send hangup here if we didn't even get to sending an invite\n if ([CallState.Fledgling, CallState.WaitLocalMedia].includes(this.state)) return;\n const content: Omit<MCallHangupReject, \"version\" | \"call_id\" | \"party_id\" | \"conf_id\"> = {};\n // Don't send UserHangup reason to older clients\n if ((this.opponentVersion && this.opponentVersion !== 0) || reason !== CallErrorCode.UserHangup) {\n content[\"reason\"] = reason;\n }\n this.sendVoipEvent(EventType.CallHangup, content);\n }\n\n /**\n * Reject a call\n * This used to be done by calling hangup, but is a separate method and protocol\n * event as of MSC2746.\n */\n public reject(): void {\n if (this.state !== CallState.Ringing) {\n throw Error(\"Call must be in 'ringing' state to reject!\");\n }\n\n if (this.opponentVersion === 0) {\n logger.info(\n `Call ${this.callId} reject() opponent version is less than 1: sending hangup instead of reject (opponentVersion=${this.opponentVersion})`,\n );\n this.hangup(CallErrorCode.UserHangup, true);\n return;\n }\n\n logger.debug(\"Rejecting call: \" + this.callId);\n this.terminate(CallParty.Local, CallErrorCode.UserHangup, true);\n this.sendVoipEvent(EventType.CallReject, {});\n }\n\n /**\n * Adds an audio and/or video track - upgrades the call\n * @param audio - should add an audio track\n * @param video - should add an video track\n */\n private async upgradeCall(audio: boolean, video: boolean): Promise<void> {\n // We don't do call downgrades\n if (!audio && !video) return;\n if (!this.opponentSupportsSDPStreamMetadata()) return;\n\n try {\n logger.debug(`Call ${this.callId} upgradeCall() upgrading call (audio=${audio}, video=${video})`);\n const getAudio = audio || this.hasLocalUserMediaAudioTrack;\n const getVideo = video || this.hasLocalUserMediaVideoTrack;\n\n // updateLocalUsermediaStream() will take the tracks, use them as\n // replacement and throw the stream away, so it isn't reusable\n const stream = await this.client.getMediaHandler().getUserMediaStream(getAudio, getVideo, false);\n await this.updateLocalUsermediaStream(stream, audio, video);\n } catch (error) {\n logger.error(`Call ${this.callId} upgradeCall() failed to upgrade the call`, error);\n this.emit(\n CallEvent.Error,\n new CallError(CallErrorCode.NoUserMedia, \"Failed to get camera access: \", <Error>error),\n this,\n );\n }\n }\n\n /**\n * Returns true if this.remoteSDPStreamMetadata is defined, otherwise returns false\n * @returns can screenshare\n */\n public opponentSupportsSDPStreamMetadata(): boolean {\n return Boolean(this.remoteSDPStreamMetadata);\n }\n\n /**\n * If there is a screensharing stream returns true, otherwise returns false\n * @returns is screensharing\n */\n public isScreensharing(): boolean {\n return Boolean(this.localScreensharingStream);\n }\n\n /**\n * Starts/stops screensharing\n * @param enabled - the desired screensharing state\n * @param opts - screen sharing options\n * @returns new screensharing state\n */\n public async setScreensharingEnabled(enabled: boolean, opts?: IScreensharingOpts): Promise<boolean> {\n // Skip if there is nothing to do\n if (enabled && this.isScreensharing()) {\n logger.warn(\n `Call ${this.callId} setScreensharingEnabled() there is already a screensharing stream - there is nothing to do!`,\n );\n return true;\n } else if (!enabled && !this.isScreensharing()) {\n logger.warn(\n `Call ${this.callId} setScreensharingEnabled() there already isn't a screensharing stream - there is nothing to do!`,\n );\n return false;\n }\n\n // Fallback to replaceTrack()\n if (!this.opponentSupportsSDPStreamMetadata()) {\n return this.setScreensharingEnabledWithoutMetadataSupport(enabled, opts);\n }\n\n logger.debug(`Call ${this.callId} setScreensharingEnabled() running (enabled=${enabled})`);\n if (enabled) {\n try {\n const stream = await this.client.getMediaHandler().getScreensharingStream(opts);\n if (!stream) return false;\n this.pushNewLocalFeed(stream, SDPStreamMetadataPurpose.Screenshare);\n return true;\n } catch (err) {\n logger.error(`Call ${this.callId} setScreensharingEnabled() failed to get screen-sharing stream:`, err);\n return false;\n }\n } else {\n const audioTransceiver = this.transceivers.get(\n getTransceiverKey(SDPStreamMetadataPurpose.Screenshare, \"audio\"),\n );\n const videoTransceiver = this.transceivers.get(\n getTransceiverKey(SDPStreamMetadataPurpose.Screenshare, \"video\"),\n );\n\n for (const transceiver of [audioTransceiver, videoTransceiver]) {\n // this is slightly mixing the track and transceiver API but is basically just shorthand\n // for removing the sender.\n if (transceiver && transceiver.sender) this.peerConn!.removeTrack(transceiver.sender);\n }\n\n this.client.getMediaHandler().stopScreensharingStream(this.localScreensharingStream!);\n this.deleteFeedByStream(this.localScreensharingStream!);\n return false;\n }\n }\n\n /**\n * Starts/stops screensharing\n * Should be used ONLY if the opponent doesn't support SDPStreamMetadata\n * @param enabled - the desired screensharing state\n * @param opts - screen sharing options\n * @returns new screensharing state\n */\n private async setScreensharingEnabledWithoutMetadataSupport(\n enabled: boolean,\n opts?: IScreensharingOpts,\n ): Promise<boolean> {\n logger.debug(\n `Call ${this.callId} setScreensharingEnabledWithoutMetadataSupport() running (enabled=${enabled})`,\n );\n if (enabled) {\n try {\n const stream = await this.client.getMediaHandler().getScreensharingStream(opts);\n if (!stream) return false;\n\n const track = stream.getTracks().find((track) => track.kind === \"video\");\n\n const sender = this.transceivers.get(\n getTransceiverKey(SDPStreamMetadataPurpose.Usermedia, \"video\"),\n )?.sender;\n\n sender?.replaceTrack(track ?? null);\n\n this.pushNewLocalFeed(stream, SDPStreamMetadataPurpose.Screenshare, false);\n\n return true;\n } catch (err) {\n logger.error(\n `Call ${this.callId} setScreensharingEnabledWithoutMetadataSupport() failed to get screen-sharing stream:`,\n err,\n );\n return false;\n }\n } else {\n const track = this.localUsermediaStream?.getTracks().find((track) => track.kind === \"video\");\n const sender = this.transceivers.get(\n getTransceiverKey(SDPStreamMetadataPurpose.Usermedia, \"video\"),\n )?.sender;\n sender?.replaceTrack(track ?? null);\n\n this.client.getMediaHandler().stopScreensharingStream(this.localScreensharingStream!);\n this.deleteFeedByStream(this.localScreensharingStream!);\n\n return false;\n }\n }\n\n /**\n * Replaces/adds the tracks from the passed stream to the localUsermediaStream\n * @param stream - to use a replacement for the local usermedia stream\n */\n public async updateLocalUsermediaStream(\n stream: MediaStream,\n forceAudio = false,\n forceVideo = false,\n ): Promise<void> {\n const callFeed = this.localUsermediaFeed!;\n const audioEnabled = forceAudio || (!callFeed.isAudioMuted() && !this.remoteOnHold);\n const videoEnabled = forceVideo || (!callFeed.isVideoMuted() && !this.remoteOnHold);\n logger.log(\n `Call ${this.callId} updateLocalUsermediaStream() running (streamId=${stream.id}, audio=${audioEnabled}, video=${videoEnabled})`,\n );\n setTracksEnabled(stream.getAudioTracks(), audioEnabled);\n setTracksEnabled(stream.getVideoTracks(), videoEnabled);\n\n // We want to keep the same stream id, so we replace the tracks rather\n // than the whole stream.\n\n // Firstly, we replace the tracks in our localUsermediaStream.\n for (const track of this.localUsermediaStream!.getTracks()) {\n this.localUsermediaStream!.removeTrack(track);\n track.stop();\n }\n for (const track of stream.getTracks()) {\n this.localUsermediaStream!.addTrack(track);\n }\n\n // Then replace the old tracks, if possible.\n for (const track of stream.getTracks()) {\n const tKey = getTransceiverKey(SDPStreamMetadataPurpose.Usermedia, track.kind);\n\n const transceiver = this.transceivers.get(tKey);\n const oldSender = transceiver?.sender;\n let added = false;\n if (oldSender) {\n try {\n logger.info(\n `Call ${this.callId} updateLocalUsermediaStream() replacing track (id=${track.id}, kind=${track.kind}, streamId=${stream.id}, streamPurpose=${callFeed.purpose})`,\n );\n await oldSender.replaceTrack(track);\n // Set the direction to indicate we're going to be sending.\n // This is only necessary in the cases where we're upgrading\n // the call to video after downgrading it.\n transceiver.direction = transceiver.direction === \"inactive\" ? \"sendonly\" : \"sendrecv\";\n added = true;\n } catch (error) {\n logger.warn(\n `Call ${this.callId} updateLocalUsermediaStream() replaceTrack failed: adding new transceiver instead`,\n error,\n );\n }\n }\n\n if (!added) {\n logger.info(\n `Call ${this.callId} updateLocalUsermediaStream() adding track to peer connection (id=${track.id}, kind=${track.kind}, streamId=${stream.id}, streamPurpose=${callFeed.purpose})`,\n );\n\n const newSender = this.peerConn!.addTrack(track, this.localUsermediaStream!);\n const newTransceiver = this.peerConn!.getTransceivers().find((t) => t.sender === newSender);\n if (newTransceiver) {\n this.transceivers.set(tKey, newTransceiver);\n } else {\n logger.warn(\n `Call ${this.callId} updateLocalUsermediaStream() couldn't find matching transceiver for newly added track!`,\n );\n }\n }\n }\n }\n\n /**\n * Set whether our outbound video should be muted or not.\n * @param muted - True to mute the outbound video.\n * @returns the new mute state\n */\n public async setLocalVideoMuted(muted: boolean): Promise<boolean> {\n logger.log(`Call ${this.callId} setLocalVideoMuted() running ${muted}`);\n\n // if we were still thinking about stopping and removing the video\n // track: don't, because we want it back.\n if (!muted && this.stopVideoTrackTimer !== undefined) {\n clearTimeout(this.stopVideoTrackTimer);\n this.stopVideoTrackTimer = undefined;\n }\n\n if (!(await this.client.getMediaHandler().hasVideoDevice())) {\n return this.isLocalVideoMuted();\n }\n\n if (!this.hasUserMediaVideoSender && !muted) {\n this.localUsermediaFeed?.setAudioVideoMuted(null, muted);\n await this.upgradeCall(false, true);\n return this.isLocalVideoMuted();\n }\n\n // we may not have a video track - if not, re-request usermedia\n if (!muted && this.localUsermediaStream!.getVideoTracks().length === 0) {\n const stream = await this.client.getMediaHandler().getUserMediaStream(true, true);\n await this.updateLocalUsermediaStream(stream);\n }\n\n this.localUsermediaFeed?.setAudioVideoMuted(null, muted);\n\n this.updateMuteStatus();\n await this.sendMetadataUpdate();\n\n // if we're muting video, set a timeout to stop & remove the video track so we release\n // the camera. We wait a short time to do this because when we disable a track, WebRTC\n // will send black video for it. If we just stop and remove it straight away, the video\n // will just freeze which means that when we unmute video, the other side will briefly\n // get a static frame of us from before we muted. This way, the still frame is just black.\n // A very small delay is not always enough so the theory here is that it needs to be long\n // enough for WebRTC to encode a frame: 120ms should be long enough even if we're only\n // doing 10fps.\n if (muted) {\n this.stopVideoTrackTimer = setTimeout(() => {\n for (const t of this.localUsermediaStream!.getVideoTracks()) {\n t.stop();\n this.localUsermediaStream!.removeTrack(t);\n }\n }, 120);\n }\n\n return this.isLocalVideoMuted();\n }\n\n /**\n * Check if local video is muted.\n *\n * If there are multiple video tracks, <i>all</i> of the tracks need to be muted\n * for this to return true. This means if there are no video tracks, this will\n * return true.\n * @returns True if the local preview video is muted, else false\n * (including if the call is not set up yet).\n */\n public isLocalVideoMuted(): boolean {\n return this.localUsermediaFeed?.isVideoMuted() ?? false;\n }\n\n /**\n * Set whether the microphone should be muted or not.\n * @param muted - True to mute the mic.\n * @returns the new mute state\n */\n public async setMicrophoneMuted(muted: boolean): Promise<boolean> {\n logger.log(`Call ${this.callId} setMicrophoneMuted() running ${muted}`);\n if (!(await this.client.getMediaHandler().hasAudioDevice())) {\n return this.isMicrophoneMuted();\n }\n\n if (!muted && (!this.hasUserMediaAudioSender || !this.hasLocalUserMediaAudioTrack)) {\n await this.upgradeCall(true, false);\n return this.isMicrophoneMuted();\n }\n this.localUsermediaFeed?.setAudioVideoMuted(muted, null);\n this.updateMuteStatus();\n await this.sendMetadataUpdate();\n return this.isMicrophoneMuted();\n }\n\n /**\n * Check if the microphone is muted.\n *\n * If there are multiple audio tracks, <i>all</i> of the tracks need to be muted\n * for this to return true. This means if there are no audio tracks, this will\n * return true.\n * @returns True if the mic is muted, else false (including if the call\n * is not set up yet).\n */\n public isMicrophoneMuted(): boolean {\n return this.localUsermediaFeed?.isAudioMuted() ?? false;\n }\n\n /**\n * @returns true if we have put the party on the other side of the call on hold\n * (that is, we are signalling to them that we are not listening)\n */\n public isRemoteOnHold(): boolean {\n return this.remoteOnHold;\n }\n\n public setRemoteOnHold(onHold: boolean): void {\n if (this.isRemoteOnHold() === onHold) return;\n this.remoteOnHold = onHold;\n\n for (const transceiver of this.peerConn!.getTransceivers()) {\n // We don't send hold music or anything so we're not actually\n // sending anything, but sendrecv is fairly standard for hold and\n // it makes it a lot easier to figure out who's put who on hold.\n transceiver.direction = onHold ? \"sendonly\" : \"sendrecv\";\n }\n this.updateMuteStatus();\n this.sendMetadataUpdate();\n\n this.emit(CallEvent.RemoteHoldUnhold, this.remoteOnHold, this);\n }\n\n /**\n * Indicates whether we are 'on hold' to the remote party (ie. if true,\n * they cannot hear us).\n * @returns true if the other party has put us on hold\n */\n public isLocalOnHold(): boolean {\n if (this.state !== CallState.Connected) return false;\n\n let callOnHold = true;\n\n // We consider a call to be on hold only if *all* the tracks are on hold\n // (is this the right thing to do?)\n for (const transceiver of this.peerConn!.getTransceivers()) {\n const trackOnHold = [\"inactive\", \"recvonly\"].includes(transceiver.currentDirection!);\n\n if (!trackOnHold) callOnHold = false;\n }\n\n return callOnHold;\n }\n\n /**\n * Sends a DTMF digit to the other party\n * @param digit - The digit (nb. string - '#' and '*' are dtmf too)\n */\n public sendDtmfDigit(digit: string): void {\n for (const sender of this.peerConn!.getSenders()) {\n if (sender.track?.kind === \"audio\" && sender.dtmf) {\n sender.dtmf.insertDTMF(digit);\n return;\n }\n }\n\n throw new Error(\"Unable to find a track to send DTMF on\");\n }\n\n private updateMuteStatus(): void {\n const micShouldBeMuted = this.isMicrophoneMuted() || this.remoteOnHold;\n const vidShouldBeMuted = this.isLocalVideoMuted() || this.remoteOnHold;\n\n logger.log(\n `Call ${this.callId} updateMuteStatus stream ${\n this.localUsermediaStream!.id\n } micShouldBeMuted ${micShouldBeMuted} vidShouldBeMuted ${vidShouldBeMuted}`,\n );\n\n setTracksEnabled(this.localUsermediaStream!.getAudioTracks(), !micShouldBeMuted);\n setTracksEnabled(this.localUsermediaStream!.getVideoTracks(), !vidShouldBeMuted);\n }\n\n public async sendMetadataUpdate(): Promise<void> {\n await this.sendVoipEvent(EventType.CallSDPStreamMetadataChangedPrefix, {\n [SDPStreamMetadataKey]: this.getLocalSDPStreamMetadata(),\n });\n }\n\n private gotCallFeedsForInvite(callFeeds: CallFeed[], requestScreenshareFeed = false): void {\n if (this.successor) {\n this.successor.queueGotCallFeedsForAnswer(callFeeds);\n return;\n }\n if (this.callHasEnded()) {\n this.stopAllMedia();\n return;\n }\n\n for (const feed of callFeeds) {\n this.pushLocalFeed(feed);\n }\n\n if (requestScreenshareFeed) {\n this.peerConn!.addTransceiver(\"video\", {\n direction: \"recvonly\",\n });\n }\n\n this.state = CallState.CreateOffer;\n\n logger.debug(`Call ${this.callId} gotUserMediaForInvite() run`);\n // Now we wait for the negotiationneeded event\n }\n\n private async sendAnswer(): Promise<void> {\n const answerContent = {\n answer: {\n sdp: this.peerConn!.localDescription!.sdp,\n // type is now deprecated as of Matrix VoIP v1, but\n // required to still be sent for backwards compat\n type: this.peerConn!.localDescription!.type,\n },\n [SDPStreamMetadataKey]: this.getLocalSDPStreamMetadata(true),\n } as MCallAnswer;\n\n answerContent.capabilities = {\n \"m.call.transferee\": this.client.supportsCallTransfer,\n \"m.call.dtmf\": false,\n };\n\n // We have just taken the local description from the peerConn which will\n // contain all the local candidates added so far, so we can discard any candidates\n // we had queued up because they'll be in the answer.\n const discardCount = this.discardDuplicateCandidates();\n logger.info(\n `Call ${this.callId} sendAnswer() discarding ${discardCount} candidates that will be sent in answer`,\n );\n\n try {\n await this.sendVoipEvent(EventType.CallAnswer, answerContent);\n // If this isn't the first time we've tried to send the answer,\n // we may have candidates queued up, so send them now.\n this.inviteOrAnswerSent = true;\n } catch (error) {\n // We've failed to answer: back to the ringing state\n this.state = CallState.Ringing;\n if (error instanceof MatrixError && error.event) this.client.cancelPendingEvent(error.event);\n\n let code = CallErrorCode.SendAnswer;\n let message = \"Failed to send answer\";\n if ((<Error>error).name == \"UnknownDeviceError\") {\n code = CallErrorCode.UnknownDevices;\n message = \"Unknown devices present in the room\";\n }\n this.emit(CallEvent.Error, new CallError(code, message, <Error>error), this);\n throw error;\n }\n\n // error handler re-throws so this won't happen on error, but\n // we don't want the same error handling on the candidate queue\n this.sendCandidateQueue();\n }\n\n private queueGotCallFeedsForAnswer(callFeeds: CallFeed[]): void {\n // Ensure only one negotiate/answer event is being processed at a time.\n if (this.responsePromiseChain) {\n this.responsePromiseChain = this.responsePromiseChain.then(() => this.gotCallFeedsForAnswer(callFeeds));\n } else {\n this.responsePromiseChain = this.gotCallFeedsForAnswer(callFeeds);\n }\n }\n\n // Enables DTX (discontinuous transmission) on the given session to reduce\n // bandwidth when transmitting silence\n private mungeSdp(description: RTCSessionDescriptionInit, mods: CodecParamsMod[]): void {\n // The only way to enable DTX at this time is through SDP munging\n const sdp = parseSdp(description.sdp!);\n\n sdp.media.forEach((media) => {\n const payloadTypeToCodecMap = new Map<number, string>();\n const codecToPayloadTypeMap = new Map<string, number>();\n for (const rtp of media.rtp) {\n payloadTypeToCodecMap.set(rtp.payload, rtp.codec);\n codecToPayloadTypeMap.set(rtp.codec, rtp.payload);\n }\n\n for (const mod of mods) {\n if (mod.mediaType !== media.type) continue;\n\n if (!codecToPayloadTypeMap.has(mod.codec)) {\n logger.info(\n `Call ${this.callId} mungeSdp() ignoring SDP modifications for ${mod.codec} as it's not present.`,\n );\n continue;\n }\n\n const extraConfig: string[] = [];\n if (mod.enableDtx !== undefined) {\n extraConfig.push(`usedtx=${mod.enableDtx ? \"1\" : \"0\"}`);\n }\n if (mod.maxAverageBitrate !== undefined) {\n extraConfig.push(`maxaveragebitrate=${mod.maxAverageBitrate}`);\n }\n\n let found = false;\n for (const fmtp of media.fmtp) {\n if (payloadTypeToCodecMap.get(fmtp.payload) === mod.codec) {\n found = true;\n fmtp.config += \";\" + extraConfig.join(\";\");\n }\n }\n if (!found) {\n media.fmtp.push({\n payload: codecToPayloadTypeMap.get(mod.codec)!,\n config: extraConfig.join(\";\"),\n });\n }\n }\n });\n description.sdp = writeSdp(sdp);\n }\n\n private async createOffer(): Promise<RTCSessionDescriptionInit> {\n const offer = await this.peerConn!.createOffer();\n this.mungeSdp(offer, getCodecParamMods(this.isPtt));\n return offer;\n }\n\n private async createAnswer(): Promise<RTCSessionDescriptionInit> {\n const answer = await this.peerConn!.createAnswer();\n this.mungeSdp(answer, getCodecParamMods(this.isPtt));\n return answer;\n }\n\n private async gotCallFeedsForAnswer(callFeeds: CallFeed[]): Promise<void> {\n if (this.callHasEnded()) return;\n\n this.waitForLocalAVStream = false;\n\n for (const feed of callFeeds) {\n this.pushLocalFeed(feed);\n }\n\n this.state = CallState.CreateAnswer;\n\n let answer: RTCSessionDescriptionInit;\n try {\n this.getRidOfRTXCodecs();\n answer = await this.createAnswer();\n } catch (err) {\n logger.debug(`Call ${this.callId} gotCallFeedsForAnswer() failed to create answer: `, err);\n this.terminate(CallParty.Local, CallErrorCode.CreateAnswer, true);\n return;\n }\n\n try {\n await this.peerConn!.setLocalDescription(answer);\n\n // make sure we're still going\n if (this.callHasEnded()) return;\n\n this.state = CallState.Connecting;\n\n // Allow a short time for initial candidates to be gathered\n await new Promise((resolve) => {\n setTimeout(resolve, 200);\n });\n\n // make sure the call hasn't ended before we continue\n if (this.callHasEnded()) return;\n\n this.sendAnswer();\n } catch (err) {\n logger.debug(`Call ${this.callId} gotCallFeedsForAnswer() error setting local description!`, err);\n this.terminate(CallParty.Local, CallErrorCode.SetLocalDescription, true);\n return;\n }\n }\n\n /**\n * Internal\n */\n private gotLocalIceCandidate = (event: RTCPeerConnectionIceEvent): void => {\n if (event.candidate) {\n if (this.candidatesEnded) {\n logger.warn(`Call ${this.callId} gotLocalIceCandidate() got candidate after candidates have ended!`);\n }\n\n logger.debug(`Call ${this.callId} got local ICE ${event.candidate.sdpMid} ${event.candidate.candidate}`);\n\n if (this.callHasEnded()) return;\n\n // As with the offer, note we need to make a copy of this object, not\n // pass the original: that broke in Chrome ~m43.\n if (event.candidate.candidate === \"\") {\n this.queueCandidate(null);\n } else {\n this.queueCandidate(event.candidate);\n }\n }\n };\n\n private onIceGatheringStateChange = (event: Event): void => {\n logger.debug(\n `Call ${this.callId} onIceGatheringStateChange() ice gathering state changed to ${\n this.peerConn!.iceGatheringState\n }`,\n );\n if (this.peerConn?.iceGatheringState === \"complete\") {\n this.queueCandidate(null); // We should leave it to WebRTC to announce the end\n logger.debug(\n `Call ${this.callId} onIceGatheringStateChange() ice gathering state complete, set candidates have ended`,\n );\n }\n };\n\n public async onRemoteIceCandidatesReceived(ev: MatrixEvent): Promise<void> {\n if (this.callHasEnded()) {\n //debuglog(\"Ignoring remote ICE candidate because call has ended\");\n return;\n }\n\n const content = ev.getContent<MCallCandidates>();\n const candidates = content.candidates;\n if (!candidates) {\n logger.info(\n `Call ${this.callId} onRemoteIceCandidatesReceived() ignoring candidates event with no candidates!`,\n );\n return;\n }\n\n const fromPartyId = content.version === 0 ? null : content.party_id || null;\n\n if (this.opponentPartyId === undefined) {\n // we haven't picked an opponent yet so save the candidates\n if (fromPartyId) {\n logger.info(\n `Call ${this.callId} onRemoteIceCandidatesReceived() buffering ${candidates.length} candidates until we pick an opponent`,\n );\n const bufferedCandidates = this.remoteCandidateBuffer.get(fromPartyId) || [];\n bufferedCandidates.push(...candidates);\n this.remoteCandidateBuffer.set(fromPartyId, bufferedCandidates);\n }\n return;\n }\n\n if (!this.partyIdMatches(content)) {\n logger.info(\n `Call ${this.callId} onRemoteIceCandidatesReceived() ignoring candidates from party ID ${content.party_id}: we have chosen party ID ${this.opponentPartyId}`,\n );\n\n return;\n }\n\n await this.addIceCandidates(candidates);\n }\n\n /**\n * Used by MatrixClient.\n */\n public async onAnswerReceived(event: MatrixEvent): Promise<void> {\n const content = event.getContent<MCallAnswer>();\n logger.debug(`Call ${this.callId} onAnswerReceived() running (hangupParty=${content.party_id})`);\n\n if (this.callHasEnded()) {\n logger.debug(`Call ${this.callId} onAnswerReceived() ignoring answer because call has ended`);\n return;\n }\n\n if (this.opponentPartyId !== undefined) {\n logger.info(\n `Call ${this.callId} onAnswerReceived() ignoring answer from party ID ${content.party_id}: we already have an answer/reject from ${this.opponentPartyId}`,\n );\n return;\n }\n\n this.chooseOpponent(event);\n await this.addBufferedIceCandidates();\n\n this.state = CallState.Connecting;\n\n const sdpStreamMetadata = content[SDPStreamMetadataKey];\n if (sdpStreamMetadata) {\n this.updateRemoteSDPStreamMetadata(sdpStreamMetadata);\n } else {\n logger.warn(\n `Call ${this.callId} onAnswerReceived() did not get any SDPStreamMetadata! Can not send/receive multiple streams`,\n );\n }\n\n try {\n this.isSettingRemoteAnswerPending = true;\n await this.peerConn!.setRemoteDescription(content.answer);\n this.isSettingRemoteAnswerPending = false;\n logger.debug(`Call ${this.callId} onAnswerReceived() set remote description: ${content.answer.type}`);\n } catch (e) {\n this.isSettingRemoteAnswerPending = false;\n logger.debug(`Call ${this.callId} onAnswerReceived() failed to set remote description`, e);\n this.terminate(CallParty.Local, CallErrorCode.SetRemoteDescription, false);\n return;\n }\n\n // If the answer we selected has a party_id, send a select_answer event\n // We do this after setting the remote description since otherwise we'd block\n // call setup on it\n if (this.opponentPartyId !== null) {\n try {\n await this.sendVoipEvent(EventType.CallSelectAnswer, {\n selected_party_id: this.opponentPartyId!,\n });\n } catch (err) {\n // This isn't fatal, and will just mean that if another party has raced to answer\n // the call, they won't know they got rejected, so we carry on & don't retry.\n logger.warn(`Call ${this.callId} onAnswerReceived() failed to send select_answer event`, err);\n }\n }\n }\n\n public async onSelectAnswerReceived(event: MatrixEvent): Promise<void> {\n if (this.direction !== CallDirection.Inbound) {\n logger.warn(\n `Call ${this.callId} onSelectAnswerReceived() got select_answer for an outbound call: ignoring`,\n );\n return;\n }\n\n const selectedPartyId = event.getContent<MCallSelectAnswer>().selected_party_id;\n\n if (selectedPartyId === undefined || selectedPartyId === null) {\n logger.warn(\n `Call ${this.callId} onSelectAnswerReceived() got nonsensical select_answer with null/undefined selected_party_id: ignoring`,\n );\n return;\n }\n\n if (selectedPartyId !== this.ourPartyId) {\n logger.info(\n `Call ${this.callId} onSelectAnswerReceived() got select_answer for party ID ${selectedPartyId}: we are party ID ${this.ourPartyId}.`,\n );\n // The other party has picked somebody else's answer\n await this.terminate(CallParty.Remote, CallErrorCode.AnsweredElsewhere, true);\n }\n }\n\n public async onNegotiateReceived(event: MatrixEvent): Promise<void> {\n const content = event.getContent<MCallInviteNegotiate>();\n const description = content.description;\n if (!description || !description.sdp || !description.type) {\n logger.info(`Call ${this.callId} onNegotiateReceived() ignoring invalid m.call.negotiate event`);\n return;\n }\n // Politeness always follows the direction of the call: in a glare situation,\n // we pick either the inbound or outbound call, so one side will always be\n // inbound and one outbound\n const polite = this.direction === CallDirection.Inbound;\n\n // Here we follow the perfect negotiation logic from\n // https://w3c.github.io/webrtc-pc/#perfect-negotiation-example\n const readyForOffer =\n !this.makingOffer && (this.peerConn!.signalingState === \"stable\" || this.isSettingRemoteAnswerPending);\n\n const offerCollision = description.type === \"offer\" && !readyForOffer;\n\n this.ignoreOffer = !polite && offerCollision;\n if (this.ignoreOffer) {\n logger.info(\n `Call ${this.callId} onNegotiateReceived() ignoring colliding negotiate event because we're impolite`,\n );\n return;\n }\n\n const prevLocalOnHold = this.isLocalOnHold();\n\n const sdpStreamMetadata = content[SDPStreamMetadataKey];\n if (sdpStreamMetadata) {\n this.updateRemoteSDPStreamMetadata(sdpStreamMetadata);\n } else {\n logger.warn(\n `Call ${this.callId} onNegotiateReceived() received negotiation event without SDPStreamMetadata!`,\n );\n }\n\n try {\n this.isSettingRemoteAnswerPending = description.type == \"answer\";\n await this.peerConn!.setRemoteDescription(description); // SRD rolls back as needed\n this.isSettingRemoteAnswerPending = false;\n\n logger.debug(`Call ${this.callId} onNegotiateReceived() set remote description: ${description.type}`);\n\n if (description.type === \"offer\") {\n let answer: RTCSessionDescriptionInit;\n try {\n this.getRidOfRTXCodecs();\n answer = await this.createAnswer();\n } catch (err) {\n logger.debug(`Call ${this.callId} onNegotiateReceived() failed to create answer: `, err);\n this.terminate(CallParty.Local, CallErrorCode.CreateAnswer, true);\n return;\n }\n\n await this.peerConn!.setLocalDescription(answer);\n logger.debug(`Call ${this.callId} onNegotiateReceived() create an answer`);\n\n this.sendVoipEvent(EventType.CallNegotiate, {\n lifetime: CALL_TIMEOUT_MS,\n description: this.peerConn!.localDescription?.toJSON() as RTCSessionDescription,\n [SDPStreamMetadataKey]: this.getLocalSDPStreamMetadata(true),\n });\n }\n } catch (err) {\n this.isSettingRemoteAnswerPending = false;\n logger.warn(`Call ${this.callId} onNegotiateReceived() failed to complete negotiation`, err);\n }\n\n const newLocalOnHold = this.isLocalOnHold();\n if (prevLocalOnHold !== newLocalOnHold) {\n this.emit(CallEvent.LocalHoldUnhold, newLocalOnHold, this);\n // also this one for backwards compat\n this.emit(CallEvent.HoldUnhold, newLocalOnHold);\n }\n }\n\n private updateRemoteSDPStreamMetadata(metadata: SDPStreamMetadata): void {\n this.remoteSDPStreamMetadata = recursivelyAssign(this.remoteSDPStreamMetadata || {}, metadata, true);\n for (const feed of this.getRemoteFeeds()) {\n const streamId = feed.stream.id;\n const metadata = this.remoteSDPStreamMetadata![streamId];\n\n feed.setAudioVideoMuted(metadata?.audio_muted, metadata?.video_muted);\n feed.purpose = this.remoteSDPStreamMetadata![streamId]?.purpose;\n }\n }\n\n public onSDPStreamMetadataChangedReceived(event: MatrixEvent): void {\n const content = event.getContent<MCallSDPStreamMetadataChanged>();\n const metadata = content[SDPStreamMetadataKey];\n this.updateRemoteSDPStreamMetadata(metadata);\n }\n\n public async onAssertedIdentityReceived(event: MatrixEvent): Promise<void> {\n const content = event.getContent<MCAllAssertedIdentity>();\n if (!content.asserted_identity) return;\n\n this.remoteAssertedIdentity = {\n id: content.asserted_identity.id,\n displayName: content.asserted_identity.display_name,\n };\n this.emit(CallEvent.AssertedIdentityChanged, this);\n }\n\n public callHasEnded(): boolean {\n // This exists as workaround to typescript trying to be clever and erroring\n // when putting if (this.state === CallState.Ended) return; twice in the same\n // function, even though that function is async.\n return this.state === CallState.Ended;\n }\n\n private queueGotLocalOffer(): void {\n // Ensure only one negotiate/answer event is being processed at a time.\n if (this.responsePromiseChain) {\n this.responsePromiseChain = this.responsePromiseChain.then(() => this.wrappedGotLocalOffer());\n } else {\n this.responsePromiseChain = this.wrappedGotLocalOffer();\n }\n }\n\n private async wrappedGotLocalOffer(): Promise<void> {\n this.makingOffer = true;\n try {\n // XXX: in what situations do we believe gotLocalOffer actually throws? It appears\n // to handle most of its exceptions itself and terminate the call. I'm not entirely\n // sure it would ever throw, so I can't add a test for these lines.\n // Also the tense is different between \"gotLocalOffer\" and \"getLocalOfferFailed\" so\n // it's not entirely clear whether getLocalOfferFailed is just misnamed or whether\n // they've been cross-polinated somehow at some point.\n await this.gotLocalOffer();\n } catch (e) {\n this.getLocalOfferFailed(e as Error);\n return;\n } finally {\n this.makingOffer = false;\n }\n }\n\n private async gotLocalOffer(): Promise<void> {\n logger.debug(`Call ${this.callId} gotLocalOffer() running`);\n\n if (this.callHasEnded()) {\n logger.debug(\n `Call ${this.callId} gotLocalOffer() ignoring newly created offer because the call has ended\"`,\n );\n return;\n }\n\n let offer: RTCSessionDescriptionInit;\n try {\n this.getRidOfRTXCodecs();\n offer = await this.createOffer();\n } catch (err) {\n logger.debug(`Call ${this.callId} gotLocalOffer() failed to create offer: `, err);\n this.terminate(CallParty.Local, CallErrorCode.CreateOffer, true);\n return;\n }\n\n try {\n await this.peerConn!.setLocalDescription(offer);\n } catch (err) {\n logger.debug(`Call ${this.callId} gotLocalOffer() error setting local description!`, err);\n this.terminate(CallParty.Local, CallErrorCode.SetLocalDescription, true);\n return;\n }\n\n if (this.peerConn!.iceGatheringState === \"gathering\") {\n // Allow a short time for initial candidates to be gathered\n await new Promise((resolve) => {\n setTimeout(resolve, 200);\n });\n }\n\n if (this.callHasEnded()) return;\n\n const eventType = this.state === CallState.CreateOffer ? EventType.CallInvite : EventType.CallNegotiate;\n\n const content = {\n lifetime: CALL_TIMEOUT_MS,\n } as MCallInviteNegotiate;\n\n if (eventType === EventType.CallInvite && this.invitee) {\n content.invitee = this.invitee;\n }\n\n // clunky because TypeScript can't follow the types through if we use an expression as the key\n if (this.state === CallState.CreateOffer) {\n content.offer = this.peerConn!.localDescription?.toJSON() as RTCSessionDescription;\n } else {\n content.description = this.peerConn!.localDescription?.toJSON() as RTCSessionDescription;\n }\n\n content.capabilities = {\n \"m.call.transferee\": this.client.supportsCallTransfer,\n \"m.call.dtmf\": false,\n };\n\n content[SDPStreamMetadataKey] = this.getLocalSDPStreamMetadata(true);\n\n // Get rid of any candidates waiting to be sent: they'll be included in the local\n // description we just got and will send in the offer.\n const discardCount = this.discardDuplicateCandidates();\n logger.info(\n `Call ${this.callId} gotLocalOffer() discarding ${discardCount} candidates that will be sent in offer`,\n );\n\n try {\n await this.sendVoipEvent(eventType, content);\n } catch (error) {\n logger.error(`Call ${this.callId} gotLocalOffer() failed to send invite`, error);\n if (error instanceof MatrixError && error.event) this.client.cancelPendingEvent(error.event);\n\n let code = CallErrorCode.SignallingFailed;\n let message = \"Signalling failed\";\n if (this.state === CallState.CreateOffer) {\n code = CallErrorCode.SendInvite;\n message = \"Failed to send invite\";\n }\n if ((<Error>error).name == \"UnknownDeviceError\") {\n code = CallErrorCode.UnknownDevices;\n message = \"Unknown devices present in the room\";\n }\n\n this.emit(CallEvent.Error, new CallError(code, message, <Error>error), this);\n this.terminate(CallParty.Local, code, false);\n\n // no need to carry on & send the candidate queue, but we also\n // don't want to rethrow the error\n return;\n }\n\n this.sendCandidateQueue();\n if (this.state === CallState.CreateOffer) {\n this.inviteOrAnswerSent = true;\n this.state = CallState.InviteSent;\n this.inviteTimeout = setTimeout(() => {\n this.inviteTimeout = undefined;\n if (this.state === CallState.InviteSent) {\n this.hangup(CallErrorCode.InviteTimeout, false);\n }\n }, CALL_TIMEOUT_MS);\n }\n }\n\n private getLocalOfferFailed = (err: Error): void => {\n logger.error(`Call ${this.callId} getLocalOfferFailed() running`, err);\n\n this.emit(\n CallEvent.Error,\n new CallError(CallErrorCode.LocalOfferFailed, \"Failed to get local offer!\", err),\n this,\n );\n this.terminate(CallParty.Local, CallErrorCode.LocalOfferFailed, false);\n };\n\n private getUserMediaFailed = (err: Error): void => {\n if (this.successor) {\n this.successor.getUserMediaFailed(err);\n return;\n }\n\n logger.warn(`Call ${this.callId} getUserMediaFailed() failed to get user media - ending call`, err);\n\n this.emit(\n CallEvent.Error,\n new CallError(\n CallErrorCode.NoUserMedia,\n \"Couldn't start capturing media! Is your microphone set up and does this app have permission?\",\n err,\n ),\n this,\n );\n this.terminate(CallParty.Local, CallErrorCode.NoUserMedia, false);\n };\n\n private placeCallFailed = (err: Error): void => {\n if (this.successor) {\n this.successor.placeCallFailed(err);\n return;\n }\n\n logger.warn(`Call ${this.callId} placeCallWithCallFeeds() failed - ending call`, err);\n\n this.emit(\n CallEvent.Error,\n new CallError(CallErrorCode.IceFailed, \"Couldn't start call! Invalid ICE server configuration.\", err),\n this,\n );\n this.terminate(CallParty.Local, CallErrorCode.IceFailed, false);\n };\n\n private onIceConnectionStateChanged = (): void => {\n if (this.callHasEnded()) {\n return; // because ICE can still complete as we're ending the call\n }\n logger.debug(\n `Call ${this.callId} onIceConnectionStateChanged() running (state=${this.peerConn?.iceConnectionState}, conn=${this.peerConn?.connectionState})`,\n );\n\n // ideally we'd consider the call to be connected when we get media but\n // chrome doesn't implement any of the 'onstarted' events yet\n if ([\"connected\", \"completed\"].includes(this.peerConn?.iceConnectionState ?? \"\")) {\n clearTimeout(this.iceDisconnectedTimeout);\n this.iceDisconnectedTimeout = undefined;\n if (this.iceReconnectionTimeOut) {\n clearTimeout(this.iceReconnectionTimeOut);\n }\n this.state = CallState.Connected;\n\n if (!this.callLengthInterval && !this.callStartTime) {\n this.callStartTime = Date.now();\n\n this.callLengthInterval = setInterval(() => {\n this.emit(CallEvent.LengthChanged, Math.round((Date.now() - this.callStartTime!) / 1000), this);\n }, CALL_LENGTH_INTERVAL);\n }\n } else if (this.peerConn?.iceConnectionState == \"failed\") {\n this.candidatesEnded = false;\n // Firefox for Android does not yet have support for restartIce()\n // (the types say it's always defined though, so we have to cast\n // to prevent typescript from warning).\n if (this.peerConn?.restartIce as (() => void) | null) {\n this.candidatesEnded = false;\n logger.debug(\n `Call ${this.callId} onIceConnectionStateChanged() ice restart (state=${this.peerConn?.iceConnectionState})`,\n );\n this.peerConn!.restartIce();\n } else {\n logger.info(\n `Call ${this.callId} onIceConnectionStateChanged() hanging up call (ICE failed and no ICE restart method)`,\n );\n this.hangup(CallErrorCode.IceFailed, false);\n }\n } else if (this.peerConn?.iceConnectionState == \"disconnected\") {\n this.candidatesEnded = false;\n this.iceReconnectionTimeOut = setTimeout((): void => {\n logger.info(\n `Call ${this.callId} onIceConnectionStateChanged() ICE restarting because of ICE disconnected, (state=${this.peerConn?.iceConnectionState}, conn=${this.peerConn?.connectionState})`,\n );\n if (this.peerConn?.restartIce as (() => void) | null) {\n this.candidatesEnded = false;\n this.peerConn!.restartIce();\n }\n this.iceReconnectionTimeOut = undefined;\n }, ICE_RECONNECTING_TIMEOUT);\n\n this.iceDisconnectedTimeout = setTimeout((): void => {\n logger.info(\n `Call ${this.callId} onIceConnectionStateChanged() hanging up call (ICE disconnected for too long)`,\n );\n this.hangup(CallErrorCode.IceFailed, false);\n }, ICE_DISCONNECTED_TIMEOUT);\n this.state = CallState.Connecting;\n }\n\n // In PTT mode, override feed status to muted when we lose connection to\n // the peer, since we don't want to block the line if they're not saying anything.\n // Experimenting in Chrome, this happens after 5 or 6 seconds, which is probably\n // fast enough.\n if (this.isPtt && [\"failed\", \"disconnected\"].includes(this.peerConn!.iceConnectionState)) {\n for (const feed of this.getRemoteFeeds()) {\n feed.setAudioVideoMuted(true, true);\n }\n }\n };\n\n private onSignallingStateChanged = (): void => {\n logger.debug(`Call ${this.callId} onSignallingStateChanged() running (state=${this.peerConn?.signalingState})`);\n };\n\n private onTrack = (ev: RTCTrackEvent): void => {\n if (ev.streams.length === 0) {\n logger.warn(\n `Call ${this.callId} onTrack() called with streamless track streamless (kind=${ev.track.kind})`,\n );\n return;\n }\n\n const stream = ev.streams[0];\n this.pushRemoteFeed(stream);\n\n if (!this.removeTrackListeners.has(stream)) {\n const onRemoveTrack = (): void => {\n if (stream.getTracks().length === 0) {\n logger.info(`Call ${this.callId} onTrack() removing track (streamId=${stream.id})`);\n this.deleteFeedByStream(stream);\n stream.removeEventListener(\"removetrack\", onRemoveTrack);\n this.removeTrackListeners.delete(stream);\n }\n };\n stream.addEventListener(\"removetrack\", onRemoveTrack);\n this.removeTrackListeners.set(stream, onRemoveTrack);\n }\n };\n\n private onDataChannel = (ev: RTCDataChannelEvent): void => {\n this.emit(CallEvent.DataChannel, ev.channel, this);\n };\n\n /**\n * This method removes all video/rtx codecs from screensharing video\n * transceivers. This is necessary since they can cause problems. Without\n * this the following steps should produce an error:\n * Chromium calls Firefox\n * Firefox answers\n * Firefox starts screen-sharing\n * Chromium starts screen-sharing\n * Call crashes for Chromium with:\n * [96685:23:0518/162603.933321:ERROR:webrtc_video_engine.cc(3296)] RTX codec (PT=97) mapped to PT=96 which is not in the codec list.\n * [96685:23:0518/162603.933377:ERROR:webrtc_video_engine.cc(1171)] GetChangedRecvParameters called without any video codecs.\n * [96685:23:0518/162603.933430:ERROR:sdp_offer_answer.cc(4302)] Failed to set local video description recv parameters for m-section with mid='2'. (INVALID_PARAMETER)\n */\n private getRidOfRTXCodecs(): void {\n // RTCRtpReceiver.getCapabilities and RTCRtpSender.getCapabilities don't seem to be supported on FF before v113\n if (!RTCRtpReceiver.getCapabilities || !RTCRtpSender.getCapabilities) return;\n\n const screenshareVideoTransceiver = this.transceivers.get(\n getTransceiverKey(SDPStreamMetadataPurpose.Screenshare, \"video\"),\n );\n\n // setCodecPreferences isn't supported on FF (as of v113)\n if (!screenshareVideoTransceiver || !screenshareVideoTransceiver.setCodecPreferences) return;\n\n const recvCodecs = RTCRtpReceiver.getCapabilities(\"video\")!.codecs;\n const sendCodecs = RTCRtpSender.getCapabilities(\"video\")!.codecs;\n const codecs = [];\n\n for (const codec of [...recvCodecs, ...sendCodecs]) {\n if (codec.mimeType !== \"video/rtx\") {\n codecs.push(codec);\n try {\n screenshareVideoTransceiver.setCodecPreferences(codecs);\n } catch (e) {\n // Specifically, Chrome around version 125 and Electron 30 (which is Chromium 124) return an H.264 codec in\n // the sender's capabilities but throw when you try to set it. Hence... this mess.\n // Specifically, that codec is:\n // {\n // clockRate: 90000,\n // mimeType: \"video/H264\",\n // sdpFmtpLine: \"level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640034\",\n // }\n logger.info(\n \"Working around buggy WebRTC impl: claimed to support codec but threw when setting codec preferences\",\n codec,\n e,\n );\n codecs.pop();\n }\n }\n }\n }\n\n private onNegotiationNeeded = async (): Promise<void> => {\n logger.info(`Call ${this.callId} onNegotiationNeeded() negotiation is needed!`);\n\n if (this.state !== CallState.CreateOffer && this.opponentVersion === 0) {\n logger.info(\n `Call ${this.callId} onNegotiationNeeded() opponent does not support renegotiation: ignoring negotiationneeded event`,\n );\n return;\n }\n\n this.queueGotLocalOffer();\n };\n\n public onHangupReceived = (msg: MCallHangupReject): void => {\n logger.debug(`Call ${this.callId} onHangupReceived() running`);\n\n // party ID must match (our chosen partner hanging up the call) or be undefined (we haven't chosen\n // a partner yet but we're treating the hangup as a reject as per VoIP v0)\n if (this.partyIdMatches(msg) || this.state === CallState.Ringing) {\n // default reason is user_hangup\n this.terminate(CallParty.Remote, msg.reason || CallErrorCode.UserHangup, true);\n } else {\n logger.info(\n `Call ${this.callId} onHangupReceived() ignoring message from party ID ${msg.party_id}: our partner is ${this.opponentPartyId}`,\n );\n }\n };\n\n public onRejectReceived = (msg: MCallHangupReject): void => {\n logger.debug(`Call ${this.callId} onRejectReceived() running`);\n\n // No need to check party_id for reject because if we'd received either\n // an answer or reject, we wouldn't be in state InviteSent\n\n const shouldTerminate =\n // reject events also end the call if it's ringing: it's another of\n // our devices rejecting the call.\n [CallState.InviteSent, CallState.Ringing].includes(this.state) ||\n // also if we're in the init state and it's an inbound call, since\n // this means we just haven't entered the ringing state yet\n (this.state === CallState.Fledgling && this.direction === CallDirection.Inbound);\n\n if (shouldTerminate) {\n this.terminate(CallParty.Remote, msg.reason || CallErrorCode.UserHangup, true);\n } else {\n logger.debug(`Call ${this.callId} onRejectReceived() called in wrong state (state=${this.state})`);\n }\n };\n\n public onAnsweredElsewhere = (msg: MCallAnswer): void => {\n logger.debug(`Call ${this.callId} onAnsweredElsewhere() running`);\n this.terminate(CallParty.Remote, CallErrorCode.AnsweredElsewhere, true);\n };\n\n /**\n * @internal\n */\n private async sendVoipEvent<K extends keyof Pick<TimelineEvents, CallEventType>>(\n eventType: K,\n content: Omit<TimelineEvents[K], \"version\" | \"call_id\" | \"party_id\" | \"conf_id\">,\n ): Promise<void> {\n const realContent = {\n ...content,\n version: VOIP_PROTO_VERSION,\n call_id: this.callId,\n party_id: this.ourPartyId,\n conf_id: this.groupCallId,\n } as TimelineEvents[K];\n\n if (this.opponentDeviceId) {\n const toDeviceSeq = this.toDeviceSeq++;\n const content = {\n ...realContent,\n device_id: this.client.deviceId,\n sender_session_id: this.client.getSessionId(),\n dest_session_id: this.opponentSessionId,\n seq: toDeviceSeq,\n [ToDeviceMessageId]: uuidv4(),\n };\n\n this.emit(\n CallEvent.SendVoipEvent,\n {\n type: \"toDevice\",\n eventType,\n userId: this.invitee || this.getOpponentMember()?.userId,\n opponentDeviceId: this.opponentDeviceId,\n content,\n },\n this,\n );\n\n const userId = this.invitee || this.getOpponentMember()!.userId;\n if (this.client.getUseE2eForGroupCall()) {\n if (!this.opponentDeviceInfo) {\n logger.warn(`Call ${this.callId} sendVoipEvent() failed: we do not have opponentDeviceInfo`);\n return;\n }\n\n await this.client.encryptAndSendToDevices(\n [\n {\n userId,\n deviceInfo: this.opponentDeviceInfo,\n },\n ],\n {\n type: eventType,\n content,\n },\n );\n } else {\n await this.client.sendToDevice(\n eventType,\n new Map<string, any>([[userId, new Map([[this.opponentDeviceId, content]])]]),\n );\n }\n } else {\n this.emit(\n CallEvent.SendVoipEvent,\n {\n type: \"sendEvent\",\n eventType,\n roomId: this.roomId,\n content: realContent,\n userId: this.invitee || this.getOpponentMember()?.userId,\n },\n this,\n );\n\n await this.client.sendEvent(this.roomId!, eventType, realContent);\n }\n }\n\n /**\n * Queue a candidate to be sent\n * @param content - The candidate to queue up, or null if candidates have finished being generated\n * and end-of-candidates should be signalled\n */\n private queueCandidate(content: RTCIceCandidate | null): void {\n // We partially de-trickle candidates by waiting for `delay` before sending them\n // amalgamated, in order to avoid sending too many m.call.candidates events and hitting\n // rate limits in Matrix.\n // In practice, it'd be better to remove rate limits for m.call.*\n\n // N.B. this deliberately lets you queue and send blank candidates, which MSC2746\n // currently proposes as the way to indicate that candidate gathering is complete.\n // This will hopefully be changed to an explicit rather than implicit notification\n // shortly.\n if (content) {\n this.candidateSendQueue.push(content);\n } else {\n this.candidatesEnded = true;\n }\n\n // Don't send the ICE candidates yet if the call is in the ringing state: this\n // means we tried to pick (ie. started generating candidates) and then failed to\n // send the answer and went back to the ringing state. Queue up the candidates\n // to send if we successfully send the answer.\n // Equally don't send if we haven't yet sent the answer because we can send the\n // first batch of candidates along with the answer\n if (this.state === CallState.Ringing || !this.inviteOrAnswerSent) return;\n\n // MSC2746 recommends these values (can be quite long when calling because the\n // callee will need a while to answer the call)\n const delay = this.direction === CallDirection.Inbound ? 500 : 2000;\n\n if (this.candidateSendTries === 0) {\n setTimeout(() => {\n this.sendCandidateQueue();\n }, delay);\n }\n }\n\n // Discard all non-end-of-candidates messages\n // Return the number of candidate messages that were discarded.\n // Call this method before sending an invite or answer message\n private discardDuplicateCandidates(): number {\n let discardCount = 0;\n const newQueue: RTCIceCandidate[] = [];\n\n for (let i = 0; i < this.candidateSendQueue.length; i++) {\n const candidate = this.candidateSendQueue[i];\n if (candidate.candidate === \"\") {\n newQueue.push(candidate);\n } else {\n discardCount++;\n }\n }\n\n this.candidateSendQueue = newQueue;\n\n return discardCount;\n }\n\n /*\n * Transfers this call to another user\n */\n public async transfer(targetUserId: string): Promise<void> {\n // Fetch the target user's global profile info: their room avatar / displayname\n // could be different in whatever room we share with them.\n const profileInfo = await this.client.getProfileInfo(targetUserId);\n\n const replacementId = genCallID();\n\n const body = {\n replacement_id: genCallID(),\n target_user: {\n id: targetUserId,\n display_name: profileInfo.displayname,\n avatar_url: profileInfo.avatar_url,\n },\n create_call: replacementId,\n } as MCallReplacesEvent;\n\n await this.sendVoipEvent(EventType.CallReplaces, body);\n\n await this.terminate(CallParty.Local, CallErrorCode.Transferred, true);\n }\n\n /*\n * Transfers this call to the target call, effectively 'joining' the\n * two calls (so the remote parties on each call are connected together).\n */\n public async transferToCall(transferTargetCall: MatrixCall): Promise<void> {\n const targetUserId = transferTargetCall.getOpponentMember()?.userId;\n const targetProfileInfo = targetUserId ? await this.client.getProfileInfo(targetUserId) : undefined;\n const opponentUserId = this.getOpponentMember()?.userId;\n const transfereeProfileInfo = opponentUserId ? await this.client.getProfileInfo(opponentUserId) : undefined;\n\n const newCallId = genCallID();\n\n const bodyToTransferTarget = {\n // the replacements on each side have their own ID, and it's distinct from the\n // ID of the new call (but we can use the same function to generate it)\n replacement_id: genCallID(),\n target_user: {\n id: opponentUserId,\n display_name: transfereeProfileInfo?.displayname,\n avatar_url: transfereeProfileInfo?.avatar_url,\n },\n await_call: newCallId,\n } as MCallReplacesEvent;\n\n await transferTargetCall.sendVoipEvent(EventType.CallReplaces, bodyToTransferTarget);\n\n const bodyToTransferee = {\n replacement_id: genCallID(),\n target_user: {\n id: targetUserId,\n display_name: targetProfileInfo?.displayname,\n avatar_url: targetProfileInfo?.avatar_url,\n },\n create_call: newCallId,\n } as MCallReplacesEvent;\n\n await this.sendVoipEvent(EventType.CallReplaces, bodyToTransferee);\n\n await this.terminate(CallParty.Local, CallErrorCode.Transferred, true);\n await transferTargetCall.terminate(CallParty.Local, CallErrorCode.Transferred, true);\n }\n\n private async terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean): Promise<void> {\n if (this.callHasEnded()) return;\n\n this.hangupParty = hangupParty;\n this.hangupReason = hangupReason;\n this.state = CallState.Ended;\n\n if (this.inviteTimeout) {\n clearTimeout(this.inviteTimeout);\n this.inviteTimeout = undefined;\n }\n if (this.iceDisconnectedTimeout !== undefined) {\n clearTimeout(this.iceDisconnectedTimeout);\n this.iceDisconnectedTimeout = undefined;\n }\n if (this.callLengthInterval) {\n clearInterval(this.callLengthInterval);\n this.callLengthInterval = undefined;\n }\n if (this.stopVideoTrackTimer !== undefined) {\n clearTimeout(this.stopVideoTrackTimer);\n this.stopVideoTrackTimer = undefined;\n }\n\n for (const [stream, listener] of this.removeTrackListeners) {\n stream.removeEventListener(\"removetrack\", listener);\n }\n this.removeTrackListeners.clear();\n\n this.callStatsAtEnd = await this.collectCallStats();\n\n // Order is important here: first we stopAllMedia() and only then we can deleteAllFeeds()\n this.stopAllMedia();\n this.deleteAllFeeds();\n\n if (this.peerConn && this.peerConn.signalingState !== \"closed\") {\n this.peerConn.close();\n }\n this.stats?.removeStatsReportGatherer(this.callId);\n\n if (shouldEmit) {\n this.emit(CallEvent.Hangup, this);\n }\n\n this.client.callEventHandler!.calls.delete(this.callId);\n }\n\n private stopAllMedia(): void {\n logger.debug(`Call ${this.callId} stopAllMedia() running`);\n\n for (const feed of this.feeds) {\n // Slightly awkward as local feed need to go via the correct method on\n // the MediaHandler so they get removed from MediaHandler (remote tracks\n // don't)\n // NB. We clone local streams when passing them to individual calls in a group\n // call, so we can (and should) stop the clones once we no longer need them:\n // the other clones will continue fine.\n if (feed.isLocal() && feed.purpose === SDPStreamMetadataPurpose.Usermedia) {\n this.client.getMediaHandler().stopUserMediaStream(feed.stream);\n } else if (feed.isLocal() && feed.purpose === SDPStreamMetadataPurpose.Screenshare) {\n this.client.getMediaHandler().stopScreensharingStream(feed.stream);\n } else if (!feed.isLocal()) {\n logger.debug(`Call ${this.callId} stopAllMedia() stopping stream (streamId=${feed.stream.id})`);\n for (const track of feed.stream.getTracks()) {\n track.stop();\n }\n }\n }\n }\n\n private checkForErrorListener(): void {\n if (this.listeners(EventEmitterEvents.Error).length === 0) {\n throw new Error(\"You MUST attach an error listener using call.on('error', function() {})\");\n }\n }\n\n private async sendCandidateQueue(): Promise<void> {\n if (this.candidateSendQueue.length === 0 || this.callHasEnded()) {\n return;\n }\n\n const candidates = this.candidateSendQueue;\n this.candidateSendQueue = [];\n ++this.candidateSendTries;\n const content: Pick<MCallCandidates, \"candidates\"> = {\n candidates: candidates.map((candidate) => candidate.toJSON()),\n };\n if (this.candidatesEnded) {\n // If there are no more candidates, signal this by adding an empty string candidate\n content.candidates.push({\n candidate: \"\",\n });\n }\n logger.debug(`Call ${this.callId} sendCandidateQueue() attempting to send ${candidates.length} candidates`);\n try {\n await this.sendVoipEvent(EventType.CallCandidates, content);\n // reset our retry count if we have successfully sent our candidates\n // otherwise queueCandidate() will refuse to try to flush the queue\n this.candidateSendTries = 0;\n\n // Try to send candidates again just in case we received more candidates while sending.\n this.sendCandidateQueue();\n } catch (error) {\n // don't retry this event: we'll send another one later as we might\n // have more candidates by then.\n if (error instanceof MatrixError && error.event) this.client.cancelPendingEvent(error.event);\n\n // put all the candidates we failed to send back in the queue\n this.candidateSendQueue.push(...candidates);\n\n if (this.candidateSendTries > 5) {\n logger.debug(\n `Call ${this.callId} sendCandidateQueue() failed to send candidates on attempt ${this.candidateSendTries}. Giving up on this call.`,\n error,\n );\n\n const code = CallErrorCode.SignallingFailed;\n const message = \"Signalling failed\";\n\n this.emit(CallEvent.Error, new CallError(code, message, <Error>error), this);\n this.hangup(code, false);\n\n return;\n }\n\n const delayMs = 500 * Math.pow(2, this.candidateSendTries);\n ++this.candidateSendTries;\n logger.debug(\n `Call ${this.callId} sendCandidateQueue() failed to send candidates. Retrying in ${delayMs}ms`,\n error,\n );\n setTimeout(() => {\n this.sendCandidateQueue();\n }, delayMs);\n }\n }\n\n /**\n * Place a call to this room.\n * @throws if you have not specified a listener for 'error' events.\n * @throws if have passed audio=false.\n */\n public async placeCall(audio: boolean, video: boolean): Promise<void> {\n if (!audio) {\n throw new Error(\"You CANNOT start a call without audio\");\n }\n this.state = CallState.WaitLocalMedia;\n\n let callFeed: CallFeed;\n try {\n const stream = await this.client.getMediaHandler().getUserMediaStream(audio, video);\n\n // make sure all the tracks are enabled (same as pushNewLocalFeed -\n // we probably ought to just have one code path for adding streams)\n setTracksEnabled(stream.getAudioTracks(), true);\n setTracksEnabled(stream.getVideoTracks(), true);\n\n callFeed = new CallFeed({\n client: this.client,\n roomId: this.roomId,\n userId: this.client.getUserId()!,\n deviceId: this.client.getDeviceId() ?? undefined,\n stream,\n purpose: SDPStreamMetadataPurpose.Usermedia,\n audioMuted: false,\n videoMuted: false,\n });\n } catch (e) {\n this.getUserMediaFailed(<Error>e);\n return;\n }\n\n try {\n await this.placeCallWithCallFeeds([callFeed]);\n } catch (e) {\n this.placeCallFailed(<Error>e);\n return;\n }\n }\n\n /**\n * Place a call to this room with call feed.\n * @param callFeeds - to use\n * @throws if you have not specified a listener for 'error' events.\n * @throws if have passed audio=false.\n */\n public async placeCallWithCallFeeds(callFeeds: CallFeed[], requestScreenshareFeed = false): Promise<void> {\n this.checkForErrorListener();\n this.direction = CallDirection.Outbound;\n\n await this.initOpponentCrypto();\n\n // XXX Find a better way to do this\n this.client.callEventHandler!.calls.set(this.callId, this);\n\n // make sure we have valid turn creds. Unless something's gone wrong, it should\n // poll and keep the credentials valid so this should be instant.\n const haveTurnCreds = await this.client.checkTurnServers();\n if (!haveTurnCreds) {\n logger.warn(\n `Call ${this.callId} placeCallWithCallFeeds() failed to get TURN credentials! Proceeding with call anyway...`,\n );\n }\n\n // create the peer connection now so it can be gathering candidates while we get user\n // media (assuming a candidate pool size is configured)\n this.peerConn = this.createPeerConnection();\n this.emit(CallEvent.PeerConnectionCreated, this.peerConn, this);\n this.gotCallFeedsForInvite(callFeeds, requestScreenshareFeed);\n }\n\n private createPeerConnection(): RTCPeerConnection {\n const pc = new window.RTCPeerConnection({\n iceTransportPolicy: this.forceTURN ? \"relay\" : undefined,\n iceServers: this.turnServers.length ? this.turnServers : undefined,\n iceCandidatePoolSize: this.client.iceCandidatePoolSize,\n bundlePolicy: \"max-bundle\",\n });\n\n // 'connectionstatechange' would be better, but firefox doesn't implement that.\n pc.addEventListener(\"iceconnectionstatechange\", this.onIceConnectionStateChanged);\n pc.addEventListener(\"signalingstatechange\", this.onSignallingStateChanged);\n pc.addEventListener(\"icecandidate\", this.gotLocalIceCandidate);\n pc.addEventListener(\"icegatheringstatechange\", this.onIceGatheringStateChange);\n pc.addEventListener(\"track\", this.onTrack);\n pc.addEventListener(\"negotiationneeded\", this.onNegotiationNeeded);\n pc.addEventListener(\"datachannel\", this.onDataChannel);\n\n const opponentMember: RoomMember | undefined = this.getOpponentMember();\n const opponentMemberId = opponentMember ? opponentMember.userId : \"unknown\";\n this.stats?.addStatsReportGatherer(this.callId, opponentMemberId, pc);\n return pc;\n }\n\n private partyIdMatches(msg: MCallBase): boolean {\n // They must either match or both be absent (in which case opponentPartyId will be null)\n // Also we ignore party IDs on the invite/offer if the version is 0, so we must do the same\n // here and use null if the version is 0 (woe betide any opponent sending messages in the\n // same call with different versions)\n const msgPartyId = msg.version === 0 ? null : msg.party_id || null;\n return msgPartyId === this.opponentPartyId;\n }\n\n // Commits to an opponent for the call\n // ev: An invite or answer event\n private chooseOpponent(ev: MatrixEvent): void {\n // I choo-choo-choose you\n const msg = ev.getContent<MCallInviteNegotiate | MCallAnswer>();\n\n logger.debug(`Call ${this.callId} chooseOpponent() running (partyId=${msg.party_id})`);\n\n this.opponentVersion = msg.version;\n if (this.opponentVersion === 0) {\n // set to null to indicate that we've chosen an opponent, but because\n // they're v0 they have no party ID (even if they sent one, we're ignoring it)\n this.opponentPartyId = null;\n } else {\n // set to their party ID, or if they're naughty and didn't send one despite\n // not being v0, set it to null to indicate we picked an opponent with no\n // party ID\n this.opponentPartyId = msg.party_id || null;\n }\n this.opponentCaps = msg.capabilities || ({} as CallCapabilities);\n this.opponentMember = this.client.getRoom(this.roomId)!.getMember(ev.getSender()!) ?? undefined;\n if (this.opponentMember) {\n this.stats?.updateOpponentMember(this.callId, this.opponentMember.userId);\n }\n }\n\n private async addBufferedIceCandidates(): Promise<void> {\n const bufferedCandidates = this.remoteCandidateBuffer.get(this.opponentPartyId!);\n if (bufferedCandidates) {\n logger.info(\n `Call ${this.callId} addBufferedIceCandidates() adding ${bufferedCandidates.length} buffered candidates for opponent ${this.opponentPartyId}`,\n );\n await this.addIceCandidates(bufferedCandidates);\n }\n this.remoteCandidateBuffer.clear();\n }\n\n private async addIceCandidates(candidates: RTCIceCandidate[] | MCallCandidates[\"candidates\"]): Promise<void> {\n for (const candidate of candidates) {\n if (\n (candidate.sdpMid === null || candidate.sdpMid === undefined) &&\n (candidate.sdpMLineIndex === null || candidate.sdpMLineIndex === undefined)\n ) {\n logger.debug(`Call ${this.callId} addIceCandidates() got remote ICE end-of-candidates`);\n } else {\n logger.debug(\n `Call ${this.callId} addIceCandidates() got remote ICE candidate (sdpMid=${candidate.sdpMid}, candidate=${candidate.candidate})`,\n );\n }\n\n try {\n await this.peerConn!.addIceCandidate(candidate);\n } catch (err) {\n if (!this.ignoreOffer) {\n logger.info(`Call ${this.callId} addIceCandidates() failed to add remote ICE candidate`, err);\n } else {\n logger.debug(\n `Call ${this.callId} addIceCandidates() failed to add remote ICE candidate because ignoring offer`,\n err,\n );\n }\n }\n }\n }\n\n public get hasPeerConnection(): boolean {\n return Boolean(this.peerConn);\n }\n\n public initStats(stats: GroupCallStats, peerId = \"unknown\"): void {\n this.stats = stats;\n this.stats.start();\n }\n}\n\nexport function setTracksEnabled(tracks: Array<MediaStreamTrack>, enabled: boolean): void {\n for (const track of tracks) {\n track.enabled = enabled;\n }\n}\n\nexport function supportsMatrixCall(): boolean {\n // typeof prevents Node from erroring on an undefined reference\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n // NB. We don't log here as apps try to create a call object as a test for\n // whether calls are supported, so we shouldn't fill the logs up.\n return false;\n }\n\n // Firefox throws on so little as accessing the RTCPeerConnection when operating in a secure mode.\n // There's some information at https://bugzilla.mozilla.org/show_bug.cgi?id=1542616 though the concern\n // is that the browser throwing a SecurityError will brick the client creation process.\n try {\n const supported = Boolean(\n window.RTCPeerConnection ||\n window.RTCSessionDescription ||\n window.RTCIceCandidate ||\n navigator.mediaDevices,\n );\n if (!supported) {\n /* istanbul ignore if */ // Adds a lot of noise to test runs, so disable logging there.\n if (process.env.NODE_ENV !== \"test\") {\n logger.error(\"WebRTC is not supported in this browser / environment\");\n }\n return false;\n }\n } catch (e) {\n logger.error(\"Exception thrown when trying to access WebRTC\", e);\n return false;\n }\n\n return true;\n}\n\n/**\n * DEPRECATED\n * Use client.createCall()\n *\n * Create a new Matrix call for the browser.\n * @param client - The client instance to use.\n * @param roomId - The room the call is in.\n * @param options - DEPRECATED optional options map.\n * @returns the call or null if the browser doesn't support calling.\n */\nexport function createNewMatrixCall(\n client: MatrixClient,\n roomId: string,\n options?: Pick<CallOpts, \"forceTURN\" | \"invitee\" | \"opponentDeviceId\" | \"opponentSessionId\" | \"groupCallId\">,\n): MatrixCall | null {\n if (!supportsMatrixCall()) return null;\n\n const optionsForceTURN = options ? options.forceTURN : false;\n\n const opts: CallOpts = {\n client: client,\n roomId: roomId,\n invitee: options?.invitee,\n turnServers: client.getTurnServers(),\n // call level options\n forceTURN: client.forceTURN || optionsForceTURN,\n opponentDeviceId: options?.opponentDeviceId,\n opponentSessionId: options?.opponentSessionId,\n groupCallId: options?.groupCallId,\n };\n const call = new MatrixCall(opts);\n\n client.reEmitter.reEmit(call, Object.values(CallEvent));\n\n return call;\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAASA,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,KAAK,IAAIC,QAAQ,EAAEC,KAAK,IAAIC,QAAQ,QAAQ,eAAe;AAEpE,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,kBAAkB,EAAEC,iBAAiB,EAAEC,iBAAiB,QAAQ,aAAa;AAEtF,SAASC,SAAS,E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,IAAI;AACf","ignoreList":[]}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { MatrixEvent } from "../models/event.ts";
|
2
|
+
import { MatrixCall } from "./call.ts";
|
3
|
+
import { MatrixClient } from "../client.ts";
|
4
|
+
export declare enum CallEventHandlerEvent {
|
5
|
+
Incoming = "Call.incoming"
|
6
|
+
}
|
7
|
+
export type CallEventHandlerEventHandlerMap = {
|
8
|
+
/**
|
9
|
+
* Fires whenever an incoming call arrives.
|
10
|
+
* @param call - The incoming call.
|
11
|
+
* @example
|
12
|
+
* ```
|
13
|
+
* matrixClient.on("Call.incoming", function(call){
|
14
|
+
* call.answer(); // auto-answer
|
15
|
+
* });
|
16
|
+
* ```
|
17
|
+
*/
|
18
|
+
[CallEventHandlerEvent.Incoming]: (call: MatrixCall) => void;
|
19
|
+
};
|
20
|
+
export declare class CallEventHandler {
|
21
|
+
calls: Map<string, MatrixCall>;
|
22
|
+
callEventBuffer: MatrixEvent[];
|
23
|
+
nextSeqByCall: Map<string, number>;
|
24
|
+
toDeviceEventBuffers: Map<string, Array<MatrixEvent>>;
|
25
|
+
private client;
|
26
|
+
private candidateEventsByCall;
|
27
|
+
private eventBufferPromiseChain?;
|
28
|
+
constructor(client: MatrixClient);
|
29
|
+
start(): void;
|
30
|
+
stop(): void;
|
31
|
+
private onSync;
|
32
|
+
private evaluateEventBuffer;
|
33
|
+
private onRoomTimeline;
|
34
|
+
private onToDeviceEvent;
|
35
|
+
private handleCallEvent;
|
36
|
+
}
|
37
|
+
//# sourceMappingURL=callEventHandler.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"callEventHandler.d.ts","sourceRoot":"","sources":["../../src/webrtc/callEventHandler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAA2E,UAAU,EAAE,MAAM,WAAW,CAAC;AAEhH,OAAO,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AASzD,oBAAY,qBAAqB;IAC7B,QAAQ,kBAAkB;CAC7B;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC1C;;;;;;;;;OASG;IACH,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAChE,CAAC;AAEF,qBAAa,gBAAgB;IAElB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/B,eAAe,EAAE,WAAW,EAAE,CAAC;IAC/B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAa;IAC/C,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAa;IAEzE,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,uBAAuB,CAAC,CAAgB;gBAE7B,MAAM,EAAE,YAAY;IAehC,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAMnB,OAAO,CAAC,MAAM,CAaZ;YAEY,mBAAmB;IAsCjC,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,eAAe,CA+CrB;YAEY,eAAe;CAyOhC"}
|