Firebase Update

This commit is contained in:
Lukas Nowy
2018-12-22 23:30:39 +01:00
parent befb44764d
commit acffe619b3
11523 changed files with 1614327 additions and 930246 deletions

View File

@ -0,0 +1,5 @@
# @firebase/messaging
This is the Firebase Cloud Messaging component of the Firebase JS SDK.
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
import { _FirebaseNamespace } from '@firebase/app-types/private';
import { FirebaseMessaging } from '@firebase/messaging-types';
export declare function registerMessaging(instance: _FirebaseNamespace): void;
/**
* Define extension behavior of `registerMessaging`
*/
declare module '@firebase/app-types' {
interface FirebaseNamespace {
messaging: {
(app?: FirebaseApp): FirebaseMessaging;
isSupported(): boolean;
};
}
interface FirebaseApp {
messaging(): FirebaseMessaging;
}
}
export declare function isSupported(): boolean;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,90 @@
/**
* 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 } from '@firebase/app-types';
import { FirebaseServiceInternals } from '@firebase/app-types/private';
import { FirebaseMessaging } from '@firebase/messaging-types';
import { CompleteFn, ErrorFn, NextFn, Observer, Unsubscribe } from '@firebase/util';
import { MessagePayload } from '../interfaces/message-payload';
import { IidModel } from '../models/iid-model';
import { TokenDetailsModel } from '../models/token-details-model';
import { VapidDetailsModel } from '../models/vapid-details-model';
export declare type BgMessageHandler = (payload: MessagePayload) => Promise<any> | void;
export declare const TOKEN_EXPIRATION_MILLIS: number;
export declare abstract class BaseController implements FirebaseMessaging {
app: FirebaseApp;
INTERNAL: FirebaseServiceInternals;
private readonly messagingSenderId;
private readonly tokenDetailsModel;
private readonly vapidDetailsModel;
private readonly iidModel;
/**
* An interface of the Messaging Service API
*/
constructor(app: FirebaseApp);
/**
* @export
*/
getToken(): Promise<string | null>;
/**
* manageExistingToken is triggered if there's an existing FCM token in the
* database and it can take 3 different actions:
* 1) Retrieve the existing FCM token from the database.
* 2) If VAPID details have changed: Delete the existing token and create a
* new one with the new VAPID key.
* 3) If the database cache is invalidated: Send a request to FCM to update
* the token, and to check if the token is still valid on FCM-side.
*/
private manageExistingToken(swReg, pushSubscription, publicVapidKey, tokenDetails);
private updateToken(swReg, pushSubscription, publicVapidKey, tokenDetails);
private getNewToken(swReg, pushSubscription, publicVapidKey);
/**
* This method deletes tokens that the token manager looks after,
* unsubscribes the token from FCM and then unregisters the push
* subscription if it exists. It returns a promise that indicates
* whether or not the unsubscribe request was processed successfully.
*/
deleteToken(token: string): Promise<boolean>;
/**
* This method will delete the token from the client database, and make a
* call to FCM to remove it from the server DB. Does not temper with the
* push subscription.
*/
private deleteTokenFromDB(token);
abstract getSWRegistration_(): Promise<ServiceWorkerRegistration>;
abstract getPublicVapidKey_(): Promise<Uint8Array>;
/**
* Gets a PushSubscription for the current user.
*/
getPushSubscription(swRegistration: ServiceWorkerRegistration, publicVapidKey: Uint8Array): Promise<PushSubscription>;
requestPermission(): Promise<void>;
useServiceWorker(registration: ServiceWorkerRegistration): void;
usePublicVapidKey(b64PublicKey: string): void;
onMessage(nextOrObserver: NextFn<object> | Observer<object>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
onTokenRefresh(nextOrObserver: NextFn<object> | Observer<object>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
setBackgroundMessageHandler(callback: BgMessageHandler): void;
/**
* This method is required to adhere to the Firebase interface.
* It closes any currently open indexdb database connections.
*/
delete(): Promise<void>;
/**
* Returns the current Notification Permission state.
*/
getNotificationPermission_(): NotificationPermission;
getTokenDetailsModel(): TokenDetailsModel;
getVapidDetailsModel(): VapidDetailsModel;
getIidModel(): IidModel;
}

View File

@ -0,0 +1,94 @@
/**
* 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 './sw-types';
import { FirebaseApp } from '@firebase/app-types';
import { MessagePayload, NotificationDetails } from '../interfaces/message-payload';
import { InternalMessage } from '../models/worker-page-message';
import { BaseController, BgMessageHandler } from './base-controller';
export declare class SwController extends BaseController {
private bgMessageHandler;
constructor(app: FirebaseApp);
onPush(event: PushEvent): void;
onSubChange(event: PushSubscriptionChangeEvent): void;
onNotificationClick(event: NotificationEvent): void;
/**
* 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.
*/
private onPush_(event);
private onSubChange_(event);
private onNotificationClick_(event);
getNotificationData_(msgPayload: MessagePayload): NotificationDetails | undefined;
/**
* 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;
/**
* @param url The URL to look for when focusing a client.
* @return Returns an existing window client or a newly opened WindowClient.
*/
getWindowClient_(url: string): Promise<WindowClient | null>;
/**
* This message will attempt to send the message to a window client.
* @param client The WindowClient to send the message to.
* @param message The message to send to the client.
* @returns Returns a promise that resolves after sending the message. This
* does not guarantee that the message was successfully received.
*/
attemptToMessageClient_(client: WindowClient, message: InternalMessage): Promise<void>;
/**
* @returns If there is currently a visible WindowClient, this method will
* resolve to true, otherwise false.
*/
hasVisibleClients_(): Promise<boolean>;
/**
* @param msgPayload The data from the push event that should be sent to all
* available pages.
* @returns Returns a promise that resolves once the message has been sent to
* all WindowClients.
*/
sendMessageToWindowClients_(msgPayload: MessagePayload): Promise<void>;
/**
* This will register the default service worker and return the registration.
* @return he service worker registration to be used for the push service.
*/
getSWRegistration_(): Promise<ServiceWorkerRegistration>;
/**
* This will return the default VAPID key or the uint8array version of the
* public VAPID key provided by the developer.
*/
getPublicVapidKey_(): Promise<Uint8Array>;
}

View File

@ -0,0 +1,90 @@
/**
* 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 reserved: boolean;
readonly type: ClientTypes;
readonly url: string;
postMessage(message: any, transfer?: any[]): void;
}
interface ClientQueryOptions {
includeReserved?: boolean;
includeUncontrolled?: boolean;
type?: ClientTypes;
}
interface WindowClient extends Client {
readonly ancestorOrigins: ReadonlyArray<string>;
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;
}

View File

@ -0,0 +1,109 @@
/**
* 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 } from '@firebase/app-types';
import { CompleteFn, ErrorFn, NextFn, Observer, Unsubscribe } from '@firebase/util';
import { BaseController } from './base-controller';
export declare class WindowController extends BaseController {
private registrationToUse;
private publicVapidKeyToUse;
private manifestCheckPromise;
private messageObserver;
private tokenRefreshObserver;
private readonly onMessageInternal;
private readonly onTokenRefreshInternal;
/**
* A service that provides a MessagingService instance.
*/
constructor(app: FirebaseApp);
/**
* This method returns an FCM token if it can be generated.
* The return promise will reject if the browser doesn't support
* FCM, if permission is denied for notifications or it's not
* possible to generate a token.
*
* @return Returns a promise that resolves to an FCM token or null if
* permission isn't granted.
*/
getToken(): Promise<string | null>;
/**
* Request permission if it is not currently granted
*
* @return Resolves if the permission was granted, otherwise rejects
*/
requestPermission(): Promise<void>;
/**
* This method allows a developer to override the default service worker and
* instead use a custom service worker.
*
* @param registration The service worker registration that should be used to
* receive the push messages.
*/
useServiceWorker(registration: ServiceWorkerRegistration): void;
/**
* This method allows a developer to override the default vapid key
* and instead use a custom VAPID public key.
*
* @param publicKey A URL safe base64 encoded string.
*/
usePublicVapidKey(publicKey: string): void;
/**
* @export
* @param nextOrObserver An observer object or a function triggered on
* message.
* @param error A function triggered on message error.
* @param completed function triggered when the observer is removed.
* @return The unsubscribe function for the observer.
*/
onMessage(nextOrObserver: NextFn<object> | Observer<object>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
/**
* @param nextOrObserver An observer object or a function triggered on token
* refresh.
* @param error A function triggered on token refresh error.
* @param completed function triggered when the observer is removed.
* @return The unsubscribe function for the observer.
*/
onTokenRefresh(nextOrObserver: NextFn<object> | Observer<object>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
/**
* Given a registration, wait for the service worker it relates to
* become activer
* @param registration Registration to wait for service worker to become active
* @return Wait for service worker registration to become active
*/
waitForRegistrationToActivate_(registration: ServiceWorkerRegistration): Promise<ServiceWorkerRegistration>;
/**
* This will register the default service worker and return the registration
* @return The service worker registration to be used for the push service.
*/
getSWRegistration_(): Promise<ServiceWorkerRegistration>;
/**
* This will return the default VAPID key or the uint8array version of the public VAPID key
* provided by the developer.
*/
getPublicVapidKey_(): Promise<Uint8Array>;
/**
* This method will set up a message listener to handle
* events from the service worker that should trigger
* events in the page.
*/
setupSWMessageListener_(): void;
}
/**
* The method checks that a manifest is defined and has the correct GCM
* sender ID.
* @return Returns a promise that resolves if the manifest matches
* our required sender ID
*/
export declare function manifestCheck(): Promise<void>;

View File

@ -0,0 +1 @@
export declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer | Uint8Array): string;

View File

@ -0,0 +1,16 @@
/**
* 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 base64ToArrayBuffer(base64String: string): Uint8Array;

View File

@ -0,0 +1,16 @@
/**
* 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 declare function isArrayBufferEqual(a: ArrayBufferLike | undefined | null, b: ArrayBufferLike | undefined | null): boolean;

View File

@ -0,0 +1,27 @@
/**
* 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 NotificationDetails extends NotificationOptions {
title: string;
click_action?: string;
}
export interface FcmOptions {
link?: string;
}
export interface MessagePayload {
fcmOptions?: FcmOptions;
notification?: NotificationDetails;
data?: object;
}

View File

@ -0,0 +1,26 @@
/**
* 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 {
fcmToken: string;
swScope: string;
vapidKey: Uint8Array;
fcmSenderId: string;
fcmPushSet: string;
endpoint: string;
auth: ArrayBufferLike;
p256dh: ArrayBufferLike;
createTime: number;
}

View File

@ -0,0 +1,19 @@
/**
* 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 VapidDetails {
swScope: string;
vapidKey: Uint8Array;
}

View File

@ -0,0 +1 @@
export declare function cleanV1(): void;

View File

@ -0,0 +1,48 @@
/**
* 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 abstract class DbInterface {
private dbPromise;
protected readonly abstract dbName: string;
protected readonly abstract dbVersion: number;
protected readonly abstract objectStoreName: string;
/**
* Database initialization.
*
* This function should create and update object stores.
*/
protected abstract onDbUpgrade(request: IDBOpenDBRequest, event: IDBVersionChangeEvent): void;
/** Gets record(s) from the objectStore that match the given key. */
get<T>(key: IDBValidKey): Promise<T | undefined>;
/** Gets record(s) from the objectStore that match the given index. */
getIndex<T>(index: string, key: IDBValidKey): Promise<T | undefined>;
/** Assigns or overwrites the record for the given value. */
put(value: any): Promise<void>;
/** Deletes record(s) from the objectStore that match the given key. */
delete(key: IDBValidKey | IDBKeyRange): Promise<void>;
/**
* Close the currently open database.
*/
closeDatabase(): Promise<void>;
/**
* Creates an IndexedDB Transaction and passes its objectStore to the
* runRequest function, which runs the database request.
*
* @return Promise that resolves with the result of the runRequest function
*/
private createTransaction<T>(runRequest, mode?);
/** Gets the cached db connection or opens a new one. */
private getDb();
}

View File

@ -0,0 +1,17 @@
/**
* 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 const DEFAULT_SW_PATH = "/firebase-messaging-sw.js";
export declare const DEFAULT_SW_SCOPE = "/firebase-cloud-messaging-push-scope";

View File

@ -0,0 +1,61 @@
/**
* 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 } from '@firebase/util';
export declare const ERROR_CODES: {
AVAILABLE_IN_WINDOW: string;
AVAILABLE_IN_SW: string;
SHOULD_BE_INHERITED: string;
BAD_SENDER_ID: string;
INCORRECT_GCM_SENDER_ID: string;
PERMISSION_DEFAULT: string;
PERMISSION_BLOCKED: string;
UNSUPPORTED_BROWSER: string;
NOTIFICATIONS_BLOCKED: string;
FAILED_DEFAULT_REGISTRATION: string;
SW_REGISTRATION_EXPECTED: string;
GET_SUBSCRIPTION_FAILED: string;
INVALID_SAVED_TOKEN: string;
SW_REG_REDUNDANT: string;
TOKEN_SUBSCRIBE_FAILED: string;
TOKEN_SUBSCRIBE_NO_TOKEN: string;
TOKEN_SUBSCRIBE_NO_PUSH_SET: string;
TOKEN_UNSUBSCRIBE_FAILED: string;
TOKEN_UPDATE_FAILED: string;
TOKEN_UPDATE_NO_TOKEN: string;
USE_SW_BEFORE_GET_TOKEN: string;
INVALID_DELETE_TOKEN: string;
DELETE_TOKEN_NOT_FOUND: string;
DELETE_SCOPE_NOT_FOUND: string;
BG_HANDLER_FUNCTION_EXPECTED: string;
NO_WINDOW_CLIENT_TO_MSG: string;
UNABLE_TO_RESUBSCRIBE: string;
NO_FCM_TOKEN_FOR_RESUBSCRIBE: string;
FAILED_TO_DELETE_TOKEN: string;
NO_SW_IN_REG: string;
BAD_SCOPE: string;
BAD_VAPID_KEY: string;
BAD_SUBSCRIPTION: string;
BAD_TOKEN: string;
BAD_PUSH_SET: string;
FAILED_DELETE_VAPID_KEY: string;
INVALID_PUBLIC_VAPID_KEY: string;
USE_PUBLIC_KEY_BEFORE_GET_TOKEN: string;
PUBLIC_KEY_DECRYPTION_FAILED: string;
};
export declare const ERROR_MAP: {
[x: string]: string;
};
export declare const errorFactory: ErrorFactory<string>;

View File

@ -0,0 +1,21 @@
/**
* 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 const DEFAULT_PUBLIC_VAPID_KEY: Uint8Array;
export declare const SUBSCRIPTION_DETAILS: {
userVisibleOnly: boolean;
applicationServerKey: Uint8Array;
};
export declare const ENDPOINT = "https://fcm.googleapis.com";

View File

@ -0,0 +1,15 @@
export interface IidDetails {
token: string;
pushSet: string;
}
export declare class IidModel {
getToken(senderId: string, subscription: PushSubscription, publicVapidKey: Uint8Array): Promise<IidDetails>;
/**
* Update the underlying token details for fcmToken.
*/
updateToken(senderId: string, fcmToken: string, fcmPushSet: string, subscription: PushSubscription, publicVapidKey: Uint8Array): Promise<string>;
/**
* Given a fcmToken, pushSet and messagingSenderId, delete an FCM token.
*/
deleteToken(senderId: string, fcmToken: string, fcmPushSet: string): Promise<void>;
}

View File

@ -0,0 +1,32 @@
import { TokenDetails } from '../interfaces/token-details';
import { DbInterface } from './db-interface';
export declare class TokenDetailsModel extends DbInterface {
protected readonly dbName: string;
protected readonly dbVersion: number;
protected readonly objectStoreName: string;
protected onDbUpgrade(request: IDBOpenDBRequest, event: IDBVersionChangeEvent): void;
/**
* Given a token, this method will look up the details in indexedDB.
*/
getTokenDetailsFromToken(fcmToken: string): Promise<TokenDetails | undefined>;
/**
* Given a service worker scope, this method will look up the details in
* indexedDB.
* @return The details associated with that token.
*/
getTokenDetailsFromSWScope(swScope: string): Promise<TokenDetails | undefined>;
/**
* Save the details for the fcm token for re-use at a later date.
* @param input A plain js object containing args to save.
*/
saveTokenDetails(tokenDetails: TokenDetails): Promise<void>;
/**
* This method deletes details of the current FCM token.
* It's returning a promise in case we need to move to an async
* method for deleting at a later date.
*
* @return Resolves once the FCM token details have been deleted and returns
* the deleted details.
*/
deleteToken(token: string): Promise<TokenDetails>;
}

View File

@ -0,0 +1,22 @@
import { DbInterface } from './db-interface';
export declare class VapidDetailsModel extends DbInterface {
protected readonly dbName: string;
protected readonly dbVersion: number;
protected readonly objectStoreName: string;
protected onDbUpgrade(request: IDBOpenDBRequest): void;
/**
* Given a service worker scope, this method will look up the vapid key
* in indexedDB.
*/
getVapidFromSWScope(swScope: string): Promise<Uint8Array | undefined>;
/**
* Save a vapid key against a swScope for later date.
*/
saveVapidDetails(swScope: string, vapidKey: Uint8Array): Promise<void>;
/**
* This method deletes details of the current FCM VAPID key for a SW scope.
* Resolves once the scope/vapid details have been deleted and returns the
* deleted vapid key.
*/
deleteVapidDetails(swScope: string): Promise<Uint8Array>;
}

View File

@ -0,0 +1,28 @@
/**
* 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 '../interfaces/message-payload';
export declare enum MessageParameter {
TYPE_OF_MSG = "firebase-messaging-msg-type",
DATA = "firebase-messaging-msg-data",
}
export declare enum MessageType {
PUSH_MSG_RECEIVED = "push-msg-received",
NOTIFICATION_CLICKED = "notification-clicked",
}
export interface InternalMessage {
[MessageParameter.TYPE_OF_MSG]: MessageType;
[MessageParameter.DATA]: MessagePayload;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,16 @@
/**
* 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 '../src/controllers/sw-types';

View File

@ -0,0 +1,16 @@
/**
* 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 deleteDatabase(dbName: string): Promise<void>;

View File

@ -0,0 +1,3 @@
import { TokenDetails } from '../../src/interfaces/token-details';
/** Compares the input details and the saved ones */
export declare function compareDetails(input: TokenDetails, saved: TokenDetails): void;

View File

@ -0,0 +1,2 @@
import { FirebaseApp } from '@firebase/app-types';
export declare function makeFakeApp(options?: object): FirebaseApp;

View File

@ -0,0 +1,6 @@
/**
* Used only in tests to make a semi-reasonable fake push subscription.
* @param options Options to set on the object if desired.
* @return Returns a fake subscription.
*/
export declare function makeFakeSubscription(options?: any): PushSubscription;

View File

@ -0,0 +1 @@
export declare function makeFakeSWReg(selectedState?: string, desiredValue?: object): ServiceWorkerRegistration;

View File

@ -0,0 +1,4 @@
/// <reference types="mocha" />
/** Runner for tests that require service worker functionality. */
declare const runner: (description: string, callback: (this: Mocha.ISuiteCallbackContext) => void) => void;
export { runner as describe };

View File

@ -0,0 +1,20 @@
/**
* 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 const fetchMock: {
jsonOk(body: string): Promise<Response>;
jsonError(status: number, msg: string): Promise<Response>;
htmlError(status: number, msg: string): Promise<Response>;
};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,94 @@
{
"_from": "@firebase/messaging@0.3.7",
"_id": "@firebase/messaging@0.3.7",
"_inBundle": false,
"_integrity": "sha512-8tZgRVJuvmFe5HDUiKvGAsK/jehrMnoUx95XU3RkZHX2D5QHjXAvvXIfFQ118EtG5/whZoEo1nCjEHAd9mSalA==",
"_location": "/@firebase/messaging",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@firebase/messaging@0.3.7",
"name": "@firebase/messaging",
"escapedName": "@firebase%2fmessaging",
"scope": "@firebase",
"rawSpec": "0.3.7",
"saveSpec": null,
"fetchSpec": "0.3.7"
},
"_requiredBy": [
"/firebase"
],
"_resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.3.7.tgz",
"_shasum": "812e4344400e9d1db68b8d59933610c0d8bcb319",
"_spec": "@firebase/messaging@0.3.7",
"_where": "D:\\Desktop\\smartshopperNodeReworkFirebase\\node_modules\\firebase",
"author": {
"name": "Firebase",
"email": "firebase-support@google.com",
"url": "https://firebase.google.com/"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"bundleDependencies": false,
"dependencies": {
"@firebase/messaging-types": "0.2.3",
"@firebase/util": "0.2.3",
"tslib": "1.9.0"
},
"deprecated": false,
"description": "This is the Firebase Cloud Messaging component of the Firebase JS SDK.",
"devDependencies": {
"@types/chai": "4.1.2",
"@types/mocha": "5.0.0",
"@types/sinon": "4.3.1",
"chai": "4.1.2",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-firefox-launcher": "1.1.0",
"karma-mocha": "1.3.0",
"karma-safari-launcher": "1.0.0",
"karma-sauce-launcher": "1.2.0",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.32",
"mocha": "5.2.0",
"npm-run-all": "4.1.2",
"rollup": "0.57.1",
"rollup-plugin-commonjs": "9.1.0",
"rollup-plugin-node-resolve": "3.3.0",
"rollup-plugin-typescript2": "0.12.0",
"sinon": "4.5.0",
"tslint": "5.9.1",
"typescript": "2.8.1"
},
"files": [
"dist"
],
"license": "Apache-2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"name": "@firebase/messaging",
"peerDependencies": {
"@firebase/app": "0.x",
"@firebase/app-types": "0.x"
},
"repository": {
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk/tree/master/packages/messaging"
},
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"lint": "tslint -p .",
"lint:fix": "yarn lint --fix",
"prepare": "npm run build",
"test": "run-p test:karma type-check lint",
"test:debug": "karma start --browsers=Chrome --auto-watch",
"test:karma": "karma start --single-run",
"type-check": "tsc --noEmit"
},
"typings": "dist/index.d.ts",
"version": "0.3.7"
}