matrix-js-sdk 41.4.0 → 41.5.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/CHANGELOG.md +12 -0
- package/README.md +1 -0
- package/lib/@types/json.d.ts +7 -0
- package/lib/@types/json.d.ts.map +1 -0
- package/lib/@types/json.js +1 -0
- package/lib/@types/json.js.map +1 -0
- package/lib/@types/requests.d.ts +6 -9
- package/lib/@types/requests.d.ts.map +1 -1
- package/lib/@types/requests.js.map +1 -1
- package/lib/client.d.ts +17 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +27 -12
- package/lib/client.js.map +1 -1
- package/lib/filter.d.ts +20 -5
- package/lib/filter.d.ts.map +1 -1
- package/lib/filter.js +21 -0
- package/lib/filter.js.map +1 -1
- package/lib/models/user.d.ts +5 -0
- package/lib/models/user.d.ts.map +1 -1
- package/lib/models/user.js +5 -0
- package/lib/models/user.js.map +1 -1
- package/lib/oidc/authorize.d.ts +60 -0
- package/lib/oidc/authorize.d.ts.map +1 -1
- package/lib/oidc/authorize.js +115 -2
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/register.d.ts.map +1 -1
- package/lib/oidc/register.js +5 -0
- package/lib/oidc/register.js.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +19 -2
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +126 -36
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +4 -2
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/index.d.ts +36 -0
- package/lib/rendezvous/index.d.ts.map +1 -1
- package/lib/rendezvous/index.js +115 -0
- package/lib/rendezvous/index.js.map +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +2 -2
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/store/index.d.ts +17 -1
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js.map +1 -1
- package/lib/store/indexeddb-backend.d.ts +4 -0
- package/lib/store/indexeddb-backend.d.ts.map +1 -1
- package/lib/store/indexeddb-backend.js.map +1 -1
- package/lib/store/indexeddb-local-backend.d.ts +4 -1
- package/lib/store/indexeddb-local-backend.d.ts.map +1 -1
- package/lib/store/indexeddb-local-backend.js +45 -3
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb-remote-backend.d.ts +4 -0
- package/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
- package/lib/store/indexeddb-remote-backend.js +21 -3
- package/lib/store/indexeddb-remote-backend.js.map +1 -1
- package/lib/store/indexeddb-store-worker.d.ts.map +1 -1
- package/lib/store/indexeddb-store-worker.js +10 -1
- package/lib/store/indexeddb-store-worker.js.map +1 -1
- package/lib/store/indexeddb.d.ts +4 -0
- package/lib/store/indexeddb.d.ts.map +1 -1
- package/lib/store/indexeddb.js +18 -0
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/store/memory.d.ts +5 -1
- package/lib/store/memory.d.ts.map +1 -1
- package/lib/store/memory.js +19 -0
- package/lib/store/memory.js.map +1 -1
- package/lib/store/stub.d.ts +3 -0
- package/lib/store/stub.d.ts.map +1 -1
- package/lib/store/stub.js +15 -0
- package/lib/store/stub.js.map +1 -1
- package/lib/sync-accumulator.d.ts +15 -0
- package/lib/sync-accumulator.d.ts.map +1 -1
- package/lib/sync-accumulator.js +4 -0
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts +9 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +51 -9
- package/lib/sync.js.map +1 -1
- package/lib/webrtc/call.d.ts.map +1 -1
- package/lib/webrtc/call.js +1 -2
- package/lib/webrtc/call.js.map +1 -1
- package/package.json +7 -7
- package/src/@types/json.ts +16 -0
- package/src/@types/requests.ts +6 -9
- package/src/client.ts +40 -12
- package/src/filter.ts +31 -5
- package/src/models/user.ts +6 -0
- package/src/oidc/authorize.ts +135 -2
- package/src/oidc/register.ts +5 -0
- package/src/rendezvous/MSC4108SignInWithQR.ts +117 -4
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +10 -2
- package/src/rendezvous/index.ts +115 -0
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +1 -1
- package/src/rust-crypto/rust-crypto.ts +6 -3
- package/src/store/index.ts +20 -1
- package/src/store/indexeddb-backend.ts +4 -0
- package/src/store/indexeddb-local-backend.ts +32 -1
- package/src/store/indexeddb-remote-backend.ts +13 -0
- package/src/store/indexeddb-store-worker.ts +9 -0
- package/src/store/indexeddb.ts +13 -0
- package/src/store/memory.ts +14 -1
- package/src/store/stub.ts +12 -0
- package/src/sync-accumulator.ts +16 -1
- package/src/sync.ts +48 -4
- package/src/webrtc/call.ts +1 -2
package/lib/store/stub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stub.d.ts","sourceRoot":"","sources":["../../src/store/stub.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,M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AiB,GAAG,SAAS,CAAC;IAI1D,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAIlE,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAIxD,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC;IAIpC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
package/lib/store/stub.js
CHANGED
|
@@ -261,6 +261,21 @@ export class StubStore {
|
|
|
261
261
|
return Promise.resolve();
|
|
262
262
|
})();
|
|
263
263
|
}
|
|
264
|
+
getUserProfile() {
|
|
265
|
+
return _asyncToGenerator(function* () {
|
|
266
|
+
return undefined;
|
|
267
|
+
})();
|
|
268
|
+
}
|
|
269
|
+
storeUserProfiles() {
|
|
270
|
+
return _asyncToGenerator(function* () {
|
|
271
|
+
return;
|
|
272
|
+
})();
|
|
273
|
+
}
|
|
274
|
+
removeUserProfiles() {
|
|
275
|
+
return _asyncToGenerator(function* () {
|
|
276
|
+
return;
|
|
277
|
+
})();
|
|
278
|
+
}
|
|
264
279
|
destroy() {
|
|
265
280
|
return _asyncToGenerator(function* () {})();
|
|
266
281
|
} // Nothing to do
|
package/lib/store/stub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stub.js","names":["StubStore","constructor","_defineProperty","Map","isNewlyCreated","Promise","resolve","getSyncToken","fromToken","setSyncToken","token","storeRoom","room","getRoom","roomId","getRooms","removeRoom","getRoomSummaries","storeUser","user","getUser","userId","getUsers","scrollback","limit","setUserCreator","creator","storeEvents","events","toStart","storeFilter","filter","getFilter","filterId","getFilterIdByName","filterName","setFilterIdByName","storeAccountDataEvents","getAccountData","eventType","undefined","setSyncData","syncData","wantsSave","save","startup","getSavedSync","getSavedSyncToken","deleteAllData","getOutOfBandMembers","setOutOfBandMembers","membershipEvents","clearOutOfBandMembers","getClientOptions","storeClientOptions","options","getPendingEvents","_asyncToGenerator","setPendingEvents","saveToDeviceBatches","batch","getOldestToDeviceBatch","removeToDeviceBatch","id","destroy"],"sources":["../../src/store/stub.ts"],"sourcesContent":["/*\nCopyright 2015 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * This is an internal module.\n */\n\nimport { type EventType } from \"../@types/event.ts\";\nimport { type Room } from \"../models/room.ts\";\nimport { type User } from \"../models/user.ts\";\nimport { type IEvent, type MatrixEvent } from \"../models/event.ts\";\nimport { type Filter } from \"../filter.ts\";\nimport { type ISavedSync, type IStore, type UserCreator } from \"./index.ts\";\nimport { type RoomSummary } from \"../models/room-summary.ts\";\nimport { type ISyncResponse } from \"../sync-accumulator.ts\";\nimport { type IStateEventWithRoomId } from \"../@types/search.ts\";\nimport { type IndexedToDeviceBatch, type ToDeviceBatch } from \"../models/ToDeviceMessage.ts\";\nimport { type IStoredClientOpts } from \"../client.ts\";\n\n/**\n * Construct a stub store. This does no-ops on most store methods.\n */\nexport class StubStore implements IStore {\n public readonly accountData = new Map(); // stub\n private fromToken: string | null = null;\n\n /** @returns whether or not the database was newly created in this session. */\n public isNewlyCreated(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n /**\n * Get the sync token.\n */\n public getSyncToken(): string | null {\n return this.fromToken;\n }\n\n /**\n * Set the sync token.\n */\n public setSyncToken(token: string): void {\n this.fromToken = token;\n }\n\n /**\n * No-op.\n */\n public storeRoom(room: Room): void {}\n\n /**\n * No-op.\n */\n public getRoom(roomId: string): Room | null {\n return null;\n }\n\n /**\n * No-op.\n * @returns An empty array.\n */\n public getRooms(): Room[] {\n return [];\n }\n\n /**\n * Permanently delete a room.\n */\n public removeRoom(roomId: string): void {\n return;\n }\n\n /**\n * No-op.\n * @returns An empty array.\n */\n public getRoomSummaries(): RoomSummary[] {\n return [];\n }\n\n /**\n * No-op.\n */\n public storeUser(user: User): void {}\n\n /**\n * No-op.\n */\n public getUser(userId: string): User | null {\n return null;\n }\n\n /**\n * No-op.\n */\n public getUsers(): User[] {\n return [];\n }\n\n /**\n * No-op.\n */\n public scrollback(room: Room, limit: number): MatrixEvent[] {\n return [];\n }\n\n /**\n * No-op.\n */\n public setUserCreator(creator: UserCreator): void {\n return;\n }\n\n /**\n * Store events for a room.\n * @param room - The room to store events for.\n * @param events - The events to store.\n * @param token - The token associated with these events.\n * @param toStart - True if these are paginated results.\n */\n public storeEvents(room: Room, events: MatrixEvent[], token: string | null, toStart: boolean): void {}\n\n /**\n * Store a filter.\n */\n public storeFilter(filter: Filter): void {}\n\n /**\n * Retrieve a filter.\n * @returns A filter or null.\n */\n public getFilter(userId: string, filterId: string): Filter | null {\n return null;\n }\n\n /**\n * Retrieve a filter ID with the given name.\n * @param filterName - The filter name.\n * @returns The filter ID or null.\n */\n public getFilterIdByName(filterName: string): string | null {\n return null;\n }\n\n /**\n * Set a filter name to ID mapping.\n */\n public setFilterIdByName(filterName: string, filterId?: string): void {}\n\n /**\n * Store user-scoped account data events\n * @param events - The events to store.\n */\n public storeAccountDataEvents(events: MatrixEvent[]): void {}\n\n /**\n * Get account data event by event type\n * @param eventType - The event type being queried\n */\n public getAccountData(eventType: EventType | string): MatrixEvent | undefined {\n return undefined;\n }\n\n /**\n * setSyncData does nothing as there is no backing data store.\n *\n * @param syncData - The sync data\n * @returns An immediately resolved promise.\n */\n public setSyncData(syncData: ISyncResponse): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * We never want to save because we have nothing to save to.\n *\n * @returns If the store wants to save\n */\n public wantsSave(): boolean {\n return false;\n }\n\n /**\n * Save does nothing as there is no backing data store.\n */\n public save(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Startup does nothing.\n * @returns An immediately resolved promise.\n */\n public startup(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * @returns Promise which resolves with a sync response to restore the\n * client state to where it was at the last save, or null if there\n * is no saved sync data.\n */\n public getSavedSync(): Promise<ISavedSync | null> {\n return Promise.resolve(null);\n }\n\n /**\n * @returns If there is a saved sync, the nextBatch token\n * for this sync, otherwise null.\n */\n public getSavedSyncToken(): Promise<string | null> {\n return Promise.resolve(null);\n }\n\n /**\n * Delete all data from this store. Does nothing since this store\n * doesn't store anything.\n * @returns An immediately resolved promise.\n */\n public deleteAllData(): Promise<void> {\n return Promise.resolve();\n }\n\n public getOutOfBandMembers(): Promise<IStateEventWithRoomId[] | null> {\n return Promise.resolve(null);\n }\n\n public setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void> {\n return Promise.resolve();\n }\n\n public clearOutOfBandMembers(): Promise<void> {\n return Promise.resolve();\n }\n\n public getClientOptions(): Promise<IStoredClientOpts | undefined> {\n return Promise.resolve(undefined);\n }\n\n public storeClientOptions(options: IStoredClientOpts): Promise<void> {\n return Promise.resolve();\n }\n\n public async getPendingEvents(roomId: string): Promise<Partial<IEvent>[]> {\n return [];\n }\n\n public setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void> {\n return Promise.resolve();\n }\n\n public async saveToDeviceBatches(batch: ToDeviceBatch[]): Promise<void> {\n return Promise.resolve();\n }\n\n public getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null> {\n return Promise.resolve(null);\n }\n\n public async removeToDeviceBatch(id: number): Promise<void> {\n return Promise.resolve();\n }\n\n public async destroy(): Promise<void> {\n // Nothing to do\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAcA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,CAAmB;EAAAC,YAAA;IAAAC,eAAA,sBACP,IAAIC,GAAG,CAAC,CAAC;IAAE;IAAAD,eAAA,oBACN,IAAI;EAAA;EAEvC;EACOE,cAAcA,CAAA,EAAqB;IACtC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;;EAEA;AACJ;AACA;EACWC,YAAYA,CAAA,EAAkB;IACjC,OAAO,IAAI,CAACC,SAAS;EACzB;;EAEA;AACJ;AACA;EACWC,YAAYA,CAACC,KAAa,EAAQ;IACrC,IAAI,CAACF,SAAS,GAAGE,KAAK;EAC1B;;EAEA;AACJ;AACA;EACWC,SAASA,CAACC,IAAU,EAAQ,CAAC;;EAEpC;AACJ;AACA;EACWC,OAAOA,CAACC,MAAc,EAAe;IACxC,OAAO,IAAI;EACf;;EAEA;AACJ;AACA;AACA;EACWC,QAAQA,CAAA,EAAW;IACtB,OAAO,EAAE;EACb;;EAEA;AACJ;AACA;EACWC,UAAUA,CAACF,MAAc,EAAQ;IACpC;EACJ;;EAEA;AACJ;AACA;AACA;EACWG,gBAAgBA,CAAA,EAAkB;IACrC,OAAO,EAAE;EACb;;EAEA;AACJ;AACA;EACWC,SAASA,CAACC,IAAU,EAAQ,CAAC;;EAEpC;AACJ;AACA;EACWC,OAAOA,CAACC,MAAc,EAAe;IACxC,OAAO,IAAI;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O,CAACC,OAAO,CAAC,CAAC;IAAC;EAC7B;EAEa0D,OAAOA,CAAA,EAAkB;IAAA,OAAAP,iBAAA;EAEtC,CAAC,CADG;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"stub.js","names":["StubStore","constructor","_defineProperty","Map","isNewlyCreated","Promise","resolve","getSyncToken","fromToken","setSyncToken","token","storeRoom","room","getRoom","roomId","getRooms","removeRoom","getRoomSummaries","storeUser","user","getUser","userId","getUsers","scrollback","limit","setUserCreator","creator","storeEvents","events","toStart","storeFilter","filter","getFilter","filterId","getFilterIdByName","filterName","setFilterIdByName","storeAccountDataEvents","getAccountData","eventType","undefined","setSyncData","syncData","wantsSave","save","startup","getSavedSync","getSavedSyncToken","deleteAllData","getOutOfBandMembers","setOutOfBandMembers","membershipEvents","clearOutOfBandMembers","getClientOptions","storeClientOptions","options","getPendingEvents","_asyncToGenerator","setPendingEvents","saveToDeviceBatches","batch","getOldestToDeviceBatch","removeToDeviceBatch","id","getUserProfile","storeUserProfiles","removeUserProfiles","destroy"],"sources":["../../src/store/stub.ts"],"sourcesContent":["/*\nCopyright 2015 - 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * This is an internal module.\n */\n\nimport { type EventType } from \"../@types/event.ts\";\nimport { type Room } from \"../models/room.ts\";\nimport { type User } from \"../models/user.ts\";\nimport { type IEvent, type MatrixEvent } from \"../models/event.ts\";\nimport { type Filter } from \"../filter.ts\";\nimport { type ISavedSync, type IStore, type UserCreator } from \"./index.ts\";\nimport { type RoomSummary } from \"../models/room-summary.ts\";\nimport { type ISyncResponse } from \"../sync-accumulator.ts\";\nimport { type IStateEventWithRoomId } from \"../@types/search.ts\";\nimport { type IndexedToDeviceBatch, type ToDeviceBatch } from \"../models/ToDeviceMessage.ts\";\nimport { type IStoredClientOpts } from \"../client.ts\";\n\n/**\n * Construct a stub store. This does no-ops on most store methods.\n */\nexport class StubStore implements IStore {\n public readonly accountData = new Map(); // stub\n private fromToken: string | null = null;\n\n /** @returns whether or not the database was newly created in this session. */\n public isNewlyCreated(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n /**\n * Get the sync token.\n */\n public getSyncToken(): string | null {\n return this.fromToken;\n }\n\n /**\n * Set the sync token.\n */\n public setSyncToken(token: string): void {\n this.fromToken = token;\n }\n\n /**\n * No-op.\n */\n public storeRoom(room: Room): void {}\n\n /**\n * No-op.\n */\n public getRoom(roomId: string): Room | null {\n return null;\n }\n\n /**\n * No-op.\n * @returns An empty array.\n */\n public getRooms(): Room[] {\n return [];\n }\n\n /**\n * Permanently delete a room.\n */\n public removeRoom(roomId: string): void {\n return;\n }\n\n /**\n * No-op.\n * @returns An empty array.\n */\n public getRoomSummaries(): RoomSummary[] {\n return [];\n }\n\n /**\n * No-op.\n */\n public storeUser(user: User): void {}\n\n /**\n * No-op.\n */\n public getUser(userId: string): User | null {\n return null;\n }\n\n /**\n * No-op.\n */\n public getUsers(): User[] {\n return [];\n }\n\n /**\n * No-op.\n */\n public scrollback(room: Room, limit: number): MatrixEvent[] {\n return [];\n }\n\n /**\n * No-op.\n */\n public setUserCreator(creator: UserCreator): void {\n return;\n }\n\n /**\n * Store events for a room.\n * @param room - The room to store events for.\n * @param events - The events to store.\n * @param token - The token associated with these events.\n * @param toStart - True if these are paginated results.\n */\n public storeEvents(room: Room, events: MatrixEvent[], token: string | null, toStart: boolean): void {}\n\n /**\n * Store a filter.\n */\n public storeFilter(filter: Filter): void {}\n\n /**\n * Retrieve a filter.\n * @returns A filter or null.\n */\n public getFilter(userId: string, filterId: string): Filter | null {\n return null;\n }\n\n /**\n * Retrieve a filter ID with the given name.\n * @param filterName - The filter name.\n * @returns The filter ID or null.\n */\n public getFilterIdByName(filterName: string): string | null {\n return null;\n }\n\n /**\n * Set a filter name to ID mapping.\n */\n public setFilterIdByName(filterName: string, filterId?: string): void {}\n\n /**\n * Store user-scoped account data events\n * @param events - The events to store.\n */\n public storeAccountDataEvents(events: MatrixEvent[]): void {}\n\n /**\n * Get account data event by event type\n * @param eventType - The event type being queried\n */\n public getAccountData(eventType: EventType | string): MatrixEvent | undefined {\n return undefined;\n }\n\n /**\n * setSyncData does nothing as there is no backing data store.\n *\n * @param syncData - The sync data\n * @returns An immediately resolved promise.\n */\n public setSyncData(syncData: ISyncResponse): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * We never want to save because we have nothing to save to.\n *\n * @returns If the store wants to save\n */\n public wantsSave(): boolean {\n return false;\n }\n\n /**\n * Save does nothing as there is no backing data store.\n */\n public save(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Startup does nothing.\n * @returns An immediately resolved promise.\n */\n public startup(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * @returns Promise which resolves with a sync response to restore the\n * client state to where it was at the last save, or null if there\n * is no saved sync data.\n */\n public getSavedSync(): Promise<ISavedSync | null> {\n return Promise.resolve(null);\n }\n\n /**\n * @returns If there is a saved sync, the nextBatch token\n * for this sync, otherwise null.\n */\n public getSavedSyncToken(): Promise<string | null> {\n return Promise.resolve(null);\n }\n\n /**\n * Delete all data from this store. Does nothing since this store\n * doesn't store anything.\n * @returns An immediately resolved promise.\n */\n public deleteAllData(): Promise<void> {\n return Promise.resolve();\n }\n\n public getOutOfBandMembers(): Promise<IStateEventWithRoomId[] | null> {\n return Promise.resolve(null);\n }\n\n public setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void> {\n return Promise.resolve();\n }\n\n public clearOutOfBandMembers(): Promise<void> {\n return Promise.resolve();\n }\n\n public getClientOptions(): Promise<IStoredClientOpts | undefined> {\n return Promise.resolve(undefined);\n }\n\n public storeClientOptions(options: IStoredClientOpts): Promise<void> {\n return Promise.resolve();\n }\n\n public async getPendingEvents(roomId: string): Promise<Partial<IEvent>[]> {\n return [];\n }\n\n public setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void> {\n return Promise.resolve();\n }\n\n public async saveToDeviceBatches(batch: ToDeviceBatch[]): Promise<void> {\n return Promise.resolve();\n }\n\n public getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null> {\n return Promise.resolve(null);\n }\n\n public async removeToDeviceBatch(id: number): Promise<void> {\n return Promise.resolve();\n }\n\n public async getUserProfile(): Promise<undefined> {\n return undefined;\n }\n\n public async storeUserProfiles(): Promise<void> {\n return;\n }\n\n public async removeUserProfiles(): Promise<void> {\n return;\n }\n\n public async destroy(): Promise<void> {\n // Nothing to do\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAcA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,CAAmB;EAAAC,YAAA;IAAAC,eAAA,sBACP,IAAIC,GAAG,CAAC,CAAC;IAAE;IAAAD,eAAA,oBACN,IAAI;EAAA;EAEvC;EACOE,cAAcA,CAAA,EAAqB;IACtC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;;EAEA;AACJ;AACA;EACWC,YAAYA,CAAA,EAAkB;IACjC,OAAO,IAAI,CAACC,SAAS;EACzB;;EAEA;AACJ;AACA;EACWC,YAAYA,CAACC,KAAa,EAAQ;IACrC,IAAI,CAACF,SAAS,GAAGE,KAAK;EAC1B;;EAEA;AACJ;AACA;EACWC,SAASA,CAACC,IAAU,EAAQ,CAAC;;EAEpC;AACJ;AACA;EACWC,OAAOA,CAACC,MAAc,EAAe;IACxC,OAAO,IAAI;EACf;;EAEA;AACJ;AACA;AACA;EACWC,QAAQA,CAAA,EAAW;IACtB,OAAO,EAAE;EACb;;EA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C,KAAsB,EAAiB;IAAA,OAAAH,iBAAA;MACpE,OAAOpD,OAAO,CAACC,OAAO,CAAC,CAAC;IAAC;EAC7B;EAEOuD,sBAAsBA,CAAA,EAAyC;IAClE,OAAOxD,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEawD,mBAAmBA,CAACC,EAAU,EAAiB;IAAA,OAAAN,iBAAA;MACxD,OAAOpD,OAAO,CAACC,OAAO,CAAC,CAAC;IAAC;EAC7B;EAEa0D,cAAcA,CAAA,EAAuB;IAAA,OAAAP,iBAAA;MAC9C,OAAOjB,SAAS;IAAC;EACrB;EAEayB,iBAAiBA,CAAA,EAAkB;IAAA,OAAAR,iBAAA;MAC5C;IAAO;EACX;EAEaS,kBAAkBA,CAAA,EAAkB;IAAA,OAAAT,iBAAA;MAC7C;IAAO;EACX;EAEaU,OAAOA,CAAA,EAAkB;IAAA,OAAAV,iBAAA;EAEtC,CAAC,CADG;AAER","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@ import { type IContent, type IUnsigned } from "./models/event.ts";
|
|
|
2
2
|
import { type IRoomSummary } from "./models/room-summary.ts";
|
|
3
3
|
import { type EventType } from "./@types/event.ts";
|
|
4
4
|
import { type OlmEncryptionInfo } from "./crypto-api/index.ts";
|
|
5
|
+
import { type SyncUserProfile } from "./matrix.ts";
|
|
5
6
|
interface IOpts {
|
|
6
7
|
/**
|
|
7
8
|
* The ideal maximum number of timeline entries to keep in the sync response.
|
|
@@ -11,6 +12,10 @@ interface IOpts {
|
|
|
11
12
|
* Default: 50.
|
|
12
13
|
*/
|
|
13
14
|
maxTimelineEntries?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to use the stable or unstable fields for user profiles.
|
|
17
|
+
*/
|
|
18
|
+
profileFieldsStable?: boolean;
|
|
14
19
|
}
|
|
15
20
|
export interface IMinimalEvent {
|
|
16
21
|
content: IContent;
|
|
@@ -133,6 +138,14 @@ export interface IDeviceLists {
|
|
|
133
138
|
changed?: string[];
|
|
134
139
|
left?: string[];
|
|
135
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* The "users" section of the sync update which contains extended profile updates.
|
|
143
|
+
*/
|
|
144
|
+
export interface UsersUpdate {
|
|
145
|
+
[userId: string]: {
|
|
146
|
+
profile_updates?: SyncUserProfile | null;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
136
149
|
export interface ISyncResponse {
|
|
137
150
|
"next_batch": string;
|
|
138
151
|
"rooms": IRooms;
|
|
@@ -141,6 +154,8 @@ export interface ISyncResponse {
|
|
|
141
154
|
"to_device"?: IToDevice;
|
|
142
155
|
"device_lists"?: IDeviceLists;
|
|
143
156
|
"device_one_time_keys_count"?: Record<string, number>;
|
|
157
|
+
"users"?: UsersUpdate;
|
|
158
|
+
"org.matrix.msc4429.users"?: UsersUpdate;
|
|
144
159
|
"device_unused_fallback_key_types"?: string[];
|
|
145
160
|
"org.matrix.msc2732.device_unused_fallback_key_types"?: string[];
|
|
146
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-accumulator.d.ts","sourceRoot":"","sources":["../src/sync-accumulator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA0B,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-accumulator.d.ts","sourceRoot":"","sources":["../src/sync-accumulator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA0B,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,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10 @@ import { ReceiptAccumulator } from "./receipt-accumulator.js";
|
|
|
38
38
|
* The `message` field contains the message `type`, `content`, and `sender` as if the message was sent in clear.
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* The "users" section of the sync update which contains extended profile updates.
|
|
43
|
+
*/
|
|
44
|
+
|
|
41
45
|
/* eslint-enable camelcase */
|
|
42
46
|
|
|
43
47
|
export var Category = /*#__PURE__*/function (Category) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-accumulator.js","names":["logger","deepCopy","MAX_STICKY_DURATION_MS","UNREAD_THREAD_NOTIFICATIONS","ReceiptAccumulator","Category","isTaggedEvent","event","undefined","SyncAccumulator","constructor","opts","arguments","length","_defineProperty","maxTimelineEntries","accumulate","syncResponse","fromDatabase","accumulateRooms","accumulateAccountData","nextBatch","next_batch","account_data","events","forEach","e","accountData","type","rooms","invite","Object","keys","roomId","accumulateRoom","Invite","join","Join","leave","Leave","knock","Knock","category","data","knockRooms","accumulateInviteState","accumulateKnockState","inviteRooms","accumulateJoinState","joinRooms","error","invite_state","currentData","hasAdded","i","current","state_key","push","knock_state","_ref","_data","_data$ephemeral","_data$state","_data$orgMatrixMsc","_data$timeline","_data$msc4354_sticky","now","Date","_currentState","create","_timeline","_accountData","_unreadNotifications","_unreadThreadNotifications","_summary","_receipts","_stickyEvents","unread_notifications","stable","unstable","summary","_sum$HEROES_KEY","_sum$JOINED_COUNT_KEY","_sum$INVITED_COUNT_KE","HEROES_KEY","INVITED_COUNT_KEY","JOINED_COUNT_KEY","acc","sum","consumeEphemeralEvents","ephemeral","timeline","limited","state","setState","index","_data$timeline$prev_b","transformedEvent","_e$unsigned","assign","unsigned","age","_localTs","token","prev_batch","filter","_ref2","expiresTs","msc4354_sticky","concat","map","cappedDuration","Math","min","duration_ms","createdTs","origin_server_ts","startIndex","slice","getJSON","forDatabase","_roomData$_stickyEven","roomData","roomJson","evType","receiptEvent","buildAccumulatedReceiptEvent","msgData","rollBackState","timelineEvent","prevStateEvent","prev_content","content","prev_sender","sender","stateKey","ev","accData","roomsData","getNextBatchToken","eventMap"],"sources":["../src/sync-accumulator.ts"],"sourcesContent":["/*\nCopyright 2017 - 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\n/**\n * This is an internal module. See {@link SyncAccumulator} for the public class.\n */\n\nimport { logger } from \"./logger.ts\";\nimport { deepCopy } from \"./utils.ts\";\nimport { MAX_STICKY_DURATION_MS, type IContent, type IUnsigned } from \"./models/event.ts\";\nimport { type IRoomSummary } from \"./models/room-summary.ts\";\nimport { type EventType } from \"./@types/event.ts\";\nimport { UNREAD_THREAD_NOTIFICATIONS } from \"./@types/sync.ts\";\nimport { ReceiptAccumulator } from \"./receipt-accumulator.ts\";\nimport { type OlmEncryptionInfo } from \"./crypto-api/index.ts\";\n\ninterface IOpts {\n /**\n * The ideal maximum number of timeline entries to keep in the sync response.\n * This is best-effort, as clients do not always have a back-pagination token for each event,\n * so it's possible there may be slightly *less* than this value. There will never be more.\n * This cannot be 0 or else it makes it impossible to scroll back in a room.\n * Default: 50.\n */\n maxTimelineEntries?: number;\n}\n\nexport interface IMinimalEvent {\n content: IContent;\n type: EventType | string;\n room_id?: string;\n unsigned?: IUnsigned;\n}\n\nexport interface IEphemeral {\n events: IMinimalEvent[];\n}\n\n/* eslint-disable camelcase */\ninterface UnreadNotificationCounts {\n highlight_count?: number;\n notification_count?: number;\n}\n\nexport interface IRoomEvent extends IMinimalEvent {\n event_id: string;\n sender: string;\n origin_server_ts: number;\n}\n\nexport interface IStateEvent extends IRoomEvent {\n prev_content?: IContent;\n state_key: string;\n}\n\ninterface IState {\n events: IStateEvent[];\n}\n\nexport interface ITimeline {\n events: Array<IRoomEvent | IStateEvent>;\n limited?: boolean;\n prev_batch: string | null;\n}\n\ntype StickyEventFields = {\n msc4354_sticky: { duration_ms: number };\n content: { msc4354_sticky_key?: string };\n};\n\nexport type IStickyEvent = IRoomEvent & StickyEventFields;\n\nexport type IStickyStateEvent = IStateEvent & StickyEventFields;\n\nexport interface ISticky {\n events: Array<IStickyEvent | IStickyStateEvent>;\n}\n\nexport interface IJoinedRoom {\n \"summary\": IRoomSummary;\n // One of `state` or `state_after` is required.\n \"state\"?: IState;\n \"org.matrix.msc4222.state_after\"?: IState; // https://github.com/matrix-org/matrix-spec-proposals/pull/4222\n \"msc4354_sticky\"?: ISticky; // https://github.com/matrix-org/matrix-spec-proposals/pull/4354\n \"timeline\": ITimeline;\n \"ephemeral\": IEphemeral;\n \"account_data\": IAccountData;\n \"unread_notifications\": UnreadNotificationCounts;\n \"unread_thread_notifications\"?: Record<string, UnreadNotificationCounts>;\n \"org.matrix.msc3773.unread_thread_notifications\"?: Record<string, UnreadNotificationCounts>;\n}\n\nexport interface IStrippedState {\n content: IContent;\n state_key: string;\n type: EventType | string;\n sender: string;\n}\n\nexport interface IInviteState {\n events: IStrippedState[];\n}\n\nexport interface IKnockState {\n events: IStrippedState[];\n}\n\nexport interface IInvitedRoom {\n invite_state: IInviteState;\n}\n\nexport interface ILeftRoom {\n // One of `state` or `state_after` is required.\n \"state\"?: IState;\n \"org.matrix.msc4222.state_after\"?: IState;\n \"timeline\": ITimeline;\n \"account_data\": IAccountData;\n}\n\nexport interface IKnockedRoom {\n knock_state: IKnockState;\n}\n\nexport interface IRooms {\n [Category.Join]: Record<string, IJoinedRoom>;\n [Category.Invite]: Record<string, IInvitedRoom>;\n [Category.Leave]: Record<string, ILeftRoom>;\n [Category.Knock]: Record<string, IKnockedRoom>;\n}\n\ninterface IPresence {\n events: IMinimalEvent[];\n}\n\ninterface IAccountData {\n events: IMinimalEvent[];\n}\n\n/** A to-device message as received from the sync. */\nexport interface IToDeviceEvent {\n content: IContent;\n sender: string;\n type: string;\n}\n\n/**\n * A (possibly decrypted) to-device message after it has been successfully processed by the sdk.\n *\n * If the message was encrypted, the `encryptionInfo` field will contain the encryption information.\n * If the message was sent in clear, this field will be null.\n *\n * The `message` field contains the message `type`, `content`, and `sender` as if the message was sent in clear.\n */\nexport interface ReceivedToDeviceMessage {\n /** The message type, content, and sender as if the message was sent in clear. */\n message: IToDeviceEvent;\n /**\n * Information about the encryption of the message.\n * Will be null if the message was sent in clear\n */\n encryptionInfo: OlmEncryptionInfo | null;\n}\n\ninterface IToDevice {\n events: IToDeviceEvent[];\n}\n\nexport interface IDeviceLists {\n changed?: string[];\n left?: string[];\n}\n\nexport interface ISyncResponse {\n \"next_batch\": string;\n \"rooms\": IRooms;\n \"presence\"?: IPresence;\n \"account_data\": IAccountData;\n \"to_device\"?: IToDevice;\n \"device_lists\"?: IDeviceLists;\n \"device_one_time_keys_count\"?: Record<string, number>;\n\n \"device_unused_fallback_key_types\"?: string[];\n \"org.matrix.msc2732.device_unused_fallback_key_types\"?: string[];\n}\n/* eslint-enable camelcase */\n\nexport enum Category {\n Invite = \"invite\",\n Leave = \"leave\",\n Join = \"join\",\n Knock = \"knock\",\n}\n\ninterface IRoom {\n _currentState: { [eventType: string]: { [stateKey: string]: IStateEvent } };\n _timeline: {\n event: IRoomEvent | IStateEvent;\n token: string | null;\n }[];\n _summary: Partial<IRoomSummary>;\n _accountData: { [eventType: string]: IMinimalEvent };\n _unreadNotifications: Partial<UnreadNotificationCounts>;\n _unreadThreadNotifications?: Record<string, Partial<UnreadNotificationCounts>>;\n _receipts: ReceiptAccumulator;\n _stickyEvents: {\n readonly event: IStickyEvent | IStickyStateEvent;\n /**\n * This is the timestamp at which point it is safe to remove this event from the store.\n * This value is immutable\n */\n readonly expiresTs: number;\n }[];\n}\n\nexport interface ISyncData {\n nextBatch: string;\n accountData: IMinimalEvent[];\n roomsData: IRooms;\n}\n\ntype TaggedEvent = IRoomEvent & { _localTs?: number };\n\nfunction isTaggedEvent(event: IRoomEvent): event is TaggedEvent {\n return \"_localTs\" in event && event[\"_localTs\"] !== undefined;\n}\n\n/**\n * The purpose of this class is to accumulate /sync responses such that a\n * complete \"initial\" JSON response can be returned which accurately represents\n * the sum total of the /sync responses accumulated to date. It only handles\n * room data: that is, everything under the \"rooms\" top-level key.\n *\n * This class is used when persisting room data so a complete /sync response can\n * be loaded from disk and incremental syncs can be performed on the server,\n * rather than asking the server to do an initial sync on startup.\n */\nexport class SyncAccumulator {\n private accountData: Record<string, IMinimalEvent> = {}; // $event_type: Object\n private inviteRooms: Record<string, IInvitedRoom> = {}; // $roomId: { ... sync 'invite' json data ... }\n private knockRooms: Record<string, IKnockedRoom> = {}; // $roomId: { ... sync 'knock' json data ... }\n private joinRooms: { [roomId: string]: IRoom } = {};\n // the /sync token which corresponds to the last time rooms were\n // accumulated. We remember this so that any caller can obtain a\n // coherent /sync response and know at what point they should be\n // streaming from without losing events.\n private nextBatch: string | null = null;\n\n public constructor(private readonly opts: IOpts = {}) {\n this.opts.maxTimelineEntries = this.opts.maxTimelineEntries || 50;\n }\n\n public accumulate(syncResponse: ISyncResponse, fromDatabase = false): void {\n this.accumulateRooms(syncResponse, fromDatabase);\n this.accumulateAccountData(syncResponse);\n this.nextBatch = syncResponse.next_batch;\n }\n\n private accumulateAccountData(syncResponse: ISyncResponse): void {\n if (!syncResponse.account_data || !syncResponse.account_data.events) {\n return;\n }\n // Clobbers based on event type.\n syncResponse.account_data.events.forEach((e) => {\n this.accountData[e.type] = e;\n });\n }\n\n /**\n * Accumulate incremental /sync room data.\n * @param syncResponse - the complete /sync JSON\n * @param fromDatabase - True if the sync response is one saved to the database\n */\n private accumulateRooms(syncResponse: ISyncResponse, fromDatabase = false): void {\n if (!syncResponse.rooms) {\n return;\n }\n if (syncResponse.rooms.invite) {\n Object.keys(syncResponse.rooms.invite).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Invite, syncResponse.rooms.invite[roomId], fromDatabase);\n });\n }\n if (syncResponse.rooms.join) {\n Object.keys(syncResponse.rooms.join).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Join, syncResponse.rooms.join[roomId], fromDatabase);\n });\n }\n if (syncResponse.rooms.leave) {\n Object.keys(syncResponse.rooms.leave).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Leave, syncResponse.rooms.leave[roomId], fromDatabase);\n });\n }\n if (syncResponse.rooms.knock) {\n Object.keys(syncResponse.rooms.knock).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Knock, syncResponse.rooms.knock[roomId], fromDatabase);\n });\n }\n }\n\n private accumulateRoom(roomId: string, category: Category.Invite, data: IInvitedRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category.Join, data: IJoinedRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category.Leave, data: ILeftRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category.Knock, data: IKnockedRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category, data: any, fromDatabase = false): void {\n // Valid /sync state transitions\n // +--------+ <======+ 1: Accept an invite\n // +== | INVITE | | (5) 2: Leave a room\n // | +--------+ =====+ | 3: Join a public room previously\n // |(1) (4) | | left (handle as if new room)\n // V (2) V | 4: Reject an invite\n // +------+ ========> +--------+ 5: Invite to a room previously\n // | JOIN | (3) | LEAVE* | left (handle as if new room)\n // +------+ <======== +--------+\n //\n // * equivalent to \"no state\"\n switch (category) {\n case Category.Invite: // (5)\n if (this.knockRooms[roomId]) {\n // was previously knock, now invite, need to delete knock state\n delete this.knockRooms[roomId];\n }\n this.accumulateInviteState(roomId, data as IInvitedRoom);\n break;\n\n case Category.Knock:\n this.accumulateKnockState(roomId, data as IKnockedRoom);\n break;\n\n case Category.Join:\n if (this.knockRooms[roomId]) {\n // delete knock state on join\n delete this.knockRooms[roomId];\n } else if (this.inviteRooms[roomId]) {\n // (1)\n // was previously invite, now join. We expect /sync to give\n // the entire state and timeline on 'join', so delete previous\n // invite state\n delete this.inviteRooms[roomId];\n }\n // (3)\n this.accumulateJoinState(roomId, data as IJoinedRoom, fromDatabase);\n break;\n\n case Category.Leave:\n if (this.knockRooms[roomId]) {\n // delete knock state on leave\n delete this.knockRooms[roomId];\n } else if (this.inviteRooms[roomId]) {\n // (4)\n delete this.inviteRooms[roomId];\n } else {\n // (2)\n delete this.joinRooms[roomId];\n }\n break;\n\n default:\n logger.error(\"Unknown cateogory: \", category);\n }\n }\n\n private accumulateInviteState(roomId: string, data: IInvitedRoom): void {\n if (!data.invite_state || !data.invite_state.events) {\n // no new data\n return;\n }\n if (!this.inviteRooms[roomId]) {\n this.inviteRooms[roomId] = {\n invite_state: data.invite_state,\n };\n return;\n }\n // accumulate extra keys for invite->invite transitions\n // clobber based on event type / state key\n // We expect invite_state to be small, so just loop over the events\n const currentData = this.inviteRooms[roomId];\n data.invite_state.events.forEach((e) => {\n let hasAdded = false;\n for (let i = 0; i < currentData.invite_state.events.length; i++) {\n const current = currentData.invite_state.events[i];\n if (current.type === e.type && current.state_key == e.state_key) {\n currentData.invite_state.events[i] = e; // update\n hasAdded = true;\n }\n }\n if (!hasAdded) {\n currentData.invite_state.events.push(e);\n }\n });\n }\n\n private accumulateKnockState(roomId: string, data: IKnockedRoom): void {\n if (!data.knock_state || !data.knock_state.events) {\n // no new data\n return;\n }\n if (!this.knockRooms[roomId]) {\n this.knockRooms[roomId] = {\n knock_state: data.knock_state,\n };\n return;\n }\n // accumulate extra keys\n // clobber based on event type / state key\n // We expect knock_state to be small, so just loop over the events\n const currentData = this.knockRooms[roomId];\n data.knock_state.events.forEach((e) => {\n let hasAdded = false;\n for (let i = 0; i < currentData.knock_state.events.length; i++) {\n const current = currentData.knock_state.events[i];\n if (current.type === e.type && current.state_key == e.state_key) {\n currentData.knock_state.events[i] = e; // update\n hasAdded = true;\n }\n }\n if (!hasAdded) {\n currentData.knock_state.events.push(e);\n }\n });\n }\n\n // Accumulate timeline and state events in a room.\n private accumulateJoinState(roomId: string, data: IJoinedRoom, fromDatabase = false): void {\n const now = Date.now();\n // We expect this function to be called a lot (every /sync) so we want\n // this to be fast. /sync stores events in an array but we often want\n // to clobber based on type/state_key. Rather than convert arrays to\n // maps all the time, just keep private maps which contain\n // the actual current accumulated sync state, and array-ify it when\n // getJSON() is called.\n\n // State resolution:\n // The 'state' key is the delta from the previous sync (or start of time\n // if no token was supplied), to the START of the timeline. To obtain\n // the current state, we need to \"roll forward\" state by reading the\n // timeline. We want to store the current state so we can drop events\n // out the end of the timeline based on opts.maxTimelineEntries.\n //\n // 'state' 'timeline' current state\n // |-------x<======================>x\n // T I M E\n //\n // When getJSON() is called, we 'roll back' the current state by the\n // number of entries in the timeline to work out what 'state' should be.\n\n // Back-pagination:\n // On an initial /sync, the server provides a back-pagination token for\n // the start of the timeline. When /sync deltas come down, they also\n // include back-pagination tokens for the start of the timeline. This\n // means not all events in the timeline have back-pagination tokens, as\n // it is only the ones at the START of the timeline which have them.\n // In order for us to have a valid timeline (and back-pagination token\n // to match), we need to make sure that when we remove old timeline\n // events, that we roll forward to an event which has a back-pagination\n // token. This means we can't keep a strict sliding-window based on\n // opts.maxTimelineEntries, and we may have a few less. We should never\n // have more though, provided that the /sync limit is less than or equal\n // to opts.maxTimelineEntries.\n\n if (!this.joinRooms[roomId]) {\n // Create truly empty objects so event types of 'hasOwnProperty' and co\n // don't cause this code to break.\n this.joinRooms[roomId] = {\n _currentState: Object.create(null),\n _timeline: [],\n _accountData: Object.create(null),\n _unreadNotifications: {},\n _unreadThreadNotifications: {},\n _summary: {},\n _receipts: new ReceiptAccumulator(),\n _stickyEvents: [],\n };\n }\n const currentData = this.joinRooms[roomId];\n\n if (data.account_data && data.account_data.events) {\n // clobber based on type\n data.account_data.events.forEach((e) => {\n currentData._accountData[e.type] = e;\n });\n }\n\n // these probably clobber, spec is unclear.\n if (data.unread_notifications) {\n currentData._unreadNotifications = data.unread_notifications;\n }\n currentData._unreadThreadNotifications =\n data[UNREAD_THREAD_NOTIFICATIONS.stable!] ?? data[UNREAD_THREAD_NOTIFICATIONS.unstable!] ?? undefined;\n\n if (data.summary) {\n const HEROES_KEY = \"m.heroes\";\n const INVITED_COUNT_KEY = \"m.invited_member_count\";\n const JOINED_COUNT_KEY = \"m.joined_member_count\";\n\n const acc = currentData._summary;\n const sum = data.summary;\n acc[HEROES_KEY] = sum[HEROES_KEY] ?? acc[HEROES_KEY];\n acc[JOINED_COUNT_KEY] = sum[JOINED_COUNT_KEY] ?? acc[JOINED_COUNT_KEY];\n acc[INVITED_COUNT_KEY] = sum[INVITED_COUNT_KEY] ?? acc[INVITED_COUNT_KEY];\n }\n\n // We purposefully do not persist m.typing events.\n // Technically you could refresh a browser before the timer on a\n // typing event is up, so it'll look like you aren't typing when\n // you really still are. However, the alternative is worse. If\n // we do persist typing events, it will look like people are\n // typing forever until someone really does start typing (which\n // will prompt Synapse to send down an actual m.typing event to\n // clobber the one we persisted).\n\n // Persist the receipts\n currentData._receipts.consumeEphemeralEvents(data.ephemeral?.events);\n\n // if we got a limited sync, we need to remove all timeline entries or else\n // we will have gaps in the timeline.\n if (data.timeline && data.timeline.limited) {\n currentData._timeline = [];\n }\n\n // Work out the current state. The deltas need to be applied in the order:\n // - existing state which didn't come down /sync.\n // - State events under the 'state' key.\n // - State events under the 'state_after' key OR state events in the 'timeline' if 'state_after' is not present.\n data.state?.events?.forEach((e) => {\n setState(currentData._currentState, e);\n });\n data[\"org.matrix.msc4222.state_after\"]?.events?.forEach((e) => {\n setState(currentData._currentState, e);\n });\n data.timeline?.events?.forEach((e, index) => {\n if (!data[\"org.matrix.msc4222.state_after\"]) {\n // this nops if 'e' isn't a state event\n setState(currentData._currentState, e);\n }\n // append the event to the timeline. The back-pagination token\n // corresponds to the first event in the timeline\n let transformedEvent: TaggedEvent;\n if (!fromDatabase) {\n transformedEvent = Object.assign({}, e);\n if (transformedEvent.unsigned !== undefined) {\n transformedEvent.unsigned = Object.assign({}, transformedEvent.unsigned);\n }\n const age = e.unsigned?.age;\n if (age !== undefined) transformedEvent._localTs = Date.now() - age;\n } else {\n transformedEvent = e;\n }\n\n currentData._timeline.push({\n event: transformedEvent,\n token: index === 0 ? (data.timeline.prev_batch ?? null) : null,\n });\n });\n\n // Prune out any events in our stores that have since expired, do this before we\n // insert new events.\n currentData._stickyEvents = currentData._stickyEvents.filter(({ expiresTs }) => expiresTs > now);\n\n // We want this to be fast, so don't worry about duplicate events here. The RoomStickyEventsStore will\n // process these events into the correct mapped order.\n if (data.msc4354_sticky?.events) {\n currentData._stickyEvents = currentData._stickyEvents.concat(\n data.msc4354_sticky.events.map((event) => {\n // If `duration_ms` exceeds the spec limit of a hour, we cap it.\n const cappedDuration = Math.min(event.msc4354_sticky.duration_ms, MAX_STICKY_DURATION_MS);\n // If `origin_server_ts` claims to have been from the future, we still bound it to now.\n const createdTs = Math.min(event.origin_server_ts, now);\n return {\n event,\n expiresTs: cappedDuration + createdTs,\n };\n }),\n );\n }\n\n // attempt to prune the timeline by jumping between events which have\n // pagination tokens.\n if (currentData._timeline.length > this.opts.maxTimelineEntries!) {\n const startIndex = currentData._timeline.length - this.opts.maxTimelineEntries!;\n for (let i = startIndex; i < currentData._timeline.length; i++) {\n if (currentData._timeline[i].token) {\n // keep all events after this, including this one\n currentData._timeline = currentData._timeline.slice(i, currentData._timeline.length);\n break;\n }\n }\n }\n }\n\n /**\n * Return everything under the 'rooms' key from a /sync response which\n * represents all room data that should be stored. This should be paired\n * with the sync token which represents the most recent /sync response\n * provided to accumulate().\n * @param forDatabase - True to generate a sync to be saved to storage\n * @returns An object with a \"nextBatch\", \"roomsData\" and \"accountData\"\n * keys.\n * The \"nextBatch\" key is a string which represents at what point in the\n * /sync stream the accumulator reached. This token should be used when\n * restarting a /sync stream at startup. Failure to do so can lead to missing\n * events. The \"roomsData\" key is an Object which represents the entire\n * /sync response from the 'rooms' key onwards. The \"accountData\" key is\n * a list of raw events which represent global account data.\n */\n public getJSON(forDatabase = false): ISyncData {\n const data: IRooms = {\n join: {},\n invite: {},\n knock: {},\n // always empty. This is set by /sync when a room was previously\n // in 'invite' or 'join'. On fresh startup, the client won't know\n // about any previous room being in 'invite' or 'join' so we can\n // just omit mentioning it at all, even if it has previously come\n // down /sync.\n // The notable exception is when a client is kicked or banned:\n // we may want to hold onto that room so the client can clearly see\n // why their room has disappeared. We don't persist it though because\n // it is unclear *when* we can safely remove the room from the DB.\n // Instead, we assume that if you're loading from the DB, you've\n // refreshed the page, which means you've seen the kick/ban already.\n leave: {},\n };\n Object.keys(this.inviteRooms).forEach((roomId) => {\n data.invite[roomId] = this.inviteRooms[roomId];\n });\n Object.keys(this.knockRooms).forEach((roomId) => {\n data.knock[roomId] = this.knockRooms[roomId];\n });\n Object.keys(this.joinRooms).forEach((roomId) => {\n const roomData = this.joinRooms[roomId];\n const roomJson: IJoinedRoom & {\n // We track both `state` and `state_after` for downgrade compatibility\n \"state\": IState;\n \"org.matrix.msc4222.state_after\": IState;\n } = {\n \"ephemeral\": { events: [] },\n \"account_data\": { events: [] },\n \"state\": { events: [] },\n \"org.matrix.msc4222.state_after\": { events: [] },\n \"timeline\": {\n events: [],\n prev_batch: null,\n },\n \"unread_notifications\": roomData._unreadNotifications,\n \"unread_thread_notifications\": roomData._unreadThreadNotifications,\n \"summary\": roomData._summary as IRoomSummary,\n \"msc4354_sticky\": roomData._stickyEvents?.length\n ? {\n events: roomData._stickyEvents.map((e) => e.event),\n }\n : undefined,\n };\n // Add account data\n Object.keys(roomData._accountData).forEach((evType) => {\n roomJson.account_data.events.push(roomData._accountData[evType]);\n });\n\n const receiptEvent = roomData._receipts.buildAccumulatedReceiptEvent(roomId);\n\n // add only if we have some receipt data\n if (receiptEvent) {\n roomJson.ephemeral.events.push(receiptEvent);\n }\n\n // Add timeline data\n roomData._timeline.forEach((msgData) => {\n if (!roomJson.timeline.prev_batch) {\n // the first event we add to the timeline MUST match up to\n // the prev_batch token.\n if (!msgData.token) {\n return; // this shouldn't happen as we prune constantly.\n }\n roomJson.timeline.prev_batch = msgData.token;\n }\n\n let transformedEvent: (IRoomEvent | IStateEvent) & { _localTs?: number };\n if (!forDatabase && isTaggedEvent(msgData.event)) {\n // This means we have to copy each event, so we can fix it up to\n // set a correct 'age' parameter whilst keeping the local timestamp\n // on our stored event. If this turns out to be a bottleneck, it could\n // be optimised either by doing this in the main process after the data\n // has been structured-cloned to go between the worker & main process,\n // or special-casing data from saved syncs to read the local timestamp\n // directly rather than turning it into age to then immediately be\n // transformed back again into a local timestamp.\n transformedEvent = Object.assign({}, msgData.event);\n if (transformedEvent.unsigned !== undefined) {\n transformedEvent.unsigned = Object.assign({}, transformedEvent.unsigned);\n }\n delete transformedEvent._localTs;\n transformedEvent.unsigned = transformedEvent.unsigned || {};\n transformedEvent.unsigned.age = Date.now() - msgData.event._localTs!;\n } else {\n transformedEvent = msgData.event;\n }\n roomJson.timeline.events.push(transformedEvent);\n });\n\n // Add state data: roll back current state to the start of timeline,\n // by \"reverse clobbering\" from the end of the timeline to the start.\n // Convert maps back into arrays.\n const rollBackState = Object.create(null);\n for (let i = roomJson.timeline.events.length - 1; i >= 0; i--) {\n const timelineEvent = roomJson.timeline.events[i];\n if (\n (timelineEvent as IStateEvent).state_key === null ||\n (timelineEvent as IStateEvent).state_key === undefined\n ) {\n continue; // not a state event\n }\n // since we're going back in time, we need to use the previous\n // state value else we'll break causality. We don't have the\n // complete previous state event, so we need to create one.\n const prevStateEvent = deepCopy(timelineEvent);\n if (prevStateEvent.unsigned) {\n if (prevStateEvent.unsigned.prev_content) {\n prevStateEvent.content = prevStateEvent.unsigned.prev_content;\n }\n if (prevStateEvent.unsigned.prev_sender) {\n prevStateEvent.sender = prevStateEvent.unsigned.prev_sender;\n }\n }\n setState(rollBackState, prevStateEvent);\n }\n Object.keys(roomData._currentState).forEach((evType) => {\n Object.keys(roomData._currentState[evType]).forEach((stateKey) => {\n let ev = roomData._currentState[evType][stateKey];\n // Push to both fields to provide downgrade compatibility in the sync accumulator db\n // the code will prefer `state_after` if it is present\n roomJson[\"org.matrix.msc4222.state_after\"].events.push(ev);\n // Roll the state back to the value at the start of the timeline if it was changed\n if (rollBackState[evType] && rollBackState[evType][stateKey]) {\n ev = rollBackState[evType][stateKey];\n }\n roomJson.state.events.push(ev);\n });\n });\n data.join[roomId] = roomJson;\n });\n\n // Add account data\n const accData: IMinimalEvent[] = [];\n Object.keys(this.accountData).forEach((evType) => {\n accData.push(this.accountData[evType]);\n });\n\n return {\n nextBatch: this.nextBatch!,\n roomsData: data,\n accountData: accData,\n };\n }\n\n public getNextBatchToken(): string {\n return this.nextBatch!;\n }\n}\n\nfunction setState(eventMap: Record<string, Record<string, IStateEvent>>, event: IRoomEvent | IStateEvent): void {\n if ((event as IStateEvent).state_key === null || (event as IStateEvent).state_key === undefined || !event.type) {\n return;\n }\n if (!eventMap[event.type]) {\n eventMap[event.type] = Object.create(null);\n }\n eventMap[event.type][(event as IStateEvent).state_key] = event as IStateEvent;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,aAAa;AACpC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,sBAAsB,QAAuC,mBAAmB;AAGzF,SAASC,2BAA2B,QAAQ,kBAAkB;AAC9D,SAASC,kBAAkB,QAAQ,0BAA0B;;AAyB7D;;AAoGA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgCA;;AAEA,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAoCpB,SAASC,aAAaA,CAACC,KAAiB,EAAwB;EAC5D,OAAO,UAAU,IAAIA,KAAK,IAAIA,KAAK,CAAC,UAAU,CAAC,KAAKC,SAAS;AACjE;;AAE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E;IACvBgH,QAAQ,CAACrI,KAAK,CAACqB,IAAI,CAAC,GAAGG,MAAM,CAACsC,MAAM,CAAC,IAAI,CAAC;EAC9C;EACAuE,QAAQ,CAACrI,KAAK,CAACqB,IAAI,CAAC,CAAErB,KAAK,CAAiBiD,SAAS,CAAC,GAAGjD,KAAoB;AACjF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"sync-accumulator.js","names":["logger","deepCopy","MAX_STICKY_DURATION_MS","UNREAD_THREAD_NOTIFICATIONS","ReceiptAccumulator","Category","isTaggedEvent","event","undefined","SyncAccumulator","constructor","opts","arguments","length","_defineProperty","maxTimelineEntries","accumulate","syncResponse","fromDatabase","accumulateRooms","accumulateAccountData","nextBatch","next_batch","account_data","events","forEach","e","accountData","type","rooms","invite","Object","keys","roomId","accumulateRoom","Invite","join","Join","leave","Leave","knock","Knock","category","data","knockRooms","accumulateInviteState","accumulateKnockState","inviteRooms","accumulateJoinState","joinRooms","error","invite_state","currentData","hasAdded","i","current","state_key","push","knock_state","_ref","_data","_data$ephemeral","_data$state","_data$orgMatrixMsc","_data$timeline","_data$msc4354_sticky","now","Date","_currentState","create","_timeline","_accountData","_unreadNotifications","_unreadThreadNotifications","_summary","_receipts","_stickyEvents","unread_notifications","stable","unstable","summary","_sum$HEROES_KEY","_sum$JOINED_COUNT_KEY","_sum$INVITED_COUNT_KE","HEROES_KEY","INVITED_COUNT_KEY","JOINED_COUNT_KEY","acc","sum","consumeEphemeralEvents","ephemeral","timeline","limited","state","setState","index","_data$timeline$prev_b","transformedEvent","_e$unsigned","assign","unsigned","age","_localTs","token","prev_batch","filter","_ref2","expiresTs","msc4354_sticky","concat","map","cappedDuration","Math","min","duration_ms","createdTs","origin_server_ts","startIndex","slice","getJSON","forDatabase","_roomData$_stickyEven","roomData","roomJson","evType","receiptEvent","buildAccumulatedReceiptEvent","msgData","rollBackState","timelineEvent","prevStateEvent","prev_content","content","prev_sender","sender","stateKey","ev","accData","roomsData","getNextBatchToken","eventMap"],"sources":["../src/sync-accumulator.ts"],"sourcesContent":["/*\nCopyright 2017 - 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\n/**\n * This is an internal module. See {@link SyncAccumulator} for the public class.\n */\n\nimport { logger } from \"./logger.ts\";\nimport { deepCopy } from \"./utils.ts\";\nimport { MAX_STICKY_DURATION_MS, type IContent, type IUnsigned } from \"./models/event.ts\";\nimport { type IRoomSummary } from \"./models/room-summary.ts\";\nimport { type EventType } from \"./@types/event.ts\";\nimport { UNREAD_THREAD_NOTIFICATIONS } from \"./@types/sync.ts\";\nimport { ReceiptAccumulator } from \"./receipt-accumulator.ts\";\nimport { type OlmEncryptionInfo } from \"./crypto-api/index.ts\";\nimport { type SyncUserProfile } from \"./matrix.ts\";\n\ninterface IOpts {\n /**\n * The ideal maximum number of timeline entries to keep in the sync response.\n * This is best-effort, as clients do not always have a back-pagination token for each event,\n * so it's possible there may be slightly *less* than this value. There will never be more.\n * This cannot be 0 or else it makes it impossible to scroll back in a room.\n * Default: 50.\n */\n maxTimelineEntries?: number;\n /**\n * Whether to use the stable or unstable fields for user profiles.\n */\n profileFieldsStable?: boolean;\n}\n\nexport interface IMinimalEvent {\n content: IContent;\n type: EventType | string;\n room_id?: string;\n unsigned?: IUnsigned;\n}\n\nexport interface IEphemeral {\n events: IMinimalEvent[];\n}\n\n/* eslint-disable camelcase */\ninterface UnreadNotificationCounts {\n highlight_count?: number;\n notification_count?: number;\n}\n\nexport interface IRoomEvent extends IMinimalEvent {\n event_id: string;\n sender: string;\n origin_server_ts: number;\n}\n\nexport interface IStateEvent extends IRoomEvent {\n prev_content?: IContent;\n state_key: string;\n}\n\ninterface IState {\n events: IStateEvent[];\n}\n\nexport interface ITimeline {\n events: Array<IRoomEvent | IStateEvent>;\n limited?: boolean;\n prev_batch: string | null;\n}\n\ntype StickyEventFields = {\n msc4354_sticky: { duration_ms: number };\n content: { msc4354_sticky_key?: string };\n};\n\nexport type IStickyEvent = IRoomEvent & StickyEventFields;\n\nexport type IStickyStateEvent = IStateEvent & StickyEventFields;\n\nexport interface ISticky {\n events: Array<IStickyEvent | IStickyStateEvent>;\n}\n\nexport interface IJoinedRoom {\n \"summary\": IRoomSummary;\n // One of `state` or `state_after` is required.\n \"state\"?: IState;\n \"org.matrix.msc4222.state_after\"?: IState; // https://github.com/matrix-org/matrix-spec-proposals/pull/4222\n \"msc4354_sticky\"?: ISticky; // https://github.com/matrix-org/matrix-spec-proposals/pull/4354\n \"timeline\": ITimeline;\n \"ephemeral\": IEphemeral;\n \"account_data\": IAccountData;\n \"unread_notifications\": UnreadNotificationCounts;\n \"unread_thread_notifications\"?: Record<string, UnreadNotificationCounts>;\n \"org.matrix.msc3773.unread_thread_notifications\"?: Record<string, UnreadNotificationCounts>;\n}\n\nexport interface IStrippedState {\n content: IContent;\n state_key: string;\n type: EventType | string;\n sender: string;\n}\n\nexport interface IInviteState {\n events: IStrippedState[];\n}\n\nexport interface IKnockState {\n events: IStrippedState[];\n}\n\nexport interface IInvitedRoom {\n invite_state: IInviteState;\n}\n\nexport interface ILeftRoom {\n // One of `state` or `state_after` is required.\n \"state\"?: IState;\n \"org.matrix.msc4222.state_after\"?: IState;\n \"timeline\": ITimeline;\n \"account_data\": IAccountData;\n}\n\nexport interface IKnockedRoom {\n knock_state: IKnockState;\n}\n\nexport interface IRooms {\n [Category.Join]: Record<string, IJoinedRoom>;\n [Category.Invite]: Record<string, IInvitedRoom>;\n [Category.Leave]: Record<string, ILeftRoom>;\n [Category.Knock]: Record<string, IKnockedRoom>;\n}\n\ninterface IPresence {\n events: IMinimalEvent[];\n}\n\ninterface IAccountData {\n events: IMinimalEvent[];\n}\n\n/** A to-device message as received from the sync. */\nexport interface IToDeviceEvent {\n content: IContent;\n sender: string;\n type: string;\n}\n\n/**\n * A (possibly decrypted) to-device message after it has been successfully processed by the sdk.\n *\n * If the message was encrypted, the `encryptionInfo` field will contain the encryption information.\n * If the message was sent in clear, this field will be null.\n *\n * The `message` field contains the message `type`, `content`, and `sender` as if the message was sent in clear.\n */\nexport interface ReceivedToDeviceMessage {\n /** The message type, content, and sender as if the message was sent in clear. */\n message: IToDeviceEvent;\n /**\n * Information about the encryption of the message.\n * Will be null if the message was sent in clear\n */\n encryptionInfo: OlmEncryptionInfo | null;\n}\n\ninterface IToDevice {\n events: IToDeviceEvent[];\n}\n\nexport interface IDeviceLists {\n changed?: string[];\n left?: string[];\n}\n\n/**\n * The \"users\" section of the sync update which contains extended profile updates.\n */\nexport interface UsersUpdate {\n [userId: string]: {\n profile_updates?: SyncUserProfile | null;\n };\n}\n\nexport interface ISyncResponse {\n \"next_batch\": string;\n \"rooms\": IRooms;\n \"presence\"?: IPresence;\n \"account_data\": IAccountData;\n \"to_device\"?: IToDevice;\n \"device_lists\"?: IDeviceLists;\n \"device_one_time_keys_count\"?: Record<string, number>;\n \"users\"?: UsersUpdate;\n \"org.matrix.msc4429.users\"?: UsersUpdate;\n \"device_unused_fallback_key_types\"?: string[];\n \"org.matrix.msc2732.device_unused_fallback_key_types\"?: string[];\n}\n/* eslint-enable camelcase */\n\nexport enum Category {\n Invite = \"invite\",\n Leave = \"leave\",\n Join = \"join\",\n Knock = \"knock\",\n}\n\ninterface IRoom {\n _currentState: { [eventType: string]: { [stateKey: string]: IStateEvent } };\n _timeline: {\n event: IRoomEvent | IStateEvent;\n token: string | null;\n }[];\n _summary: Partial<IRoomSummary>;\n _accountData: { [eventType: string]: IMinimalEvent };\n _unreadNotifications: Partial<UnreadNotificationCounts>;\n _unreadThreadNotifications?: Record<string, Partial<UnreadNotificationCounts>>;\n _receipts: ReceiptAccumulator;\n _stickyEvents: {\n readonly event: IStickyEvent | IStickyStateEvent;\n /**\n * This is the timestamp at which point it is safe to remove this event from the store.\n * This value is immutable\n */\n readonly expiresTs: number;\n }[];\n}\n\nexport interface ISyncData {\n nextBatch: string;\n accountData: IMinimalEvent[];\n roomsData: IRooms;\n}\n\ntype TaggedEvent = IRoomEvent & { _localTs?: number };\n\nfunction isTaggedEvent(event: IRoomEvent): event is TaggedEvent {\n return \"_localTs\" in event && event[\"_localTs\"] !== undefined;\n}\n\n/**\n * The purpose of this class is to accumulate /sync responses such that a\n * complete \"initial\" JSON response can be returned which accurately represents\n * the sum total of the /sync responses accumulated to date. It only handles\n * room data: that is, everything under the \"rooms\" top-level key.\n *\n * This class is used when persisting room data so a complete /sync response can\n * be loaded from disk and incremental syncs can be performed on the server,\n * rather than asking the server to do an initial sync on startup.\n */\nexport class SyncAccumulator {\n private accountData: Record<string, IMinimalEvent> = {}; // $event_type: Object\n private inviteRooms: Record<string, IInvitedRoom> = {}; // $roomId: { ... sync 'invite' json data ... }\n private knockRooms: Record<string, IKnockedRoom> = {}; // $roomId: { ... sync 'knock' json data ... }\n private joinRooms: { [roomId: string]: IRoom } = {};\n // the /sync token which corresponds to the last time rooms were\n // accumulated. We remember this so that any caller can obtain a\n // coherent /sync response and know at what point they should be\n // streaming from without losing events.\n private nextBatch: string | null = null;\n\n public constructor(private readonly opts: IOpts = {}) {\n this.opts.maxTimelineEntries = this.opts.maxTimelineEntries || 50;\n }\n\n public accumulate(syncResponse: ISyncResponse, fromDatabase = false): void {\n this.accumulateRooms(syncResponse, fromDatabase);\n this.accumulateAccountData(syncResponse);\n this.nextBatch = syncResponse.next_batch;\n }\n\n private accumulateAccountData(syncResponse: ISyncResponse): void {\n if (!syncResponse.account_data || !syncResponse.account_data.events) {\n return;\n }\n // Clobbers based on event type.\n syncResponse.account_data.events.forEach((e) => {\n this.accountData[e.type] = e;\n });\n }\n\n /**\n * Accumulate incremental /sync room data.\n * @param syncResponse - the complete /sync JSON\n * @param fromDatabase - True if the sync response is one saved to the database\n */\n private accumulateRooms(syncResponse: ISyncResponse, fromDatabase = false): void {\n if (!syncResponse.rooms) {\n return;\n }\n if (syncResponse.rooms.invite) {\n Object.keys(syncResponse.rooms.invite).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Invite, syncResponse.rooms.invite[roomId], fromDatabase);\n });\n }\n if (syncResponse.rooms.join) {\n Object.keys(syncResponse.rooms.join).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Join, syncResponse.rooms.join[roomId], fromDatabase);\n });\n }\n if (syncResponse.rooms.leave) {\n Object.keys(syncResponse.rooms.leave).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Leave, syncResponse.rooms.leave[roomId], fromDatabase);\n });\n }\n if (syncResponse.rooms.knock) {\n Object.keys(syncResponse.rooms.knock).forEach((roomId) => {\n this.accumulateRoom(roomId, Category.Knock, syncResponse.rooms.knock[roomId], fromDatabase);\n });\n }\n }\n\n private accumulateRoom(roomId: string, category: Category.Invite, data: IInvitedRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category.Join, data: IJoinedRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category.Leave, data: ILeftRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category.Knock, data: IKnockedRoom, fromDatabase: boolean): void;\n private accumulateRoom(roomId: string, category: Category, data: any, fromDatabase = false): void {\n // Valid /sync state transitions\n // +--------+ <======+ 1: Accept an invite\n // +== | INVITE | | (5) 2: Leave a room\n // | +--------+ =====+ | 3: Join a public room previously\n // |(1) (4) | | left (handle as if new room)\n // V (2) V | 4: Reject an invite\n // +------+ ========> +--------+ 5: Invite to a room previously\n // | JOIN | (3) | LEAVE* | left (handle as if new room)\n // +------+ <======== +--------+\n //\n // * equivalent to \"no state\"\n switch (category) {\n case Category.Invite: // (5)\n if (this.knockRooms[roomId]) {\n // was previously knock, now invite, need to delete knock state\n delete this.knockRooms[roomId];\n }\n this.accumulateInviteState(roomId, data as IInvitedRoom);\n break;\n\n case Category.Knock:\n this.accumulateKnockState(roomId, data as IKnockedRoom);\n break;\n\n case Category.Join:\n if (this.knockRooms[roomId]) {\n // delete knock state on join\n delete this.knockRooms[roomId];\n } else if (this.inviteRooms[roomId]) {\n // (1)\n // was previously invite, now join. We expect /sync to give\n // the entire state and timeline on 'join', so delete previous\n // invite state\n delete this.inviteRooms[roomId];\n }\n // (3)\n this.accumulateJoinState(roomId, data as IJoinedRoom, fromDatabase);\n break;\n\n case Category.Leave:\n if (this.knockRooms[roomId]) {\n // delete knock state on leave\n delete this.knockRooms[roomId];\n } else if (this.inviteRooms[roomId]) {\n // (4)\n delete this.inviteRooms[roomId];\n } else {\n // (2)\n delete this.joinRooms[roomId];\n }\n break;\n\n default:\n logger.error(\"Unknown cateogory: \", category);\n }\n }\n\n private accumulateInviteState(roomId: string, data: IInvitedRoom): void {\n if (!data.invite_state || !data.invite_state.events) {\n // no new data\n return;\n }\n if (!this.inviteRooms[roomId]) {\n this.inviteRooms[roomId] = {\n invite_state: data.invite_state,\n };\n return;\n }\n // accumulate extra keys for invite->invite transitions\n // clobber based on event type / state key\n // We expect invite_state to be small, so just loop over the events\n const currentData = this.inviteRooms[roomId];\n data.invite_state.events.forEach((e) => {\n let hasAdded = false;\n for (let i = 0; i < currentData.invite_state.events.length; i++) {\n const current = currentData.invite_state.events[i];\n if (current.type === e.type && current.state_key == e.state_key) {\n currentData.invite_state.events[i] = e; // update\n hasAdded = true;\n }\n }\n if (!hasAdded) {\n currentData.invite_state.events.push(e);\n }\n });\n }\n\n private accumulateKnockState(roomId: string, data: IKnockedRoom): void {\n if (!data.knock_state || !data.knock_state.events) {\n // no new data\n return;\n }\n if (!this.knockRooms[roomId]) {\n this.knockRooms[roomId] = {\n knock_state: data.knock_state,\n };\n return;\n }\n // accumulate extra keys\n // clobber based on event type / state key\n // We expect knock_state to be small, so just loop over the events\n const currentData = this.knockRooms[roomId];\n data.knock_state.events.forEach((e) => {\n let hasAdded = false;\n for (let i = 0; i < currentData.knock_state.events.length; i++) {\n const current = currentData.knock_state.events[i];\n if (current.type === e.type && current.state_key == e.state_key) {\n currentData.knock_state.events[i] = e; // update\n hasAdded = true;\n }\n }\n if (!hasAdded) {\n currentData.knock_state.events.push(e);\n }\n });\n }\n\n // Accumulate timeline and state events in a room.\n private accumulateJoinState(roomId: string, data: IJoinedRoom, fromDatabase = false): void {\n const now = Date.now();\n // We expect this function to be called a lot (every /sync) so we want\n // this to be fast. /sync stores events in an array but we often want\n // to clobber based on type/state_key. Rather than convert arrays to\n // maps all the time, just keep private maps which contain\n // the actual current accumulated sync state, and array-ify it when\n // getJSON() is called.\n\n // State resolution:\n // The 'state' key is the delta from the previous sync (or start of time\n // if no token was supplied), to the START of the timeline. To obtain\n // the current state, we need to \"roll forward\" state by reading the\n // timeline. We want to store the current state so we can drop events\n // out the end of the timeline based on opts.maxTimelineEntries.\n //\n // 'state' 'timeline' current state\n // |-------x<======================>x\n // T I M E\n //\n // When getJSON() is called, we 'roll back' the current state by the\n // number of entries in the timeline to work out what 'state' should be.\n\n // Back-pagination:\n // On an initial /sync, the server provides a back-pagination token for\n // the start of the timeline. When /sync deltas come down, they also\n // include back-pagination tokens for the start of the timeline. This\n // means not all events in the timeline have back-pagination tokens, as\n // it is only the ones at the START of the timeline which have them.\n // In order for us to have a valid timeline (and back-pagination token\n // to match), we need to make sure that when we remove old timeline\n // events, that we roll forward to an event which has a back-pagination\n // token. This means we can't keep a strict sliding-window based on\n // opts.maxTimelineEntries, and we may have a few less. We should never\n // have more though, provided that the /sync limit is less than or equal\n // to opts.maxTimelineEntries.\n\n if (!this.joinRooms[roomId]) {\n // Create truly empty objects so event types of 'hasOwnProperty' and co\n // don't cause this code to break.\n this.joinRooms[roomId] = {\n _currentState: Object.create(null),\n _timeline: [],\n _accountData: Object.create(null),\n _unreadNotifications: {},\n _unreadThreadNotifications: {},\n _summary: {},\n _receipts: new ReceiptAccumulator(),\n _stickyEvents: [],\n };\n }\n const currentData = this.joinRooms[roomId];\n\n if (data.account_data && data.account_data.events) {\n // clobber based on type\n data.account_data.events.forEach((e) => {\n currentData._accountData[e.type] = e;\n });\n }\n\n // these probably clobber, spec is unclear.\n if (data.unread_notifications) {\n currentData._unreadNotifications = data.unread_notifications;\n }\n currentData._unreadThreadNotifications =\n data[UNREAD_THREAD_NOTIFICATIONS.stable!] ?? data[UNREAD_THREAD_NOTIFICATIONS.unstable!] ?? undefined;\n\n if (data.summary) {\n const HEROES_KEY = \"m.heroes\";\n const INVITED_COUNT_KEY = \"m.invited_member_count\";\n const JOINED_COUNT_KEY = \"m.joined_member_count\";\n\n const acc = currentData._summary;\n const sum = data.summary;\n acc[HEROES_KEY] = sum[HEROES_KEY] ?? acc[HEROES_KEY];\n acc[JOINED_COUNT_KEY] = sum[JOINED_COUNT_KEY] ?? acc[JOINED_COUNT_KEY];\n acc[INVITED_COUNT_KEY] = sum[INVITED_COUNT_KEY] ?? acc[INVITED_COUNT_KEY];\n }\n\n // We purposefully do not persist m.typing events.\n // Technically you could refresh a browser before the timer on a\n // typing event is up, so it'll look like you aren't typing when\n // you really still are. However, the alternative is worse. If\n // we do persist typing events, it will look like people are\n // typing forever until someone really does start typing (which\n // will prompt Synapse to send down an actual m.typing event to\n // clobber the one we persisted).\n\n // Persist the receipts\n currentData._receipts.consumeEphemeralEvents(data.ephemeral?.events);\n\n // if we got a limited sync, we need to remove all timeline entries or else\n // we will have gaps in the timeline.\n if (data.timeline && data.timeline.limited) {\n currentData._timeline = [];\n }\n\n // Work out the current state. The deltas need to be applied in the order:\n // - existing state which didn't come down /sync.\n // - State events under the 'state' key.\n // - State events under the 'state_after' key OR state events in the 'timeline' if 'state_after' is not present.\n data.state?.events?.forEach((e) => {\n setState(currentData._currentState, e);\n });\n data[\"org.matrix.msc4222.state_after\"]?.events?.forEach((e) => {\n setState(currentData._currentState, e);\n });\n data.timeline?.events?.forEach((e, index) => {\n if (!data[\"org.matrix.msc4222.state_after\"]) {\n // this nops if 'e' isn't a state event\n setState(currentData._currentState, e);\n }\n // append the event to the timeline. The back-pagination token\n // corresponds to the first event in the timeline\n let transformedEvent: TaggedEvent;\n if (!fromDatabase) {\n transformedEvent = Object.assign({}, e);\n if (transformedEvent.unsigned !== undefined) {\n transformedEvent.unsigned = Object.assign({}, transformedEvent.unsigned);\n }\n const age = e.unsigned?.age;\n if (age !== undefined) transformedEvent._localTs = Date.now() - age;\n } else {\n transformedEvent = e;\n }\n\n currentData._timeline.push({\n event: transformedEvent,\n token: index === 0 ? (data.timeline.prev_batch ?? null) : null,\n });\n });\n\n // Prune out any events in our stores that have since expired, do this before we\n // insert new events.\n currentData._stickyEvents = currentData._stickyEvents.filter(({ expiresTs }) => expiresTs > now);\n\n // We want this to be fast, so don't worry about duplicate events here. The RoomStickyEventsStore will\n // process these events into the correct mapped order.\n if (data.msc4354_sticky?.events) {\n currentData._stickyEvents = currentData._stickyEvents.concat(\n data.msc4354_sticky.events.map((event) => {\n // If `duration_ms` exceeds the spec limit of a hour, we cap it.\n const cappedDuration = Math.min(event.msc4354_sticky.duration_ms, MAX_STICKY_DURATION_MS);\n // If `origin_server_ts` claims to have been from the future, we still bound it to now.\n const createdTs = Math.min(event.origin_server_ts, now);\n return {\n event,\n expiresTs: cappedDuration + createdTs,\n };\n }),\n );\n }\n\n // attempt to prune the timeline by jumping between events which have\n // pagination tokens.\n if (currentData._timeline.length > this.opts.maxTimelineEntries!) {\n const startIndex = currentData._timeline.length - this.opts.maxTimelineEntries!;\n for (let i = startIndex; i < currentData._timeline.length; i++) {\n if (currentData._timeline[i].token) {\n // keep all events after this, including this one\n currentData._timeline = currentData._timeline.slice(i, currentData._timeline.length);\n break;\n }\n }\n }\n }\n\n /**\n * Return everything under the 'rooms' key from a /sync response which\n * represents all room data that should be stored. This should be paired\n * with the sync token which represents the most recent /sync response\n * provided to accumulate().\n * @param forDatabase - True to generate a sync to be saved to storage\n * @returns An object with a \"nextBatch\", \"roomsData\" and \"accountData\"\n * keys.\n * The \"nextBatch\" key is a string which represents at what point in the\n * /sync stream the accumulator reached. This token should be used when\n * restarting a /sync stream at startup. Failure to do so can lead to missing\n * events. The \"roomsData\" key is an Object which represents the entire\n * /sync response from the 'rooms' key onwards. The \"accountData\" key is\n * a list of raw events which represent global account data.\n */\n public getJSON(forDatabase = false): ISyncData {\n const data: IRooms = {\n join: {},\n invite: {},\n knock: {},\n // always empty. This is set by /sync when a room was previously\n // in 'invite' or 'join'. On fresh startup, the client won't know\n // about any previous room being in 'invite' or 'join' so we can\n // just omit mentioning it at all, even if it has previously come\n // down /sync.\n // The notable exception is when a client is kicked or banned:\n // we may want to hold onto that room so the client can clearly see\n // why their room has disappeared. We don't persist it though because\n // it is unclear *when* we can safely remove the room from the DB.\n // Instead, we assume that if you're loading from the DB, you've\n // refreshed the page, which means you've seen the kick/ban already.\n leave: {},\n };\n Object.keys(this.inviteRooms).forEach((roomId) => {\n data.invite[roomId] = this.inviteRooms[roomId];\n });\n Object.keys(this.knockRooms).forEach((roomId) => {\n data.knock[roomId] = this.knockRooms[roomId];\n });\n Object.keys(this.joinRooms).forEach((roomId) => {\n const roomData = this.joinRooms[roomId];\n const roomJson: IJoinedRoom & {\n // We track both `state` and `state_after` for downgrade compatibility\n \"state\": IState;\n \"org.matrix.msc4222.state_after\": IState;\n } = {\n \"ephemeral\": { events: [] },\n \"account_data\": { events: [] },\n \"state\": { events: [] },\n \"org.matrix.msc4222.state_after\": { events: [] },\n \"timeline\": {\n events: [],\n prev_batch: null,\n },\n \"unread_notifications\": roomData._unreadNotifications,\n \"unread_thread_notifications\": roomData._unreadThreadNotifications,\n \"summary\": roomData._summary as IRoomSummary,\n \"msc4354_sticky\": roomData._stickyEvents?.length\n ? {\n events: roomData._stickyEvents.map((e) => e.event),\n }\n : undefined,\n };\n // Add account data\n Object.keys(roomData._accountData).forEach((evType) => {\n roomJson.account_data.events.push(roomData._accountData[evType]);\n });\n\n const receiptEvent = roomData._receipts.buildAccumulatedReceiptEvent(roomId);\n\n // add only if we have some receipt data\n if (receiptEvent) {\n roomJson.ephemeral.events.push(receiptEvent);\n }\n\n // Add timeline data\n roomData._timeline.forEach((msgData) => {\n if (!roomJson.timeline.prev_batch) {\n // the first event we add to the timeline MUST match up to\n // the prev_batch token.\n if (!msgData.token) {\n return; // this shouldn't happen as we prune constantly.\n }\n roomJson.timeline.prev_batch = msgData.token;\n }\n\n let transformedEvent: (IRoomEvent | IStateEvent) & { _localTs?: number };\n if (!forDatabase && isTaggedEvent(msgData.event)) {\n // This means we have to copy each event, so we can fix it up to\n // set a correct 'age' parameter whilst keeping the local timestamp\n // on our stored event. If this turns out to be a bottleneck, it could\n // be optimised either by doing this in the main process after the data\n // has been structured-cloned to go between the worker & main process,\n // or special-casing data from saved syncs to read the local timestamp\n // directly rather than turning it into age to then immediately be\n // transformed back again into a local timestamp.\n transformedEvent = Object.assign({}, msgData.event);\n if (transformedEvent.unsigned !== undefined) {\n transformedEvent.unsigned = Object.assign({}, transformedEvent.unsigned);\n }\n delete transformedEvent._localTs;\n transformedEvent.unsigned = transformedEvent.unsigned || {};\n transformedEvent.unsigned.age = Date.now() - msgData.event._localTs!;\n } else {\n transformedEvent = msgData.event;\n }\n roomJson.timeline.events.push(transformedEvent);\n });\n\n // Add state data: roll back current state to the start of timeline,\n // by \"reverse clobbering\" from the end of the timeline to the start.\n // Convert maps back into arrays.\n const rollBackState = Object.create(null);\n for (let i = roomJson.timeline.events.length - 1; i >= 0; i--) {\n const timelineEvent = roomJson.timeline.events[i];\n if (\n (timelineEvent as IStateEvent).state_key === null ||\n (timelineEvent as IStateEvent).state_key === undefined\n ) {\n continue; // not a state event\n }\n // since we're going back in time, we need to use the previous\n // state value else we'll break causality. We don't have the\n // complete previous state event, so we need to create one.\n const prevStateEvent = deepCopy(timelineEvent);\n if (prevStateEvent.unsigned) {\n if (prevStateEvent.unsigned.prev_content) {\n prevStateEvent.content = prevStateEvent.unsigned.prev_content;\n }\n if (prevStateEvent.unsigned.prev_sender) {\n prevStateEvent.sender = prevStateEvent.unsigned.prev_sender;\n }\n }\n setState(rollBackState, prevStateEvent);\n }\n Object.keys(roomData._currentState).forEach((evType) => {\n Object.keys(roomData._currentState[evType]).forEach((stateKey) => {\n let ev = roomData._currentState[evType][stateKey];\n // Push to both fields to provide downgrade compatibility in the sync accumulator db\n // the code will prefer `state_after` if it is present\n roomJson[\"org.matrix.msc4222.state_after\"].events.push(ev);\n // Roll the state back to the value at the start of the timeline if it was changed\n if (rollBackState[evType] && rollBackState[evType][stateKey]) {\n ev = rollBackState[evType][stateKey];\n }\n roomJson.state.events.push(ev);\n });\n });\n data.join[roomId] = roomJson;\n });\n\n // Add account data\n const accData: IMinimalEvent[] = [];\n Object.keys(this.accountData).forEach((evType) => {\n accData.push(this.accountData[evType]);\n });\n\n return {\n nextBatch: this.nextBatch!,\n roomsData: data,\n accountData: accData,\n };\n }\n\n public getNextBatchToken(): string {\n return this.nextBatch!;\n }\n}\n\nfunction setState(eventMap: Record<string, Record<string, IStateEvent>>, event: IRoomEvent | IStateEvent): void {\n if ((event as IStateEvent).state_key === null || (event as IStateEvent).state_key === undefined || !event.type) {\n return;\n }\n if (!eventMap[event.type]) {\n eventMap[event.type] = Object.create(null);\n }\n eventMap[event.type][(event as IStateEvent).state_key] = event as IStateEvent;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,aAAa;AACpC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,sBAAsB,QAAuC,mBAAmB;AAGzF,SAASC,2BAA2B,QAAQ,kBAAkB;AAC9D,SAASC,kBAAkB,QAAQ,0BAA0B;;AA8B7D;;AAoGA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;;AAoBA;;AAEA,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ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,KAAK,IAAI,IAAKjD,KAAK,CAAiBiD,SAAS,KAAKhD,SAAS,IAAI,CAACD,KAAK,CAACqB,IAAI,EAAE;IAC5G;EACJ;EACA,IAAI,CAACgH,QAAQ,CAACrI,KAAK,CAACqB,IAAI,CAAC,EAAE;IACvBgH,QAAQ,CAACrI,KAAK,CAACqB,IAAI,CAAC,GAAGG,MAAM,CAACsC,MAAM,CAAC,IAAI,CAAC;EAC9C;EACAuE,QAAQ,CAACrI,KAAK,CAACqB,IAAI,CAAC,CAAErB,KAAK,CAAiBiD,SAAS,CAAC,GAAGjD,KAAoB;AACjF","ignoreList":[]}
|
package/lib/sync.d.ts
CHANGED
|
@@ -151,7 +151,15 @@ export declare class SyncApi {
|
|
|
151
151
|
private shouldAbortSync;
|
|
152
152
|
private getPushRules;
|
|
153
153
|
private buildDefaultFilter;
|
|
154
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Sets up the sync filter options for lazy loading if enabled,
|
|
156
|
+
* (or force-disables lazy loading entirely if we're a guest).
|
|
157
|
+
*/
|
|
158
|
+
private prepareSyncFilterLazyLoading;
|
|
159
|
+
/**
|
|
160
|
+
* Preare sync filter options for the unstable MSC4429 user profile fields if enabled.
|
|
161
|
+
*/
|
|
162
|
+
private prepareSyncFilterUserProfiles;
|
|
155
163
|
private storeClientOptions;
|
|
156
164
|
private getFilter;
|
|
157
165
|
private savedSyncPromise?;
|
package/lib/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAAyB,IAAI,EAAa,MAAM,kBAAkB,CAAC;AAI1E,OAAO,
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAA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ACzB,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,SAAS,EACzB,mBAAmB,EAAE,WAAW,EAAE,EAClC,iBAAiB,CAAC,EAAE,WAAW,EAAE,EACjC,SAAS,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,IAAI,CAAC;IA2EhB;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,cAAc;IAMtB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAOvB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAGd;CACL;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CA2CjH;AAED;;;;;KAKK;AACL,wBAAgB,uBAAuB,CAAC,gBAAgB,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAuD/G"}
|
package/lib/sync.js
CHANGED
|
@@ -32,6 +32,7 @@ import { NotificationCountType, Room, RoomEvent } from "./models/room.js";
|
|
|
32
32
|
import { deepCopy, noUnsafeEventProps, unsafeProp } from "./utils.js";
|
|
33
33
|
import { Filter } from "./filter.js";
|
|
34
34
|
import { EventTimeline } from "./models/event-timeline.js";
|
|
35
|
+
import { logger } from "./logger.js";
|
|
35
36
|
import { ClientEvent, PendingEventOrdering } from "./client.js";
|
|
36
37
|
import { MatrixEvent } from "./models/event.js";
|
|
37
38
|
import { Method } from "./http-api/index.js";
|
|
@@ -162,17 +163,34 @@ export class SyncApi {
|
|
|
162
163
|
}
|
|
163
164
|
return filter;
|
|
164
165
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Sets up the sync filter options for lazy loading if enabled,
|
|
168
|
+
* (or force-disables lazy loading entirely if we're a guest).
|
|
169
|
+
*/
|
|
170
|
+
_defineProperty(this, "prepareSyncFilterLazyLoading", () => {
|
|
171
|
+
this.syncOpts.logger.debug("Prepare lazy loading for sync...");
|
|
172
|
+
if (this.client.isGuest()) {
|
|
173
|
+
this.opts.lazyLoadMembers = false;
|
|
174
|
+
}
|
|
175
|
+
if (this.opts.lazyLoadMembers) {
|
|
176
|
+
this.syncOpts.logger.debug("Enabling lazy load on sync filter...");
|
|
177
|
+
if (!this.opts.filter) {
|
|
178
|
+
this.opts.filter = this.buildDefaultFilter();
|
|
179
|
+
}
|
|
180
|
+
this.opts.filter.setLazyLoadMembers(true);
|
|
169
181
|
}
|
|
170
|
-
|
|
171
|
-
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Preare sync filter options for the unstable MSC4429 user profile fields if enabled.
|
|
185
|
+
*/
|
|
186
|
+
_defineProperty(this, "prepareSyncFilterUserProfiles", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
187
|
+
var _this$opts$unstableMS;
|
|
188
|
+
if ((_this$opts$unstableMS = _this.opts.unstableMSC4429SyncUserProfileFields) !== null && _this$opts$unstableMS !== void 0 && _this$opts$unstableMS.length) {
|
|
189
|
+
_this.syncOpts.logger.debug("Enabling EXPERIMENTAL user profiles on sync filter...");
|
|
172
190
|
if (!_this.opts.filter) {
|
|
173
191
|
_this.opts.filter = _this.buildDefaultFilter();
|
|
174
192
|
}
|
|
175
|
-
_this.opts.filter.
|
|
193
|
+
_this.opts.filter.setUnstableMSC4429SyncUserProfiles(_this.opts.unstableMSC4429SyncUserProfileFields, yield _this.client.doesServerSupportUnstableFeature("org.matrix.msc4429.stable"));
|
|
176
194
|
}
|
|
177
195
|
}));
|
|
178
196
|
_defineProperty(this, "storeClientOptions", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
@@ -602,7 +620,8 @@ export class SyncApi {
|
|
|
602
620
|
// take a while so if we set it going now, we can wait for it
|
|
603
621
|
// to finish while we process our saved sync data.
|
|
604
622
|
yield _this5.getPushRules();
|
|
605
|
-
|
|
623
|
+
_this5.prepareSyncFilterLazyLoading();
|
|
624
|
+
yield _this5.prepareSyncFilterUserProfiles();
|
|
606
625
|
yield _this5.storeClientOptions();
|
|
607
626
|
var {
|
|
608
627
|
filterId,
|
|
@@ -921,7 +940,7 @@ export class SyncApi {
|
|
|
921
940
|
processSyncResponse(syncEventData, data) {
|
|
922
941
|
var _this9 = this;
|
|
923
942
|
return _asyncToGenerator(function* () {
|
|
924
|
-
var _data$presence, _data$account_data, _this9$syncOpts$crypt, _data$device_unused_f;
|
|
943
|
+
var _data$presence, _data$account_data, _data$users, _this9$syncOpts$crypt, _data$device_unused_f;
|
|
925
944
|
var client = _this9.client;
|
|
926
945
|
|
|
927
946
|
// data looks like:
|
|
@@ -1009,6 +1028,29 @@ export class SyncApi {
|
|
|
1009
1028
|
});
|
|
1010
1029
|
}
|
|
1011
1030
|
|
|
1031
|
+
// handle user profile updates (MSC4429)
|
|
1032
|
+
var userUpdate = (_data$users = data["users"]) !== null && _data$users !== void 0 ? _data$users : data["org.matrix.msc4429.users"];
|
|
1033
|
+
if (typeof userUpdate === "object" && userUpdate !== null) {
|
|
1034
|
+
var usersToRemove = [];
|
|
1035
|
+
var profilesToAmend = new Map();
|
|
1036
|
+
for (var [userId, userData] of Object.entries(userUpdate)) {
|
|
1037
|
+
logger.info("Storing user profile ".concat(userId), userData);
|
|
1038
|
+
if (userData.profile_updates) {
|
|
1039
|
+
client.emit(ClientEvent.UserProfileUpdate, userId, userData.profile_updates);
|
|
1040
|
+
var existingProfile = yield client.store.getUserProfile(userId);
|
|
1041
|
+
profilesToAmend.set(userId, _objectSpread(_objectSpread({}, existingProfile), userData.profile_updates));
|
|
1042
|
+
} else if (userData.profile_updates === null) {
|
|
1043
|
+
usersToRemove.push(userId);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (usersToRemove.length) {
|
|
1047
|
+
yield client.store.removeUserProfiles(usersToRemove);
|
|
1048
|
+
}
|
|
1049
|
+
if (profilesToAmend.size) {
|
|
1050
|
+
yield client.store.storeUserProfiles(profilesToAmend);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1012
1054
|
// handle to-device events
|
|
1013
1055
|
if (data.to_device && Array.isArray(data.to_device.events) && data.to_device.events.length > 0) {
|
|
1014
1056
|
var toDeviceMessages = data.to_device.events.filter(noUnsafeEventProps);
|