@firebase/messaging 0.11.0 → 0.12.0-canary.41549bb86

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.
@@ -314,26 +314,26 @@ function getKey({ appConfig }) {
314
314
  * limitations under the License.
315
315
  */
316
316
  const ERROR_MAP = {
317
- ["missing-app-config-values" /* MISSING_APP_CONFIG_VALUES */]: 'Missing App configuration value: "{$valueName}"',
318
- ["only-available-in-window" /* AVAILABLE_IN_WINDOW */]: 'This method is available in a Window context.',
319
- ["only-available-in-sw" /* AVAILABLE_IN_SW */]: 'This method is available in a service worker context.',
320
- ["permission-default" /* PERMISSION_DEFAULT */]: 'The notification permission was not granted and dismissed instead.',
321
- ["permission-blocked" /* PERMISSION_BLOCKED */]: 'The notification permission was not granted and blocked instead.',
322
- ["unsupported-browser" /* UNSUPPORTED_BROWSER */]: "This browser doesn't support the API's required to use the Firebase SDK.",
323
- ["indexed-db-unsupported" /* INDEXED_DB_UNSUPPORTED */]: "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
324
- ["failed-service-worker-registration" /* FAILED_DEFAULT_REGISTRATION */]: 'We are unable to register the default service worker. {$browserErrorMessage}',
325
- ["token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */]: 'A problem occurred while subscribing the user to FCM: {$errorInfo}',
326
- ["token-subscribe-no-token" /* TOKEN_SUBSCRIBE_NO_TOKEN */]: 'FCM returned no token when subscribing the user to push.',
327
- ["token-unsubscribe-failed" /* TOKEN_UNSUBSCRIBE_FAILED */]: 'A problem occurred while unsubscribing the ' +
317
+ ["missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */]: 'Missing App configuration value: "{$valueName}"',
318
+ ["only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */]: 'This method is available in a Window context.',
319
+ ["only-available-in-sw" /* ErrorCode.AVAILABLE_IN_SW */]: 'This method is available in a service worker context.',
320
+ ["permission-default" /* ErrorCode.PERMISSION_DEFAULT */]: 'The notification permission was not granted and dismissed instead.',
321
+ ["permission-blocked" /* ErrorCode.PERMISSION_BLOCKED */]: 'The notification permission was not granted and blocked instead.',
322
+ ["unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */]: "This browser doesn't support the API's required to use the Firebase SDK.",
323
+ ["indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */]: "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
324
+ ["failed-service-worker-registration" /* ErrorCode.FAILED_DEFAULT_REGISTRATION */]: 'We are unable to register the default service worker. {$browserErrorMessage}',
325
+ ["token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */]: 'A problem occurred while subscribing the user to FCM: {$errorInfo}',
326
+ ["token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */]: 'FCM returned no token when subscribing the user to push.',
327
+ ["token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */]: 'A problem occurred while unsubscribing the ' +
328
328
  'user from FCM: {$errorInfo}',
329
- ["token-update-failed" /* TOKEN_UPDATE_FAILED */]: 'A problem occurred while updating the user from FCM: {$errorInfo}',
330
- ["token-update-no-token" /* TOKEN_UPDATE_NO_TOKEN */]: 'FCM returned no token when updating the user to push.',
331
- ["use-sw-after-get-token" /* USE_SW_AFTER_GET_TOKEN */]: 'The useServiceWorker() method may only be called once and must be ' +
329
+ ["token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */]: 'A problem occurred while updating the user from FCM: {$errorInfo}',
330
+ ["token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */]: 'FCM returned no token when updating the user to push.',
331
+ ["use-sw-after-get-token" /* ErrorCode.USE_SW_AFTER_GET_TOKEN */]: 'The useServiceWorker() method may only be called once and must be ' +
332
332
  'called before calling getToken() to ensure your service worker is used.',
333
- ["invalid-sw-registration" /* INVALID_SW_REGISTRATION */]: 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',
334
- ["invalid-bg-handler" /* INVALID_BG_HANDLER */]: 'The input to setBackgroundMessageHandler() must be a function.',
335
- ["invalid-vapid-key" /* INVALID_VAPID_KEY */]: 'The public VAPID key must be a string.',
336
- ["use-vapid-key-after-get-token" /* USE_VAPID_KEY_AFTER_GET_TOKEN */]: 'The usePublicVapidKey() method may only be called once and must be ' +
333
+ ["invalid-sw-registration" /* ErrorCode.INVALID_SW_REGISTRATION */]: 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',
334
+ ["invalid-bg-handler" /* ErrorCode.INVALID_BG_HANDLER */]: 'The input to setBackgroundMessageHandler() must be a function.',
335
+ ["invalid-vapid-key" /* ErrorCode.INVALID_VAPID_KEY */]: 'The public VAPID key must be a string.',
336
+ ["use-vapid-key-after-get-token" /* ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN */]: 'The usePublicVapidKey() method may only be called once and must be ' +
337
337
  'called before calling getToken() to ensure your VAPID key is used.'
338
338
  };
339
339
  const ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
@@ -355,7 +355,6 @@ const ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
355
355
  * limitations under the License.
356
356
  */
357
357
  async function requestGetToken(firebaseDependencies, subscriptionOptions) {
358
- var _a;
359
358
  const headers = await getHeaders(firebaseDependencies);
360
359
  const body = getBody(subscriptionOptions);
361
360
  const subscribeOptions = {
@@ -369,23 +368,22 @@ async function requestGetToken(firebaseDependencies, subscriptionOptions) {
369
368
  responseData = await response.json();
370
369
  }
371
370
  catch (err) {
372
- throw ERROR_FACTORY.create("token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */, {
373
- errorInfo: (_a = err) === null || _a === void 0 ? void 0 : _a.toString()
371
+ throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
372
+ errorInfo: err === null || err === void 0 ? void 0 : err.toString()
374
373
  });
375
374
  }
376
375
  if (responseData.error) {
377
376
  const message = responseData.error.message;
378
- throw ERROR_FACTORY.create("token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */, {
377
+ throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
379
378
  errorInfo: message
380
379
  });
381
380
  }
382
381
  if (!responseData.token) {
383
- throw ERROR_FACTORY.create("token-subscribe-no-token" /* TOKEN_SUBSCRIBE_NO_TOKEN */);
382
+ throw ERROR_FACTORY.create("token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */);
384
383
  }
385
384
  return responseData.token;
386
385
  }
387
386
  async function requestUpdateToken(firebaseDependencies, tokenDetails) {
388
- var _a;
389
387
  const headers = await getHeaders(firebaseDependencies);
390
388
  const body = getBody(tokenDetails.subscriptionOptions);
391
389
  const updateOptions = {
@@ -399,23 +397,22 @@ async function requestUpdateToken(firebaseDependencies, tokenDetails) {
399
397
  responseData = await response.json();
400
398
  }
401
399
  catch (err) {
402
- throw ERROR_FACTORY.create("token-update-failed" /* TOKEN_UPDATE_FAILED */, {
403
- errorInfo: (_a = err) === null || _a === void 0 ? void 0 : _a.toString()
400
+ throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
401
+ errorInfo: err === null || err === void 0 ? void 0 : err.toString()
404
402
  });
405
403
  }
406
404
  if (responseData.error) {
407
405
  const message = responseData.error.message;
408
- throw ERROR_FACTORY.create("token-update-failed" /* TOKEN_UPDATE_FAILED */, {
406
+ throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
409
407
  errorInfo: message
410
408
  });
411
409
  }
412
410
  if (!responseData.token) {
413
- throw ERROR_FACTORY.create("token-update-no-token" /* TOKEN_UPDATE_NO_TOKEN */);
411
+ throw ERROR_FACTORY.create("token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */);
414
412
  }
415
413
  return responseData.token;
416
414
  }
417
415
  async function requestDeleteToken(firebaseDependencies, token) {
418
- var _a;
419
416
  const headers = await getHeaders(firebaseDependencies);
420
417
  const unsubscribeOptions = {
421
418
  method: 'DELETE',
@@ -426,14 +423,14 @@ async function requestDeleteToken(firebaseDependencies, token) {
426
423
  const responseData = await response.json();
427
424
  if (responseData.error) {
428
425
  const message = responseData.error.message;
429
- throw ERROR_FACTORY.create("token-unsubscribe-failed" /* TOKEN_UNSUBSCRIBE_FAILED */, {
426
+ throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
430
427
  errorInfo: message
431
428
  });
432
429
  }
433
430
  }
434
431
  catch (err) {
435
- throw ERROR_FACTORY.create("token-unsubscribe-failed" /* TOKEN_UNSUBSCRIBE_FAILED */, {
436
- errorInfo: (_a = err) === null || _a === void 0 ? void 0 : _a.toString()
432
+ throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
433
+ errorInfo: err === null || err === void 0 ? void 0 : err.toString()
437
434
  });
438
435
  }
439
436
  }
@@ -1014,7 +1011,7 @@ function extractAppConfig(app) {
1014
1011
  };
1015
1012
  }
1016
1013
  function getMissingValueError(valueName) {
1017
- return ERROR_FACTORY.create("missing-app-config-values" /* MISSING_APP_CONFIG_VALUES */, {
1014
+ return ERROR_FACTORY.create("missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */, {
1018
1015
  valueName
1019
1016
  });
1020
1017
  }
@@ -1091,7 +1088,7 @@ const SwMessagingFactory = (container) => {
1091
1088
  * `messaging-compat` and component with the same name can only be registered once.
1092
1089
  */
1093
1090
  function registerMessagingInSw() {
1094
- _registerComponent(new Component('messaging-sw', SwMessagingFactory, "PUBLIC" /* PUBLIC */));
1091
+ _registerComponent(new Component('messaging-sw', SwMessagingFactory, "PUBLIC" /* ComponentType.PUBLIC */));
1095
1092
  }
1096
1093
 
1097
1094
  /**
@@ -1146,7 +1143,7 @@ async function isSwSupported() {
1146
1143
  */
1147
1144
  function onBackgroundMessage$1(messaging, nextOrObserver) {
1148
1145
  if (self.document !== undefined) {
1149
- throw ERROR_FACTORY.create("only-available-in-sw" /* AVAILABLE_IN_SW */);
1146
+ throw ERROR_FACTORY.create("only-available-in-sw" /* ErrorCode.AVAILABLE_IN_SW */);
1150
1147
  }
1151
1148
  messaging.onBackgroundMessageHandler = nextOrObserver;
1152
1149
  return () => {
@@ -1206,11 +1203,11 @@ function getMessagingInSw(app = getApp()) {
1206
1203
  isSwSupported().then(isSupported => {
1207
1204
  // If `isSwSupported()` resolved, but returned false.
1208
1205
  if (!isSupported) {
1209
- throw ERROR_FACTORY.create("unsupported-browser" /* UNSUPPORTED_BROWSER */);
1206
+ throw ERROR_FACTORY.create("unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */);
1210
1207
  }
1211
1208
  }, _ => {
1212
1209
  // If `isSwSupported()` rejected.
1213
- throw ERROR_FACTORY.create("indexed-db-unsupported" /* INDEXED_DB_UNSUPPORTED */);
1210
+ throw ERROR_FACTORY.create("indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */);
1214
1211
  });
1215
1212
  return _getProvider(getModularInstance(app), 'messaging-sw').getImmediate();
1216
1213
  }