@firebase/messaging 0.9.13 → 0.9.14-canary.8e952e2ee

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
  # @firebase/messaging
2
2
 
3
+ ## 0.9.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2cd1cc76f`](https://github.com/firebase/firebase-js-sdk/commit/2cd1cc76f2a308135cd60f424fe09084a34b5cb5) [#6307](https://github.com/firebase/firebase-js-sdk/pull/6307) (fixes [#6300](https://github.com/firebase/firebase-js-sdk/issues/6300)) - fix: add type declarations to exports field
8
+
9
+ * [`c66d59c3d`](https://github.com/firebase/firebase-js-sdk/commit/c66d59c3dcfea71bcdb61715f59911dd8a18d717) [#6327](https://github.com/firebase/firebase-js-sdk/pull/6327) (fixes [#6207](https://github.com/firebase/firebase-js-sdk/issues/6207)) - Fix missing FcmOptions.link
10
+
11
+ * Updated dependencies [[`2cd1cc76f`](https://github.com/firebase/firebase-js-sdk/commit/2cd1cc76f2a308135cd60f424fe09084a34b5cb5)]:
12
+ - @firebase/component@0.5.15
13
+ - @firebase/installations@0.5.10
14
+ - @firebase/util@1.6.1
15
+
3
16
  ## 0.9.13
4
17
 
5
18
  ### Patch Changes
@@ -430,33 +430,34 @@ var ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
430
430
  * limitations under the License.
431
431
  */
432
432
  function requestGetToken(firebaseDependencies, subscriptionOptions) {
433
+ var _a;
433
434
  return __awaiter(this, void 0, void 0, function () {
434
435
  var headers, body, subscribeOptions, responseData, response, err_1, message;
435
- return __generator(this, function (_a) {
436
- switch (_a.label) {
436
+ return __generator(this, function (_b) {
437
+ switch (_b.label) {
437
438
  case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];
438
439
  case 1:
439
- headers = _a.sent();
440
+ headers = _b.sent();
440
441
  body = getBody(subscriptionOptions);
441
442
  subscribeOptions = {
442
443
  method: 'POST',
443
444
  headers: headers,
444
445
  body: JSON.stringify(body)
445
446
  };
446
- _a.label = 2;
447
+ _b.label = 2;
447
448
  case 2:
448
- _a.trys.push([2, 5, , 6]);
449
+ _b.trys.push([2, 5, , 6]);
449
450
  return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions)];
450
451
  case 3:
451
- response = _a.sent();
452
+ response = _b.sent();
452
453
  return [4 /*yield*/, response.json()];
453
454
  case 4:
454
- responseData = _a.sent();
455
+ responseData = _b.sent();
455
456
  return [3 /*break*/, 6];
456
457
  case 5:
457
- err_1 = _a.sent();
458
+ err_1 = _b.sent();
458
459
  throw ERROR_FACTORY.create("token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */, {
459
- errorInfo: err_1
460
+ errorInfo: (_a = err_1) === null || _a === void 0 ? void 0 : _a.toString()
460
461
  });
461
462
  case 6:
462
463
  if (responseData.error) {
@@ -474,33 +475,34 @@ function requestGetToken(firebaseDependencies, subscriptionOptions) {
474
475
  });
475
476
  }
476
477
  function requestUpdateToken(firebaseDependencies, tokenDetails) {
478
+ var _a;
477
479
  return __awaiter(this, void 0, void 0, function () {
478
480
  var headers, body, updateOptions, responseData, response, err_2, message;
479
- return __generator(this, function (_a) {
480
- switch (_a.label) {
481
+ return __generator(this, function (_b) {
482
+ switch (_b.label) {
481
483
  case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];
482
484
  case 1:
483
- headers = _a.sent();
485
+ headers = _b.sent();
484
486
  body = getBody(tokenDetails.subscriptionOptions);
485
487
  updateOptions = {
486
488
  method: 'PATCH',
487
489
  headers: headers,
488
490
  body: JSON.stringify(body)
489
491
  };
490
- _a.label = 2;
492
+ _b.label = 2;
491
493
  case 2:
492
- _a.trys.push([2, 5, , 6]);
494
+ _b.trys.push([2, 5, , 6]);
493
495
  return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig) + "/" + tokenDetails.token, updateOptions)];
494
496
  case 3:
495
- response = _a.sent();
497
+ response = _b.sent();
496
498
  return [4 /*yield*/, response.json()];
497
499
  case 4:
498
- responseData = _a.sent();
500
+ responseData = _b.sent();
499
501
  return [3 /*break*/, 6];
500
502
  case 5:
501
- err_2 = _a.sent();
503
+ err_2 = _b.sent();
502
504
  throw ERROR_FACTORY.create("token-update-failed" /* TOKEN_UPDATE_FAILED */, {
503
- errorInfo: err_2
505
+ errorInfo: (_a = err_2) === null || _a === void 0 ? void 0 : _a.toString()
504
506
  });
505
507
  case 6:
506
508
  if (responseData.error) {
@@ -833,16 +835,19 @@ function propagateDataPayload(payload, messagePayloadInternal) {
833
835
  payload.data = messagePayloadInternal.data;
834
836
  }
835
837
  function propagateFcmOptions(payload, messagePayloadInternal) {
836
- if (!messagePayloadInternal.fcmOptions) {
838
+ var _a, _b, _c, _d, _e;
839
+ // fcmOptions.link value is written into notification.click_action. see more in b/232072111
840
+ if (!messagePayloadInternal.fcmOptions &&
841
+ !((_a = messagePayloadInternal.notification) === null || _a === void 0 ? void 0 : _a.click_action)) {
837
842
  return;
838
843
  }
839
844
  payload.fcmOptions = {};
840
- var link = messagePayloadInternal.fcmOptions.link;
845
+ var link = (_c = (_b = messagePayloadInternal.fcmOptions) === null || _b === void 0 ? void 0 : _b.link) !== null && _c !== void 0 ? _c : (_d = messagePayloadInternal.notification) === null || _d === void 0 ? void 0 : _d.click_action;
841
846
  if (!!link) {
842
847
  payload.fcmOptions.link = link;
843
848
  }
844
849
  // eslint-disable-next-line camelcase
845
- var analyticsLabel = messagePayloadInternal.fcmOptions.analytics_label;
850
+ var analyticsLabel = (_e = messagePayloadInternal.fcmOptions) === null || _e === void 0 ? void 0 : _e.analytics_label;
846
851
  if (!!analyticsLabel) {
847
852
  payload.fcmOptions.analyticsLabel = analyticsLabel;
848
853
  }
@@ -1014,18 +1019,19 @@ var MessagingService = /** @class */ (function () {
1014
1019
  * limitations under the License.
1015
1020
  */
1016
1021
  function registerDefaultSw(messaging) {
1022
+ var _a;
1017
1023
  return __awaiter(this, void 0, void 0, function () {
1018
- var _a, e_1;
1019
- return __generator(this, function (_b) {
1020
- switch (_b.label) {
1024
+ var _b, e_1;
1025
+ return __generator(this, function (_c) {
1026
+ switch (_c.label) {
1021
1027
  case 0:
1022
- _b.trys.push([0, 2, , 3]);
1023
- _a = messaging;
1028
+ _c.trys.push([0, 2, , 3]);
1029
+ _b = messaging;
1024
1030
  return [4 /*yield*/, navigator.serviceWorker.register(DEFAULT_SW_PATH, {
1025
1031
  scope: DEFAULT_SW_SCOPE
1026
1032
  })];
1027
1033
  case 1:
1028
- _a.swRegistration = _b.sent();
1034
+ _b.swRegistration = _c.sent();
1029
1035
  // The timing when browser updates sw when sw has an update is unreliable from experiment. It
1030
1036
  // leads to version conflict when the SDK upgrades to a newer version in the main page, but sw
1031
1037
  // is stuck with the old version. For example,
@@ -1036,9 +1042,9 @@ function registerDefaultSw(messaging) {
1036
1042
  });
1037
1043
  return [3 /*break*/, 3];
1038
1044
  case 2:
1039
- e_1 = _b.sent();
1045
+ e_1 = _c.sent();
1040
1046
  throw ERROR_FACTORY.create("failed-service-worker-registration" /* FAILED_DEFAULT_REGISTRATION */, {
1041
- browserErrorMessage: e_1.message
1047
+ browserErrorMessage: (_a = e_1) === null || _a === void 0 ? void 0 : _a.message
1042
1048
  });
1043
1049
  case 3: return [2 /*return*/];
1044
1050
  }
@@ -1260,7 +1266,7 @@ function messageEventListener(messaging, event) {
1260
1266
  }
1261
1267
 
1262
1268
  var name = "@firebase/messaging";
1263
- var version = "0.9.13";
1269
+ var version = "0.9.14-canary.8e952e2ee";
1264
1270
 
1265
1271
  /**
1266
1272
  * @license