@firebase/messaging 0.9.1 → 0.9.2-canary.2322b6023

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 (125) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{index.esm.js → esm/index.esm.js} +8 -2
  3. package/dist/esm/index.esm.js.map +1 -0
  4. package/dist/{index.esm2017.js → esm/index.esm2017.js} +8 -2
  5. package/dist/esm/index.esm2017.js.map +1 -0
  6. package/dist/esm/package.json +1 -0
  7. package/dist/{api → esm/src/api}/deleteToken.d.ts +0 -0
  8. package/dist/{api → esm/src/api}/getToken.d.ts +0 -0
  9. package/dist/{api → esm/src/api}/isSupported.d.ts +0 -0
  10. package/dist/{api → esm/src/api}/onBackgroundMessage.d.ts +0 -0
  11. package/dist/{api → esm/src/api}/onMessage.d.ts +0 -0
  12. package/dist/{api → esm/src/api}/setDeliveryMetricsExportedToBigQueryEnabled.d.ts +0 -0
  13. package/dist/{api.d.ts → esm/src/api.d.ts} +0 -0
  14. package/dist/{helpers → esm/src/helpers}/array-base64-translator.d.ts +0 -0
  15. package/dist/{helpers → esm/src/helpers}/array-base64-translator.test.d.ts +0 -0
  16. package/dist/{helpers → esm/src/helpers}/externalizePayload.d.ts +0 -0
  17. package/dist/{helpers → esm/src/helpers}/externalizePayload.test.d.ts +0 -0
  18. package/dist/{helpers → esm/src/helpers}/extract-app-config.d.ts +0 -0
  19. package/dist/{helpers → esm/src/helpers}/extract-app-config.test.d.ts +0 -0
  20. package/dist/{helpers → esm/src/helpers}/is-console-message.d.ts +0 -0
  21. package/dist/{helpers → esm/src/helpers}/logToFirelog.d.ts +0 -0
  22. package/dist/{helpers → esm/src/helpers}/logToFirelog.test.d.ts +0 -0
  23. package/dist/{helpers → esm/src/helpers}/logToScion.d.ts +0 -0
  24. package/dist/{helpers → esm/src/helpers}/migrate-old-database.d.ts +0 -0
  25. package/dist/{helpers → esm/src/helpers}/migrate-old-database.test.d.ts +0 -0
  26. package/dist/{helpers → esm/src/helpers}/register.d.ts +0 -0
  27. package/dist/{helpers → esm/src/helpers}/registerDefaultSw.d.ts +0 -0
  28. package/dist/{helpers → esm/src/helpers}/sleep.d.ts +0 -0
  29. package/dist/{helpers → esm/src/helpers}/sleep.test.d.ts +0 -0
  30. package/dist/{helpers → esm/src/helpers}/updateSwReg.d.ts +0 -0
  31. package/dist/{helpers → esm/src/helpers}/updateVapidKey.d.ts +0 -0
  32. package/dist/{index.d.ts → esm/src/index.d.ts} +0 -0
  33. package/dist/{index.sw.d.ts → esm/src/index.sw.d.ts} +0 -0
  34. package/dist/{interfaces → esm/src/interfaces}/app-config.d.ts +0 -0
  35. package/dist/{interfaces → esm/src/interfaces}/internal-dependencies.d.ts +0 -0
  36. package/dist/{interfaces → esm/src/interfaces}/internal-message-payload.d.ts +0 -0
  37. package/dist/{interfaces → esm/src/interfaces}/logging-types.d.ts +0 -0
  38. package/dist/{interfaces → esm/src/interfaces}/public-types.d.ts +0 -0
  39. package/dist/{interfaces → esm/src/interfaces}/token-details.d.ts +0 -0
  40. package/dist/{internals → esm/src/internals}/idb-manager.d.ts +0 -0
  41. package/dist/{internals → esm/src/internals}/idb-manager.test.d.ts +0 -0
  42. package/dist/{internals → esm/src/internals}/requests.d.ts +0 -0
  43. package/dist/{internals → esm/src/internals}/requests.test.d.ts +0 -0
  44. package/dist/{internals → esm/src/internals}/token-manager.d.ts +0 -0
  45. package/dist/{internals → esm/src/internals}/token-manager.test.d.ts +0 -0
  46. package/dist/{listeners → esm/src/listeners}/sw-listeners.d.ts +0 -0
  47. package/dist/{listeners → esm/src/listeners}/sw-listeners.test.d.ts +0 -0
  48. package/dist/{listeners → esm/src/listeners}/window-listener.d.ts +0 -0
  49. package/dist/{messaging-service.d.ts → esm/src/messaging-service.d.ts} +0 -0
  50. package/dist/{testing → esm/src/testing}/compare-headers.d.ts +0 -0
  51. package/dist/{testing → esm/src/testing}/compare-headers.test.d.ts +0 -0
  52. package/dist/{testing → esm/src/testing}/fakes/firebase-dependencies.d.ts +0 -0
  53. package/dist/{testing → esm/src/testing}/fakes/logging-object.d.ts +0 -0
  54. package/dist/{testing → esm/src/testing}/fakes/messaging-service.d.ts +0 -0
  55. package/dist/{testing → esm/src/testing}/fakes/service-worker.d.ts +0 -0
  56. package/dist/{testing → esm/src/testing}/fakes/token-details.d.ts +0 -0
  57. package/dist/{testing → esm/src/testing}/setup.d.ts +0 -0
  58. package/dist/{testing → esm/src/testing}/sinon-types.d.ts +0 -0
  59. package/dist/{util → esm/src/util}/constants.d.ts +0 -0
  60. package/dist/{util → esm/src/util}/errors.d.ts +0 -0
  61. package/dist/{util → esm/src/util}/sw-types.d.ts +0 -0
  62. package/dist/index.cjs.js +7 -1
  63. package/dist/index.cjs.js.map +1 -1
  64. package/dist/index.sw.esm2017.js +1 -1
  65. package/dist/index.sw.esm2017.js.map +1 -1
  66. package/dist/src/api/deleteToken.d.ts +18 -0
  67. package/dist/src/api/getToken.d.ts +19 -0
  68. package/dist/src/api/isSupported.d.ts +30 -0
  69. package/dist/src/api/onBackgroundMessage.d.ts +19 -0
  70. package/dist/src/api/onMessage.d.ts +19 -0
  71. package/dist/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts +18 -0
  72. package/dist/src/api.d.ts +101 -0
  73. package/dist/src/helpers/array-base64-translator.d.ts +18 -0
  74. package/dist/src/helpers/array-base64-translator.test.d.ts +17 -0
  75. package/dist/src/helpers/externalizePayload.d.ts +19 -0
  76. package/dist/src/helpers/externalizePayload.test.d.ts +17 -0
  77. package/dist/src/helpers/extract-app-config.d.ts +19 -0
  78. package/dist/src/helpers/extract-app-config.test.d.ts +17 -0
  79. package/dist/src/helpers/is-console-message.d.ts +18 -0
  80. package/dist/src/helpers/logToFirelog.d.ts +30 -0
  81. package/dist/src/helpers/logToFirelog.test.d.ts +17 -0
  82. package/dist/src/helpers/logToScion.d.ts +19 -0
  83. package/dist/src/helpers/migrate-old-database.d.ts +51 -0
  84. package/dist/src/helpers/migrate-old-database.test.d.ts +17 -0
  85. package/dist/src/helpers/register.d.ts +23 -0
  86. package/dist/src/helpers/registerDefaultSw.d.ts +18 -0
  87. package/dist/src/helpers/sleep.d.ts +18 -0
  88. package/dist/src/helpers/sleep.test.d.ts +17 -0
  89. package/dist/src/helpers/updateSwReg.d.ts +18 -0
  90. package/dist/src/helpers/updateVapidKey.d.ts +18 -0
  91. package/dist/src/index.d.ts +31 -0
  92. package/dist/src/index.sw.d.ts +26 -0
  93. package/dist/src/interfaces/app-config.d.ts +24 -0
  94. package/dist/src/interfaces/internal-dependencies.d.ts +27 -0
  95. package/dist/src/interfaces/internal-message-payload.d.ts +44 -0
  96. package/dist/src/interfaces/logging-types.d.ts +50 -0
  97. package/dist/src/interfaces/public-types.d.ts +139 -0
  98. package/dist/src/interfaces/token-details.d.ts +32 -0
  99. package/dist/src/internals/idb-manager.d.ts +27 -0
  100. package/dist/src/internals/idb-manager.test.d.ts +17 -0
  101. package/dist/src/internals/requests.d.ts +35 -0
  102. package/dist/src/internals/requests.test.d.ts +17 -0
  103. package/dist/src/internals/token-manager.d.ts +23 -0
  104. package/dist/src/internals/token-manager.test.d.ts +17 -0
  105. package/dist/src/listeners/sw-listeners.d.ts +21 -0
  106. package/dist/src/listeners/sw-listeners.test.d.ts +17 -0
  107. package/dist/src/listeners/window-listener.d.ts +18 -0
  108. package/dist/src/messaging-service.d.ts +36 -0
  109. package/dist/src/testing/compare-headers.d.ts +22 -0
  110. package/dist/src/testing/compare-headers.test.d.ts +17 -0
  111. package/dist/src/testing/fakes/firebase-dependencies.d.ts +25 -0
  112. package/dist/src/testing/fakes/logging-object.d.ts +18 -0
  113. package/dist/src/testing/fakes/messaging-service.d.ts +18 -0
  114. package/dist/src/testing/fakes/service-worker.d.ts +84 -0
  115. package/dist/src/testing/fakes/token-details.d.ts +18 -0
  116. package/dist/src/testing/setup.d.ts +17 -0
  117. package/dist/src/testing/sinon-types.d.ts +19 -0
  118. package/dist/{tsdoc-metadata.json → src/tsdoc-metadata.json} +0 -0
  119. package/dist/src/util/constants.d.ts +39 -0
  120. package/dist/src/util/errors.d.ts +57 -0
  121. package/dist/src/util/sw-types.d.ts +90 -0
  122. package/package.json +24 -15
  123. package/sw/package.json +1 -1
  124. package/dist/index.esm.js.map +0 -1
  125. package/dist/index.esm2017.js.map +0 -1
@@ -0,0 +1,50 @@
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
+ }
38
+ export interface LogResponse {
39
+ nextRequestWaitMillis: number;
40
+ logResponseDetails: LogResponseDetails[];
41
+ }
42
+ interface LogResponseDetails {
43
+ responseAction: UserResponse;
44
+ }
45
+ export declare const enum UserResponse {
46
+ RESPONSE_ACTION_UNKNOWN = "RESPONSE_ACTION_UNKNOWN",
47
+ RETRY_REQUEST_LATER = "RETRY_REQUEST_LATER",
48
+ DELETE_REQUEST = "DELETE_REQUEST"
49
+ }
50
+ export {};
@@ -0,0 +1,139 @@
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. They 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
+ /**
39
+ * Options for features provided by the FCM SDK for Web. See {@link
40
+ * https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions |
41
+ * WebpushFcmOptions}
42
+ *
43
+ * @public
44
+ */
45
+ export interface FcmOptions {
46
+ /**
47
+ * The link to open when the user clicks on the notification.
48
+ */
49
+ link?: string;
50
+ /**
51
+ * The label associated with the message's analytics data.
52
+ */
53
+ analyticsLabel?: string;
54
+ }
55
+ /**
56
+ * Message payload that contains the notification payload that is represented with
57
+ * {@link NotificationPayload} and the data payload that contains an arbitrary
58
+ * number of key-value pairs sent by developers through the
59
+ * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}
60
+ *
61
+ * @public
62
+ */
63
+ export interface MessagePayload {
64
+ /**
65
+ * {@inheritdoc NotificationPayload}
66
+ */
67
+ notification?: NotificationPayload;
68
+ /**
69
+ * Arbitrary key/value payload.
70
+ */
71
+ data?: {
72
+ [key: string]: string;
73
+ };
74
+ /**
75
+ * {@inheritdoc FcmOptions}
76
+ */
77
+ fcmOptions?: FcmOptions;
78
+ /**
79
+ * The sender of this message.
80
+ */
81
+ from: string;
82
+ /**
83
+ * The collapse key of the message. See
84
+ * {@link https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages | Non-collapsible and collapsible messages}
85
+ */
86
+ collapseKey: string;
87
+ /**
88
+ * The message id of a message.
89
+ */
90
+ messageId: string;
91
+ }
92
+ /**
93
+ * Options for {@link getToken}
94
+ *
95
+ * @public
96
+ */
97
+ export interface GetTokenOptions {
98
+ /**
99
+ * The public server key provided to push services. It is used to
100
+ * authenticate the push subscribers to receive push messages only from sending servers that hold
101
+ * the corresponding private key. If it is not provided, a default VAPID key is used. Note that some
102
+ * push services (Chrome Push Service) require a non-default VAPID key. Therefore, it is recommended
103
+ * to generate and import a VAPID key for your project with
104
+ * {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_with_fcm | Configure Web Credentials with FCM}.
105
+ * See
106
+ * {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol | The Web Push Protocol}
107
+ * for details on web push services.
108
+ */
109
+ vapidKey?: string;
110
+ /**
111
+ * The service worker registration for receiving push
112
+ * messaging. If the registration is not provided explicitly, you need to have a
113
+ * `firebase-messaging-sw.js` at your root location. See
114
+ * {@link https://firebase.google.com/docs/cloud-messaging/js/client#retrieve-the-current-registration-token | Retrieve the current registration token}
115
+ * for more details.
116
+ */
117
+ serviceWorkerRegistration?: ServiceWorkerRegistration;
118
+ }
119
+ /**
120
+ * Public interface of the Firebase Cloud Messaging SDK.
121
+ *
122
+ * @public
123
+ */
124
+ export interface Messaging {
125
+ /**
126
+ * The {@link @firebase/app#FirebaseApp} this `Messaging` instance is associated with.
127
+ */
128
+ app: FirebaseApp;
129
+ }
130
+ /**
131
+ * @internal
132
+ */
133
+ export declare type _FirebaseMessagingName = 'messaging';
134
+ export { NextFn, Observer, Unsubscribe } from '@firebase/util';
135
+ declare module '@firebase/component' {
136
+ interface NameServiceMapping {
137
+ 'messaging': Messaging;
138
+ }
139
+ }
@@ -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,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
+ import '../testing/setup';
@@ -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,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
+ import '../testing/setup';
@@ -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,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
+ import '../testing/setup';
@@ -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,17 @@
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 '../testing/setup';
@@ -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,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
+ import './setup';
@@ -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,84 @@
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
+ sync: SyncManager;
29
+ updateViaCache: ServiceWorkerUpdateViaCache;
30
+ getNotifications(): Promise<never[]>;
31
+ showNotification(): Promise<void>;
32
+ update(): Promise<void>;
33
+ unregister(): Promise<boolean>;
34
+ addEventListener(): void;
35
+ removeEventListener(): void;
36
+ dispatchEvent(): boolean;
37
+ }
38
+ declare class FakePushManager implements PushManager {
39
+ private subscription;
40
+ permissionState(): Promise<"granted">;
41
+ getSubscription(): Promise<FakePushSubscription | null>;
42
+ subscribe(): Promise<FakePushSubscription>;
43
+ }
44
+ export declare class FakePushSubscription implements PushSubscription {
45
+ endpoint: string;
46
+ expirationTime: number;
47
+ auth: string;
48
+ p256: string;
49
+ getKey(name: PushEncryptionKeyName): Uint8Array;
50
+ unsubscribe(): Promise<boolean>;
51
+ toJSON: () => PushSubscriptionJSON;
52
+ options: PushSubscriptionOptions;
53
+ }
54
+ /**
55
+ * Most of the fields in here are unused / deprecated. They are only added here to match the TS
56
+ * Event interface.
57
+ */
58
+ export declare class FakeEvent implements ExtendableEvent {
59
+ type: string;
60
+ NONE: number;
61
+ AT_TARGET: number;
62
+ BUBBLING_PHASE: number;
63
+ CAPTURING_PHASE: number;
64
+ bubbles: boolean;
65
+ cancelable: boolean;
66
+ composed: boolean;
67
+ timeStamp: number;
68
+ isTrusted: boolean;
69
+ eventPhase: number;
70
+ target: null;
71
+ currentTarget: null;
72
+ srcElement: null;
73
+ cancelBubble: boolean;
74
+ defaultPrevented: boolean;
75
+ returnValue: boolean;
76
+ preventDefault(): void;
77
+ stopPropagation(): void;
78
+ stopImmediatePropagation(): void;
79
+ initEvent(): void;
80
+ waitUntil(): void;
81
+ composedPath(): never[];
82
+ constructor(type: string, options?: EventInit);
83
+ }
84
+ export {};