@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,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
+ /** Returns a promise that resolves after given time passes. */
18
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,18 @@
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 { MessagingService } from '../messaging-service';
18
+ export declare function updateSwReg(messaging: MessagingService, swRegistration?: ServiceWorkerRegistration | undefined): Promise<void>;
@@ -0,0 +1,18 @@
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 { MessagingService } from '../messaging-service';
18
+ export declare function updateVapidKey(messaging: MessagingService, vapidKey?: string | undefined): Promise<void>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The Firebase Cloud Messaging Web SDK.
3
+ * This SDK does not work in a Node.js environment.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ /**
8
+ * @license
9
+ * Copyright 2017 Google LLC
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ import '@firebase/installations';
24
+ import { Messaging } from './interfaces/public-types';
25
+ export { getToken, deleteToken, onMessage, getMessagingInWindow as getMessaging } from './api';
26
+ export { isWindowSupported as isSupported } from './api/isSupported';
27
+ export * from './interfaces/public-types';
28
+ declare module '@firebase/component' {
29
+ interface NameServiceMapping {
30
+ 'messaging': Messaging;
31
+ }
32
+ }
@@ -0,0 +1,26 @@
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 '@firebase/installations';
18
+ import { Messaging } from './interfaces/public-types';
19
+ export * from './interfaces/public-types';
20
+ export { onBackgroundMessage, getMessagingInSw as getMessaging, experimentalSetDeliveryMetricsExportedToBigQueryEnabled } from './api';
21
+ export { isSwSupported as isSupported } from './api/isSupported';
22
+ declare module '@firebase/component' {
23
+ interface NameServiceMapping {
24
+ 'messaging-sw': Messaging;
25
+ }
26
+ }
@@ -0,0 +1,24 @@
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 interface AppConfig {
18
+ readonly appName: string;
19
+ readonly projectId: string;
20
+ readonly apiKey: string;
21
+ readonly appId: string;
22
+ /** Only used for old DB migration. */
23
+ readonly senderId: string;
24
+ }
@@ -0,0 +1,27 @@
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 { AppConfig } from './app-config';
18
+ import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
19
+ import { FirebaseApp } from '@firebase/app';
20
+ import { Provider } from '@firebase/component';
21
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
22
+ export interface FirebaseInternalDependencies {
23
+ app: FirebaseApp;
24
+ appConfig: AppConfig;
25
+ installations: _FirebaseInstallationsInternal;
26
+ analyticsProvider: Provider<FirebaseAnalyticsInternalName>;
27
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2018 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 { CONSOLE_CAMPAIGN_ANALYTICS_ENABLED, CONSOLE_CAMPAIGN_ID, CONSOLE_CAMPAIGN_NAME, CONSOLE_CAMPAIGN_TIME } from '../util/constants';
16
+ export interface MessagePayloadInternal {
17
+ notification?: NotificationPayloadInternal;
18
+ data?: unknown;
19
+ fcmOptions?: FcmOptionsInternal;
20
+ messageType?: MessageType;
21
+ isFirebaseMessaging?: boolean;
22
+ from: string;
23
+ fcmMessageId: string;
24
+ productId: number;
25
+ collapse_key: string;
26
+ }
27
+ interface NotificationAction {
28
+ action: string;
29
+ icon?: string;
30
+ title: string;
31
+ }
32
+ /**
33
+ * This interface defines experimental properties of NotificationOptions, that are not part of
34
+ * the interface in the generated DOM types at https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/179bdd84a944933a3103f29c2274c9f5a857b693/baselines/dom.generated.d.ts#L1012
35
+ * https://developer.mozilla.org/en-US/docs/Web/API/Notification
36
+ */
37
+ interface NotificationOptionsExperimental extends NotificationOptions {
38
+ readonly maxActions?: number;
39
+ readonly actions?: NotificationAction[];
40
+ readonly image?: string;
41
+ readonly renotify?: boolean;
42
+ readonly timestamp?: EpochTimeStamp;
43
+ readonly vibrate?: VibratePattern;
44
+ }
45
+ export interface NotificationPayloadInternal extends NotificationOptionsExperimental {
46
+ title: string;
47
+ click_action?: string;
48
+ icon?: string;
49
+ }
50
+ export interface FcmOptionsInternal {
51
+ link?: string;
52
+ analytics_label?: string;
53
+ }
54
+ export declare enum MessageType {
55
+ PUSH_RECEIVED = "push-received",
56
+ NOTIFICATION_CLICKED = "notification-clicked"
57
+ }
58
+ /** Additional data of a message sent from the FN Console. */
59
+ export interface ConsoleMessageData {
60
+ [CONSOLE_CAMPAIGN_ID]: string;
61
+ [CONSOLE_CAMPAIGN_TIME]: string;
62
+ [CONSOLE_CAMPAIGN_NAME]?: string;
63
+ [CONSOLE_CAMPAIGN_ANALYTICS_ENABLED]?: '1';
64
+ }
65
+ export {};
@@ -0,0 +1,60 @@
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
+ export interface FcmEvent {
16
+ project_number: string;
17
+ message_id: string;
18
+ instance_id: string;
19
+ message_type: string;
20
+ sdk_platform: string;
21
+ package_name: string;
22
+ collapse_key: string;
23
+ event: string;
24
+ analytics_label?: string;
25
+ }
26
+ /**
27
+ * A LogRequest represents a batched collection of loggable events sent to firelog, each event to be
28
+ * processed and sent to Sawmill. Defined as in proto/clientanalytics.proto#LogRequest
29
+ */
30
+ export interface LogRequest {
31
+ log_source: string;
32
+ log_event: LogEvent[];
33
+ }
34
+ export interface LogEvent {
35
+ event_time_ms: string;
36
+ source_extension_json_proto3: string;
37
+ compliance_data: ComplianceData;
38
+ }
39
+ export interface ComplianceData {
40
+ privacy_context: ExternalPrivacyContext;
41
+ }
42
+ export interface ExternalPrivacyContext {
43
+ prequest: ExternalPRequestContext;
44
+ }
45
+ export interface ExternalPRequestContext {
46
+ origin_associated_product_id: number;
47
+ }
48
+ export interface LogResponse {
49
+ nextRequestWaitMillis: number;
50
+ logResponseDetails: LogResponseDetails[];
51
+ }
52
+ interface LogResponseDetails {
53
+ responseAction: UserResponse;
54
+ }
55
+ export declare const enum UserResponse {
56
+ RESPONSE_ACTION_UNKNOWN = "RESPONSE_ACTION_UNKNOWN",
57
+ RETRY_REQUEST_LATER = "RETRY_REQUEST_LATER",
58
+ DELETE_REQUEST = "DELETE_REQUEST"
59
+ }
60
+ export {};
@@ -0,0 +1,144 @@
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 } from '@firebase/app';
18
+ /**
19
+ * Display notification details. Details are sent through the
20
+ * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}.
21
+ *
22
+ * @public
23
+ */
24
+ export interface NotificationPayload {
25
+ /**
26
+ * The notification's title.
27
+ */
28
+ title?: string;
29
+ /**
30
+ * The notification's body text.
31
+ */
32
+ body?: string;
33
+ /**
34
+ * The URL of an image that is downloaded on the device and displayed in the notification.
35
+ */
36
+ image?: string;
37
+ /**
38
+ * The URL to use for the notification's icon. If you don't send this key in the request,
39
+ * FCM displays the launcher icon specified in your app manifest.
40
+ */
41
+ icon?: string;
42
+ }
43
+ /**
44
+ * Options for features provided by the FCM SDK for Web. See {@link
45
+ * https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions |
46
+ * WebpushFcmOptions}.
47
+ *
48
+ * @public
49
+ */
50
+ export interface FcmOptions {
51
+ /**
52
+ * The link to open when the user clicks on the notification.
53
+ */
54
+ link?: string;
55
+ /**
56
+ * The label associated with the message's analytics data.
57
+ */
58
+ analyticsLabel?: string;
59
+ }
60
+ /**
61
+ * Message payload that contains the notification payload that is represented with
62
+ * {@link NotificationPayload} and the data payload that contains an arbitrary
63
+ * number of key-value pairs sent by developers through the
64
+ * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}.
65
+ *
66
+ * @public
67
+ */
68
+ export interface MessagePayload {
69
+ /**
70
+ * {@inheritdoc NotificationPayload}
71
+ */
72
+ notification?: NotificationPayload;
73
+ /**
74
+ * Arbitrary key/value payload.
75
+ */
76
+ data?: {
77
+ [key: string]: string;
78
+ };
79
+ /**
80
+ * {@inheritdoc FcmOptions}
81
+ */
82
+ fcmOptions?: FcmOptions;
83
+ /**
84
+ * The sender of this message.
85
+ */
86
+ from: string;
87
+ /**
88
+ * The collapse key of the message. See
89
+ * {@link https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages | Non-collapsible and collapsible messages}
90
+ */
91
+ collapseKey: string;
92
+ /**
93
+ * The message ID of a message.
94
+ */
95
+ messageId: string;
96
+ }
97
+ /**
98
+ * Options for {@link getToken}.
99
+ *
100
+ * @public
101
+ */
102
+ export interface GetTokenOptions {
103
+ /**
104
+ * The public server key provided to push services. The key is used to
105
+ * authenticate push subscribers to receive push messages only from sending servers that hold
106
+ * the corresponding private key. If it is not provided, a default VAPID key is used. Note that some
107
+ * push services (Chrome Push Service) require a non-default VAPID key. Therefore, it is recommended
108
+ * to generate and import a VAPID key for your project with
109
+ * {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_in_your_app | Configure Web Credentials with FCM}.
110
+ * See
111
+ * {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol | The Web Push Protocol}
112
+ * for details on web push services.
113
+ */
114
+ vapidKey?: string;
115
+ /**
116
+ * The service worker registration for receiving push
117
+ * messaging. If the registration is not provided explicitly, you need to have a
118
+ * `firebase-messaging-sw.js` at your root location. See
119
+ * {@link https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token | Access the registration token}
120
+ * for more details.
121
+ */
122
+ serviceWorkerRegistration?: ServiceWorkerRegistration;
123
+ }
124
+ /**
125
+ * Public interface of the Firebase Cloud Messaging SDK.
126
+ *
127
+ * @public
128
+ */
129
+ export interface Messaging {
130
+ /**
131
+ * The {@link @firebase/app#FirebaseApp} this `Messaging` instance is associated with.
132
+ */
133
+ app: FirebaseApp;
134
+ }
135
+ /**
136
+ * @internal
137
+ */
138
+ export type _FirebaseMessagingName = 'messaging';
139
+ export { NextFn, Observer, Unsubscribe } from '@firebase/util';
140
+ declare module '@firebase/component' {
141
+ interface NameServiceMapping {
142
+ 'messaging': Messaging;
143
+ }
144
+ }
@@ -0,0 +1,32 @@
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
+ export interface TokenDetails {
18
+ token: string;
19
+ createTime: number;
20
+ /** Does not exist in Safari since it's not using Push API. */
21
+ subscriptionOptions?: SubscriptionOptions;
22
+ }
23
+ /**
24
+ * Additional options and values required by a Push API subscription.
25
+ */
26
+ export interface SubscriptionOptions {
27
+ vapidKey: string;
28
+ swScope: string;
29
+ endpoint: string;
30
+ auth: string;
31
+ p256dh: string;
32
+ }
@@ -0,0 +1,27 @@
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 { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
18
+ import { TokenDetails } from '../interfaces/token-details';
19
+ export declare const DATABASE_NAME = "firebase-messaging-database";
20
+ /** Gets record(s) from the objectStore that match the given key. */
21
+ export declare function dbGet(firebaseDependencies: FirebaseInternalDependencies): Promise<TokenDetails | undefined>;
22
+ /** Assigns or overwrites the record for the given key with the given value. */
23
+ export declare function dbSet(firebaseDependencies: FirebaseInternalDependencies, tokenDetails: TokenDetails): Promise<TokenDetails>;
24
+ /** Removes record(s) from the objectStore that match the given key. */
25
+ export declare function dbRemove(firebaseDependencies: FirebaseInternalDependencies): Promise<void>;
26
+ /** Deletes the DB. Useful for tests. */
27
+ export declare function dbDelete(): Promise<void>;
@@ -0,0 +1,35 @@
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 { SubscriptionOptions, TokenDetails } from '../interfaces/token-details';
18
+ import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
19
+ export interface ApiResponse {
20
+ token?: string;
21
+ error?: {
22
+ message: string;
23
+ };
24
+ }
25
+ export interface ApiRequestBody {
26
+ web: {
27
+ endpoint: string;
28
+ p256dh: string;
29
+ auth: string;
30
+ applicationPubKey?: string;
31
+ };
32
+ }
33
+ export declare function requestGetToken(firebaseDependencies: FirebaseInternalDependencies, subscriptionOptions: SubscriptionOptions): Promise<string>;
34
+ export declare function requestUpdateToken(firebaseDependencies: FirebaseInternalDependencies, tokenDetails: TokenDetails): Promise<string>;
35
+ export declare function requestDeleteToken(firebaseDependencies: FirebaseInternalDependencies, token: string): Promise<void>;
@@ -0,0 +1,23 @@
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 { MessagingService } from '../messaging-service';
18
+ export declare function getTokenInternal(messaging: MessagingService): Promise<string>;
19
+ /**
20
+ * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters
21
+ * the push subscription if it exists.
22
+ */
23
+ export declare function deleteTokenInternal(messaging: MessagingService): Promise<boolean>;
@@ -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 {};