@react-native-firebase/app-check 23.7.0 → 23.8.1

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/commonjs/ReactNativeFirebaseAppCheckProvider.js +19 -0
  3. package/dist/commonjs/ReactNativeFirebaseAppCheckProvider.js.map +1 -0
  4. package/dist/commonjs/index.js +38 -0
  5. package/dist/commonjs/index.js.map +1 -0
  6. package/dist/commonjs/modular.js +124 -0
  7. package/dist/commonjs/modular.js.map +1 -0
  8. package/dist/commonjs/namespaced.js +212 -0
  9. package/dist/commonjs/namespaced.js.map +1 -0
  10. package/dist/commonjs/package.json +1 -0
  11. package/dist/commonjs/types/appcheck.js +93 -0
  12. package/dist/commonjs/types/appcheck.js.map +1 -0
  13. package/dist/commonjs/version.js +9 -0
  14. package/dist/commonjs/version.js.map +1 -0
  15. package/dist/commonjs/web/RNFBAppCheckModule.android.js +10 -0
  16. package/dist/commonjs/web/RNFBAppCheckModule.android.js.map +1 -0
  17. package/dist/commonjs/web/RNFBAppCheckModule.ios.js +10 -0
  18. package/dist/commonjs/web/RNFBAppCheckModule.ios.js.map +1 -0
  19. package/dist/commonjs/web/RNFBAppCheckModule.js +91 -0
  20. package/dist/commonjs/web/RNFBAppCheckModule.js.map +1 -0
  21. package/dist/module/ReactNativeFirebaseAppCheckProvider.js +14 -0
  22. package/dist/module/ReactNativeFirebaseAppCheckProvider.js.map +1 -0
  23. package/dist/module/index.js +28 -0
  24. package/dist/module/index.js.map +1 -0
  25. package/dist/module/modular.js +110 -0
  26. package/dist/module/modular.js.map +1 -0
  27. package/{lib/index.js → dist/module/namespaced.js} +50 -80
  28. package/dist/module/namespaced.js.map +1 -0
  29. package/dist/module/package.json +1 -0
  30. package/dist/module/types/appcheck.js +89 -0
  31. package/dist/module/types/appcheck.js.map +1 -0
  32. package/dist/module/version.js +5 -0
  33. package/dist/module/version.js.map +1 -0
  34. package/dist/module/web/RNFBAppCheckModule.android.js +6 -0
  35. package/dist/module/web/RNFBAppCheckModule.android.js.map +1 -0
  36. package/dist/module/web/RNFBAppCheckModule.ios.js +6 -0
  37. package/dist/module/web/RNFBAppCheckModule.ios.js.map +1 -0
  38. package/{lib → dist/module}/web/RNFBAppCheckModule.js +19 -27
  39. package/dist/module/web/RNFBAppCheckModule.js.map +1 -0
  40. package/dist/typescript/commonjs/lib/ReactNativeFirebaseAppCheckProvider.d.ts +8 -0
  41. package/dist/typescript/commonjs/lib/ReactNativeFirebaseAppCheckProvider.d.ts.map +1 -0
  42. package/dist/typescript/commonjs/lib/index.d.ts +5 -0
  43. package/dist/typescript/commonjs/lib/index.d.ts.map +1 -0
  44. package/dist/typescript/commonjs/lib/modular.d.ts +57 -0
  45. package/dist/typescript/commonjs/lib/modular.d.ts.map +1 -0
  46. package/dist/typescript/commonjs/lib/namespaced.d.ts +17 -0
  47. package/dist/typescript/commonjs/lib/namespaced.d.ts.map +1 -0
  48. package/{lib/index.d.ts → dist/typescript/commonjs/lib/types/appcheck.d.ts} +162 -221
  49. package/dist/typescript/commonjs/lib/types/appcheck.d.ts.map +1 -0
  50. package/dist/typescript/commonjs/lib/version.d.ts +2 -0
  51. package/dist/typescript/commonjs/lib/version.d.ts.map +1 -0
  52. package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.android.d.ts +3 -0
  53. package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.android.d.ts.map +1 -0
  54. package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.d.ts +18 -0
  55. package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.d.ts.map +1 -0
  56. package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.ios.d.ts +3 -0
  57. package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.ios.d.ts.map +1 -0
  58. package/dist/typescript/commonjs/package.json +1 -0
  59. package/dist/typescript/module/lib/ReactNativeFirebaseAppCheckProvider.d.ts +8 -0
  60. package/dist/typescript/module/lib/ReactNativeFirebaseAppCheckProvider.d.ts.map +1 -0
  61. package/dist/typescript/module/lib/index.d.ts +5 -0
  62. package/dist/typescript/module/lib/index.d.ts.map +1 -0
  63. package/dist/typescript/module/lib/modular.d.ts +57 -0
  64. package/dist/typescript/module/lib/modular.d.ts.map +1 -0
  65. package/dist/typescript/module/lib/namespaced.d.ts +17 -0
  66. package/dist/typescript/module/lib/namespaced.d.ts.map +1 -0
  67. package/dist/typescript/module/lib/types/appcheck.d.ts +299 -0
  68. package/dist/typescript/module/lib/types/appcheck.d.ts.map +1 -0
  69. package/dist/typescript/module/lib/version.d.ts +2 -0
  70. package/dist/typescript/module/lib/version.d.ts.map +1 -0
  71. package/dist/typescript/module/lib/web/RNFBAppCheckModule.android.d.ts +3 -0
  72. package/dist/typescript/module/lib/web/RNFBAppCheckModule.android.d.ts.map +1 -0
  73. package/dist/typescript/module/lib/web/RNFBAppCheckModule.d.ts +18 -0
  74. package/dist/typescript/module/lib/web/RNFBAppCheckModule.d.ts.map +1 -0
  75. package/dist/typescript/module/lib/web/RNFBAppCheckModule.ios.d.ts +3 -0
  76. package/dist/typescript/module/lib/web/RNFBAppCheckModule.ios.d.ts.map +1 -0
  77. package/dist/typescript/module/package.json +1 -0
  78. package/lib/ReactNativeFirebaseAppCheckProvider.ts +21 -0
  79. package/lib/index.ts +46 -0
  80. package/lib/modular.ts +157 -0
  81. package/lib/namespaced.ts +305 -0
  82. package/lib/types/appcheck.ts +386 -0
  83. package/lib/version.ts +2 -0
  84. package/lib/web/RNFBAppCheckModule.android.ts +4 -0
  85. package/lib/web/RNFBAppCheckModule.ios.ts +4 -0
  86. package/lib/web/RNFBAppCheckModule.ts +115 -0
  87. package/package.json +54 -8
  88. package/tsconfig.json +21 -0
  89. package/lib/ReactNativeFirebaseAppCheckProvider.js +0 -9
  90. package/lib/modular/index.d.ts +0 -149
  91. package/lib/modular/index.js +0 -102
  92. package/lib/version.js +0 -2
  93. package/lib/web/RNFBAppCheckModule.android.js +0 -2
  94. package/lib/web/RNFBAppCheckModule.ios.js +0 -2
@@ -0,0 +1,4 @@
1
+ // No-op for ios.
2
+ const module: Record<string, never> = {};
3
+
4
+ export default module;
@@ -0,0 +1,115 @@
1
+ import {
2
+ getApp,
3
+ initializeAppCheck,
4
+ getToken,
5
+ getLimitedUseToken,
6
+ setTokenAutoRefreshEnabled,
7
+ CustomProvider,
8
+ onTokenChanged,
9
+ makeIDBAvailable,
10
+ } from '@react-native-firebase/app/lib/internal/web/firebaseAppCheck';
11
+ import { guard, emitEvent } from '@react-native-firebase/app/lib/internal/web/utils';
12
+ import type { FirebaseAppCheckTypes } from '../types/appcheck';
13
+
14
+ let appCheckInstances: Record<string, any> = {};
15
+ let listenersForApp: Record<string, () => void> = {};
16
+
17
+ function getAppCheckInstanceForApp(appName: string): any {
18
+ if (!appCheckInstances[appName]) {
19
+ throw new Error(
20
+ `firebase AppCheck instance for app ${appName} has not been initialized, ensure you have called initializeAppCheck() first.`,
21
+ );
22
+ }
23
+ return appCheckInstances[appName];
24
+ }
25
+
26
+ interface AppCheckModule {
27
+ initializeAppCheck(
28
+ appName: string,
29
+ options: FirebaseAppCheckTypes.AppCheckOptions,
30
+ ): Promise<void>;
31
+ setTokenAutoRefreshEnabled(appName: string, isTokenAutoRefreshEnabled: boolean): Promise<void>;
32
+ getLimitedUseToken(appName: string): Promise<FirebaseAppCheckTypes.AppCheckTokenResult>;
33
+ getToken(
34
+ appName: string,
35
+ forceRefresh: boolean,
36
+ ): Promise<FirebaseAppCheckTypes.AppCheckTokenResult>;
37
+ addAppCheckListener(appName: string): Promise<void>;
38
+ removeAppCheckListener(appName: string): Promise<void>;
39
+ }
40
+
41
+ /**
42
+ * This is a 'NativeModule' for the web platform.
43
+ * Methods here are identical to the ones found in
44
+ * the native android/ios modules e.g. `@ReactMethod` annotated
45
+ * java methods on Android.
46
+ */
47
+ const module: AppCheckModule = {
48
+ initializeAppCheck(appName: string, options: FirebaseAppCheckTypes.AppCheckOptions) {
49
+ makeIDBAvailable();
50
+ return guard(async () => {
51
+ if (appCheckInstances[appName]) {
52
+ return;
53
+ }
54
+ const { provider, isTokenAutoRefreshEnabled } = options;
55
+ const _provider = new CustomProvider({
56
+ getToken() {
57
+ if ('getToken' in provider && typeof provider.getToken === 'function') {
58
+ return provider.getToken();
59
+ }
60
+ throw new Error('Provider does not have a getToken method');
61
+ },
62
+ });
63
+ appCheckInstances[appName] = initializeAppCheck(getApp(appName), {
64
+ provider: _provider,
65
+ isTokenAutoRefreshEnabled,
66
+ });
67
+ });
68
+ },
69
+ setTokenAutoRefreshEnabled(appName: string, isTokenAutoRefreshEnabled: boolean) {
70
+ return guard(async () => {
71
+ const instance = getAppCheckInstanceForApp(appName);
72
+ setTokenAutoRefreshEnabled(instance, isTokenAutoRefreshEnabled);
73
+ });
74
+ },
75
+ getLimitedUseToken(appName: string) {
76
+ return guard(async () => {
77
+ const instance = getAppCheckInstanceForApp(appName);
78
+ return getLimitedUseToken(instance);
79
+ });
80
+ },
81
+ getToken(appName: string, forceRefresh: boolean) {
82
+ return guard(async () => {
83
+ const instance = getAppCheckInstanceForApp(appName);
84
+ return getToken(instance, forceRefresh);
85
+ });
86
+ },
87
+ addAppCheckListener(appName: string) {
88
+ return guard(async () => {
89
+ if (listenersForApp[appName]) {
90
+ return;
91
+ }
92
+ const instance = getAppCheckInstanceForApp(appName);
93
+ listenersForApp[appName] = onTokenChanged(
94
+ instance,
95
+ (tokenResult: FirebaseAppCheckTypes.AppCheckTokenResult) => {
96
+ emitEvent('appCheck_token_changed', {
97
+ appName,
98
+ ...tokenResult,
99
+ });
100
+ },
101
+ );
102
+ });
103
+ },
104
+ removeAppCheckListener(appName: string) {
105
+ return guard(async () => {
106
+ if (!listenersForApp[appName]) {
107
+ return;
108
+ }
109
+ listenersForApp[appName]();
110
+ delete listenersForApp[appName];
111
+ });
112
+ },
113
+ };
114
+
115
+ export default module;
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@react-native-firebase/app-check",
3
- "version": "23.7.0",
3
+ "version": "23.8.1",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - App Check",
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
6
+ "main": "./dist/commonjs/index.js",
7
+ "module": "./dist/module/index.js",
8
+ "types": "./dist/typescript/commonjs/lib/index.d.ts",
8
9
  "scripts": {
9
- "build": "genversion --semi lib/version.js",
10
+ "build": "genversion --esm --semi lib/version.ts",
10
11
  "build:clean": "rimraf android/build && rimraf ios/build",
11
12
  "build:plugin": "rimraf plugin/build && tsc --build plugin",
12
13
  "lint:plugin": "eslint plugin/src/*",
13
- "prepare": "yarn run build && yarn run build:plugin"
14
+ "compile": "bob build",
15
+ "prepare": "yarn run build && yarn compile && yarn run build:plugin"
14
16
  },
15
17
  "repository": {
16
18
  "type": "git",
@@ -25,11 +27,13 @@
25
27
  "appCheck"
26
28
  ],
27
29
  "peerDependencies": {
28
- "@react-native-firebase/app": "23.7.0",
30
+ "@react-native-firebase/app": "23.8.1",
29
31
  "expo": ">=47.0.0"
30
32
  },
31
33
  "devDependencies": {
32
- "expo": "^54.0.27"
34
+ "expo": "^54.0.27",
35
+ "react-native-builder-bob": "^0.40.17",
36
+ "typescript": "^5.9.3"
33
37
  },
34
38
  "peerDependenciesMeta": {
35
39
  "expo": {
@@ -40,5 +44,47 @@
40
44
  "access": "public",
41
45
  "provenance": true
42
46
  },
43
- "gitHead": "2a30c0b1e41a2b239172afd167f98a03fd422f2c"
47
+ "exports": {
48
+ ".": {
49
+ "source": "./lib/index.ts",
50
+ "import": {
51
+ "types": "./dist/typescript/module/lib/index.d.ts",
52
+ "default": "./dist/module/index.js"
53
+ },
54
+ "require": {
55
+ "types": "./dist/typescript/commonjs/lib/index.d.ts",
56
+ "default": "./dist/commonjs/index.js"
57
+ }
58
+ },
59
+ "./package.json": "./package.json"
60
+ },
61
+ "react-native-builder-bob": {
62
+ "source": "lib",
63
+ "output": "dist",
64
+ "targets": [
65
+ [
66
+ "module",
67
+ {
68
+ "esm": true
69
+ }
70
+ ],
71
+ [
72
+ "commonjs",
73
+ {
74
+ "esm": true
75
+ }
76
+ ],
77
+ [
78
+ "typescript",
79
+ {
80
+ "tsc": "../../node_modules/.bin/tsc"
81
+ }
82
+ ]
83
+ ]
84
+ },
85
+ "eslintIgnore": [
86
+ "node_modules/",
87
+ "dist/"
88
+ ],
89
+ "gitHead": "46b06d2b1100ec03c7807b4ff34b583b773a19d7"
44
90
  }
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "../../tsconfig.packages.base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "rootDir": ".",
6
+ "paths": {
7
+ "@react-native-firebase/app/lib/common/*": ["../app/dist/typescript/commonjs/lib/common/*"],
8
+ "@react-native-firebase/app/lib/common": ["../app/dist/typescript/commonjs/lib/common"],
9
+ "@react-native-firebase/app/lib/internal/web/*": [
10
+ "../app/dist/typescript/commonjs/lib/internal/web/*"
11
+ ],
12
+ "@react-native-firebase/app/lib/internal/*": [
13
+ "../app/dist/typescript/commonjs/lib/internal/*"
14
+ ],
15
+ "@react-native-firebase/app/lib/internal": ["../app/dist/typescript/commonjs/lib/internal"],
16
+ "@react-native-firebase/app": ["../app/dist/typescript/commonjs/lib"]
17
+ }
18
+ },
19
+ "include": ["lib/**/*", "../app/lib/internal/global.d.ts"],
20
+ "exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts"]
21
+ }
@@ -1,9 +0,0 @@
1
- export default class ReactNativeFirebaseAppCheckProvider {
2
- providerOptions;
3
-
4
- constructor() {}
5
-
6
- configure(options) {
7
- this.providerOptions = options;
8
- }
9
- }
@@ -1,149 +0,0 @@
1
- import { ReactNativeFirebase } from '@react-native-firebase/app';
2
- import { FirebaseAppCheckTypes } from '..';
3
-
4
- import FirebaseApp = ReactNativeFirebase.FirebaseApp;
5
- import AppCheck = FirebaseAppCheckTypes.Module;
6
- import AppCheckOptions = FirebaseAppCheckTypes.AppCheckOptions;
7
- import AppCheckTokenResult = FirebaseAppCheckTypes.AppCheckTokenResult;
8
- import PartialObserver = FirebaseAppCheckTypes.PartialObserver;
9
- import Unsubscribe = FirebaseAppCheckTypes.Unsubscribe;
10
- import AppCheckProvider = FirebaseAppCheckTypes.AppCheckProvider;
11
- import CustomProviderOptions = FirebaseAppCheckTypes.CustomProviderOptions;
12
-
13
- /**
14
- * Activate App Check for the given app. Can be called only once per app.
15
- * @param app - FirebaseApp. Optional.
16
- * @param options - AppCheckOptions
17
- * @returns {Promise<AppCheck>}
18
- */
19
- export function initializeAppCheck(app?: FirebaseApp, options?: AppCheckOptions): Promise<AppCheck>;
20
-
21
- /**
22
- * Get the current App Check token. Attaches to the most recent in-flight request if one is present.
23
- * Returns null if no token is present and no token requests are in-flight.
24
- * @param appCheckInstance - AppCheck
25
- * @param forceRefresh - If true, will always try to fetch a fresh token. If false, will use a cached token if found in storage.
26
- * @returns {Promise<AppCheckTokenResult>}
27
- */
28
- export function getToken(
29
- appCheckInstance: AppCheck,
30
- forceRefresh?: boolean,
31
- ): Promise<AppCheckTokenResult>;
32
-
33
- /**
34
- * Get a limited-use (consumable) App Check token.
35
- * For use with server calls to firebase functions or custom backends using the firebase admin SDK
36
- * @param appCheckInstance - AppCheck
37
- * @returns {Promise<AppCheckTokenResult>}
38
- */
39
- export function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
40
-
41
- /**
42
- * Registers a listener to changes in the token state. There can be more
43
- * than one listener registered at the same time for one or more
44
- * App Check instances. The listeners call back on the UI thread whenever
45
- * the current token associated with this App Check instance changes.
46
- *
47
- * @returns A function that unsubscribes this listener.
48
- */
49
- export function onTokenChanged(
50
- appCheckInstance: AppCheck,
51
- listener: PartialObserver<AppCheckTokenResult>,
52
- ): Unsubscribe;
53
-
54
- /**
55
- * Registers a listener to changes in the token state. There can be more
56
- * than one listener registered at the same time for one or more
57
- * App Check instances. The listeners call back on the UI thread whenever
58
- * the current token associated with this App Check instance changes.
59
- *
60
- * Token listeners do not exist in the native SDK for iOS, no token change events will be emitted on that platform.
61
- * This is not yet implemented on Android, no token change events will be emitted until implemented.
62
- *
63
- * NOTE: Although an `onError` callback can be provided, it will
64
- * never be called, Android sdk code doesn't provide handling for onError function
65
- *
66
- * NOTE: Although an `onCompletion` callback can be provided, it will
67
- * never be called because the token stream is never-ending.
68
- *
69
- * @returns A function that unsubscribes this listener.
70
- */
71
- export function onTokenChanged(
72
- appCheckInstance: AppCheck,
73
- onNext: (tokenResult: AppCheckListenerResult) => void,
74
- onError?: (error: Error) => void,
75
- onCompletion?: () => void,
76
- ): () => void;
77
-
78
- /**
79
- * Set whether App Check will automatically refresh tokens as needed.
80
- * @param appCheckInstance - AppCheck
81
- * @param isAutoRefreshEnabled - boolean
82
- */
83
- export function setTokenAutoRefreshEnabled(
84
- appCheckInstance: AppCheck,
85
- isAutoRefreshEnabled: boolean,
86
- ): void;
87
-
88
- /**
89
- * Custom provider class.
90
- * @public
91
- */
92
- export class CustomProvider implements AppCheckProvider {
93
- constructor(customProviderOptions: CustomProviderOptions);
94
- }
95
-
96
- /**
97
- * React-Native-Firebase AppCheckProvider that allows hot-swapping native AppCheck implementations
98
- */
99
- export interface ReactNativeFirebaseAppCheckProviderOptions {
100
- /**
101
- * debug token to use, if any. Defaults to undefined, pre-configure tokens in firebase web console if needed
102
- */
103
- debugToken?: string;
104
- }
105
-
106
- export interface ReactNativeFirebaseAppCheckProviderWebOptions extends ReactNativeFirebaseAppCheckProviderOptions {
107
- /**
108
- * The web provider to use, either `reCaptchaV3` or `reCaptchaEnterprise`, defaults to `reCaptchaV3`
109
- */
110
- provider?: 'debug' | 'reCaptchaV3' | 'reCaptchaEnterprise';
111
-
112
- /**
113
- * siteKey for use in web queries, defaults to `none`
114
- */
115
- siteKey?: string;
116
- }
117
-
118
- export interface ReactNativeFirebaseAppCheckProviderAppleOptions extends ReactNativeFirebaseAppCheckProviderOptions {
119
- /**
120
- * The apple provider to use, either `deviceCheck` or `appAttest`, or `appAttestWithDeviceCheckFallback`,
121
- * defaults to `DeviceCheck`. `appAttest` requires iOS 14+ or will fail, `appAttestWithDeviceCheckFallback`
122
- * will use `appAttest` for iOS14+ and fallback to `deviceCheck` on devices with ios13 and lower
123
- */
124
- provider?: 'debug' | 'deviceCheck' | 'appAttest' | 'appAttestWithDeviceCheckFallback';
125
- }
126
-
127
- export interface ReactNativeFirebaseAppCheckProviderAndroidOptions extends ReactNativeFirebaseAppCheckProviderOptions {
128
- /**
129
- * The android provider to use, either `debug` or `playIntegrity`. default is `playIntegrity`.
130
- */
131
- provider?: 'debug' | 'playIntegrity';
132
- }
133
-
134
- export class ReactNativeFirebaseAppCheckProvider extends AppCheckProvider {
135
- /**
136
- * Specify how the app check provider should be configured. The new configuration is
137
- * in effect when this call returns. You must call `getToken()`
138
- * after this call to get a token using the new configuration.
139
- * This custom provider allows for delayed configuration and re-configuration on all platforms
140
- * so AppCheck has the same experience across all platforms, with the only difference being the native
141
- * providers you choose to use on each platform.
142
- */
143
- configure(options: {
144
- web?: ReactNativeFirebaseAppCheckProviderWebOptions;
145
- android?: ReactNativeFirebaseAppCheckProviderAndroidOptions;
146
- apple?: ReactNativeFirebaseAppCheckProviderAppleOptions;
147
- isTokenAutoRefreshEnabled?: boolean;
148
- }): void;
149
- }
@@ -1,102 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- import { getApp } from '@react-native-firebase/app';
19
- import { MODULAR_DEPRECATION_ARG } from '../../../app/lib/common';
20
- import ReactNativeFirebaseAppCheckProvider from '../ReactNativeFirebaseAppCheckProvider';
21
-
22
- /**
23
- * @typedef {import('@firebase/app').FirebaseApp} FirebaseApp
24
- * @typedef {import('..').FirebaseAppCheckTypes.Module} AppCheck
25
- * @typedef {import('..').FirebaseAppCheckTypes.AppCheckTokenResult} AppCheckTokenResult
26
- * @typedef {import('..').FirebaseAppCheckTypes.Unsubscribe} Unsubscribe
27
- * @typedef {import('..').FirebaseAppCheckTypes.PartialObserver} PartialObserver
28
- * @typedef {import('..').FirebaseAppCheckTypes.AppCheckOptions} AppCheckOptions
29
- */
30
-
31
- /**
32
- * Activate App Check for the given app. Can be called only once per app.
33
- * @param {FirebaseApp} [app] - The app to initialize App Check for. Optional.
34
- * @param {AppCheckOptions} options - App Check options.
35
- * @returns {Promise<AppCheck>}
36
- */
37
- export async function initializeAppCheck(app, options) {
38
- if (app) {
39
- const appCheck = getApp(app.name).appCheck();
40
- await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG);
41
- return appCheck;
42
- }
43
- const appCheck = getApp().appCheck();
44
- await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG);
45
- return appCheck;
46
- }
47
-
48
- /**
49
- * Get the current App Check token. Attaches to the most recent in-flight request if one is present.
50
- * Returns null if no token is present and no token requests are in-flight.
51
- * @param {AppCheck} appCheckInstance - The App Check instance.
52
- * @param {boolean} forceRefresh - Whether to force refresh the token. Optional
53
- * @returns {Promise<AppCheckTokenResult>}
54
- */
55
- export function getToken(appCheckInstance, forceRefresh) {
56
- return appCheckInstance.getToken.call(appCheckInstance, forceRefresh, MODULAR_DEPRECATION_ARG);
57
- }
58
-
59
- /**
60
- * Get a limited-use (consumable) App Check token.
61
- * For use with server calls to firebase functions or custom backends using the firebase admin SDK.
62
- * @param {AppCheck} appCheckInstance - The App Check instance.
63
- * @returns {Promise<AppCheckTokenResult>}
64
- */
65
- export function getLimitedUseToken(appCheckInstance) {
66
- return appCheckInstance.getLimitedUseToken.call(appCheckInstance, MODULAR_DEPRECATION_ARG);
67
- }
68
-
69
- /**
70
- * Set whether App Check will automatically refresh tokens as needed.
71
- * @param {AppCheck} appCheckInstance - The App Check instance.
72
- * @param {boolean} isAutoRefreshEnabled - Whether to enable auto-refresh.
73
- */
74
- export function setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnabled) {
75
- return appCheckInstance.setTokenAutoRefreshEnabled.call(
76
- appCheckInstance,
77
- isAutoRefreshEnabled,
78
- MODULAR_DEPRECATION_ARG,
79
- );
80
- }
81
-
82
- /**
83
- * Registers a listener to changes in the token state. There can be more
84
- * than one listener registered at the same time for one or more
85
- * App Check instances. The listeners call back on the UI thread whenever
86
- * the current token associated with this App Check instance changes.
87
- *
88
- * @param {AppCheck} appCheckInstance - The App Check instance.
89
- * @param {PartialObserver<AppCheckTokenResult>} listener - The listener to register.
90
- * @returns {Unsubscribe}
91
- */
92
- export function onTokenChanged(appCheckInstance, onNextOrObserver, onError, onCompletion) {
93
- return appCheckInstance.onTokenChanged.call(
94
- appCheckInstance,
95
- onNextOrObserver,
96
- onError,
97
- onCompletion,
98
- MODULAR_DEPRECATION_ARG,
99
- );
100
- }
101
-
102
- export { ReactNativeFirebaseAppCheckProvider };
package/lib/version.js DELETED
@@ -1,2 +0,0 @@
1
- // Generated by genversion.
2
- module.exports = '23.7.0';
@@ -1,2 +0,0 @@
1
- // No-op for android.
2
- export default {};
@@ -1,2 +0,0 @@
1
- // No-op for ios.
2
- export default {};