@react-native-firebase/app-check 21.7.0 → 21.7.2
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 +8 -0
- package/README.md +1 -1
- package/__tests__/appcheck.test.ts +119 -6
- package/lib/index.d.ts +0 -1
- package/lib/modular/index.d.ts +43 -9
- package/lib/modular/index.js +37 -20
- package/lib/version.js +1 -1
- package/package.json +4 -4
- package/plugin/build/ios/appDelegate.js +1 -1
- package/plugin/src/ios/appDelegate.ts +1 -1
- package/plugin/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [21.7.2](https://github.com/invertase/react-native-firebase/compare/v21.7.1...v21.7.2) (2025-02-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @react-native-firebase/app-check
|
|
9
|
+
|
|
10
|
+
## [21.7.1](https://github.com/invertase/react-native-firebase/compare/v21.7.0...v21.7.1) (2025-01-20)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @react-native-firebase/app-check
|
|
13
|
+
|
|
6
14
|
## [21.7.0](https://github.com/invertase/react-native-firebase/compare/v21.6.2...v21.7.0) (2025-01-16)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @react-native-firebase/app-check
|
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ yarn add @react-native-firebase/app-check
|
|
|
50
50
|
---
|
|
51
51
|
|
|
52
52
|
<p>
|
|
53
|
-
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase-
|
|
53
|
+
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase/invertase-rounded.png">
|
|
54
54
|
<p align="left">
|
|
55
55
|
Built and maintained with 💛 by <a href="https://invertase.io">Invertase</a>.
|
|
56
56
|
</p>
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
1
|
+
import { jest, beforeEach, describe, expect, it } from '@jest/globals';
|
|
2
|
+
// @ts-ignore test
|
|
3
|
+
import FirebaseModule from '../../app/lib/internal/FirebaseModule';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
createCheckV9Deprecation,
|
|
7
|
+
CheckV9DeprecationFunction,
|
|
8
|
+
} from '../../app/lib/common/unitTestUtils';
|
|
2
9
|
|
|
3
10
|
import {
|
|
4
11
|
firebase,
|
|
5
12
|
initializeAppCheck,
|
|
6
13
|
getToken,
|
|
7
14
|
getLimitedUseToken,
|
|
8
|
-
addTokenListener,
|
|
9
15
|
setTokenAutoRefreshEnabled,
|
|
16
|
+
onTokenChanged,
|
|
17
|
+
CustomProvider,
|
|
10
18
|
} from '../lib';
|
|
11
19
|
|
|
12
20
|
describe('appCheck()', function () {
|
|
@@ -47,12 +55,117 @@ describe('appCheck()', function () {
|
|
|
47
55
|
expect(getLimitedUseToken).toBeDefined();
|
|
48
56
|
});
|
|
49
57
|
|
|
50
|
-
it('`addTokenListener` function is properly exposed to end user', function () {
|
|
51
|
-
expect(addTokenListener).toBeDefined();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
58
|
it('`setTokenAutoRefreshEnabled` function is properly exposed to end user', function () {
|
|
55
59
|
expect(setTokenAutoRefreshEnabled).toBeDefined();
|
|
56
60
|
});
|
|
61
|
+
|
|
62
|
+
it('`CustomProvider` function is properly exposed to end user', function () {
|
|
63
|
+
expect(CustomProvider).toBeDefined();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
|
|
68
|
+
let appCheckRefV9Deprecation: CheckV9DeprecationFunction;
|
|
69
|
+
let staticsRefV9Deprecation: CheckV9DeprecationFunction;
|
|
70
|
+
|
|
71
|
+
beforeEach(function () {
|
|
72
|
+
appCheckRefV9Deprecation = createCheckV9Deprecation(['appCheck']);
|
|
73
|
+
staticsRefV9Deprecation = createCheckV9Deprecation(['appCheck', 'statics']);
|
|
74
|
+
|
|
75
|
+
// @ts-ignore test
|
|
76
|
+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
|
|
77
|
+
return new Proxy(
|
|
78
|
+
{},
|
|
79
|
+
{
|
|
80
|
+
get: () =>
|
|
81
|
+
jest.fn().mockResolvedValue({
|
|
82
|
+
source: 'cache',
|
|
83
|
+
changes: [],
|
|
84
|
+
documents: [],
|
|
85
|
+
metadata: {},
|
|
86
|
+
path: 'foo',
|
|
87
|
+
} as never),
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('AppCheck', function () {
|
|
94
|
+
it('appCheck.activate()', function () {
|
|
95
|
+
const app = firebase.app();
|
|
96
|
+
const appCheck = firebase.appCheck();
|
|
97
|
+
appCheckRefV9Deprecation(
|
|
98
|
+
() =>
|
|
99
|
+
initializeAppCheck(app, {
|
|
100
|
+
provider: {
|
|
101
|
+
providerOptions: {
|
|
102
|
+
android: {
|
|
103
|
+
provider: 'playIntegrity',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
isTokenAutoRefreshEnabled: true,
|
|
108
|
+
}),
|
|
109
|
+
() => appCheck.activate('string'),
|
|
110
|
+
'activate',
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('appCheck.setTokenAutoRefreshEnabled()', function () {
|
|
115
|
+
const appCheck = firebase.appCheck();
|
|
116
|
+
appCheckRefV9Deprecation(
|
|
117
|
+
() => setTokenAutoRefreshEnabled(appCheck, true),
|
|
118
|
+
() => appCheck.setTokenAutoRefreshEnabled(true),
|
|
119
|
+
'setTokenAutoRefreshEnabled',
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('appCheck.getToken()', function () {
|
|
124
|
+
const appCheck = firebase.appCheck();
|
|
125
|
+
appCheckRefV9Deprecation(
|
|
126
|
+
() => getToken(appCheck, true),
|
|
127
|
+
() => appCheck.getToken(true),
|
|
128
|
+
'getToken',
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('appCheck.getLimitedUseToken()', function () {
|
|
133
|
+
const appCheck = firebase.appCheck();
|
|
134
|
+
appCheckRefV9Deprecation(
|
|
135
|
+
() => getLimitedUseToken(appCheck),
|
|
136
|
+
() => appCheck.getLimitedUseToken(),
|
|
137
|
+
'getLimitedUseToken',
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('appCheck.onTokenChanged()', function () {
|
|
142
|
+
const appCheck = firebase.appCheck();
|
|
143
|
+
appCheckRefV9Deprecation(
|
|
144
|
+
() =>
|
|
145
|
+
onTokenChanged(
|
|
146
|
+
appCheck,
|
|
147
|
+
() => {},
|
|
148
|
+
() => {},
|
|
149
|
+
() => {},
|
|
150
|
+
),
|
|
151
|
+
() =>
|
|
152
|
+
appCheck.onTokenChanged(
|
|
153
|
+
() => {},
|
|
154
|
+
() => {},
|
|
155
|
+
() => {},
|
|
156
|
+
),
|
|
157
|
+
'onTokenChanged',
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('CustomProvider', function () {
|
|
162
|
+
const appCheck = firebase.appCheck;
|
|
163
|
+
staticsRefV9Deprecation(
|
|
164
|
+
() => CustomProvider,
|
|
165
|
+
() => appCheck.CustomProvider,
|
|
166
|
+
'CustomProvider',
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
57
170
|
});
|
|
58
171
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -196,7 +196,6 @@ export namespace FirebaseAppCheckTypes {
|
|
|
196
196
|
*/
|
|
197
197
|
export type AppCheckListenerResult = AppCheckToken & { readonly appName: string };
|
|
198
198
|
|
|
199
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
200
199
|
export interface Statics {
|
|
201
200
|
// firebase.appCheck.* static props go here
|
|
202
201
|
CustomProvider: typeof CustomProvider;
|
package/lib/modular/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
2
2
|
import { FirebaseAppCheckTypes } from '..';
|
|
3
3
|
|
|
4
|
+
import FirebaseApp = ReactNativeFirebase.FirebaseApp;
|
|
4
5
|
import AppCheck = FirebaseAppCheckTypes.Module;
|
|
5
6
|
import AppCheckOptions = FirebaseAppCheckTypes.AppCheckOptions;
|
|
6
7
|
import AppCheckTokenResult = FirebaseAppCheckTypes.AppCheckTokenResult;
|
|
7
8
|
import PartialObserver = FirebaseAppCheckTypes.PartialObserver;
|
|
8
9
|
import Unsubscribe = FirebaseAppCheckTypes.Unsubscribe;
|
|
10
|
+
import AppCheckProvider = FirebaseAppCheckTypes.AppCheckProvider;
|
|
11
|
+
import CustomProviderOptions = FirebaseAppCheckTypes.CustomProviderOptions;
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Activate App Check for the given app. Can be called only once per app.
|
|
@@ -39,19 +42,42 @@ export function getToken(
|
|
|
39
42
|
export function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult>;
|
|
40
43
|
|
|
41
44
|
/**
|
|
42
|
-
* Registers a listener to changes in the token state.
|
|
43
|
-
*
|
|
44
|
-
* The listeners call back on the UI thread whenever
|
|
45
|
-
* token associated with this App Check instance changes.
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
* @returns {Unsubscribe}
|
|
45
|
+
* Registers a listener to changes in the token state. There can be more
|
|
46
|
+
* than one listener registered at the same time for one or more
|
|
47
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
48
|
+
* the current token associated with this App Check instance changes.
|
|
49
|
+
*
|
|
50
|
+
* @returns A function that unsubscribes this listener.
|
|
49
51
|
*/
|
|
50
|
-
export function
|
|
52
|
+
export function onTokenChanged(
|
|
51
53
|
appCheckInstance: AppCheck,
|
|
52
54
|
listener: PartialObserver<AppCheckTokenResult>,
|
|
53
55
|
): Unsubscribe;
|
|
54
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Registers a listener to changes in the token state. There can be more
|
|
59
|
+
* than one listener registered at the same time for one or more
|
|
60
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
61
|
+
* the current token associated with this App Check instance changes.
|
|
62
|
+
*
|
|
63
|
+
* Token listeners do not exist in the native SDK for iOS, no token change events will be emitted on that platform.
|
|
64
|
+
* This is not yet implemented on Android, no token change events will be emitted until implemented.
|
|
65
|
+
*
|
|
66
|
+
* NOTE: Although an `onError` callback can be provided, it will
|
|
67
|
+
* never be called, Android sdk code doesn't provide handling for onError function
|
|
68
|
+
*
|
|
69
|
+
* NOTE: Although an `onCompletion` callback can be provided, it will
|
|
70
|
+
* never be called because the token stream is never-ending.
|
|
71
|
+
*
|
|
72
|
+
* @returns A function that unsubscribes this listener.
|
|
73
|
+
*/
|
|
74
|
+
export function onTokenChanged(
|
|
75
|
+
appCheckInstance: AppCheck,
|
|
76
|
+
onNext: (tokenResult: AppCheckListenerResult) => void,
|
|
77
|
+
onError?: (error: Error) => void,
|
|
78
|
+
onCompletion?: () => void,
|
|
79
|
+
): () => void;
|
|
80
|
+
|
|
55
81
|
/**
|
|
56
82
|
* Set whether App Check will automatically refresh tokens as needed.
|
|
57
83
|
* @param appCheckInstance - AppCheck
|
|
@@ -61,3 +87,11 @@ export function setTokenAutoRefreshEnabled(
|
|
|
61
87
|
appCheckInstance: AppCheck,
|
|
62
88
|
isAutoRefreshEnabled: boolean,
|
|
63
89
|
): void;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Custom provider class.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export class CustomProvider implements AppCheckProvider {
|
|
96
|
+
constructor(customProviderOptions: CustomProviderOptions);
|
|
97
|
+
}
|
package/lib/modular/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
4
3
|
*
|
|
@@ -17,6 +16,8 @@
|
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
import { firebase } from '..';
|
|
19
|
+
import { MODULAR_DEPRECATION_ARG } from '../../../app/lib/common';
|
|
20
|
+
import CustomProvider from '../ReactNativeFirebaseAppCheckProvider';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @typedef {import('@firebase/app').FirebaseApp} FirebaseApp
|
|
@@ -35,11 +36,12 @@ import { firebase } from '..';
|
|
|
35
36
|
*/
|
|
36
37
|
export async function initializeAppCheck(app, options) {
|
|
37
38
|
if (app) {
|
|
38
|
-
|
|
39
|
+
const appCheck = firebase.app(app.name).appCheck();
|
|
40
|
+
await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG);
|
|
39
41
|
return { app: firebase.app(app.name) };
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
await
|
|
43
|
+
const appCheck = firebase.app().appCheck();
|
|
44
|
+
await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG);
|
|
43
45
|
return { app: firebase.app() };
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -51,7 +53,8 @@ export async function initializeAppCheck(app, options) {
|
|
|
51
53
|
* @returns {Promise<AppCheckTokenResult>}
|
|
52
54
|
*/
|
|
53
55
|
export function getToken(appCheckInstance, forceRefresh) {
|
|
54
|
-
|
|
56
|
+
const appCheck = appCheckInstance.app.appCheck();
|
|
57
|
+
return appCheck.getToken.call(appCheck, forceRefresh, MODULAR_DEPRECATION_ARG);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/**
|
|
@@ -61,29 +64,43 @@ export function getToken(appCheckInstance, forceRefresh) {
|
|
|
61
64
|
* @returns {Promise<AppCheckTokenResult>}
|
|
62
65
|
*/
|
|
63
66
|
export function getLimitedUseToken(appCheckInstance) {
|
|
64
|
-
|
|
67
|
+
const appCheck = appCheckInstance.app.appCheck();
|
|
68
|
+
return appCheck.getLimitedUseToken.call(appCheck, MODULAR_DEPRECATION_ARG);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
|
-
*
|
|
69
|
-
* There can be more than one listener registered at the same time for one or more App Check instances.
|
|
70
|
-
* The listeners call back on the UI thread whenever the current
|
|
71
|
-
* token associated with this App Check instance changes.
|
|
72
|
+
* Set whether App Check will automatically refresh tokens as needed.
|
|
72
73
|
* @param {AppCheck} appCheckInstance - The App Check instance.
|
|
73
|
-
* @param {
|
|
74
|
-
* @returns {Unsubscribe}
|
|
74
|
+
* @param {boolean} isAutoRefreshEnabled - Whether to enable auto-refresh.
|
|
75
75
|
*/
|
|
76
|
-
export function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
export function setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnabled) {
|
|
77
|
+
const appCheck = appCheckInstance.app.appCheck();
|
|
78
|
+
return appCheck.setTokenAutoRefreshEnabled.call(
|
|
79
|
+
appCheck,
|
|
80
|
+
isAutoRefreshEnabled,
|
|
81
|
+
MODULAR_DEPRECATION_ARG,
|
|
82
|
+
);
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
/**
|
|
83
|
-
*
|
|
86
|
+
* Registers a listener to changes in the token state. There can be more
|
|
87
|
+
* than one listener registered at the same time for one or more
|
|
88
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
89
|
+
* the current token associated with this App Check instance changes.
|
|
90
|
+
*
|
|
84
91
|
* @param {AppCheck} appCheckInstance - The App Check instance.
|
|
85
|
-
* @param {
|
|
92
|
+
* @param {PartialObserver<AppCheckTokenResult>} listener - The listener to register.
|
|
93
|
+
* @returns {Unsubscribe}
|
|
86
94
|
*/
|
|
87
|
-
export function
|
|
88
|
-
|
|
95
|
+
export function onTokenChanged(appCheckInstance, onNextOrObserver, onError, onCompletion) {
|
|
96
|
+
const appCheck = appCheckInstance.app.appCheck();
|
|
97
|
+
return appCheck.onTokenChanged.call(
|
|
98
|
+
appCheck,
|
|
99
|
+
onNextOrObserver,
|
|
100
|
+
onError,
|
|
101
|
+
onCompletion,
|
|
102
|
+
MODULAR_DEPRECATION_ARG,
|
|
103
|
+
);
|
|
89
104
|
}
|
|
105
|
+
|
|
106
|
+
export { CustomProvider };
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
module.exports = '21.7.
|
|
2
|
+
module.exports = '21.7.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/app-check",
|
|
3
|
-
"version": "21.7.
|
|
3
|
+
"version": "21.7.2",
|
|
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,11 +25,11 @@
|
|
|
25
25
|
"appCheck"
|
|
26
26
|
],
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@react-native-firebase/app": "21.7.
|
|
28
|
+
"@react-native-firebase/app": "21.7.2",
|
|
29
29
|
"expo": ">=47.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"expo": "^
|
|
32
|
+
"expo": "^52.0.30"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
35
35
|
"expo": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "209b36e4b469355e4d024ecdeb6c875f8bd8a187"
|
|
43
43
|
}
|
|
@@ -41,7 +41,7 @@ function modifyObjcAppDelegate(contents) {
|
|
|
41
41
|
comment: '//',
|
|
42
42
|
}).contents;
|
|
43
43
|
}
|
|
44
|
-
catch (
|
|
44
|
+
catch (_) {
|
|
45
45
|
// tests if the opening `{` is in the new line
|
|
46
46
|
const multilineMatcher = new RegExp(fallbackInvocationLineMatcher.source + '.+\\n*{');
|
|
47
47
|
const isHeaderMultiline = multilineMatcher.test(contents);
|
|
@@ -49,7 +49,7 @@ export function modifyObjcAppDelegate(contents: string): string {
|
|
|
49
49
|
offset: 0, // new line will be inserted right above matched anchor
|
|
50
50
|
comment: '//',
|
|
51
51
|
}).contents;
|
|
52
|
-
} catch (
|
|
52
|
+
} catch (_: any) {
|
|
53
53
|
// tests if the opening `{` is in the new line
|
|
54
54
|
const multilineMatcher = new RegExp(fallbackInvocationLineMatcher.source + '.+\\n*{');
|
|
55
55
|
const isHeaderMultiline = multilineMatcher.test(contents);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/ios/appDelegate.ts","./src/ios/index.ts"],"version":"5.
|
|
1
|
+
{"root":["./src/index.ts","./src/ios/appDelegate.ts","./src/ios/index.ts"],"version":"5.7.3"}
|