@react-native-firebase/app-check 22.1.0 → 22.2.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,16 @@
|
|
|
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
|
+
## [22.2.0](https://github.com/invertase/react-native-firebase/compare/v22.1.0...v22.2.0) (2025-05-12)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **app-check:** add Swift AppDelegate support for Expo SDK53+ ([#8521](https://github.com/invertase/react-native-firebase/issues/8521)) ([8c631e1](https://github.com/invertase/react-native-firebase/commit/8c631e14375f97ec6ad7f72cf359b8f7a048479a))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **app-check, types:** modular exports of ReactNativeFirebaseAppCheckProvider types ([f08b687](https://github.com/invertase/react-native-firebase/commit/f08b687b4bf8acdd1cc5846ba5a32565cc2f4318))
|
|
15
|
+
|
|
6
16
|
## [22.1.0](https://github.com/invertase/react-native-firebase/compare/v22.0.0...v22.1.0) (2025-04-30)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @react-native-firebase/app-check
|
package/lib/modular/index.d.ts
CHANGED
|
@@ -92,3 +92,61 @@ export function setTokenAutoRefreshEnabled(
|
|
|
92
92
|
export class CustomProvider implements AppCheckProvider {
|
|
93
93
|
constructor(customProviderOptions: CustomProviderOptions);
|
|
94
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
|
|
107
|
+
extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
108
|
+
/**
|
|
109
|
+
* The web provider to use, either `reCaptchaV3` or `reCaptchaEnterprise`, defaults to `reCaptchaV3`
|
|
110
|
+
*/
|
|
111
|
+
provider?: 'debug' | 'reCaptchaV3' | 'reCaptchaEnterprise';
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* siteKey for use in web queries, defaults to `none`
|
|
115
|
+
*/
|
|
116
|
+
siteKey?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ReactNativeFirebaseAppCheckProviderAppleOptions
|
|
120
|
+
extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
121
|
+
/**
|
|
122
|
+
* The apple provider to use, either `deviceCheck` or `appAttest`, or `appAttestWithDeviceCheckFallback`,
|
|
123
|
+
* defaults to `DeviceCheck`. `appAttest` requires iOS 14+ or will fail, `appAttestWithDeviceCheckFallback`
|
|
124
|
+
* will use `appAttest` for iOS14+ and fallback to `deviceCheck` on devices with ios13 and lower
|
|
125
|
+
*/
|
|
126
|
+
provider?: 'debug' | 'deviceCheck' | 'appAttest' | 'appAttestWithDeviceCheckFallback';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ReactNativeFirebaseAppCheckProviderAndroidOptions
|
|
130
|
+
extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
131
|
+
/**
|
|
132
|
+
* The android provider to use, either `debug` or `playIntegrity`. default is `playIntegrity`.
|
|
133
|
+
*/
|
|
134
|
+
provider?: 'debug' | 'playIntegrity';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export class ReactNativeFirebaseAppCheckProvider extends AppCheckProvider {
|
|
138
|
+
/**
|
|
139
|
+
* Specify how the app check provider should be configured. The new configuration is
|
|
140
|
+
* in effect when this call returns. You must call `getToken()`
|
|
141
|
+
* after this call to get a token using the new configuration.
|
|
142
|
+
* This custom provider allows for delayed configuration and re-configuration on all platforms
|
|
143
|
+
* so AppCheck has the same experience across all platforms, with the only difference being the native
|
|
144
|
+
* providers you choose to use on each platform.
|
|
145
|
+
*/
|
|
146
|
+
configure(options: {
|
|
147
|
+
web?: ReactNativeFirebaseAppCheckProviderWebOptions;
|
|
148
|
+
android?: ReactNativeFirebaseAppCheckProviderAndroidOptions;
|
|
149
|
+
apple?: ReactNativeFirebaseAppCheckProviderAppleOptions;
|
|
150
|
+
isTokenAutoRefreshEnabled?: boolean;
|
|
151
|
+
}): void;
|
|
152
|
+
}
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
module.exports = '22.
|
|
2
|
+
module.exports = '22.2.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/app-check",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.2.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": "22.
|
|
28
|
+
"@react-native-firebase/app": "22.2.0",
|
|
29
29
|
"expo": ">=47.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"access": "public",
|
|
41
41
|
"provenance": true
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "b302210509ceac8078b5fb9fd0b24e68f0641c6a"
|
|
44
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
|
|
3
3
|
export declare function modifyObjcAppDelegate(contents: string): string;
|
|
4
|
+
export declare function modifySwiftAppDelegate(contents: string): string;
|
|
4
5
|
export declare function modifyAppDelegateAsync(appDelegateFileInfo: AppDelegateProjectFile): Promise<void>;
|
|
5
6
|
export declare const withFirebaseAppDelegate: ConfigPlugin;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.withFirebaseAppDelegate = void 0;
|
|
7
7
|
exports.modifyObjcAppDelegate = modifyObjcAppDelegate;
|
|
8
|
+
exports.modifySwiftAppDelegate = modifySwiftAppDelegate;
|
|
8
9
|
exports.modifyAppDelegateAsync = modifyAppDelegateAsync;
|
|
9
10
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
10
11
|
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
@@ -58,16 +59,70 @@ function modifyObjcAppDelegate(contents) {
|
|
|
58
59
|
}).contents;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
62
|
+
function modifySwiftAppDelegate(contents) {
|
|
63
|
+
// Add imports for Swift
|
|
64
|
+
if (!contents.includes('import RNFBAppCheck')) {
|
|
65
|
+
// Try to add after FirebaseCore if it exists
|
|
66
|
+
if (contents.includes('import FirebaseCore')) {
|
|
67
|
+
contents = contents.replace(/import FirebaseCore/g, `import FirebaseCore
|
|
68
|
+
import RNFBAppCheck`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Otherwise add after Expo
|
|
72
|
+
contents = contents.replace(/import Expo/g, `import Expo
|
|
73
|
+
import RNFBAppCheck`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Check if App Check code is already added to avoid duplication
|
|
77
|
+
if (contents.includes('RNFBAppCheckModule.sharedInstance()')) {
|
|
78
|
+
return contents;
|
|
79
|
+
}
|
|
80
|
+
// Find the Firebase initialization end line to insert after
|
|
81
|
+
const firebaseLine = '// @generated end @react-native-firebase/app-didFinishLaunchingWithOptions';
|
|
82
|
+
if (contents.includes(firebaseLine)) {
|
|
83
|
+
// Insert right after Firebase initialization
|
|
84
|
+
return contents.replace(firebaseLine, `${firebaseLine}
|
|
85
|
+
FirebaseApp.configure()
|
|
86
|
+
RNFBAppCheckModule.sharedInstance()
|
|
87
|
+
`);
|
|
88
|
+
}
|
|
89
|
+
// If Firebase initialization block not found, add both Firebase and App Check initialization
|
|
90
|
+
// This is to make sure Firebase is initialized before App Check
|
|
91
|
+
const methodInvocationBlock = `FirebaseApp.configure()
|
|
92
|
+
RNFBAppCheckModule.sharedInstance()`;
|
|
93
|
+
const methodInvocationLineMatcher = /(?:factory\.startReactNative\()/;
|
|
94
|
+
if (!methodInvocationLineMatcher.test(contents)) {
|
|
95
|
+
config_plugins_1.WarningAggregator.addWarningIOS('@react-native-firebase/app-check', 'Unable to determine correct insertion point in AppDelegate.swift. Skipping App Check addition.');
|
|
96
|
+
return contents;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
return (0, generateCode_1.mergeContents)({
|
|
100
|
+
tag: '@react-native-firebase/app-check',
|
|
101
|
+
src: contents,
|
|
102
|
+
newSrc: methodInvocationBlock,
|
|
103
|
+
anchor: methodInvocationLineMatcher,
|
|
104
|
+
offset: 0,
|
|
105
|
+
comment: '//',
|
|
106
|
+
}).contents;
|
|
107
|
+
}
|
|
108
|
+
catch (_e) {
|
|
109
|
+
config_plugins_1.WarningAggregator.addWarningIOS('@react-native-firebase/app-check', 'Failed to insert App Check initialization code.');
|
|
110
|
+
return contents;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
61
113
|
async function modifyAppDelegateAsync(appDelegateFileInfo) {
|
|
62
114
|
const { language, path, contents } = appDelegateFileInfo;
|
|
115
|
+
let newContents;
|
|
63
116
|
if (['objc', 'objcpp'].includes(language)) {
|
|
64
|
-
|
|
65
|
-
|
|
117
|
+
newContents = modifyObjcAppDelegate(contents);
|
|
118
|
+
}
|
|
119
|
+
else if (language === 'swift') {
|
|
120
|
+
newContents = modifySwiftAppDelegate(contents);
|
|
66
121
|
}
|
|
67
122
|
else {
|
|
68
|
-
// TODO: Support Swift
|
|
69
123
|
throw new Error(`Cannot add Firebase code to AppDelegate of language "${language}"`);
|
|
70
124
|
}
|
|
125
|
+
await fs_1.default.promises.writeFile(path, newContents);
|
|
71
126
|
}
|
|
72
127
|
const withFirebaseAppDelegate = config => {
|
|
73
128
|
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
@@ -68,16 +68,91 @@ export function modifyObjcAppDelegate(contents: string): string {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
export function modifySwiftAppDelegate(contents: string): string {
|
|
72
|
+
// Add imports for Swift
|
|
73
|
+
if (!contents.includes('import RNFBAppCheck')) {
|
|
74
|
+
// Try to add after FirebaseCore if it exists
|
|
75
|
+
if (contents.includes('import FirebaseCore')) {
|
|
76
|
+
contents = contents.replace(
|
|
77
|
+
/import FirebaseCore/g,
|
|
78
|
+
`import FirebaseCore
|
|
79
|
+
import RNFBAppCheck`,
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
// Otherwise add after Expo
|
|
83
|
+
contents = contents.replace(
|
|
84
|
+
/import Expo/g,
|
|
85
|
+
`import Expo
|
|
86
|
+
import RNFBAppCheck`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Check if App Check code is already added to avoid duplication
|
|
92
|
+
if (contents.includes('RNFBAppCheckModule.sharedInstance()')) {
|
|
93
|
+
return contents;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Find the Firebase initialization end line to insert after
|
|
97
|
+
const firebaseLine = '// @generated end @react-native-firebase/app-didFinishLaunchingWithOptions';
|
|
98
|
+
|
|
99
|
+
if (contents.includes(firebaseLine)) {
|
|
100
|
+
// Insert right after Firebase initialization
|
|
101
|
+
return contents.replace(
|
|
102
|
+
firebaseLine,
|
|
103
|
+
`${firebaseLine}
|
|
104
|
+
FirebaseApp.configure()
|
|
105
|
+
RNFBAppCheckModule.sharedInstance()
|
|
106
|
+
`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// If Firebase initialization block not found, add both Firebase and App Check initialization
|
|
111
|
+
// This is to make sure Firebase is initialized before App Check
|
|
112
|
+
const methodInvocationBlock = `FirebaseApp.configure()
|
|
113
|
+
RNFBAppCheckModule.sharedInstance()`;
|
|
114
|
+
|
|
115
|
+
const methodInvocationLineMatcher = /(?:factory\.startReactNative\()/;
|
|
116
|
+
|
|
117
|
+
if (!methodInvocationLineMatcher.test(contents)) {
|
|
118
|
+
WarningAggregator.addWarningIOS(
|
|
119
|
+
'@react-native-firebase/app-check',
|
|
120
|
+
'Unable to determine correct insertion point in AppDelegate.swift. Skipping App Check addition.',
|
|
121
|
+
);
|
|
122
|
+
return contents;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
return mergeContents({
|
|
127
|
+
tag: '@react-native-firebase/app-check',
|
|
128
|
+
src: contents,
|
|
129
|
+
newSrc: methodInvocationBlock,
|
|
130
|
+
anchor: methodInvocationLineMatcher,
|
|
131
|
+
offset: 0,
|
|
132
|
+
comment: '//',
|
|
133
|
+
}).contents;
|
|
134
|
+
} catch (_e) {
|
|
135
|
+
WarningAggregator.addWarningIOS(
|
|
136
|
+
'@react-native-firebase/app-check',
|
|
137
|
+
'Failed to insert App Check initialization code.',
|
|
138
|
+
);
|
|
139
|
+
return contents;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
71
143
|
export async function modifyAppDelegateAsync(appDelegateFileInfo: AppDelegateProjectFile) {
|
|
72
144
|
const { language, path, contents } = appDelegateFileInfo;
|
|
73
145
|
|
|
146
|
+
let newContents;
|
|
74
147
|
if (['objc', 'objcpp'].includes(language)) {
|
|
75
|
-
|
|
76
|
-
|
|
148
|
+
newContents = modifyObjcAppDelegate(contents);
|
|
149
|
+
} else if (language === 'swift') {
|
|
150
|
+
newContents = modifySwiftAppDelegate(contents);
|
|
77
151
|
} else {
|
|
78
|
-
// TODO: Support Swift
|
|
79
152
|
throw new Error(`Cannot add Firebase code to AppDelegate of language "${language}"`);
|
|
80
153
|
}
|
|
154
|
+
|
|
155
|
+
await fs.promises.writeFile(path, newContents);
|
|
81
156
|
}
|
|
82
157
|
|
|
83
158
|
export const withFirebaseAppDelegate: ConfigPlugin = config => {
|