@react-native-firebase/app-check 20.3.0 → 20.4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [20.4.0](https://github.com/invertase/react-native-firebase/compare/v20.3.0...v20.4.0) (2024-08-13)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/app-check
9
+
6
10
  ## [20.3.0](https://github.com/invertase/react-native-firebase/compare/v20.2.1...v20.3.0) (2024-07-19)
7
11
 
8
12
  **Note:** Version bump only for package @react-native-firebase/app-check
@@ -1,6 +1,13 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import { firebase } from '../lib';
3
+ import {
4
+ firebase,
5
+ initializeAppCheck,
6
+ getToken,
7
+ getLimitedUseToken,
8
+ addTokenListener,
9
+ setTokenAutoRefreshEnabled,
10
+ } from '../lib';
4
11
 
5
12
  describe('appCheck()', function () {
6
13
  describe('namespace', function () {
@@ -26,4 +33,26 @@ describe('appCheck()', function () {
26
33
  expect(firebase.appCheck().newReactNativeFirebaseAppCheckProvider()).toBeDefined();
27
34
  });
28
35
  });
36
+
37
+ describe('modular', function () {
38
+ it('`initializeAppCheck` function is properly exposed to end user', function () {
39
+ expect(initializeAppCheck).toBeDefined();
40
+ });
41
+
42
+ it('`getToken` function is properly exposed to end user', function () {
43
+ expect(getToken).toBeDefined();
44
+ });
45
+
46
+ it('`getLimitedUseToken` function is properly exposed to end user', function () {
47
+ expect(getLimitedUseToken).toBeDefined();
48
+ });
49
+
50
+ it('`addTokenListener` function is properly exposed to end user', function () {
51
+ expect(addTokenListener).toBeDefined();
52
+ });
53
+
54
+ it('`setTokenAutoRefreshEnabled` function is properly exposed to end user', function () {
55
+ expect(setTokenAutoRefreshEnabled).toBeDefined();
56
+ });
57
+ });
29
58
  });
package/lib/index.d.ts CHANGED
@@ -341,6 +341,8 @@ export const firebase: ReactNativeFirebase.Module & {
341
341
 
342
342
  export default defaultExport;
343
343
 
344
+ export * from './modular';
345
+
344
346
  /**
345
347
  * Attach namespace to `firebase.` and `FirebaseApp.`.
346
348
  */
package/lib/index.js CHANGED
@@ -36,14 +36,6 @@ import fallBackModule from './web/RNFBAppCheckModule';
36
36
 
37
37
  import version from './version';
38
38
 
39
- export {
40
- addTokenListener,
41
- getToken,
42
- getLimitedUseToken,
43
- initializeAppCheck,
44
- setTokenAutoRefreshEnabled,
45
- } from './modular/index';
46
-
47
39
  const namespace = 'appCheck';
48
40
 
49
41
  const nativeModuleName = 'RNFBAppCheckModule';
@@ -240,6 +232,8 @@ export default createModuleNamespace({
240
232
  ModuleClass: FirebaseAppCheckModule,
241
233
  });
242
234
 
235
+ export * from './modular';
236
+
243
237
  // import appCheck, { firebase } from '@react-native-firebase/app-check';
244
238
  // appCheck().X(...);
245
239
  // firebase.appCheck().X(...);
@@ -0,0 +1,63 @@
1
+ import { FirebaseApp } from '@firebase/app-types';
2
+ import { FirebaseAppCheckTypes } from '..';
3
+
4
+ import AppCheck = FirebaseAppCheckTypes.Module;
5
+ import AppCheckOptions = FirebaseAppCheckTypes.AppCheckOptions;
6
+ import AppCheckTokenResult = FirebaseAppCheckTypes.AppCheckTokenResult;
7
+ import PartialObserver = FirebaseAppCheckTypes.PartialObserver;
8
+ import Unsubscribe = FirebaseAppCheckTypes.Unsubscribe;
9
+
10
+ /**
11
+ * Activate App Check for the given app. Can be called only once per app.
12
+ * @param app - FirebaseApp. Optional.
13
+ * @param options - AppCheckOptions
14
+ * @returns {Promise<{ app: FirebaseApp }>}
15
+ */
16
+ export function initializeAppCheck(
17
+ app?: FirebaseApp,
18
+ options?: AppCheckOptions,
19
+ ): Promise<{ app: FirebaseApp }>;
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 - boolean
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.
43
+ * There can be more than one listener registered at the same time for one or more App Check instances.
44
+ * The listeners call back on the UI thread whenever the current
45
+ * token associated with this App Check instance changes.
46
+ * @param appCheckInstance - AppCheck
47
+ * @param listener - PartialObserver<AppCheckTokenResult>
48
+ * @returns {Unsubscribe}
49
+ */
50
+ export function addTokenListener(
51
+ appCheckInstance: AppCheck,
52
+ listener: PartialObserver<AppCheckTokenResult>,
53
+ ): Unsubscribe;
54
+
55
+ /**
56
+ * Set whether App Check will automatically refresh tokens as needed.
57
+ * @param appCheckInstance - AppCheck
58
+ * @param isAutoRefreshEnabled - boolean
59
+ */
60
+ export function setTokenAutoRefreshEnabled(
61
+ appCheckInstance: AppCheck,
62
+ isAutoRefreshEnabled: boolean,
63
+ ): void;
@@ -18,11 +18,20 @@
18
18
 
19
19
  import { firebase } from '..';
20
20
 
21
+ /**
22
+ * @typedef {import('@firebase/app').FirebaseApp} FirebaseApp
23
+ * @typedef {import('..').FirebaseAppCheckTypes.Module} AppCheck
24
+ * @typedef {import('..').FirebaseAppCheckTypes.AppCheckTokenResult} AppCheckTokenResult
25
+ * @typedef {import('..').FirebaseAppCheckTypes.Unsubscribe} Unsubscribe
26
+ * @typedef {import('..').FirebaseAppCheckTypes.PartialObserver} PartialObserver
27
+ * @typedef {import('..').FirebaseAppCheckTypes.AppCheckOptions} AppCheckOptions
28
+ */
29
+
21
30
  /**
22
31
  * Activate App Check for the given app. Can be called only once per app.
23
- * @param app - FirebaseApp. Optional.
24
- * @param options - AppCheckOptions
25
- * @returns {AppCheck}
32
+ * @param {FirebaseApp} [app] - The app to initialize App Check for. Optional.
33
+ * @param {AppCheckOptions} options - App Check options.
34
+ * @returns {Promise<{ app: FirebaseApp }>}
26
35
  */
27
36
  export async function initializeAppCheck(app, options) {
28
37
  if (app) {
@@ -37,8 +46,8 @@ export async function initializeAppCheck(app, options) {
37
46
  /**
38
47
  * Get the current App Check token. Attaches to the most recent in-flight request if one is present.
39
48
  * Returns null if no token is present and no token requests are in-flight.
40
- * @param appCheckInstance - AppCheck
41
- * @param forceRefresh - boolean
49
+ * @param {AppCheck} appCheckInstance - The App Check instance.
50
+ * @param {boolean} forceRefresh - Whether to force refresh the token.
42
51
  * @returns {Promise<AppCheckTokenResult>}
43
52
  */
44
53
  export function getToken(appCheckInstance, forceRefresh) {
@@ -47,8 +56,8 @@ export function getToken(appCheckInstance, forceRefresh) {
47
56
 
48
57
  /**
49
58
  * Get a limited-use (consumable) App Check token.
50
- * For use with server calls to firebase functions or custom backends using the firebase admin SDK
51
- * @param appCheckInstance - AppCheck
59
+ * For use with server calls to firebase functions or custom backends using the firebase admin SDK.
60
+ * @param {AppCheck} appCheckInstance - The App Check instance.
52
61
  * @returns {Promise<AppCheckTokenResult>}
53
62
  */
54
63
  export function getLimitedUseToken(appCheckInstance) {
@@ -60,8 +69,8 @@ export function getLimitedUseToken(appCheckInstance) {
60
69
  * There can be more than one listener registered at the same time for one or more App Check instances.
61
70
  * The listeners call back on the UI thread whenever the current
62
71
  * token associated with this App Check instance changes.
63
- * @param appCheckInstance - AppCheck
64
- * @param listener - PartialObserver<AppCheckTokenResult>
72
+ * @param {AppCheck} appCheckInstance - The App Check instance.
73
+ * @param {PartialObserver<AppCheckTokenResult>} listener - The listener to register.
65
74
  * @returns {Unsubscribe}
66
75
  */
67
76
  export function addTokenListener(appCheckInstance, listener) {
@@ -72,8 +81,8 @@ export function addTokenListener(appCheckInstance, listener) {
72
81
 
73
82
  /**
74
83
  * Set whether App Check will automatically refresh tokens as needed.
75
- * @param appCheckInstance - AppCheck
76
- * @param isAutoRefreshEnabled - boolean
84
+ * @param {AppCheck} appCheckInstance - The App Check instance.
85
+ * @param {boolean} isAutoRefreshEnabled - Whether to enable auto-refresh.
77
86
  */
78
87
  export function setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnabled) {
79
88
  return appCheckInstance.app.appCheck().setTokenAutoRefreshEnabled(isAutoRefreshEnabled);
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '20.3.0';
2
+ module.exports = '20.4.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/app-check",
3
- "version": "20.3.0",
3
+ "version": "20.4.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - App Check",
6
6
  "main": "lib/index.js",
@@ -25,7 +25,7 @@
25
25
  "appCheck"
26
26
  ],
27
27
  "peerDependencies": {
28
- "@react-native-firebase/app": "20.3.0",
28
+ "@react-native-firebase/app": "20.4.0",
29
29
  "expo": ">=47.0.0"
30
30
  },
31
31
  "devDependencies": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "a916b37b022cf40588fa0fd915b7ab901e2458d0"
42
+ "gitHead": "3ac3e9623674a8db52c111b4aa0a85a883260116"
43
43
  }