Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 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"}

105
node_modules/@firebase/app-check/dist/esm/src/api.d.ts generated vendored Normal file
View file

@ -0,0 +1,105 @@
/**
* @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 { AppCheck, AppCheckOptions, AppCheckTokenResult, Unsubscribe, PartialObserver } from './public-types';
import { FirebaseApp } from '@firebase/app';
import { AppCheckService } from './factory';
declare module '@firebase/component' {
interface NameServiceMapping {
'app-check': AppCheckService;
}
}
export { ReCaptchaV3Provider, CustomProvider, ReCaptchaEnterpriseProvider } from './providers';
/**
* Activate App Check for the given app. Can be called only once per app.
* @param app - the {@link @firebase/app#FirebaseApp} to activate App Check for
* @param options - App Check initialization options
* @public
*/
export declare function initializeAppCheck(app: FirebaseApp | undefined, options: AppCheckOptions): AppCheck;
/**
* Set whether App Check will automatically refresh tokens as needed.
*
* @param appCheckInstance - The App Check service instance.
* @param isTokenAutoRefreshEnabled - If true, the SDK automatically
* refreshes App Check tokens as needed. This overrides any value set
* during `initializeAppCheck()`.
* @public
*/
export declare function setTokenAutoRefreshEnabled(appCheckInstance: AppCheck, isTokenAutoRefreshEnabled: boolean): void;
/**
* Get the current App Check token. If `forceRefresh` is false, this function first
* checks for a valid token in memory, then local persistence (IndexedDB).
* If not found, or if `forceRefresh` is true, it makes a request to the
* App Check endpoint for a fresh token. That request attaches
* to the most recent in-flight request if one is present.
*
* @param appCheckInstance - The App Check service instance.
* @param forceRefresh - If true, will always try to fetch a fresh token.
* If false, will use a cached token if found in storage.
* @public
*/
export declare function getToken(appCheckInstance: AppCheck, forceRefresh?: boolean): Promise<AppCheckTokenResult>;
/**
* Requests a Firebase App Check token. This method should be used
* only if you need to authorize requests to a non-Firebase backend.
*
* Returns limited-use tokens that are intended for use with your
* non-Firebase backend endpoints that are protected with
* <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
* Replay Protection</a>. This method
* does not affect the token generation behavior of the
* #getAppCheckToken() method.
*
* @param appCheckInstance - The App Check service instance.
* @returns The limited use token.
* @public
*/
export declare function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
/**
* Registers a listener to changes in the token state. There can be more
* than one listener registered at the same time for one or more
* App Check instances. The listeners call back on the UI thread whenever
* the current token associated with this App Check instance changes.
*
* @param appCheckInstance - The App Check service instance.
* @param observer - An object with `next`, `error`, and `complete`
* properties. `next` is called with an
* {@link AppCheckTokenResult}
* whenever the token changes. `error` is optional and is called if an
* error is thrown by the listener (the `next` function). `complete`
* is unused, as the token stream is unending.
*
* @returns A function that unsubscribes this listener.
* @public
*/
export declare function onTokenChanged(appCheckInstance: AppCheck, observer: PartialObserver<AppCheckTokenResult>): Unsubscribe;
/**
* Registers a listener to changes in the token state. There can be more
* than one listener registered at the same time for one or more
* App Check instances. The listeners call back on the UI thread whenever
* the current token associated with this App Check instance changes.
*
* @param appCheckInstance - The App Check service instance.
* @param onNext - When the token changes, this function is called with an
* {@link AppCheckTokenResult}.
* @param onError - Optional. Called if there is an error thrown by the
* listener (the `onNext` function).
* @param onCompletion - Currently unused, as the token stream is unending.
* @returns A function that unsubscribes this listener.
* @public
*/
export declare function onTokenChanged(appCheckInstance: AppCheck, onNext: (tokenResult: AppCheckTokenResult) => void, onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;

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.
*/
import '../test/setup';

View file

@ -0,0 +1,30 @@
/**
* @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 { Provider } from '@firebase/component';
import { AppCheckTokenInternal } from './types';
interface AppCheckRequest {
url: string;
body: {
[key: string]: string;
};
}
export declare function exchangeToken({ url, body }: AppCheckRequest, heartbeatServiceProvider: Provider<'heartbeat'>): Promise<AppCheckTokenInternal>;
export declare function getExchangeRecaptchaV3TokenRequest(app: FirebaseApp, reCAPTCHAToken: string): AppCheckRequest;
export declare function getExchangeRecaptchaEnterpriseTokenRequest(app: FirebaseApp, reCAPTCHAToken: string): AppCheckRequest;
export declare function getExchangeDebugTokenRequest(app: FirebaseApp, debugToken: string): AppCheckRequest;
export {};

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.
*/
import '../test/setup';

View file

@ -0,0 +1,40 @@
/**
* @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 const BASE_ENDPOINT = "https://content-firebaseappcheck.googleapis.com/v1";
export declare const EXCHANGE_RECAPTCHA_TOKEN_METHOD = "exchangeRecaptchaV3Token";
export declare const EXCHANGE_RECAPTCHA_ENTERPRISE_TOKEN_METHOD = "exchangeRecaptchaEnterpriseToken";
export declare const EXCHANGE_DEBUG_TOKEN_METHOD = "exchangeDebugToken";
export declare const TOKEN_REFRESH_TIME: {
/**
* The offset time before token natural expiration to run the refresh.
* This is currently 5 minutes.
*/
OFFSET_DURATION: number;
/**
* This is the first retrial wait after an error. This is currently
* 30 seconds.
*/
RETRIAL_MIN_WAIT: number;
/**
* This is the maximum retrial wait, currently 16 minutes.
*/
RETRIAL_MAX_WAIT: number;
};
/**
* One day in millis, for certain error code backoffs.
*/
export declare const ONE_DAY: number;

View file

@ -0,0 +1,22 @@
/**
* @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.
*/
declare global {
var FIREBASE_APPCHECK_DEBUG_TOKEN: boolean | string | undefined;
}
export declare function isDebugMode(): boolean;
export declare function getDebugToken(): Promise<string>;
export declare function initializeDebugMode(): void;

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.
*/
import '../test/setup';

View file

@ -0,0 +1,61 @@
/**
* @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 { ErrorFactory } from '@firebase/util';
export declare const enum AppCheckError {
ALREADY_INITIALIZED = "already-initialized",
USE_BEFORE_ACTIVATION = "use-before-activation",
FETCH_NETWORK_ERROR = "fetch-network-error",
FETCH_PARSE_ERROR = "fetch-parse-error",
FETCH_STATUS_ERROR = "fetch-status-error",
STORAGE_OPEN = "storage-open",
STORAGE_GET = "storage-get",
STORAGE_WRITE = "storage-set",
RECAPTCHA_ERROR = "recaptcha-error",
THROTTLED = "throttled"
}
interface ErrorParams {
[AppCheckError.ALREADY_INITIALIZED]: {
appName: string;
};
[AppCheckError.USE_BEFORE_ACTIVATION]: {
appName: string;
};
[AppCheckError.FETCH_NETWORK_ERROR]: {
originalErrorMessage: string;
};
[AppCheckError.FETCH_PARSE_ERROR]: {
originalErrorMessage: string;
};
[AppCheckError.FETCH_STATUS_ERROR]: {
httpStatus: number;
};
[AppCheckError.STORAGE_OPEN]: {
originalErrorMessage?: string;
};
[AppCheckError.STORAGE_GET]: {
originalErrorMessage?: string;
};
[AppCheckError.STORAGE_WRITE]: {
originalErrorMessage?: string;
};
[AppCheckError.THROTTLED]: {
time: string;
httpStatus: number;
};
}
export declare const ERROR_FACTORY: ErrorFactory<AppCheckError, ErrorParams>;
export {};

View file

@ -0,0 +1,31 @@
/**
* @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 { AppCheck } from './public-types';
import { FirebaseApp, _FirebaseService } from '@firebase/app';
import { FirebaseAppCheckInternal } from './types';
import { Provider } from '@firebase/component';
/**
* AppCheck Service class.
*/
export declare class AppCheckService implements AppCheck, _FirebaseService {
app: FirebaseApp;
heartbeatServiceProvider: Provider<'heartbeat'>;
constructor(app: FirebaseApp, heartbeatServiceProvider: Provider<'heartbeat'>);
_delete(): Promise<void>;
}
export declare function factory(app: FirebaseApp, heartbeatServiceProvider: Provider<'heartbeat'>): AppCheckService;
export declare function internalFactory(appCheck: AppCheckService): FirebaseAppCheckInternal;

View file

@ -0,0 +1,14 @@
/**
* The Firebase App Check Web SDK.
*
* @remarks
* Firebase App Check does not work in a Node.js environment using `ReCaptchaV3Provider` or
* `ReCaptchaEnterpriseProvider`, but can be used in Node.js if you use
* `CustomProvider` and write your own attestation method.
*
* @packageDocumentation
*/
import { _AppCheckInternalComponentName } from './types';
export { _AppCheckInternalComponentName };
export * from './api';
export * from './public-types';

View file

@ -0,0 +1,22 @@
/**
* @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 { AppCheckTokenInternal } from './types';
export declare function readTokenFromIndexedDB(app: FirebaseApp): Promise<AppCheckTokenInternal | undefined>;
export declare function writeTokenToIndexedDB(app: FirebaseApp, token?: AppCheckTokenInternal): Promise<void>;
export declare function writeDebugTokenToIndexedDB(token: string): Promise<void>;
export declare function readDebugTokenFromIndexedDB(): Promise<string | undefined>;

View file

@ -0,0 +1,44 @@
/**
* @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 { AppCheckTokenResult, AppCheckTokenInternal, ListenerType } from './types';
import { AppCheckTokenListener } from './public-types';
import { AppCheckService } from './factory';
export declare const defaultTokenErrorData: {
error: string;
};
/**
* Stringify and base64 encode token error data.
*
* @param tokenError Error data, currently hardcoded.
*/
export declare function formatDummyToken(tokenErrorData: Record<string, string>): string;
/**
* This function always resolves.
* The result will contain an error field if there is any error.
* In case there is an error, the token field in the result will be populated with a dummy value
*/
export declare function getToken(appCheck: AppCheckService, forceRefresh?: boolean): Promise<AppCheckTokenResult>;
/**
* Internal API for limited use tokens. Skips all FAC state and simply calls
* the underlying provider.
*/
export declare function getLimitedUseToken(appCheck: AppCheckService): Promise<AppCheckTokenResult>;
export declare function addTokenListener(appCheck: AppCheckService, type: ListenerType, listener: AppCheckTokenListener, onError?: (error: Error) => void): void;
export declare function removeTokenListener(app: FirebaseApp, listener: AppCheckTokenListener): void;
export declare function notifyTokenListeners(app: FirebaseApp, token: AppCheckTokenResult): void;
export declare function isValid(token: AppCheckTokenInternal): boolean;

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.
*/
import '../test/setup';

View file

@ -0,0 +1,18 @@
/**
* @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 { Logger } from '@firebase/logger';
export declare const logger: Logger;

View file

@ -0,0 +1,35 @@
/**
* @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.
*/
/**
* Port from auth proactiverefresh.js
*
*/
export declare class Refresher {
private readonly operation;
private readonly retryPolicy;
private readonly getWaitDuration;
private readonly lowerBound;
private readonly upperBound;
private pending;
private nextErrorWaitInterval;
constructor(operation: () => Promise<unknown>, retryPolicy: (error: unknown) => boolean, getWaitDuration: () => number, lowerBound: number, upperBound: number);
start(): void;
stop(): void;
isRunning(): boolean;
private process;
private getNextRun;
}

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.
*/
import '../test/setup';

View file

@ -0,0 +1,108 @@
/**
* @license
* Copyright 2021 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 { CustomProviderOptions } from './public-types';
import { AppCheckProvider, AppCheckTokenInternal } from './types';
/**
* App Check provider that can obtain a reCAPTCHA V3 token and exchange it
* for an App Check token.
*
* @public
*/
export declare class ReCaptchaV3Provider implements AppCheckProvider {
private _siteKey;
private _app?;
private _heartbeatServiceProvider?;
/**
* Throttle requests on certain error codes to prevent too many retries
* in a short time.
*/
private _throttleData;
/**
* Create a ReCaptchaV3Provider instance.
* @param siteKey - ReCAPTCHA V3 siteKey.
*/
constructor(_siteKey: string);
/**
* Returns an App Check token.
* @internal
*/
getToken(): Promise<AppCheckTokenInternal>;
/**
* @internal
*/
initialize(app: FirebaseApp): void;
/**
* @internal
*/
isEqual(otherProvider: unknown): boolean;
}
/**
* App Check provider that can obtain a reCAPTCHA Enterprise token and exchange it
* for an App Check token.
*
* @public
*/
export declare class ReCaptchaEnterpriseProvider implements AppCheckProvider {
private _siteKey;
private _app?;
private _heartbeatServiceProvider?;
/**
* Throttle requests on certain error codes to prevent too many retries
* in a short time.
*/
private _throttleData;
/**
* Create a ReCaptchaEnterpriseProvider instance.
* @param siteKey - reCAPTCHA Enterprise score-based site key.
*/
constructor(_siteKey: string);
/**
* Returns an App Check token.
* @internal
*/
getToken(): Promise<AppCheckTokenInternal>;
/**
* @internal
*/
initialize(app: FirebaseApp): void;
/**
* @internal
*/
isEqual(otherProvider: unknown): boolean;
}
/**
* Custom provider class.
* @public
*/
export declare class CustomProvider implements AppCheckProvider {
private _customProviderOptions;
private _app?;
constructor(_customProviderOptions: CustomProviderOptions);
/**
* @internal
*/
getToken(): Promise<AppCheckTokenInternal>;
/**
* @internal
*/
initialize(app: FirebaseApp): void;
/**
* @internal
*/
isEqual(otherProvider: unknown): boolean;
}

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2021 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 '../test/setup';

View file

@ -0,0 +1,85 @@
/**
* @license
* Copyright 2021 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 { CustomProvider, ReCaptchaEnterpriseProvider, ReCaptchaV3Provider } from './providers';
export { Unsubscribe, PartialObserver } from '@firebase/util';
/**
* The Firebase App Check service interface.
*
* @public
*/
export interface AppCheck {
/**
* The {@link @firebase/app#FirebaseApp} this `AppCheck` instance is associated with.
*/
app: FirebaseApp;
}
/**
* The token returned from an App Check provider.
* @public
*/
export interface AppCheckToken {
readonly token: string;
/**
* The local timestamp after which the token will expire.
*/
readonly expireTimeMillis: number;
}
/**
* @internal
*/
export declare type _AppCheckComponentName = 'app-check';
/**
* Options for App Check initialization.
* @public
*/
export interface AppCheckOptions {
/**
* A reCAPTCHA V3 provider, reCAPTCHA Enterprise provider, or custom provider.
*/
provider: CustomProvider | ReCaptchaV3Provider | ReCaptchaEnterpriseProvider;
/**
* If set to true, enables automatic background refresh of App Check token.
*/
isTokenAutoRefreshEnabled?: boolean;
}
/**
* Options when creating a {@link CustomProvider}.
* @public
*/
export interface CustomProviderOptions {
/**
* Function to get an App Check token through a custom provider
* service.
*/
getToken: () => Promise<AppCheckToken>;
}
/**
* Result returned by `getToken()`.
* @public
*/
export interface AppCheckTokenResult {
/**
* The token string in JWT format.
*/
readonly token: string;
}
/**
* A listener that is called whenever the App Check token changes.
* @public
*/
export declare type AppCheckTokenListener = (token: AppCheckTokenResult) => void;

View file

@ -0,0 +1,43 @@
/**
* @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';
export declare const RECAPTCHA_URL = "https://www.google.com/recaptcha/api.js";
export declare const RECAPTCHA_ENTERPRISE_URL = "https://www.google.com/recaptcha/enterprise.js";
export declare function initializeV3(app: FirebaseApp, siteKey: string): Promise<GreCAPTCHA>;
export declare function initializeEnterprise(app: FirebaseApp, siteKey: string): Promise<GreCAPTCHA>;
export declare function getToken(app: FirebaseApp): Promise<string>;
declare global {
interface Window {
grecaptcha: GreCAPTCHATopLevel | undefined;
}
}
export interface GreCAPTCHATopLevel extends GreCAPTCHA {
enterprise: GreCAPTCHA;
}
export interface GreCAPTCHA {
ready: (callback: () => void) => void;
execute: (siteKey: string, options: {
action: string;
}) => Promise<string>;
render: (container: string | HTMLElement, parameters: GreCAPTCHARenderOption) => string;
}
export interface GreCAPTCHARenderOption {
sitekey: string;
size: 'invisible';
callback: () => void;
'error-callback': () => void;
}

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.
*/
import '../test/setup';

View file

@ -0,0 +1,54 @@
/**
* @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 { AppCheckProvider, AppCheckTokenInternal, AppCheckTokenObserver } from './types';
import { Refresher } from './proactive-refresh';
import { Deferred } from '@firebase/util';
import { GreCAPTCHA } from './recaptcha';
export interface AppCheckState {
activated: boolean;
tokenObservers: AppCheckTokenObserver[];
provider?: AppCheckProvider;
token?: AppCheckTokenInternal;
cachedTokenPromise?: Promise<AppCheckTokenInternal | undefined>;
exchangeTokenPromise?: Promise<AppCheckTokenInternal>;
tokenRefresher?: Refresher;
reCAPTCHAState?: ReCAPTCHAState;
isTokenAutoRefreshEnabled?: boolean;
}
export interface ReCAPTCHAState {
initialized: Deferred<GreCAPTCHA>;
widgetId?: string;
succeeded?: boolean;
}
export interface DebugState {
initialized: boolean;
enabled: boolean;
token?: Deferred<string>;
}
export declare const DEFAULT_STATE: AppCheckState;
/**
* Gets a reference to the state object.
*/
export declare function getStateReference(app: FirebaseApp): AppCheckState;
/**
* Set once on initialization. The map should hold the same reference to the
* same object until this entry is deleted.
*/
export declare function setInitialState(app: FirebaseApp, state: AppCheckState): AppCheckState;
export declare function clearState(): void;
export declare function getDebugState(): DebugState;

View file

@ -0,0 +1,27 @@
/**
* @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 { AppCheckTokenInternal } from './types';
/**
* Always resolves. In case of an error reading from indexeddb, resolve with undefined
*/
export declare function readTokenFromStorage(app: FirebaseApp): Promise<AppCheckTokenInternal | undefined>;
/**
* Always resolves. In case of an error writing to indexeddb, print a warning and resolve the promise
*/
export declare function writeTokenToStorage(app: FirebaseApp, token?: AppCheckTokenInternal): Promise<void>;
export declare function readOrCreateDebugTokenFromStorage(): Promise<string>;

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.
*/
import '../test/setup';

View file

@ -0,0 +1,66 @@
/**
* @license
* Copyright 2021 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 { PartialObserver } from '@firebase/util';
import { AppCheckToken, AppCheckTokenListener } from './public-types';
export interface FirebaseAppCheckInternal {
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
getLimitedUseToken(): Promise<AppCheckTokenResult>;
addTokenListener(listener: AppCheckTokenListener): void;
removeTokenListener(listener: AppCheckTokenListener): void;
}
export interface AppCheckTokenObserver extends PartialObserver<AppCheckTokenResult> {
next: AppCheckTokenListener;
type: ListenerType;
}
export declare const enum ListenerType {
'INTERNAL' = "INTERNAL",
'EXTERNAL' = "EXTERNAL"
}
export interface AppCheckTokenResult {
readonly token: string;
readonly error?: Error;
readonly internalError?: Error;
}
export interface AppCheckTokenInternal extends AppCheckToken {
issuedAtTimeMillis: number;
}
export interface AppCheckProvider {
/**
* Returns an App Check token.
* @internal
*/
getToken: () => Promise<AppCheckTokenInternal>;
/**
* @internal
*/
initialize(app: FirebaseApp): void;
}
/**
* @internal
*/
export declare type _AppCheckInternalComponentName = 'app-check-internal';
export interface ThrottleData {
allowRequestsAfter: number;
backoffCount: number;
httpStatus: number;
}
declare module '@firebase/component' {
interface NameServiceMapping {
'app-check-internal': FirebaseAppCheckInternal;
}
}

View file

@ -0,0 +1,21 @@
/**
* @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 { GreCAPTCHA } from './recaptcha';
import { FirebaseApp } from '@firebase/app';
export declare function getRecaptcha(isEnterprise?: boolean): GreCAPTCHA | undefined;
export declare function ensureActivated(app: FirebaseApp): void;
export declare function getDurationString(durationInMillis: number): string;

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 {};

View file

@ -0,0 +1,34 @@
/**
* @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 { GreCAPTCHA, GreCAPTCHATopLevel } from '../src/recaptcha';
import { Provider } from '@firebase/component';
import { AppCheck, CustomProvider } from '../src';
export declare const FAKE_SITE_KEY = "fake-site-key";
export declare function getFakeApp(overrides?: Record<string, any>): FirebaseApp;
export declare function getFakeAppCheck(app: FirebaseApp): AppCheck;
export declare function getFullApp(): FirebaseApp;
export declare function getFakeCustomTokenProvider(): CustomProvider;
export declare function getFakeHeartbeatServiceProvider(fakeLogString?: string): Provider<'heartbeat'>;
export declare function getFakeGreCAPTCHA(isTopLevel?: boolean): GreCAPTCHATopLevel | GreCAPTCHA;
/**
* Returns all script tags in DOM matching our reCAPTCHA url pattern.
* Tests in other files may have inserted multiple reCAPTCHA scripts, because they don't
* care about it.
*/
export declare function findgreCAPTCHAScriptsOnPage(): HTMLScriptElement[];
export declare function removegreCAPTCHAScriptsOnPage(): void;