@depup/firebase__app-check 0.11.1-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/app-check-public.d.ts +248 -0
- package/dist/app-check.d.ts +290 -0
- package/dist/esm/index.esm.js +1694 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/src/api.d.ts +105 -0
- package/dist/esm/src/api.test.d.ts +17 -0
- package/dist/esm/src/client.d.ts +30 -0
- package/dist/esm/src/client.test.d.ts +17 -0
- package/dist/esm/src/constants.d.ts +40 -0
- package/dist/esm/src/debug.d.ts +22 -0
- package/dist/esm/src/debug.test.d.ts +17 -0
- package/dist/esm/src/errors.d.ts +66 -0
- package/dist/esm/src/factory.d.ts +31 -0
- package/dist/esm/src/index.d.ts +14 -0
- package/dist/esm/src/indexeddb.d.ts +22 -0
- package/dist/esm/src/internal-api.d.ts +44 -0
- package/dist/esm/src/internal-api.test.d.ts +17 -0
- package/dist/esm/src/logger.d.ts +18 -0
- package/dist/esm/src/proactive-refresh.d.ts +35 -0
- package/dist/esm/src/proactive-refresh.test.d.ts +17 -0
- package/dist/esm/src/providers.d.ts +108 -0
- package/dist/esm/src/providers.test.d.ts +17 -0
- package/dist/esm/src/public-types.d.ts +85 -0
- package/dist/esm/src/recaptcha.d.ts +43 -0
- package/dist/esm/src/recaptcha.test.d.ts +17 -0
- package/dist/esm/src/state.d.ts +54 -0
- package/dist/esm/src/storage.d.ts +27 -0
- package/dist/esm/src/storage.test.d.ts +17 -0
- package/dist/esm/src/types.d.ts +66 -0
- package/dist/esm/src/util.d.ts +21 -0
- package/dist/esm/test/setup.d.ts +17 -0
- package/dist/esm/test/util.d.ts +34 -0
- package/dist/index.cjs.js +1705 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/src/api.d.ts +105 -0
- package/dist/src/api.test.d.ts +17 -0
- package/dist/src/client.d.ts +30 -0
- package/dist/src/client.test.d.ts +17 -0
- package/dist/src/constants.d.ts +40 -0
- package/dist/src/debug.d.ts +22 -0
- package/dist/src/debug.test.d.ts +17 -0
- package/dist/src/errors.d.ts +66 -0
- package/dist/src/factory.d.ts +31 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/indexeddb.d.ts +22 -0
- package/dist/src/internal-api.d.ts +44 -0
- package/dist/src/internal-api.test.d.ts +17 -0
- package/dist/src/logger.d.ts +18 -0
- package/dist/src/proactive-refresh.d.ts +35 -0
- package/dist/src/proactive-refresh.test.d.ts +17 -0
- package/dist/src/providers.d.ts +108 -0
- package/dist/src/providers.test.d.ts +17 -0
- package/dist/src/public-types.d.ts +85 -0
- package/dist/src/recaptcha.d.ts +43 -0
- package/dist/src/recaptcha.test.d.ts +17 -0
- package/dist/src/state.d.ts +54 -0
- package/dist/src/storage.d.ts +27 -0
- package/dist/src/storage.test.d.ts +17 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/types.d.ts +66 -0
- package/dist/src/util.d.ts +21 -0
- package/dist/test/setup.d.ts +17 -0
- package/dist/test/util.d.ts +34 -0
- package/package.json +94 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Firebase App Check Web SDK.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Firebase App Check does not work in a Node.js environment using `ReCaptchaV3Provider` or
|
|
6
|
+
* `ReCaptchaEnterpriseProvider`, but can be used in Node.js if you use
|
|
7
|
+
* `CustomProvider` and write your own attestation method.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import { _AppCheckInternalComponentName } from './types';
|
|
12
|
+
export { _AppCheckInternalComponentName };
|
|
13
|
+
export * from './api';
|
|
14
|
+
export * from './public-types';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckTokenInternal } from './types';
|
|
19
|
+
export declare function readTokenFromIndexedDB(app: FirebaseApp): Promise<AppCheckTokenInternal | undefined>;
|
|
20
|
+
export declare function writeTokenToIndexedDB(app: FirebaseApp, token?: AppCheckTokenInternal): Promise<void>;
|
|
21
|
+
export declare function writeDebugTokenToIndexedDB(token: string): Promise<void>;
|
|
22
|
+
export declare function readDebugTokenFromIndexedDB(): Promise<string | undefined>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckTokenResult, AppCheckTokenInternal, ListenerType } from './types';
|
|
19
|
+
import { AppCheckTokenListener } from './public-types';
|
|
20
|
+
import { AppCheckService } from './factory';
|
|
21
|
+
export declare const defaultTokenErrorData: {
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Stringify and base64 encode token error data.
|
|
26
|
+
*
|
|
27
|
+
* @param tokenError Error data, currently hardcoded.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatDummyToken(tokenErrorData: Record<string, string>): string;
|
|
30
|
+
/**
|
|
31
|
+
* This function always resolves.
|
|
32
|
+
* The result will contain an error field if there is any error.
|
|
33
|
+
* In case there is an error, the token field in the result will be populated with a dummy value
|
|
34
|
+
*/
|
|
35
|
+
export declare function getToken(appCheck: AppCheckService, forceRefresh?: boolean, shouldLogErrors?: boolean): Promise<AppCheckTokenResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Internal API for limited use tokens. Skips all FAC state and simply calls
|
|
38
|
+
* the underlying provider.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getLimitedUseToken(appCheck: AppCheckService): Promise<AppCheckTokenResult>;
|
|
41
|
+
export declare function addTokenListener(appCheck: AppCheckService, type: ListenerType, listener: AppCheckTokenListener, onError?: (error: Error) => void): void;
|
|
42
|
+
export declare function removeTokenListener(app: FirebaseApp, listener: AppCheckTokenListener): void;
|
|
43
|
+
export declare function notifyTokenListeners(app: FirebaseApp, token: AppCheckTokenResult): void;
|
|
44
|
+
export declare function isValid(token: AppCheckTokenInternal): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import '../test/setup';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Logger } from '@firebase/logger';
|
|
18
|
+
export declare const logger: Logger;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Port from auth proactiverefresh.js
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare class Refresher {
|
|
22
|
+
private readonly operation;
|
|
23
|
+
private readonly retryPolicy;
|
|
24
|
+
private readonly getWaitDuration;
|
|
25
|
+
private readonly lowerBound;
|
|
26
|
+
private readonly upperBound;
|
|
27
|
+
private pending;
|
|
28
|
+
private nextErrorWaitInterval;
|
|
29
|
+
constructor(operation: () => Promise<unknown>, retryPolicy: (error: unknown) => boolean, getWaitDuration: () => number, lowerBound: number, upperBound: number);
|
|
30
|
+
start(): void;
|
|
31
|
+
stop(): void;
|
|
32
|
+
isRunning(): boolean;
|
|
33
|
+
private process;
|
|
34
|
+
private getNextRun;
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import '../test/setup';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { CustomProviderOptions } from './public-types';
|
|
19
|
+
import { AppCheckProvider, AppCheckTokenInternal } from './types';
|
|
20
|
+
/**
|
|
21
|
+
* App Check provider that can obtain a reCAPTCHA V3 token and exchange it
|
|
22
|
+
* for an App Check token.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare class ReCaptchaV3Provider implements AppCheckProvider {
|
|
27
|
+
private _siteKey;
|
|
28
|
+
private _app?;
|
|
29
|
+
private _heartbeatServiceProvider?;
|
|
30
|
+
/**
|
|
31
|
+
* Throttle requests on certain error codes to prevent too many retries
|
|
32
|
+
* in a short time.
|
|
33
|
+
*/
|
|
34
|
+
private _throttleData;
|
|
35
|
+
/**
|
|
36
|
+
* Create a ReCaptchaV3Provider instance.
|
|
37
|
+
* @param siteKey - ReCAPTCHA V3 siteKey.
|
|
38
|
+
*/
|
|
39
|
+
constructor(_siteKey: string);
|
|
40
|
+
/**
|
|
41
|
+
* Returns an App Check token.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
getToken(): Promise<AppCheckTokenInternal>;
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
initialize(app: FirebaseApp): void;
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
isEqual(otherProvider: unknown): boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* App Check provider that can obtain a reCAPTCHA Enterprise token and exchange it
|
|
56
|
+
* for an App Check token.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare class ReCaptchaEnterpriseProvider implements AppCheckProvider {
|
|
61
|
+
private _siteKey;
|
|
62
|
+
private _app?;
|
|
63
|
+
private _heartbeatServiceProvider?;
|
|
64
|
+
/**
|
|
65
|
+
* Throttle requests on certain error codes to prevent too many retries
|
|
66
|
+
* in a short time.
|
|
67
|
+
*/
|
|
68
|
+
private _throttleData;
|
|
69
|
+
/**
|
|
70
|
+
* Create a ReCaptchaEnterpriseProvider instance.
|
|
71
|
+
* @param siteKey - reCAPTCHA Enterprise score-based site key.
|
|
72
|
+
*/
|
|
73
|
+
constructor(_siteKey: string);
|
|
74
|
+
/**
|
|
75
|
+
* Returns an App Check token.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
getToken(): Promise<AppCheckTokenInternal>;
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
initialize(app: FirebaseApp): void;
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
isEqual(otherProvider: unknown): boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Custom provider class.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export declare class CustomProvider implements AppCheckProvider {
|
|
93
|
+
private _customProviderOptions;
|
|
94
|
+
private _app?;
|
|
95
|
+
constructor(_customProviderOptions: CustomProviderOptions);
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
getToken(): Promise<AppCheckTokenInternal>;
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
initialize(app: FirebaseApp): void;
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
isEqual(otherProvider: unknown): boolean;
|
|
108
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import '../test/setup';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { CustomProvider, ReCaptchaEnterpriseProvider, ReCaptchaV3Provider } from './providers';
|
|
19
|
+
export { Unsubscribe, PartialObserver } from '@firebase/util';
|
|
20
|
+
/**
|
|
21
|
+
* The Firebase App Check service interface.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export interface AppCheck {
|
|
26
|
+
/**
|
|
27
|
+
* The {@link @firebase/app#FirebaseApp} this `AppCheck` instance is associated with.
|
|
28
|
+
*/
|
|
29
|
+
app: FirebaseApp;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The token returned from an App Check provider.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export interface AppCheckToken {
|
|
36
|
+
readonly token: string;
|
|
37
|
+
/**
|
|
38
|
+
* The local timestamp after which the token will expire.
|
|
39
|
+
*/
|
|
40
|
+
readonly expireTimeMillis: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export type _AppCheckComponentName = 'app-check';
|
|
46
|
+
/**
|
|
47
|
+
* Options for App Check initialization.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export interface AppCheckOptions {
|
|
51
|
+
/**
|
|
52
|
+
* A reCAPTCHA V3 provider, reCAPTCHA Enterprise provider, or custom provider.
|
|
53
|
+
*/
|
|
54
|
+
provider: CustomProvider | ReCaptchaV3Provider | ReCaptchaEnterpriseProvider;
|
|
55
|
+
/**
|
|
56
|
+
* If set to true, enables automatic background refresh of App Check token.
|
|
57
|
+
*/
|
|
58
|
+
isTokenAutoRefreshEnabled?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options when creating a {@link CustomProvider}.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export interface CustomProviderOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Function to get an App Check token through a custom provider
|
|
67
|
+
* service.
|
|
68
|
+
*/
|
|
69
|
+
getToken: () => Promise<AppCheckToken>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Result returned by `getToken()`.
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export interface AppCheckTokenResult {
|
|
76
|
+
/**
|
|
77
|
+
* The token string in JWT format.
|
|
78
|
+
*/
|
|
79
|
+
readonly token: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A listener that is called whenever the App Check token changes.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export type AppCheckTokenListener = (token: AppCheckTokenResult) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
export declare const RECAPTCHA_URL = "https://www.google.com/recaptcha/api.js";
|
|
19
|
+
export declare const RECAPTCHA_ENTERPRISE_URL = "https://www.google.com/recaptcha/enterprise.js";
|
|
20
|
+
export declare function initializeV3(app: FirebaseApp, siteKey: string): Promise<GreCAPTCHA>;
|
|
21
|
+
export declare function initializeEnterprise(app: FirebaseApp, siteKey: string): Promise<GreCAPTCHA>;
|
|
22
|
+
export declare function getToken(app: FirebaseApp): Promise<string>;
|
|
23
|
+
declare global {
|
|
24
|
+
interface Window {
|
|
25
|
+
grecaptcha: GreCAPTCHATopLevel | undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export interface GreCAPTCHATopLevel extends GreCAPTCHA {
|
|
29
|
+
enterprise: GreCAPTCHA;
|
|
30
|
+
}
|
|
31
|
+
export interface GreCAPTCHA {
|
|
32
|
+
ready: (callback: () => void) => void;
|
|
33
|
+
execute: (siteKey: string, options: {
|
|
34
|
+
action: string;
|
|
35
|
+
}) => Promise<string>;
|
|
36
|
+
render: (container: string | HTMLElement, parameters: GreCAPTCHARenderOption) => string;
|
|
37
|
+
}
|
|
38
|
+
export interface GreCAPTCHARenderOption {
|
|
39
|
+
sitekey: string;
|
|
40
|
+
size: 'invisible';
|
|
41
|
+
callback: () => void;
|
|
42
|
+
'error-callback': () => void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import '../test/setup';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckProvider, AppCheckTokenInternal, AppCheckTokenObserver } from './types';
|
|
19
|
+
import { Refresher } from './proactive-refresh';
|
|
20
|
+
import { Deferred } from '@firebase/util';
|
|
21
|
+
import { GreCAPTCHA } from './recaptcha';
|
|
22
|
+
export interface AppCheckState {
|
|
23
|
+
activated: boolean;
|
|
24
|
+
tokenObservers: AppCheckTokenObserver[];
|
|
25
|
+
provider?: AppCheckProvider;
|
|
26
|
+
token?: AppCheckTokenInternal;
|
|
27
|
+
cachedTokenPromise?: Promise<AppCheckTokenInternal | undefined>;
|
|
28
|
+
exchangeTokenPromise?: Promise<AppCheckTokenInternal>;
|
|
29
|
+
tokenRefresher?: Refresher;
|
|
30
|
+
reCAPTCHAState?: ReCAPTCHAState;
|
|
31
|
+
isTokenAutoRefreshEnabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ReCAPTCHAState {
|
|
34
|
+
initialized: Deferred<GreCAPTCHA>;
|
|
35
|
+
widgetId?: string;
|
|
36
|
+
succeeded?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface DebugState {
|
|
39
|
+
initialized: boolean;
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
token?: Deferred<string>;
|
|
42
|
+
}
|
|
43
|
+
export declare const DEFAULT_STATE: AppCheckState;
|
|
44
|
+
/**
|
|
45
|
+
* Gets a reference to the state object.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getStateReference(app: FirebaseApp): AppCheckState;
|
|
48
|
+
/**
|
|
49
|
+
* Set once on initialization. The map should hold the same reference to the
|
|
50
|
+
* same object until this entry is deleted.
|
|
51
|
+
*/
|
|
52
|
+
export declare function setInitialState(app: FirebaseApp, state: AppCheckState): AppCheckState;
|
|
53
|
+
export declare function clearState(): void;
|
|
54
|
+
export declare function getDebugState(): DebugState;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckTokenInternal } from './types';
|
|
19
|
+
/**
|
|
20
|
+
* Always resolves. In case of an error reading from indexeddb, resolve with undefined
|
|
21
|
+
*/
|
|
22
|
+
export declare function readTokenFromStorage(app: FirebaseApp): Promise<AppCheckTokenInternal | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Always resolves. In case of an error writing to indexeddb, print a warning and resolve the promise
|
|
25
|
+
*/
|
|
26
|
+
export declare function writeTokenToStorage(app: FirebaseApp, token?: AppCheckTokenInternal): Promise<void>;
|
|
27
|
+
export declare function readOrCreateDebugTokenFromStorage(): Promise<string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import '../test/setup';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { PartialObserver } from '@firebase/util';
|
|
19
|
+
import { AppCheckToken, AppCheckTokenListener } from './public-types';
|
|
20
|
+
export interface FirebaseAppCheckInternal {
|
|
21
|
+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
22
|
+
getLimitedUseToken(): Promise<AppCheckTokenResult>;
|
|
23
|
+
addTokenListener(listener: AppCheckTokenListener): void;
|
|
24
|
+
removeTokenListener(listener: AppCheckTokenListener): void;
|
|
25
|
+
}
|
|
26
|
+
export interface AppCheckTokenObserver extends PartialObserver<AppCheckTokenResult> {
|
|
27
|
+
next: AppCheckTokenListener;
|
|
28
|
+
type: ListenerType;
|
|
29
|
+
}
|
|
30
|
+
export declare const enum ListenerType {
|
|
31
|
+
'INTERNAL' = "INTERNAL",
|
|
32
|
+
'EXTERNAL' = "EXTERNAL"
|
|
33
|
+
}
|
|
34
|
+
export interface AppCheckTokenResult {
|
|
35
|
+
readonly token: string;
|
|
36
|
+
readonly error?: Error;
|
|
37
|
+
readonly internalError?: Error;
|
|
38
|
+
}
|
|
39
|
+
export interface AppCheckTokenInternal extends AppCheckToken {
|
|
40
|
+
issuedAtTimeMillis: number;
|
|
41
|
+
}
|
|
42
|
+
export interface AppCheckProvider {
|
|
43
|
+
/**
|
|
44
|
+
* Returns an App Check token.
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
getToken: () => Promise<AppCheckTokenInternal>;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
initialize(app: FirebaseApp): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export type _AppCheckInternalComponentName = 'app-check-internal';
|
|
57
|
+
export interface ThrottleData {
|
|
58
|
+
allowRequestsAfter: number;
|
|
59
|
+
backoffCount: number;
|
|
60
|
+
httpStatus: number;
|
|
61
|
+
}
|
|
62
|
+
declare module '@firebase/component' {
|
|
63
|
+
interface NameServiceMapping {
|
|
64
|
+
'app-check-internal': FirebaseAppCheckInternal;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { GreCAPTCHA } from './recaptcha';
|
|
18
|
+
import { FirebaseApp } from '@firebase/app';
|
|
19
|
+
export declare function getRecaptcha(isEnterprise?: boolean): GreCAPTCHA | undefined;
|
|
20
|
+
export declare function ensureActivated(app: FirebaseApp): void;
|
|
21
|
+
export declare function getDurationString(durationInMillis: number): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|