@react-native-firebase/app-check 19.1.0 → 19.1.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.
- package/CHANGELOG.md +6 -0
- package/lib/version.js +1 -1
- package/package.json +6 -4
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +15 -0
- package/plugin/build/ios/appDelegate.d.ts +5 -0
- package/plugin/build/ios/appDelegate.js +82 -0
- package/plugin/build/ios/index.d.ts +2 -0
- package/plugin/build/ios/index.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
## [19.1.1](https://github.com/invertase/react-native-firebase/compare/v19.1.0...v19.1.1) (2024-03-26)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **app-check, expo:** ensure config plugin is built before using ([#7704](https://github.com/invertase/react-native-firebase/issues/7704)) ([873130c](https://github.com/invertase/react-native-firebase/commit/873130c11595690924cf60feb08b64b3b9421042))
|
|
11
|
+
|
|
6
12
|
## [19.1.0](https://github.com/invertase/react-native-firebase/compare/v19.0.1...v19.1.0) (2024-03-23)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
module.exports = '19.1.
|
|
2
|
+
module.exports = '19.1.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/app-check",
|
|
3
|
-
"version": "19.1.
|
|
3
|
+
"version": "19.1.1",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Firebase - App Check",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "genversion --semi lib/version.js",
|
|
10
10
|
"build:clean": "rimraf android/build && rimraf ios/build",
|
|
11
|
-
"
|
|
11
|
+
"build:plugin": "rimraf plugin/build && tsc --build plugin",
|
|
12
|
+
"lint:plugin": "eslint plugin/src/*",
|
|
13
|
+
"prepare": "yarn run build && yarn run build:plugin"
|
|
12
14
|
},
|
|
13
15
|
"repository": {
|
|
14
16
|
"type": "git",
|
|
@@ -23,7 +25,7 @@
|
|
|
23
25
|
"appCheck"
|
|
24
26
|
],
|
|
25
27
|
"peerDependencies": {
|
|
26
|
-
"@react-native-firebase/app": "19.1.
|
|
28
|
+
"@react-native-firebase/app": "19.1.1",
|
|
27
29
|
"expo": ">=47.0.0"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
@@ -37,5 +39,5 @@
|
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "2cee82424b7191c83d5378209a31cb73cbf8bd0a"
|
|
41
43
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
+
const ios_1 = require("./ios");
|
|
5
|
+
/**
|
|
6
|
+
* A config plugin for configuring `@react-native-firebase/app-check`
|
|
7
|
+
*/
|
|
8
|
+
const withRnFirebaseAppCheck = config => {
|
|
9
|
+
return (0, config_plugins_1.withPlugins)(config, [
|
|
10
|
+
// iOS
|
|
11
|
+
ios_1.withFirebaseAppDelegate,
|
|
12
|
+
]);
|
|
13
|
+
};
|
|
14
|
+
const pak = require('@react-native-firebase/app-check/package.json');
|
|
15
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withRnFirebaseAppCheck, pak.name, pak.version);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
|
|
3
|
+
export declare function modifyObjcAppDelegate(contents: string): string;
|
|
4
|
+
export declare function modifyAppDelegateAsync(appDelegateFileInfo: AppDelegateProjectFile): Promise<void>;
|
|
5
|
+
export declare const withFirebaseAppDelegate: ConfigPlugin;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.withFirebaseAppDelegate = exports.modifyAppDelegateAsync = exports.modifyObjcAppDelegate = void 0;
|
|
7
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
8
|
+
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const methodInvocationBlock = `[RNFBAppCheckModule sharedInstance];`;
|
|
11
|
+
// https://regex101.com/r/mPgaq6/1
|
|
12
|
+
const methodInvocationLineMatcher = /(?:self\.moduleName\s*=\s*@\"([^"]*)\";)|(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[(\[RCTBridge alloc\]|self\.reactDelegate))/g;
|
|
13
|
+
// https://regex101.com/r/nHrTa9/1/
|
|
14
|
+
// if the above regex fails, we can use this one as a fallback:
|
|
15
|
+
const fallbackInvocationLineMatcher = /-\s*\(BOOL\)\s*application:\s*\(UIApplication\s*\*\s*\)\s*\w+\s+didFinishLaunchingWithOptions:/g;
|
|
16
|
+
function modifyObjcAppDelegate(contents) {
|
|
17
|
+
// Add import
|
|
18
|
+
if (!contents.includes('#import <RNFBAppCheckModule.h>')) {
|
|
19
|
+
contents = contents.replace(/#import "AppDelegate.h"/g, `#import "AppDelegate.h"
|
|
20
|
+
#import <RNFBAppCheckModule.h>`);
|
|
21
|
+
}
|
|
22
|
+
// To avoid potential issues with existing changes from older plugin versions
|
|
23
|
+
if (contents.includes(methodInvocationBlock)) {
|
|
24
|
+
return contents;
|
|
25
|
+
}
|
|
26
|
+
if (!methodInvocationLineMatcher.test(contents) &&
|
|
27
|
+
!fallbackInvocationLineMatcher.test(contents)) {
|
|
28
|
+
config_plugins_1.WarningAggregator.addWarningIOS('@react-native-firebase/app-check', 'Unable to determine correct Firebase insertion point in AppDelegate.m. Skipping Firebase addition.');
|
|
29
|
+
return contents;
|
|
30
|
+
}
|
|
31
|
+
// Add invocation
|
|
32
|
+
try {
|
|
33
|
+
return (0, generateCode_1.mergeContents)({
|
|
34
|
+
tag: '@react-native-firebase/app-check-didFinishLaunchingWithOptions',
|
|
35
|
+
src: contents,
|
|
36
|
+
newSrc: methodInvocationBlock,
|
|
37
|
+
anchor: methodInvocationLineMatcher,
|
|
38
|
+
offset: 0, // new line will be inserted right above matched anchor
|
|
39
|
+
comment: '//',
|
|
40
|
+
}).contents;
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
// tests if the opening `{` is in the new line
|
|
44
|
+
const multilineMatcher = new RegExp(fallbackInvocationLineMatcher.source + '.+\\n*{');
|
|
45
|
+
const isHeaderMultiline = multilineMatcher.test(contents);
|
|
46
|
+
// we fallback to another regex if the first one fails
|
|
47
|
+
return (0, generateCode_1.mergeContents)({
|
|
48
|
+
tag: '@react-native-firebase/app-didFinishLaunchingWithOptions-fallback',
|
|
49
|
+
src: contents,
|
|
50
|
+
newSrc: methodInvocationBlock,
|
|
51
|
+
anchor: fallbackInvocationLineMatcher,
|
|
52
|
+
// new line will be inserted right below matched anchor
|
|
53
|
+
// or two lines, if the `{` is in the new line
|
|
54
|
+
offset: isHeaderMultiline ? 2 : 1,
|
|
55
|
+
comment: '//',
|
|
56
|
+
}).contents;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.modifyObjcAppDelegate = modifyObjcAppDelegate;
|
|
60
|
+
async function modifyAppDelegateAsync(appDelegateFileInfo) {
|
|
61
|
+
const { language, path, contents } = appDelegateFileInfo;
|
|
62
|
+
if (['objc', 'objcpp'].includes(language)) {
|
|
63
|
+
const newContents = modifyObjcAppDelegate(contents);
|
|
64
|
+
await fs_1.default.promises.writeFile(path, newContents);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// TODO: Support Swift
|
|
68
|
+
throw new Error(`Cannot add Firebase code to AppDelegate of language "${language}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.modifyAppDelegateAsync = modifyAppDelegateAsync;
|
|
72
|
+
const withFirebaseAppDelegate = config => {
|
|
73
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
74
|
+
'ios',
|
|
75
|
+
async (config) => {
|
|
76
|
+
const fileInfo = config_plugins_1.IOSConfig.Paths.getAppDelegate(config.modRequest.projectRoot);
|
|
77
|
+
await modifyAppDelegateAsync(fileInfo);
|
|
78
|
+
return config;
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
exports.withFirebaseAppDelegate = withFirebaseAppDelegate;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withFirebaseAppDelegate = void 0;
|
|
4
|
+
const appDelegate_1 = require("./appDelegate");
|
|
5
|
+
Object.defineProperty(exports, "withFirebaseAppDelegate", { enumerable: true, get: function () { return appDelegate_1.withFirebaseAppDelegate; } });
|