1
0
mirror of https://github.com/musix-org/musix-oss synced 2026-05-12 21:54:53 +00:00
This commit is contained in:
MatteZ02
2020-03-03 22:30:50 +02:00
parent edfcc6f474
commit 30022c7634
11800 changed files with 1984416 additions and 1 deletions
+68
View File
@@ -0,0 +1,68 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
import { FirebaseMessaging } from '@firebase/messaging-types';
import { MessagePayload } from '../interfaces/message-payload';
import { Unsubscribe } from '@firebase/util';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseService } from '@firebase/app-types/private';
export declare type BgMessageHandler = (payload: MessagePayload) => unknown;
export declare class SwController implements FirebaseMessaging, FirebaseService {
private readonly firebaseDependencies;
private vapidKey;
private bgMessageHandler;
constructor(firebaseDependencies: FirebaseInternalDependencies);
get app(): FirebaseApp;
/**
* Calling setBackgroundMessageHandler will opt in to some specific
* behaviours.
* 1.) If a notification doesn't need to be shown due to a window already
* being visible, then push messages will be sent to the page.
* 2.) If a notification needs to be shown, and the message contains no
* notification data this method will be called
* and the promise it returns will be passed to event.waitUntil.
* If you do not set this callback then all push messages will let and the
* developer can handle them in a their own 'push' event callback
*
* @param callback The callback to be called when a push message is received
* and a notification must be shown. The callback will be given the data from
* the push message.
*/
setBackgroundMessageHandler(callback: BgMessageHandler): void;
getToken(): Promise<string>;
deleteToken(): Promise<boolean>;
requestPermission(): Promise<void>;
usePublicVapidKey(vapidKey: string): void;
useServiceWorker(): void;
onMessage(): Unsubscribe;
onTokenRefresh(): Unsubscribe;
/**
* A handler for push events that shows notifications based on the content of
* the payload.
*
* The payload must be a JSON-encoded Object with a `notification` key. The
* value of the `notification` property will be used as the NotificationOptions
* object passed to showNotification. Additionally, the `title` property of the
* notification object will be used as the title.
*
* If there is no notification data in the payload then no notification will be
* shown.
*/
onPush(event: PushEvent): Promise<void>;
onSubChange(event: PushSubscriptionChangeEvent): Promise<void>;
onNotificationClick(event: NotificationEvent): Promise<void>;
}
@@ -0,0 +1 @@
import '../testing/setup';
@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
import { FirebaseMessaging } from '@firebase/messaging-types';
import { NextFn, Observer, Unsubscribe } from '@firebase/util';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseService } from '@firebase/app-types/private';
export declare class WindowController implements FirebaseMessaging, FirebaseService {
private readonly firebaseDependencies;
private vapidKey;
private swRegistration?;
private onMessageCallback;
constructor(firebaseDependencies: FirebaseInternalDependencies);
get app(): FirebaseApp;
getToken(): Promise<string>;
deleteToken(): Promise<boolean>;
/**
* Request permission if it is not currently granted.
*
* @return Resolves if the permission was granted, rejects otherwise.
*
* @deprecated Use Notification.requestPermission() instead.
* https://developer.mozilla.org/en-US/docs/Web/API/Notification/requestPermission
*/
requestPermission(): Promise<void>;
usePublicVapidKey(vapidKey: string): void;
useServiceWorker(swRegistration: ServiceWorkerRegistration): void;
/**
* @param nextOrObserver An observer object or a function triggered on
* message.
* @return The unsubscribe function for the observer.
*/
onMessage(nextOrObserver: NextFn<object> | Observer<object>): Unsubscribe;
setBackgroundMessageHandler(): void;
onTokenRefresh(): Unsubscribe;
/**
* Creates or updates the default service worker registration.
* @return The service worker registration to be used for the push service.
*/
private getServiceWorkerRegistration;
private messageEventListener;
private logEvent;
}
@@ -0,0 +1 @@
import '../testing/setup';
+35
View File
@@ -0,0 +1,35 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TokenDetails, SubscriptionOptions } from '../interfaces/token-details';
import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
export interface ApiResponse {
token?: string;
error?: {
message: string;
};
}
export interface ApiRequestBody {
web: {
endpoint: string;
p256dh: string;
auth: string;
applicationPubKey?: string;
};
}
export declare function requestGetToken(firebaseDependencies: FirebaseInternalDependencies, subscriptionOptions: SubscriptionOptions): Promise<string>;
export declare function requestUpdateToken(firebaseDependencies: FirebaseInternalDependencies, tokenDetails: TokenDetails): Promise<string>;
export declare function requestDeleteToken(firebaseDependencies: FirebaseInternalDependencies, token: string): Promise<void>;
+17
View File
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
+23
View File
@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
export declare function getToken(firebaseDependencies: FirebaseInternalDependencies, swRegistration: ServiceWorkerRegistration, vapidKey: string): Promise<string>;
/**
* This method deletes the token from the database, unsubscribes the token from
* FCM, and unregisters the push subscription if it exists.
*/
export declare function deleteToken(firebaseDependencies: FirebaseInternalDependencies, swRegistration: ServiceWorkerRegistration): Promise<boolean>;
+17
View File
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
+17
View File
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function arrayToBase64(array: Uint8Array | ArrayBuffer): string;
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
+19
View File
@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseApp } from '@firebase/app-types';
import { AppConfig } from '../interfaces/app-config';
export declare function extractAppConfig(app: FirebaseApp): AppConfig;
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
+27
View File
@@ -0,0 +1,27 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TokenDetails } from '../interfaces/token-details';
import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
export declare const DATABASE_NAME = "firebase-messaging-database";
/** Gets record(s) from the objectStore that match the given key. */
export declare function dbGet(firebaseDependencies: FirebaseInternalDependencies): Promise<TokenDetails | undefined>;
/** Assigns or overwrites the record for the given key with the given value. */
export declare function dbSet(firebaseDependencies: FirebaseInternalDependencies, tokenDetails: TokenDetails): Promise<TokenDetails>;
/** Removes record(s) from the objectStore that match the given key. */
export declare function dbRemove(firebaseDependencies: FirebaseInternalDependencies): Promise<void>;
/** Deletes the DB. Useful for tests. */
export declare function dbDelete(): Promise<void>;
+17
View File
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
+18
View File
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ConsoleMessageData } from '../interfaces/message-payload';
export declare function isConsoleMessage(data: unknown): data is ConsoleMessageData;
@@ -0,0 +1,51 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TokenDetails } from '../interfaces/token-details';
export interface V2TokenDetails {
fcmToken: string;
swScope: string;
vapidKey: string | Uint8Array;
subscription: PushSubscription;
fcmSenderId: string;
fcmPushSet: string;
createTime?: number;
endpoint?: string;
auth?: string;
p256dh?: string;
}
export interface V3TokenDetails {
fcmToken: string;
swScope: string;
vapidKey: Uint8Array;
fcmSenderId: string;
fcmPushSet: string;
endpoint: string;
auth: ArrayBuffer;
p256dh: ArrayBuffer;
createTime: number;
}
export interface V4TokenDetails {
fcmToken: string;
swScope: string;
vapidKey: Uint8Array;
fcmSenderId: string;
endpoint: string;
auth: ArrayBufferLike;
p256dh: ArrayBufferLike;
createTime: number;
}
export declare function migrateOldDatabase(senderId: string): Promise<TokenDetails | null>;
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
+18
View File
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Returns a promise that resolves after given time passes. */
export declare function sleep(ms: number): Promise<void>;
+17
View File
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+32
View File
@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '@firebase/installations';
import { FirebaseMessaging } from '@firebase/messaging-types';
/**
* Define extension behavior of `registerMessaging`
*/
declare module '@firebase/app-types' {
interface FirebaseNamespace {
messaging: {
(app?: FirebaseApp): FirebaseMessaging;
isSupported(): boolean;
};
}
interface FirebaseApp {
messaging(): FirebaseMessaging;
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+24
View File
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface AppConfig {
readonly appName: string;
readonly projectId: string;
readonly apiKey: string;
readonly appId: string;
/** Only used for old DB migration. */
readonly senderId: string;
}
@@ -0,0 +1,27 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseInstallations } from '@firebase/installations-types';
import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
import { Provider } from '@firebase/component';
import { AppConfig } from './app-config';
import { FirebaseApp } from '@firebase/app-types';
export interface FirebaseInternalDependencies {
app: FirebaseApp;
appConfig: AppConfig;
installations: FirebaseInstallations;
analyticsProvider: Provider<FirebaseAnalyticsInternalName>;
}
+27
View File
@@ -0,0 +1,27 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MessagePayload } from './message-payload';
export declare enum MessageType {
PUSH_RECEIVED = "push-received",
NOTIFICATION_CLICKED = "notification-clicked"
}
export interface InternalMessage {
firebaseMessaging: {
type: MessageType;
payload: MessagePayload;
};
}
+36
View File
@@ -0,0 +1,36 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CONSOLE_CAMPAIGN_ID, CONSOLE_CAMPAIGN_TIME, CONSOLE_CAMPAIGN_NAME, CONSOLE_CAMPAIGN_ANALYTICS_ENABLED } from '../util/constants';
export interface NotificationDetails extends NotificationOptions {
title: string;
click_action?: string;
}
export interface FcmOptions {
link?: string;
}
export interface MessagePayload {
fcmOptions?: FcmOptions;
notification?: NotificationDetails;
data?: unknown;
}
/** Additional data of a message sent from the FN Console. */
export interface ConsoleMessageData {
[CONSOLE_CAMPAIGN_ID]: string;
[CONSOLE_CAMPAIGN_TIME]: string;
[CONSOLE_CAMPAIGN_NAME]?: string;
[CONSOLE_CAMPAIGN_ANALYTICS_ENABLED]?: '1';
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface TokenDetails {
token: string;
createTime: number;
/** Does not exist in Safari since it's not using Push API. */
subscriptionOptions?: SubscriptionOptions;
}
/**
* Additional options and values required by a Push API subscription.
*/
export interface SubscriptionOptions {
vapidKey: string;
swScope: string;
endpoint: string;
auth: string;
p256dh: string;
}
+22
View File
@@ -0,0 +1,22 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
declare class HeadersWithEntries extends Headers {
entries?(): Iterable<[string, string]>;
}
export declare function compareHeaders(expectedHeaders: HeadersWithEntries, actualHeaders: HeadersWithEntries): void;
export {};
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../testing/setup';
@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseApp, FirebaseOptions } from '@firebase/app-types';
import { FirebaseInternalDependencies } from '../../interfaces/internal-dependencies';
export declare function getFakeFirebaseDependencies(options?: FirebaseOptions): FirebaseInternalDependencies;
export declare function getFakeApp(options?: FirebaseOptions): FirebaseApp;
@@ -0,0 +1,83 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function mockServiceWorker(): void;
export declare function restoreServiceWorker(): void;
export declare class FakeServiceWorkerRegistration implements ServiceWorkerRegistration {
active: null;
installing: null;
waiting: null;
onupdatefound: null;
pushManager: FakePushManager;
scope: string;
navigationPreload: NavigationPreloadManager;
sync: SyncManager;
updateViaCache: ServiceWorkerUpdateViaCache;
getNotifications(): Promise<never[]>;
showNotification(): Promise<void>;
update(): Promise<void>;
unregister(): Promise<boolean>;
addEventListener(): void;
removeEventListener(): void;
dispatchEvent(): boolean;
}
declare class FakePushManager implements PushManager {
private subscription;
permissionState(): Promise<"granted">;
getSubscription(): Promise<FakePushSubscription | null>;
subscribe(): Promise<FakePushSubscription>;
}
export declare class FakePushSubscription implements PushSubscription {
endpoint: string;
expirationTime: number;
auth: string;
p256: string;
getKey(name: PushEncryptionKeyName): Uint8Array;
unsubscribe(): Promise<boolean>;
toJSON: () => PushSubscriptionJSON;
options: PushSubscriptionOptions;
}
/**
* Most of the fields in here are unused / deprecated.
* They are only added here to match the TS Event interface.
*/
export declare class FakeEvent implements ExtendableEvent {
type: string;
NONE: number;
AT_TARGET: number;
BUBBLING_PHASE: number;
CAPTURING_PHASE: number;
bubbles: boolean;
cancelable: boolean;
composed: boolean;
timeStamp: number;
isTrusted: boolean;
eventPhase: number;
target: null;
currentTarget: null;
srcElement: null;
cancelBubble: boolean;
defaultPrevented: boolean;
returnValue: boolean;
preventDefault(): void;
stopPropagation(): void;
stopImmediatePropagation(): void;
initEvent(): void;
waitUntil(): void;
composedPath(): never[];
constructor(type: string, options?: EventInit);
}
export {};
+18
View File
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TokenDetails } from '../../interfaces/token-details';
export declare function getFakeTokenDetails(): TokenDetails;
+17
View File
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};
+19
View File
@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { SinonStub, SinonSpy } from 'sinon';
export declare type Stub<T extends (...args: any) => any> = SinonStub<Parameters<T>, ReturnType<T>>;
export declare type Spy<T extends (...args: any) => any> = SinonSpy<Parameters<T>, ReturnType<T>>;
+27
View File
@@ -0,0 +1,27 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const DEFAULT_SW_PATH = "/firebase-messaging-sw.js";
export declare const DEFAULT_SW_SCOPE = "/firebase-cloud-messaging-push-scope";
export declare const DEFAULT_VAPID_KEY = "BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4";
export declare const ENDPOINT = "https://fcmregistrations.googleapis.com/v1";
/** Key of FCM Payload in Notification's data field. */
export declare const FCM_MSG = "FCM_MSG";
export declare const CONSOLE_CAMPAIGN_ID = "google.c.a.c_id";
export declare const CONSOLE_CAMPAIGN_NAME = "google.c.a.c_l";
export declare const CONSOLE_CAMPAIGN_TIME = "google.c.a.ts";
/** Set to '1' if Analytics is enabled for the campaign */
export declare const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = "google.c.a.e";
+56
View File
@@ -0,0 +1,56 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ErrorFactory, ErrorMap } from '@firebase/util';
export declare const enum ErrorCode {
MISSING_APP_CONFIG_VALUES = "missing-app-config-values",
AVAILABLE_IN_WINDOW = "only-available-in-window",
AVAILABLE_IN_SW = "only-available-in-sw",
PERMISSION_DEFAULT = "permission-default",
PERMISSION_BLOCKED = "permission-blocked",
UNSUPPORTED_BROWSER = "unsupported-browser",
FAILED_DEFAULT_REGISTRATION = "failed-service-worker-registration",
TOKEN_SUBSCRIBE_FAILED = "token-subscribe-failed",
TOKEN_SUBSCRIBE_NO_TOKEN = "token-subscribe-no-token",
TOKEN_UNSUBSCRIBE_FAILED = "token-unsubscribe-failed",
TOKEN_UPDATE_FAILED = "token-update-failed",
TOKEN_UPDATE_NO_TOKEN = "token-update-no-token",
INVALID_BG_HANDLER = "invalid-bg-handler",
USE_SW_AFTER_GET_TOKEN = "use-sw-after-get-token",
INVALID_SW_REGISTRATION = "invalid-sw-registration",
USE_VAPID_KEY_AFTER_GET_TOKEN = "use-vapid-key-after-get-token",
INVALID_VAPID_KEY = "invalid-vapid-key"
}
export declare const ERROR_MAP: ErrorMap<ErrorCode>;
interface ErrorParams {
[ErrorCode.MISSING_APP_CONFIG_VALUES]: {
valueName: string;
};
[ErrorCode.FAILED_DEFAULT_REGISTRATION]: {
browserErrorMessage: string;
};
[ErrorCode.TOKEN_SUBSCRIBE_FAILED]: {
errorInfo: string;
};
[ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]: {
errorInfo: string;
};
[ErrorCode.TOKEN_UPDATE_FAILED]: {
errorInfo: string;
};
}
export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
export {};
+89
View File
@@ -0,0 +1,89 @@
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Subset of Web Worker types from lib.webworker.d.ts
* https://github.com/Microsoft/TypeScript/blob/master/lib/lib.webworker.d.ts
*
* Since it's not possible to have both "dom" and "webworker" libs in a single
* project, we have to manually declare the web worker types we need.
*/
interface ServiceWorkerGlobalScope {
readonly location: WorkerLocation;
readonly clients: Clients;
readonly registration: ServiceWorkerRegistration;
addEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
}
interface ServiceWorkerGlobalScopeEventMap {
notificationclick: NotificationEvent;
push: PushEvent;
pushsubscriptionchange: PushSubscriptionChangeEvent;
}
interface Client {
readonly id: string;
readonly type: ClientTypes;
readonly url: string;
postMessage(message: any, transfer?: Transferable[]): void;
}
interface ClientQueryOptions {
includeReserved?: boolean;
includeUncontrolled?: boolean;
type?: ClientTypes;
}
interface WindowClient extends Client {
readonly focused: boolean;
readonly visibilityState: VisibilityState;
focus(): Promise<WindowClient>;
navigate(url: string): Promise<WindowClient>;
}
interface Clients {
claim(): Promise<void>;
get(id: string): Promise<any>;
matchAll(options?: ClientQueryOptions): Promise<Client[]>;
openWindow(url: string): Promise<WindowClient | null>;
}
interface ExtendableEvent extends Event {
waitUntil(f: Promise<any>): void;
}
interface NotificationEvent extends ExtendableEvent {
readonly action: string;
readonly notification: Notification;
}
interface PushMessageData {
arrayBuffer(): ArrayBuffer;
blob(): Blob;
json(): any;
text(): string;
}
interface PushEvent extends ExtendableEvent {
readonly data: PushMessageData | null;
}
interface PushSubscriptionChangeEvent extends ExtendableEvent {
readonly newSubscription: PushSubscription | null;
readonly oldSubscription: PushSubscription | null;
}
interface WorkerLocation {
readonly hash: string;
readonly host: string;
readonly hostname: string;
readonly href: string;
readonly origin: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
readonly search: string;
toString(): string;
}