@unwanted/matrix-sdk-mini 34.13.0 → 36.0.1

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.
Files changed (96) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/@types/event.d.ts +25 -0
  3. package/lib/@types/event.d.ts.map +1 -1
  4. package/lib/@types/event.js +5 -0
  5. package/lib/@types/event.js.map +1 -1
  6. package/lib/client.d.ts +44 -19
  7. package/lib/client.d.ts.map +1 -1
  8. package/lib/client.js +148 -90
  9. package/lib/client.js.map +1 -1
  10. package/lib/embedded.d.ts +4 -3
  11. package/lib/embedded.d.ts.map +1 -1
  12. package/lib/embedded.js +57 -74
  13. package/lib/embedded.js.map +1 -1
  14. package/lib/feature.d.ts.map +1 -1
  15. package/lib/feature.js +2 -1
  16. package/lib/feature.js.map +1 -1
  17. package/lib/http-api/errors.d.ts +3 -3
  18. package/lib/http-api/errors.js +3 -3
  19. package/lib/http-api/errors.js.map +1 -1
  20. package/lib/http-api/utils.js +2 -2
  21. package/lib/http-api/utils.js.map +1 -1
  22. package/lib/models/event-timeline.d.ts.map +1 -1
  23. package/lib/models/event-timeline.js +1 -21
  24. package/lib/models/event-timeline.js.map +1 -1
  25. package/lib/models/event.d.ts +11 -1
  26. package/lib/models/event.d.ts.map +1 -1
  27. package/lib/models/event.js +48 -5
  28. package/lib/models/event.js.map +1 -1
  29. package/lib/models/invites-ignorer-types.d.ts +27 -0
  30. package/lib/models/invites-ignorer-types.d.ts.map +1 -0
  31. package/lib/models/invites-ignorer-types.js +36 -0
  32. package/lib/models/invites-ignorer-types.js.map +1 -0
  33. package/lib/models/invites-ignorer.d.ts +2 -26
  34. package/lib/models/invites-ignorer.d.ts.map +1 -1
  35. package/lib/models/invites-ignorer.js +2 -27
  36. package/lib/models/invites-ignorer.js.map +1 -1
  37. package/lib/models/room-member.d.ts +6 -1
  38. package/lib/models/room-member.d.ts.map +1 -1
  39. package/lib/models/room-member.js +7 -1
  40. package/lib/models/room-member.js.map +1 -1
  41. package/lib/models/room.d.ts +6 -1
  42. package/lib/models/room.d.ts.map +1 -1
  43. package/lib/models/room.js +7 -1
  44. package/lib/models/room.js.map +1 -1
  45. package/lib/oidc/authorize.d.ts +2 -2
  46. package/lib/oidc/authorize.d.ts.map +1 -1
  47. package/lib/oidc/authorize.js +5 -5
  48. package/lib/oidc/authorize.js.map +1 -1
  49. package/lib/oidc/discovery.d.ts +8 -0
  50. package/lib/oidc/discovery.d.ts.map +1 -1
  51. package/lib/oidc/discovery.js +22 -11
  52. package/lib/oidc/discovery.js.map +1 -1
  53. package/lib/oidc/index.d.ts +3 -4
  54. package/lib/oidc/index.d.ts.map +1 -1
  55. package/lib/oidc/index.js.map +1 -1
  56. package/lib/oidc/register.js +3 -3
  57. package/lib/oidc/register.js.map +1 -1
  58. package/lib/oidc/tokenRefresher.d.ts.map +1 -1
  59. package/lib/oidc/tokenRefresher.js +6 -5
  60. package/lib/oidc/tokenRefresher.js.map +1 -1
  61. package/lib/oidc/validate.d.ts +9 -23
  62. package/lib/oidc/validate.d.ts.map +1 -1
  63. package/lib/oidc/validate.js +13 -28
  64. package/lib/oidc/validate.js.map +1 -1
  65. package/lib/randomstring.d.ts +30 -3
  66. package/lib/randomstring.d.ts.map +1 -1
  67. package/lib/randomstring.js +68 -16
  68. package/lib/randomstring.js.map +1 -1
  69. package/lib/store/indexeddb-local-backend.js +4 -2
  70. package/lib/store/indexeddb-local-backend.js.map +1 -1
  71. package/lib/testing.d.ts +17 -0
  72. package/lib/testing.d.ts.map +1 -1
  73. package/lib/testing.js +42 -0
  74. package/lib/testing.js.map +1 -1
  75. package/package.json +5 -5
  76. package/src/@types/event.ts +17 -0
  77. package/src/client.ts +87 -41
  78. package/src/embedded.ts +41 -51
  79. package/src/feature.ts +1 -0
  80. package/src/http-api/errors.ts +3 -3
  81. package/src/http-api/utils.ts +2 -2
  82. package/src/models/event-timeline.ts +1 -21
  83. package/src/models/event.ts +46 -0
  84. package/src/models/invites-ignorer-types.ts +48 -0
  85. package/src/models/invites-ignorer.ts +7 -42
  86. package/src/models/room-member.ts +16 -1
  87. package/src/models/room.ts +16 -1
  88. package/src/oidc/authorize.ts +7 -7
  89. package/src/oidc/discovery.ts +16 -10
  90. package/src/oidc/index.ts +3 -4
  91. package/src/oidc/register.ts +3 -3
  92. package/src/oidc/tokenRefresher.ts +3 -2
  93. package/src/oidc/validate.ts +40 -63
  94. package/src/randomstring.ts +65 -19
  95. package/src/store/indexeddb-local-backend.ts +2 -2
  96. package/src/testing.ts +41 -0
package/lib/embedded.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { WidgetApi } from "matrix-widget-api";
2
2
  import { ISendEventResponse, SendDelayedEventRequestOpts, SendDelayedEventResponse, UpdateDelayedEventAction } from "./@types/requests.ts";
3
3
  import { StateEvents } from "./@types/event.ts";
4
- import { MatrixClient, IMatrixClientCreateOpts, IStartClientOpts, SendToDeviceContentMap, IOpenIDToken } from "./client.ts";
4
+ import { MatrixClient, ICreateClientOpts, IStartClientOpts, SendToDeviceContentMap, IOpenIDToken } from "./client.ts";
5
5
  import { SyncState } from "./sync.ts";
6
6
  import { Room } from "./models/room.ts";
7
7
  import { ToDeviceBatch } from "./models/ToDeviceMessage.ts";
@@ -75,10 +75,10 @@ export type EventHandlerMap = {
75
75
  */
76
76
  export declare class RoomWidgetClient extends MatrixClient {
77
77
  private readonly widgetApi;
78
- private readonly capabilities;
79
78
  private readonly roomId;
80
79
  private room?;
81
80
  private readonly widgetApiReady;
81
+ private readonly roomStateSynced;
82
82
  private lifecycle?;
83
83
  private syncState;
84
84
  private pendingSendingEventsTxId;
@@ -93,7 +93,7 @@ export declare class RoomWidgetClient extends MatrixClient {
93
93
  * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),
94
94
  * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.
95
95
  */
96
- constructor(widgetApi: WidgetApi, capabilities: ICapabilities, roomId: string, opts: IMatrixClientCreateOpts, sendContentLoaded: boolean);
96
+ constructor(widgetApi: WidgetApi, capabilities: ICapabilities, roomId: string, opts: ICreateClientOpts, sendContentLoaded: boolean);
97
97
  startClient(opts?: IStartClientOpts): Promise<void>;
98
98
  stopClient(): void;
99
99
  joinRoom(roomIdOrAlias: string): Promise<Room>;
@@ -116,6 +116,7 @@ export declare class RoomWidgetClient extends MatrixClient {
116
116
  private updateTxId;
117
117
  private onEvent;
118
118
  private onToDevice;
119
+ private onStateUpdate;
119
120
  }
120
121
  export {};
121
122
  //# sourceMappingURL=embedded.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,SAAS,EAaZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACH,kBAAkB,EAClB,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACH,YAAY,EAEZ,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAW,SAAS,EAAE,MAAM,WAAW,CAAC;AAI/C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAmB,MAAM,6BAA6B,CAAC;AAI7E,UAAU,kBAAkB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,cAAc,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EAAE,CAAC;IAKhF,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC;IAYvC,aAAa,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvE,YAAY,IAAI,SAAS,GAAG,IAAI;IAIvC,OAAO,CAAC,YAAY;YAMN,GAAG;IAIjB,OAAO,CAAC,UAAU,CAwChB;IAEF,OAAO,CAAC,OAAO,CA0Bb;IAEF,OAAO,CAAC,UAAU,CAYhB;IAEF,OAAO,CAAC,aAAa,CAqBnB;CACL"}
package/lib/embedded.js CHANGED
@@ -48,15 +48,15 @@ export class RoomWidgetClient extends MatrixClient {
48
48
  * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),
49
49
  * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.
50
50
  */
51
- constructor(widgetApi, capabilities, roomId, opts, sendContentLoaded) {
52
- var _this, _capabilities$sendEve, _capabilities$receive, _capabilities$sendSta, _capabilities$receive2, _capabilities$sendEve2, _capabilities$receive3, _capabilities$sendSta2, _capabilities$receive4, _capabilities$sendToD, _capabilities$receive5, _capabilities$sendEve3, _capabilities$sendSta3;
51
+ constructor(widgetApi, /*private readonly */capabilities, roomId, opts, sendContentLoaded) {
52
+ var _this, _capabilities$receive, _capabilities$sendEve, _capabilities$receive2, _capabilities$sendSta, _capabilities$receive3, _capabilities$sendEve2, _capabilities$receive4, _capabilities$sendSta2, _capabilities$receive5, _capabilities$sendToD, _capabilities$receive6, _capabilities$sendEve3, _capabilities$sendSta3;
53
53
  super(opts);
54
54
  _this = this;
55
55
  this.widgetApi = widgetApi;
56
- this.capabilities = capabilities;
57
56
  this.roomId = roomId;
58
57
  _defineProperty(this, "room", void 0);
59
58
  _defineProperty(this, "widgetApiReady", void 0);
59
+ _defineProperty(this, "roomStateSynced", void 0);
60
60
  _defineProperty(this, "lifecycle", void 0);
61
61
  _defineProperty(this, "syncState", null);
62
62
  _defineProperty(this, "pendingSendingEventsTxId", []);
@@ -119,37 +119,15 @@ export class RoomWidgetClient extends MatrixClient {
119
119
 
120
120
  // Only inject once we have update the txId
121
121
  yield _this.updateTxId(event);
122
-
123
- // The widget API does not tell us whether a state event came from `state_after` or not so we assume legacy behaviour for now.
124
122
  if (_this.syncApi instanceof SyncApi) {
125
- // The code will want to be something like:
126
- // ```
127
- // if (!params.addToTimeline && !params.addToState) {
128
- // // Passing undefined for `stateAfterEventList` makes `injectRoomEvents` run in "legacy mode"
129
- // // -> state events part of the `timelineEventList` parameter will update the state.
130
- // this.injectRoomEvents(this.room!, [], undefined, [event]);
131
- // } else {
132
- // this.injectRoomEvents(this.room!, undefined, params.addToState ? [event] : [], params.addToTimeline ? [event] : []);
133
- // }
134
- // ```
135
-
136
- // Passing undefined for `stateAfterEventList` allows will make `injectRoomEvents` run in legacy mode
137
- // -> state events in `timelineEventList` will update the state.
138
- yield _this.syncApi.injectRoomEvents(_this.room, [], undefined, [event]);
123
+ yield _this.syncApi.injectRoomEvents(_this.room, undefined, [], [event]);
139
124
  } else {
140
- // The code will want to be something like:
141
- // ```
142
- // if (!params.addToTimeline && !params.addToState) {
143
- // this.injectRoomEvents(this.room!, [], [event]);
144
- // } else {
145
- // this.injectRoomEvents(this.room!, params.addToState ? [event] : [], params.addToTimeline ? [event] : []);
146
- // }
147
- // ```
148
- yield _this.syncApi.injectRoomEvents(_this.room, [], [event]); // Sliding Sync
125
+ // Sliding Sync
126
+ yield _this.syncApi.injectRoomEvents(_this.room, [], [event]);
149
127
  }
150
128
  _this.emit(ClientEvent.Event, event);
151
129
  _this.setSyncState(SyncState.Syncing);
152
- logger.info("Received event ".concat(event.getId(), " ").concat(event.getType(), " ").concat(event.getStateKey()));
130
+ logger.info("Received event ".concat(event.getId(), " ").concat(event.getType()));
153
131
  } else {
154
132
  var {
155
133
  event_id: eventId,
@@ -179,40 +157,71 @@ export class RoomWidgetClient extends MatrixClient {
179
157
  return _ref3.apply(this, arguments);
180
158
  };
181
159
  }());
160
+ _defineProperty(this, "onStateUpdate", /*#__PURE__*/function () {
161
+ var _ref4 = _asyncToGenerator(function* (ev) {
162
+ ev.preventDefault();
163
+ for (var rawEvent of ev.detail.data.state) {
164
+ // Verify the room ID matches, since it's possible for the client to
165
+ // send us state updates from other rooms if this widget is always
166
+ // on screen
167
+ if (rawEvent.room_id === _this.roomId) {
168
+ var event = new MatrixEvent(rawEvent);
169
+ if (_this.syncApi instanceof SyncApi) {
170
+ yield _this.syncApi.injectRoomEvents(_this.room, undefined, [event]);
171
+ } else {
172
+ // Sliding Sync
173
+ yield _this.syncApi.injectRoomEvents(_this.room, [event]);
174
+ }
175
+ logger.info("Updated state entry ".concat(event.getType(), " ").concat(event.getStateKey(), " to ").concat(event.getId()));
176
+ } else {
177
+ var {
178
+ event_id: eventId,
179
+ room_id: _roomId2
180
+ } = ev.detail.data;
181
+ logger.info("Received state entry ".concat(eventId, " for a different room ").concat(_roomId2, "; discarding"));
182
+ }
183
+ }
184
+ yield _this.ack(ev);
185
+ });
186
+ return function (_x4) {
187
+ return _ref4.apply(this, arguments);
188
+ };
189
+ }());
182
190
  var transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);
183
191
  this.widgetApi.transport.send = /*#__PURE__*/function () {
184
- var _ref4 = _asyncToGenerator(function* (action, data) {
192
+ var _ref5 = _asyncToGenerator(function* (action, data) {
185
193
  try {
186
194
  return yield transportSend(action, data);
187
195
  } catch (error) {
188
196
  processAndThrow(error);
189
197
  }
190
198
  });
191
- return function (_x4, _x5) {
192
- return _ref4.apply(this, arguments);
199
+ return function (_x5, _x6) {
200
+ return _ref5.apply(this, arguments);
193
201
  };
194
202
  }();
195
203
  var transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);
196
204
  this.widgetApi.transport.sendComplete = /*#__PURE__*/function () {
197
- var _ref5 = _asyncToGenerator(function* (action, data) {
205
+ var _ref6 = _asyncToGenerator(function* (action, data) {
198
206
  try {
199
207
  return yield transportSendComplete(action, data);
200
208
  } catch (error) {
201
209
  processAndThrow(error);
202
210
  }
203
211
  });
204
- return function (_x6, _x7) {
205
- return _ref5.apply(this, arguments);
212
+ return function (_x7, _x8) {
213
+ return _ref6.apply(this, arguments);
206
214
  };
207
215
  }();
208
216
  this.widgetApiReady = new Promise(resolve => this.widgetApi.once("ready", resolve));
217
+ this.roomStateSynced = (_capabilities$receive = capabilities.receiveState) !== null && _capabilities$receive !== void 0 && _capabilities$receive.length ? new Promise(resolve => this.widgetApi.once("action:".concat(WidgetApiToWidgetAction.UpdateState), resolve)) : Promise.resolve();
209
218
 
210
219
  // Request capabilities for the functionality this client needs to support
211
- if ((_capabilities$sendEve = capabilities.sendEvent) !== null && _capabilities$sendEve !== void 0 && _capabilities$sendEve.length || (_capabilities$receive = capabilities.receiveEvent) !== null && _capabilities$receive !== void 0 && _capabilities$receive.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.receiveMessage === true || Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length || (_capabilities$sendSta = capabilities.sendState) !== null && _capabilities$sendSta !== void 0 && _capabilities$sendSta.length || (_capabilities$receive2 = capabilities.receiveState) !== null && _capabilities$receive2 !== void 0 && _capabilities$receive2.length) {
220
+ if ((_capabilities$sendEve = capabilities.sendEvent) !== null && _capabilities$sendEve !== void 0 && _capabilities$sendEve.length || (_capabilities$receive2 = capabilities.receiveEvent) !== null && _capabilities$receive2 !== void 0 && _capabilities$receive2.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.receiveMessage === true || Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length || (_capabilities$sendSta = capabilities.sendState) !== null && _capabilities$sendSta !== void 0 && _capabilities$sendSta.length || (_capabilities$receive3 = capabilities.receiveState) !== null && _capabilities$receive3 !== void 0 && _capabilities$receive3.length) {
212
221
  widgetApi.requestCapabilityForRoomTimeline(roomId);
213
222
  }
214
223
  (_capabilities$sendEve2 = capabilities.sendEvent) === null || _capabilities$sendEve2 === void 0 || _capabilities$sendEve2.forEach(eventType => widgetApi.requestCapabilityToSendEvent(eventType));
215
- (_capabilities$receive3 = capabilities.receiveEvent) === null || _capabilities$receive3 === void 0 || _capabilities$receive3.forEach(eventType => widgetApi.requestCapabilityToReceiveEvent(eventType));
224
+ (_capabilities$receive4 = capabilities.receiveEvent) === null || _capabilities$receive4 === void 0 || _capabilities$receive4.forEach(eventType => widgetApi.requestCapabilityToReceiveEvent(eventType));
216
225
  if (capabilities.sendMessage === true) {
217
226
  widgetApi.requestCapabilityToSendMessage();
218
227
  } else if (Array.isArray(capabilities.sendMessage)) {
@@ -223,22 +232,22 @@ export class RoomWidgetClient extends MatrixClient {
223
232
  } else if (Array.isArray(capabilities.receiveMessage)) {
224
233
  capabilities.receiveMessage.forEach(msgType => widgetApi.requestCapabilityToReceiveMessage(msgType));
225
234
  }
226
- (_capabilities$sendSta2 = capabilities.sendState) === null || _capabilities$sendSta2 === void 0 || _capabilities$sendSta2.forEach(_ref6 => {
235
+ (_capabilities$sendSta2 = capabilities.sendState) === null || _capabilities$sendSta2 === void 0 || _capabilities$sendSta2.forEach(_ref7 => {
227
236
  var {
228
237
  eventType,
229
238
  stateKey
230
- } = _ref6;
239
+ } = _ref7;
231
240
  return widgetApi.requestCapabilityToSendState(eventType, stateKey);
232
241
  });
233
- (_capabilities$receive4 = capabilities.receiveState) === null || _capabilities$receive4 === void 0 || _capabilities$receive4.forEach(_ref7 => {
242
+ (_capabilities$receive5 = capabilities.receiveState) === null || _capabilities$receive5 === void 0 || _capabilities$receive5.forEach(_ref8 => {
234
243
  var {
235
244
  eventType,
236
245
  stateKey
237
- } = _ref7;
246
+ } = _ref8;
238
247
  return widgetApi.requestCapabilityToReceiveState(eventType, stateKey);
239
248
  });
240
249
  (_capabilities$sendToD = capabilities.sendToDevice) === null || _capabilities$sendToD === void 0 || _capabilities$sendToD.forEach(eventType => widgetApi.requestCapabilityToSendToDevice(eventType));
241
- (_capabilities$receive5 = capabilities.receiveToDevice) === null || _capabilities$receive5 === void 0 || _capabilities$receive5.forEach(eventType => widgetApi.requestCapabilityToReceiveToDevice(eventType));
250
+ (_capabilities$receive6 = capabilities.receiveToDevice) === null || _capabilities$receive6 === void 0 || _capabilities$receive6.forEach(eventType => widgetApi.requestCapabilityToReceiveToDevice(eventType));
242
251
  if (capabilities.sendDelayedEvents && ((_capabilities$sendEve3 = capabilities.sendEvent) !== null && _capabilities$sendEve3 !== void 0 && _capabilities$sendEve3.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || (_capabilities$sendSta3 = capabilities.sendState) !== null && _capabilities$sendSta3 !== void 0 && _capabilities$sendSta3.length)) {
243
252
  widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);
244
253
  }
@@ -250,6 +259,7 @@ export class RoomWidgetClient extends MatrixClient {
250
259
  }
251
260
  widgetApi.on("action:".concat(WidgetApiToWidgetAction.SendEvent), this.onEvent);
252
261
  widgetApi.on("action:".concat(WidgetApiToWidgetAction.SendToDevice), this.onToDevice);
262
+ widgetApi.on("action:".concat(WidgetApiToWidgetAction.UpdateState), this.onStateUpdate);
253
263
 
254
264
  // Open communication with the host
255
265
  widgetApi.start();
@@ -264,7 +274,6 @@ export class RoomWidgetClient extends MatrixClient {
264
274
  var _arguments = arguments,
265
275
  _this2 = this;
266
276
  return _asyncToGenerator(function* () {
267
- var _this2$capabilities$r, _this2$capabilities$r2;
268
277
  var opts = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
269
278
  _this2.lifecycle = new AbortController();
270
279
 
@@ -286,47 +295,21 @@ export class RoomWidgetClient extends MatrixClient {
286
295
  _this2.room = _this2.syncApi.createRoom(_this2.roomId);
287
296
  _this2.store.storeRoom(_this2.room);
288
297
  yield _this2.widgetApiReady;
289
-
290
- // Backfill the requested events
291
- // We only get the most recent event for every type + state key combo,
292
- // so it doesn't really matter what order we inject them in
293
- yield Promise.all((_this2$capabilities$r = (_this2$capabilities$r2 = _this2.capabilities.receiveState) === null || _this2$capabilities$r2 === void 0 ? void 0 : _this2$capabilities$r2.map(/*#__PURE__*/function () {
294
- var _ref9 = _asyncToGenerator(function* (_ref8) {
295
- var {
296
- eventType,
297
- stateKey
298
- } = _ref8;
299
- var rawEvents = yield _this2.widgetApi.readStateEvents(eventType, undefined, stateKey, [_this2.roomId]);
300
- var events = rawEvents.map(rawEvent => new MatrixEvent(rawEvent));
301
- if (_this2.syncApi instanceof SyncApi) {
302
- // Passing undefined for `stateAfterEventList` allows will make `injectRoomEvents` run in legacy mode
303
- // -> state events in `timelineEventList` will update the state.
304
- yield _this2.syncApi.injectRoomEvents(_this2.room, undefined, events);
305
- } else {
306
- yield _this2.syncApi.injectRoomEvents(_this2.room, events); // Sliding Sync
307
- }
308
- events.forEach(event => {
309
- _this2.emit(ClientEvent.Event, event);
310
- logger.info("Backfilled event ".concat(event.getId(), " ").concat(event.getType(), " ").concat(event.getStateKey()));
311
- });
312
- });
313
- return function (_x8) {
314
- return _ref9.apply(this, arguments);
315
- };
316
- }())) !== null && _this2$capabilities$r !== void 0 ? _this2$capabilities$r : []);
317
298
  if (opts.clientWellKnownPollPeriod !== undefined) {
318
299
  _this2.clientWellKnownIntervalID = setInterval(() => {
319
300
  _this2.fetchClientWellKnown();
320
301
  }, 1000 * opts.clientWellKnownPollPeriod);
321
302
  _this2.fetchClientWellKnown();
322
303
  }
304
+ yield _this2.roomStateSynced;
323
305
  _this2.setSyncState(SyncState.Syncing);
324
- logger.info("Finished backfilling events");
306
+ logger.info("Finished initial sync");
325
307
  })();
326
308
  }
327
309
  stopClient() {
328
310
  this.widgetApi.off("action:".concat(WidgetApiToWidgetAction.SendEvent), this.onEvent);
329
311
  this.widgetApi.off("action:".concat(WidgetApiToWidgetAction.SendToDevice), this.onToDevice);
312
+ this.widgetApi.off("action:".concat(WidgetApiToWidgetAction.UpdateState), this.onStateUpdate);
330
313
  super.stopClient();
331
314
  this.lifecycle.abort(); // Signal to other async tasks that the client has stopped
332
315
  }
@@ -411,13 +394,13 @@ export class RoomWidgetClient extends MatrixClient {
411
394
  };
412
395
  })();
413
396
  }
414
- queueToDevice(_ref10) {
397
+ queueToDevice(_ref9) {
415
398
  var _this9 = this;
416
399
  return _asyncToGenerator(function* () {
417
400
  var {
418
401
  eventType,
419
402
  batch
420
- } = _ref10;
403
+ } = _ref9;
421
404
  // map: user Id → device Id → payload
422
405
  var contentMap = new MapWithDefault(() => new Map());
423
406
  for (var {
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.js","names":["WidgetApiToWidgetAction","WidgetApiResponseError","MatrixCapabilities","MatrixEvent","logger","MatrixClient","ClientEvent","UNSTABLE_MSC4140_DELAYED_EVENTS","SyncApi","SyncState","SlidingSyncSdk","MatrixError","User","MapWithDefault","recursiveMapToObject","TypedEventEmitter","RoomWidgetClientEvent","RoomWidgetClient","constructor","widgetApi","capabilities","roomId","opts","sendContentLoaded","_this","_capabilities$sendEve","_capabilities$receive","_capabilities$sendSta","_capabilities$receive2","_capabilities$sendEve2","_capabilities$receive3","_capabilities$sendSta2","_capabilities$receive4","_capabilities$sendToD","_capabilities$receive5","_capabilities$sendEve3","_capabilities$sendSta3","this","_defineProperty","_ref","_asyncToGenerator","event","getSender","getUserId","pendingSendingEventsTxId","some","p","getType","type","_this$pendingSendingE","matchingTxId","find","id","getId","txId","length","_this$pendingSendingE2","Promise","resolve","eventEmitter","once","PendingEventsChanged","setTxnId","setUnsigned","_objectSpread","getUnsigned","transaction_id","filter","emit","_x","apply","arguments","_ref2","ev","preventDefault","detail","data","room_id","updateTxId","syncApi","injectRoomEvents","room","undefined","Event","setSyncState","Syncing","info","concat","getStateKey","event_id","eventId","ack","_x2","_ref3","sender","content","ToDeviceEvent","_x3","transportSend","transport","send","bind","_ref4","action","error","processAndThrow","_x4","_x5","transportSendComplete","sendComplete","_ref5","_x6","_x7","widgetApiReady","sendEvent","receiveEvent","sendMessage","Array","isArray","receiveMessage","sendState","receiveState","requestCapabilityForRoomTimeline","forEach","eventType","requestCapabilityToSendEvent","requestCapabilityToReceiveEvent","requestCapabilityToSendMessage","msgType","requestCapabilityToReceiveMessage","_ref6","stateKey","requestCapabilityToSendState","_ref7","requestCapabilityToReceiveState","sendToDevice","requestCapabilityToSendToDevice","receiveToDevice","requestCapabilityToReceiveToDevice","sendDelayedEvents","requestCapability","MSC4157SendDelayedEvent","updateDelayedEvents","MSC4157UpdateDelayedEvent","turnServers","MSC3846TurnServers","on","SendEvent","onEvent","SendToDevice","onToDevice","start","startClient","_arguments","_this2","_this2$capabilities$r","_this2$capabilities$r2","lifecycle","AbortController","userId","store","storeUser","slidingSync","buildSyncApiOptions","createRoom","storeRoom","all","map","_ref9","_ref8","rawEvents","readStateEvents","events","rawEvent","_x8","clientWellKnownPollPeriod","clientWellKnownIntervalID","setInterval","fetchClientWellKnown","stopClient","off","abort","joinRoom","roomIdOrAlias","_this3","Error","sendStateEvent","_arguments2","_this4","response","_unstable_sendDelayedStateEvent","delayOpts","_arguments3","_this5","doesServerSupportUnstableFeature","delay","parent_delay_id","validateSendDelayedEventResponse","delay_id","_unstable_updateDelayedEvent","delayId","_this6","updateDelayedEvent","contentMap","_this7","getOpenIdToken","_this8","token","requestOpenIDConnectToken","access_token","expires_in","matrix_server_name","token_type","queueToDevice","_ref10","_this9","batch","Map","deviceId","payload","getOrCreate","set","getSyncState","syncState","state","oldState","Sync","_this10","reply","matrix_api_error","fromWidgetApiErrorData"],"sources":["../src/embedded.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n WidgetApi,\n WidgetApiToWidgetAction,\n WidgetApiResponseError,\n MatrixCapabilities,\n IWidgetApiRequest,\n IWidgetApiAcknowledgeResponseData,\n ISendEventToWidgetActionRequest,\n ISendToDeviceToWidgetActionRequest,\n ISendEventFromWidgetResponseData,\n IWidgetApiRequestData,\n WidgetApiAction,\n IWidgetApiResponse,\n IWidgetApiResponseData,\n} from \"matrix-widget-api\";\n\nimport { MatrixEvent, IEvent, IContent } from \"./models/event.ts\";\nimport {\n ISendEventResponse,\n SendDelayedEventRequestOpts,\n SendDelayedEventResponse,\n UpdateDelayedEventAction,\n} from \"./@types/requests.ts\";\nimport { StateEvents } from \"./@types/event.ts\";\nimport { logger } from \"./logger.ts\";\nimport {\n MatrixClient,\n ClientEvent,\n IMatrixClientCreateOpts,\n IStartClientOpts,\n SendToDeviceContentMap,\n IOpenIDToken,\n UNSTABLE_MSC4140_DELAYED_EVENTS,\n} from \"./client.ts\";\nimport { SyncApi, SyncState } from \"./sync.ts\";\nimport { SlidingSyncSdk } from \"./sliding-sync-sdk.ts\";\nimport { MatrixError } from \"./http-api/errors.ts\";\nimport { User } from \"./models/user.ts\";\nimport { Room } from \"./models/room.ts\";\nimport { ToDeviceBatch, ToDevicePayload } from \"./models/ToDeviceMessage.ts\";\nimport { MapWithDefault, recursiveMapToObject } from \"./utils.ts\";\nimport { TypedEventEmitter } from \"./matrix.ts\";\n\ninterface IStateEventRequest {\n eventType: string;\n stateKey?: string;\n}\n\nexport interface ICapabilities {\n /**\n * Event types that this client expects to send.\n */\n sendEvent?: string[];\n /**\n * Event types that this client expects to receive.\n */\n receiveEvent?: string[];\n\n /**\n * Message types that this client expects to send, or true for all message\n * types.\n */\n sendMessage?: string[] | true;\n /**\n * Message types that this client expects to receive, or true for all\n * message types.\n */\n receiveMessage?: string[] | true;\n\n /**\n * Types of state events that this client expects to send.\n */\n sendState?: IStateEventRequest[];\n /**\n * Types of state events that this client expects to receive.\n */\n receiveState?: IStateEventRequest[];\n\n /**\n * To-device event types that this client expects to send.\n */\n sendToDevice?: string[];\n /**\n * To-device event types that this client expects to receive.\n */\n receiveToDevice?: string[];\n\n /**\n * Whether this client needs access to TURN servers.\n * @defaultValue false\n */\n turnServers?: boolean;\n\n /**\n * Whether this client needs to be able to send delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n sendDelayedEvents?: boolean;\n\n /**\n * Whether this client needs to be able to update delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n updateDelayedEvents?: boolean;\n}\n\nexport enum RoomWidgetClientEvent {\n PendingEventsChanged = \"PendingEvent.pendingEventsChanged\",\n}\nexport type EventHandlerMap = { [RoomWidgetClientEvent.PendingEventsChanged]: () => void };\n/**\n * A MatrixClient that routes its requests through the widget API instead of the\n * real CS API.\n * @experimental This class is considered unstable!\n */\nexport class RoomWidgetClient extends MatrixClient {\n private room?: Room;\n private readonly widgetApiReady: Promise<void>;\n private lifecycle?: AbortController;\n private syncState: SyncState | null = null;\n\n private pendingSendingEventsTxId: { type: string; id: string | undefined; txId: string }[] = [];\n private eventEmitter = new TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap>();\n\n /**\n *\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param opts - The configuration options for this client.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\n public constructor(\n private readonly widgetApi: WidgetApi,\n private readonly capabilities: ICapabilities,\n private readonly roomId: string,\n opts: IMatrixClientCreateOpts,\n sendContentLoaded: boolean,\n ) {\n super(opts);\n\n const transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);\n this.widgetApi.transport.send = async <\n T extends IWidgetApiRequestData,\n R extends IWidgetApiResponseData = IWidgetApiAcknowledgeResponseData,\n >(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSend(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n const transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);\n this.widgetApi.transport.sendComplete = async <T extends IWidgetApiRequestData, R extends IWidgetApiResponse>(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSendComplete(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n this.widgetApiReady = new Promise<void>((resolve) => this.widgetApi.once(\"ready\", resolve));\n\n // Request capabilities for the functionality this client needs to support\n if (\n capabilities.sendEvent?.length ||\n capabilities.receiveEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.receiveMessage === true ||\n (Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length) ||\n capabilities.sendState?.length ||\n capabilities.receiveState?.length\n ) {\n widgetApi.requestCapabilityForRoomTimeline(roomId);\n }\n capabilities.sendEvent?.forEach((eventType) => widgetApi.requestCapabilityToSendEvent(eventType));\n capabilities.receiveEvent?.forEach((eventType) => widgetApi.requestCapabilityToReceiveEvent(eventType));\n if (capabilities.sendMessage === true) {\n widgetApi.requestCapabilityToSendMessage();\n } else if (Array.isArray(capabilities.sendMessage)) {\n capabilities.sendMessage.forEach((msgType) => widgetApi.requestCapabilityToSendMessage(msgType));\n }\n if (capabilities.receiveMessage === true) {\n widgetApi.requestCapabilityToReceiveMessage();\n } else if (Array.isArray(capabilities.receiveMessage)) {\n capabilities.receiveMessage.forEach((msgType) => widgetApi.requestCapabilityToReceiveMessage(msgType));\n }\n capabilities.sendState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToSendState(eventType, stateKey),\n );\n capabilities.receiveState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToReceiveState(eventType, stateKey),\n );\n capabilities.sendToDevice?.forEach((eventType) => widgetApi.requestCapabilityToSendToDevice(eventType));\n capabilities.receiveToDevice?.forEach((eventType) => widgetApi.requestCapabilityToReceiveToDevice(eventType));\n if (\n capabilities.sendDelayedEvents &&\n (capabilities.sendEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.sendState?.length)\n ) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);\n }\n if (capabilities.updateDelayedEvents) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157UpdateDelayedEvent);\n }\n if (capabilities.turnServers) {\n widgetApi.requestCapability(MatrixCapabilities.MSC3846TurnServers);\n }\n\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n\n // Open communication with the host\n widgetApi.start();\n // Send a content loaded event now we've started the widget API\n // Note that element-web currently does not use waitForIFrameLoad=false and so\n // does *not* (yes, that is the right way around) wait for this event. Let's\n // start sending this, then once this has rolled out, we can change element-web to\n // use waitForIFrameLoad=false and have a widget API that's less racy.\n if (sendContentLoaded) widgetApi.sendContentLoaded();\n }\n\n public async startClient(opts: IStartClientOpts = {}): Promise<void> {\n this.lifecycle = new AbortController();\n\n // Create our own user object artificially (instead of waiting for sync)\n // so it's always available, even if the user is not in any rooms etc.\n const userId = this.getUserId();\n if (userId) {\n this.store.storeUser(new User(userId));\n }\n\n // Even though we have no access token and cannot sync, the sync class\n // still has some valuable helper methods that we make use of, so we\n // instantiate it anyways\n if (opts.slidingSync) {\n this.syncApi = new SlidingSyncSdk(opts.slidingSync, this, opts);\n } else {\n this.syncApi = new SyncApi(this, opts, this.buildSyncApiOptions());\n }\n\n this.room = this.syncApi.createRoom(this.roomId);\n this.store.storeRoom(this.room);\n\n await this.widgetApiReady;\n\n // Backfill the requested events\n // We only get the most recent event for every type + state key combo,\n // so it doesn't really matter what order we inject them in\n await Promise.all(\n this.capabilities.receiveState?.map(async ({ eventType, stateKey }) => {\n const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]);\n const events = rawEvents.map((rawEvent) => new MatrixEvent(rawEvent as Partial<IEvent>));\n\n if (this.syncApi instanceof SyncApi) {\n // Passing undefined for `stateAfterEventList` allows will make `injectRoomEvents` run in legacy mode\n // -> state events in `timelineEventList` will update the state.\n await this.syncApi.injectRoomEvents(this.room!, undefined, events);\n } else {\n await this.syncApi!.injectRoomEvents(this.room!, events); // Sliding Sync\n }\n events.forEach((event) => {\n this.emit(ClientEvent.Event, event);\n logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);\n });\n }) ?? [],\n );\n\n if (opts.clientWellKnownPollPeriod !== undefined) {\n this.clientWellKnownIntervalID = setInterval(() => {\n this.fetchClientWellKnown();\n }, 1000 * opts.clientWellKnownPollPeriod);\n this.fetchClientWellKnown();\n }\n\n this.setSyncState(SyncState.Syncing);\n logger.info(\"Finished backfilling events\");\n }\n\n public stopClient(): void {\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n\n super.stopClient();\n this.lifecycle!.abort(); // Signal to other async tasks that the client has stopped\n }\n\n public async joinRoom(roomIdOrAlias: string): Promise<Room> {\n if (roomIdOrAlias === this.roomId) return this.room!;\n throw new Error(`Unknown room: ${roomIdOrAlias}`);\n }\n\n public async sendStateEvent(\n roomId: string,\n eventType: string,\n content: any,\n stateKey = \"\",\n ): Promise<ISendEventResponse> {\n const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);\n if (response.event_id === undefined) {\n throw new Error(\"'event_id' absent from response to an event request\");\n }\n return { event_id: response.event_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_sendDelayedStateEvent<K extends keyof StateEvents>(\n roomId: string,\n delayOpts: SendDelayedEventRequestOpts,\n eventType: K,\n content: StateEvents[K],\n stateKey = \"\",\n ): Promise<SendDelayedEventResponse> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n const response = await this.widgetApi.sendStateEvent(\n eventType,\n stateKey,\n content,\n roomId,\n \"delay\" in delayOpts ? delayOpts.delay : undefined,\n \"parent_delay_id\" in delayOpts ? delayOpts.parent_delay_id : undefined,\n );\n return this.validateSendDelayedEventResponse(response);\n }\n\n private validateSendDelayedEventResponse(response: ISendEventFromWidgetResponseData): SendDelayedEventResponse {\n if (response.delay_id === undefined) {\n throw new Error(\"'delay_id' absent from response to a delayed event request\");\n }\n return { delay_id: response.delay_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<{}> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n return await this.widgetApi.updateDelayedEvent(delayId, action);\n }\n\n public async sendToDevice(eventType: string, contentMap: SendToDeviceContentMap): Promise<{}> {\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n return {};\n }\n\n public async getOpenIdToken(): Promise<IOpenIDToken> {\n const token = await this.widgetApi.requestOpenIDConnectToken();\n // the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.\n // we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.\n return <IOpenIDToken>{\n access_token: token.access_token,\n expires_in: token.expires_in,\n matrix_server_name: token.matrix_server_name,\n token_type: token.token_type,\n };\n }\n\n public async queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void> {\n // map: user Id → device Id → payload\n const contentMap: MapWithDefault<string, Map<string, ToDevicePayload>> = new MapWithDefault(() => new Map());\n for (const { userId, deviceId, payload } of batch) {\n contentMap.getOrCreate(userId).set(deviceId, payload);\n }\n\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n }\n\n // Overridden since we 'sync' manually without the sync API\n public getSyncState(): SyncState | null {\n return this.syncState;\n }\n\n private setSyncState(state: SyncState): void {\n const oldState = this.syncState;\n this.syncState = state;\n this.emit(ClientEvent.Sync, state, oldState);\n }\n\n private async ack(ev: CustomEvent<IWidgetApiRequest>): Promise<void> {\n await this.widgetApi.transport.reply<IWidgetApiAcknowledgeResponseData>(ev.detail, {});\n }\n\n private updateTxId = async (event: MatrixEvent): Promise<void> => {\n // We update the txId for remote echos that originate from this client.\n // This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending\n // with their widget txId and once ready the final evId.\n if (\n // This could theoretically be an event send by this device\n // In that case we need to update the txId of the event because the embedded client/widget\n // knows this event with a different transaction Id than what was used by the host client.\n event.getSender() === this.getUserId() &&\n // We optimize by not blocking events from types that we have not send\n // with this client.\n this.pendingSendingEventsTxId.some((p) => event.getType() === p.type)\n ) {\n // Compare by event Id if we have a matching pending event where we know the txId.\n let matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n // Block any further processing of this event until we have received the sending response.\n // -> until we know the event id.\n // -> until we have not pending events anymore.\n while (!matchingTxId && this.pendingSendingEventsTxId.length > 0) {\n // Recheck whenever the PendingEventsChanged\n await new Promise<void>((resolve) =>\n this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()),\n );\n matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n }\n\n // We found the correct txId: we update the event and delete the entry of the pending events.\n if (matchingTxId) {\n event.setTxnId(matchingTxId);\n event.setUnsigned({ ...event.getUnsigned(), transaction_id: matchingTxId });\n }\n this.pendingSendingEventsTxId = this.pendingSendingEventsTxId.filter((p) => p.id !== event.getId());\n\n // Emit once there are no pending events anymore to release all other events that got\n // awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop\n // but are not send by this client.\n if (this.pendingSendingEventsTxId.length === 0) {\n this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);\n }\n }\n };\n\n private onEvent = async (ev: CustomEvent<ISendEventToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n // Verify the room ID matches, since it's possible for the client to\n // send us events from other rooms if this widget is always on screen\n if (ev.detail.data.room_id === this.roomId) {\n const event = new MatrixEvent(ev.detail.data as Partial<IEvent>);\n\n // Only inject once we have update the txId\n await this.updateTxId(event);\n \n // The widget API does not tell us whether a state event came from `state_after` or not so we assume legacy behaviour for now.\n if (this.syncApi instanceof SyncApi) {\n // The code will want to be something like:\n // ```\n // if (!params.addToTimeline && !params.addToState) {\n // // Passing undefined for `stateAfterEventList` makes `injectRoomEvents` run in \"legacy mode\"\n // // -> state events part of the `timelineEventList` parameter will update the state.\n // this.injectRoomEvents(this.room!, [], undefined, [event]);\n // } else {\n // this.injectRoomEvents(this.room!, undefined, params.addToState ? [event] : [], params.addToTimeline ? [event] : []);\n // }\n // ```\n\n // Passing undefined for `stateAfterEventList` allows will make `injectRoomEvents` run in legacy mode\n // -> state events in `timelineEventList` will update the state.\n await this.syncApi.injectRoomEvents(this.room!, [], undefined, [event]);\n } else {\n // The code will want to be something like:\n // ```\n // if (!params.addToTimeline && !params.addToState) {\n // this.injectRoomEvents(this.room!, [], [event]);\n // } else {\n // this.injectRoomEvents(this.room!, params.addToState ? [event] : [], params.addToTimeline ? [event] : []);\n // }\n // ```\n await this.syncApi!.injectRoomEvents(this.room!, [], [event]); // Sliding Sync\n }\n this.emit(ClientEvent.Event, event);\n this.setSyncState(SyncState.Syncing);\n logger.info(`Received event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);\n } else {\n const { event_id: eventId, room_id: roomId } = ev.detail.data;\n logger.info(`Received event ${eventId} for a different room ${roomId}; discarding`);\n }\n\n await this.ack(ev);\n };\n\n private onToDevice = async (ev: CustomEvent<ISendToDeviceToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n const event = new MatrixEvent({\n type: ev.detail.data.type,\n sender: ev.detail.data.sender,\n content: ev.detail.data.content as IContent,\n });\n\n this.emit(ClientEvent.ToDeviceEvent, event);\n this.setSyncState(SyncState.Syncing);\n await this.ack(ev);\n };\n}\n\nfunction processAndThrow(error: unknown): never {\n if (error instanceof WidgetApiResponseError && error.data.matrix_api_error) {\n throw MatrixError.fromWidgetApiErrorData(error.data.matrix_api_error);\n } else {\n throw error;\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEIA,uBAAuB,EACvBC,sBAAsB,EACtBC,kBAAkB,QAUf,mBAAmB;AAE1B,SAASC,WAAW,QAA0B,mBAAmB;AAQjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SACIC,YAAY,EACZC,WAAW,EAKXC,+BAA+B,QAC5B,aAAa;AACpB,SAASC,OAAO,EAAEC,SAAS,QAAQ,WAAW;AAC9C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,IAAI,QAAQ,kBAAkB;AAGvC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,YAAY;AACjE,SAASC,iBAAiB,QAAQ,aAAa;AAmE/C,WAAYC,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA;AAIjC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASZ,YAAY,CAAC;EAS/C;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACWa,WAAWA,CACGC,SAAoB,EACpBC,YAA2B,EAC3BC,MAAc,EAC/BC,IAA6B,EAC7BC,iBAA0B,EAC5B;IAAA,IAAAC,KAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAA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List":[]}
1
+ {"version":3,"file":"embedded.js","names":["WidgetApiToWidgetAction","WidgetApiResponseError","MatrixCapabilities","MatrixEvent","logger","MatrixClient","ClientEvent","UNSTABLE_MSC4140_DELAYED_EVENTS","SyncApi","SyncState","SlidingSyncSdk","MatrixError","User","MapWithDefault","recursiveMapToObject","TypedEventEmitter","RoomWidgetClientEvent","RoomWidgetClient","constructor","widgetApi","capabilities","roomId","opts","sendContentLoaded","_this","_capabilities$receive","_capabilities$sendEve","_capabilities$receive2","_capabilities$sendSta","_capabilities$receive3","_capabilities$sendEve2","_capabilities$receive4","_capabilities$sendSta2","_capabilities$receive5","_capabilities$sendToD","_capabilities$receive6","_capabilities$sendEve3","_capabilities$sendSta3","this","_defineProperty","_ref","_asyncToGenerator","event","getSender","getUserId","pendingSendingEventsTxId","some","p","getType","type","_this$pendingSendingE","matchingTxId","find","id","getId","txId","length","_this$pendingSendingE2","Promise","resolve","eventEmitter","once","PendingEventsChanged","setTxnId","setUnsigned","_objectSpread","getUnsigned","transaction_id","filter","emit","_x","apply","arguments","_ref2","ev","preventDefault","detail","data","room_id","updateTxId","syncApi","injectRoomEvents","room","undefined","Event","setSyncState","Syncing","info","concat","event_id","eventId","ack","_x2","_ref3","sender","content","ToDeviceEvent","_x3","_ref4","rawEvent","state","getStateKey","_x4","transportSend","transport","send","bind","_ref5","action","error","processAndThrow","_x5","_x6","transportSendComplete","sendComplete","_ref6","_x7","_x8","widgetApiReady","roomStateSynced","receiveState","UpdateState","sendEvent","receiveEvent","sendMessage","Array","isArray","receiveMessage","sendState","requestCapabilityForRoomTimeline","forEach","eventType","requestCapabilityToSendEvent","requestCapabilityToReceiveEvent","requestCapabilityToSendMessage","msgType","requestCapabilityToReceiveMessage","_ref7","stateKey","requestCapabilityToSendState","_ref8","requestCapabilityToReceiveState","sendToDevice","requestCapabilityToSendToDevice","receiveToDevice","requestCapabilityToReceiveToDevice","sendDelayedEvents","requestCapability","MSC4157SendDelayedEvent","updateDelayedEvents","MSC4157UpdateDelayedEvent","turnServers","MSC3846TurnServers","on","SendEvent","onEvent","SendToDevice","onToDevice","onStateUpdate","start","startClient","_arguments","_this2","lifecycle","AbortController","userId","store","storeUser","slidingSync","buildSyncApiOptions","createRoom","storeRoom","clientWellKnownPollPeriod","clientWellKnownIntervalID","setInterval","fetchClientWellKnown","stopClient","off","abort","joinRoom","roomIdOrAlias","_this3","Error","sendStateEvent","_arguments2","_this4","response","_unstable_sendDelayedStateEvent","delayOpts","_arguments3","_this5","doesServerSupportUnstableFeature","delay","parent_delay_id","validateSendDelayedEventResponse","delay_id","_unstable_updateDelayedEvent","delayId","_this6","updateDelayedEvent","contentMap","_this7","getOpenIdToken","_this8","token","requestOpenIDConnectToken","access_token","expires_in","matrix_server_name","token_type","queueToDevice","_ref9","_this9","batch","Map","deviceId","payload","getOrCreate","set","getSyncState","syncState","oldState","Sync","_this10","reply","matrix_api_error","fromWidgetApiErrorData"],"sources":["../src/embedded.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n WidgetApi,\n WidgetApiToWidgetAction,\n WidgetApiResponseError,\n MatrixCapabilities,\n IWidgetApiRequest,\n IWidgetApiAcknowledgeResponseData,\n ISendEventToWidgetActionRequest,\n ISendToDeviceToWidgetActionRequest,\n ISendEventFromWidgetResponseData,\n IWidgetApiRequestData,\n WidgetApiAction,\n IWidgetApiResponse,\n IWidgetApiResponseData,\n IUpdateStateToWidgetActionRequest,\n} from \"matrix-widget-api\";\n\nimport { MatrixEvent, IEvent, IContent } from \"./models/event.ts\";\nimport {\n ISendEventResponse,\n SendDelayedEventRequestOpts,\n SendDelayedEventResponse,\n UpdateDelayedEventAction,\n} from \"./@types/requests.ts\";\nimport { StateEvents } from \"./@types/event.ts\";\nimport { logger } from \"./logger.ts\";\nimport {\n MatrixClient,\n ClientEvent,\n ICreateClientOpts,\n IStartClientOpts,\n SendToDeviceContentMap,\n IOpenIDToken,\n UNSTABLE_MSC4140_DELAYED_EVENTS,\n} from \"./client.ts\";\nimport { SyncApi, SyncState } from \"./sync.ts\";\nimport { SlidingSyncSdk } from \"./sliding-sync-sdk.ts\";\nimport { MatrixError } from \"./http-api/errors.ts\";\nimport { User } from \"./models/user.ts\";\nimport { Room } from \"./models/room.ts\";\nimport { ToDeviceBatch, ToDevicePayload } from \"./models/ToDeviceMessage.ts\";\nimport { MapWithDefault, recursiveMapToObject } from \"./utils.ts\";\nimport { TypedEventEmitter } from \"./matrix.ts\";\n\ninterface IStateEventRequest {\n eventType: string;\n stateKey?: string;\n}\n\nexport interface ICapabilities {\n /**\n * Event types that this client expects to send.\n */\n sendEvent?: string[];\n /**\n * Event types that this client expects to receive.\n */\n receiveEvent?: string[];\n\n /**\n * Message types that this client expects to send, or true for all message\n * types.\n */\n sendMessage?: string[] | true;\n /**\n * Message types that this client expects to receive, or true for all\n * message types.\n */\n receiveMessage?: string[] | true;\n\n /**\n * Types of state events that this client expects to send.\n */\n sendState?: IStateEventRequest[];\n /**\n * Types of state events that this client expects to receive.\n */\n receiveState?: IStateEventRequest[];\n\n /**\n * To-device event types that this client expects to send.\n */\n sendToDevice?: string[];\n /**\n * To-device event types that this client expects to receive.\n */\n receiveToDevice?: string[];\n\n /**\n * Whether this client needs access to TURN servers.\n * @defaultValue false\n */\n turnServers?: boolean;\n\n /**\n * Whether this client needs to be able to send delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n sendDelayedEvents?: boolean;\n\n /**\n * Whether this client needs to be able to update delayed events.\n * @experimental Part of MSC4140 & MSC4157\n * @defaultValue false\n */\n updateDelayedEvents?: boolean;\n}\n\nexport enum RoomWidgetClientEvent {\n PendingEventsChanged = \"PendingEvent.pendingEventsChanged\",\n}\nexport type EventHandlerMap = { [RoomWidgetClientEvent.PendingEventsChanged]: () => void };\n/**\n * A MatrixClient that routes its requests through the widget API instead of the\n * real CS API.\n * @experimental This class is considered unstable!\n */\nexport class RoomWidgetClient extends MatrixClient {\n private room?: Room;\n private readonly widgetApiReady: Promise<void>;\n private readonly roomStateSynced: Promise<void>;\n private lifecycle?: AbortController;\n private syncState: SyncState | null = null;\n\n private pendingSendingEventsTxId: { type: string; id: string | undefined; txId: string }[] = [];\n private eventEmitter = new TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap>();\n\n /**\n *\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param opts - The configuration options for this client.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\n public constructor(\n private readonly widgetApi: WidgetApi,\n /*private readonly */capabilities: ICapabilities,\n private readonly roomId: string,\n opts: ICreateClientOpts,\n sendContentLoaded: boolean,\n ) {\n super(opts);\n\n const transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);\n this.widgetApi.transport.send = async <\n T extends IWidgetApiRequestData,\n R extends IWidgetApiResponseData = IWidgetApiAcknowledgeResponseData,\n >(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSend(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n const transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);\n this.widgetApi.transport.sendComplete = async <T extends IWidgetApiRequestData, R extends IWidgetApiResponse>(\n action: WidgetApiAction,\n data: T,\n ): Promise<R> => {\n try {\n return await transportSendComplete(action, data);\n } catch (error) {\n processAndThrow(error);\n }\n };\n\n this.widgetApiReady = new Promise<void>((resolve) => this.widgetApi.once(\"ready\", resolve));\n this.roomStateSynced = capabilities.receiveState?.length\n ? new Promise<void>((resolve) =>\n this.widgetApi.once(`action:${WidgetApiToWidgetAction.UpdateState}`, resolve),\n )\n : Promise.resolve();\n\n // Request capabilities for the functionality this client needs to support\n if (\n capabilities.sendEvent?.length ||\n capabilities.receiveEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.receiveMessage === true ||\n (Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length) ||\n capabilities.sendState?.length ||\n capabilities.receiveState?.length\n ) {\n widgetApi.requestCapabilityForRoomTimeline(roomId);\n }\n capabilities.sendEvent?.forEach((eventType) => widgetApi.requestCapabilityToSendEvent(eventType));\n capabilities.receiveEvent?.forEach((eventType) => widgetApi.requestCapabilityToReceiveEvent(eventType));\n if (capabilities.sendMessage === true) {\n widgetApi.requestCapabilityToSendMessage();\n } else if (Array.isArray(capabilities.sendMessage)) {\n capabilities.sendMessage.forEach((msgType) => widgetApi.requestCapabilityToSendMessage(msgType));\n }\n if (capabilities.receiveMessage === true) {\n widgetApi.requestCapabilityToReceiveMessage();\n } else if (Array.isArray(capabilities.receiveMessage)) {\n capabilities.receiveMessage.forEach((msgType) => widgetApi.requestCapabilityToReceiveMessage(msgType));\n }\n capabilities.sendState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToSendState(eventType, stateKey),\n );\n capabilities.receiveState?.forEach(({ eventType, stateKey }) =>\n widgetApi.requestCapabilityToReceiveState(eventType, stateKey),\n );\n capabilities.sendToDevice?.forEach((eventType) => widgetApi.requestCapabilityToSendToDevice(eventType));\n capabilities.receiveToDevice?.forEach((eventType) => widgetApi.requestCapabilityToReceiveToDevice(eventType));\n if (\n capabilities.sendDelayedEvents &&\n (capabilities.sendEvent?.length ||\n capabilities.sendMessage === true ||\n (Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length) ||\n capabilities.sendState?.length)\n ) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);\n }\n if (capabilities.updateDelayedEvents) {\n widgetApi.requestCapability(MatrixCapabilities.MSC4157UpdateDelayedEvent);\n }\n if (capabilities.turnServers) {\n widgetApi.requestCapability(MatrixCapabilities.MSC3846TurnServers);\n }\n\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n widgetApi.on(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n widgetApi.on(`action:${WidgetApiToWidgetAction.UpdateState}`, this.onStateUpdate);\n\n // Open communication with the host\n widgetApi.start();\n // Send a content loaded event now we've started the widget API\n // Note that element-web currently does not use waitForIFrameLoad=false and so\n // does *not* (yes, that is the right way around) wait for this event. Let's\n // start sending this, then once this has rolled out, we can change element-web to\n // use waitForIFrameLoad=false and have a widget API that's less racy.\n if (sendContentLoaded) widgetApi.sendContentLoaded();\n }\n\n public async startClient(opts: IStartClientOpts = {}): Promise<void> {\n this.lifecycle = new AbortController();\n\n // Create our own user object artificially (instead of waiting for sync)\n // so it's always available, even if the user is not in any rooms etc.\n const userId = this.getUserId();\n if (userId) {\n this.store.storeUser(new User(userId));\n }\n\n // Even though we have no access token and cannot sync, the sync class\n // still has some valuable helper methods that we make use of, so we\n // instantiate it anyways\n if (opts.slidingSync) {\n this.syncApi = new SlidingSyncSdk(opts.slidingSync, this, opts);\n } else {\n this.syncApi = new SyncApi(this, opts, this.buildSyncApiOptions());\n }\n\n this.room = this.syncApi.createRoom(this.roomId);\n this.store.storeRoom(this.room);\n\n await this.widgetApiReady;\n\n if (opts.clientWellKnownPollPeriod !== undefined) {\n this.clientWellKnownIntervalID = setInterval(() => {\n this.fetchClientWellKnown();\n }, 1000 * opts.clientWellKnownPollPeriod);\n this.fetchClientWellKnown();\n }\n\n await this.roomStateSynced;\n this.setSyncState(SyncState.Syncing);\n logger.info(\"Finished initial sync\");\n }\n\n public stopClient(): void {\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);\n this.widgetApi.off(`action:${WidgetApiToWidgetAction.UpdateState}`, this.onStateUpdate);\n\n super.stopClient();\n this.lifecycle!.abort(); // Signal to other async tasks that the client has stopped\n }\n\n public async joinRoom(roomIdOrAlias: string): Promise<Room> {\n if (roomIdOrAlias === this.roomId) return this.room!;\n throw new Error(`Unknown room: ${roomIdOrAlias}`);\n }\n\n public async sendStateEvent(\n roomId: string,\n eventType: string,\n content: any,\n stateKey = \"\",\n ): Promise<ISendEventResponse> {\n const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);\n if (response.event_id === undefined) {\n throw new Error(\"'event_id' absent from response to an event request\");\n }\n return { event_id: response.event_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_sendDelayedStateEvent<K extends keyof StateEvents>(\n roomId: string,\n delayOpts: SendDelayedEventRequestOpts,\n eventType: K,\n content: StateEvents[K],\n stateKey = \"\",\n ): Promise<SendDelayedEventResponse> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n const response = await this.widgetApi.sendStateEvent(\n eventType,\n stateKey,\n content,\n roomId,\n \"delay\" in delayOpts ? delayOpts.delay : undefined,\n \"parent_delay_id\" in delayOpts ? delayOpts.parent_delay_id : undefined,\n );\n return this.validateSendDelayedEventResponse(response);\n }\n\n private validateSendDelayedEventResponse(response: ISendEventFromWidgetResponseData): SendDelayedEventResponse {\n if (response.delay_id === undefined) {\n throw new Error(\"'delay_id' absent from response to a delayed event request\");\n }\n return { delay_id: response.delay_id };\n }\n\n /**\n * @experimental This currently relies on an unstable MSC (MSC4140).\n */\n // eslint-disable-next-line\n public async _unstable_updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<{}> {\n if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {\n throw Error(\"Server does not support the delayed events API\");\n }\n\n return await this.widgetApi.updateDelayedEvent(delayId, action);\n }\n\n public async sendToDevice(eventType: string, contentMap: SendToDeviceContentMap): Promise<{}> {\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n return {};\n }\n\n public async getOpenIdToken(): Promise<IOpenIDToken> {\n const token = await this.widgetApi.requestOpenIDConnectToken();\n // the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.\n // we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.\n return <IOpenIDToken>{\n access_token: token.access_token,\n expires_in: token.expires_in,\n matrix_server_name: token.matrix_server_name,\n token_type: token.token_type,\n };\n }\n\n public async queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void> {\n // map: user Id → device Id → payload\n const contentMap: MapWithDefault<string, Map<string, ToDevicePayload>> = new MapWithDefault(() => new Map());\n for (const { userId, deviceId, payload } of batch) {\n contentMap.getOrCreate(userId).set(deviceId, payload);\n }\n\n await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap));\n }\n\n // Overridden since we 'sync' manually without the sync API\n public getSyncState(): SyncState | null {\n return this.syncState;\n }\n\n private setSyncState(state: SyncState): void {\n const oldState = this.syncState;\n this.syncState = state;\n this.emit(ClientEvent.Sync, state, oldState);\n }\n\n private async ack(ev: CustomEvent<IWidgetApiRequest>): Promise<void> {\n await this.widgetApi.transport.reply<IWidgetApiAcknowledgeResponseData>(ev.detail, {});\n }\n\n private updateTxId = async (event: MatrixEvent): Promise<void> => {\n // We update the txId for remote echos that originate from this client.\n // This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending\n // with their widget txId and once ready the final evId.\n if (\n // This could theoretically be an event send by this device\n // In that case we need to update the txId of the event because the embedded client/widget\n // knows this event with a different transaction Id than what was used by the host client.\n event.getSender() === this.getUserId() &&\n // We optimize by not blocking events from types that we have not send\n // with this client.\n this.pendingSendingEventsTxId.some((p) => event.getType() === p.type)\n ) {\n // Compare by event Id if we have a matching pending event where we know the txId.\n let matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n // Block any further processing of this event until we have received the sending response.\n // -> until we know the event id.\n // -> until we have not pending events anymore.\n while (!matchingTxId && this.pendingSendingEventsTxId.length > 0) {\n // Recheck whenever the PendingEventsChanged\n await new Promise<void>((resolve) =>\n this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()),\n );\n matchingTxId = this.pendingSendingEventsTxId.find((p) => p.id === event.getId())?.txId;\n }\n\n // We found the correct txId: we update the event and delete the entry of the pending events.\n if (matchingTxId) {\n event.setTxnId(matchingTxId);\n event.setUnsigned({ ...event.getUnsigned(), transaction_id: matchingTxId });\n }\n this.pendingSendingEventsTxId = this.pendingSendingEventsTxId.filter((p) => p.id !== event.getId());\n\n // Emit once there are no pending events anymore to release all other events that got\n // awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop\n // but are not send by this client.\n if (this.pendingSendingEventsTxId.length === 0) {\n this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);\n }\n }\n };\n\n private onEvent = async (ev: CustomEvent<ISendEventToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n // Verify the room ID matches, since it's possible for the client to\n // send us events from other rooms if this widget is always on screen\n if (ev.detail.data.room_id === this.roomId) {\n const event = new MatrixEvent(ev.detail.data as Partial<IEvent>);\n\n // Only inject once we have update the txId\n await this.updateTxId(event);\n \n if (this.syncApi instanceof SyncApi) {\n await this.syncApi.injectRoomEvents(this.room!, undefined, [], [event]);\n } else {\n // Sliding Sync\n await this.syncApi!.injectRoomEvents(this.room!, [], [event]);\n }\n this.emit(ClientEvent.Event, event);\n this.setSyncState(SyncState.Syncing);\n logger.info(`Received event ${event.getId()} ${event.getType()}`);\n } else {\n const { event_id: eventId, room_id: roomId } = ev.detail.data;\n logger.info(`Received event ${eventId} for a different room ${roomId}; discarding`);\n }\n\n await this.ack(ev);\n };\n\n private onToDevice = async (ev: CustomEvent<ISendToDeviceToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n\n const event = new MatrixEvent({\n type: ev.detail.data.type,\n sender: ev.detail.data.sender,\n content: ev.detail.data.content as IContent,\n });\n\n this.emit(ClientEvent.ToDeviceEvent, event);\n this.setSyncState(SyncState.Syncing);\n await this.ack(ev);\n };\n\n private onStateUpdate = async (ev: CustomEvent<IUpdateStateToWidgetActionRequest>): Promise<void> => {\n ev.preventDefault();\n for (const rawEvent of ev.detail.data.state) {\n // Verify the room ID matches, since it's possible for the client to\n // send us state updates from other rooms if this widget is always\n // on screen\n if (rawEvent.room_id === this.roomId) {\n const event = new MatrixEvent(rawEvent as Partial<IEvent>);\n if (this.syncApi instanceof SyncApi) {\n await this.syncApi.injectRoomEvents(this.room!, undefined, [event]);\n } else {\n // Sliding Sync\n await this.syncApi!.injectRoomEvents(this.room!, [event]);\n }\n logger.info(`Updated state entry ${event.getType()} ${event.getStateKey()} to ${event.getId()}`);\n } else {\n const { event_id: eventId, room_id: roomId } = ev.detail.data;\n logger.info(`Received state entry ${eventId} for a different room ${roomId}; discarding`);\n }\n }\n await this.ack(ev);\n };\n}\n\nfunction processAndThrow(error: unknown): never {\n if (error instanceof WidgetApiResponseError && error.data.matrix_api_error) {\n throw MatrixError.fromWidgetApiErrorData(error.data.matrix_api_error);\n } else {\n throw error;\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEIA,uBAAuB,EACvBC,sBAAsB,EACtBC,kBAAkB,QAWf,mBAAmB;AAE1B,SAASC,WAAW,QAA0B,mBAAmB;AAQjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SACIC,YAAY,EACZC,WAAW,EAKXC,+BAA+B,QAC5B,aAAa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,wBAAwB;CAC9C;AAkCD,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAiB5G"}
1
+ {"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../src/feature.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,oBAAY,aAAa;IACrB,MAAM,IAAA;IACN,QAAQ,IAAA;IACR,WAAW,IAAA;CACd;AAED,oBAAY,OAAO;IACf,MAAM,WAAW;IACjB,yBAAyB,8BAA8B;IACvD;;OAEG;IACH,iBAAiB,sBAAsB;IACvC,uBAAuB,4BAA4B;IACnD,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;CAC9C;AAmCD,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAiB5G"}
package/lib/feature.js CHANGED
@@ -50,7 +50,8 @@ var featureSupportResolver = {
50
50
  unstablePrefixes: ["org.matrix.msc3391"]
51
51
  },
52
52
  [Feature.RelationsRecursion]: {
53
- unstablePrefixes: ["org.matrix.msc3981"]
53
+ unstablePrefixes: ["org.matrix.msc3981"],
54
+ matrixVersion: "v1.10"
54
55
  },
55
56
  [Feature.IntentionalMentions]: {
56
57
  unstablePrefixes: ["org.matrix.msc3952_intentional_mentions"],
@@ -1 +1 @@
1
- {"version":3,"file":"feature.js","names":["ServerSupport","Feature","featureSupportResolver","Thread","unstablePrefixes","matrixVersion","ThreadUnreadNotifications","LoginTokenRequest","RelationBasedRedactions","AccountDataDeletion","RelationsRecursion","IntentionalMentions","buildFeatureSupportMap","_x","_buildFeatureSupportMap","apply","arguments","_asyncToGenerator","versions","supportMap","Map","feature","supportCondition","Object","entries","_versions$versions$in","_versions$versions","_supportCondition$uns","_supportCondition$uns2","supportMatrixVersion","includes","supportUnstablePrefixes","every","unstablePrefix","_versions$unstable_fe","unstable_features","set","Stable","Unstable","Unsupported"],"sources":["../src/feature.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { IServerVersions } from \"./client.ts\";\n\nexport enum ServerSupport {\n Stable,\n Unstable,\n Unsupported,\n}\n\nexport enum Feature {\n Thread = \"Thread\",\n ThreadUnreadNotifications = \"ThreadUnreadNotifications\",\n /**\n * @deprecated this is now exposed as a capability not a feature\n */\n LoginTokenRequest = \"LoginTokenRequest\",\n RelationBasedRedactions = \"RelationBasedRedactions\",\n AccountDataDeletion = \"AccountDataDeletion\",\n RelationsRecursion = \"RelationsRecursion\",\n IntentionalMentions = \"IntentionalMentions\",\n}\n\ntype FeatureSupportCondition = {\n unstablePrefixes?: string[];\n matrixVersion?: string;\n};\n\nconst featureSupportResolver: Record<string, FeatureSupportCondition> = {\n [Feature.Thread]: {\n unstablePrefixes: [\"org.matrix.msc3440\"],\n matrixVersion: \"v1.3\",\n },\n [Feature.ThreadUnreadNotifications]: {\n unstablePrefixes: [\"org.matrix.msc3771\", \"org.matrix.msc3773\"],\n matrixVersion: \"v1.4\",\n },\n [Feature.LoginTokenRequest]: {\n unstablePrefixes: [\"org.matrix.msc3882\"],\n },\n [Feature.RelationBasedRedactions]: {\n unstablePrefixes: [\"org.matrix.msc3912\"],\n },\n [Feature.AccountDataDeletion]: {\n unstablePrefixes: [\"org.matrix.msc3391\"],\n },\n [Feature.RelationsRecursion]: {\n unstablePrefixes: [\"org.matrix.msc3981\"],\n },\n [Feature.IntentionalMentions]: {\n unstablePrefixes: [\"org.matrix.msc3952_intentional_mentions\"],\n matrixVersion: \"v1.7\",\n },\n};\n\nexport async function buildFeatureSupportMap(versions: IServerVersions): Promise<Map<Feature, ServerSupport>> {\n const supportMap = new Map<Feature, ServerSupport>();\n for (const [feature, supportCondition] of Object.entries(featureSupportResolver)) {\n const supportMatrixVersion = versions.versions?.includes(supportCondition.matrixVersion || \"\") ?? false;\n const supportUnstablePrefixes =\n supportCondition.unstablePrefixes?.every((unstablePrefix) => {\n return versions.unstable_features?.[unstablePrefix] === true;\n }) ?? false;\n if (supportMatrixVersion) {\n supportMap.set(feature as Feature, ServerSupport.Stable);\n } else if (supportUnstablePrefixes) {\n supportMap.set(feature as Feature, ServerSupport.Unstable);\n } else {\n supportMap.set(feature as Feature, ServerSupport.Unsupported);\n }\n }\n return supportMap;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAMzB,WAAYC,OAAO,0BAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;AAkBnB,IAAMC,sBAA+D,GAAG;EACpE,CAACD,OAAO,CAACE,MAAM,GAAG;IACdC,gBAAgB,EAAE,CAAC,oBAAoB,CAAC;IACxCC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACK,yBAAyB,GAAG;IACjCF,gBAAgB,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC9DC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACM,iBAAiB,GAAG;IACzBH,gBAAgB,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B,QAAQ,CAACiB,iBAAiB,cAAAD,qBAAA,uBAA1BA,qBAAA,CAA6BD,cAAc,CAAC,MAAK,IAAI;MAChE,CAAC,CAAC,cAAAN,qBAAA,cAAAA,qBAAA,GAAI,KAAK;MACf,IAAIE,oBAAoB,EAAE;QACtBV,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACqC,MAAM,CAAC;MAC5D,CAAC,MAAM,IAAIN,uBAAuB,EAAE;QAChCZ,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACsC,QAAQ,CAAC;MAC9D,CAAC,MAAM;QACHnB,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACuC,WAAW,CAAC;MACjE;IACJ;IACA,OAAOpB,UAAU;EACrB,CAAC;EAAA,OAAAL,uBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"feature.js","names":["ServerSupport","Feature","featureSupportResolver","Thread","unstablePrefixes","matrixVersion","ThreadUnreadNotifications","LoginTokenRequest","RelationBasedRedactions","AccountDataDeletion","RelationsRecursion","IntentionalMentions","buildFeatureSupportMap","_x","_buildFeatureSupportMap","apply","arguments","_asyncToGenerator","versions","supportMap","Map","feature","supportCondition","Object","entries","_versions$versions$in","_versions$versions","_supportCondition$uns","_supportCondition$uns2","supportMatrixVersion","includes","supportUnstablePrefixes","every","unstablePrefix","_versions$unstable_fe","unstable_features","set","Stable","Unstable","Unsupported"],"sources":["../src/feature.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { IServerVersions } from \"./client.ts\";\n\nexport enum ServerSupport {\n Stable,\n Unstable,\n Unsupported,\n}\n\nexport enum Feature {\n Thread = \"Thread\",\n ThreadUnreadNotifications = \"ThreadUnreadNotifications\",\n /**\n * @deprecated this is now exposed as a capability not a feature\n */\n LoginTokenRequest = \"LoginTokenRequest\",\n RelationBasedRedactions = \"RelationBasedRedactions\",\n AccountDataDeletion = \"AccountDataDeletion\",\n RelationsRecursion = \"RelationsRecursion\",\n IntentionalMentions = \"IntentionalMentions\",\n}\n\ntype FeatureSupportCondition = {\n unstablePrefixes?: string[];\n matrixVersion?: string;\n};\n\nconst featureSupportResolver: Record<string, FeatureSupportCondition> = {\n [Feature.Thread]: {\n unstablePrefixes: [\"org.matrix.msc3440\"],\n matrixVersion: \"v1.3\",\n },\n [Feature.ThreadUnreadNotifications]: {\n unstablePrefixes: [\"org.matrix.msc3771\", \"org.matrix.msc3773\"],\n matrixVersion: \"v1.4\",\n },\n [Feature.LoginTokenRequest]: {\n unstablePrefixes: [\"org.matrix.msc3882\"],\n },\n [Feature.RelationBasedRedactions]: {\n unstablePrefixes: [\"org.matrix.msc3912\"],\n },\n [Feature.AccountDataDeletion]: {\n unstablePrefixes: [\"org.matrix.msc3391\"],\n },\n [Feature.RelationsRecursion]: {\n unstablePrefixes: [\"org.matrix.msc3981\"],\n matrixVersion: \"v1.10\",\n },\n [Feature.IntentionalMentions]: {\n unstablePrefixes: [\"org.matrix.msc3952_intentional_mentions\"],\n matrixVersion: \"v1.7\",\n },\n};\n\nexport async function buildFeatureSupportMap(versions: IServerVersions): Promise<Map<Feature, ServerSupport>> {\n const supportMap = new Map<Feature, ServerSupport>();\n for (const [feature, supportCondition] of Object.entries(featureSupportResolver)) {\n const supportMatrixVersion = versions.versions?.includes(supportCondition.matrixVersion || \"\") ?? false;\n const supportUnstablePrefixes =\n supportCondition.unstablePrefixes?.every((unstablePrefix) => {\n return versions.unstable_features?.[unstablePrefix] === true;\n }) ?? false;\n if (supportMatrixVersion) {\n supportMap.set(feature as Feature, ServerSupport.Stable);\n } else if (supportUnstablePrefixes) {\n supportMap.set(feature as Feature, ServerSupport.Unstable);\n } else {\n supportMap.set(feature as Feature, ServerSupport.Unsupported);\n }\n }\n return supportMap;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAMzB,WAAYC,OAAO,0BAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;AAkBnB,IAAMC,sBAA+D,GAAG;EACpE,CAACD,OAAO,CAACE,MAAM,GAAG;IACdC,gBAAgB,EAAE,CAAC,oBAAoB,CAAC;IACxCC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACK,yBAAyB,GAAG;IACjCF,gBAAgB,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC9DC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACM,iBAAiB,GAAG;IACzBH,gBAAgB,EAAE,CAAC,oBAAoB;EAC3C,CAAC;EACD,CAACH,OAAO,CAACO,uBAAuB,GAAG;IAC/BJ,gBAAgB,EAAE,CAAC,oBAAoB;EAC3C,CAAC;EACD,CAACH,OAAO,CAACQ,mBAAmB,GAAG;IAC3BL,gBAAgB,EAAE,CAAC,oBAAoB;EAC3C,CAAC;EACD,CAACH,OAAO,CAACS,kBAAkB,GAAG;IAC1BN,gBAAgB,EAAE,CAAC,oBAAoB,CAAC;IACxCC,aAAa,EAAE;EACnB,CAAC;EACD,CAACJ,OAAO,CAACU,mBAAmB,GAAG;IAC3B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sC,QAAQ,CAAC;MAC9D,CAAC,MAAM;QACHnB,UAAU,CAACiB,GAAG,CAACf,OAAO,EAAarB,aAAa,CAACuC,WAAW,CAAC;MACjE;IACJ;IACA,OAAOpB,UAAU;EACrB,CAAC;EAAA,OAAAL,uBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
@@ -61,9 +61,9 @@ export declare class MatrixError extends HTTPError {
61
61
  static fromWidgetApiErrorData(data: IWidgetMatrixError): MatrixError;
62
62
  }
63
63
  /**
64
- * @returns The recommended delay in milliseconds to wait before retrying
65
- * the request that triggered {@link error}, or {@link defaultMs} if the
66
- * error was not due to rate-limiting or if no valid delay is recommended.
64
+ * @returns The recommended delay in milliseconds to wait before retrying the request.
65
+ * @param error - The error to check for a retry delay.
66
+ * @param defaultMs - The delay to use if the error was not due to rate-limiting or if no valid delay is recommended.
67
67
  */
68
68
  export declare function safeGetRetryAfterMs(error: unknown, defaultMs: number): number;
69
69
  /**
@@ -152,9 +152,9 @@ export class MatrixError extends HTTPError {
152
152
  }
153
153
 
154
154
  /**
155
- * @returns The recommended delay in milliseconds to wait before retrying
156
- * the request that triggered {@link error}, or {@link defaultMs} if the
157
- * error was not due to rate-limiting or if no valid delay is recommended.
155
+ * @returns The recommended delay in milliseconds to wait before retrying the request.
156
+ * @param error - The error to check for a retry delay.
157
+ * @param defaultMs - The delay to use if the error was not due to rate-limiting or if no valid delay is recommended.
158
158
  */
159
159
  export function safeGetRetryAfterMs(error, defaultMs) {
160
160
  if (!(error instanceof HTTPError) || !error.isRateLimitError()) {