diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
commit | 633c92eae865e957121e08de634aeee11a8b3992 (patch) | |
tree | 09d881bee1dae0b6eee49db1dfaf0f500240606c /includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto | |
parent | c4657e4509733699c0f26a3c900bab47e915d5a0 (diff) | |
download | pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2 pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip |
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto')
4 files changed, 149 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts new file mode 100644 index 0000000..adfff15 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts @@ -0,0 +1,141 @@ +import type { IToDeviceEvent } from "../sync-accumulator"; +import { MatrixEvent } from "../models/event"; +import { Room } from "../models/room"; +import { CryptoApi } from "../crypto-api"; +import { DeviceTrustLevel, UserTrustLevel } from "../crypto/CrossSigning"; +import { IEncryptedEventInfo } from "../crypto/api"; +import { IEventDecryptionResult } from "../@types/crypto"; +/** + * Common interface for the crypto implementations + */ +export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi { + /** + * Whether sendMessage in a room with unknown and unverified devices + * should throw an error and not send the message. This has 'Global' for + * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently + * no room-level equivalent for this setting. + * + * @remarks this is here, rather than in `CryptoApi`, because I don't think we're + * going to support it in the rust crypto implementation. + */ + globalErrorOnUnknownDevices: boolean; + /** + * Shut down any background processes related to crypto + */ + stop(): void; + /** + * Get the verification level for a given user + * + * TODO: define this better + * + * @param userId - user to be checked + */ + checkUserTrust(userId: string): UserTrustLevel; + /** + * Get the verification level for a given device + * + * TODO: define this better + * + * @param userId - user to be checked + * @param deviceId - device to be checked + */ + checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel; + /** + * Encrypt an event according to the configuration of the room. + * + * @param event - event to be sent + * + * @param room - destination room. + * + * @returns Promise which resolves when the event has been + * encrypted, or null if nothing was needed + */ + encryptEvent(event: MatrixEvent, room: Room): Promise<void>; + /** + * Decrypt a received event + * + * @returns a promise which resolves once we have finished decrypting. + * Rejects with an error if there is a problem decrypting the event. + */ + decryptEvent(event: MatrixEvent): Promise<IEventDecryptionResult>; + /** + * Get information about the encryption of an event + * + * @param event - event to be checked + */ + getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo; +} +/** The methods which crypto implementations should expose to the Sync api */ +export interface SyncCryptoCallbacks { + /** + * Called by the /sync loop whenever there are incoming to-device messages. + * + * The implementation may preprocess the received messages (eg, decrypt them) and return an + * updated list of messages for dispatch to the rest of the system. + * + * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device + * messages, rather than the results of any decryption attempts. + * + * @param events - the received to-device messages + * @returns A list of preprocessed to-device messages. + */ + preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<IToDeviceEvent[]>; + /** + * Called by the /sync loop whenever there are incoming to-device messages. + * + * The implementation may preprocess the received messages (eg, decrypt them) and return an + * updated list of messages for dispatch to the rest of the system. + * + * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device + * messages, rather than the results of any decryption attempts. + * + * @param oneTimeKeysCounts - the received one time key counts + * @returns A list of preprocessed to-device messages. + */ + preprocessOneTimeKeyCounts(oneTimeKeysCounts: Map<string, number>): Promise<void>; + /** + * Called by the /sync loop whenever there are incoming to-device messages. + * + * The implementation may preprocess the received messages (eg, decrypt them) and return an + * updated list of messages for dispatch to the rest of the system. + * + * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device + * messages, rather than the results of any decryption attempts. + * + * @param unusedFallbackKeys - the received unused fallback keys + * @returns A list of preprocessed to-device messages. + */ + preprocessUnusedFallbackKeys(unusedFallbackKeys: Set<string>): Promise<void>; + /** + * Called by the /sync loop whenever an m.room.encryption event is received. + * + * This is called before RoomStateEvents are emitted for any of the events in the /sync + * response (even if the other events technically happened first). This works around a problem + * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message + * in a new room (or one where encryption has been newly enabled): that would otherwise leave the + * crypto layer confused because it expects crypto to be set up, but it has not yet been. + * + * @param room - in which the event was received + * @param event - encryption event to be processed + */ + onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>; + /** + * Called by the /sync loop after each /sync response is processed. + * + * Used to complete batch processing, or to initiate background processes + * + * @param syncState - information about the completed sync. + */ + onSyncCompleted(syncState: OnSyncCompletedData): void; +} +export interface OnSyncCompletedData { + /** + * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync. + */ + nextSyncToken?: string; + /** + * True if we are working our way through a backlog of events after connecting. + */ + catchingUp?: boolean; +} +//# sourceMappingURL=CryptoBackend.d.ts.map
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts.map new file mode 100644 index 0000000..85416cf --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CryptoBackend.d.ts","sourceRoot":"","sources":["../../src/common-crypto/CryptoBackend.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;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CAAC;IAE7E;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D;;;;;;OAMG;IACH,eAAe,CAAC,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACzD;AAED,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB"}
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js new file mode 100644 index 0000000..628411d --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js @@ -0,0 +1,6 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +//# sourceMappingURL=CryptoBackend.js.map
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js.map new file mode 100644 index 0000000..06cee66 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CryptoBackend.js","names":[],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport type { IToDeviceEvent } from \"../sync-accumulator\";\nimport { MatrixEvent } from \"../models/event\";\nimport { Room } from \"../models/room\";\nimport { CryptoApi } from \"../crypto-api\";\nimport { DeviceTrustLevel, UserTrustLevel } from \"../crypto/CrossSigning\";\nimport { IEncryptedEventInfo } from \"../crypto/api\";\nimport { IEventDecryptionResult } from \"../@types/crypto\";\n\n/**\n * Common interface for the crypto implementations\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks this is here, rather than in `CryptoApi`, because I don't think we're\n * going to support it in the rust crypto implementation.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Get the verification level for a given user\n *\n * TODO: define this better\n *\n * @param userId - user to be checked\n */\n checkUserTrust(userId: string): UserTrustLevel;\n\n /**\n * Get the verification level for a given device\n *\n * TODO: define this better\n *\n * @param userId - user to be checked\n * @param deviceId - device to be checked\n */\n checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<IEventDecryptionResult>;\n\n /**\n * Get information about the encryption of an event\n *\n * @param event - event to be checked\n */\n getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo;\n}\n\n/** The methods which crypto implementations should expose to the Sync api */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages.\n */\n preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<IToDeviceEvent[]>;\n\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @returns A list of preprocessed to-device messages.\n */\n preprocessOneTimeKeyCounts(oneTimeKeysCounts: Map<string, number>): Promise<void>;\n\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param unusedFallbackKeys - the received unused fallback keys\n * @returns A list of preprocessed to-device messages.\n */\n preprocessUnusedFallbackKeys(unusedFallbackKeys: Set<string>): Promise<void>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n}\n\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n"],"mappings":""}
\ No newline at end of file |