@depup/firebase__messaging 0.12.24-depup.0

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 (108) hide show
  1. package/README.md +32 -0
  2. package/changes.json +14 -0
  3. package/dist/esm/index.esm.js +1270 -0
  4. package/dist/esm/index.esm.js.map +1 -0
  5. package/dist/esm/index.sw.esm.js +1278 -0
  6. package/dist/esm/index.sw.esm.js.map +1 -0
  7. package/dist/esm/package.json +1 -0
  8. package/dist/esm/src/api/deleteToken.d.ts +18 -0
  9. package/dist/esm/src/api/getToken.d.ts +19 -0
  10. package/dist/esm/src/api/isSupported.d.ts +30 -0
  11. package/dist/esm/src/api/onBackgroundMessage.d.ts +19 -0
  12. package/dist/esm/src/api/onMessage.d.ts +19 -0
  13. package/dist/esm/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts +18 -0
  14. package/dist/esm/src/api.d.ts +101 -0
  15. package/dist/esm/src/helpers/array-base64-translator.d.ts +18 -0
  16. package/dist/esm/src/helpers/externalizePayload.d.ts +19 -0
  17. package/dist/esm/src/helpers/extract-app-config.d.ts +19 -0
  18. package/dist/esm/src/helpers/is-console-message.d.ts +18 -0
  19. package/dist/esm/src/helpers/logToFirelog.d.ts +30 -0
  20. package/dist/esm/src/helpers/logToScion.d.ts +19 -0
  21. package/dist/esm/src/helpers/migrate-old-database.d.ts +51 -0
  22. package/dist/esm/src/helpers/register.d.ts +23 -0
  23. package/dist/esm/src/helpers/registerDefaultSw.d.ts +18 -0
  24. package/dist/esm/src/helpers/sleep.d.ts +18 -0
  25. package/dist/esm/src/helpers/updateSwReg.d.ts +18 -0
  26. package/dist/esm/src/helpers/updateVapidKey.d.ts +18 -0
  27. package/dist/esm/src/index.d.ts +32 -0
  28. package/dist/esm/src/index.sw.d.ts +26 -0
  29. package/dist/esm/src/interfaces/app-config.d.ts +24 -0
  30. package/dist/esm/src/interfaces/internal-dependencies.d.ts +27 -0
  31. package/dist/esm/src/interfaces/internal-message-payload.d.ts +65 -0
  32. package/dist/esm/src/interfaces/logging-types.d.ts +60 -0
  33. package/dist/esm/src/interfaces/public-types.d.ts +144 -0
  34. package/dist/esm/src/interfaces/token-details.d.ts +32 -0
  35. package/dist/esm/src/internals/idb-manager.d.ts +27 -0
  36. package/dist/esm/src/internals/requests.d.ts +35 -0
  37. package/dist/esm/src/internals/token-manager.d.ts +23 -0
  38. package/dist/esm/src/listeners/sw-listeners.d.ts +21 -0
  39. package/dist/esm/src/listeners/window-listener.d.ts +18 -0
  40. package/dist/esm/src/messaging-service.d.ts +36 -0
  41. package/dist/esm/src/testing/compare-headers.d.ts +22 -0
  42. package/dist/esm/src/testing/fakes/firebase-dependencies.d.ts +25 -0
  43. package/dist/esm/src/testing/fakes/logging-object.d.ts +18 -0
  44. package/dist/esm/src/testing/fakes/messaging-service.d.ts +18 -0
  45. package/dist/esm/src/testing/fakes/service-worker.d.ts +83 -0
  46. package/dist/esm/src/testing/fakes/token-details.d.ts +18 -0
  47. package/dist/esm/src/testing/setup.d.ts +17 -0
  48. package/dist/esm/src/testing/sinon-types.d.ts +19 -0
  49. package/dist/esm/src/util/constants.d.ts +40 -0
  50. package/dist/esm/src/util/errors.d.ts +57 -0
  51. package/dist/esm/src/util/sw-types.d.ts +90 -0
  52. package/dist/index-public.d.ts +204 -0
  53. package/dist/index.cjs.js +1278 -0
  54. package/dist/index.cjs.js.map +1 -0
  55. package/dist/index.sw.cjs +1285 -0
  56. package/dist/index.sw.cjs.map +1 -0
  57. package/dist/internal.d.ts +220 -0
  58. package/dist/private.d.ts +217 -0
  59. package/dist/src/api/deleteToken.d.ts +18 -0
  60. package/dist/src/api/getToken.d.ts +19 -0
  61. package/dist/src/api/isSupported.d.ts +30 -0
  62. package/dist/src/api/onBackgroundMessage.d.ts +19 -0
  63. package/dist/src/api/onMessage.d.ts +19 -0
  64. package/dist/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts +18 -0
  65. package/dist/src/api.d.ts +101 -0
  66. package/dist/src/helpers/array-base64-translator.d.ts +18 -0
  67. package/dist/src/helpers/externalizePayload.d.ts +19 -0
  68. package/dist/src/helpers/extract-app-config.d.ts +19 -0
  69. package/dist/src/helpers/is-console-message.d.ts +18 -0
  70. package/dist/src/helpers/logToFirelog.d.ts +30 -0
  71. package/dist/src/helpers/logToScion.d.ts +19 -0
  72. package/dist/src/helpers/migrate-old-database.d.ts +51 -0
  73. package/dist/src/helpers/register.d.ts +23 -0
  74. package/dist/src/helpers/registerDefaultSw.d.ts +18 -0
  75. package/dist/src/helpers/sleep.d.ts +18 -0
  76. package/dist/src/helpers/updateSwReg.d.ts +18 -0
  77. package/dist/src/helpers/updateVapidKey.d.ts +18 -0
  78. package/dist/src/index.d.ts +32 -0
  79. package/dist/src/index.sw.d.ts +26 -0
  80. package/dist/src/interfaces/app-config.d.ts +24 -0
  81. package/dist/src/interfaces/internal-dependencies.d.ts +27 -0
  82. package/dist/src/interfaces/internal-message-payload.d.ts +65 -0
  83. package/dist/src/interfaces/logging-types.d.ts +60 -0
  84. package/dist/src/interfaces/public-types.d.ts +144 -0
  85. package/dist/src/interfaces/token-details.d.ts +32 -0
  86. package/dist/src/internals/idb-manager.d.ts +27 -0
  87. package/dist/src/internals/requests.d.ts +35 -0
  88. package/dist/src/internals/token-manager.d.ts +23 -0
  89. package/dist/src/listeners/sw-listeners.d.ts +21 -0
  90. package/dist/src/listeners/window-listener.d.ts +18 -0
  91. package/dist/src/messaging-service.d.ts +36 -0
  92. package/dist/src/testing/compare-headers.d.ts +22 -0
  93. package/dist/src/testing/fakes/firebase-dependencies.d.ts +25 -0
  94. package/dist/src/testing/fakes/logging-object.d.ts +18 -0
  95. package/dist/src/testing/fakes/messaging-service.d.ts +18 -0
  96. package/dist/src/testing/fakes/service-worker.d.ts +83 -0
  97. package/dist/src/testing/fakes/token-details.d.ts +18 -0
  98. package/dist/src/testing/setup.d.ts +17 -0
  99. package/dist/src/testing/sinon-types.d.ts +19 -0
  100. package/dist/src/tsdoc-metadata.json +11 -0
  101. package/dist/src/util/constants.d.ts +40 -0
  102. package/dist/src/util/errors.d.ts +57 -0
  103. package/dist/src/util/sw-types.d.ts +90 -0
  104. package/dist/sw/index-public.d.ts +166 -0
  105. package/dist/sw/internal.d.ts +180 -0
  106. package/dist/sw/private.d.ts +177 -0
  107. package/package.json +103 -0
  108. package/sw/package.json +8 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { NotificationEvent, PushEvent, PushSubscriptionChangeEvent } from '../util/sw-types';
18
+ import { MessagingService } from '../messaging-service';
19
+ export declare function onSubChange(event: PushSubscriptionChangeEvent, messaging: MessagingService): Promise<void>;
20
+ export declare function onPush(event: PushEvent, messaging: MessagingService): Promise<void>;
21
+ export declare function onNotificationClick(event: NotificationEvent): Promise<void>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { MessagingService } from '../messaging-service';
18
+ export declare function messageEventListener(messaging: MessagingService, event: MessageEvent): Promise<void>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseApp, _FirebaseService } from '@firebase/app';
18
+ import { MessagePayload, NextFn, Observer } from './interfaces/public-types';
19
+ import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
20
+ import { FirebaseInternalDependencies } from './interfaces/internal-dependencies';
21
+ import { LogEvent } from './interfaces/logging-types';
22
+ import { Provider } from '@firebase/component';
23
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
24
+ export declare class MessagingService implements _FirebaseService {
25
+ readonly app: FirebaseApp;
26
+ readonly firebaseDependencies: FirebaseInternalDependencies;
27
+ swRegistration?: ServiceWorkerRegistration;
28
+ vapidKey?: string;
29
+ deliveryMetricsExportedToBigQueryEnabled: boolean;
30
+ onBackgroundMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null;
31
+ onMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null;
32
+ logEvents: LogEvent[];
33
+ isLogServiceStarted: boolean;
34
+ constructor(app: FirebaseApp, installations: _FirebaseInstallationsInternal, analyticsProvider: Provider<FirebaseAnalyticsInternalName>);
35
+ _delete(): Promise<void>;
36
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import './setup';
18
+ declare class HeadersWithEntries extends Headers {
19
+ entries?(): Iterable<[string, string]>;
20
+ }
21
+ export declare function compareHeaders(expectedHeaders: HeadersWithEntries, actualHeaders: HeadersWithEntries): void;
22
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
18
+ import { FirebaseInternalDependencies } from '../../interfaces/internal-dependencies';
19
+ import { FirebaseOptions } from '@firebase/app';
20
+ import { Provider } from '@firebase/component';
21
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
22
+ export declare function getFakeFirebaseDependencies(options?: FirebaseOptions): FirebaseInternalDependencies;
23
+ export declare function getFakeApp(options?: FirebaseOptions): any;
24
+ export declare function getFakeInstallations(): _FirebaseInstallationsInternal;
25
+ export declare function getFakeAnalyticsProvider(): Provider<FirebaseAnalyticsInternalName>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
11
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12
+ * or implied. See the License for the specific language governing permissions and limitations under
13
+ * the License.
14
+ */
15
+ import { LogEvent, LogResponse } from '../../interfaces/logging-types';
16
+ export declare function getFakeLogEvent(): LogEvent;
17
+ export declare function getSuccessResponse(): LogResponse;
18
+ export declare function getFailedResponse(): LogResponse;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { MessagingService } from '../../messaging-service';
18
+ export declare function getFakeMessagingService(): MessagingService;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ExtendableEvent } from '../../util/sw-types';
18
+ export declare function mockServiceWorker(): void;
19
+ export declare function restoreServiceWorker(): void;
20
+ export declare class FakeServiceWorkerRegistration implements ServiceWorkerRegistration {
21
+ active: null;
22
+ installing: null;
23
+ waiting: null;
24
+ onupdatefound: null;
25
+ pushManager: FakePushManager;
26
+ scope: string;
27
+ navigationPreload: NavigationPreloadManager;
28
+ updateViaCache: ServiceWorkerUpdateViaCache;
29
+ getNotifications(): Promise<never[]>;
30
+ showNotification(): Promise<void>;
31
+ update(): Promise<void>;
32
+ unregister(): Promise<boolean>;
33
+ addEventListener(): void;
34
+ removeEventListener(): void;
35
+ dispatchEvent(): boolean;
36
+ }
37
+ declare class FakePushManager implements PushManager {
38
+ private subscription;
39
+ permissionState(): Promise<"granted">;
40
+ getSubscription(): Promise<FakePushSubscription | null>;
41
+ subscribe(): Promise<FakePushSubscription>;
42
+ }
43
+ export declare class FakePushSubscription implements PushSubscription {
44
+ endpoint: string;
45
+ expirationTime: number;
46
+ auth: string;
47
+ p256: string;
48
+ getKey(name: PushEncryptionKeyName): Uint8Array;
49
+ unsubscribe(): Promise<boolean>;
50
+ toJSON: () => PushSubscriptionJSON;
51
+ options: PushSubscriptionOptions;
52
+ }
53
+ /**
54
+ * Most of the fields in here are unused / deprecated. They are only added here to match the TS
55
+ * Event interface.
56
+ */
57
+ export declare class FakeEvent implements ExtendableEvent {
58
+ type: string;
59
+ NONE: 0;
60
+ AT_TARGET: 2;
61
+ BUBBLING_PHASE: 3;
62
+ CAPTURING_PHASE: 1;
63
+ bubbles: boolean;
64
+ cancelable: boolean;
65
+ composed: boolean;
66
+ timeStamp: number;
67
+ isTrusted: boolean;
68
+ eventPhase: 0;
69
+ target: null;
70
+ currentTarget: null;
71
+ srcElement: null;
72
+ cancelBubble: boolean;
73
+ defaultPrevented: boolean;
74
+ returnValue: boolean;
75
+ preventDefault(): void;
76
+ stopPropagation(): void;
77
+ stopImmediatePropagation(): void;
78
+ initEvent(): void;
79
+ waitUntil(): void;
80
+ composedPath(): never[];
81
+ constructor(type: string, options?: EventInit);
82
+ }
83
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { TokenDetails } from '../../interfaces/token-details';
18
+ export declare function getFakeTokenDetails(): TokenDetails;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { SinonSpy, SinonStub } from 'sinon';
18
+ export type Stub<T extends (...args: any) => any> = SinonStub<Parameters<T>, ReturnType<T>>;
19
+ export type Spy<T extends (...args: any) => any> = SinonSpy<Parameters<T>, ReturnType<T>>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare const DEFAULT_SW_PATH = "/firebase-messaging-sw.js";
18
+ export declare const DEFAULT_SW_SCOPE = "/firebase-cloud-messaging-push-scope";
19
+ export declare const DEFAULT_VAPID_KEY = "BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4";
20
+ export declare const ENDPOINT = "https://fcmregistrations.googleapis.com/v1";
21
+ /** Key of FCM Payload in Notification's data field. */
22
+ export declare const FCM_MSG = "FCM_MSG";
23
+ export declare const CONSOLE_CAMPAIGN_ID = "google.c.a.c_id";
24
+ export declare const CONSOLE_CAMPAIGN_NAME = "google.c.a.c_l";
25
+ export declare const CONSOLE_CAMPAIGN_TIME = "google.c.a.ts";
26
+ /** Set to '1' if Analytics is enabled for the campaign */
27
+ export declare const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = "google.c.a.e";
28
+ export declare const TAG = "FirebaseMessaging: ";
29
+ export declare const MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST = 1000;
30
+ export declare const MAX_RETRIES = 3;
31
+ export declare const LOG_INTERVAL_IN_MS = 86400000;
32
+ export declare const DEFAULT_BACKOFF_TIME_MS = 5000;
33
+ export declare const DEFAULT_REGISTRATION_TIMEOUT = 10000;
34
+ export declare const FCM_LOG_SOURCE = 1249;
35
+ export declare const SDK_PLATFORM_WEB = 3;
36
+ export declare const EVENT_MESSAGE_DELIVERED = 1;
37
+ export declare enum MessageType {
38
+ DATA_MESSAGE = 1,
39
+ DISPLAY_NOTIFICATION = 3
40
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ErrorFactory, ErrorMap } from '@firebase/util';
18
+ export declare const enum ErrorCode {
19
+ MISSING_APP_CONFIG_VALUES = "missing-app-config-values",
20
+ AVAILABLE_IN_WINDOW = "only-available-in-window",
21
+ AVAILABLE_IN_SW = "only-available-in-sw",
22
+ PERMISSION_DEFAULT = "permission-default",
23
+ PERMISSION_BLOCKED = "permission-blocked",
24
+ UNSUPPORTED_BROWSER = "unsupported-browser",
25
+ INDEXED_DB_UNSUPPORTED = "indexed-db-unsupported",
26
+ FAILED_DEFAULT_REGISTRATION = "failed-service-worker-registration",
27
+ TOKEN_SUBSCRIBE_FAILED = "token-subscribe-failed",
28
+ TOKEN_SUBSCRIBE_NO_TOKEN = "token-subscribe-no-token",
29
+ TOKEN_UNSUBSCRIBE_FAILED = "token-unsubscribe-failed",
30
+ TOKEN_UPDATE_FAILED = "token-update-failed",
31
+ TOKEN_UPDATE_NO_TOKEN = "token-update-no-token",
32
+ INVALID_BG_HANDLER = "invalid-bg-handler",
33
+ USE_SW_AFTER_GET_TOKEN = "use-sw-after-get-token",
34
+ INVALID_SW_REGISTRATION = "invalid-sw-registration",
35
+ USE_VAPID_KEY_AFTER_GET_TOKEN = "use-vapid-key-after-get-token",
36
+ INVALID_VAPID_KEY = "invalid-vapid-key"
37
+ }
38
+ export declare const ERROR_MAP: ErrorMap<ErrorCode>;
39
+ interface ErrorParams {
40
+ [ErrorCode.MISSING_APP_CONFIG_VALUES]: {
41
+ valueName: string;
42
+ };
43
+ [ErrorCode.FAILED_DEFAULT_REGISTRATION]: {
44
+ browserErrorMessage: string;
45
+ };
46
+ [ErrorCode.TOKEN_SUBSCRIBE_FAILED]: {
47
+ errorInfo: string;
48
+ };
49
+ [ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]: {
50
+ errorInfo: string;
51
+ };
52
+ [ErrorCode.TOKEN_UPDATE_FAILED]: {
53
+ errorInfo: string;
54
+ };
55
+ }
56
+ export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
57
+ export {};
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2018 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Subset of Web Worker types from lib.webworker.d.ts
19
+ * https://github.com/Microsoft/TypeScript/blob/master/lib/lib.webworker.d.ts
20
+ *
21
+ * Since it's not possible to have both "dom" and "webworker" libs in a single project, we have to
22
+ * manually declare the web worker types we need.
23
+ */
24
+ export interface ServiceWorkerGlobalScope {
25
+ readonly location: WorkerLocation;
26
+ readonly clients: Clients;
27
+ readonly registration: ServiceWorkerRegistration;
28
+ addEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
29
+ }
30
+ export interface ServiceWorkerGlobalScopeEventMap {
31
+ notificationclick: NotificationEvent;
32
+ push: PushEvent;
33
+ pushsubscriptionchange: PushSubscriptionChangeEvent;
34
+ }
35
+ export interface Client {
36
+ readonly id: string;
37
+ readonly type: ClientTypes;
38
+ readonly url: string;
39
+ postMessage(message: any, transfer?: Transferable[]): void;
40
+ }
41
+ export interface ClientQueryOptions {
42
+ includeReserved?: boolean;
43
+ includeUncontrolled?: boolean;
44
+ type?: ClientTypes;
45
+ }
46
+ export interface WindowClient extends Client {
47
+ readonly focused: boolean;
48
+ readonly visibilityState: DocumentVisibilityState;
49
+ focus(): Promise<WindowClient>;
50
+ navigate(url: string): Promise<WindowClient>;
51
+ }
52
+ export interface Clients {
53
+ claim(): Promise<void>;
54
+ get(id: string): Promise<any>;
55
+ matchAll(options?: ClientQueryOptions): Promise<Client[]>;
56
+ openWindow(url: string): Promise<WindowClient | null>;
57
+ }
58
+ export interface ExtendableEvent extends Event {
59
+ waitUntil(f: Promise<any>): void;
60
+ }
61
+ export interface NotificationEvent extends ExtendableEvent {
62
+ readonly action: string;
63
+ readonly notification: Notification;
64
+ }
65
+ interface PushMessageData {
66
+ arrayBuffer(): ArrayBuffer;
67
+ blob(): Blob;
68
+ json(): any;
69
+ text(): string;
70
+ }
71
+ export interface PushEvent extends ExtendableEvent {
72
+ readonly data: PushMessageData | null;
73
+ }
74
+ export interface PushSubscriptionChangeEvent extends ExtendableEvent {
75
+ readonly newSubscription: PushSubscription | null;
76
+ readonly oldSubscription: PushSubscription | null;
77
+ }
78
+ interface WorkerLocation {
79
+ readonly hash: string;
80
+ readonly host: string;
81
+ readonly hostname: string;
82
+ readonly href: string;
83
+ readonly origin: string;
84
+ readonly pathname: string;
85
+ readonly port: string;
86
+ readonly protocol: string;
87
+ readonly search: string;
88
+ toString(): string;
89
+ }
90
+ export {};