@unwanted/matrix-sdk-mini 34.12.0-2 → 34.12.0-4
Sign up to get free protection for your applications and to get access to all the features.
- package/git-revision.txt +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +0 -11
- package/lib/browser-index.js.map +1 -1
- package/lib/client.d.ts +2 -1221
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +331 -2821
- package/lib/client.js.map +1 -1
- package/lib/embedded.d.ts +0 -22
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +24 -166
- package/lib/embedded.js.map +1 -1
- package/lib/event-mapper.d.ts.map +1 -1
- package/lib/event-mapper.js +0 -4
- package/lib/event-mapper.js.map +1 -1
- package/lib/matrix.d.ts +0 -19
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -26
- package/lib/matrix.js.map +1 -1
- package/lib/models/MSC3089Branch.d.ts.map +1 -1
- package/lib/models/MSC3089Branch.js +0 -3
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/event.d.ts +0 -94
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +0 -274
- package/lib/models/event.js.map +1 -1
- package/lib/models/poll.d.ts.map +1 -1
- package/lib/models/poll.js +1 -5
- package/lib/models/poll.js.map +1 -1
- package/lib/models/relations-container.d.ts.map +1 -1
- package/lib/models/relations-container.js +1 -7
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.d.ts +0 -1
- package/lib/models/relations.d.ts.map +1 -1
- package/lib/models/relations.js +0 -8
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +10 -26
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +0 -18
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +94 -148
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +0 -1
- package/lib/models/thread.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +2 -3
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +41 -90
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sync.d.ts +0 -12
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +1 -73
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +0 -48
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +0 -105
- package/lib/testing.js.map +1 -1
- package/lib/types.d.ts +0 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +1 -3
- package/src/@types/global.d.ts +0 -3
- package/src/browser-index.ts +0 -11
- package/src/client.ts +60 -2882
- package/src/embedded.ts +3 -130
- package/src/event-mapper.ts +0 -4
- package/src/matrix.ts +0 -28
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event.ts +0 -289
- package/src/models/poll.ts +0 -6
- package/src/models/relations-container.ts +1 -8
- package/src/models/relations.ts +0 -8
- package/src/models/room-state.ts +2 -8
- package/src/models/room.ts +0 -62
- package/src/models/thread.ts +0 -1
- package/src/sliding-sync-sdk.ts +2 -72
- package/src/sync.ts +1 -98
- package/src/testing.ts +0 -108
- package/src/types.ts +0 -1
- package/CHANGELOG.md +0 -5910
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
- package/lib/@types/crypto.d.ts +0 -47
- package/lib/@types/crypto.d.ts.map +0 -1
- package/lib/@types/crypto.js +0 -1
- package/lib/@types/crypto.js.map +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
- package/lib/common-crypto/CryptoBackend.d.ts +0 -240
- package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
- package/lib/common-crypto/CryptoBackend.js +0 -73
- package/lib/common-crypto/CryptoBackend.js.map +0 -1
- package/lib/common-crypto/key-passphrase.d.ts +0 -14
- package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
- package/lib/common-crypto/key-passphrase.js +0 -33
- package/lib/common-crypto/key-passphrase.js.map +0 -1
- package/lib/crypto/CrossSigning.d.ts +0 -184
- package/lib/crypto/CrossSigning.d.ts.map +0 -1
- package/lib/crypto/CrossSigning.js +0 -718
- package/lib/crypto/CrossSigning.js.map +0 -1
- package/lib/crypto/DeviceList.d.ts +0 -216
- package/lib/crypto/DeviceList.d.ts.map +0 -1
- package/lib/crypto/DeviceList.js +0 -892
- package/lib/crypto/DeviceList.js.map +0 -1
- package/lib/crypto/EncryptionSetup.d.ts +0 -152
- package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
- package/lib/crypto/EncryptionSetup.js +0 -356
- package/lib/crypto/EncryptionSetup.js.map +0 -1
- package/lib/crypto/OlmDevice.d.ts +0 -457
- package/lib/crypto/OlmDevice.d.ts.map +0 -1
- package/lib/crypto/OlmDevice.js +0 -1241
- package/lib/crypto/OlmDevice.js.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
- package/lib/crypto/RoomList.d.ts +0 -26
- package/lib/crypto/RoomList.d.ts.map +0 -1
- package/lib/crypto/RoomList.js +0 -71
- package/lib/crypto/RoomList.js.map +0 -1
- package/lib/crypto/SecretSharing.d.ts +0 -24
- package/lib/crypto/SecretSharing.d.ts.map +0 -1
- package/lib/crypto/SecretSharing.js +0 -194
- package/lib/crypto/SecretSharing.js.map +0 -1
- package/lib/crypto/SecretStorage.d.ts +0 -55
- package/lib/crypto/SecretStorage.d.ts.map +0 -1
- package/lib/crypto/SecretStorage.js +0 -118
- package/lib/crypto/SecretStorage.js.map +0 -1
- package/lib/crypto/aes.d.ts +0 -6
- package/lib/crypto/aes.d.ts.map +0 -1
- package/lib/crypto/aes.js +0 -24
- package/lib/crypto/aes.js.map +0 -1
- package/lib/crypto/algorithms/base.d.ts +0 -156
- package/lib/crypto/algorithms/base.d.ts.map +0 -1
- package/lib/crypto/algorithms/base.js +0 -187
- package/lib/crypto/algorithms/base.js.map +0 -1
- package/lib/crypto/algorithms/index.d.ts +0 -4
- package/lib/crypto/algorithms/index.d.ts.map +0 -1
- package/lib/crypto/algorithms/index.js +0 -20
- package/lib/crypto/algorithms/index.js.map +0 -1
- package/lib/crypto/algorithms/megolm.d.ts +0 -385
- package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
- package/lib/crypto/algorithms/megolm.js +0 -1822
- package/lib/crypto/algorithms/megolm.js.map +0 -1
- package/lib/crypto/algorithms/olm.d.ts +0 -5
- package/lib/crypto/algorithms/olm.d.ts.map +0 -1
- package/lib/crypto/algorithms/olm.js +0 -299
- package/lib/crypto/algorithms/olm.js.map +0 -1
- package/lib/crypto/api.d.ts +0 -32
- package/lib/crypto/api.d.ts.map +0 -1
- package/lib/crypto/api.js +0 -22
- package/lib/crypto/api.js.map +0 -1
- package/lib/crypto/backup.d.ts +0 -227
- package/lib/crypto/backup.d.ts.map +0 -1
- package/lib/crypto/backup.js +0 -824
- package/lib/crypto/backup.js.map +0 -1
- package/lib/crypto/crypto.d.ts +0 -3
- package/lib/crypto/crypto.d.ts.map +0 -1
- package/lib/crypto/crypto.js +0 -19
- package/lib/crypto/crypto.js.map +0 -1
- package/lib/crypto/dehydration.d.ts +0 -34
- package/lib/crypto/dehydration.d.ts.map +0 -1
- package/lib/crypto/dehydration.js +0 -252
- package/lib/crypto/dehydration.js.map +0 -1
- package/lib/crypto/device-converter.d.ts +0 -9
- package/lib/crypto/device-converter.d.ts.map +0 -1
- package/lib/crypto/device-converter.js +0 -42
- package/lib/crypto/device-converter.js.map +0 -1
- package/lib/crypto/deviceinfo.d.ts +0 -99
- package/lib/crypto/deviceinfo.d.ts.map +0 -1
- package/lib/crypto/deviceinfo.js +0 -148
- package/lib/crypto/deviceinfo.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -1209
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4097
- package/lib/crypto/index.js.map +0 -1
- package/lib/crypto/key_passphrase.d.ts +0 -14
- package/lib/crypto/key_passphrase.d.ts.map +0 -1
- package/lib/crypto/key_passphrase.js +0 -44
- package/lib/crypto/key_passphrase.js.map +0 -1
- package/lib/crypto/keybackup.d.ts +0 -18
- package/lib/crypto/keybackup.d.ts.map +0 -1
- package/lib/crypto/keybackup.js +0 -1
- package/lib/crypto/keybackup.js.map +0 -1
- package/lib/crypto/olmlib.d.ts +0 -129
- package/lib/crypto/olmlib.d.ts.map +0 -1
- package/lib/crypto/olmlib.js +0 -492
- package/lib/crypto/olmlib.js.map +0 -1
- package/lib/crypto/recoverykey.d.ts +0 -2
- package/lib/crypto/recoverykey.d.ts.map +0 -1
- package/lib/crypto/recoverykey.js +0 -19
- package/lib/crypto/recoverykey.js.map +0 -1
- package/lib/crypto/store/base.d.ts +0 -252
- package/lib/crypto/store/base.d.ts.map +0 -1
- package/lib/crypto/store/base.js +0 -64
- package/lib/crypto/store/base.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
- package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/localStorage-crypto-store.js +0 -531
- package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
- package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
- package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
- package/lib/crypto/store/memory-crypto-store.js +0 -622
- package/lib/crypto/store/memory-crypto-store.js.map +0 -1
- package/lib/crypto/verification/Base.d.ts +0 -105
- package/lib/crypto/verification/Base.d.ts.map +0 -1
- package/lib/crypto/verification/Base.js +0 -372
- package/lib/crypto/verification/Base.js.map +0 -1
- package/lib/crypto/verification/Error.d.ts +0 -35
- package/lib/crypto/verification/Error.d.ts.map +0 -1
- package/lib/crypto/verification/Error.js +0 -86
- package/lib/crypto/verification/Error.js.map +0 -1
- package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
- package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
- package/lib/crypto/verification/IllegalMethod.js +0 -43
- package/lib/crypto/verification/IllegalMethod.js.map +0 -1
- package/lib/crypto/verification/QRCode.d.ts +0 -51
- package/lib/crypto/verification/QRCode.d.ts.map +0 -1
- package/lib/crypto/verification/QRCode.js +0 -277
- package/lib/crypto/verification/QRCode.js.map +0 -1
- package/lib/crypto/verification/SAS.d.ts +0 -27
- package/lib/crypto/verification/SAS.d.ts.map +0 -1
- package/lib/crypto/verification/SAS.js +0 -485
- package/lib/crypto/verification/SAS.js.map +0 -1
- package/lib/crypto/verification/SASDecimal.d.ts +0 -8
- package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
- package/lib/crypto/verification/SASDecimal.js +0 -34
- package/lib/crypto/verification/SASDecimal.js.map +0 -1
- package/lib/crypto/verification/request/Channel.d.ts +0 -18
- package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
- package/lib/crypto/verification/request/Channel.js +0 -1
- package/lib/crypto/verification/request/Channel.js.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/InRoomChannel.js +0 -351
- package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
- package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
- package/lib/crypto/verification/request/VerificationRequest.js +0 -937
- package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
- package/lib/crypto-api/CryptoEvent.d.ts +0 -69
- package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEvent.js +0 -33
- package/lib/crypto-api/CryptoEvent.js.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
- package/lib/crypto-api/index.d.ts +0 -978
- package/lib/crypto-api/index.d.ts.map +0 -1
- package/lib/crypto-api/index.js +0 -304
- package/lib/crypto-api/index.js.map +0 -1
- package/lib/crypto-api/key-passphrase.d.ts +0 -11
- package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
- package/lib/crypto-api/key-passphrase.js +0 -51
- package/lib/crypto-api/key-passphrase.js.map +0 -1
- package/lib/crypto-api/keybackup.d.ts +0 -88
- package/lib/crypto-api/keybackup.d.ts.map +0 -1
- package/lib/crypto-api/keybackup.js +0 -1
- package/lib/crypto-api/keybackup.js.map +0 -1
- package/lib/crypto-api/recovery-key.d.ts +0 -11
- package/lib/crypto-api/recovery-key.d.ts.map +0 -1
- package/lib/crypto-api/recovery-key.js +0 -65
- package/lib/crypto-api/recovery-key.js.map +0 -1
- package/lib/crypto-api/verification.d.ts +0 -344
- package/lib/crypto-api/verification.d.ts.map +0 -1
- package/lib/crypto-api/verification.js +0 -91
- package/lib/crypto-api/verification.js.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
- package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
- package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousChannel.js +0 -1
- package/lib/rendezvous/RendezvousChannel.js.map +0 -1
- package/lib/rendezvous/RendezvousCode.d.ts +0 -9
- package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousCode.js +0 -1
- package/lib/rendezvous/RendezvousCode.js.map +0 -1
- package/lib/rendezvous/RendezvousError.d.ts +0 -6
- package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousError.js +0 -23
- package/lib/rendezvous/RendezvousError.js.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousFailureReason.js +0 -38
- package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
- package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
- package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousIntent.js +0 -22
- package/lib/rendezvous/RendezvousIntent.js.map +0 -1
- package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
- package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
- package/lib/rendezvous/RendezvousTransport.js +0 -1
- package/lib/rendezvous/RendezvousTransport.js.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
- package/lib/rendezvous/channels/index.d.ts +0 -2
- package/lib/rendezvous/channels/index.d.ts.map +0 -1
- package/lib/rendezvous/channels/index.js +0 -18
- package/lib/rendezvous/channels/index.js.map +0 -1
- package/lib/rendezvous/index.d.ts +0 -10
- package/lib/rendezvous/index.d.ts.map +0 -1
- package/lib/rendezvous/index.js +0 -23
- package/lib/rendezvous/index.js.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
- package/lib/rendezvous/transports/index.d.ts +0 -2
- package/lib/rendezvous/transports/index.d.ts.map +0 -1
- package/lib/rendezvous/transports/index.js +0 -18
- package/lib/rendezvous/transports/index.js.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
- package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
- package/lib/rust-crypto/KeyClaimManager.js +0 -82
- package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
- package/lib/rust-crypto/RoomEncryptor.js +0 -299
- package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
- package/lib/rust-crypto/backup.d.ts +0 -254
- package/lib/rust-crypto/backup.d.ts.map +0 -1
- package/lib/rust-crypto/backup.js +0 -837
- package/lib/rust-crypto/backup.js.map +0 -1
- package/lib/rust-crypto/constants.d.ts +0 -3
- package/lib/rust-crypto/constants.d.ts.map +0 -1
- package/lib/rust-crypto/constants.js +0 -19
- package/lib/rust-crypto/constants.js.map +0 -1
- package/lib/rust-crypto/device-converter.d.ts +0 -28
- package/lib/rust-crypto/device-converter.d.ts.map +0 -1
- package/lib/rust-crypto/device-converter.js +0 -123
- package/lib/rust-crypto/device-converter.js.map +0 -1
- package/lib/rust-crypto/index.d.ts +0 -61
- package/lib/rust-crypto/index.d.ts.map +0 -1
- package/lib/rust-crypto/index.js +0 -152
- package/lib/rust-crypto/index.js.map +0 -1
- package/lib/rust-crypto/libolm_migration.d.ts +0 -81
- package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
- package/lib/rust-crypto/libolm_migration.js +0 -459
- package/lib/rust-crypto/libolm_migration.js.map +0 -1
- package/lib/rust-crypto/rust-crypto.d.ts +0 -556
- package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
- package/lib/rust-crypto/rust-crypto.js +0 -2016
- package/lib/rust-crypto/rust-crypto.js.map +0 -1
- package/lib/rust-crypto/secret-storage.d.ts +0 -22
- package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
- package/lib/rust-crypto/secret-storage.js +0 -63
- package/lib/rust-crypto/secret-storage.js.map +0 -1
- package/lib/rust-crypto/verification.d.ts +0 -319
- package/lib/rust-crypto/verification.d.ts.map +0 -1
- package/lib/rust-crypto/verification.js +0 -816
- package/lib/rust-crypto/verification.js.map +0 -1
- package/lib/secret-storage.d.ts +0 -370
- package/lib/secret-storage.d.ts.map +0 -1
- package/lib/secret-storage.js +0 -466
- package/lib/secret-storage.js.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/decryptAESSecretStorageItem.js +0 -50
- package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
- package/lib/utils/encryptAESSecretStorageItem.js +0 -68
- package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
- package/lib/utils/internal/deriveKeys.d.ts +0 -10
- package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
- package/lib/utils/internal/deriveKeys.js +0 -60
- package/lib/utils/internal/deriveKeys.js.map +0 -1
- package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
- package/src/@types/crypto.ts +0 -73
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
- package/src/common-crypto/CryptoBackend.ts +0 -302
- package/src/common-crypto/README.md +0 -4
- package/src/common-crypto/key-passphrase.ts +0 -43
- package/src/crypto/CrossSigning.ts +0 -773
- package/src/crypto/DeviceList.ts +0 -989
- package/src/crypto/EncryptionSetup.ts +0 -351
- package/src/crypto/OlmDevice.ts +0 -1500
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
- package/src/crypto/RoomList.ts +0 -70
- package/src/crypto/SecretSharing.ts +0 -240
- package/src/crypto/SecretStorage.ts +0 -136
- package/src/crypto/aes.ts +0 -23
- package/src/crypto/algorithms/base.ts +0 -236
- package/src/crypto/algorithms/index.ts +0 -20
- package/src/crypto/algorithms/megolm.ts +0 -2216
- package/src/crypto/algorithms/olm.ts +0 -381
- package/src/crypto/api.ts +0 -70
- package/src/crypto/backup.ts +0 -922
- package/src/crypto/crypto.ts +0 -18
- package/src/crypto/dehydration.ts +0 -272
- package/src/crypto/device-converter.ts +0 -45
- package/src/crypto/deviceinfo.ts +0 -158
- package/src/crypto/index.ts +0 -4414
- package/src/crypto/key_passphrase.ts +0 -42
- package/src/crypto/keybackup.ts +0 -47
- package/src/crypto/olmlib.ts +0 -539
- package/src/crypto/recoverykey.ts +0 -18
- package/src/crypto/store/base.ts +0 -348
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
- package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
- package/src/crypto/store/localStorage-crypto-store.ts +0 -579
- package/src/crypto/store/memory-crypto-store.ts +0 -680
- package/src/crypto/verification/Base.ts +0 -409
- package/src/crypto/verification/Error.ts +0 -76
- package/src/crypto/verification/IllegalMethod.ts +0 -50
- package/src/crypto/verification/QRCode.ts +0 -310
- package/src/crypto/verification/SAS.ts +0 -494
- package/src/crypto/verification/SASDecimal.ts +0 -37
- package/src/crypto/verification/request/Channel.ts +0 -34
- package/src/crypto/verification/request/InRoomChannel.ts +0 -371
- package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
- package/src/crypto/verification/request/VerificationRequest.ts +0 -976
- package/src/crypto-api/CryptoEvent.ts +0 -93
- package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
- package/src/crypto-api/index.ts +0 -1175
- package/src/crypto-api/key-passphrase.ts +0 -58
- package/src/crypto-api/keybackup.ts +0 -115
- package/src/crypto-api/recovery-key.ts +0 -69
- package/src/crypto-api/verification.ts +0 -408
- package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
- package/src/rendezvous/RendezvousChannel.ts +0 -48
- package/src/rendezvous/RendezvousCode.ts +0 -25
- package/src/rendezvous/RendezvousError.ts +0 -26
- package/src/rendezvous/RendezvousFailureReason.ts +0 -49
- package/src/rendezvous/RendezvousIntent.ts +0 -20
- package/src/rendezvous/RendezvousTransport.ts +0 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
- package/src/rendezvous/channels/index.ts +0 -17
- package/src/rendezvous/index.ts +0 -25
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
- package/src/rendezvous/transports/index.ts +0 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
- package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
- package/src/rust-crypto/KeyClaimManager.ts +0 -86
- package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
- package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
- package/src/rust-crypto/RoomEncryptor.ts +0 -352
- package/src/rust-crypto/backup.ts +0 -881
- package/src/rust-crypto/constants.ts +0 -18
- package/src/rust-crypto/device-converter.ts +0 -128
- package/src/rust-crypto/index.ts +0 -237
- package/src/rust-crypto/libolm_migration.ts +0 -530
- package/src/rust-crypto/rust-crypto.ts +0 -2205
- package/src/rust-crypto/secret-storage.ts +0 -60
- package/src/rust-crypto/verification.ts +0 -830
- package/src/secret-storage.ts +0 -693
- package/src/utils/decryptAESSecretStorageItem.ts +0 -54
- package/src/utils/encryptAESSecretStorageItem.ts +0 -73
- package/src/utils/internal/deriveKeys.ts +0 -63
package/lib/crypto/backup.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"backup.js","names":["MatrixClient","logger","MEGOLM_ALGORITHM","verifySignature","keyFromPassphrase","encodeUri","safeSet","sleep","IndexedDBCryptoStore","UnstableValue","CryptoEvent","ClientPrefix","MatrixError","Method","encodeRecoveryKey","decryptAESSecretStorageItem","encryptAESSecretStorageItem","calculateKeyCheck","KEY_BACKUP_KEYS_PER_REQUEST","KEY_BACKUP_CHECK_RATE_LIMIT","BackupManager","constructor","baseApis","getKey","_defineProperty","checkedForBackup","sendingBackups","stop","clientRunning","version","backupInfo","checkBackupVersion","info","Algorithm","algorithmsByName","algorithm","Error","auth_data","makeAlgorithm","init","enableKeyBackup","_this","_asyncToGenerator","free","emit","KeyBackupStatus","scheduleKeyBackupSend","disableKeyBackup","undefined","getKeyBackupEnabled","Boolean","prepareKeyBackupVersion","key","DefaultAlgorithm","privateKey","authData","prepare","recoveryKey","algorithmName","recovery_key","createKeyBackupVersion","_this2","deleteAllKeyBackupVersions","_this3","_yield$_this3$baseApi","_yield$_this3$baseApi2","current","getKeyBackupVersion","_yield$_this3$baseApi3","_yield$_this3$baseApi4","deleteKeyBackupVersion","_this4","path","$version","http","authedRequest","Delete","prefix","V3","checkAndStart","_this5","log","isGuest","_yield$_this5$baseApi","e","httpStatus","trustInfo","isKeyBackupTrusted","usable","concat","scheduleAllGroupSessionsForBackup","checkKeyBackup","_this6","queryKeyBackupRateLimited","targetRoomId","targetSessionId","_this7","now","Date","getTime","sessionLastCheckAttemptedTime","restoreKeyBackupWithCache","_this8","ret","trusted_locally","sigs","signatures","JSON","stringify","userId","getUserId","privKey","crypto","getSessionBackupPrivateKey","keyMatches","_unused","_algorithm","mySigs","keyId","Object","keys","keyIdParts","split","sigInfo","deviceId","crossSigningId","crossSigningInfo","getId","olmDevice","valid","warn","push","device","deviceList","getStoredDevice","deviceTrust","checkDeviceTrust","getFingerprint","some","s","_s$deviceTrust","isVerified","_arguments","arguments","_this9","maxDelay","length","debug","delay","Math","random","numFailures","numBackedUp","backupPendingKeys","err","errCode","data","errcode","KeyBackupFailed","pow","min","limit","_this10","sessions","cryptoStore","getSessionsNeedingBackup","remaining","countSessionsNeedingBackup","KeyBackupSessionsRemaining","rooms","session","_deviceList$getDevice","roomId","sessionData","room_id","exportInboundGroupSession","senderKey","sessionId","forwardedCount","forwarding_curve25519_key_chain","getUserByIdentityKey","getDeviceByIdentityKey","verified","checkDeviceInfoTrust","first_message_index","first_known_index","forwarded_count","is_verified","session_data","encryptSession","sendKeyBackup","unmarkSessionsNeedingBackup","backupGroupSession","_this11","markSessionsNeedingBackup","_this12","flagAllGroupSessionsForBackup","_this13","doTxn","STORE_INBOUND_GROUP_SESSIONS","STORE_BACKUP","txn","getAllEndToEndInboundGroupSessions","Curve25519","publicKey","globalThis","Olm","PkEncryption","set_recipient_key","public_key","decryption","PkDecryption","generate_key","Uint8Array","init_with_private_key","derivation","private_key_salt","salt","private_key_iterations","iterations","get_private_key","untrusted","_this14","plainText","assign","session_id","encrypt","decryptSessions","_this15","backupPubKey","RESTORE_BACKUP_ERROR_BAD_KEY","entries","decrypted","parse","decrypt","ephemeral","mac","ciphertext","_this16","pubKey","randomBytes","size","buf","getRandomValues","UNSTABLE_MSC3270_NAME","Aes256","iv","replace","outKey","_this17","_this18","fill","name","backupTrustInfoFromLegacyTrustInfo","_trustInfo$trusted_lo","trusted","matchesDecryptionKey","LibOlmBackupDecryptor","sourceTrusted","_this19"],"sources":["../../src/crypto/backup.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\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 * Classes for dealing with key backup.\n */\n\nimport type { IMegolmSessionData } from \"../@types/crypto.ts\";\nimport { MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { MEGOLM_ALGORITHM, verifySignature } from \"./olmlib.ts\";\nimport { DeviceInfo } from \"./deviceinfo.ts\";\nimport { DeviceTrustLevel } from \"./CrossSigning.ts\";\nimport { keyFromPassphrase } from \"./key_passphrase.ts\";\nimport { encodeUri, safeSet, sleep } from \"../utils.ts\";\nimport { IndexedDBCryptoStore } from \"./store/indexeddb-crypto-store.ts\";\nimport {\n Curve25519SessionData,\n IAes256AuthData,\n ICurve25519AuthData,\n IKeyBackupInfo,\n IKeyBackupSession,\n} from \"./keybackup.ts\";\nimport { UnstableValue } from \"../NamespacedValue.ts\";\nimport { CryptoEvent } from \"./index.ts\";\nimport { ClientPrefix, HTTPError, MatrixError, Method } from \"../http-api/index.ts\";\nimport { BackupTrustInfo } from \"../crypto-api/keybackup.ts\";\nimport { BackupDecryptor } from \"../common-crypto/CryptoBackend.ts\";\nimport { encodeRecoveryKey } from \"../crypto-api/index.ts\";\nimport decryptAESSecretStorageItem from \"../utils/decryptAESSecretStorageItem.ts\";\nimport encryptAESSecretStorageItem from \"../utils/encryptAESSecretStorageItem.ts\";\nimport { AESEncryptedSecretStoragePayload } from \"../@types/AESEncryptedSecretStoragePayload.ts\";\nimport { calculateKeyCheck } from \"../secret-storage.ts\";\n\nconst KEY_BACKUP_KEYS_PER_REQUEST = 200;\nconst KEY_BACKUP_CHECK_RATE_LIMIT = 5000; // ms\n\ntype AuthData = IKeyBackupInfo[\"auth_data\"];\n\ntype SigInfo = {\n deviceId: string;\n valid?: boolean | null; // true: valid, false: invalid, null: cannot attempt validation\n device?: DeviceInfo | null;\n crossSigningId?: boolean;\n deviceTrust?: DeviceTrustLevel;\n};\n\n/** @deprecated Prefer {@link BackupTrustInfo} */\nexport type TrustInfo = {\n usable: boolean; // is the backup trusted, true iff there is a sig that is valid & from a trusted device\n sigs: SigInfo[];\n // eslint-disable-next-line camelcase\n trusted_locally?: boolean;\n};\n\nexport interface IKeyBackupCheck {\n backupInfo?: IKeyBackupInfo;\n trustInfo: TrustInfo;\n}\n\n/* eslint-disable camelcase */\nexport interface IPreparedKeyBackupVersion {\n algorithm: string;\n auth_data: AuthData;\n recovery_key: string;\n privateKey: Uint8Array;\n}\n/* eslint-enable camelcase */\n\n/** A function used to get the secret key for a backup.\n */\ntype GetKey = () => Promise<ArrayLike<number>>;\n\ninterface BackupAlgorithmClass {\n algorithmName: string;\n // initialize from an existing backup\n init(authData: AuthData, getKey: GetKey): Promise<BackupAlgorithm>;\n\n // prepare a brand new backup\n prepare(key?: string | Uint8Array | null): Promise<[Uint8Array, AuthData]>;\n\n checkBackupVersion(info: IKeyBackupInfo): void;\n}\n\ninterface BackupAlgorithm {\n untrusted: boolean;\n encryptSession(data: Record<string, any>): Promise<Curve25519SessionData | AESEncryptedSecretStoragePayload>;\n decryptSessions(ciphertexts: Record<string, IKeyBackupSession>): Promise<IMegolmSessionData[]>;\n authData: AuthData;\n keyMatches(key: ArrayLike<number>): Promise<boolean>;\n free(): void;\n}\n\nexport interface IKeyBackup {\n rooms: {\n [roomId: string]: {\n sessions: {\n [sessionId: string]: IKeyBackupSession;\n };\n };\n };\n}\n\n/**\n * Manages the key backup.\n */\nexport class BackupManager {\n private algorithm: BackupAlgorithm | undefined;\n public backupInfo: IKeyBackupInfo | undefined; // The info dict from /room_keys/version\n public checkedForBackup: boolean; // Have we checked the server for a backup we can use?\n private sendingBackups: boolean; // Are we currently sending backups?\n private sessionLastCheckAttemptedTime: Record<string, number> = {}; // When did we last try to check the server for a given session id?\n // The backup manager will schedule backup of keys when active (`scheduleKeyBackupSend`), this allows cancel when client is stopped\n private clientRunning = true;\n\n public constructor(\n private readonly baseApis: MatrixClient,\n public readonly getKey: GetKey,\n ) {\n this.checkedForBackup = false;\n this.sendingBackups = false;\n }\n\n /**\n * Stop the backup manager from backing up keys and allow a clean shutdown.\n */\n public stop(): void {\n this.clientRunning = false;\n }\n\n public get version(): string | undefined {\n return this.backupInfo && this.backupInfo.version;\n }\n\n /**\n * Performs a quick check to ensure that the backup info looks sane.\n *\n * Throws an error if a problem is detected.\n *\n * @param info - the key backup info\n */\n public static checkBackupVersion(info: IKeyBackupInfo): void {\n const Algorithm = algorithmsByName[info.algorithm];\n if (!Algorithm) {\n throw new Error(\"Unknown backup algorithm: \" + info.algorithm);\n }\n if (typeof info.auth_data !== \"object\") {\n throw new Error(\"Invalid backup data returned\");\n }\n return Algorithm.checkBackupVersion(info);\n }\n\n public static makeAlgorithm(info: IKeyBackupInfo, getKey: GetKey): Promise<BackupAlgorithm> {\n const Algorithm = algorithmsByName[info.algorithm];\n if (!Algorithm) {\n throw new Error(\"Unknown backup algorithm\");\n }\n return Algorithm.init(info.auth_data, getKey);\n }\n\n public async enableKeyBackup(info: IKeyBackupInfo): Promise<void> {\n this.backupInfo = info;\n if (this.algorithm) {\n this.algorithm.free();\n }\n\n this.algorithm = await BackupManager.makeAlgorithm(info, this.getKey);\n\n this.baseApis.emit(CryptoEvent.KeyBackupStatus, true);\n\n // There may be keys left over from a partially completed backup, so\n // schedule a send to check.\n this.scheduleKeyBackupSend();\n }\n\n /**\n * Disable backing up of keys.\n */\n public disableKeyBackup(): void {\n if (this.algorithm) {\n this.algorithm.free();\n }\n this.algorithm = undefined;\n\n this.backupInfo = undefined;\n\n this.baseApis.emit(CryptoEvent.KeyBackupStatus, false);\n }\n\n public getKeyBackupEnabled(): boolean | null {\n if (!this.checkedForBackup) {\n return null;\n }\n return Boolean(this.algorithm);\n }\n\n public async prepareKeyBackupVersion(\n key?: string | Uint8Array | null,\n algorithm?: string | undefined,\n ): Promise<IPreparedKeyBackupVersion> {\n const Algorithm = algorithm ? algorithmsByName[algorithm] : DefaultAlgorithm;\n if (!Algorithm) {\n throw new Error(\"Unknown backup algorithm\");\n }\n\n const [privateKey, authData] = await Algorithm.prepare(key);\n const recoveryKey = encodeRecoveryKey(privateKey)!;\n return {\n algorithm: Algorithm.algorithmName,\n auth_data: authData,\n recovery_key: recoveryKey,\n privateKey,\n };\n }\n\n public async createKeyBackupVersion(info: IKeyBackupInfo): Promise<void> {\n this.algorithm = await BackupManager.makeAlgorithm(info, this.getKey);\n }\n\n /**\n * Deletes all key backups.\n *\n * Will call the API to delete active backup until there is no more present.\n */\n public async deleteAllKeyBackupVersions(): Promise<void> {\n // there could be several backup versions, delete all to be safe.\n let current = (await this.baseApis.getKeyBackupVersion())?.version ?? null;\n while (current != null) {\n await this.deleteKeyBackupVersion(current);\n this.disableKeyBackup();\n current = (await this.baseApis.getKeyBackupVersion())?.version ?? null;\n }\n }\n\n /**\n * Deletes the given key backup.\n *\n * @param version - The backup version to delete.\n */\n public async deleteKeyBackupVersion(version: string): Promise<void> {\n const path = encodeUri(\"/room_keys/version/$version\", { $version: version });\n await this.baseApis.http.authedRequest<void>(Method.Delete, path, undefined, undefined, {\n prefix: ClientPrefix.V3,\n });\n }\n\n /**\n * Check the server for an active key backup and\n * if one is present and has a valid signature from\n * one of the user's verified devices, start backing up\n * to it.\n */\n public async checkAndStart(): Promise<IKeyBackupCheck | null> {\n logger.log(\"Checking key backup status...\");\n if (this.baseApis.isGuest()) {\n logger.log(\"Skipping key backup check since user is guest\");\n this.checkedForBackup = true;\n return null;\n }\n let backupInfo: IKeyBackupInfo | undefined;\n try {\n backupInfo = (await this.baseApis.getKeyBackupVersion()) ?? undefined;\n } catch (e) {\n logger.log(\"Error checking for active key backup\", e);\n if ((<HTTPError>e).httpStatus === 404) {\n // 404 is returned when the key backup does not exist, so that\n // counts as successfully checking.\n this.checkedForBackup = true;\n }\n return null;\n }\n this.checkedForBackup = true;\n\n const trustInfo = await this.isKeyBackupTrusted(backupInfo);\n\n if (trustInfo.usable && !this.backupInfo) {\n logger.log(`Found usable key backup v${backupInfo!.version}: enabling key backups`);\n await this.enableKeyBackup(backupInfo!);\n } else if (!trustInfo.usable && this.backupInfo) {\n logger.log(\"No usable key backup: disabling key backup\");\n this.disableKeyBackup();\n } else if (!trustInfo.usable && !this.backupInfo) {\n logger.log(\"No usable key backup: not enabling key backup\");\n } else if (trustInfo.usable && this.backupInfo) {\n // may not be the same version: if not, we should switch\n if (backupInfo!.version !== this.backupInfo.version) {\n logger.log(\n `On backup version ${this.backupInfo.version} but ` +\n `found version ${backupInfo!.version}: switching.`,\n );\n this.disableKeyBackup();\n await this.enableKeyBackup(backupInfo!);\n // We're now using a new backup, so schedule all the keys we have to be\n // uploaded to the new backup. This is a bit of a workaround to upload\n // keys to a new backup in *most* cases, but it won't cover all cases\n // because we don't remember what backup version we uploaded keys to:\n // see https://github.com/vector-im/element-web/issues/14833\n await this.scheduleAllGroupSessionsForBackup();\n } else {\n logger.log(`Backup version ${backupInfo!.version} still current`);\n }\n }\n\n return { backupInfo, trustInfo };\n }\n\n /**\n * Forces a re-check of the key backup and enables/disables it\n * as appropriate.\n *\n * @returns Object with backup info (as returned by\n * getKeyBackupVersion) in backupInfo and\n * trust information (as returned by isKeyBackupTrusted)\n * in trustInfo.\n */\n public async checkKeyBackup(): Promise<IKeyBackupCheck | null> {\n this.checkedForBackup = false;\n return this.checkAndStart();\n }\n\n /**\n * Attempts to retrieve a session from a key backup, if enough time\n * has elapsed since the last check for this session id.\n */\n public async queryKeyBackupRateLimited(\n targetRoomId: string | undefined,\n targetSessionId: string | undefined,\n ): Promise<void> {\n if (!this.backupInfo) {\n return;\n }\n\n const now = new Date().getTime();\n if (\n !this.sessionLastCheckAttemptedTime[targetSessionId!] ||\n now - this.sessionLastCheckAttemptedTime[targetSessionId!] > KEY_BACKUP_CHECK_RATE_LIMIT\n ) {\n this.sessionLastCheckAttemptedTime[targetSessionId!] = now;\n await this.baseApis.restoreKeyBackupWithCache(targetRoomId!, targetSessionId!, this.backupInfo, {});\n }\n }\n\n /**\n * Check if the given backup info is trusted.\n *\n * @param backupInfo - key backup info dict from /room_keys/version\n */\n public async isKeyBackupTrusted(backupInfo?: IKeyBackupInfo): Promise<TrustInfo> {\n const ret = {\n usable: false,\n trusted_locally: false,\n sigs: [] as SigInfo[],\n };\n\n if (!backupInfo || !backupInfo.algorithm || !backupInfo.auth_data || !backupInfo.auth_data.signatures) {\n logger.info(`Key backup is absent or missing required data: ${JSON.stringify(backupInfo)}`);\n return ret;\n }\n\n const userId = this.baseApis.getUserId()!;\n const privKey = await this.baseApis.crypto!.getSessionBackupPrivateKey();\n if (privKey) {\n let algorithm: BackupAlgorithm | null = null;\n try {\n algorithm = await BackupManager.makeAlgorithm(backupInfo, async () => privKey);\n\n if (await algorithm.keyMatches(privKey)) {\n logger.info(\"Backup is trusted locally\");\n ret.trusted_locally = true;\n }\n } catch {\n // do nothing -- if we have an error, then we don't mark it as\n // locally trusted\n } finally {\n algorithm?.free();\n }\n }\n\n const mySigs = backupInfo.auth_data.signatures[userId] || {};\n\n for (const keyId of Object.keys(mySigs)) {\n const keyIdParts = keyId.split(\":\");\n if (keyIdParts[0] !== \"ed25519\") {\n logger.log(\"Ignoring unknown signature type: \" + keyIdParts[0]);\n continue;\n }\n // Could be a cross-signing master key, but just say this is the device\n // ID for backwards compat\n const sigInfo: SigInfo = { deviceId: keyIdParts[1] };\n\n // first check to see if it's from our cross-signing key\n const crossSigningId = this.baseApis.crypto!.crossSigningInfo.getId();\n if (crossSigningId === sigInfo.deviceId) {\n sigInfo.crossSigningId = true;\n try {\n await verifySignature(\n this.baseApis.crypto!.olmDevice,\n backupInfo.auth_data,\n userId,\n sigInfo.deviceId,\n crossSigningId,\n );\n sigInfo.valid = true;\n } catch (e) {\n logger.warn(\"Bad signature from cross signing key \" + crossSigningId, e);\n sigInfo.valid = false;\n }\n ret.sigs.push(sigInfo);\n continue;\n }\n\n // Now look for a sig from a device\n // At some point this can probably go away and we'll just support\n // it being signed by the cross-signing master key\n const device = this.baseApis.crypto!.deviceList.getStoredDevice(userId, sigInfo.deviceId);\n if (device) {\n sigInfo.device = device;\n sigInfo.deviceTrust = this.baseApis.checkDeviceTrust(userId, sigInfo.deviceId);\n try {\n await verifySignature(\n this.baseApis.crypto!.olmDevice,\n backupInfo.auth_data,\n userId,\n device.deviceId,\n device.getFingerprint(),\n );\n sigInfo.valid = true;\n } catch (e) {\n logger.info(\n \"Bad signature from key ID \" +\n keyId +\n \" userID \" +\n this.baseApis.getUserId() +\n \" device ID \" +\n device.deviceId +\n \" fingerprint: \" +\n device.getFingerprint(),\n backupInfo.auth_data,\n e,\n );\n sigInfo.valid = false;\n }\n } else {\n sigInfo.valid = null; // Can't determine validity because we don't have the signing device\n logger.info(\"Ignoring signature from unknown key \" + keyId);\n }\n ret.sigs.push(sigInfo);\n }\n\n ret.usable = ret.sigs.some((s) => {\n return s.valid && ((s.device && s.deviceTrust?.isVerified()) || s.crossSigningId);\n });\n return ret;\n }\n\n /**\n * Schedules sending all keys waiting to be sent to the backup, if not already\n * scheduled. Retries if necessary.\n *\n * @param maxDelay - Maximum delay to wait in ms. 0 means no delay.\n */\n public async scheduleKeyBackupSend(maxDelay = 10000): Promise<void> {\n logger.debug(`Key backup: scheduleKeyBackupSend currentSending:${this.sendingBackups} delay:${maxDelay}`);\n if (this.sendingBackups) return;\n\n this.sendingBackups = true;\n\n try {\n // wait between 0 and `maxDelay` seconds, to avoid backup\n // requests from different clients hitting the server all at\n // the same time when a new key is sent\n const delay = Math.random() * maxDelay;\n await sleep(delay);\n if (!this.clientRunning) {\n this.sendingBackups = false;\n return;\n }\n let numFailures = 0; // number of consecutive failures\n for (;;) {\n if (!this.algorithm) {\n return;\n }\n try {\n const numBackedUp = await this.backupPendingKeys(KEY_BACKUP_KEYS_PER_REQUEST);\n if (numBackedUp === 0) {\n // no sessions left needing backup: we're done\n this.sendingBackups = false;\n return;\n }\n numFailures = 0;\n } catch (err) {\n numFailures++;\n logger.log(\"Key backup request failed\", err);\n if (err instanceof MatrixError) {\n const errCode = err.data.errcode;\n if (errCode == \"M_NOT_FOUND\" || errCode == \"M_WRONG_ROOM_KEYS_VERSION\") {\n // Set to false now as `checkKeyBackup` might schedule a backupsend before this one ends.\n this.sendingBackups = false;\n // Backup version has changed or this backup version\n // has been deleted\n this.baseApis.crypto!.emit(CryptoEvent.KeyBackupFailed, errCode);\n // Re-check key backup status on error, so we can be\n // sure to present the current situation when asked.\n // This call might restart the backup loop if new backup version is trusted\n await this.checkKeyBackup();\n return;\n }\n }\n }\n if (numFailures) {\n // exponential backoff if we have failures\n await sleep(1000 * Math.pow(2, Math.min(numFailures - 1, 4)));\n }\n\n if (!this.clientRunning) {\n logger.debug(\"Key backup send loop aborted, client stopped\");\n this.sendingBackups = false;\n return;\n }\n }\n } catch (err) {\n // No one actually checks errors on this promise, it's spawned internally.\n // Just log, apps/client should use events to check status\n logger.log(`Backup loop failed ${err}`);\n this.sendingBackups = false;\n }\n }\n\n /**\n * Take some e2e keys waiting to be backed up and send them\n * to the backup.\n *\n * @param limit - Maximum number of keys to back up\n * @returns Number of sessions backed up\n */\n public async backupPendingKeys(limit: number): Promise<number> {\n const sessions = await this.baseApis.crypto!.cryptoStore.getSessionsNeedingBackup(limit);\n if (!sessions.length) {\n return 0;\n }\n\n let remaining = await this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n this.baseApis.crypto!.emit(CryptoEvent.KeyBackupSessionsRemaining, remaining);\n\n const rooms: IKeyBackup[\"rooms\"] = {};\n for (const session of sessions) {\n const roomId = session.sessionData!.room_id;\n safeSet(rooms, roomId, rooms[roomId] || { sessions: {} });\n\n const sessionData = this.baseApis.crypto!.olmDevice.exportInboundGroupSession(\n session.senderKey,\n session.sessionId,\n session.sessionData!,\n );\n sessionData.algorithm = MEGOLM_ALGORITHM;\n\n const forwardedCount = (sessionData.forwarding_curve25519_key_chain || []).length;\n\n const userId = this.baseApis.crypto!.deviceList.getUserByIdentityKey(MEGOLM_ALGORITHM, session.senderKey);\n const device =\n this.baseApis.crypto!.deviceList.getDeviceByIdentityKey(MEGOLM_ALGORITHM, session.senderKey) ??\n undefined;\n const verified = this.baseApis.crypto!.checkDeviceInfoTrust(userId!, device).isVerified();\n\n safeSet(rooms[roomId][\"sessions\"], session.sessionId, {\n first_message_index: sessionData.first_known_index,\n forwarded_count: forwardedCount,\n is_verified: verified,\n session_data: await this.algorithm!.encryptSession(sessionData),\n });\n }\n\n await this.baseApis.sendKeyBackup(undefined, undefined, this.backupInfo!.version, { rooms });\n\n await this.baseApis.crypto!.cryptoStore.unmarkSessionsNeedingBackup(sessions);\n remaining = await this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n this.baseApis.crypto!.emit(CryptoEvent.KeyBackupSessionsRemaining, remaining);\n\n return sessions.length;\n }\n\n public async backupGroupSession(senderKey: string, sessionId: string): Promise<void> {\n await this.baseApis.crypto!.cryptoStore.markSessionsNeedingBackup([\n {\n senderKey: senderKey,\n sessionId: sessionId,\n },\n ]);\n\n if (this.backupInfo) {\n // don't wait for this to complete: it will delay so\n // happens in the background\n this.scheduleKeyBackupSend();\n }\n // if this.backupInfo is not set, then the keys will be backed up when\n // this.enableKeyBackup is called\n }\n\n /**\n * Marks all group sessions as needing to be backed up and schedules them to\n * upload in the background as soon as possible.\n */\n public async scheduleAllGroupSessionsForBackup(): Promise<void> {\n await this.flagAllGroupSessionsForBackup();\n\n // Schedule keys to upload in the background as soon as possible.\n this.scheduleKeyBackupSend(0 /* maxDelay */);\n }\n\n /**\n * Marks all group sessions as needing to be backed up without scheduling\n * them to upload in the background.\n * @returns Promise which resolves to the number of sessions now requiring a backup\n * (which will be equal to the number of sessions in the store).\n */\n public async flagAllGroupSessionsForBackup(): Promise<number> {\n await this.baseApis.crypto!.cryptoStore.doTxn(\n \"readwrite\",\n [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS, IndexedDBCryptoStore.STORE_BACKUP],\n (txn) => {\n this.baseApis.crypto!.cryptoStore.getAllEndToEndInboundGroupSessions(txn, (session) => {\n if (session !== null) {\n this.baseApis.crypto!.cryptoStore.markSessionsNeedingBackup([session], txn);\n }\n });\n },\n );\n\n const remaining = await this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n this.baseApis.emit(CryptoEvent.KeyBackupSessionsRemaining, remaining);\n return remaining;\n }\n\n /**\n * Counts the number of end to end session keys that are waiting to be backed up\n * @returns Promise which resolves to the number of sessions requiring backup\n */\n public countSessionsNeedingBackup(): Promise<number> {\n return this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n }\n}\n\nexport class Curve25519 implements BackupAlgorithm {\n public static algorithmName = \"m.megolm_backup.v1.curve25519-aes-sha2\";\n\n public constructor(\n public authData: ICurve25519AuthData,\n private publicKey: any, // FIXME: PkEncryption\n private getKey: () => Promise<Uint8Array>,\n ) {}\n\n public static async init(authData: AuthData, getKey: () => Promise<Uint8Array>): Promise<Curve25519> {\n if (!authData || !(\"public_key\" in authData)) {\n throw new Error(\"auth_data missing required information\");\n }\n const publicKey = new globalThis.Olm.PkEncryption();\n publicKey.set_recipient_key(authData.public_key);\n return new Curve25519(authData as ICurve25519AuthData, publicKey, getKey);\n }\n\n public static async prepare(key?: string | Uint8Array | null): Promise<[Uint8Array, AuthData]> {\n const decryption = new globalThis.Olm.PkDecryption();\n try {\n const authData: Partial<ICurve25519AuthData> = {};\n if (!key) {\n authData.public_key = decryption.generate_key();\n } else if (key instanceof Uint8Array) {\n authData.public_key = decryption.init_with_private_key(key);\n } else {\n const derivation = await keyFromPassphrase(key);\n authData.private_key_salt = derivation.salt;\n authData.private_key_iterations = derivation.iterations;\n authData.public_key = decryption.init_with_private_key(derivation.key);\n }\n const publicKey = new globalThis.Olm.PkEncryption();\n publicKey.set_recipient_key(authData.public_key);\n\n return [decryption.get_private_key(), authData as AuthData];\n } finally {\n decryption.free();\n }\n }\n\n public static checkBackupVersion(info: IKeyBackupInfo): void {\n if (!(\"public_key\" in info.auth_data)) {\n throw new Error(\"Invalid backup data returned\");\n }\n }\n\n public get untrusted(): boolean {\n return true;\n }\n\n public async encryptSession(data: Record<string, any>): Promise<Curve25519SessionData> {\n const plainText: Record<string, any> = Object.assign({}, data);\n delete plainText.session_id;\n delete plainText.room_id;\n delete plainText.first_known_index;\n return this.publicKey.encrypt(JSON.stringify(plainText));\n }\n\n public async decryptSessions(\n sessions: Record<string, IKeyBackupSession<Curve25519SessionData>>,\n ): Promise<IMegolmSessionData[]> {\n const privKey = await this.getKey();\n const decryption = new globalThis.Olm.PkDecryption();\n try {\n const backupPubKey = decryption.init_with_private_key(privKey);\n\n if (backupPubKey !== this.authData.public_key) {\n throw new MatrixError({ errcode: MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY });\n }\n\n const keys: IMegolmSessionData[] = [];\n\n for (const [sessionId, sessionData] of Object.entries(sessions)) {\n try {\n const decrypted = JSON.parse(\n decryption.decrypt(\n sessionData.session_data.ephemeral,\n sessionData.session_data.mac,\n sessionData.session_data.ciphertext,\n ),\n );\n decrypted.session_id = sessionId;\n keys.push(decrypted);\n } catch (e) {\n logger.log(\"Failed to decrypt megolm session from backup\", e, sessionData);\n }\n }\n return keys;\n } finally {\n decryption.free();\n }\n }\n\n public async keyMatches(key: Uint8Array): Promise<boolean> {\n const decryption = new globalThis.Olm.PkDecryption();\n let pubKey: string;\n try {\n pubKey = decryption.init_with_private_key(key);\n } finally {\n decryption.free();\n }\n\n return pubKey === this.authData.public_key;\n }\n\n public free(): void {\n this.publicKey.free();\n }\n}\n\nfunction randomBytes(size: number): Uint8Array {\n const buf = new Uint8Array(size);\n globalThis.crypto.getRandomValues(buf);\n return buf;\n}\n\nconst UNSTABLE_MSC3270_NAME = new UnstableValue(\n \"m.megolm_backup.v1.aes-hmac-sha2\",\n \"org.matrix.msc3270.v1.aes-hmac-sha2\",\n);\n\nexport class Aes256 implements BackupAlgorithm {\n public static algorithmName = UNSTABLE_MSC3270_NAME.name;\n\n public constructor(\n public readonly authData: IAes256AuthData,\n private readonly key: Uint8Array,\n ) {}\n\n public static async init(authData: IAes256AuthData, getKey: () => Promise<Uint8Array>): Promise<Aes256> {\n if (!authData) {\n throw new Error(\"auth_data missing\");\n }\n const key = await getKey();\n if (authData.mac) {\n const { mac } = await calculateKeyCheck(key, authData.iv);\n if (authData.mac.replace(/=+$/g, \"\") !== mac.replace(/=+/g, \"\")) {\n throw new Error(\"Key does not match\");\n }\n }\n return new Aes256(authData, key);\n }\n\n public static async prepare(key?: string | Uint8Array | null): Promise<[Uint8Array, AuthData]> {\n let outKey: Uint8Array;\n const authData: Partial<IAes256AuthData> = {};\n if (!key) {\n outKey = randomBytes(32);\n } else if (key instanceof Uint8Array) {\n outKey = new Uint8Array(key);\n } else {\n const derivation = await keyFromPassphrase(key);\n authData.private_key_salt = derivation.salt;\n authData.private_key_iterations = derivation.iterations;\n outKey = derivation.key;\n }\n\n const { iv, mac } = await calculateKeyCheck(outKey);\n authData.iv = iv;\n authData.mac = mac;\n\n return [outKey, authData as AuthData];\n }\n\n public static checkBackupVersion(info: IKeyBackupInfo): void {\n if (!(\"iv\" in info.auth_data && \"mac\" in info.auth_data)) {\n throw new Error(\"Invalid backup data returned\");\n }\n }\n\n public get untrusted(): boolean {\n return false;\n }\n\n public encryptSession(data: Record<string, any>): Promise<AESEncryptedSecretStoragePayload> {\n const plainText: Record<string, any> = Object.assign({}, data);\n delete plainText.session_id;\n delete plainText.room_id;\n delete plainText.first_known_index;\n return encryptAESSecretStorageItem(JSON.stringify(plainText), this.key, data.session_id);\n }\n\n public async decryptSessions(\n sessions: Record<string, IKeyBackupSession<AESEncryptedSecretStoragePayload>>,\n ): Promise<IMegolmSessionData[]> {\n const keys: IMegolmSessionData[] = [];\n\n for (const [sessionId, sessionData] of Object.entries(sessions)) {\n try {\n const decrypted = JSON.parse(\n await decryptAESSecretStorageItem(sessionData.session_data, this.key, sessionId),\n );\n decrypted.session_id = sessionId;\n keys.push(decrypted);\n } catch (e) {\n logger.log(\"Failed to decrypt megolm session from backup\", e, sessionData);\n }\n }\n return keys;\n }\n\n public async keyMatches(key: Uint8Array): Promise<boolean> {\n if (this.authData.mac) {\n const { mac } = await calculateKeyCheck(key, this.authData.iv);\n return this.authData.mac.replace(/=+$/g, \"\") === mac.replace(/=+/g, \"\");\n } else {\n // if we have no information, we have to assume the key is right\n return true;\n }\n }\n\n public free(): void {\n this.key.fill(0);\n }\n}\n\nexport const algorithmsByName: Record<string, BackupAlgorithmClass> = {\n [Curve25519.algorithmName]: Curve25519,\n [Aes256.algorithmName]: Aes256,\n};\n\n// the linter doesn't like this but knip does\n// eslint-disable-next-line tsdoc/syntax\n/** @alias */\nexport const DefaultAlgorithm: BackupAlgorithmClass = Curve25519;\n\n/**\n * Map a legacy {@link TrustInfo} into a new-style {@link BackupTrustInfo}.\n *\n * @param trustInfo - trustInfo to convert\n */\nexport function backupTrustInfoFromLegacyTrustInfo(trustInfo: TrustInfo): BackupTrustInfo {\n return {\n trusted: trustInfo.usable,\n matchesDecryptionKey: trustInfo.trusted_locally ?? false,\n };\n}\n\n/**\n * Implementation of {@link BackupDecryptor} for the libolm crypto backend.\n */\nexport class LibOlmBackupDecryptor implements BackupDecryptor {\n private algorithm: BackupAlgorithm;\n public readonly sourceTrusted: boolean;\n\n public constructor(algorithm: BackupAlgorithm) {\n this.algorithm = algorithm;\n this.sourceTrusted = !algorithm.untrusted;\n }\n\n /**\n * Implements {@link BackupDecryptor#free}\n */\n public free(): void {\n this.algorithm.free();\n }\n\n /**\n * Implements {@link BackupDecryptor#decryptSessions}\n */\n public async decryptSessions(\n sessions: Record<string, IKeyBackupSession<Curve25519SessionData>>,\n ): Promise<IMegolmSessionData[]> {\n return await this.algorithm.decryptSessions(sessions);\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA,SAASA,YAAY,QAAQ,cAAc;AAC3C,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,aAAa;AAG/D,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,SAAS,EAAEC,OAAO,EAAEC,KAAK,QAAQ,aAAa;AACvD,SAASC,oBAAoB,QAAQ,mCAAmC;AAQxE,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SA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hE;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkD,kCAAkCA,CAACvK,SAAoB,EAAmB;EAAA,IAAAwK,qBAAA;EACtF,OAAO;IACHC,OAAO,EAAEzK,SAAS,CAACE,MAAM;IACzBwK,oBAAoB,GAAAF,qBAAA,GAAExK,SAAS,CAACkB,eAAe,cAAAsJ,qBAAA,cAAAA,qBAAA,GAAI;EACvD,CAAC;AACL;;AAEA;AACA;AACA;AACA,OAAO,MAAMG,qBAAqB,CAA4B;EAInD5O,WAAWA,CAACc,SAA0B,EAAE;IAAAX,eAAA;IAAAA,eAAA;IAC3C,IAAI,CAACW,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAAC+N,aAAa,GAAG,CAAC/N,SAAS,CAAC0L,SAAS;EAC7C;;EAEA;AACJ;AACA;EACWlL,IAAIA,CAAA,EAAS;IAChB,IAAI,CAACR,SAAS,CAACQ,IAAI,CAAC,CAAC;EACzB;;EAEA;AACJ;AACA;EACiBwL,eAAeA,CACxBhE,QAAkE,EACrC;IAAA,IAAAgG,OAAA;IAAA,OAAAzN,iBAAA;MAC7B,aAAayN,OAAI,CAAChO,SAAS,CAACgM,eAAe,CAAChE,QAAQ,CAAC;IAAC;EAC1D;AACJ","ignoreList":[]}
|
package/lib/crypto/crypto.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto/crypto.ts"],"names":[],"mappings":"AAgBA,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAG"}
|
package/lib/crypto/crypto.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2022 The Matrix.org Foundation C.I.C.
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
|
-
/** @deprecated this is a no-op and should no longer be called. */
|
18
|
-
export function setCrypto(_crypto) {}
|
19
|
-
//# sourceMappingURL=crypto.js.map
|
package/lib/crypto/crypto.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"crypto.js","names":["setCrypto","_crypto"],"sources":["../../src/crypto/crypto.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\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/** @deprecated this is a no-op and should no longer be called. */\nexport function setCrypto(_crypto: Crypto): void {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,SAASA,SAASA,CAACC,OAAe,EAAQ,CAAC","ignoreList":[]}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { Crypto } from "./index.ts";
|
2
|
-
import { SecretStorageKeyDescription } from "../secret-storage.ts";
|
3
|
-
export interface IDehydratedDevice {
|
4
|
-
device_id: string;
|
5
|
-
device_data: SecretStorageKeyDescription & {
|
6
|
-
algorithm: string;
|
7
|
-
account: string;
|
8
|
-
};
|
9
|
-
}
|
10
|
-
export interface IDehydratedDeviceKeyInfo {
|
11
|
-
passphrase?: string;
|
12
|
-
}
|
13
|
-
export declare const DEHYDRATION_ALGORITHM = "org.matrix.msc2697.v1.olm.libolm_pickle";
|
14
|
-
export declare class DehydrationManager {
|
15
|
-
private readonly crypto;
|
16
|
-
private inProgress;
|
17
|
-
private timeoutId;
|
18
|
-
private key?;
|
19
|
-
private keyInfo?;
|
20
|
-
private deviceDisplayName?;
|
21
|
-
constructor(crypto: Crypto);
|
22
|
-
getDehydrationKeyFromCache(): Promise<void>;
|
23
|
-
/** set the key, and queue periodic dehydration to the server in the background */
|
24
|
-
setKeyAndQueueDehydration(key: Uint8Array, keyInfo?: {
|
25
|
-
[props: string]: any;
|
26
|
-
}, deviceDisplayName?: string): Promise<void>;
|
27
|
-
setKey(key: Uint8Array, keyInfo?: {
|
28
|
-
[props: string]: any;
|
29
|
-
}, deviceDisplayName?: string): Promise<boolean | undefined>;
|
30
|
-
/** returns the device id of the newly created dehydrated device */
|
31
|
-
dehydrateDevice(): Promise<string | undefined>;
|
32
|
-
stop(): void;
|
33
|
-
}
|
34
|
-
//# sourceMappingURL=dehydration.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"dehydration.d.ts","sourceRoot":"","sources":["../../src/crypto/dehydration.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAInE,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,2BAA2B,GAAG;QAEvC,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC;CACL;AAED,MAAM,WAAW,wBAAwB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,qBAAqB,4CAA4C,CAAC;AAI/E,qBAAa,kBAAkB;IAOR,OAAO,CAAC,QAAQ,CAAC,MAAM;IAN1C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,GAAG,CAAC,CAAa;IACzB,OAAO,CAAC,OAAO,CAAC,CAA2B;IAC3C,OAAO,CAAC,iBAAiB,CAAC,CAAS;gBAEC,MAAM,EAAE,MAAM;IAI3C,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBlD,kFAAkF;IACrE,yBAAyB,CAClC,GAAG,EAAE,UAAU,EACf,OAAO,GAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO,EACtC,iBAAiB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,IAAI,CAAC;IAQH,MAAM,CACf,GAAG,EAAE,UAAU,EACf,OAAO,GAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO,EACtC,iBAAiB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAkC/B,mEAAmE;IACtD,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAuIpD,IAAI,IAAI,IAAI;CAMtB"}
|
@@ -1,252 +0,0 @@
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
/*
|
4
|
-
Copyright 2020-2021 The Matrix.org Foundation C.I.C.
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
*/
|
18
|
-
|
19
|
-
import anotherjson from "another-json";
|
20
|
-
import { decodeBase64, encodeBase64 } from "../base64.js";
|
21
|
-
import { IndexedDBCryptoStore } from "../crypto/store/indexeddb-crypto-store.js";
|
22
|
-
import { logger } from "../logger.js";
|
23
|
-
import { Method } from "../http-api/index.js";
|
24
|
-
import decryptAESSecretStorageItem from "../utils/decryptAESSecretStorageItem.js";
|
25
|
-
import encryptAESSecretStorageItem from "../utils/encryptAESSecretStorageItem.js";
|
26
|
-
export var DEHYDRATION_ALGORITHM = "org.matrix.msc2697.v1.olm.libolm_pickle";
|
27
|
-
var oneweek = 7 * 24 * 60 * 60 * 1000;
|
28
|
-
export class DehydrationManager {
|
29
|
-
constructor(crypto) {
|
30
|
-
this.crypto = crypto;
|
31
|
-
_defineProperty(this, "inProgress", false);
|
32
|
-
_defineProperty(this, "timeoutId", void 0);
|
33
|
-
_defineProperty(this, "key", void 0);
|
34
|
-
_defineProperty(this, "keyInfo", void 0);
|
35
|
-
_defineProperty(this, "deviceDisplayName", void 0);
|
36
|
-
this.getDehydrationKeyFromCache();
|
37
|
-
}
|
38
|
-
getDehydrationKeyFromCache() {
|
39
|
-
var _this = this;
|
40
|
-
return this.crypto.cryptoStore.doTxn("readonly", [IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
|
41
|
-
this.crypto.cryptoStore.getSecretStorePrivateKey(txn, /*#__PURE__*/function () {
|
42
|
-
var _ref = _asyncToGenerator(function* (result) {
|
43
|
-
if (result) {
|
44
|
-
var {
|
45
|
-
key,
|
46
|
-
keyInfo,
|
47
|
-
deviceDisplayName,
|
48
|
-
time
|
49
|
-
} = result;
|
50
|
-
var pickleKey = Buffer.from(_this.crypto.olmDevice.pickleKey);
|
51
|
-
var decrypted = yield decryptAESSecretStorageItem(key, pickleKey, DEHYDRATION_ALGORITHM);
|
52
|
-
_this.key = decodeBase64(decrypted);
|
53
|
-
_this.keyInfo = keyInfo;
|
54
|
-
_this.deviceDisplayName = deviceDisplayName;
|
55
|
-
var now = Date.now();
|
56
|
-
var delay = Math.max(1, time + oneweek - now);
|
57
|
-
_this.timeoutId = globalThis.setTimeout(_this.dehydrateDevice.bind(_this), delay);
|
58
|
-
}
|
59
|
-
});
|
60
|
-
return function (_x) {
|
61
|
-
return _ref.apply(this, arguments);
|
62
|
-
};
|
63
|
-
}(), "dehydration");
|
64
|
-
});
|
65
|
-
}
|
66
|
-
|
67
|
-
/** set the key, and queue periodic dehydration to the server in the background */
|
68
|
-
setKeyAndQueueDehydration(key) {
|
69
|
-
var _arguments = arguments,
|
70
|
-
_this2 = this;
|
71
|
-
return _asyncToGenerator(function* () {
|
72
|
-
var keyInfo = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
|
73
|
-
var deviceDisplayName = _arguments.length > 2 ? _arguments[2] : undefined;
|
74
|
-
var matches = yield _this2.setKey(key, keyInfo, deviceDisplayName);
|
75
|
-
if (!matches) {
|
76
|
-
// start dehydration in the background
|
77
|
-
_this2.dehydrateDevice();
|
78
|
-
}
|
79
|
-
})();
|
80
|
-
}
|
81
|
-
setKey(key) {
|
82
|
-
var _arguments2 = arguments,
|
83
|
-
_this3 = this;
|
84
|
-
return _asyncToGenerator(function* () {
|
85
|
-
var keyInfo = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : {};
|
86
|
-
var deviceDisplayName = _arguments2.length > 2 ? _arguments2[2] : undefined;
|
87
|
-
if (!key) {
|
88
|
-
// unsetting the key -- cancel any pending dehydration task
|
89
|
-
if (_this3.timeoutId) {
|
90
|
-
globalThis.clearTimeout(_this3.timeoutId);
|
91
|
-
_this3.timeoutId = undefined;
|
92
|
-
}
|
93
|
-
// clear storage
|
94
|
-
yield _this3.crypto.cryptoStore.doTxn("readwrite", [IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
|
95
|
-
_this3.crypto.cryptoStore.storeSecretStorePrivateKey(txn, "dehydration", null);
|
96
|
-
});
|
97
|
-
_this3.key = undefined;
|
98
|
-
_this3.keyInfo = undefined;
|
99
|
-
return;
|
100
|
-
}
|
101
|
-
|
102
|
-
// Check to see if it's the same key as before. If it's different,
|
103
|
-
// dehydrate a new device. If it's the same, we can keep the same
|
104
|
-
// device. (Assume that keyInfo and deviceDisplayName will be the
|
105
|
-
// same if the key is the same.)
|
106
|
-
var matches = !!_this3.key && key.length == _this3.key.length;
|
107
|
-
for (var i = 0; matches && i < key.length; i++) {
|
108
|
-
if (key[i] != _this3.key[i]) {
|
109
|
-
matches = false;
|
110
|
-
}
|
111
|
-
}
|
112
|
-
if (!matches) {
|
113
|
-
_this3.key = key;
|
114
|
-
_this3.keyInfo = keyInfo;
|
115
|
-
_this3.deviceDisplayName = deviceDisplayName;
|
116
|
-
}
|
117
|
-
return matches;
|
118
|
-
})();
|
119
|
-
}
|
120
|
-
|
121
|
-
/** returns the device id of the newly created dehydrated device */
|
122
|
-
dehydrateDevice() {
|
123
|
-
var _this4 = this;
|
124
|
-
return _asyncToGenerator(function* () {
|
125
|
-
if (_this4.inProgress) {
|
126
|
-
logger.log("Dehydration already in progress -- not starting new dehydration");
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
_this4.inProgress = true;
|
130
|
-
if (_this4.timeoutId) {
|
131
|
-
globalThis.clearTimeout(_this4.timeoutId);
|
132
|
-
_this4.timeoutId = undefined;
|
133
|
-
}
|
134
|
-
try {
|
135
|
-
var pickleKey = Buffer.from(_this4.crypto.olmDevice.pickleKey);
|
136
|
-
|
137
|
-
// update the crypto store with the timestamp
|
138
|
-
var key = yield encryptAESSecretStorageItem(encodeBase64(_this4.key), pickleKey, DEHYDRATION_ALGORITHM);
|
139
|
-
yield _this4.crypto.cryptoStore.doTxn("readwrite", [IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
|
140
|
-
_this4.crypto.cryptoStore.storeSecretStorePrivateKey(txn, "dehydration", {
|
141
|
-
keyInfo: _this4.keyInfo,
|
142
|
-
key,
|
143
|
-
deviceDisplayName: _this4.deviceDisplayName,
|
144
|
-
time: Date.now()
|
145
|
-
});
|
146
|
-
});
|
147
|
-
logger.log("Attempting to dehydrate device");
|
148
|
-
logger.log("Creating account");
|
149
|
-
// create the account and all the necessary keys
|
150
|
-
var account = new globalThis.Olm.Account();
|
151
|
-
account.create();
|
152
|
-
var e2eKeys = JSON.parse(account.identity_keys());
|
153
|
-
var maxKeys = account.max_number_of_one_time_keys();
|
154
|
-
// FIXME: generate in small batches?
|
155
|
-
account.generate_one_time_keys(maxKeys / 2);
|
156
|
-
account.generate_fallback_key();
|
157
|
-
var otks = JSON.parse(account.one_time_keys());
|
158
|
-
var fallbacks = JSON.parse(account.fallback_key());
|
159
|
-
account.mark_keys_as_published();
|
160
|
-
|
161
|
-
// dehydrate the account and store it on the server
|
162
|
-
var pickledAccount = account.pickle(new Uint8Array(_this4.key));
|
163
|
-
var deviceData = {
|
164
|
-
algorithm: DEHYDRATION_ALGORITHM,
|
165
|
-
account: pickledAccount
|
166
|
-
};
|
167
|
-
if (_this4.keyInfo.passphrase) {
|
168
|
-
deviceData.passphrase = _this4.keyInfo.passphrase;
|
169
|
-
}
|
170
|
-
logger.log("Uploading account to server");
|
171
|
-
// eslint-disable-next-line camelcase
|
172
|
-
var dehydrateResult = yield _this4.crypto.baseApis.http.authedRequest(Method.Put, "/dehydrated_device", undefined, {
|
173
|
-
device_data: deviceData,
|
174
|
-
initial_device_display_name: _this4.deviceDisplayName
|
175
|
-
}, {
|
176
|
-
prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
|
177
|
-
});
|
178
|
-
|
179
|
-
// send the keys to the server
|
180
|
-
var deviceId = dehydrateResult.device_id;
|
181
|
-
logger.log("Preparing device keys", deviceId);
|
182
|
-
var deviceKeys = {
|
183
|
-
algorithms: _this4.crypto.supportedAlgorithms,
|
184
|
-
device_id: deviceId,
|
185
|
-
user_id: _this4.crypto.userId,
|
186
|
-
keys: {
|
187
|
-
["ed25519:".concat(deviceId)]: e2eKeys.ed25519,
|
188
|
-
["curve25519:".concat(deviceId)]: e2eKeys.curve25519
|
189
|
-
}
|
190
|
-
};
|
191
|
-
var deviceSignature = account.sign(anotherjson.stringify(deviceKeys));
|
192
|
-
deviceKeys.signatures = {
|
193
|
-
[_this4.crypto.userId]: {
|
194
|
-
["ed25519:".concat(deviceId)]: deviceSignature
|
195
|
-
}
|
196
|
-
};
|
197
|
-
if (_this4.crypto.crossSigningInfo.getId("self_signing")) {
|
198
|
-
yield _this4.crypto.crossSigningInfo.signObject(deviceKeys, "self_signing");
|
199
|
-
}
|
200
|
-
logger.log("Preparing one-time keys");
|
201
|
-
var oneTimeKeys = {};
|
202
|
-
for (var [keyId, _key] of Object.entries(otks.curve25519)) {
|
203
|
-
var k = {
|
204
|
-
key: _key
|
205
|
-
};
|
206
|
-
var signature = account.sign(anotherjson.stringify(k));
|
207
|
-
k.signatures = {
|
208
|
-
[_this4.crypto.userId]: {
|
209
|
-
["ed25519:".concat(deviceId)]: signature
|
210
|
-
}
|
211
|
-
};
|
212
|
-
oneTimeKeys["signed_curve25519:".concat(keyId)] = k;
|
213
|
-
}
|
214
|
-
logger.log("Preparing fallback keys");
|
215
|
-
var fallbackKeys = {};
|
216
|
-
for (var [_keyId, _key2] of Object.entries(fallbacks.curve25519)) {
|
217
|
-
var _k = {
|
218
|
-
key: _key2,
|
219
|
-
fallback: true
|
220
|
-
};
|
221
|
-
var _signature = account.sign(anotherjson.stringify(_k));
|
222
|
-
_k.signatures = {
|
223
|
-
[_this4.crypto.userId]: {
|
224
|
-
["ed25519:".concat(deviceId)]: _signature
|
225
|
-
}
|
226
|
-
};
|
227
|
-
fallbackKeys["signed_curve25519:".concat(_keyId)] = _k;
|
228
|
-
}
|
229
|
-
logger.log("Uploading keys to server");
|
230
|
-
yield _this4.crypto.baseApis.http.authedRequest(Method.Post, "/keys/upload/" + encodeURI(deviceId), undefined, {
|
231
|
-
"device_keys": deviceKeys,
|
232
|
-
"one_time_keys": oneTimeKeys,
|
233
|
-
"org.matrix.msc2732.fallback_keys": fallbackKeys
|
234
|
-
});
|
235
|
-
logger.log("Done dehydrating");
|
236
|
-
|
237
|
-
// dehydrate again in a week
|
238
|
-
_this4.timeoutId = globalThis.setTimeout(_this4.dehydrateDevice.bind(_this4), oneweek);
|
239
|
-
return deviceId;
|
240
|
-
} finally {
|
241
|
-
_this4.inProgress = false;
|
242
|
-
}
|
243
|
-
})();
|
244
|
-
}
|
245
|
-
stop() {
|
246
|
-
if (this.timeoutId) {
|
247
|
-
globalThis.clearTimeout(this.timeoutId);
|
248
|
-
this.timeoutId = undefined;
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}
|
252
|
-
//# sourceMappingURL=dehydration.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"dehydration.js","names":["anotherjson","decodeBase64","encodeBase64","IndexedDBCryptoStore","logger","Method","decryptAESSecretStorageItem","encryptAESSecretStorageItem","DEHYDRATION_ALGORITHM","oneweek","DehydrationManager","constructor","crypto","_defineProperty","getDehydrationKeyFromCache","_this","cryptoStore","doTxn","STORE_ACCOUNT","txn","getSecretStorePrivateKey","_ref","_asyncToGenerator","result","key","keyInfo","deviceDisplayName","time","pickleKey","Buffer","from","olmDevice","decrypted","now","Date","delay","Math","max","timeoutId","globalThis","setTimeout","dehydrateDevice","bind","_x","apply","arguments","setKeyAndQueueDehydration","_arguments","_this2","length","undefined","matches","setKey","_arguments2","_this3","clearTimeout","storeSecretStorePrivateKey","i","_this4","inProgress","log","account","Olm","Account","create","e2eKeys","JSON","parse","identity_keys","maxKeys","max_number_of_one_time_keys","generate_one_time_keys","generate_fallback_key","otks","one_time_keys","fallbacks","fallback_key","mark_keys_as_published","pickledAccount","pickle","Uint8Array","deviceData","algorithm","passphrase","dehydrateResult","baseApis","http","authedRequest","Put","device_data","initial_device_display_name","prefix","deviceId","device_id","deviceKeys","algorithms","supportedAlgorithms","user_id","userId","keys","concat","ed25519","curve25519","deviceSignature","sign","stringify","signatures","crossSigningInfo","getId","signObject","oneTimeKeys","keyId","Object","entries","k","signature","fallbackKeys","fallback","Post","encodeURI","stop"],"sources":["../../src/crypto/dehydration.ts"],"sourcesContent":["/*\nCopyright 2020-2021 The Matrix.org Foundation C.I.C.\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\nimport anotherjson from \"another-json\";\n\nimport type { IDeviceKeys, IOneTimeKey } from \"../@types/crypto.ts\";\nimport { decodeBase64, encodeBase64 } from \"../base64.ts\";\nimport { IndexedDBCryptoStore } from \"../crypto/store/indexeddb-crypto-store.ts\";\nimport { logger } from \"../logger.ts\";\nimport { Crypto } from \"./index.ts\";\nimport { Method } from \"../http-api/index.ts\";\nimport { SecretStorageKeyDescription } from \"../secret-storage.ts\";\nimport decryptAESSecretStorageItem from \"../utils/decryptAESSecretStorageItem.ts\";\nimport encryptAESSecretStorageItem from \"../utils/encryptAESSecretStorageItem.ts\";\n\nexport interface IDehydratedDevice {\n device_id: string; // eslint-disable-line camelcase\n device_data: SecretStorageKeyDescription & {\n // eslint-disable-line camelcase\n algorithm: string;\n account: string; // pickle\n };\n}\n\nexport interface IDehydratedDeviceKeyInfo {\n passphrase?: string;\n}\n\nexport const DEHYDRATION_ALGORITHM = \"org.matrix.msc2697.v1.olm.libolm_pickle\";\n\nconst oneweek = 7 * 24 * 60 * 60 * 1000;\n\nexport class DehydrationManager {\n private inProgress = false;\n private timeoutId: any;\n private key?: Uint8Array;\n private keyInfo?: { [props: string]: any };\n private deviceDisplayName?: string;\n\n public constructor(private readonly crypto: Crypto) {\n this.getDehydrationKeyFromCache();\n }\n\n public getDehydrationKeyFromCache(): Promise<void> {\n return this.crypto.cryptoStore.doTxn(\"readonly\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n this.crypto.cryptoStore.getSecretStorePrivateKey(\n txn,\n async (result) => {\n if (result) {\n const { key, keyInfo, deviceDisplayName, time } = result;\n const pickleKey = Buffer.from(this.crypto.olmDevice.pickleKey);\n const decrypted = await decryptAESSecretStorageItem(key, pickleKey, DEHYDRATION_ALGORITHM);\n this.key = decodeBase64(decrypted);\n this.keyInfo = keyInfo;\n this.deviceDisplayName = deviceDisplayName;\n const now = Date.now();\n const delay = Math.max(1, time + oneweek - now);\n this.timeoutId = globalThis.setTimeout(this.dehydrateDevice.bind(this), delay);\n }\n },\n \"dehydration\",\n );\n });\n }\n\n /** set the key, and queue periodic dehydration to the server in the background */\n public async setKeyAndQueueDehydration(\n key: Uint8Array,\n keyInfo: { [props: string]: any } = {},\n deviceDisplayName?: string,\n ): Promise<void> {\n const matches = await this.setKey(key, keyInfo, deviceDisplayName);\n if (!matches) {\n // start dehydration in the background\n this.dehydrateDevice();\n }\n }\n\n public async setKey(\n key: Uint8Array,\n keyInfo: { [props: string]: any } = {},\n deviceDisplayName?: string,\n ): Promise<boolean | undefined> {\n if (!key) {\n // unsetting the key -- cancel any pending dehydration task\n if (this.timeoutId) {\n globalThis.clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n // clear storage\n await this.crypto.cryptoStore.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n this.crypto.cryptoStore.storeSecretStorePrivateKey(txn, \"dehydration\", null);\n });\n this.key = undefined;\n this.keyInfo = undefined;\n return;\n }\n\n // Check to see if it's the same key as before. If it's different,\n // dehydrate a new device. If it's the same, we can keep the same\n // device. (Assume that keyInfo and deviceDisplayName will be the\n // same if the key is the same.)\n let matches: boolean = !!this.key && key.length == this.key.length;\n for (let i = 0; matches && i < key.length; i++) {\n if (key[i] != this.key![i]) {\n matches = false;\n }\n }\n if (!matches) {\n this.key = key;\n this.keyInfo = keyInfo;\n this.deviceDisplayName = deviceDisplayName;\n }\n return matches;\n }\n\n /** returns the device id of the newly created dehydrated device */\n public async dehydrateDevice(): Promise<string | undefined> {\n if (this.inProgress) {\n logger.log(\"Dehydration already in progress -- not starting new dehydration\");\n return;\n }\n this.inProgress = true;\n if (this.timeoutId) {\n globalThis.clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n try {\n const pickleKey = Buffer.from(this.crypto.olmDevice.pickleKey);\n\n // update the crypto store with the timestamp\n const key = await encryptAESSecretStorageItem(encodeBase64(this.key!), pickleKey, DEHYDRATION_ALGORITHM);\n await this.crypto.cryptoStore.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n this.crypto.cryptoStore.storeSecretStorePrivateKey(txn, \"dehydration\", {\n keyInfo: this.keyInfo,\n key,\n deviceDisplayName: this.deviceDisplayName!,\n time: Date.now(),\n });\n });\n logger.log(\"Attempting to dehydrate device\");\n\n logger.log(\"Creating account\");\n // create the account and all the necessary keys\n const account = new globalThis.Olm.Account();\n account.create();\n const e2eKeys = JSON.parse(account.identity_keys());\n\n const maxKeys = account.max_number_of_one_time_keys();\n // FIXME: generate in small batches?\n account.generate_one_time_keys(maxKeys / 2);\n account.generate_fallback_key();\n const otks: Record<string, string> = JSON.parse(account.one_time_keys());\n const fallbacks: Record<string, string> = JSON.parse(account.fallback_key());\n account.mark_keys_as_published();\n\n // dehydrate the account and store it on the server\n const pickledAccount = account.pickle(new Uint8Array(this.key!));\n\n const deviceData: { [props: string]: any } = {\n algorithm: DEHYDRATION_ALGORITHM,\n account: pickledAccount,\n };\n if (this.keyInfo!.passphrase) {\n deviceData.passphrase = this.keyInfo!.passphrase;\n }\n\n logger.log(\"Uploading account to server\");\n // eslint-disable-next-line camelcase\n const dehydrateResult = await this.crypto.baseApis.http.authedRequest<{ device_id: string }>(\n Method.Put,\n \"/dehydrated_device\",\n undefined,\n {\n device_data: deviceData,\n initial_device_display_name: this.deviceDisplayName,\n },\n {\n prefix: \"/_matrix/client/unstable/org.matrix.msc2697.v2\",\n },\n );\n\n // send the keys to the server\n const deviceId = dehydrateResult.device_id;\n logger.log(\"Preparing device keys\", deviceId);\n const deviceKeys: IDeviceKeys = {\n algorithms: this.crypto.supportedAlgorithms,\n device_id: deviceId,\n user_id: this.crypto.userId,\n keys: {\n [`ed25519:${deviceId}`]: e2eKeys.ed25519,\n [`curve25519:${deviceId}`]: e2eKeys.curve25519,\n },\n };\n const deviceSignature = account.sign(anotherjson.stringify(deviceKeys));\n deviceKeys.signatures = {\n [this.crypto.userId]: {\n [`ed25519:${deviceId}`]: deviceSignature,\n },\n };\n if (this.crypto.crossSigningInfo.getId(\"self_signing\")) {\n await this.crypto.crossSigningInfo.signObject(deviceKeys, \"self_signing\");\n }\n\n logger.log(\"Preparing one-time keys\");\n const oneTimeKeys: Record<string, IOneTimeKey> = {};\n for (const [keyId, key] of Object.entries(otks.curve25519)) {\n const k: IOneTimeKey = { key };\n const signature = account.sign(anotherjson.stringify(k));\n k.signatures = {\n [this.crypto.userId]: {\n [`ed25519:${deviceId}`]: signature,\n },\n };\n oneTimeKeys[`signed_curve25519:${keyId}`] = k;\n }\n\n logger.log(\"Preparing fallback keys\");\n const fallbackKeys: Record<string, IOneTimeKey> = {};\n for (const [keyId, key] of Object.entries(fallbacks.curve25519)) {\n const k: IOneTimeKey = { key, fallback: true };\n const signature = account.sign(anotherjson.stringify(k));\n k.signatures = {\n [this.crypto.userId]: {\n [`ed25519:${deviceId}`]: signature,\n },\n };\n fallbackKeys[`signed_curve25519:${keyId}`] = k;\n }\n\n logger.log(\"Uploading keys to server\");\n await this.crypto.baseApis.http.authedRequest(\n Method.Post,\n \"/keys/upload/\" + encodeURI(deviceId),\n undefined,\n {\n \"device_keys\": deviceKeys,\n \"one_time_keys\": oneTimeKeys,\n \"org.matrix.msc2732.fallback_keys\": fallbackKeys,\n },\n );\n logger.log(\"Done dehydrating\");\n\n // dehydrate again in a week\n this.timeoutId = globalThis.setTimeout(this.dehydrateDevice.bind(this), oneweek);\n\n return deviceId;\n } finally {\n this.inProgress = false;\n }\n }\n\n public stop(): void {\n if (this.timeoutId) {\n globalThis.clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,WAAW,MAAM,cAAc;AAGtC,SAASC,YAAY,EAAEC,YAAY,QAAQ,cAAc;AACzD,SAASC,oBAAoB,QAAQ,2CAA2C;AAChF,SAASC,MAAM,QAAQ,cAAc;AAErC,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,OAAOC,2BAA2B,MAAM,yCAAyC;AACjF,OAAOC,2BAA2B,MAAM,yCAAyC;AAejF,OAAO,IAAMC,qBAAqB,GAAG,yCAAyC;AAE9E,IAAMC,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;AAEvC,OAAO,MAAMC,kBAAkB,CAAC;EAOrBC,WAAWA,CAAkBC,MAAc,EAAE;IAAA,KAAhBA,MAAc,GAAdA,MAAc;IAAAC,eAAA,qBAN7B,KAAK;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAOtB,IAAI,CAACC,0BAA0B,CAAC,CAAC;EACrC;EAEOA,0BAA0BA,CAAA,EAAkB;IAAA,IAAAC,KAAA;IAC/C,OAAO,IAAI,CAACH,MAAM,CAACI,WAAW,CAACC,KAAK,CAAC,UAAU,EAAE,CAACd,oBAAoB,CAACe,aAAa,CAAC,EAAGC,GAAG,IAAK;MAC5F,IAAI,CAACP,MAAM,CAACI,WAAW,CAACI,wBAAwB,CAC5CD,GAAG;QAAA,IAAAE,IAAA,GAAAC,iBAAA,CACH,WAAOC,MAAM,EAAK;UACd,IAAIA,MAAM,EAAE;YACR,IAAM;cAAEC,GAAG;cAAEC,OAAO;cAAEC,iBAAiB;cAAEC;YAAK,CAAC,GAAGJ,MAAM;YACxD,IAAMK,SAAS,GAAGC,MAAM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,CAACC,UAAU,CAACkB,MAAI,CAACjB,eAAe,CAACC,IAAI,CAACgB,MAAI,CAAC,EAAEjD,OAAO,CAAC;QAEhF,OAAOmF,QAAQ;MACnB,CAAC,SAAS;QACNlC,MAAI,CAACC,UAAU,GAAG,KAAK;MAC3B;IAAC;EACL;EAEO6D,IAAIA,CAAA,EAAS;IAChB,IAAI,IAAI,CAAClF,SAAS,EAAE;MAChBC,UAAU,CAACgB,YAAY,CAAC,IAAI,CAACjB,SAAS,CAAC;MACvC,IAAI,CAACA,SAAS,GAAGY,SAAS;IAC9B;EACJ;AACJ","ignoreList":[]}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Device } from "../models/device.ts";
|
2
|
-
import { DeviceInfo } from "./deviceinfo.ts";
|
3
|
-
/**
|
4
|
-
* Convert a {@link DeviceInfo} to a {@link Device}.
|
5
|
-
* @param deviceInfo - deviceInfo to convert
|
6
|
-
* @param userId - id of the user that owns the device.
|
7
|
-
*/
|
8
|
-
export declare function deviceInfoToDevice(deviceInfo: DeviceInfo, userId: string): Device;
|
9
|
-
//# sourceMappingURL=device-converter.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"device-converter.d.ts","sourceRoot":"","sources":["../../src/crypto/device-converter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBjF"}
|
@@ -1,42 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Copyright 2023 The Matrix.org Foundation C.I.C.
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
|
-
import { Device } from "../models/device.js";
|
18
|
-
/**
|
19
|
-
* Convert a {@link DeviceInfo} to a {@link Device}.
|
20
|
-
* @param deviceInfo - deviceInfo to convert
|
21
|
-
* @param userId - id of the user that owns the device.
|
22
|
-
*/
|
23
|
-
export function deviceInfoToDevice(deviceInfo, userId) {
|
24
|
-
var keys = new Map(Object.entries(deviceInfo.keys));
|
25
|
-
var displayName = deviceInfo.getDisplayName() || undefined;
|
26
|
-
var signatures = new Map();
|
27
|
-
if (deviceInfo.signatures) {
|
28
|
-
for (var _userId in deviceInfo.signatures) {
|
29
|
-
signatures.set(_userId, new Map(Object.entries(deviceInfo.signatures[_userId])));
|
30
|
-
}
|
31
|
-
}
|
32
|
-
return new Device({
|
33
|
-
deviceId: deviceInfo.deviceId,
|
34
|
-
userId: userId,
|
35
|
-
keys,
|
36
|
-
algorithms: deviceInfo.algorithms,
|
37
|
-
verified: deviceInfo.verified,
|
38
|
-
signatures,
|
39
|
-
displayName
|
40
|
-
});
|
41
|
-
}
|
42
|
-
//# sourceMappingURL=device-converter.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"device-converter.js","names":["Device","deviceInfoToDevice","deviceInfo","userId","keys","Map","Object","entries","displayName","getDisplayName","undefined","signatures","set","deviceId","algorithms","verified"],"sources":["../../src/crypto/device-converter.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\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\nimport { Device } from \"../models/device.ts\";\nimport { DeviceInfo } from \"./deviceinfo.ts\";\n\n/**\n * Convert a {@link DeviceInfo} to a {@link Device}.\n * @param deviceInfo - deviceInfo to convert\n * @param userId - id of the user that owns the device.\n */\nexport function deviceInfoToDevice(deviceInfo: DeviceInfo, userId: string): Device {\n const keys = new Map<string, string>(Object.entries(deviceInfo.keys));\n const displayName = deviceInfo.getDisplayName() || undefined;\n\n const signatures = new Map<string, Map<string, string>>();\n if (deviceInfo.signatures) {\n for (const userId in deviceInfo.signatures) {\n signatures.set(userId, new Map(Object.entries(deviceInfo.signatures[userId])));\n }\n }\n\n return new Device({\n deviceId: deviceInfo.deviceId,\n userId: userId,\n keys,\n algorithms: deviceInfo.algorithms,\n verified: deviceInfo.verified,\n signatures,\n displayName,\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,qBAAqB;AAG5C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,UAAsB,EAAEC,MAAc,EAAU;EAC/E,IAAMC,IAAI,GAAG,IAAIC,GAAG,CAAiBC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACE,IAAI,CAAC,CAAC;EACrE,IAAMI,WAAW,GAAGN,UAAU,CAACO,cAAc,CAAC,CAAC,IAAIC,SAAS;EAE5D,IAAMC,UAAU,GAAG,IAAIN,GAAG,CAA8B,CAAC;EACzD,IAAIH,UAAU,CAACS,UAAU,EAAE;IACvB,KAAK,IAAMR,OAAM,IAAID,UAAU,CAACS,UAAU,EAAE;MACxCA,UAAU,CAACC,GAAG,CAACT,OAAM,EAAE,IAAIE,GAAG,CAACC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACS,UAAU,CAACR,OAAM,CAAC,CAAC,CAAC,CAAC;IAClF;EACJ;EAEA,OAAO,IAAIH,MAAM,CAAC;IACda,QAAQ,EAAEX,UAAU,CAACW,QAAQ;IAC7BV,MAAM,EAAEA,MAAM;IACdC,IAAI;IACJU,UAAU,EAAEZ,UAAU,CAACY,UAAU;IACjCC,QAAQ,EAAEb,UAAU,CAACa,QAAQ;IAC7BJ,UAAU;IACVH;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|