Initial Commit

This commit is contained in:
2026-03-06 04:54:20 -04:00
commit 63677bfcf5
9332 changed files with 1507319 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* Deletes the Firebase Installation and all associated data.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function deleteInstallations(installations: Installations): Promise<void>;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function getId(installations: Installations): Promise<string>;

View File

@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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';
import { Installations } from '../interfaces/public-types';
/**
* Returns an instance of {@link Installations} associated with the given
* {@link @firebase/app#FirebaseApp} instance.
* @param app - The {@link @firebase/app#FirebaseApp} instance.
*
* @public
*/
export declare function getInstallations(app?: FirebaseApp): Installations;

View File

@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* Returns a Firebase Installations auth token, identifying the current
* Firebase Installation.
* @param installations - The `Installations` instance.
* @param forceRefresh - Force refresh regardless of token expiration.
*
* @public
*/
export declare function getToken(installations: Installations, forceRefresh?: boolean): Promise<string>;

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 * from './get-id';
export * from './get-token';
export * from './delete-installations';
export * from './on-id-change';
export * from './get-installations';

View File

@@ -0,0 +1,39 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* An user defined callback function that gets called when Installations ID changes.
*
* @public
*/
export type IdChangeCallbackFn = (installationId: string) => void;
/**
* Unsubscribe a callback function previously added via {@link IdChangeCallbackFn}.
*
* @public
*/
export type IdChangeUnsubscribeFn = () => void;
/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
* @param installations - The `Installations` instance.
* @param callback - The callback function that is invoked when FID changes.
* @returns A function that can be called to unsubscribe.
*
* @public
*/
export declare function onIdChange(installations: Installations, callback: IdChangeCallbackFn): IdChangeUnsubscribeFn;

View File

@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseError } from '@firebase/util';
import { GenerateAuthTokenResponse } from '../interfaces/api-response';
import { CompletedAuthToken, RegisteredInstallationEntry } from '../interfaces/installation-entry';
import { AppConfig } from '../interfaces/installation-impl';
export declare function getInstallationsEndpoint({ projectId }: AppConfig): string;
export declare function extractAuthTokenInfoFromResponse(response: GenerateAuthTokenResponse): CompletedAuthToken;
export declare function getErrorFromResponse(requestName: string, response: Response): Promise<FirebaseError>;
export declare function getHeaders({ apiKey }: AppConfig): Headers;
export declare function getHeadersWithAuth(appConfig: AppConfig, { refreshToken }: RegisteredInstallationEntry): Headers;
export interface ErrorResponse {
error: {
code: number;
message: string;
status: string;
};
}
/**
* Calls the passed in fetch wrapper and returns the response.
* If the returned response has a status of 5xx, re-runs the function once and
* returns the response.
*/
export declare function retryIfServerError(fn: () => Promise<Response>): Promise<Response>;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 registerInstallations(): void;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { InProgressInstallationEntry, RegisteredInstallationEntry } from '../interfaces/installation-entry';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
export declare function createInstallationRequest({ appConfig, heartbeatServiceProvider }: FirebaseInstallationsImpl, { fid }: InProgressInstallationEntry): Promise<RegisteredInstallationEntry>;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
import { RegisteredInstallationEntry } from '../interfaces/installation-entry';
export declare function deleteInstallationRequest(appConfig: AppConfig, installationEntry: RegisteredInstallationEntry): Promise<void>;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { CompletedAuthToken, RegisteredInstallationEntry } from '../interfaces/installation-entry';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
export declare function generateAuthTokenRequest({ appConfig, heartbeatServiceProvider }: FirebaseInstallationsImpl, installationEntry: RegisteredInstallationEntry): Promise<CompletedAuthToken>;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 bufferToBase64UrlSafe(array: Uint8Array): string;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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';
import { AppConfig } from '../interfaces/installation-impl';
export declare function extractAppConfig(app: FirebaseApp): AppConfig;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
import { IdChangeCallbackFn } from '../api';
/**
* Calls the onIdChange callbacks with the new FID value, and broadcasts the
* change to other tabs.
*/
export declare function fidChanged(appConfig: AppConfig, fid: string): void;
export declare function addCallback(appConfig: AppConfig, callback: IdChangeCallbackFn): void;
export declare function removeCallback(appConfig: AppConfig, callback: IdChangeCallbackFn): void;

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 VALID_FID_PATTERN: RegExp;
export declare const INVALID_FID = "";
/**
* Generates a new FID using random values from Web Crypto API.
* Returns an empty string if FID generation fails for any reason.
*/
export declare function generateFid(): string;

View File

@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { InstallationEntry, RegisteredInstallationEntry } from '../interfaces/installation-entry';
export interface InstallationEntryWithRegistrationPromise {
installationEntry: InstallationEntry;
/** Exist iff the installationEntry is not registered. */
registrationPromise?: Promise<RegisteredInstallationEntry>;
}
/**
* Updates and returns the InstallationEntry from the database.
* Also triggers a registration request if it is necessary and possible.
*/
export declare function getInstallationEntry(installations: FirebaseInstallationsImpl): Promise<InstallationEntryWithRegistrationPromise>;

View File

@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
import { InstallationEntry } from '../interfaces/installation-entry';
/** Gets record(s) from the objectStore that match the given key. */
export declare function get(appConfig: AppConfig): Promise<InstallationEntry | undefined>;
/** Assigns or overwrites the record for the given key with the given value. */
export declare function set<ValueType extends InstallationEntry>(appConfig: AppConfig, value: ValueType): Promise<ValueType>;
/** Removes record(s) from the objectStore that match the given key. */
export declare function remove(appConfig: AppConfig): Promise<void>;
/**
* Atomically updates a record with the result of updateFn, which gets
* called with the current value. If newValue is undefined, the record is
* deleted instead.
* @return Updated value
*/
export declare function update<ValueType extends InstallationEntry | undefined>(appConfig: AppConfig, updateFn: (previousValue: InstallationEntry | undefined) => ValueType): Promise<ValueType>;
export declare function clear(): Promise<void>;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { CompletedAuthToken } from '../interfaces/installation-entry';
/**
* Returns a valid authentication token for the installation. Generates a new
* token if one doesn't exist, is expired or about to expire.
*
* Should only be called if the Firebase Installation is registered.
*/
export declare function refreshAuthToken(installations: FirebaseInstallationsImpl, forceRefresh?: boolean): Promise<CompletedAuthToken>;

View File

@@ -0,0 +1,8 @@
/**
* The Firebase Installations Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
export * from './api';
export * from './interfaces/public-types';

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 CreateInstallationResponse {
readonly refreshToken: string;
readonly authToken: GenerateAuthTokenResponse;
readonly fid?: string;
}
export interface GenerateAuthTokenResponse {
readonly token: string;
/**
* Encoded as a string with the suffix 's' (indicating seconds), preceded by
* the number of seconds.
*
* Example: "604800s".
*/
readonly expiresIn: string;
}

View File

@@ -0,0 +1,85 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
/** Status of a server request. */
export declare const enum RequestStatus {
NOT_STARTED = 0,
IN_PROGRESS = 1,
COMPLETED = 2
}
export interface NotStartedAuthToken {
readonly requestStatus: RequestStatus.NOT_STARTED;
}
export interface InProgressAuthToken {
readonly requestStatus: RequestStatus.IN_PROGRESS;
/**
* Unix timestamp when the current generateAuthRequest was initiated.
* Used for figuring out how long the request status has been IN_PROGRESS.
*/
readonly requestTime: number;
}
export interface CompletedAuthToken {
readonly requestStatus: RequestStatus.COMPLETED;
/**
* Firebase Installations Authentication Token.
* Only exists if requestStatus is COMPLETED.
*/
readonly token: string;
/**
* Unix timestamp when Authentication Token was created.
* Only exists if requestStatus is COMPLETED.
*/
readonly creationTime: number;
/**
* Authentication Token time to live duration in milliseconds.
* Only exists if requestStatus is COMPLETED.
*/
readonly expiresIn: number;
}
export type AuthToken = NotStartedAuthToken | InProgressAuthToken | CompletedAuthToken;
export interface UnregisteredInstallationEntry {
/** Status of the Firebase Installation registration on the server. */
readonly registrationStatus: RequestStatus.NOT_STARTED;
/** Firebase Installation ID */
readonly fid: string;
}
export interface InProgressInstallationEntry {
/** Status of the Firebase Installation registration on the server. */
readonly registrationStatus: RequestStatus.IN_PROGRESS;
/**
* Unix timestamp that shows the time when the current createInstallation
* request was initiated.
* Used for figuring out how long the registration status has been PENDING.
*/
readonly registrationTime: number;
/** Firebase Installation ID */
readonly fid: string;
}
export interface RegisteredInstallationEntry {
/** Status of the Firebase Installation registration on the server. */
readonly registrationStatus: RequestStatus.COMPLETED;
/** Firebase Installation ID */
readonly fid: string;
/**
* Refresh Token returned from the server.
* Used for authenticating generateAuthToken requests.
*/
readonly refreshToken: string;
/** Firebase Installation Authentication Token. */
readonly authToken: AuthToken;
}
/** Firebase Installation ID and related data in the database. */
export type InstallationEntry = UnregisteredInstallationEntry | InProgressInstallationEntry | RegisteredInstallationEntry;

View File

@@ -0,0 +1,29 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { Provider } from '@firebase/component';
import { _FirebaseService } from '@firebase/app';
import { Installations } from '../interfaces/public-types';
export interface FirebaseInstallationsImpl extends Installations, _FirebaseService {
readonly appConfig: AppConfig;
readonly heartbeatServiceProvider: Provider<'heartbeat'>;
}
export interface AppConfig {
readonly appName: string;
readonly projectId: string;
readonly apiKey: string;
readonly appId: string;
}

View File

@@ -0,0 +1,50 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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';
/**
* Public interface of the Firebase Installations SDK.
*
* @public
*/
export interface Installations {
/**
* The {@link @firebase/app#FirebaseApp} this `Installations` instance is associated with.
*/
app: FirebaseApp;
}
/**
* An interface for Firebase internal SDKs use only.
*
* @internal
*/
export interface _FirebaseInstallationsInternal {
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
*/
getId(): Promise<string>;
/**
* Returns an Authentication Token for the current Firebase Installation.
*/
getToken(forceRefresh?: boolean): Promise<string>;
}
declare module '@firebase/component' {
interface NameServiceMapping {
'installations': Installations;
'installations-internal': _FirebaseInstallationsInternal;
}
}

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
declare class HeadersWithEntries extends Headers {
entries?(): Iterable<[string, string]>;
}
export declare function compareHeaders(expectedHeaders: HeadersWithEntries, actualHeaders: HeadersWithEntries): void;
export {};

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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';
import { FirebaseInstallationsImpl, AppConfig } from '../interfaces/installation-impl';
export declare function getFakeApp(): FirebaseApp;
export declare function getFakeAppConfig(customValues?: Partial<AppConfig>): AppConfig;
export declare function getFakeInstallations(): FirebaseInstallationsImpl;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 {};

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 PENDING_TIMEOUT_MS = 10000;
export declare const PACKAGE_VERSION: string;
export declare const INTERNAL_AUTH_VERSION = "FIS_v2";
export declare const INSTALLATIONS_API_URL = "https://firebaseinstallations.googleapis.com/v1";
export declare const TOKEN_EXPIRATION_BUFFER: number;
export declare const SERVICE = "installations";
export declare const SERVICE_NAME = "Installations";

View File

@@ -0,0 +1,46 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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, FirebaseError } from '@firebase/util';
export declare const enum ErrorCode {
MISSING_APP_CONFIG_VALUES = "missing-app-config-values",
NOT_REGISTERED = "not-registered",
INSTALLATION_NOT_FOUND = "installation-not-found",
REQUEST_FAILED = "request-failed",
APP_OFFLINE = "app-offline",
DELETE_PENDING_REGISTRATION = "delete-pending-registration"
}
interface ErrorParams {
[ErrorCode.MISSING_APP_CONFIG_VALUES]: {
valueName: string;
};
[ErrorCode.REQUEST_FAILED]: {
requestName: string;
[index: string]: string | number;
} & ServerErrorData;
}
export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
export interface ServerErrorData {
serverCode: number;
serverMessage: string;
serverStatus: string;
}
export type ServerError = FirebaseError & {
customData: ServerErrorData;
};
/** Returns true if error is a FirebaseError that is based on an error from the server. */
export declare function isServerError(error: unknown): error is ServerError;
export {};

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
/** Returns a string key that can be used to identify the app. */
export declare function getKey(appConfig: AppConfig): string;

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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>;

1175
node_modules/@firebase/installations/dist/index.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,85 @@
/**
* The Firebase Installations Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
import { FirebaseApp } from '@firebase/app';
/**
* Deletes the Firebase Installation and all associated data.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function deleteInstallations(installations: Installations): Promise<void>;
/* Excluded from this release type: _FirebaseInstallationsInternal */
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function getId(installations: Installations): Promise<string>;
/**
* Returns an instance of {@link Installations} associated with the given
* {@link @firebase/app#FirebaseApp} instance.
* @param app - The {@link @firebase/app#FirebaseApp} instance.
*
* @public
*/
export declare function getInstallations(app?: FirebaseApp): Installations;
/**
* Returns a Firebase Installations auth token, identifying the current
* Firebase Installation.
* @param installations - The `Installations` instance.
* @param forceRefresh - Force refresh regardless of token expiration.
*
* @public
*/
export declare function getToken(installations: Installations, forceRefresh?: boolean): Promise<string>;
/**
* An user defined callback function that gets called when Installations ID changes.
*
* @public
*/
export declare type IdChangeCallbackFn = (installationId: string) => void;
/**
* Unsubscribe a callback function previously added via {@link IdChangeCallbackFn}.
*
* @public
*/
export declare type IdChangeUnsubscribeFn = () => void;
/**
* Public interface of the Firebase Installations SDK.
*
* @public
*/
export declare interface Installations {
/**
* The {@link @firebase/app#FirebaseApp} this `Installations` instance is associated with.
*/
app: FirebaseApp;
}
/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
* @param installations - The `Installations` instance.
* @param callback - The callback function that is invoked when FID changes.
* @returns A function that can be called to unsubscribe.
*
* @public
*/
export declare function onIdChange(installations: Installations, callback: IdChangeCallbackFn): IdChangeUnsubscribeFn;
export { }

View File

@@ -0,0 +1,100 @@
/**
* The Firebase Installations Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
import { FirebaseApp } from '@firebase/app';
/**
* Deletes the Firebase Installation and all associated data.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function deleteInstallations(installations: Installations): Promise<void>;
/**
* An interface for Firebase internal SDKs use only.
*
* @internal
*/
export declare interface _FirebaseInstallationsInternal {
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
*/
getId(): Promise<string>;
/**
* Returns an Authentication Token for the current Firebase Installation.
*/
getToken(forceRefresh?: boolean): Promise<string>;
}
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function getId(installations: Installations): Promise<string>;
/**
* Returns an instance of {@link Installations} associated with the given
* {@link @firebase/app#FirebaseApp} instance.
* @param app - The {@link @firebase/app#FirebaseApp} instance.
*
* @public
*/
export declare function getInstallations(app?: FirebaseApp): Installations;
/**
* Returns a Firebase Installations auth token, identifying the current
* Firebase Installation.
* @param installations - The `Installations` instance.
* @param forceRefresh - Force refresh regardless of token expiration.
*
* @public
*/
export declare function getToken(installations: Installations, forceRefresh?: boolean): Promise<string>;
/**
* An user defined callback function that gets called when Installations ID changes.
*
* @public
*/
export declare type IdChangeCallbackFn = (installationId: string) => void;
/**
* Unsubscribe a callback function previously added via {@link IdChangeCallbackFn}.
*
* @public
*/
export declare type IdChangeUnsubscribeFn = () => void;
/**
* Public interface of the Firebase Installations SDK.
*
* @public
*/
export declare interface Installations {
/**
* The {@link @firebase/app#FirebaseApp} this `Installations` instance is associated with.
*/
app: FirebaseApp;
}
/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
* @param installations - The `Installations` instance.
* @param callback - The callback function that is invoked when FID changes.
* @returns A function that can be called to unsubscribe.
*
* @public
*/
export declare function onIdChange(installations: Installations, callback: IdChangeCallbackFn): IdChangeUnsubscribeFn;
export { }

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* Deletes the Firebase Installation and all associated data.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function deleteInstallations(installations: Installations): Promise<void>;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
* @param installations - The `Installations` instance.
*
* @public
*/
export declare function getId(installations: Installations): Promise<string>;

View File

@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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';
import { Installations } from '../interfaces/public-types';
/**
* Returns an instance of {@link Installations} associated with the given
* {@link @firebase/app#FirebaseApp} instance.
* @param app - The {@link @firebase/app#FirebaseApp} instance.
*
* @public
*/
export declare function getInstallations(app?: FirebaseApp): Installations;

View File

@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* Returns a Firebase Installations auth token, identifying the current
* Firebase Installation.
* @param installations - The `Installations` instance.
* @param forceRefresh - Force refresh regardless of token expiration.
*
* @public
*/
export declare function getToken(installations: Installations, forceRefresh?: boolean): Promise<string>;

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 * from './get-id';
export * from './get-token';
export * from './delete-installations';
export * from './on-id-change';
export * from './get-installations';

View File

@@ -0,0 +1,39 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Installations } from '../interfaces/public-types';
/**
* An user defined callback function that gets called when Installations ID changes.
*
* @public
*/
export type IdChangeCallbackFn = (installationId: string) => void;
/**
* Unsubscribe a callback function previously added via {@link IdChangeCallbackFn}.
*
* @public
*/
export type IdChangeUnsubscribeFn = () => void;
/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
* @param installations - The `Installations` instance.
* @param callback - The callback function that is invoked when FID changes.
* @returns A function that can be called to unsubscribe.
*
* @public
*/
export declare function onIdChange(installations: Installations, callback: IdChangeCallbackFn): IdChangeUnsubscribeFn;

View File

@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseError } from '@firebase/util';
import { GenerateAuthTokenResponse } from '../interfaces/api-response';
import { CompletedAuthToken, RegisteredInstallationEntry } from '../interfaces/installation-entry';
import { AppConfig } from '../interfaces/installation-impl';
export declare function getInstallationsEndpoint({ projectId }: AppConfig): string;
export declare function extractAuthTokenInfoFromResponse(response: GenerateAuthTokenResponse): CompletedAuthToken;
export declare function getErrorFromResponse(requestName: string, response: Response): Promise<FirebaseError>;
export declare function getHeaders({ apiKey }: AppConfig): Headers;
export declare function getHeadersWithAuth(appConfig: AppConfig, { refreshToken }: RegisteredInstallationEntry): Headers;
export interface ErrorResponse {
error: {
code: number;
message: string;
status: string;
};
}
/**
* Calls the passed in fetch wrapper and returns the response.
* If the returned response has a status of 5xx, re-runs the function once and
* returns the response.
*/
export declare function retryIfServerError(fn: () => Promise<Response>): Promise<Response>;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 registerInstallations(): void;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { InProgressInstallationEntry, RegisteredInstallationEntry } from '../interfaces/installation-entry';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
export declare function createInstallationRequest({ appConfig, heartbeatServiceProvider }: FirebaseInstallationsImpl, { fid }: InProgressInstallationEntry): Promise<RegisteredInstallationEntry>;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
import { RegisteredInstallationEntry } from '../interfaces/installation-entry';
export declare function deleteInstallationRequest(appConfig: AppConfig, installationEntry: RegisteredInstallationEntry): Promise<void>;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { CompletedAuthToken, RegisteredInstallationEntry } from '../interfaces/installation-entry';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
export declare function generateAuthTokenRequest({ appConfig, heartbeatServiceProvider }: FirebaseInstallationsImpl, installationEntry: RegisteredInstallationEntry): Promise<CompletedAuthToken>;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 bufferToBase64UrlSafe(array: Uint8Array): string;

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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';
import { AppConfig } from '../interfaces/installation-impl';
export declare function extractAppConfig(app: FirebaseApp): AppConfig;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
import { IdChangeCallbackFn } from '../api';
/**
* Calls the onIdChange callbacks with the new FID value, and broadcasts the
* change to other tabs.
*/
export declare function fidChanged(appConfig: AppConfig, fid: string): void;
export declare function addCallback(appConfig: AppConfig, callback: IdChangeCallbackFn): void;
export declare function removeCallback(appConfig: AppConfig, callback: IdChangeCallbackFn): void;

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 VALID_FID_PATTERN: RegExp;
export declare const INVALID_FID = "";
/**
* Generates a new FID using random values from Web Crypto API.
* Returns an empty string if FID generation fails for any reason.
*/
export declare function generateFid(): string;

View File

@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { InstallationEntry, RegisteredInstallationEntry } from '../interfaces/installation-entry';
export interface InstallationEntryWithRegistrationPromise {
installationEntry: InstallationEntry;
/** Exist iff the installationEntry is not registered. */
registrationPromise?: Promise<RegisteredInstallationEntry>;
}
/**
* Updates and returns the InstallationEntry from the database.
* Also triggers a registration request if it is necessary and possible.
*/
export declare function getInstallationEntry(installations: FirebaseInstallationsImpl): Promise<InstallationEntryWithRegistrationPromise>;

View File

@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
import { InstallationEntry } from '../interfaces/installation-entry';
/** Gets record(s) from the objectStore that match the given key. */
export declare function get(appConfig: AppConfig): Promise<InstallationEntry | undefined>;
/** Assigns or overwrites the record for the given key with the given value. */
export declare function set<ValueType extends InstallationEntry>(appConfig: AppConfig, value: ValueType): Promise<ValueType>;
/** Removes record(s) from the objectStore that match the given key. */
export declare function remove(appConfig: AppConfig): Promise<void>;
/**
* Atomically updates a record with the result of updateFn, which gets
* called with the current value. If newValue is undefined, the record is
* deleted instead.
* @return Updated value
*/
export declare function update<ValueType extends InstallationEntry | undefined>(appConfig: AppConfig, updateFn: (previousValue: InstallationEntry | undefined) => ValueType): Promise<ValueType>;
export declare function clear(): Promise<void>;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { CompletedAuthToken } from '../interfaces/installation-entry';
/**
* Returns a valid authentication token for the installation. Generates a new
* token if one doesn't exist, is expired or about to expire.
*
* Should only be called if the Firebase Installation is registered.
*/
export declare function refreshAuthToken(installations: FirebaseInstallationsImpl, forceRefresh?: boolean): Promise<CompletedAuthToken>;

View File

@@ -0,0 +1,8 @@
/**
* The Firebase Installations Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
export * from './api';
export * from './interfaces/public-types';

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 CreateInstallationResponse {
readonly refreshToken: string;
readonly authToken: GenerateAuthTokenResponse;
readonly fid?: string;
}
export interface GenerateAuthTokenResponse {
readonly token: string;
/**
* Encoded as a string with the suffix 's' (indicating seconds), preceded by
* the number of seconds.
*
* Example: "604800s".
*/
readonly expiresIn: string;
}

View File

@@ -0,0 +1,85 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
/** Status of a server request. */
export declare const enum RequestStatus {
NOT_STARTED = 0,
IN_PROGRESS = 1,
COMPLETED = 2
}
export interface NotStartedAuthToken {
readonly requestStatus: RequestStatus.NOT_STARTED;
}
export interface InProgressAuthToken {
readonly requestStatus: RequestStatus.IN_PROGRESS;
/**
* Unix timestamp when the current generateAuthRequest was initiated.
* Used for figuring out how long the request status has been IN_PROGRESS.
*/
readonly requestTime: number;
}
export interface CompletedAuthToken {
readonly requestStatus: RequestStatus.COMPLETED;
/**
* Firebase Installations Authentication Token.
* Only exists if requestStatus is COMPLETED.
*/
readonly token: string;
/**
* Unix timestamp when Authentication Token was created.
* Only exists if requestStatus is COMPLETED.
*/
readonly creationTime: number;
/**
* Authentication Token time to live duration in milliseconds.
* Only exists if requestStatus is COMPLETED.
*/
readonly expiresIn: number;
}
export type AuthToken = NotStartedAuthToken | InProgressAuthToken | CompletedAuthToken;
export interface UnregisteredInstallationEntry {
/** Status of the Firebase Installation registration on the server. */
readonly registrationStatus: RequestStatus.NOT_STARTED;
/** Firebase Installation ID */
readonly fid: string;
}
export interface InProgressInstallationEntry {
/** Status of the Firebase Installation registration on the server. */
readonly registrationStatus: RequestStatus.IN_PROGRESS;
/**
* Unix timestamp that shows the time when the current createInstallation
* request was initiated.
* Used for figuring out how long the registration status has been PENDING.
*/
readonly registrationTime: number;
/** Firebase Installation ID */
readonly fid: string;
}
export interface RegisteredInstallationEntry {
/** Status of the Firebase Installation registration on the server. */
readonly registrationStatus: RequestStatus.COMPLETED;
/** Firebase Installation ID */
readonly fid: string;
/**
* Refresh Token returned from the server.
* Used for authenticating generateAuthToken requests.
*/
readonly refreshToken: string;
/** Firebase Installation Authentication Token. */
readonly authToken: AuthToken;
}
/** Firebase Installation ID and related data in the database. */
export type InstallationEntry = UnregisteredInstallationEntry | InProgressInstallationEntry | RegisteredInstallationEntry;

View File

@@ -0,0 +1,29 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { Provider } from '@firebase/component';
import { _FirebaseService } from '@firebase/app';
import { Installations } from '../interfaces/public-types';
export interface FirebaseInstallationsImpl extends Installations, _FirebaseService {
readonly appConfig: AppConfig;
readonly heartbeatServiceProvider: Provider<'heartbeat'>;
}
export interface AppConfig {
readonly appName: string;
readonly projectId: string;
readonly apiKey: string;
readonly appId: string;
}

View File

@@ -0,0 +1,50 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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';
/**
* Public interface of the Firebase Installations SDK.
*
* @public
*/
export interface Installations {
/**
* The {@link @firebase/app#FirebaseApp} this `Installations` instance is associated with.
*/
app: FirebaseApp;
}
/**
* An interface for Firebase internal SDKs use only.
*
* @internal
*/
export interface _FirebaseInstallationsInternal {
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
*/
getId(): Promise<string>;
/**
* Returns an Authentication Token for the current Firebase Installation.
*/
getToken(forceRefresh?: boolean): Promise<string>;
}
declare module '@firebase/component' {
interface NameServiceMapping {
'installations': Installations;
'installations-internal': _FirebaseInstallationsInternal;
}
}

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
declare class HeadersWithEntries extends Headers {
entries?(): Iterable<[string, string]>;
}
export declare function compareHeaders(expectedHeaders: HeadersWithEntries, actualHeaders: HeadersWithEntries): void;
export {};

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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';
import { FirebaseInstallationsImpl, AppConfig } from '../interfaces/installation-impl';
export declare function getFakeApp(): FirebaseApp;
export declare function getFakeAppConfig(customValues?: Partial<AppConfig>): AppConfig;
export declare function getFakeInstallations(): FirebaseInstallationsImpl;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 {};

View File

@@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "0.1.2"
}
]
}

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 PENDING_TIMEOUT_MS = 10000;
export declare const PACKAGE_VERSION: string;
export declare const INTERNAL_AUTH_VERSION = "FIS_v2";
export declare const INSTALLATIONS_API_URL = "https://firebaseinstallations.googleapis.com/v1";
export declare const TOKEN_EXPIRATION_BUFFER: number;
export declare const SERVICE = "installations";
export declare const SERVICE_NAME = "Installations";

View File

@@ -0,0 +1,46 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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, FirebaseError } from '@firebase/util';
export declare const enum ErrorCode {
MISSING_APP_CONFIG_VALUES = "missing-app-config-values",
NOT_REGISTERED = "not-registered",
INSTALLATION_NOT_FOUND = "installation-not-found",
REQUEST_FAILED = "request-failed",
APP_OFFLINE = "app-offline",
DELETE_PENDING_REGISTRATION = "delete-pending-registration"
}
interface ErrorParams {
[ErrorCode.MISSING_APP_CONFIG_VALUES]: {
valueName: string;
};
[ErrorCode.REQUEST_FAILED]: {
requestName: string;
[index: string]: string | number;
} & ServerErrorData;
}
export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
export interface ServerErrorData {
serverCode: number;
serverMessage: string;
serverStatus: string;
}
export type ServerError = FirebaseError & {
customData: ServerErrorData;
};
/** Returns true if error is a FirebaseError that is based on an error from the server. */
export declare function isServerError(error: unknown): error is ServerError;
export {};

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { AppConfig } from '../interfaces/installation-impl';
/** Returns a string key that can be used to identify the app. */
export declare function getKey(appConfig: AppConfig): string;

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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>;