@unwanted/matrix-sdk-mini 34.12.0 → 36.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/git-revision.txt +1 -1
- package/lib/@types/event.d.ts +25 -19
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js +5 -0
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/global.d.js +0 -2
- package/lib/@types/global.d.js.map +1 -1
- package/lib/autodiscovery.d.ts +1 -1
- package/lib/autodiscovery.d.ts.map +1 -1
- package/lib/autodiscovery.js.map +1 -1
- package/lib/base64.d.ts +3 -6
- package/lib/base64.d.ts.map +1 -1
- package/lib/base64.js +43 -36
- package/lib/base64.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 +45 -1306
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +406 -2963
- package/lib/client.js.map +1 -1
- package/lib/digest.d.ts +2 -2
- package/lib/digest.d.ts.map +1 -1
- package/lib/digest.js +2 -2
- package/lib/digest.js.map +1 -1
- package/lib/embedded.d.ts +2 -23
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +82 -209
- 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/feature.d.ts.map +1 -1
- package/lib/feature.js +2 -1
- package/lib/feature.js.map +1 -1
- package/lib/http-api/errors.d.ts +3 -3
- package/lib/http-api/errors.js +3 -3
- package/lib/http-api/errors.js.map +1 -1
- package/lib/http-api/utils.js +2 -2
- package/lib/http-api/utils.js.map +1 -1
- package/lib/matrix.d.ts +0 -25
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -30
- 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-timeline-set.d.ts +6 -10
- package/lib/models/event-timeline-set.d.ts.map +1 -1
- package/lib/models/event-timeline-set.js +28 -36
- package/lib/models/event-timeline-set.js.map +1 -1
- package/lib/models/event-timeline.d.ts +7 -2
- package/lib/models/event-timeline.d.ts.map +1 -1
- package/lib/models/event-timeline.js +9 -30
- package/lib/models/event-timeline.js.map +1 -1
- package/lib/models/event.d.ts +12 -96
- package/lib/models/event.d.ts.map +1 -1
- package/lib/models/event.js +59 -286
- package/lib/models/event.js.map +1 -1
- package/lib/models/invites-ignorer-types.d.ts +27 -0
- package/lib/models/invites-ignorer-types.d.ts.map +1 -0
- package/lib/models/invites-ignorer-types.js +36 -0
- package/lib/models/invites-ignorer-types.js.map +1 -0
- package/lib/models/invites-ignorer.d.ts +2 -26
- package/lib/models/invites-ignorer.d.ts.map +1 -1
- package/lib/models/invites-ignorer.js +2 -27
- package/lib/models/invites-ignorer.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-member.d.ts +6 -1
- package/lib/models/room-member.d.ts.map +1 -1
- package/lib/models/room-member.js +7 -1
- package/lib/models/room-member.js.map +1 -1
- package/lib/models/room-state.d.ts +2 -13
- package/lib/models/room-state.d.ts.map +1 -1
- package/lib/models/room-state.js +12 -56
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room.d.ts +8 -21
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +128 -163
- package/lib/models/room.js.map +1 -1
- package/lib/models/thread.d.ts.map +1 -1
- package/lib/models/thread.js +5 -4
- package/lib/models/thread.js.map +1 -1
- package/lib/oidc/authorize.d.ts +2 -2
- package/lib/oidc/authorize.d.ts.map +1 -1
- package/lib/oidc/authorize.js +5 -5
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/discovery.d.ts +8 -0
- package/lib/oidc/discovery.d.ts.map +1 -1
- package/lib/oidc/discovery.js +22 -11
- package/lib/oidc/discovery.js.map +1 -1
- package/lib/oidc/index.d.ts +3 -4
- package/lib/oidc/index.d.ts.map +1 -1
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +3 -3
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.d.ts.map +1 -1
- package/lib/oidc/tokenRefresher.js +6 -5
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.d.ts +9 -23
- package/lib/oidc/validate.d.ts.map +1 -1
- package/lib/oidc/validate.js +13 -28
- package/lib/oidc/validate.js.map +1 -1
- package/lib/randomstring.d.ts +30 -3
- package/lib/randomstring.d.ts.map +1 -1
- package/lib/randomstring.js +68 -16
- package/lib/randomstring.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts +3 -4
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +55 -102
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.js +9 -6
- package/lib/sliding-sync.js.map +1 -1
- package/lib/store/indexeddb-local-backend.js +4 -2
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb.d.ts +1 -1
- package/lib/store/indexeddb.d.ts.map +1 -1
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/sync-accumulator.d.ts +6 -4
- package/lib/sync-accumulator.d.ts.map +1 -1
- package/lib/sync-accumulator.js +23 -12
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts +10 -13
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +94 -115
- package/lib/sync.js.map +1 -1
- package/lib/testing.d.ts +13 -44
- package/lib/testing.d.ts.map +1 -1
- package/lib/testing.js +36 -99
- 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 +14 -15
- package/src/@types/event.ts +19 -36
- package/src/@types/global.d.ts +21 -4
- package/src/autodiscovery.ts +1 -1
- package/src/base64.ts +38 -40
- package/src/browser-index.ts +0 -11
- package/src/client.ts +175 -3136
- package/src/digest.ts +3 -3
- package/src/embedded.ts +43 -149
- package/src/event-mapper.ts +0 -4
- package/src/feature.ts +1 -0
- package/src/http-api/errors.ts +3 -3
- package/src/http-api/utils.ts +2 -2
- package/src/matrix.ts +0 -41
- package/src/models/MSC3089Branch.ts +0 -3
- package/src/models/event-timeline-set.ts +17 -38
- package/src/models/event-timeline.ts +11 -26
- package/src/models/event.ts +54 -295
- package/src/models/invites-ignorer-types.ts +48 -0
- package/src/models/invites-ignorer.ts +7 -42
- 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-member.ts +16 -1
- package/src/models/room-state.ts +4 -37
- package/src/models/room.ts +34 -69
- package/src/models/thread.ts +4 -3
- package/src/oidc/authorize.ts +7 -7
- package/src/oidc/discovery.ts +16 -10
- package/src/oidc/index.ts +3 -4
- package/src/oidc/register.ts +3 -3
- package/src/oidc/tokenRefresher.ts +3 -2
- package/src/oidc/validate.ts +40 -63
- package/src/randomstring.ts +65 -19
- package/src/sliding-sync-sdk.ts +10 -83
- package/src/sliding-sync.ts +6 -6
- package/src/store/indexeddb-local-backend.ts +2 -2
- package/src/store/indexeddb.ts +1 -1
- package/src/sync-accumulator.ts +33 -16
- package/src/sync.ts +112 -143
- package/src/testing.ts +36 -103
- 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 -1210
- package/lib/crypto/index.d.ts.map +0 -1
- package/lib/crypto/index.js +0 -4101
- 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/matrixrtc/CallMembership.d.ts +0 -66
- package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
- package/lib/matrixrtc/CallMembership.js +0 -197
- package/lib/matrixrtc/CallMembership.js.map +0 -1
- package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
- package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
- package/lib/matrixrtc/LivekitFocus.js +0 -20
- package/lib/matrixrtc/LivekitFocus.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
- package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
- package/lib/matrixrtc/focus.d.ts +0 -10
- package/lib/matrixrtc/focus.d.ts.map +0 -1
- package/lib/matrixrtc/focus.js +0 -1
- package/lib/matrixrtc/focus.js.map +0 -1
- package/lib/matrixrtc/index.d.ts +0 -7
- package/lib/matrixrtc/index.d.ts.map +0 -1
- package/lib/matrixrtc/index.js +0 -21
- package/lib/matrixrtc/index.js.map +0 -1
- package/lib/matrixrtc/types.d.ts +0 -19
- package/lib/matrixrtc/types.d.ts.map +0 -1
- package/lib/matrixrtc/types.js +0 -1
- package/lib/matrixrtc/types.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/lib/webrtc/audioContext.d.ts +0 -15
- package/lib/webrtc/audioContext.d.ts.map +0 -1
- package/lib/webrtc/audioContext.js +0 -46
- package/lib/webrtc/audioContext.js.map +0 -1
- package/lib/webrtc/call.d.ts +0 -560
- package/lib/webrtc/call.d.ts.map +0 -1
- package/lib/webrtc/call.js +0 -2541
- package/lib/webrtc/call.js.map +0 -1
- package/lib/webrtc/callEventHandler.d.ts +0 -37
- package/lib/webrtc/callEventHandler.d.ts.map +0 -1
- package/lib/webrtc/callEventHandler.js +0 -344
- package/lib/webrtc/callEventHandler.js.map +0 -1
- package/lib/webrtc/callEventTypes.d.ts +0 -73
- package/lib/webrtc/callEventTypes.d.ts.map +0 -1
- package/lib/webrtc/callEventTypes.js +0 -13
- package/lib/webrtc/callEventTypes.js.map +0 -1
- package/lib/webrtc/callFeed.d.ts +0 -128
- package/lib/webrtc/callFeed.d.ts.map +0 -1
- package/lib/webrtc/callFeed.js +0 -289
- package/lib/webrtc/callFeed.js.map +0 -1
- package/lib/webrtc/groupCall.d.ts +0 -323
- package/lib/webrtc/groupCall.d.ts.map +0 -1
- package/lib/webrtc/groupCall.js +0 -1337
- package/lib/webrtc/groupCall.js.map +0 -1
- package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
- package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
- package/lib/webrtc/groupCallEventHandler.js +0 -178
- package/lib/webrtc/groupCallEventHandler.js.map +0 -1
- package/lib/webrtc/mediaHandler.d.ts +0 -89
- package/lib/webrtc/mediaHandler.d.ts.map +0 -1
- package/lib/webrtc/mediaHandler.js +0 -437
- package/lib/webrtc/mediaHandler.js.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
- package/lib/webrtc/stats/connectionStats.d.ts +0 -28
- package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStats.js +0 -26
- package/lib/webrtc/stats/connectionStats.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
- package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
- package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
- package/lib/webrtc/stats/groupCallStats.js +0 -78
- package/lib/webrtc/stats/groupCallStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
- package/lib/webrtc/stats/statsReport.d.ts +0 -99
- package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReport.js +0 -32
- package/lib/webrtc/stats/statsReport.js.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
- package/lib/webrtc/stats/statsReportEmitter.js +0 -33
- package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
- package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/transportStats.d.ts +0 -11
- package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStats.js +0 -1
- package/lib/webrtc/stats/transportStats.js.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
- package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
- package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
- package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
- package/lib/webrtc/stats/valueFormatter.js +0 -25
- package/lib/webrtc/stats/valueFormatter.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 -4418
- 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/matrixrtc/CallMembership.ts +0 -247
- package/src/matrixrtc/LivekitFocus.ts +0 -39
- package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
- package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
- package/src/matrixrtc/focus.ts +0 -25
- package/src/matrixrtc/index.ts +0 -22
- package/src/matrixrtc/types.ts +0 -36
- 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/src/webrtc/audioContext.ts +0 -44
- package/src/webrtc/call.ts +0 -3074
- package/src/webrtc/callEventHandler.ts +0 -425
- package/src/webrtc/callEventTypes.ts +0 -93
- package/src/webrtc/callFeed.ts +0 -364
- package/src/webrtc/groupCall.ts +0 -1735
- package/src/webrtc/groupCallEventHandler.ts +0 -234
- package/src/webrtc/mediaHandler.ts +0 -484
- package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
- package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
- package/src/webrtc/stats/connectionStats.ts +0 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
- package/src/webrtc/stats/groupCallStats.ts +0 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
- package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
- package/src/webrtc/stats/statsReport.ts +0 -133
- package/src/webrtc/stats/statsReportEmitter.ts +0 -49
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
- package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
- package/src/webrtc/stats/transportStats.ts +0 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
- package/src/webrtc/stats/valueFormatter.ts +0 -27
package/lib/oidc/discovery.js
CHANGED
@@ -19,7 +19,7 @@ limitations under the License.
|
|
19
19
|
*/
|
20
20
|
|
21
21
|
import { MetadataService, OidcClientSettingsStore } from "oidc-client-ts";
|
22
|
-
import {
|
22
|
+
import { validateAuthMetadata } from "./validate.js";
|
23
23
|
import { Method, timeoutSignal } from "../http-api/index.js";
|
24
24
|
/**
|
25
25
|
* @experimental
|
@@ -31,36 +31,47 @@ import { Method, timeoutSignal } from "../http-api/index.js";
|
|
31
31
|
* @param issuer - the OIDC issuer as returned by the /auth_issuer API
|
32
32
|
* @returns validated authentication metadata and optionally signing keys
|
33
33
|
* @throws when delegated auth config is invalid or unreachable
|
34
|
+
* @deprecated in favour of {@link MatrixClient#getAuthMetadata}
|
34
35
|
*/
|
35
36
|
export var discoverAndValidateOIDCIssuerWellKnown = /*#__PURE__*/function () {
|
36
37
|
var _ref = _asyncToGenerator(function* (issuer) {
|
37
|
-
var _yield$metadataServic;
|
38
38
|
var issuerOpenIdConfigUrl = new URL(".well-known/openid-configuration", issuer);
|
39
39
|
var issuerWellKnownResponse = yield fetch(issuerOpenIdConfigUrl, {
|
40
40
|
method: Method.Get,
|
41
41
|
signal: timeoutSignal(5000)
|
42
42
|
});
|
43
43
|
var issuerWellKnown = yield issuerWellKnownResponse.json();
|
44
|
-
|
44
|
+
return validateAuthMetadataAndKeys(issuerWellKnown);
|
45
|
+
});
|
46
|
+
return function discoverAndValidateOIDCIssuerWellKnown(_x) {
|
47
|
+
return _ref.apply(this, arguments);
|
48
|
+
};
|
49
|
+
}();
|
50
|
+
/**
|
51
|
+
* @experimental
|
52
|
+
* Validate the authentication metadata and fetch the signing keys from the jwks_uri in the metadata
|
53
|
+
* @param authMetadata - the authentication metadata to validate
|
54
|
+
* @returns validated authentication metadata and signing keys
|
55
|
+
*/
|
56
|
+
export var validateAuthMetadataAndKeys = /*#__PURE__*/function () {
|
57
|
+
var _ref2 = _asyncToGenerator(function* (authMetadata) {
|
58
|
+
var validatedIssuerConfig = validateAuthMetadata(authMetadata);
|
45
59
|
|
46
60
|
// create a temporary settings store, so we can use metadata service for discovery
|
47
61
|
var settings = new OidcClientSettingsStore({
|
48
|
-
authority: issuer,
|
62
|
+
authority: validatedIssuerConfig.issuer,
|
63
|
+
metadata: validatedIssuerConfig,
|
49
64
|
redirect_uri: "",
|
50
65
|
// Not known yet, this is here to make the type checker happy
|
51
66
|
client_id: "" // Not known yet, this is here to make the type checker happy
|
52
67
|
});
|
53
68
|
var metadataService = new MetadataService(settings);
|
54
|
-
var metadata = yield metadataService.getMetadata();
|
55
|
-
var signingKeys = (_yield$metadataServic = yield metadataService.getSigningKeys()) !== null && _yield$metadataServic !== void 0 ? _yield$metadataServic : undefined;
|
56
|
-
isValidatedIssuerMetadata(metadata);
|
57
69
|
return _objectSpread(_objectSpread({}, validatedIssuerConfig), {}, {
|
58
|
-
|
59
|
-
signingKeys
|
70
|
+
signingKeys: yield metadataService.getSigningKeys()
|
60
71
|
});
|
61
72
|
});
|
62
|
-
return function
|
63
|
-
return
|
73
|
+
return function validateAuthMetadataAndKeys(_x2) {
|
74
|
+
return _ref2.apply(this, arguments);
|
64
75
|
};
|
65
76
|
}();
|
66
77
|
//# sourceMappingURL=discovery.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"discovery.js","names":["MetadataService","OidcClientSettingsStore","
|
1
|
+
{"version":3,"file":"discovery.js","names":["MetadataService","OidcClientSettingsStore","validateAuthMetadata","Method","timeoutSignal","discoverAndValidateOIDCIssuerWellKnown","_ref","_asyncToGenerator","issuer","issuerOpenIdConfigUrl","URL","issuerWellKnownResponse","fetch","method","Get","signal","issuerWellKnown","json","validateAuthMetadataAndKeys","_x","apply","arguments","_ref2","authMetadata","validatedIssuerConfig","settings","authority","metadata","redirect_uri","client_id","metadataService","_objectSpread","signingKeys","getSigningKeys","_x2"],"sources":["../../src/oidc/discovery.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 { MetadataService, OidcClientSettingsStore } from \"oidc-client-ts\";\n\nimport { validateAuthMetadata } from \"./validate.ts\";\nimport { Method, timeoutSignal } from \"../http-api/index.ts\";\nimport { OidcClientConfig } from \"./index.ts\";\n\n/**\n * @experimental\n * Discover and validate delegated auth configuration\n * - delegated auth issuer openid-configuration is reachable\n * - delegated auth issuer openid-configuration is configured correctly for us\n * Fetches https://oidc-issuer.example.com/.well-known/openid-configuration and other files linked therein.\n * When successful, validated metadata is returned\n * @param issuer - the OIDC issuer as returned by the /auth_issuer API\n * @returns validated authentication metadata and optionally signing keys\n * @throws when delegated auth config is invalid or unreachable\n * @deprecated in favour of {@link MatrixClient#getAuthMetadata}\n */\nexport const discoverAndValidateOIDCIssuerWellKnown = async (issuer: string): Promise<OidcClientConfig> => {\n const issuerOpenIdConfigUrl = new URL(\".well-known/openid-configuration\", issuer);\n const issuerWellKnownResponse = await fetch(issuerOpenIdConfigUrl, {\n method: Method.Get,\n signal: timeoutSignal(5000),\n });\n const issuerWellKnown = await issuerWellKnownResponse.json();\n return validateAuthMetadataAndKeys(issuerWellKnown);\n};\n/**\n * @experimental\n * Validate the authentication metadata and fetch the signing keys from the jwks_uri in the metadata\n * @param authMetadata - the authentication metadata to validate\n * @returns validated authentication metadata and signing keys\n */\nexport const validateAuthMetadataAndKeys = async (authMetadata: unknown): Promise<OidcClientConfig> => {\n const validatedIssuerConfig = validateAuthMetadata(authMetadata);\n\n // create a temporary settings store, so we can use metadata service for discovery\n const settings = new OidcClientSettingsStore({\n authority: validatedIssuerConfig.issuer,\n metadata: validatedIssuerConfig,\n redirect_uri: \"\", // Not known yet, this is here to make the type checker happy\n client_id: \"\", // Not known yet, this is here to make the type checker happy\n });\n const metadataService = new MetadataService(settings);\n \n return {\n ...validatedIssuerConfig,\n signingKeys: await metadataService.getSigningKeys(),\n };\n};\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,EAAEC,uBAAuB,QAAQ,gBAAgB;AAEzE,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,MAAM,EAAEC,aAAa,QAAQ,sBAAsB;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,sCAAsC;EAAA,IAAAC,IAAA,GAAAC,iBAAA,CAAG,WAAOC,MAAc,EAAgC;IACvG,IAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAAC,kCAAkC,EAAEF,MAAM,CAAC;IACjF,IAAMG,uBAAuB,SAASC,KAAK,CAACH,qBAAqB,EAAE;MAC/DI,MAAM,EAAEV,MAAM,CAACW,GAAG;MAClBC,MAAM,EAAEX,aAAa,CAAC,IAAI;IAC9B,CAAC,CAAC;IACF,IAAMY,eAAe,SAASL,uBAAuB,CAACM,IAAI,CAAC,CAAC;IAC5D,OAAOC,2BAA2B,CAACF,eAAe,CAAC;EACvD,CAAC;EAAA,gBARYX,sCAAsCA,CAAAc,EAAA;IAAA,OAAAb,IAAA,CAAAc,KAAA,OAAAC,SAAA;EAAA;AAAA,GAQlD;AACD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMH,2BAA2B;EAAA,IAAAI,KAAA,GAAAf,iBAAA,CAAG,WAAOgB,YAAqB,EAAgC;IACnG,IAAMC,qBAAqB,GAAGtB,oBAAoB,CAACqB,YAAY,CAAC;;IAEhE;IACA,IAAME,QAAQ,GAAG,IAAIxB,uBAAuB,CAAC;MACzCyB,SAAS,EAAEF,qBAAqB,CAAChB,MAAM;MACvCmB,QAAQ,EAAEH,qBAAqB;MAC/BI,YAAY,EAAE,EAAE;MAAE;MAClBC,SAAS,EAAE,EAAE,CAAE;IACnB,CAAC,CAAC;IACF,IAAMC,eAAe,GAAG,IAAI9B,eAAe,CAACyB,QAAQ,CAAC;IAErD,OAAAM,aAAA,CAAAA,aAAA,KACOP,qBAAqB;MACxBQ,WAAW,QAAQF,eAAe,CAACG,cAAc,CAAC;IAAC;EAE3D,CAAC;EAAA,gBAhBYf,2BAA2BA,CAAAgB,GAAA;IAAA,OAAAZ,KAAA,CAAAF,KAAA,OAAAC,SAAA;EAAA;AAAA,GAgBvC","ignoreList":[]}
|
package/lib/oidc/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { SigningKey } from "oidc-client-ts";
|
2
|
-
import {
|
2
|
+
import { ValidatedAuthMetadata } from "./validate.ts";
|
3
3
|
export * from "./authorize.ts";
|
4
4
|
export * from "./discovery.ts";
|
5
5
|
export * from "./error.ts";
|
@@ -10,8 +10,7 @@ export * from "./validate.ts";
|
|
10
10
|
* Validated config for native OIDC authentication, as returned by {@link discoverAndValidateOIDCIssuerWellKnown}.
|
11
11
|
* Contains metadata and signing keys from the issuer's well-known (https://oidc-issuer.example.com/.well-known/openid-configuration).
|
12
12
|
*/
|
13
|
-
export interface OidcClientConfig extends
|
14
|
-
|
15
|
-
signingKeys?: SigningKey[];
|
13
|
+
export interface OidcClientConfig extends ValidatedAuthMetadata {
|
14
|
+
signingKeys: SigningKey[] | null;
|
16
15
|
}
|
17
16
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/oidc/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oidc/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oidc/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAE9B;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC3D,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;CACpC"}
|
package/lib/oidc/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/oidc/index.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 type { SigningKey } from \"oidc-client-ts\";\nimport {
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/oidc/index.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 type { SigningKey } from \"oidc-client-ts\";\nimport { ValidatedAuthMetadata } from \"./validate.ts\";\n\nexport * from \"./authorize.ts\";\nexport * from \"./discovery.ts\";\nexport * from \"./error.ts\";\nexport * from \"./register.ts\";\nexport * from \"./tokenRefresher.ts\";\nexport * from \"./validate.ts\";\n\n/**\n * Validated config for native OIDC authentication, as returned by {@link discoverAndValidateOIDCIssuerWellKnown}.\n * Contains metadata and signing keys from the issuer's well-known (https://oidc-issuer.example.com/.well-known/openid-configuration).\n */\nexport interface OidcClientConfig extends ValidatedAuthMetadata {\n signingKeys: SigningKey[] | null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,eAAe;;AAE7B;AACA;AACA;AACA;AAHA","ignoreList":[]}
|
package/lib/oidc/register.js
CHANGED
@@ -38,11 +38,11 @@ export var DEVICE_CODE_SCOPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
38
38
|
*/
|
39
39
|
export var registerOidcClient = /*#__PURE__*/function () {
|
40
40
|
var _ref = _asyncToGenerator(function* (delegatedAuthConfig, clientMetadata) {
|
41
|
-
if (!delegatedAuthConfig.
|
41
|
+
if (!delegatedAuthConfig.registration_endpoint) {
|
42
42
|
throw new Error(OidcError.DynamicRegistrationNotSupported);
|
43
43
|
}
|
44
44
|
var grantTypes = ["authorization_code", "refresh_token"];
|
45
|
-
if (grantTypes.some(scope => !delegatedAuthConfig.
|
45
|
+
if (grantTypes.some(scope => !delegatedAuthConfig.grant_types_supported.includes(scope))) {
|
46
46
|
throw new Error(OidcError.DynamicRegistrationNotSupported);
|
47
47
|
}
|
48
48
|
|
@@ -66,7 +66,7 @@ export var registerOidcClient = /*#__PURE__*/function () {
|
|
66
66
|
"Content-Type": "application/json"
|
67
67
|
};
|
68
68
|
try {
|
69
|
-
var response = yield fetch(delegatedAuthConfig.
|
69
|
+
var response = yield fetch(delegatedAuthConfig.registration_endpoint, {
|
70
70
|
method: Method.Post,
|
71
71
|
headers,
|
72
72
|
body: JSON.stringify(metadata)
|
package/lib/oidc/register.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"register.js","names":["OidcError","Method","logger","DEVICE_CODE_SCOPE","registerOidcClient","_ref","_asyncToGenerator","delegatedAuthConfig","clientMetadata","
|
1
|
+
{"version":3,"file":"register.js","names":["OidcError","Method","logger","DEVICE_CODE_SCOPE","registerOidcClient","_ref","_asyncToGenerator","delegatedAuthConfig","clientMetadata","registration_endpoint","Error","DynamicRegistrationNotSupported","grantTypes","some","scope","grant_types_supported","includes","metadata","client_name","clientName","client_uri","clientUri","response_types","grant_types","redirect_uris","redirectUris","id_token_signed_response_alg","token_endpoint_auth_method","application_type","applicationType","logo_uri","logoUri","contacts","policy_uri","policyUri","tos_uri","tosUri","headers","response","fetch","method","Post","body","JSON","stringify","status","DynamicRegistrationFailed","json","clientId","DynamicRegistrationInvalid","error","Object","values","message","_x","_x2","apply","arguments"],"sources":["../../src/oidc/register.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 { OidcClientConfig } from \"./index.ts\";\nimport { OidcError } from \"./error.ts\";\nimport { Method } from \"../http-api/index.ts\";\nimport { logger } from \"../logger.ts\";\nimport { NonEmptyArray } from \"../@types/common.ts\";\n\n/**\n * Client metadata passed to registration endpoint\n */\nexport type OidcRegistrationClientMetadata = {\n clientName: OidcRegistrationRequestBody[\"client_name\"];\n clientUri: OidcRegistrationRequestBody[\"client_uri\"];\n logoUri?: OidcRegistrationRequestBody[\"logo_uri\"];\n applicationType: OidcRegistrationRequestBody[\"application_type\"];\n redirectUris: OidcRegistrationRequestBody[\"redirect_uris\"];\n contacts: OidcRegistrationRequestBody[\"contacts\"];\n tosUri: OidcRegistrationRequestBody[\"tos_uri\"];\n policyUri: OidcRegistrationRequestBody[\"policy_uri\"];\n};\n\n/**\n * Request body for dynamic registration as defined by https://github.com/matrix-org/matrix-spec-proposals/pull/2966\n */\ninterface OidcRegistrationRequestBody {\n client_name?: string;\n client_uri: string;\n logo_uri?: string;\n contacts?: string[];\n tos_uri?: string;\n policy_uri?: string;\n redirect_uris?: NonEmptyArray<string>;\n response_types?: NonEmptyArray<string>;\n grant_types?: NonEmptyArray<string>;\n id_token_signed_response_alg?: string;\n token_endpoint_auth_method: string;\n application_type: \"web\" | \"native\";\n}\n\nexport const DEVICE_CODE_SCOPE = \"urn:ietf:params:oauth:grant-type:device_code\";\n\n/**\n * Attempts dynamic registration against the configured registration endpoint\n * @param delegatedAuthConfig - Auth config from {@link discoverAndValidateOIDCIssuerWellKnown}\n * @param clientMetadata - The metadata for the client which to register\n * @returns Promise<string> resolved with registered clientId\n * @throws when registration is not supported, on failed request or invalid response\n */\nexport const registerOidcClient = async (\n delegatedAuthConfig: OidcClientConfig,\n clientMetadata: OidcRegistrationClientMetadata,\n): Promise<string> => {\n if (!delegatedAuthConfig.registration_endpoint) {\n throw new Error(OidcError.DynamicRegistrationNotSupported);\n }\n\n const grantTypes: NonEmptyArray<string> = [\"authorization_code\", \"refresh_token\"];\n if (grantTypes.some((scope) => !delegatedAuthConfig.grant_types_supported.includes(scope))) {\n throw new Error(OidcError.DynamicRegistrationNotSupported);\n }\n\n // https://openid.net/specs/openid-connect-registration-1_0.html\n const metadata: OidcRegistrationRequestBody = {\n client_name: clientMetadata.clientName,\n client_uri: clientMetadata.clientUri,\n response_types: [\"code\"],\n grant_types: grantTypes,\n redirect_uris: clientMetadata.redirectUris,\n id_token_signed_response_alg: \"RS256\",\n token_endpoint_auth_method: \"none\",\n application_type: clientMetadata.applicationType,\n logo_uri: clientMetadata.logoUri,\n contacts: clientMetadata.contacts,\n policy_uri: clientMetadata.policyUri,\n tos_uri: clientMetadata.tosUri,\n };\n const headers = {\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n };\n\n try {\n const response = await fetch(delegatedAuthConfig.registration_endpoint, {\n method: Method.Post,\n headers,\n body: JSON.stringify(metadata),\n });\n\n if (response.status >= 400) {\n throw new Error(OidcError.DynamicRegistrationFailed);\n }\n\n const body = await response.json();\n const clientId = body[\"client_id\"];\n if (!clientId || typeof clientId !== \"string\") {\n throw new Error(OidcError.DynamicRegistrationInvalid);\n }\n\n return clientId;\n } catch (error) {\n if (Object.values(OidcError).includes((error as Error).message as OidcError)) {\n throw error;\n } else {\n logger.error(\"Dynamic registration request failed\", error);\n throw new Error(OidcError.DynamicRegistrationFailed);\n }\n }\n};\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,SAAS,QAAQ,YAAY;AACtC,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,MAAM,QAAQ,cAAc;;AAGrC;AACA;AACA;;AAYA;AACA;AACA;;AAgBA,OAAO,IAAMC,iBAAiB,GAAG,8CAA8C;;AAE/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,kBAAkB;EAAA,IAAAC,IAAA,GAAAC,iBAAA,CAAG,WAC9BC,mBAAqC,EACrCC,cAA8C,EAC5B;IAClB,IAAI,CAACD,mBAAmB,CAACE,qBAAqB,EAAE;MAC5C,MAAM,IAAIC,KAAK,CAACV,SAAS,CAACW,+BAA+B,CAAC;IAC9D;IAEA,IAAMC,UAAiC,GAAG,CAAC,o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AE,aAAa;YAKnC,oBAAoB;
|
1
|
+
{"version":3,"file":"tokenRefresher.d.ts","sourceRoot":"","sources":["../../src/oidc/tokenRefresher.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAoC,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD;;;;;;GAMG;AACH,qBAAa,kBAAkB;IA4BvB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa;IA/BlC;;;;;OAKG;IACH,SAAgB,eAAe,EAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,sBAAsB,CAAC,CAAwB;;IAGnD;;OAEG;IACH,MAAM,EAAE,MAAM;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM;IAChB;;OAEG;IACH,WAAW,EAAE,MAAM;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM;IAChB;;;OAGG;IACc,aAAa,EAAE,aAAa;YAKnC,oBAAoB;IA0BlC;;;;;OAKG;IACU,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAY9E;;;;;;;OAOG;IACU,aAAa,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAInF,YAAY;CA0B7B"}
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
5
3
|
/*
|
6
4
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
7
5
|
|
@@ -69,18 +67,21 @@ export class OidcTokenRefresher {
|
|
69
67
|
var _this = this;
|
70
68
|
return _asyncToGenerator(function* () {
|
71
69
|
try {
|
70
|
+
var _config$signingKeys;
|
72
71
|
var config = yield discoverAndValidateOIDCIssuerWellKnown(issuer);
|
73
72
|
var scope = generateScope(deviceId);
|
74
|
-
_this.oidcClient = new OidcClient(
|
73
|
+
_this.oidcClient = new OidcClient({
|
74
|
+
metadata: config,
|
75
|
+
signingKeys: (_config$signingKeys = config.signingKeys) !== null && _config$signingKeys !== void 0 ? _config$signingKeys : undefined,
|
75
76
|
client_id: clientId,
|
76
77
|
scope,
|
77
78
|
redirect_uri: redirectUri,
|
78
|
-
authority: config.
|
79
|
+
authority: config.issuer,
|
79
80
|
stateStore: new WebStorageStateStore({
|
80
81
|
prefix: "mx_oidc_",
|
81
82
|
store: window.sessionStorage
|
82
83
|
})
|
83
|
-
})
|
84
|
+
});
|
84
85
|
} catch (error) {
|
85
86
|
logger.error("Failed to initialise OIDC client.", error);
|
86
87
|
throw new Error("Failed to initialise OIDC client.");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tokenRefresher.js","names":["OidcClient","WebStorageStateStore","generateScope","discoverAndValidateOIDCIssuerWellKnown","logger","OidcTokenRefresher","constructor","issuer","clientId","redirectUri","deviceId","idTokenClaims","_defineProperty","oidcClientReady","initialiseOidcClient","_this","_asyncToGenerator","config","scope","oidcClient","
|
1
|
+
{"version":3,"file":"tokenRefresher.js","names":["OidcClient","WebStorageStateStore","generateScope","discoverAndValidateOIDCIssuerWellKnown","logger","OidcTokenRefresher","constructor","issuer","clientId","redirectUri","deviceId","idTokenClaims","_defineProperty","oidcClientReady","initialiseOidcClient","_this","_asyncToGenerator","_config$signingKeys","config","scope","oidcClient","metadata","signingKeys","undefined","client_id","redirect_uri","authority","stateStore","prefix","store","window","sessionStorage","error","Error","doRefreshAccessToken","refreshToken","_this2","inflightRefreshRequest","getNewTokens","tokens","persistTokens","_this3","refreshTokenState","refresh_token","session_state","data","profile","response","useRefreshToken","state","timeoutInSeconds","accessToken","access_token"],"sources":["../../src/oidc/tokenRefresher.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 { IdTokenClaims, OidcClient, WebStorageStateStore } from \"oidc-client-ts\";\n\nimport { AccessTokens } from \"../http-api/index.ts\";\nimport { generateScope } from \"./authorize.ts\";\nimport { discoverAndValidateOIDCIssuerWellKnown } from \"./discovery.ts\";\nimport { logger } from \"../logger.ts\";\n\n/**\n * @experimental\n * Class responsible for refreshing OIDC access tokens\n *\n * Client implementations will likely want to override {@link persistTokens} to persist tokens after successful refresh\n *\n */\nexport class OidcTokenRefresher {\n /**\n * Promise which will complete once the OidcClient has been initialised\n * and is ready to start refreshing tokens.\n *\n * Will reject if the client initialisation fails.\n */\n public readonly oidcClientReady!: Promise<void>;\n private oidcClient!: OidcClient;\n private inflightRefreshRequest?: Promise<AccessTokens>;\n\n public constructor(\n /**\n * The OIDC issuer as returned by the /auth_issuer API\n */\n issuer: string,\n /**\n * id of this client as registered with the OP\n */\n clientId: string,\n /**\n * redirectUri as registered with OP\n */\n redirectUri: string,\n /**\n * Device ID of current session\n */\n deviceId: string,\n /**\n * idTokenClaims as returned from authorization grant\n * used to validate tokens\n */\n private readonly idTokenClaims: IdTokenClaims,\n ) {\n this.oidcClientReady = this.initialiseOidcClient(issuer, clientId, deviceId, redirectUri);\n }\n\n private async initialiseOidcClient(\n issuer: string,\n clientId: string,\n deviceId: string,\n redirectUri: string,\n ): Promise<void> {\n try {\n const config = await discoverAndValidateOIDCIssuerWellKnown(issuer);\n\n const scope = generateScope(deviceId);\n\n this.oidcClient = new OidcClient({\n metadata: config,\n signingKeys: config.signingKeys ?? undefined,\n client_id: clientId,\n scope,\n redirect_uri: redirectUri,\n authority: config.issuer,\n stateStore: new WebStorageStateStore({ prefix: \"mx_oidc_\", store: window.sessionStorage }),\n });\n } catch (error) {\n logger.error(\"Failed to initialise OIDC client.\", error);\n throw new Error(\"Failed to initialise OIDC client.\");\n }\n }\n\n /**\n * Attempt token refresh using given refresh token\n * @param refreshToken - refresh token to use in request with token issuer\n * @returns tokens - Promise that resolves with new access and refresh tokens\n * @throws when token refresh fails\n */\n public async doRefreshAccessToken(refreshToken: string): Promise<AccessTokens> {\n if (!this.inflightRefreshRequest) {\n this.inflightRefreshRequest = this.getNewTokens(refreshToken);\n }\n try {\n const tokens = await this.inflightRefreshRequest;\n return tokens;\n } finally {\n this.inflightRefreshRequest = undefined;\n }\n }\n\n /**\n * Persist the new tokens, called after tokens are successfully refreshed.\n *\n * This function is intended to be overriden by the consumer when persistence is necessary.\n *\n * @param tokens.accessToken - new access token\n * @param tokens.refreshToken - OPTIONAL new refresh token\n */\n public async persistTokens(tokens: { accessToken: string; refreshToken?: string }): Promise<void> {\n // NOOP\n }\n\n private async getNewTokens(refreshToken: string): Promise<AccessTokens> {\n if (!this.oidcClient) {\n throw new Error(\"Cannot get new token before OIDC client is initialised.\");\n }\n\n const refreshTokenState = {\n refresh_token: refreshToken,\n session_state: \"test\",\n data: undefined,\n profile: this.idTokenClaims,\n };\n\n const response = await this.oidcClient.useRefreshToken({\n state: refreshTokenState,\n timeoutInSeconds: 300,\n });\n\n const tokens = {\n accessToken: response.access_token,\n refreshToken: response.refresh_token,\n };\n\n await this.persistTokens(tokens);\n\n return tokens;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAwBA,UAAU,EAAEC,oBAAoB,QAAQ,gBAAgB;AAGhF,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,sCAAsC,QAAQ,gBAAgB;AACvE,SAASC,MAAM,QAAQ,cAAc;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,CAAC;EAWrBC,WAAWA;EACd;AACR;AACA;EACQC,MAAc;EACd;AACR;AACA;EACQC,QAAgB;EAChB;AACR;AACA;EACQC,WAAmB;EACnB;AACR;AACA;EACQC,QAAgB;EAChB;AACR;AACA;AACA;EACyBC,aAA4B,EAC/C;IAAA,KADmBA,aAA4B,GAA5BA,aAA4B;IA/BjD;AACJ;AACA;AACA;AACA;AACA;IALIC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAiCI,IAAI,CAACC,eAAe,GAAG,IAAI,CAACC,oBAAoB,CAACP,MAAM,EAAEC,QAAQ,EAAEE,QAAQ,EAAED,WAAW,CAAC;EAC7F;EAEcK,oBAAoBA,CAC9BP,MAAc,EACdC,QAAgB,EAChBE,QAAgB,EAChBD,WAAmB,EACN;IAAA,IAAAM,KAAA;IAAA,OAAAC,iBAAA;MACb,IAAI;QAAA,IAAAC,mBAAA;QACA,IAAMC,MAAM,SAASf,sCAAsC,CAACI,MAAM,CAAC;QAEnE,IAAMY,KAAK,GAAGjB,aAAa,CAACQ,QAAQ,CAAC;QAErCK,KAAI,CAACK,UAAU,GAAG,IAAIpB,UAAU,CAAC;UAC7BqB,QAAQ,EAAEH,MAAM;UAChBI,WAAW,GAAAL,mB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ACrBC,IAAI,EAAEtB,SAAS;QACfuB,OAAO,EAAEL,MAAI,CAAC9B;MAClB,CAAC;MAED,IAAMoC,QAAQ,SAASN,MAAI,CAACrB,UAAU,CAAC4B,eAAe,CAAC;QACnDC,KAAK,EAAEP,iBAAiB;QACxBQ,gBAAgB,EAAE;MACtB,CAAC,CAAC;MAEF,IAAMX,MAAM,GAAG;QACXY,WAAW,EAAEJ,QAAQ,CAACK,YAAY;QAClCjB,YAAY,EAAEY,QAAQ,CAACJ;MAC3B,CAAC;MAED,MAAMF,MAAI,CAACD,aAAa,CAACD,MAAM,CAAC;MAEhC,OAAOA,MAAM;IAAC;EAClB;AACJ","ignoreList":[]}
|
package/lib/oidc/validate.d.ts
CHANGED
@@ -1,36 +1,22 @@
|
|
1
1
|
import { IdTokenClaims, OidcMetadata, SigninResponse } from "oidc-client-ts";
|
2
|
-
export type ValidatedIssuerConfig = {
|
3
|
-
authorizationEndpoint: string;
|
4
|
-
tokenEndpoint: string;
|
5
|
-
registrationEndpoint?: string;
|
6
|
-
accountManagementEndpoint?: string;
|
7
|
-
accountManagementActionsSupported?: string[];
|
8
|
-
};
|
9
|
-
/**
|
10
|
-
* Validates issuer `.well-known/openid-configuration`
|
11
|
-
* As defined in RFC5785 https://openid.net/specs/openid-connect-discovery-1_0.html
|
12
|
-
* validates that OP is compatible with Element's OIDC flow
|
13
|
-
* @param wellKnown - json object
|
14
|
-
* @returns valid issuer config
|
15
|
-
* @throws Error - when issuer config is not found or is invalid
|
16
|
-
*/
|
17
|
-
export declare const validateOIDCIssuerWellKnown: (wellKnown: unknown) => ValidatedIssuerConfig;
|
18
2
|
/**
|
19
3
|
* Metadata from OIDC authority discovery
|
20
4
|
* With validated properties required in type
|
21
5
|
*/
|
22
|
-
export type
|
6
|
+
export type ValidatedAuthMetadata = Partial<OidcMetadata> & Pick<OidcMetadata, "issuer" | "authorization_endpoint" | "token_endpoint" | "revocation_endpoint" | "response_types_supported" | "grant_types_supported" | "code_challenge_methods_supported"> & {
|
23
7
|
account_management_uri?: string;
|
24
8
|
account_management_actions_supported?: string[];
|
9
|
+
prompt_values_supported?: string[];
|
25
10
|
};
|
26
11
|
/**
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
* @param
|
31
|
-
* @
|
12
|
+
* Validates issuer `.well-known/openid-configuration`
|
13
|
+
* As defined in RFC5785 https://openid.net/specs/openid-connect-discovery-1_0.html
|
14
|
+
* validates that OP is compatible with Element's OIDC flow
|
15
|
+
* @param authMetadata - json object
|
16
|
+
* @returns valid issuer config
|
17
|
+
* @throws Error - when issuer config is not found or is invalid
|
32
18
|
*/
|
33
|
-
export declare
|
19
|
+
export declare const validateAuthMetadata: (authMetadata: unknown) => ValidatedAuthMetadata;
|
34
20
|
export declare const decodeIdToken: (token: string) => IdTokenClaims;
|
35
21
|
/**
|
36
22
|
* Validate idToken
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/oidc/validate.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAK7E
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/oidc/validate.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAK7E;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,GACrD,IAAI,CACA,YAAY,EACV,QAAQ,GACR,wBAAwB,GACxB,gBAAgB,GAChB,qBAAqB,GACrB,0BAA0B,GAC1B,uBAAuB,GACvB,kCAAkC,CACvC,GAAG;IAEA,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,oCAAoC,CAAC,EAAE,MAAM,EAAE,CAAC;IAGhD,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC,CAAC;AAqCN;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,iBAAkB,OAAO,KAAG,qBA2B5D,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,aAO7C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,YACf,MAAM,GAAG,SAAS,UACnB,MAAM,YACJ,MAAM,SACT,MAAM,GAAG,SAAS,KAC1B,IAyCF,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AACF;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,SAAS,CAc1F;AAED;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,UAAU,EAAE,QAAQ,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,KAAK,mBAAmB,GAAG,cAAc,GACrC,mBAAmB,GAAG;IAClB,UAAU,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACnC,CAAC;AAWN,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,mBAAmB,CAItG"}
|
package/lib/oidc/validate.js
CHANGED
@@ -17,6 +17,12 @@ limitations under the License.
|
|
17
17
|
import { jwtDecode } from "jwt-decode";
|
18
18
|
import { logger } from "../logger.js";
|
19
19
|
import { OidcError } from "./error.js";
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Metadata from OIDC authority discovery
|
23
|
+
* With validated properties required in type
|
24
|
+
*/
|
25
|
+
|
20
26
|
var isRecord = value => !!value && typeof value === "object" && !Array.isArray(value);
|
21
27
|
var requiredStringProperty = (wellKnown, key) => {
|
22
28
|
if (!wellKnown[key] || !optionalStringProperty(wellKnown, key)) {
|
@@ -52,44 +58,22 @@ var requiredArrayValue = (wellKnown, key, value) => {
|
|
52
58
|
* Validates issuer `.well-known/openid-configuration`
|
53
59
|
* As defined in RFC5785 https://openid.net/specs/openid-connect-discovery-1_0.html
|
54
60
|
* validates that OP is compatible with Element's OIDC flow
|
55
|
-
* @param
|
61
|
+
* @param authMetadata - json object
|
56
62
|
* @returns valid issuer config
|
57
63
|
* @throws Error - when issuer config is not found or is invalid
|
58
64
|
*/
|
59
|
-
export var
|
60
|
-
if (!isRecord(
|
65
|
+
export var validateAuthMetadata = authMetadata => {
|
66
|
+
if (!isRecord(authMetadata)) {
|
61
67
|
logger.error("Issuer configuration not found or malformed");
|
62
68
|
throw new Error(OidcError.OpSupport);
|
63
69
|
}
|
64
|
-
var isInvalid = [requiredStringProperty(
|
70
|
+
var isInvalid = [requiredStringProperty(authMetadata, "issuer"), requiredStringProperty(authMetadata, "authorization_endpoint"), requiredStringProperty(authMetadata, "token_endpoint"), requiredStringProperty(authMetadata, "revocation_endpoint"), optionalStringProperty(authMetadata, "registration_endpoint"), optionalStringProperty(authMetadata, "account_management_uri"), optionalStringProperty(authMetadata, "device_authorization_endpoint"), optionalStringArrayProperty(authMetadata, "account_management_actions_supported"), requiredArrayValue(authMetadata, "response_types_supported", "code"), requiredArrayValue(authMetadata, "grant_types_supported", "authorization_code"), requiredArrayValue(authMetadata, "code_challenge_methods_supported", "S256"), optionalStringArrayProperty(authMetadata, "prompt_values_supported")].some(isValid => !isValid);
|
65
71
|
if (!isInvalid) {
|
66
|
-
return
|
67
|
-
authorizationEndpoint: wellKnown["authorization_endpoint"],
|
68
|
-
tokenEndpoint: wellKnown["token_endpoint"],
|
69
|
-
registrationEndpoint: wellKnown["registration_endpoint"],
|
70
|
-
accountManagementEndpoint: wellKnown["account_management_uri"],
|
71
|
-
accountManagementActionsSupported: wellKnown["account_management_actions_supported"]
|
72
|
-
};
|
72
|
+
return authMetadata;
|
73
73
|
}
|
74
74
|
logger.error("Issuer configuration not valid");
|
75
75
|
throw new Error(OidcError.OpSupport);
|
76
76
|
};
|
77
|
-
|
78
|
-
/**
|
79
|
-
* Metadata from OIDC authority discovery
|
80
|
-
* With validated properties required in type
|
81
|
-
*/
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Wraps validateOIDCIssuerWellKnown in a type assertion
|
85
|
-
* that asserts expected properties are present
|
86
|
-
* (Typescript assertions cannot be arrow functions)
|
87
|
-
* @param metadata - issuer openid-configuration response
|
88
|
-
* @throws when metadata validation fails
|
89
|
-
*/
|
90
|
-
export function isValidatedIssuerMetadata(metadata) {
|
91
|
-
validateOIDCIssuerWellKnown(metadata);
|
92
|
-
}
|
93
77
|
export var decodeIdToken = token => {
|
94
78
|
try {
|
95
79
|
return jwtDecode(token);
|
@@ -125,7 +109,8 @@ export var validateIdToken = (idToken, issuer, clientId, nonce) => {
|
|
125
109
|
* The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.
|
126
110
|
* EW: Don't accept tokens with other untrusted audiences
|
127
111
|
* */
|
128
|
-
|
112
|
+
var sanitisedAuds = typeof claims.aud === "string" ? [claims.aud] : claims.aud;
|
113
|
+
if (!sanitisedAuds.includes(clientId)) {
|
129
114
|
throw new Error("Invalid audience");
|
130
115
|
}
|
131
116
|
|
package/lib/oidc/validate.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validate.js","names":["jwtDecode","logger","OidcError","isRecord","value","Array","isArray","requiredStringProperty","wellKnown","key","optionalStringProperty","error","concat","optionalStringArrayProperty","every","v","requiredArrayValue","array","includes","validateOIDCIssuerWellKnown","Error","OpSupport","isInvalid","some","isValid","authorizationEndpoint","tokenEndpoint","registrationEndpoint","accountManagementEndpoint","accountManagementActionsSupported","isValidatedIssuerMetadata","metadata","decodeIdToken","token","validateIdToken","idToken","issuer","clientId","nonce","claims","iss","aud","undefined","exp","Date","now","InvalidIdToken","validateStoredUserState","userState","MissingOrInvalidStoredState","isValidBearerTokenResponse","response","toLowerCase","validateBearerTokenResponse","InvalidBearerTokenResponse"],"sources":["../../src/oidc/validate.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 { jwtDecode } from \"jwt-decode\";\nimport { IdTokenClaims, OidcMetadata, SigninResponse } from \"oidc-client-ts\";\n\nimport { logger } from \"../logger.ts\";\nimport { OidcError } from \"./error.ts\";\n\nexport type ValidatedIssuerConfig = {\n authorizationEndpoint: string;\n tokenEndpoint: string;\n registrationEndpoint?: string;\n accountManagementEndpoint?: string;\n accountManagementActionsSupported?: string[];\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\nconst requiredStringProperty = (wellKnown: Record<string, unknown>, key: string): boolean => {\n if (!wellKnown[key] || !optionalStringProperty(wellKnown, key)) {\n logger.error(`Missing or invalid property: ${key}`);\n return false;\n }\n return true;\n};\nconst optionalStringProperty = (wellKnown: Record<string, unknown>, key: string): boolean => {\n if (!!wellKnown[key] && typeof wellKnown[key] !== \"string\") {\n logger.error(`Invalid property: ${key}`);\n return false;\n }\n return true;\n};\nconst optionalStringArrayProperty = (wellKnown: Record<string, unknown>, key: string): boolean => {\n if (\n !!wellKnown[key] &&\n (!Array.isArray(wellKnown[key]) || !(<unknown[]>wellKnown[key]).every((v) => typeof v === \"string\"))\n ) {\n logger.error(`Invalid property: ${key}`);\n return false;\n }\n return true;\n};\nconst requiredArrayValue = (wellKnown: Record<string, unknown>, key: string, value: any): boolean => {\n const array = wellKnown[key];\n if (!array || !Array.isArray(array) || !array.includes(value)) {\n logger.error(`Invalid property: ${key}. ${value} is required.`);\n return false;\n }\n return true;\n};\n\n/**\n * Validates issuer `.well-known/openid-configuration`\n * As defined in RFC5785 https://openid.net/specs/openid-connect-discovery-1_0.html\n * validates that OP is compatible with Element's OIDC flow\n * @param wellKnown - json object\n * @returns valid issuer config\n * @throws Error - when issuer config is not found or is invalid\n */\nexport const validateOIDCIssuerWellKnown = (wellKnown: unknown): ValidatedIssuerConfig => {\n if (!isRecord(wellKnown)) {\n logger.error(\"Issuer configuration not found or malformed\");\n throw new Error(OidcError.OpSupport);\n }\n\n const isInvalid = [\n requiredStringProperty(wellKnown, \"authorization_endpoint\"),\n requiredStringProperty(wellKnown, \"token_endpoint\"),\n requiredStringProperty(wellKnown, \"revocation_endpoint\"),\n optionalStringProperty(wellKnown, \"registration_endpoint\"),\n optionalStringProperty(wellKnown, \"account_management_uri\"),\n optionalStringProperty(wellKnown, \"device_authorization_endpoint\"),\n optionalStringArrayProperty(wellKnown, \"account_management_actions_supported\"),\n requiredArrayValue(wellKnown, \"response_types_supported\", \"code\"),\n requiredArrayValue(wellKnown, \"grant_types_supported\", \"authorization_code\"),\n requiredArrayValue(wellKnown, \"code_challenge_methods_supported\", \"S256\"),\n ].some((isValid) => !isValid);\n\n if (!isInvalid) {\n return {\n authorizationEndpoint: <string>wellKnown[\"authorization_endpoint\"],\n tokenEndpoint: <string>wellKnown[\"token_endpoint\"],\n registrationEndpoint: <string>wellKnown[\"registration_endpoint\"],\n accountManagementEndpoint: <string>wellKnown[\"account_management_uri\"],\n accountManagementActionsSupported: <string[]>wellKnown[\"account_management_actions_supported\"],\n };\n }\n\n logger.error(\"Issuer configuration not valid\");\n throw new Error(OidcError.OpSupport);\n};\n\n/**\n * Metadata from OIDC authority discovery\n * With validated properties required in type\n */\nexport type ValidatedIssuerMetadata = Partial<OidcMetadata> &\n Pick<\n OidcMetadata,\n | \"issuer\"\n | \"authorization_endpoint\"\n | \"token_endpoint\"\n | \"registration_endpoint\"\n | \"revocation_endpoint\"\n | \"response_types_supported\"\n | \"grant_types_supported\"\n | \"code_challenge_methods_supported\"\n | \"device_authorization_endpoint\"\n > & {\n // MSC2965 extensions to the OIDC spec\n account_management_uri?: string;\n account_management_actions_supported?: string[];\n };\n\n/**\n * Wraps validateOIDCIssuerWellKnown in a type assertion\n * that asserts expected properties are present\n * (Typescript assertions cannot be arrow functions)\n * @param metadata - issuer openid-configuration response\n * @throws when metadata validation fails\n */\nexport function isValidatedIssuerMetadata(\n metadata: Partial<OidcMetadata>,\n): asserts metadata is ValidatedIssuerMetadata {\n validateOIDCIssuerWellKnown(metadata);\n}\n\nexport const decodeIdToken = (token: string): IdTokenClaims => {\n try {\n return jwtDecode<IdTokenClaims>(token);\n } catch (error) {\n logger.error(\"Could not decode id_token\", error);\n throw error;\n }\n};\n\n/**\n * Validate idToken\n * https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation\n * @param idToken - id token from token endpoint\n * @param issuer - issuer for the OP as found during discovery\n * @param clientId - this client's id as registered with the OP\n * @param nonce - nonce used in the authentication request\n * @throws when id token is invalid\n */\nexport const validateIdToken = (\n idToken: string | undefined,\n issuer: string,\n clientId: string,\n nonce: string | undefined,\n): void => {\n try {\n if (!idToken) {\n throw new Error(\"No ID token\");\n }\n const claims = decodeIdToken(idToken);\n\n // The Issuer Identifier for the OpenID Provider MUST exactly match the value of the iss (issuer) Claim.\n if (claims.iss !== issuer) {\n throw new Error(\"Invalid issuer\");\n }\n /**\n * The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer identified by the iss (issuer) Claim as an audience.\n * The aud (audience) Claim MAY contain an array with more than one element.\n * The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.\n * EW: Don't accept tokens with other untrusted audiences\n * */\n if (claims.aud !== clientId) {\n throw new Error(\"Invalid audience\");\n }\n\n /**\n * If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked\n * to verify that it is the same value as the one that was sent in the Authentication Request.\n */\n if (nonce !== undefined && claims.nonce !== nonce) {\n throw new Error(\"Invalid nonce\");\n }\n\n /**\n * The current time MUST be before the time represented by the exp Claim.\n * exp is an epoch timestamp in seconds\n * */\n if (!claims.exp || Date.now() > claims.exp * 1000) {\n throw new Error(\"Invalid expiry\");\n }\n } catch (error) {\n logger.error(\"Invalid ID token\", error);\n throw new Error(OidcError.InvalidIdToken);\n }\n};\n\n/**\n * State we ask OidcClient to store when starting oidc authorization flow (in `generateOidcAuthorizationUrl`)\n * so that we can access it on return from the OP and complete login\n */\nexport type UserState = {\n /**\n * Remember which server we were trying to login to\n */\n homeserverUrl: string;\n identityServerUrl?: string;\n /**\n * Used to validate id token\n */\n nonce: string;\n};\n/**\n * Validate stored user state exists and is valid\n * @param userState - userState returned by oidcClient.processSigninResponse\n * @throws when userState is invalid\n */\nexport function validateStoredUserState(userState: unknown): asserts userState is UserState {\n if (!isRecord(userState)) {\n logger.error(\"Stored user state not found\");\n throw new Error(OidcError.MissingOrInvalidStoredState);\n }\n const isInvalid = [\n requiredStringProperty(userState, \"homeserverUrl\"),\n requiredStringProperty(userState, \"nonce\"),\n optionalStringProperty(userState, \"identityServerUrl\"),\n ].some((isValid) => !isValid);\n\n if (isInvalid) {\n throw new Error(OidcError.MissingOrInvalidStoredState);\n }\n}\n\n/**\n * The expected response type from the token endpoint during authorization code flow\n * Normalized to always use capitalized 'Bearer' for token_type\n *\n * See https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4,\n * https://openid.net/specs/openid-connect-basic-1_0.html#TokenOK.\n */\nexport type BearerTokenResponse = {\n token_type: \"Bearer\";\n access_token: string;\n scope: string;\n refresh_token?: string;\n expires_in?: number;\n // from oidc-client-ts\n expires_at?: number;\n id_token: string;\n};\n\n/**\n * Make required properties required in type\n */\ntype ValidSignInResponse = SigninResponse &\n BearerTokenResponse & {\n token_type: \"Bearer\" | \"bearer\";\n };\n\nconst isValidBearerTokenResponse = (response: unknown): response is ValidSignInResponse =>\n isRecord(response) &&\n requiredStringProperty(response, \"token_type\") &&\n // token_type is case insensitive, some OPs return `token_type: \"bearer\"`\n (response[\"token_type\"] as string).toLowerCase() === \"bearer\" &&\n requiredStringProperty(response, \"access_token\") &&\n requiredStringProperty(response, \"refresh_token\") &&\n (!(\"expires_in\" in response) || typeof response[\"expires_in\"] === \"number\");\n\nexport function validateBearerTokenResponse(response: unknown): asserts response is ValidSignInResponse {\n if (!isValidBearerTokenResponse(response)) {\n throw new Error(OidcError.InvalidBearerTokenResponse);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,YAAY;AAGtC,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,SAAS,QAAQ,YAAY;AAUtC,IAAMC,QAAQ,GAAIC,KAAc,IAC5B,CAAC,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AACjE,IAAMG,sBAAsB,GAAGA,CAACC,SAAkC,EAAEC,GAAW,KAAc;EACzF,IAAI,CAACD,SAAS,CAACC,GAAG,CAAC,IAAI,CAACC,sBAAsB,CAACF,SAAS,EAAEC,GAAG,CAAC,EAAE;IAC5DR,MAAM,CAACU,KAAK,iCAAAC,MAAA,CAAiCH,GAAG,CAAE,CAAC;IACnD,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AACD,IAAMC,sBAAsB,GAAGA,CAACF,SAAkC,EAAEC,GAAW,KAAc;EACzF,IAAI,CAAC,CAACD,SAAS,CAACC,GAAG,CAAC,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{"version":3,"file":"validate.js","names":["jwtDecode","logger","OidcError","isRecord","value","Array","isArray","requiredStringProperty","wellKnown","key","optionalStringProperty","error","concat","optionalStringArrayProperty","every","v","requiredArrayValue","array","includes","validateAuthMetadata","authMetadata","Error","OpSupport","isInvalid","some","isValid","decodeIdToken","token","validateIdToken","idToken","issuer","clientId","nonce","claims","iss","sanitisedAuds","aud","undefined","exp","Date","now","InvalidIdToken","validateStoredUserState","userState","MissingOrInvalidStoredState","isValidBearerTokenResponse","response","toLowerCase","validateBearerTokenResponse","InvalidBearerTokenResponse"],"sources":["../../src/oidc/validate.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 { jwtDecode } from \"jwt-decode\";\nimport { IdTokenClaims, OidcMetadata, SigninResponse } from \"oidc-client-ts\";\n\nimport { logger } from \"../logger.ts\";\nimport { OidcError } from \"./error.ts\";\n\n/**\n * Metadata from OIDC authority discovery\n * With validated properties required in type\n */\nexport type ValidatedAuthMetadata = Partial<OidcMetadata> &\n Pick<\n OidcMetadata,\n | \"issuer\"\n | \"authorization_endpoint\"\n | \"token_endpoint\"\n | \"revocation_endpoint\"\n | \"response_types_supported\"\n | \"grant_types_supported\"\n | \"code_challenge_methods_supported\"\n > & {\n // MSC2965 extensions to the OIDC spec\n account_management_uri?: string;\n account_management_actions_supported?: string[];\n // The OidcMetadata type from oidc-client-ts does not include `prompt_values_supported`\n // even though it is part of the OIDC spec\n prompt_values_supported?: string[];\n };\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === \"object\" && !Array.isArray(value);\nconst requiredStringProperty = (wellKnown: Record<string, unknown>, key: string): boolean => {\n if (!wellKnown[key] || !optionalStringProperty(wellKnown, key)) {\n logger.error(`Missing or invalid property: ${key}`);\n return false;\n }\n return true;\n};\nconst optionalStringProperty = (wellKnown: Record<string, unknown>, key: string): boolean => {\n if (!!wellKnown[key] && typeof wellKnown[key] !== \"string\") {\n logger.error(`Invalid property: ${key}`);\n return false;\n }\n return true;\n};\nconst optionalStringArrayProperty = (wellKnown: Record<string, unknown>, key: string): boolean => {\n if (\n !!wellKnown[key] &&\n (!Array.isArray(wellKnown[key]) || !(<unknown[]>wellKnown[key]).every((v) => typeof v === \"string\"))\n ) {\n logger.error(`Invalid property: ${key}`);\n return false;\n }\n return true;\n};\nconst requiredArrayValue = (wellKnown: Record<string, unknown>, key: string, value: any): boolean => {\n const array = wellKnown[key];\n if (!array || !Array.isArray(array) || !array.includes(value)) {\n logger.error(`Invalid property: ${key}. ${value} is required.`);\n return false;\n }\n return true;\n};\n\n/**\n * Validates issuer `.well-known/openid-configuration`\n * As defined in RFC5785 https://openid.net/specs/openid-connect-discovery-1_0.html\n * validates that OP is compatible with Element's OIDC flow\n * @param authMetadata - json object\n * @returns valid issuer config\n * @throws Error - when issuer config is not found or is invalid\n */\nexport const validateAuthMetadata = (authMetadata: unknown): ValidatedAuthMetadata => {\n if (!isRecord(authMetadata)) {\n logger.error(\"Issuer configuration not found or malformed\");\n throw new Error(OidcError.OpSupport);\n }\n\n const isInvalid = [\n requiredStringProperty(authMetadata, \"issuer\"),\n requiredStringProperty(authMetadata, \"authorization_endpoint\"),\n requiredStringProperty(authMetadata, \"token_endpoint\"),\n requiredStringProperty(authMetadata, \"revocation_endpoint\"),\n optionalStringProperty(authMetadata, \"registration_endpoint\"),\n optionalStringProperty(authMetadata, \"account_management_uri\"),\n optionalStringProperty(authMetadata, \"device_authorization_endpoint\"),\n optionalStringArrayProperty(authMetadata, \"account_management_actions_supported\"),\n requiredArrayValue(authMetadata, \"response_types_supported\", \"code\"),\n requiredArrayValue(authMetadata, \"grant_types_supported\", \"authorization_code\"),\n requiredArrayValue(authMetadata, \"code_challenge_methods_supported\", \"S256\"),\n optionalStringArrayProperty(authMetadata, \"prompt_values_supported\"),\n ].some((isValid) => !isValid);\n\n if (!isInvalid) {\n return authMetadata as ValidatedAuthMetadata;\n }\n\n logger.error(\"Issuer configuration not valid\");\n throw new Error(OidcError.OpSupport);\n};\n\nexport const decodeIdToken = (token: string): IdTokenClaims => {\n try {\n return jwtDecode<IdTokenClaims>(token);\n } catch (error) {\n logger.error(\"Could not decode id_token\", error);\n throw error;\n }\n};\n\n/**\n * Validate idToken\n * https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation\n * @param idToken - id token from token endpoint\n * @param issuer - issuer for the OP as found during discovery\n * @param clientId - this client's id as registered with the OP\n * @param nonce - nonce used in the authentication request\n * @throws when id token is invalid\n */\nexport const validateIdToken = (\n idToken: string | undefined,\n issuer: string,\n clientId: string,\n nonce: string | undefined,\n): void => {\n try {\n if (!idToken) {\n throw new Error(\"No ID token\");\n }\n const claims = decodeIdToken(idToken);\n\n // The Issuer Identifier for the OpenID Provider MUST exactly match the value of the iss (issuer) Claim.\n if (claims.iss !== issuer) {\n throw new Error(\"Invalid issuer\");\n }\n /**\n * The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer identified by the iss (issuer) Claim as an audience.\n * The aud (audience) Claim MAY contain an array with more than one element.\n * The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.\n * EW: Don't accept tokens with other untrusted audiences\n * */\n const sanitisedAuds = typeof claims.aud === \"string\" ? [claims.aud] : claims.aud;\n if (!sanitisedAuds.includes(clientId)) {\n throw new Error(\"Invalid audience\");\n }\n\n /**\n * If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked\n * to verify that it is the same value as the one that was sent in the Authentication Request.\n */\n if (nonce !== undefined && claims.nonce !== nonce) {\n throw new Error(\"Invalid nonce\");\n }\n\n /**\n * The current time MUST be before the time represented by the exp Claim.\n * exp is an epoch timestamp in seconds\n * */\n if (!claims.exp || Date.now() > claims.exp * 1000) {\n throw new Error(\"Invalid expiry\");\n }\n } catch (error) {\n logger.error(\"Invalid ID token\", error);\n throw new Error(OidcError.InvalidIdToken);\n }\n};\n\n/**\n * State we ask OidcClient to store when starting oidc authorization flow (in `generateOidcAuthorizationUrl`)\n * so that we can access it on return from the OP and complete login\n */\nexport type UserState = {\n /**\n * Remember which server we were trying to login to\n */\n homeserverUrl: string;\n identityServerUrl?: string;\n /**\n * Used to validate id token\n */\n nonce: string;\n};\n/**\n * Validate stored user state exists and is valid\n * @param userState - userState returned by oidcClient.processSigninResponse\n * @throws when userState is invalid\n */\nexport function validateStoredUserState(userState: unknown): asserts userState is UserState {\n if (!isRecord(userState)) {\n logger.error(\"Stored user state not found\");\n throw new Error(OidcError.MissingOrInvalidStoredState);\n }\n const isInvalid = [\n requiredStringProperty(userState, \"homeserverUrl\"),\n requiredStringProperty(userState, \"nonce\"),\n optionalStringProperty(userState, \"identityServerUrl\"),\n ].some((isValid) => !isValid);\n\n if (isInvalid) {\n throw new Error(OidcError.MissingOrInvalidStoredState);\n }\n}\n\n/**\n * The expected response type from the token endpoint during authorization code flow\n * Normalized to always use capitalized 'Bearer' for token_type\n *\n * See https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4,\n * https://openid.net/specs/openid-connect-basic-1_0.html#TokenOK.\n */\nexport type BearerTokenResponse = {\n token_type: \"Bearer\";\n access_token: string;\n scope: string;\n refresh_token?: string;\n expires_in?: number;\n // from oidc-client-ts\n expires_at?: number;\n id_token: string;\n};\n\n/**\n * Make required properties required in type\n */\ntype ValidSignInResponse = SigninResponse &\n BearerTokenResponse & {\n token_type: \"Bearer\" | \"bearer\";\n };\n\nconst isValidBearerTokenResponse = (response: unknown): response is ValidSignInResponse =>\n isRecord(response) &&\n requiredStringProperty(response, \"token_type\") &&\n // token_type is case insensitive, some OPs return `token_type: \"bearer\"`\n (response[\"token_type\"] as string).toLowerCase() === \"bearer\" &&\n requiredStringProperty(response, \"access_token\") &&\n requiredStringProperty(response, \"refresh_token\") &&\n (!(\"expires_in\" in response) || typeof response[\"expires_in\"] === \"number\");\n\nexport function validateBearerTokenResponse(response: unknown): asserts response is ValidSignInResponse {\n if (!isValidBearerTokenResponse(response)) {\n throw new Error(OidcError.InvalidBearerTokenResponse);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,YAAY;AAGtC,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,SAAS,QAAQ,YAAY;;AAEtC;AACA;AACA;AACA;;AAoBA,IAAMC,QAAQ,GAAIC,KAAc,IAC5B,CAAC,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AACjE,IAAMG,sBAAsB,GAAGA,CAACC,SAAkC,EAAEC,GAAW,KAAc;EACzF,IAAI,CAACD,SAAS,CAACC,GAAG,CAAC,IAAI,CAACC,sBAAsB,CAACF,SAAS,EAAEC,GAAG,CAAC,EAAE;IAC5DR,MAAM,CAACU,KAAK,iCAAAC,MAAA,CAAiCH,GAAG,CAAE,CAAC;IACnD,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AACD,IAAMC,sBAAsB,GAAGA,CAACF,SAAkC,EAAEC,GAAW,KAAc;EACzF,IAAI,CAAC,CAACD,SAAS,CAACC,GAAG,CAAC,IAAI,OAAOD,SAAS,CAACC,GAAG,CAAC,KAAK,QAAQ,EAAE;IACxDR,MAAM,CAACU,KAAK,sBAAAC,MAAA,CAAsBH,GAAG,CAAE,CAAC;IACxC,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AACD,IAAMI,2BAA2B,GAAGA,CAACL,SAAkC,EAAEC,GAAW,KAAc;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AS,EAAE,mBAAmB,CAAC,CACzD,CAACnB,IAAI,CAAEC,OAAO,IAAK,CAACA,OAAO,CAAC;EAE7B,IAAIF,SAAS,EAAE;IACX,MAAM,IAAIF,KAAK,CAACnB,SAAS,CAAC0C,2BAA2B,CAAC;EAC1D;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;;AAMA,IAAMC,0BAA0B,GAAIC,QAAiB,IACjD3C,QAAQ,CAAC2C,QAAQ,CAAC,IAClBvC,sBAAsB,CAACuC,QAAQ,EAAE,YAAY,CAAC;AAC9C;AACCA,QAAQ,CAAC,YAAY,CAAC,CAAYC,WAAW,CAAC,CAAC,KAAK,QAAQ,IAC7DxC,sBAAsB,CAACuC,QAAQ,EAAE,cAAc,CAAC,IAChDvC,sBAAsB,CAACuC,QAAQ,EAAE,eAAe,CAAC,KAChD,EAAE,YAAY,IAAIA,QAAQ,CAAC,IAAI,OAAOA,QAAQ,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC;AAE/E,OAAO,SAASE,2BAA2BA,CAACF,QAAiB,EAA2C;EACpG,IAAI,CAACD,0BAA0B,CAACC,QAAQ,CAAC,EAAE;IACvC,MAAM,IAAIzB,KAAK,CAACnB,SAAS,CAAC+C,0BAA0B,CAAC;EACzD;AACJ","ignoreList":[]}
|
package/lib/randomstring.d.ts
CHANGED
@@ -1,5 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* String representing the lowercase latin alphabet for use in {@link secureRandomStringFrom}
|
3
|
+
* (can be combined with other such exports or other characters by appending strings)
|
4
|
+
*/
|
5
|
+
export declare const LOWERCASE = "abcdefghijklmnopqrstuvwxyz";
|
6
|
+
/**
|
7
|
+
* String representing the uppercase latin alphabet for use in secureRandomStringFrom
|
8
|
+
* (can be combined with other such exports or other characters by appending strings)
|
9
|
+
*/
|
10
|
+
export declare const UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
11
|
+
/**
|
12
|
+
* String representing the arabic numerals for use in secureRandomStringFrom
|
13
|
+
* (can be combined with other such exports or other characters by appending strings)
|
14
|
+
*/
|
15
|
+
export declare const DIGITS = "0123456789";
|
1
16
|
export declare function secureRandomBase64Url(len: number): string;
|
2
|
-
|
3
|
-
|
4
|
-
|
17
|
+
/**
|
18
|
+
* Generates a random string of uppercase and lowercase letters plus digits using a
|
19
|
+
* cryptographically secure random number generator.
|
20
|
+
* @param len The length of the string to generate
|
21
|
+
* @returns Random string of uppercase and lowercase letters plus digits of length `len`
|
22
|
+
*/
|
23
|
+
export declare function secureRandomString(len: number): string;
|
24
|
+
/**
|
25
|
+
* Generate a cryptographically secure random string using characters given.
|
26
|
+
*
|
27
|
+
* @param len - The length of the string to generate (must be positive and less than 32768).
|
28
|
+
* @param chars - The characters to use in the random string (between 2 and 256 characters long).
|
29
|
+
* @returns Random string of characters of length `len`.
|
30
|
+
*/
|
31
|
+
export declare function secureRandomStringFrom(len: number, chars: string): string;
|
5
32
|
//# sourceMappingURL=randomstring.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"randomstring.d.ts","sourceRoot":"","sources":["../src/randomstring.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"randomstring.d.ts","sourceRoot":"","sources":["../src/randomstring.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,eAAO,MAAM,SAAS,+BAA+B,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,SAAS,+BAA+B,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,MAAM,eAAe,CAAC;AAEnC,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAmCzE"}
|