summaryrefslogtreecommitdiff
path: root/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
committeraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
commit8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch)
tree05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha
pain
Diffstat (limited to 'frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha')
-rw-r--r--frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts78
-rw-r--r--frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts45
-rw-r--r--frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_loader.d.ts49
-rw-r--r--frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts66
-rw-r--r--frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_verifier.d.ts92
5 files changed, 330 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts
new file mode 100644
index 0000000..e47806b
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha.d.ts
@@ -0,0 +1,78 @@
+/**
+ * @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 { RecaptchaParameters } from '../../model/public_types';
+import { GetRecaptchaConfigResponse, RecaptchaEnforcementProviderState } from '../../api/authentication/recaptcha';
+import { EnforcementState } from '../../api/index';
+export interface Recaptcha {
+ render: (container: HTMLElement, parameters: RecaptchaParameters) => number;
+ getResponse: (id: number) => string;
+ execute: (id: number) => unknown;
+ reset: (id: number) => unknown;
+}
+export declare function isV2(grecaptcha: Recaptcha | GreCAPTCHA | undefined): grecaptcha is Recaptcha;
+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';
+}
+export declare function isEnterprise(grecaptcha: Recaptcha | GreCAPTCHA | undefined): grecaptcha is GreCAPTCHATopLevel;
+declare global {
+ interface Window {
+ grecaptcha?: Recaptcha | GreCAPTCHATopLevel;
+ }
+}
+export declare class RecaptchaConfig {
+ /**
+ * The reCAPTCHA site key.
+ */
+ siteKey: string;
+ /**
+ * The list of providers and their enablement status for reCAPTCHA Enterprise.
+ */
+ recaptchaEnforcementState: RecaptchaEnforcementProviderState[];
+ constructor(response: GetRecaptchaConfigResponse);
+ /**
+ * Returns the reCAPTCHA Enterprise enforcement state for the given provider.
+ *
+ * @param providerStr - The provider whose enforcement state is to be returned.
+ * @returns The reCAPTCHA Enterprise enforcement state for the given provider.
+ */
+ getProviderEnforcementState(providerStr: string): EnforcementState | null;
+ /**
+ * Returns true if the reCAPTCHA Enterprise enforcement state for the provider is set to ENFORCE or AUDIT.
+ *
+ * @param providerStr - The provider whose enablement state is to be returned.
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for the given provider.
+ */
+ isProviderEnabled(providerStr: string): boolean;
+ /**
+ * Returns true if reCAPTCHA Enterprise protection is enabled in at least one provider, otherwise
+ * returns false.
+ *
+ * @returns Whether or not reCAPTCHA Enterprise protection is enabled for at least one provider.
+ */
+ isAnyProviderEnabled(): boolean;
+}
diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts
new file mode 100644
index 0000000..adead53
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts
@@ -0,0 +1,45 @@
+/**
+ * @license
+ * Copyright 2022 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 { RecaptchaActionName, RecaptchaAuthProvider } from '../../api';
+import { Auth } from '../../model/public_types';
+import { AuthInternal } from '../../model/auth';
+export declare const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = "recaptcha-enterprise";
+export declare const FAKE_TOKEN = "NO_RECAPTCHA";
+export declare class RecaptchaEnterpriseVerifier {
+ /**
+ * Identifies the type of application verifier (e.g. "recaptcha-enterprise").
+ */
+ readonly type = "recaptcha-enterprise";
+ private readonly auth;
+ /**
+ *
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
+ *
+ */
+ constructor(authExtern: Auth);
+ /**
+ * Executes the verification process.
+ *
+ * @returns A Promise for a token that can be used to assert the validity of a request.
+ */
+ verify(action?: string, forceRefresh?: boolean): Promise<string>;
+}
+export declare function injectRecaptchaFields<T extends object>(auth: AuthInternal, request: T, action: RecaptchaActionName, isCaptchaResp?: boolean, isFakeToken?: boolean): Promise<T>;
+type ActionMethod<TRequest, TResponse> = (auth: AuthInternal, request: TRequest) => Promise<TResponse>;
+export declare function handleRecaptchaFlow<TRequest extends object, TResponse>(authInstance: AuthInternal, request: TRequest, actionName: RecaptchaActionName, actionMethod: ActionMethod<TRequest, TResponse>, recaptchaAuthProvider: RecaptchaAuthProvider): Promise<TResponse>;
+export declare function _initializeRecaptchaConfig(auth: Auth): Promise<void>;
+export {};
diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_loader.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_loader.d.ts
new file mode 100644
index 0000000..b0fc1d9
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_loader.d.ts
@@ -0,0 +1,49 @@
+/**
+ * @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 { AuthInternal } from '../../model/auth';
+import { Recaptcha } from './recaptcha';
+export declare const _JSLOAD_CALLBACK: string;
+/**
+ * We need to mark this interface as internal explicitly to exclude it in the public typings, because
+ * it references AuthInternal which has a circular dependency with UserInternal.
+ *
+ * @internal
+ */
+export interface ReCaptchaLoader {
+ load(auth: AuthInternal, hl?: string): Promise<Recaptcha>;
+ clearedOneInstance(): void;
+}
+/**
+ * Loader for the GReCaptcha library. There should only ever be one of this.
+ */
+export declare class ReCaptchaLoaderImpl implements ReCaptchaLoader {
+ private hostLanguage;
+ private counter;
+ /**
+ * Check for `render()` method. `window.grecaptcha` will exist if the Enterprise
+ * version of the ReCAPTCHA script was loaded by someone else (e.g. App Check) but
+ * `window.grecaptcha.render()` will not. Another load will add it.
+ */
+ private readonly librarySeparatelyLoaded;
+ load(auth: AuthInternal, hl?: string): Promise<Recaptcha>;
+ clearedOneInstance(): void;
+ private shouldResolveImmediately;
+}
+export declare class MockReCaptchaLoaderImpl implements ReCaptchaLoader {
+ load(auth: AuthInternal): Promise<Recaptcha>;
+ clearedOneInstance(): void;
+}
diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts
new file mode 100644
index 0000000..9cab21a
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_mock.d.ts
@@ -0,0 +1,66 @@
+/**
+ * @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 { AuthInternal } from '../../model/auth';
+import { RecaptchaParameters } from '../../model/public_types';
+import { Recaptcha, GreCAPTCHATopLevel, GreCAPTCHARenderOption, GreCAPTCHA } from './recaptcha';
+export declare const _SOLVE_TIME_MS = 500;
+export declare const _EXPIRATION_TIME_MS = 60000;
+export declare const _WIDGET_ID_START = 1000000000000;
+export interface Widget {
+ getResponse: () => string | null;
+ delete: () => void;
+ execute: () => void;
+}
+export declare class MockReCaptcha implements Recaptcha {
+ private readonly auth;
+ private counter;
+ _widgets: Map<number, Widget>;
+ constructor(auth: AuthInternal);
+ render(container: string | HTMLElement, parameters?: RecaptchaParameters): number;
+ reset(optWidgetId?: number): void;
+ getResponse(optWidgetId?: number): string;
+ execute(optWidgetId?: number | string): Promise<string>;
+}
+export declare class MockGreCAPTCHATopLevel implements GreCAPTCHATopLevel {
+ enterprise: GreCAPTCHA;
+ ready(callback: () => void): void;
+ execute(_siteKey: string, _options: {
+ action: string;
+ }): Promise<string>;
+ render(_container: string | HTMLElement, _parameters: GreCAPTCHARenderOption): string;
+}
+export declare class MockGreCAPTCHA implements GreCAPTCHA {
+ ready(callback: () => void): void;
+ execute(_siteKey: string, _options: {
+ action: string;
+ }): Promise<string>;
+ render(_container: string | HTMLElement, _parameters: GreCAPTCHARenderOption): string;
+}
+export declare class MockWidget {
+ private readonly params;
+ private readonly container;
+ private readonly isVisible;
+ private timerId;
+ private deleted;
+ private responseToken;
+ private readonly clickHandler;
+ constructor(containerOrId: string | HTMLElement, appName: string, params: RecaptchaParameters);
+ getResponse(): string | null;
+ delete(): void;
+ execute(): void;
+ private checkIfDeleted;
+}
diff --git a/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_verifier.d.ts b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_verifier.d.ts
new file mode 100644
index 0000000..cfca5c6
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/auth/dist/node-esm/src/platform_browser/recaptcha/recaptcha_verifier.d.ts
@@ -0,0 +1,92 @@
+/**
+ * @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 { Auth, RecaptchaParameters } from '../../model/public_types';
+import { ApplicationVerifierInternal } from '../../model/application_verifier';
+import { ReCaptchaLoader } from './recaptcha_loader';
+export declare const RECAPTCHA_VERIFIER_TYPE = "recaptcha";
+/**
+ * An {@link https://www.google.com/recaptcha/ | reCAPTCHA}-based application verifier.
+ *
+ * @remarks
+ * `RecaptchaVerifier` does not work in a Node.js environment.
+ *
+ * @public
+ */
+export declare class RecaptchaVerifier implements ApplicationVerifierInternal {
+ private readonly parameters;
+ /**
+ * The application verifier type.
+ *
+ * @remarks
+ * For a reCAPTCHA verifier, this is 'recaptcha'.
+ */
+ readonly type = "recaptcha";
+ private destroyed;
+ private widgetId;
+ private readonly container;
+ private readonly isInvisible;
+ private readonly tokenChangeListeners;
+ private renderPromise;
+ private readonly auth;
+ /** @internal */
+ readonly _recaptchaLoader: ReCaptchaLoader;
+ private recaptcha;
+ /**
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
+ *
+ * @param containerOrId - The reCAPTCHA container parameter.
+ *
+ * @remarks
+ * This has different meaning depending on whether the reCAPTCHA is hidden or visible. For a
+ * visible reCAPTCHA the container must be empty. If a string is used, it has to correspond to
+ * an element ID. The corresponding element must also must be in the DOM at the time of
+ * initialization.
+ *
+ * @param parameters - The optional reCAPTCHA parameters.
+ *
+ * @remarks
+ * Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted except for
+ * the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
+ * configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
+ * 'invisible'.
+ */
+ constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters);
+ /**
+ * Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA token.
+ *
+ * @returns A Promise for the reCAPTCHA token.
+ */
+ verify(): Promise<string>;
+ /**
+ * Renders the reCAPTCHA widget on the page.
+ *
+ * @returns A Promise that resolves with the reCAPTCHA widget ID.
+ */
+ render(): Promise<number>;
+ /** @internal */
+ _reset(): void;
+ /**
+ * Clears the reCAPTCHA widget from the page and destroys the instance.
+ */
+ clear(): void;
+ private validateStartingState;
+ private makeTokenCallback;
+ private assertNotDestroyed;
+ private makeRenderPromise;
+ private init;
+ private getAssertedRecaptcha;
+}