@atlaskit/collab-provider 9.25.0 → 9.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.25.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#77613](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77613) [`ef8c5965e5a9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ef8c5965e5a9) - Add log for reconcile on recovery
8
+ - [#78402](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78402) [`f55cf26552c0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f55cf26552c0) - Remove old caching FF
9
+
10
+ ## 9.25.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [#77972](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77972) [`2d7c29863c8a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2d7c29863c8a) - Add FE FF catchupv2 for futher usages
15
+
3
16
  ## 9.25.0
4
17
 
5
18
  ### Minor Changes
@@ -67,15 +67,6 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
67
67
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getToken", function () {
68
68
  return _this.token;
69
69
  });
70
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setToken", function (value) {
71
- if (_this.config.cacheToken) {
72
- _this.token = value;
73
- }
74
- });
75
- // sets the token as undefined
76
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unsetToken", function () {
77
- return _this.setToken();
78
- });
79
70
  // Used to retrieve the x-token for API requests
80
71
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getChannelToken", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
81
72
  var _yield$_this$config$p;
@@ -117,11 +108,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
117
108
  _context.t2 = undefined;
118
109
  case 15:
119
110
  token = _context.t2;
120
- if (token) {
121
- _this.setToken(token);
122
- }
123
111
  return _context.abrupt("return", token);
124
- case 18:
112
+ case 17:
125
113
  case "end":
126
114
  return _context.stop();
127
115
  }
@@ -136,7 +124,6 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
136
124
  // See: https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/29905#comment-375308874
137
125
  usedCachedToken: !!_this.token
138
126
  });
139
- _this.unsetToken();
140
127
  });
141
128
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onConnectError", function (error) {
142
129
  var _this$analyticsHelper2, _this$analyticsHelper3, _message, _errorData$code;
@@ -155,12 +142,6 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
155
142
  var errorData = error.data;
156
143
  if (errorData) {
157
144
  var _this$socket;
158
- // We only want to refresh the token if only its invalid
159
- // @ts-expect-error we should be more explicit about which type of errors we expect here, so they always have a status
160
- if ([401, 403].includes(errorData.status)) {
161
- //nullify token so it is forced to generate new token on reconnect
162
- _this.unsetToken();
163
- }
164
145
  (_this$socket = _this.socket) === null || _this$socket === void 0 || _this$socket.close();
165
146
  }
166
147
  var connectionError = {
@@ -326,8 +307,6 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
326
307
  _this.emit('error', errorNotFound);
327
308
  return _context2.abrupt("return", {});
328
309
  case 39:
329
- //nullify token so it is forced to generate new token on reconnect
330
- _this.unsetToken();
331
310
  logger("Can't fetch the catchup", _context2.t16.message);
332
311
  errorCatchup = {
333
312
  message: 'Cannot fetch catchup from collab service',
@@ -338,7 +317,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
338
317
  };
339
318
  _this.emit('error', errorCatchup);
340
319
  throw _context2.t16;
341
- case 44:
320
+ case 43:
342
321
  case "end":
343
322
  return _context2.stop();
344
323
  }
@@ -498,10 +477,9 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
498
477
  var _this$config = this.config,
499
478
  documentAri = _this$config.documentAri,
500
479
  url = _this$config.url;
501
- var createSocket = this.config.createSocket;
502
480
  var _this$config2 = this.config,
503
- permissionTokenRefresh = _this$config2.permissionTokenRefresh,
504
- cacheToken = _this$config2.cacheToken;
481
+ createSocket = _this$config2.createSocket,
482
+ permissionTokenRefresh = _this$config2.permissionTokenRefresh;
505
483
  var auth;
506
484
  if (permissionTokenRefresh) {
507
485
  auth = /*#__PURE__*/function () {
@@ -516,35 +494,23 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
516
494
  initialized: _this2.initialized,
517
495
  // ESS-1009 Allow to opt-in into 404 response
518
496
  need404: _this2.config.need404
519
- }; // use the cached token if caching in enabled and token valid
520
- if (!(cacheToken && _this2.token)) {
521
- _context4.next = 6;
522
- break;
523
- }
524
- authData.token = _this2.token;
525
- cb(authData);
526
- _context4.next = 18;
527
- break;
528
- case 6:
529
- _context4.prev = 6;
530
- _context4.next = 9;
497
+ };
498
+ _context4.prev = 1;
499
+ _context4.next = 4;
531
500
  return permissionTokenRefresh();
532
- case 9:
501
+ case 4:
533
502
  token = _context4.sent;
534
503
  if (token) {
535
- // save token locally
536
- _this2.setToken(token);
537
504
  authData.token = token;
538
505
  } else {
539
- _this2.unsetToken();
540
506
  authData.token = undefined;
541
507
  }
542
508
  cb(authData);
543
- _context4.next = 18;
509
+ _context4.next = 13;
544
510
  break;
545
- case 14:
546
- _context4.prev = 14;
547
- _context4.t0 = _context4["catch"](6);
511
+ case 9:
512
+ _context4.prev = 9;
513
+ _context4.t0 = _context4["catch"](1);
548
514
  // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
549
515
  authenticationError = {
550
516
  message: 'Insufficient editing permissions',
@@ -560,11 +526,11 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
560
526
  };
561
527
 
562
528
  _this2.emit('error', authenticationError);
563
- case 18:
529
+ case 13:
564
530
  case "end":
565
531
  return _context4.stop();
566
532
  }
567
- }, _callee4, null, [[6, 14]]);
533
+ }, _callee4, null, [[1, 9]]);
568
534
  }));
569
535
  return function auth(_x4) {
570
536
  return _ref4.apply(this, arguments);
@@ -793,8 +759,6 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
793
759
  this.unsubscribeAll();
794
760
  (_this$network = this.network) === null || _this$network === void 0 || _this$network.destroy();
795
761
  this.network = null;
796
- //nullify token so it is forced to generate new token on reconnect
797
- this.unsetToken();
798
762
  if (this.socket) {
799
763
  var _this$reconnectHelper3;
800
764
  this.socket.close();
@@ -244,7 +244,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
244
244
  // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
245
245
  (0, _defineProperty2.default)(this, "onRestore", /*#__PURE__*/function () {
246
246
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref4) {
247
- var doc, version, metadata, unconfirmedSteps, currentState, _this$analyticsHelper11, _this$analyticsHelper12, _this$analyticsHelper13;
247
+ var doc, version, metadata, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper11, _this$analyticsHelper12, _this$analyticsHelper13;
248
248
  return _regenerator.default.wrap(function _callee3$(_context3) {
249
249
  while (1) switch (_context3.prev = _context3.next) {
250
250
  case 0:
@@ -261,7 +261,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
261
261
  case 5:
262
262
  currentState = _context3.sent;
263
263
  case 6:
264
- _context3.prev = 6;
264
+ useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && _this.reconcileOnRecovery && currentState);
265
+ _context3.prev = 7;
265
266
  // Reset the editor,
266
267
  // - Replace the document, keep in sync with the server
267
268
  // - Replace the version number, so editor is in sync with NCS server and can commit new changes.
@@ -277,31 +278,33 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
277
278
  _this.metadataService.updateMetadata(metadata);
278
279
 
279
280
  // If there are unconfirmed steps, attempt to reconcile our current state with with recovered document
280
- if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length && _this.reconcileOnRecovery && currentState)) {
281
- _context3.next = 14;
281
+ if (!(useReconcile && currentState)) {
282
+ _context3.next = 15;
282
283
  break;
283
284
  }
284
- _context3.next = 12;
285
+ _context3.next = 13;
285
286
  return _this.fetchReconcile(JSON.stringify(currentState.content));
286
- case 12:
287
- _context3.next = 15;
287
+ case 13:
288
+ _context3.next = 16;
288
289
  break;
289
- case 14:
290
+ case 15:
290
291
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
291
292
  _this.applyLocalSteps(unconfirmedSteps);
292
293
  }
293
- case 15:
294
+ case 16:
294
295
  (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
295
296
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
296
- hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title)
297
+ hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
298
+ useReconcile: useReconcile
297
299
  });
298
- _context3.next = 23;
300
+ _context3.next = 24;
299
301
  break;
300
- case 18:
301
- _context3.prev = 18;
302
- _context3.t0 = _context3["catch"](6);
302
+ case 19:
303
+ _context3.prev = 19;
304
+ _context3.t0 = _context3["catch"](7);
303
305
  (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
304
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
306
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
307
+ useReconcile: useReconcile
305
308
  });
306
309
  (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, 'Error while reinitialising document');
307
310
  _this.onErrorHandled({
@@ -312,11 +315,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
312
315
  code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
313
316
  }
314
317
  });
315
- case 23:
318
+ case 24:
316
319
  case "end":
317
320
  return _context3.stop();
318
321
  }
319
- }, _callee3, null, [[6, 18]]);
322
+ }, _callee3, null, [[7, 19]]);
320
323
  }));
321
324
  return function (_x) {
322
325
  return _ref5.apply(this, arguments);
@@ -11,7 +11,8 @@ var defaultNCSFeatureFlags = {
11
11
  testFF: false,
12
12
  blockViewOnly: false,
13
13
  reconcileOnRecovery: false,
14
- connectWebsocketFirst: false
14
+ connectWebsocketFirst: false,
15
+ catchupv2: false
15
16
  };
16
17
 
17
18
  /**
@@ -22,7 +23,8 @@ var productKeys = {
22
23
  testFF: 'confluence.frontend.collab.provider.testFF',
23
24
  blockViewOnly: 'confluence.frontend.ncs.block-view-only',
24
25
  reconcileOnRecovery: 'confluence.frontend.ncs.reconcile-on-recovery',
25
- connectWebsocketFirst: 'confluence.frontend.ncs.connect-websocket-first'
26
+ connectWebsocketFirst: 'confluence.frontend.ncs.connect-websocket-first',
27
+ catchupv2: 'confluence.frontend.ncs.catchupv2'
26
28
  }
27
29
  };
28
30
  var filterFeatureFlagNames = function filterFeatureFlagNames(flags) {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "9.25.0";
8
+ var version = exports.version = "9.25.2";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -33,13 +33,6 @@ export class Channel extends Emitter {
33
33
  _defineProperty(this, "getConnected", () => this.connected);
34
34
  _defineProperty(this, "getSocket", () => this.socket);
35
35
  _defineProperty(this, "getToken", () => this.token);
36
- _defineProperty(this, "setToken", value => {
37
- if (this.config.cacheToken) {
38
- this.token = value;
39
- }
40
- });
41
- // sets the token as undefined
42
- _defineProperty(this, "unsetToken", () => this.setToken());
43
36
  // Used to retrieve the x-token for API requests
44
37
  _defineProperty(this, "getChannelToken", async () => {
45
38
  var _await$this$config$pe;
@@ -50,9 +43,6 @@ export class Channel extends Emitter {
50
43
  return undefined;
51
44
  }
52
45
  const token = (_await$this$config$pe = await this.config.permissionTokenRefresh()) !== null && _await$this$config$pe !== void 0 ? _await$this$config$pe : undefined;
53
- if (token) {
54
- this.setToken(token);
55
- }
56
46
  return token;
57
47
  });
58
48
  _defineProperty(this, "handlePermissionInvalidateToken", data => {
@@ -64,7 +54,6 @@ export class Channel extends Emitter {
64
54
  // See: https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/29905#comment-375308874
65
55
  usedCachedToken: !!this.token
66
56
  });
67
- this.unsetToken();
68
57
  });
69
58
  _defineProperty(this, "onConnectError", error => {
70
59
  var _this$analyticsHelper2, _this$analyticsHelper3, _message, _errorData$code;
@@ -83,12 +72,6 @@ export class Channel extends Emitter {
83
72
  const errorData = error.data;
84
73
  if (errorData) {
85
74
  var _this$socket;
86
- // We only want to refresh the token if only its invalid
87
- // @ts-expect-error we should be more explicit about which type of errors we expect here, so they always have a status
88
- if ([401, 403].includes(errorData.status)) {
89
- //nullify token so it is forced to generate new token on reconnect
90
- this.unsetToken();
91
- }
92
75
  (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
93
76
  }
94
77
  const connectionError = {
@@ -220,9 +203,6 @@ export class Channel extends Emitter {
220
203
  this.emit('error', errorNotFound);
221
204
  return {};
222
205
  }
223
-
224
- //nullify token so it is forced to generate new token on reconnect
225
- this.unsetToken();
226
206
  logger("Can't fetch the catchup", error.message);
227
207
  const errorCatchup = {
228
208
  message: 'Cannot fetch catchup from collab service',
@@ -339,11 +319,8 @@ export class Channel extends Emitter {
339
319
  url
340
320
  } = this.config;
341
321
  const {
342
- createSocket
343
- } = this.config;
344
- const {
345
- permissionTokenRefresh,
346
- cacheToken
322
+ createSocket,
323
+ permissionTokenRefresh
347
324
  } = this.config;
348
325
  let auth;
349
326
  if (permissionTokenRefresh) {
@@ -355,40 +332,31 @@ export class Channel extends Emitter {
355
332
  // ESS-1009 Allow to opt-in into 404 response
356
333
  need404: this.config.need404
357
334
  };
358
- // use the cached token if caching in enabled and token valid
359
- if (cacheToken && this.token) {
360
- authData.token = this.token;
335
+ try {
336
+ const token = await permissionTokenRefresh();
337
+ if (token) {
338
+ authData.token = token;
339
+ } else {
340
+ authData.token = undefined;
341
+ }
361
342
  cb(authData);
362
- } else {
363
- try {
364
- const token = await permissionTokenRefresh();
365
- if (token) {
366
- // save token locally
367
- this.setToken(token);
368
- authData.token = token;
369
- } else {
370
- this.unsetToken();
371
- authData.token = undefined;
372
- }
373
- cb(authData);
374
- } catch (error) {
375
- var _data, _data$meta;
376
- // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
377
- const authenticationError = {
378
- message: 'Insufficient editing permissions',
379
- data: {
380
- status: 403,
381
- code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
382
- meta: {
383
- originalError: error,
384
- reason: error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$meta = _data.meta) === null || _data$meta === void 0 ? void 0 : _data$meta.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
385
- // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
386
- }
343
+ } catch (error) {
344
+ var _data, _data$meta;
345
+ // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
346
+ const authenticationError = {
347
+ message: 'Insufficient editing permissions',
348
+ data: {
349
+ status: 403,
350
+ code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
351
+ meta: {
352
+ originalError: error,
353
+ reason: error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$meta = _data.meta) === null || _data$meta === void 0 ? void 0 : _data$meta.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
354
+ // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
387
355
  }
388
- };
356
+ }
357
+ };
389
358
 
390
- this.emit('error', authenticationError);
391
- }
359
+ this.emit('error', authenticationError);
392
360
  }
393
361
  };
394
362
  } else {
@@ -562,8 +530,6 @@ export class Channel extends Emitter {
562
530
  this.unsubscribeAll();
563
531
  (_this$network = this.network) === null || _this$network === void 0 ? void 0 : _this$network.destroy();
564
532
  this.network = null;
565
- //nullify token so it is forced to generate new token on reconnect
566
- this.unsetToken();
567
533
  if (this.socket) {
568
534
  var _this$reconnectHelper3;
569
535
  this.socket.close();
@@ -210,6 +210,7 @@ export class DocumentService {
210
210
  if (this.reconcileOnRecovery) {
211
211
  currentState = await this.getCurrentState();
212
212
  }
213
+ const useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && this.reconcileOnRecovery && currentState);
213
214
  try {
214
215
  var _this$analyticsHelper11;
215
216
  // Reset the editor,
@@ -227,19 +228,21 @@ export class DocumentService {
227
228
  this.metadataService.updateMetadata(metadata);
228
229
 
229
230
  // If there are unconfirmed steps, attempt to reconcile our current state with with recovered document
230
- if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length && this.reconcileOnRecovery && currentState) {
231
+ if (useReconcile && currentState) {
231
232
  await this.fetchReconcile(JSON.stringify(currentState.content));
232
233
  } else if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
233
234
  this.applyLocalSteps(unconfirmedSteps);
234
235
  }
235
236
  (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
236
237
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
237
- hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title)
238
+ hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
239
+ useReconcile
238
240
  });
239
241
  } catch (restoreError) {
240
242
  var _this$analyticsHelper12, _this$analyticsHelper13;
241
243
  (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
242
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
244
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
245
+ useReconcile
243
246
  });
244
247
  (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(restoreError, 'Error while reinitialising document');
245
248
  this.onErrorHandled({
@@ -2,7 +2,8 @@ const defaultNCSFeatureFlags = {
2
2
  testFF: false,
3
3
  blockViewOnly: false,
4
4
  reconcileOnRecovery: false,
5
- connectWebsocketFirst: false
5
+ connectWebsocketFirst: false,
6
+ catchupv2: false
6
7
  };
7
8
 
8
9
  /**
@@ -13,7 +14,8 @@ const productKeys = {
13
14
  testFF: 'confluence.frontend.collab.provider.testFF',
14
15
  blockViewOnly: 'confluence.frontend.ncs.block-view-only',
15
16
  reconcileOnRecovery: 'confluence.frontend.ncs.reconcile-on-recovery',
16
- connectWebsocketFirst: 'confluence.frontend.ncs.connect-websocket-first'
17
+ connectWebsocketFirst: 'confluence.frontend.ncs.connect-websocket-first',
18
+ catchupv2: 'confluence.frontend.ncs.catchupv2'
17
19
  }
18
20
  };
19
21
  const filterFeatureFlagNames = flags => {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.25.0";
2
+ export const version = "9.25.2";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -60,15 +60,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
60
60
  _defineProperty(_assertThisInitialized(_this), "getToken", function () {
61
61
  return _this.token;
62
62
  });
63
- _defineProperty(_assertThisInitialized(_this), "setToken", function (value) {
64
- if (_this.config.cacheToken) {
65
- _this.token = value;
66
- }
67
- });
68
- // sets the token as undefined
69
- _defineProperty(_assertThisInitialized(_this), "unsetToken", function () {
70
- return _this.setToken();
71
- });
72
63
  // Used to retrieve the x-token for API requests
73
64
  _defineProperty(_assertThisInitialized(_this), "getChannelToken", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
74
65
  var _yield$_this$config$p;
@@ -110,11 +101,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
110
101
  _context.t2 = undefined;
111
102
  case 15:
112
103
  token = _context.t2;
113
- if (token) {
114
- _this.setToken(token);
115
- }
116
104
  return _context.abrupt("return", token);
117
- case 18:
105
+ case 17:
118
106
  case "end":
119
107
  return _context.stop();
120
108
  }
@@ -129,7 +117,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
129
117
  // See: https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/29905#comment-375308874
130
118
  usedCachedToken: !!_this.token
131
119
  });
132
- _this.unsetToken();
133
120
  });
134
121
  _defineProperty(_assertThisInitialized(_this), "onConnectError", function (error) {
135
122
  var _this$analyticsHelper2, _this$analyticsHelper3, _message, _errorData$code;
@@ -148,12 +135,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
148
135
  var errorData = error.data;
149
136
  if (errorData) {
150
137
  var _this$socket;
151
- // We only want to refresh the token if only its invalid
152
- // @ts-expect-error we should be more explicit about which type of errors we expect here, so they always have a status
153
- if ([401, 403].includes(errorData.status)) {
154
- //nullify token so it is forced to generate new token on reconnect
155
- _this.unsetToken();
156
- }
157
138
  (_this$socket = _this.socket) === null || _this$socket === void 0 || _this$socket.close();
158
139
  }
159
140
  var connectionError = {
@@ -319,8 +300,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
319
300
  _this.emit('error', errorNotFound);
320
301
  return _context2.abrupt("return", {});
321
302
  case 39:
322
- //nullify token so it is forced to generate new token on reconnect
323
- _this.unsetToken();
324
303
  logger("Can't fetch the catchup", _context2.t16.message);
325
304
  errorCatchup = {
326
305
  message: 'Cannot fetch catchup from collab service',
@@ -331,7 +310,7 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
331
310
  };
332
311
  _this.emit('error', errorCatchup);
333
312
  throw _context2.t16;
334
- case 44:
313
+ case 43:
335
314
  case "end":
336
315
  return _context2.stop();
337
316
  }
@@ -491,10 +470,9 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
491
470
  var _this$config = this.config,
492
471
  documentAri = _this$config.documentAri,
493
472
  url = _this$config.url;
494
- var createSocket = this.config.createSocket;
495
473
  var _this$config2 = this.config,
496
- permissionTokenRefresh = _this$config2.permissionTokenRefresh,
497
- cacheToken = _this$config2.cacheToken;
474
+ createSocket = _this$config2.createSocket,
475
+ permissionTokenRefresh = _this$config2.permissionTokenRefresh;
498
476
  var auth;
499
477
  if (permissionTokenRefresh) {
500
478
  auth = /*#__PURE__*/function () {
@@ -509,35 +487,23 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
509
487
  initialized: _this2.initialized,
510
488
  // ESS-1009 Allow to opt-in into 404 response
511
489
  need404: _this2.config.need404
512
- }; // use the cached token if caching in enabled and token valid
513
- if (!(cacheToken && _this2.token)) {
514
- _context4.next = 6;
515
- break;
516
- }
517
- authData.token = _this2.token;
518
- cb(authData);
519
- _context4.next = 18;
520
- break;
521
- case 6:
522
- _context4.prev = 6;
523
- _context4.next = 9;
490
+ };
491
+ _context4.prev = 1;
492
+ _context4.next = 4;
524
493
  return permissionTokenRefresh();
525
- case 9:
494
+ case 4:
526
495
  token = _context4.sent;
527
496
  if (token) {
528
- // save token locally
529
- _this2.setToken(token);
530
497
  authData.token = token;
531
498
  } else {
532
- _this2.unsetToken();
533
499
  authData.token = undefined;
534
500
  }
535
501
  cb(authData);
536
- _context4.next = 18;
502
+ _context4.next = 13;
537
503
  break;
538
- case 14:
539
- _context4.prev = 14;
540
- _context4.t0 = _context4["catch"](6);
504
+ case 9:
505
+ _context4.prev = 9;
506
+ _context4.t0 = _context4["catch"](1);
541
507
  // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
542
508
  authenticationError = {
543
509
  message: 'Insufficient editing permissions',
@@ -553,11 +519,11 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
553
519
  };
554
520
 
555
521
  _this2.emit('error', authenticationError);
556
- case 18:
522
+ case 13:
557
523
  case "end":
558
524
  return _context4.stop();
559
525
  }
560
- }, _callee4, null, [[6, 14]]);
526
+ }, _callee4, null, [[1, 9]]);
561
527
  }));
562
528
  return function auth(_x4) {
563
529
  return _ref4.apply(this, arguments);
@@ -786,8 +752,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
786
752
  this.unsubscribeAll();
787
753
  (_this$network = this.network) === null || _this$network === void 0 || _this$network.destroy();
788
754
  this.network = null;
789
- //nullify token so it is forced to generate new token on reconnect
790
- this.unsetToken();
791
755
  if (this.socket) {
792
756
  var _this$reconnectHelper3;
793
757
  this.socket.close();
@@ -237,7 +237,7 @@ export var DocumentService = /*#__PURE__*/function () {
237
237
  // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
238
238
  _defineProperty(this, "onRestore", /*#__PURE__*/function () {
239
239
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
240
- var doc, version, metadata, unconfirmedSteps, currentState, _this$analyticsHelper11, _this$analyticsHelper12, _this$analyticsHelper13;
240
+ var doc, version, metadata, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper11, _this$analyticsHelper12, _this$analyticsHelper13;
241
241
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
242
242
  while (1) switch (_context3.prev = _context3.next) {
243
243
  case 0:
@@ -254,7 +254,8 @@ export var DocumentService = /*#__PURE__*/function () {
254
254
  case 5:
255
255
  currentState = _context3.sent;
256
256
  case 6:
257
- _context3.prev = 6;
257
+ useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && _this.reconcileOnRecovery && currentState);
258
+ _context3.prev = 7;
258
259
  // Reset the editor,
259
260
  // - Replace the document, keep in sync with the server
260
261
  // - Replace the version number, so editor is in sync with NCS server and can commit new changes.
@@ -270,31 +271,33 @@ export var DocumentService = /*#__PURE__*/function () {
270
271
  _this.metadataService.updateMetadata(metadata);
271
272
 
272
273
  // If there are unconfirmed steps, attempt to reconcile our current state with with recovered document
273
- if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length && _this.reconcileOnRecovery && currentState)) {
274
- _context3.next = 14;
274
+ if (!(useReconcile && currentState)) {
275
+ _context3.next = 15;
275
276
  break;
276
277
  }
277
- _context3.next = 12;
278
+ _context3.next = 13;
278
279
  return _this.fetchReconcile(JSON.stringify(currentState.content));
279
- case 12:
280
- _context3.next = 15;
280
+ case 13:
281
+ _context3.next = 16;
281
282
  break;
282
- case 14:
283
+ case 15:
283
284
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
284
285
  _this.applyLocalSteps(unconfirmedSteps);
285
286
  }
286
- case 15:
287
+ case 16:
287
288
  (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
288
289
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
289
- hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title)
290
+ hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
291
+ useReconcile: useReconcile
290
292
  });
291
- _context3.next = 23;
293
+ _context3.next = 24;
292
294
  break;
293
- case 18:
294
- _context3.prev = 18;
295
- _context3.t0 = _context3["catch"](6);
295
+ case 19:
296
+ _context3.prev = 19;
297
+ _context3.t0 = _context3["catch"](7);
296
298
  (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
297
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
299
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
300
+ useReconcile: useReconcile
298
301
  });
299
302
  (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, 'Error while reinitialising document');
300
303
  _this.onErrorHandled({
@@ -305,11 +308,11 @@ export var DocumentService = /*#__PURE__*/function () {
305
308
  code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
306
309
  }
307
310
  });
308
- case 23:
311
+ case 24:
309
312
  case "end":
310
313
  return _context3.stop();
311
314
  }
312
- }, _callee3, null, [[6, 18]]);
315
+ }, _callee3, null, [[7, 19]]);
313
316
  }));
314
317
  return function (_x) {
315
318
  return _ref5.apply(this, arguments);
@@ -3,7 +3,8 @@ var defaultNCSFeatureFlags = {
3
3
  testFF: false,
4
4
  blockViewOnly: false,
5
5
  reconcileOnRecovery: false,
6
- connectWebsocketFirst: false
6
+ connectWebsocketFirst: false,
7
+ catchupv2: false
7
8
  };
8
9
 
9
10
  /**
@@ -14,7 +15,8 @@ var productKeys = {
14
15
  testFF: 'confluence.frontend.collab.provider.testFF',
15
16
  blockViewOnly: 'confluence.frontend.ncs.block-view-only',
16
17
  reconcileOnRecovery: 'confluence.frontend.ncs.reconcile-on-recovery',
17
- connectWebsocketFirst: 'confluence.frontend.ncs.connect-websocket-first'
18
+ connectWebsocketFirst: 'confluence.frontend.ncs.connect-websocket-first',
19
+ catchupv2: 'confluence.frontend.ncs.catchupv2'
18
20
  }
19
21
  };
20
22
  var filterFeatureFlagNames = function filterFeatureFlagNames(flags) {
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "9.25.0";
2
+ export var version = "9.25.2";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -26,8 +26,6 @@ export declare class Channel extends Emitter<ChannelEvent> {
26
26
  getConnected: () => boolean;
27
27
  getSocket: () => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null;
28
28
  getToken: () => string | undefined;
29
- private setToken;
30
- private unsetToken;
31
29
  getChannelToken: () => Promise<string | undefined>;
32
30
  /**
33
31
  * Connect to collab service using websockets
@@ -3,6 +3,7 @@ export interface NCSFeatureFlags {
3
3
  blockViewOnly?: boolean;
4
4
  reconcileOnRecovery?: boolean;
5
5
  connectWebsocketFirst?: boolean;
6
+ catchupv2?: boolean;
6
7
  }
7
8
  export interface WithNCSFeatureFlags {
8
9
  featureFlags?: NCSFeatureFlags;
@@ -41,7 +41,6 @@ export interface Config {
41
41
  * If provided, permissionTokenRefresh is called whenever a new JWT token is required.
42
42
  */
43
43
  permissionTokenRefresh?: () => Promise<string | null>;
44
- cacheToken?: boolean;
45
44
  productInfo?: ProductInformation;
46
45
  /**
47
46
  * Throws errors when trying to send data to collab but the client is not offline.
@@ -26,8 +26,6 @@ export declare class Channel extends Emitter<ChannelEvent> {
26
26
  getConnected: () => boolean;
27
27
  getSocket: () => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null;
28
28
  getToken: () => string | undefined;
29
- private setToken;
30
- private unsetToken;
31
29
  getChannelToken: () => Promise<string | undefined>;
32
30
  /**
33
31
  * Connect to collab service using websockets
@@ -3,6 +3,7 @@ export interface NCSFeatureFlags {
3
3
  blockViewOnly?: boolean;
4
4
  reconcileOnRecovery?: boolean;
5
5
  connectWebsocketFirst?: boolean;
6
+ catchupv2?: boolean;
6
7
  }
7
8
  export interface WithNCSFeatureFlags {
8
9
  featureFlags?: NCSFeatureFlags;
@@ -41,7 +41,6 @@ export interface Config {
41
41
  * If provided, permissionTokenRefresh is called whenever a new JWT token is required.
42
42
  */
43
43
  permissionTokenRefresh?: () => Promise<string | null>;
44
- cacheToken?: boolean;
45
44
  productInfo?: ProductInformation;
46
45
  /**
47
46
  * Throws errors when trying to send data to collab but the client is not offline.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.25.0",
3
+ "version": "9.25.2",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@atlaskit/analytics-gas-types": "^5.1.0",
41
41
  "@atlaskit/analytics-listeners": "^8.9.0",
42
- "@atlaskit/editor-common": "^78.4.0",
42
+ "@atlaskit/editor-common": "^78.9.0",
43
43
  "@atlaskit/editor-json-transformer": "^8.10.0",
44
44
  "@atlaskit/editor-prosemirror": "3.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.2.0",
@@ -77,4 +77,4 @@
77
77
  "type": "boolean"
78
78
  }
79
79
  }
80
- }
80
+ }