@unwanted/matrix-sdk-mini 34.12.0-3 → 34.12.0-4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/client.d.ts +0 -45
  3. package/lib/client.d.ts.map +1 -1
  4. package/lib/client.js +0 -119
  5. package/lib/client.js.map +1 -1
  6. package/lib/types.d.ts +0 -1
  7. package/lib/types.d.ts.map +1 -1
  8. package/lib/types.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/client.ts +10 -157
  11. package/src/types.ts +0 -1
  12. package/CHANGELOG.md +0 -5910
  13. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
  14. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
  15. package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
  16. package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
  17. package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
  18. package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
  19. package/lib/utils/decryptAESSecretStorageItem.js +0 -50
  20. package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
  21. package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
  22. package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
  23. package/lib/utils/encryptAESSecretStorageItem.js +0 -68
  24. package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
  25. package/lib/utils/internal/deriveKeys.d.ts +0 -10
  26. package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
  27. package/lib/utils/internal/deriveKeys.js +0 -60
  28. package/lib/utils/internal/deriveKeys.js.map +0 -1
  29. package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
  30. package/src/utils/decryptAESSecretStorageItem.ts +0 -54
  31. package/src/utils/encryptAESSecretStorageItem.ts +0 -73
  32. package/src/utils/internal/deriveKeys.ts +0 -63
package/lib/types.d.ts CHANGED
@@ -3,7 +3,6 @@ export * from "./@types/membership.ts";
3
3
  export type * from "./@types/event.ts";
4
4
  export type * from "./@types/events.ts";
5
5
  export type * from "./@types/state_events.ts";
6
- export type * from "./@types/AESEncryptedSecretStoragePayload.ts";
7
6
  /** The different methods for device and user verification */
8
7
  export declare enum VerificationMethod {
9
8
  /** Short authentication string (emoji or decimals).
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuBA,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,8CAA8C,CAAC;AAElE,6DAA6D;AAC7D,oBAAY,kBAAkB;IAC1B;;;OAGG;IACH,GAAG,aAAa;IAEhB;;;;OAIG;IACH,UAAU,sBAAsB;IAEhC;;;;OAIG;IACH,UAAU,sBAAsB;IAEhC;;;;OAIG;IACH,WAAW,qBAAqB;CACnC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuBA,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,0BAA0B,CAAC;AAE9C,6DAA6D;AAC7D,oBAAY,kBAAkB;IAC1B;;;OAGG;IACH,GAAG,aAAa;IAEhB;;;;OAIG;IACH,UAAU,sBAAsB;IAEhC;;;;OAIG;IACH,UAAU,sBAAsB;IAEhC;;;;OAIG;IACH,WAAW,qBAAqB;CACnC"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["VerificationMethod"],"sources":["../src/types.ts"],"sourcesContent":["/*\nCopyright 2024 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 file is a secondary entrypoint for the js-sdk library, for use by Typescript projects.\n * It exposes low-level types and interfaces reflecting structures defined in the Matrix specification.\n *\n * Remember to only export *public* types from this file.\n */\n\nexport type * from \"./@types/media.ts\";\nexport * from \"./@types/membership.ts\";\nexport type * from \"./@types/event.ts\";\nexport type * from \"./@types/events.ts\";\nexport type * from \"./@types/state_events.ts\";\nexport type * from \"./@types/AESEncryptedSecretStoragePayload.ts\";\n\n/** The different methods for device and user verification */\nexport enum VerificationMethod {\n /** Short authentication string (emoji or decimals).\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#short-authentication-string-sas-verification\n */\n Sas = \"m.sas.v1\",\n\n /**\n * Verification by showing a QR code which is scanned by the other device.\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#qr-codes\n */\n ShowQrCode = \"m.qr_code.show.v1\",\n\n /**\n * Verification by scanning a QR code that is shown by the other device.\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#qr-codes\n */\n ScanQrCode = \"m.qr_code.scan.v1\",\n\n /**\n * Verification by confirming that we have scanned a QR code.\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#qr-codes\n */\n Reciprocate = \"m.reciprocate.v1\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAGA,cAAc,wBAAwB;AAMtC;AACA,WAAYA,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":["VerificationMethod"],"sources":["../src/types.ts"],"sourcesContent":["/*\nCopyright 2024 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 file is a secondary entrypoint for the js-sdk library, for use by Typescript projects.\n * It exposes low-level types and interfaces reflecting structures defined in the Matrix specification.\n *\n * Remember to only export *public* types from this file.\n */\n\nexport type * from \"./@types/media.ts\";\nexport * from \"./@types/membership.ts\";\nexport type * from \"./@types/event.ts\";\nexport type * from \"./@types/events.ts\";\nexport type * from \"./@types/state_events.ts\";\n\n/** The different methods for device and user verification */\nexport enum VerificationMethod {\n /** Short authentication string (emoji or decimals).\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#short-authentication-string-sas-verification\n */\n Sas = \"m.sas.v1\",\n\n /**\n * Verification by showing a QR code which is scanned by the other device.\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#qr-codes\n */\n ShowQrCode = \"m.qr_code.show.v1\",\n\n /**\n * Verification by scanning a QR code that is shown by the other device.\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#qr-codes\n */\n ScanQrCode = \"m.qr_code.scan.v1\",\n\n /**\n * Verification by confirming that we have scanned a QR code.\n *\n * @see https://spec.matrix.org/v1.9/client-server-api/#qr-codes\n */\n Reciprocate = \"m.reciprocate.v1\",\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAGA,cAAc,wBAAwB;AAKtC;AACA,WAAYA,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unwanted/matrix-sdk-mini",
3
- "version": "34.12.0-3",
3
+ "version": "34.12.0-4",
4
4
  "description": "Matrix Client-Server mini SDK for Javascript",
5
5
  "engines": {
6
6
  "node": ">=20.0.0"
package/src/client.ts CHANGED
@@ -201,13 +201,6 @@ interface IExportedDevice {
201
201
  deviceId: string;
202
202
  }
203
203
 
204
- export interface IKeysUploadResponse {
205
- one_time_key_counts: {
206
- // eslint-disable-line camelcase
207
- [algorithm: string]: number;
208
- };
209
- }
210
-
211
204
  export interface ICreateClientOpts {
212
205
  baseUrl: string;
213
206
 
@@ -324,11 +317,6 @@ export interface ICreateClientOpts {
324
317
  */
325
318
  verificationMethods?: Array<string>;
326
319
 
327
- /**
328
- * Whether relaying calls through a TURN server should be forced. Default false.
329
- */
330
- forceTURN?: boolean;
331
-
332
320
  /**
333
321
  * Up to this many ICE candidates will be gathered when an incoming call arrives.
334
322
  * Gathering does not send data to the caller, but will communicate with the configured TURN
@@ -336,23 +324,12 @@ export interface ICreateClientOpts {
336
324
  */
337
325
  iceCandidatePoolSize?: number;
338
326
 
339
- /**
340
- * True to advertise support for call transfers to other parties on Matrix calls. Default false.
341
- */
342
- supportsCallTransfer?: boolean;
343
-
344
327
  /**
345
328
  * Whether to allow a fallback ICE server should be used for negotiating a
346
329
  * WebRTC connection if the homeserver doesn't provide any servers. Defaults to false.
347
330
  */
348
331
  fallbackICEServerAllowed?: boolean;
349
332
 
350
- /**
351
- * If true, to-device signalling for group calls will be encrypted
352
- * with Olm. Default: true.
353
- */
354
- useE2eForGroupCall?: boolean;
355
-
356
333
  livekitServiceURL?: string;
357
334
 
358
335
  /**
@@ -458,7 +435,7 @@ export interface IStartClientOpts {
458
435
  slidingSync?: SlidingSync;
459
436
  }
460
437
 
461
- export interface IStoredClientOpts extends IStartClientOpts {}
438
+ export interface IStoredClientOpts extends IStartClientOpts { }
462
439
 
463
440
  export const GET_LOGIN_TOKEN_CAPABILITY = new NamespacedValue(
464
441
  "m.get_login_token",
@@ -1076,8 +1053,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1076
1053
  public identityServer?: IIdentityServerProvider;
1077
1054
  public http: MatrixHttpApi<IHttpOpts & { onlyData: true }>; // XXX: Intended private, used in code.
1078
1055
 
1079
- public supportsCallTransfer = false; // XXX: Intended private, used in code.
1080
- public forceTURN = false; // XXX: Intended private, used in code.
1081
1056
  public iceCandidatePoolSize = 0; // XXX: Intended private, used in code.
1082
1057
  public idBaseUrl?: string;
1083
1058
  public baseUrl: string;
@@ -1125,7 +1100,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1125
1100
  */
1126
1101
  private eventsBeingEncrypted = new Set<string>();
1127
1102
 
1128
- private useE2eForGroupCall = true;
1129
1103
  private toDeviceMessageQueue: ToDeviceMessageQueue;
1130
1104
  public livekitServiceURL?: string;
1131
1105
 
@@ -1175,12 +1149,12 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1175
1149
  if (this.deviceId) {
1176
1150
  this.logger.warn(
1177
1151
  "not importing device because device ID is provided to " +
1178
- "constructor independently of exported data",
1152
+ "constructor independently of exported data",
1179
1153
  );
1180
1154
  } else if (this.credentials.userId) {
1181
1155
  this.logger.warn(
1182
1156
  "not importing device because user ID is provided to " +
1183
- "constructor independently of exported data",
1157
+ "constructor independently of exported data",
1184
1158
  );
1185
1159
  } else if (!opts.deviceToImport.deviceId) {
1186
1160
  this.logger.warn("not importing device because no device ID in exported data");
@@ -1219,28 +1193,16 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1219
1193
 
1220
1194
  this.verificationMethods = opts.verificationMethods;
1221
1195
 
1222
- this.forceTURN = opts.forceTURN || false;
1223
1196
  this.iceCandidatePoolSize = opts.iceCandidatePoolSize === undefined ? 0 : opts.iceCandidatePoolSize;
1224
- this.supportsCallTransfer = opts.supportsCallTransfer || false;
1225
1197
  this.fallbackICEServerAllowed = opts.fallbackICEServerAllowed || false;
1226
1198
  this.isVoipWithNoMediaAllowed = opts.isVoipWithNoMediaAllowed || false;
1227
1199
 
1228
- if (opts.useE2eForGroupCall !== undefined) this.useE2eForGroupCall = opts.useE2eForGroupCall;
1229
-
1230
1200
  this.livekitServiceURL = opts.livekitServiceURL;
1231
1201
 
1232
1202
  this.roomNameGenerator = opts.roomNameGenerator;
1233
1203
 
1234
1204
  this.toDeviceMessageQueue = new ToDeviceMessageQueue(this);
1235
1205
 
1236
- // The SDK doesn't really provide a clean way for events to recalculate the push
1237
- // actions for themselves, so we have to kinda help them out when they are encrypted.
1238
- // We do this so that push rules are correctly executed on events in their decrypted
1239
- // state, such as highlights when the user's name is mentioned.
1240
- this.on(MatrixEventEvent.Decrypted, (event) => {
1241
- fixNotificationCountOnDecryption(this, event);
1242
- });
1243
-
1244
1206
  this.ignoredInvites = new IgnoredInvites(this);
1245
1207
 
1246
1208
  // having lots of event listeners is not unusual. 0 means "unlimited".
@@ -1443,33 +1405,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1443
1405
  return this.sessionId;
1444
1406
  }
1445
1407
 
1446
- /**
1447
- * Set whether VoIP calls are forced to use only TURN
1448
- * candidates. This is the same as the forceTURN option
1449
- * when creating the client.
1450
- * @param force - True to force use of TURN servers
1451
- */
1452
- public setForceTURN(force: boolean): void {
1453
- this.forceTURN = force;
1454
- }
1455
-
1456
- /**
1457
- * Set whether to advertise transfer support to other parties on Matrix calls.
1458
- * @param support - True to advertise the 'm.call.transferee' capability
1459
- */
1460
- public setSupportsCallTransfer(support: boolean): void {
1461
- this.supportsCallTransfer = support;
1462
- }
1463
-
1464
- /**
1465
- * Returns true if to-device signalling for group calls will be encrypted with Olm.
1466
- * If false, it will be sent unencrypted.
1467
- * @returns boolean Whether group call signalling will be encrypted
1468
- */
1469
- public getUseE2eForGroupCall(): boolean {
1470
- return this.useE2eForGroupCall;
1471
- }
1472
-
1473
1408
  public getLivekitServiceURL(): string | undefined {
1474
1409
  return this.livekitServiceURL;
1475
1410
  }
@@ -2456,7 +2391,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
2456
2391
  if (this.canSupport.get(Feature.RelationBasedRedactions) === ServerSupport.Unsupported) {
2457
2392
  throw new Error(
2458
2393
  "Server does not support relation based redactions " +
2459
- `roomId ${roomId} eventId ${eventId} txnId: ${txnId} threadId ${threadId}`,
2394
+ `roomId ${roomId} eventId ${eventId} txnId: ${txnId} threadId ${threadId}`,
2460
2395
  );
2461
2396
  }
2462
2397
 
@@ -3578,7 +3513,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
3578
3513
  if (!this.timelineSupport) {
3579
3514
  throw new Error(
3580
3515
  "timeline support is disabled. Set the 'timelineSupport'" +
3581
- " parameter to true when creating MatrixClient to enable it.",
3516
+ " parameter to true when creating MatrixClient to enable it.",
3582
3517
  );
3583
3518
  }
3584
3519
 
@@ -3821,7 +3756,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
3821
3756
  if (!this.timelineSupport) {
3822
3757
  throw new Error(
3823
3758
  "timeline support is disabled. Set the 'timelineSupport'" +
3824
- " parameter to true when creating MatrixClient to enable it.",
3759
+ " parameter to true when creating MatrixClient to enable it.",
3825
3760
  );
3826
3761
  }
3827
3762
 
@@ -6984,10 +6919,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
6984
6919
  identityAccessToken: string,
6985
6920
  ): Promise<
6986
6921
  | {
6987
- address: string;
6988
- medium: string;
6989
- mxid: string;
6990
- }
6922
+ address: string;
6923
+ medium: string;
6924
+ mxid: string;
6925
+ }
6991
6926
  | {}
6992
6927
  > {
6993
6928
  // Note: we're using the V2 API by calling this function, but our
@@ -7504,88 +7439,6 @@ function getUnstableDelayQueryOpts(delayOpts: SendDelayedEventRequestOpts): Quer
7504
7439
  );
7505
7440
  }
7506
7441
 
7507
- /**
7508
- * recalculates an accurate notifications count on event decryption.
7509
- * Servers do not have enough knowledge about encrypted events to calculate an
7510
- * accurate notification_count
7511
- */
7512
- export function fixNotificationCountOnDecryption(cli: MatrixClient, event: MatrixEvent): void {
7513
- const ourUserId = cli.getUserId();
7514
- const eventId = event.getId();
7515
-
7516
- const room = cli.getRoom(event.getRoomId());
7517
- if (!room || !ourUserId || !eventId) return;
7518
-
7519
- // Due to threads, we can get relation events (eg. edits & reactions) that never get
7520
- // added to a timeline and so cannot be found in their own room (their edit / reaction
7521
- // still applies to the event it needs to, so it doesn't matter too much). However, if
7522
- // we try to process notification about this event, we'll get very confused because we
7523
- // won't be able to find the event in the room, so will assume it must be unread, even
7524
- // if it's actually read. We therefore skip anything that isn't in the room. This isn't
7525
- // *great*, so if we can fix the homeless events (eg. with MSC4023) then we should probably
7526
- // remove this workaround.
7527
- if (!room.findEventById(eventId)) {
7528
- logger.info(`Decrypted event ${event.getId()} is not in room ${room.roomId}: ignoring`);
7529
- return;
7530
- }
7531
-
7532
- const isThreadEvent = !!event.threadRootId && !event.isThreadRoot;
7533
-
7534
- let hasReadEvent;
7535
- if (isThreadEvent) {
7536
- const thread = room.getThread(event.threadRootId);
7537
- hasReadEvent = thread
7538
- ? thread.hasUserReadEvent(ourUserId, eventId)
7539
- : // If the thread object does not exist in the room yet, we don't
7540
- // want to calculate notification for this event yet. We have not
7541
- // restored the read receipts yet and can't accurately calculate
7542
- // notifications at this stage.
7543
- //
7544
- // This issue can likely go away when MSC3874 is implemented
7545
- true;
7546
- } else {
7547
- hasReadEvent = room.hasUserReadEvent(ourUserId, eventId);
7548
- }
7549
-
7550
- if (hasReadEvent) {
7551
- // If the event has been read, ignore it.
7552
- return;
7553
- }
7554
-
7555
- const actions = cli.getPushActionsForEvent(event, true);
7556
-
7557
- // Ensure the unread counts are kept up to date if the event is encrypted
7558
- // We also want to make sure that the notification count goes up if we already
7559
- // have encrypted events to avoid other code from resetting 'highlight' to zero.
7560
- const newHighlight = !!actions?.tweaks?.highlight;
7561
-
7562
- if (newHighlight) {
7563
- // TODO: Handle mentions received while the client is offline
7564
- // See also https://github.com/vector-im/element-web/issues/9069
7565
- const newCount = room.getUnreadCountForEventContext(NotificationCountType.Highlight, event) + 1;
7566
- if (isThreadEvent) {
7567
- room.setThreadUnreadNotificationCount(event.threadRootId, NotificationCountType.Highlight, newCount);
7568
- } else {
7569
- room.setUnreadNotificationCount(NotificationCountType.Highlight, newCount);
7570
- }
7571
- }
7572
-
7573
- // `notify` is used in practice for incrementing the total count
7574
- const newNotify = !!actions?.notify;
7575
-
7576
- // The room total count is NEVER incremented by the server for encrypted rooms. We basically ignore
7577
- // the server here as it's always going to tell us to increment for encrypted events.
7578
- if (newNotify) {
7579
- // Total count is used to typically increment a room notification counter, but not loudly highlight it.
7580
- const newCount = room.getUnreadCountForEventContext(NotificationCountType.Total, event) + 1;
7581
- if (isThreadEvent) {
7582
- room.setThreadUnreadNotificationCount(event.threadRootId, NotificationCountType.Total, newCount);
7583
- } else {
7584
- room.setUnreadNotificationCount(NotificationCountType.Total, newCount);
7585
- }
7586
- }
7587
- }
7588
-
7589
7442
  /**
7590
7443
  * Given an event, figure out the thread ID we should use for it in a receipt.
7591
7444
  *
package/src/types.ts CHANGED
@@ -26,7 +26,6 @@ export * from "./@types/membership.ts";
26
26
  export type * from "./@types/event.ts";
27
27
  export type * from "./@types/events.ts";
28
28
  export type * from "./@types/state_events.ts";
29
- export type * from "./@types/AESEncryptedSecretStoragePayload.ts";
30
29
 
31
30
  /** The different methods for device and user verification */
32
31
  export enum VerificationMethod {