@react-native-firebase/app-check 25.1.0 → 26.1.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 +38 -0
- package/RNFBAppCheck.podspec +20 -7
- package/android/build.gradle +19 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/{ReactNativeFirebaseAppCheckModule.java → NativeRNFBTurboAppCheck.java} +46 -34
- package/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckPackage.java +1 -1
- package/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckProvider.java +9 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboAppCheckSpec.java +67 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/generated/jni/CMakeLists.txt +36 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/generated/jni/RNFBAppCheckTurboModules-generated.cpp +74 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/generated/jni/RNFBAppCheckTurboModules.h +31 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/generated/jni/react/renderer/components/RNFBAppCheckTurboModules/RNFBAppCheckTurboModulesJSI-generated.cpp +85 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/generated/jni/react/renderer/components/RNFBAppCheckTurboModules/RNFBAppCheckTurboModulesJSI.h +174 -0
- package/app.plugin.js +1 -1
- package/dist/module/index.js +210 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/index.d.ts +19 -4
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/types/appcheck.d.ts +5 -0
- package/dist/typescript/lib/types/appcheck.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +1 -1
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/ios/RNFBAppCheck/RNFBAppCheckModule.h +3 -8
- package/ios/RNFBAppCheck/{RNFBAppCheckModule.m → RNFBAppCheckModule.mm} +75 -45
- package/ios/RNFBAppCheck/RNFBAppCheckProvider.h +8 -1
- package/ios/RNFBAppCheck/RNFBAppCheckProvider.m +11 -1
- package/ios/RNFBAppCheck.xcodeproj/project.pbxproj +8 -8
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNFBAppCheckTurboModules/RNFBAppCheckTurboModules-generated.mm +88 -0
- package/ios/generated/RNFBAppCheckTurboModules/RNFBAppCheckTurboModules.h +85 -0
- package/ios/generated/RNFBAppCheckTurboModulesJSI-generated.cpp +85 -0
- package/ios/generated/RNFBAppCheckTurboModulesJSI.h +174 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/index.ts +335 -8
- package/lib/types/appcheck.ts +6 -0
- package/lib/types/internal.ts +1 -1
- package/lib/version.ts +1 -1
- package/package.json +30 -5
- package/plugin/build/app.plugin.d.ts +2 -0
- package/plugin/build/app.plugin.js +6 -0
- package/plugin/build/ios/appDelegate.js +18 -4
- package/plugin/src/app.plugin.ts +3 -0
- package/plugin/src/ios/appDelegate.ts +23 -4
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/react-native.config.js +10 -0
- package/specs/NativeRNFBTurboAppCheck.ts +27 -0
- package/typedoc.json +1 -1
- package/dist/module/modular.js +0 -93
- package/dist/module/modular.js.map +0 -1
- package/dist/module/namespaced.js +0 -194
- package/dist/module/namespaced.js.map +0 -1
- package/dist/module/types/namespaced.js +0 -60
- package/dist/module/types/namespaced.js.map +0 -1
- package/dist/typescript/lib/modular.d.ts +0 -56
- package/dist/typescript/lib/modular.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -12
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/dist/typescript/lib/types/namespaced.d.ts +0 -358
- package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
- package/lib/modular.ts +0 -157
- package/lib/namespaced.ts +0 -286
- package/lib/types/namespaced.ts +0 -422
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNFBAppCheckTurboModulesJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_activate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->activate(
|
|
16
|
+
rt,
|
|
17
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
18
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
19
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asBool()
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_configureProvider(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
23
|
+
return static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->configureProvider(
|
|
24
|
+
rt,
|
|
25
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
26
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
27
|
+
count <= 2 || args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt))
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_setTokenAutoRefreshEnabled(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
31
|
+
static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->setTokenAutoRefreshEnabled(
|
|
32
|
+
rt,
|
|
33
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
34
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asBool()
|
|
35
|
+
);
|
|
36
|
+
return jsi::Value::undefined();
|
|
37
|
+
}
|
|
38
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_isTokenAutoRefreshEnabled(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
39
|
+
return static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->isTokenAutoRefreshEnabled(
|
|
40
|
+
rt,
|
|
41
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_getToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
45
|
+
return static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->getToken(
|
|
46
|
+
rt,
|
|
47
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
48
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asBool()
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_getLimitedUseToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
52
|
+
return static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->getLimitedUseToken(
|
|
53
|
+
rt,
|
|
54
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_addAppCheckListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
58
|
+
static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->addAppCheckListener(
|
|
59
|
+
rt,
|
|
60
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
61
|
+
);
|
|
62
|
+
return jsi::Value::undefined();
|
|
63
|
+
}
|
|
64
|
+
static jsi::Value __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_removeAppCheckListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
65
|
+
static_cast<NativeRNFBTurboAppCheckCxxSpecJSI *>(&turboModule)->removeAppCheckListener(
|
|
66
|
+
rt,
|
|
67
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
68
|
+
);
|
|
69
|
+
return jsi::Value::undefined();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
NativeRNFBTurboAppCheckCxxSpecJSI::NativeRNFBTurboAppCheckCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
73
|
+
: TurboModule("NativeRNFBTurboAppCheck", jsInvoker) {
|
|
74
|
+
methodMap_["activate"] = MethodMetadata {3, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_activate};
|
|
75
|
+
methodMap_["configureProvider"] = MethodMetadata {3, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_configureProvider};
|
|
76
|
+
methodMap_["setTokenAutoRefreshEnabled"] = MethodMetadata {2, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_setTokenAutoRefreshEnabled};
|
|
77
|
+
methodMap_["isTokenAutoRefreshEnabled"] = MethodMetadata {1, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_isTokenAutoRefreshEnabled};
|
|
78
|
+
methodMap_["getToken"] = MethodMetadata {2, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_getToken};
|
|
79
|
+
methodMap_["getLimitedUseToken"] = MethodMetadata {1, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_getLimitedUseToken};
|
|
80
|
+
methodMap_["addAppCheckListener"] = MethodMetadata {1, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_addAppCheckListener};
|
|
81
|
+
methodMap_["removeAppCheckListener"] = MethodMetadata {1, __hostFunction_NativeRNFBTurboAppCheckCxxSpecJSI_removeAppCheckListener};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#pragma mark - NativeRNFBTurboAppCheckAppCheckTokenResult
|
|
20
|
+
|
|
21
|
+
template <typename P0>
|
|
22
|
+
struct NativeRNFBTurboAppCheckAppCheckTokenResult {
|
|
23
|
+
P0 token;
|
|
24
|
+
bool operator==(const NativeRNFBTurboAppCheckAppCheckTokenResult &other) const {
|
|
25
|
+
return token == other.token;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
template <typename T>
|
|
30
|
+
struct NativeRNFBTurboAppCheckAppCheckTokenResultBridging {
|
|
31
|
+
static T types;
|
|
32
|
+
|
|
33
|
+
static T fromJs(
|
|
34
|
+
jsi::Runtime &rt,
|
|
35
|
+
const jsi::Object &value,
|
|
36
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
37
|
+
T result{
|
|
38
|
+
bridging::fromJs<decltype(types.token)>(rt, value.getProperty(rt, "token"), jsInvoker)};
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#ifdef DEBUG
|
|
43
|
+
static jsi::String tokenToJs(jsi::Runtime &rt, decltype(types.token) value) {
|
|
44
|
+
return bridging::toJs(rt, value);
|
|
45
|
+
}
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
static jsi::Object toJs(
|
|
49
|
+
jsi::Runtime &rt,
|
|
50
|
+
const T &value,
|
|
51
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
52
|
+
auto result = facebook::jsi::Object(rt);
|
|
53
|
+
result.setProperty(rt, "token", bridging::toJs(rt, value.token, jsInvoker));
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
class JSI_EXPORT NativeRNFBTurboAppCheckCxxSpecJSI : public TurboModule {
|
|
59
|
+
protected:
|
|
60
|
+
NativeRNFBTurboAppCheckCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
virtual jsi::Value activate(jsi::Runtime &rt, jsi::String appName, jsi::String siteKeyProvider, bool isTokenAutoRefreshEnabled) = 0;
|
|
64
|
+
virtual jsi::Value configureProvider(jsi::Runtime &rt, jsi::String appName, jsi::String providerName, std::optional<jsi::String> debugToken) = 0;
|
|
65
|
+
virtual void setTokenAutoRefreshEnabled(jsi::Runtime &rt, jsi::String appName, bool isTokenAutoRefreshEnabled) = 0;
|
|
66
|
+
virtual jsi::Value isTokenAutoRefreshEnabled(jsi::Runtime &rt, jsi::String appName) = 0;
|
|
67
|
+
virtual jsi::Value getToken(jsi::Runtime &rt, jsi::String appName, bool forceRefresh) = 0;
|
|
68
|
+
virtual jsi::Value getLimitedUseToken(jsi::Runtime &rt, jsi::String appName) = 0;
|
|
69
|
+
virtual void addAppCheckListener(jsi::Runtime &rt, jsi::String appName) = 0;
|
|
70
|
+
virtual void removeAppCheckListener(jsi::Runtime &rt, jsi::String appName) = 0;
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
template <typename T>
|
|
75
|
+
class JSI_EXPORT NativeRNFBTurboAppCheckCxxSpec : public TurboModule {
|
|
76
|
+
public:
|
|
77
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
78
|
+
return delegate_.create(rt, propName);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
82
|
+
return delegate_.getPropertyNames(runtime);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static constexpr std::string_view kModuleName = "NativeRNFBTurboAppCheck";
|
|
86
|
+
|
|
87
|
+
protected:
|
|
88
|
+
NativeRNFBTurboAppCheckCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
89
|
+
: TurboModule(std::string{NativeRNFBTurboAppCheckCxxSpec::kModuleName}, jsInvoker),
|
|
90
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
private:
|
|
94
|
+
class Delegate : public NativeRNFBTurboAppCheckCxxSpecJSI {
|
|
95
|
+
public:
|
|
96
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
97
|
+
NativeRNFBTurboAppCheckCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
jsi::Value activate(jsi::Runtime &rt, jsi::String appName, jsi::String siteKeyProvider, bool isTokenAutoRefreshEnabled) override {
|
|
102
|
+
static_assert(
|
|
103
|
+
bridging::getParameterCount(&T::activate) == 4,
|
|
104
|
+
"Expected activate(...) to have 4 parameters");
|
|
105
|
+
|
|
106
|
+
return bridging::callFromJs<jsi::Value>(
|
|
107
|
+
rt, &T::activate, jsInvoker_, instance_, std::move(appName), std::move(siteKeyProvider), std::move(isTokenAutoRefreshEnabled));
|
|
108
|
+
}
|
|
109
|
+
jsi::Value configureProvider(jsi::Runtime &rt, jsi::String appName, jsi::String providerName, std::optional<jsi::String> debugToken) override {
|
|
110
|
+
static_assert(
|
|
111
|
+
bridging::getParameterCount(&T::configureProvider) == 4,
|
|
112
|
+
"Expected configureProvider(...) to have 4 parameters");
|
|
113
|
+
|
|
114
|
+
return bridging::callFromJs<jsi::Value>(
|
|
115
|
+
rt, &T::configureProvider, jsInvoker_, instance_, std::move(appName), std::move(providerName), std::move(debugToken));
|
|
116
|
+
}
|
|
117
|
+
void setTokenAutoRefreshEnabled(jsi::Runtime &rt, jsi::String appName, bool isTokenAutoRefreshEnabled) override {
|
|
118
|
+
static_assert(
|
|
119
|
+
bridging::getParameterCount(&T::setTokenAutoRefreshEnabled) == 3,
|
|
120
|
+
"Expected setTokenAutoRefreshEnabled(...) to have 3 parameters");
|
|
121
|
+
|
|
122
|
+
return bridging::callFromJs<void>(
|
|
123
|
+
rt, &T::setTokenAutoRefreshEnabled, jsInvoker_, instance_, std::move(appName), std::move(isTokenAutoRefreshEnabled));
|
|
124
|
+
}
|
|
125
|
+
jsi::Value isTokenAutoRefreshEnabled(jsi::Runtime &rt, jsi::String appName) override {
|
|
126
|
+
static_assert(
|
|
127
|
+
bridging::getParameterCount(&T::isTokenAutoRefreshEnabled) == 2,
|
|
128
|
+
"Expected isTokenAutoRefreshEnabled(...) to have 2 parameters");
|
|
129
|
+
|
|
130
|
+
return bridging::callFromJs<jsi::Value>(
|
|
131
|
+
rt, &T::isTokenAutoRefreshEnabled, jsInvoker_, instance_, std::move(appName));
|
|
132
|
+
}
|
|
133
|
+
jsi::Value getToken(jsi::Runtime &rt, jsi::String appName, bool forceRefresh) override {
|
|
134
|
+
static_assert(
|
|
135
|
+
bridging::getParameterCount(&T::getToken) == 3,
|
|
136
|
+
"Expected getToken(...) to have 3 parameters");
|
|
137
|
+
|
|
138
|
+
return bridging::callFromJs<jsi::Value>(
|
|
139
|
+
rt, &T::getToken, jsInvoker_, instance_, std::move(appName), std::move(forceRefresh));
|
|
140
|
+
}
|
|
141
|
+
jsi::Value getLimitedUseToken(jsi::Runtime &rt, jsi::String appName) override {
|
|
142
|
+
static_assert(
|
|
143
|
+
bridging::getParameterCount(&T::getLimitedUseToken) == 2,
|
|
144
|
+
"Expected getLimitedUseToken(...) to have 2 parameters");
|
|
145
|
+
|
|
146
|
+
return bridging::callFromJs<jsi::Value>(
|
|
147
|
+
rt, &T::getLimitedUseToken, jsInvoker_, instance_, std::move(appName));
|
|
148
|
+
}
|
|
149
|
+
void addAppCheckListener(jsi::Runtime &rt, jsi::String appName) override {
|
|
150
|
+
static_assert(
|
|
151
|
+
bridging::getParameterCount(&T::addAppCheckListener) == 2,
|
|
152
|
+
"Expected addAppCheckListener(...) to have 2 parameters");
|
|
153
|
+
|
|
154
|
+
return bridging::callFromJs<void>(
|
|
155
|
+
rt, &T::addAppCheckListener, jsInvoker_, instance_, std::move(appName));
|
|
156
|
+
}
|
|
157
|
+
void removeAppCheckListener(jsi::Runtime &rt, jsi::String appName) override {
|
|
158
|
+
static_assert(
|
|
159
|
+
bridging::getParameterCount(&T::removeAppCheckListener) == 2,
|
|
160
|
+
"Expected removeAppCheckListener(...) to have 2 parameters");
|
|
161
|
+
|
|
162
|
+
return bridging::callFromJs<void>(
|
|
163
|
+
rt, &T::removeAppCheckListener, jsInvoker_, instance_, std::move(appName));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private:
|
|
167
|
+
friend class NativeRNFBTurboAppCheckCxxSpec;
|
|
168
|
+
T *instance_;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
Delegate delegate_;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
version = "0.78.3"
|
|
7
|
+
source = { :git => 'https://github.com/facebook/react-native.git' }
|
|
8
|
+
if version == '1000.0.0'
|
|
9
|
+
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
|
10
|
+
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
|
|
11
|
+
else
|
|
12
|
+
source[:tag] = "v#{version}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Pod::Spec.new do |s|
|
|
16
|
+
s.name = "ReactAppDependencyProvider"
|
|
17
|
+
s.version = version
|
|
18
|
+
s.summary = "The third party dependency provider for the app"
|
|
19
|
+
s.homepage = "https://reactnative.dev/"
|
|
20
|
+
s.documentation_url = "https://reactnative.dev/"
|
|
21
|
+
s.license = "MIT"
|
|
22
|
+
s.author = "Meta Platforms, Inc. and its affiliates"
|
|
23
|
+
s.platforms = min_supported_versions
|
|
24
|
+
s.source = source
|
|
25
|
+
s.source_files = "**/RCTAppDependencyProvider.{h,mm}"
|
|
26
|
+
|
|
27
|
+
# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
s.pod_target_xcconfig = {
|
|
29
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
30
|
+
"DEFINES_MODULE" => "YES"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
s.dependency "ReactCodegen"
|
|
34
|
+
end
|
package/lib/index.ts
CHANGED
|
@@ -15,13 +15,340 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
import {
|
|
19
|
+
isBoolean,
|
|
20
|
+
isIOS,
|
|
21
|
+
isObject,
|
|
22
|
+
isString,
|
|
23
|
+
isUndefined,
|
|
24
|
+
isOther,
|
|
25
|
+
parseListenerOrObserver,
|
|
26
|
+
} from '@react-native-firebase/app/dist/module/common';
|
|
27
|
+
import type { FirebaseApp } from '@react-native-firebase/app';
|
|
28
|
+
import {
|
|
29
|
+
FirebaseModule,
|
|
30
|
+
getOrCreateModularInstance,
|
|
31
|
+
} from '@react-native-firebase/app/dist/module/internal';
|
|
32
|
+
import type { ModuleConfig } from '@react-native-firebase/app/dist/module/internal';
|
|
33
|
+
import './types/internal';
|
|
34
|
+
import { Platform } from 'react-native';
|
|
35
|
+
import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
36
|
+
import fallBackModule from './web/RNFBAppCheckModule';
|
|
37
|
+
import { version } from './version';
|
|
38
|
+
import type {
|
|
39
|
+
AppCheck,
|
|
40
|
+
AppCheckOptions,
|
|
41
|
+
AppCheckProvider,
|
|
42
|
+
AppCheckTokenResult,
|
|
43
|
+
PartialObserver,
|
|
44
|
+
Unsubscribe,
|
|
45
|
+
} from './types/appcheck';
|
|
46
|
+
import type { AppCheckInternal, ProviderWithOptions } from './types/internal';
|
|
47
|
+
import type { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
48
|
+
import { ReactNativeFirebaseAppCheckProvider } from './providers';
|
|
49
|
+
|
|
50
|
+
const nativeModuleName = 'NativeRNFBTurboAppCheck';
|
|
51
|
+
|
|
52
|
+
const VALID_APPLE_PROVIDERS = [
|
|
53
|
+
'debug',
|
|
54
|
+
'deviceCheck',
|
|
55
|
+
'appAttest',
|
|
56
|
+
'appAttestWithDeviceCheckFallback',
|
|
57
|
+
];
|
|
58
|
+
const VALID_ANDROID_PROVIDERS = ['debug', 'playIntegrity'];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Type guard to check if a provider has providerOptions.
|
|
62
|
+
* This provides proper type narrowing for providers that support platform-specific configuration.
|
|
63
|
+
*/
|
|
64
|
+
function hasProviderOptions(
|
|
65
|
+
provider: AppCheckOptions['provider'],
|
|
66
|
+
): provider is ProviderWithOptions {
|
|
67
|
+
return (
|
|
68
|
+
provider !== undefined &&
|
|
69
|
+
'providerOptions' in provider &&
|
|
70
|
+
provider.providerOptions !== undefined
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function validateProviderName(options: AppCheckOptions): void {
|
|
75
|
+
if (!hasProviderOptions(options.provider)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const provider = options.provider;
|
|
79
|
+
if (Platform.OS === 'android') {
|
|
80
|
+
const name = provider.providerOptions?.android?.provider;
|
|
81
|
+
if (isString(name) && !VALID_ANDROID_PROVIDERS.includes(name)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Invalid App Check provider "${name}". Valid android providers are: ${VALID_ANDROID_PROVIDERS.join(', ')}.`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
|
|
88
|
+
const name = provider.providerOptions?.apple?.provider;
|
|
89
|
+
if (isString(name) && !VALID_APPLE_PROVIDERS.includes(name)) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Invalid App Check provider "${name}". Valid apple providers are: ${VALID_APPLE_PROVIDERS.join(', ')}.`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
class FirebaseAppCheckModule extends FirebaseModule<typeof nativeModuleName> {
|
|
98
|
+
_listenerCount: number;
|
|
99
|
+
|
|
100
|
+
constructor(
|
|
101
|
+
app: ReactNativeFirebase.FirebaseAppBase,
|
|
102
|
+
config: ModuleConfig,
|
|
103
|
+
customUrlOrRegion?: string | null,
|
|
104
|
+
) {
|
|
105
|
+
super(app, config, customUrlOrRegion);
|
|
106
|
+
|
|
107
|
+
this.emitter.addListener(this.eventNameForApp('appCheck_token_changed'), event => {
|
|
108
|
+
this.emitter.emit(this.eventNameForApp('onAppCheckTokenChanged'), event);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
this._listenerCount = 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getIsTokenRefreshEnabledDefault(): boolean | undefined {
|
|
115
|
+
// no default to start
|
|
116
|
+
let isTokenAutoRefreshEnabled: boolean | undefined = undefined;
|
|
117
|
+
|
|
118
|
+
return isTokenAutoRefreshEnabled;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
newReactNativeFirebaseAppCheckProvider(): ReactNativeFirebaseAppCheckProvider {
|
|
122
|
+
return new ReactNativeFirebaseAppCheckProvider();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
initializeAppCheck(options: AppCheckOptions): Promise<void> {
|
|
126
|
+
if (isOther) {
|
|
127
|
+
if (!isObject(options)) {
|
|
128
|
+
throw new Error('Invalid configuration: no options defined.');
|
|
129
|
+
}
|
|
130
|
+
if (isUndefined(options.provider)) {
|
|
131
|
+
throw new Error('Invalid configuration: no provider defined.');
|
|
132
|
+
}
|
|
133
|
+
return this.native.initializeAppCheck(options);
|
|
134
|
+
}
|
|
135
|
+
// determine token refresh setting, if not specified
|
|
136
|
+
if (!isBoolean(options.isTokenAutoRefreshEnabled)) {
|
|
137
|
+
const tokenRefresh = this.firebaseJson.app_check_token_auto_refresh;
|
|
138
|
+
if (isBoolean(tokenRefresh)) {
|
|
139
|
+
options.isTokenAutoRefreshEnabled = tokenRefresh;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// If that was not defined, attempt to use app-wide data collection setting per docs:
|
|
144
|
+
if (!isBoolean(options.isTokenAutoRefreshEnabled)) {
|
|
145
|
+
const dataCollection = this.firebaseJson.app_data_collection_default_enabled;
|
|
146
|
+
if (isBoolean(dataCollection)) {
|
|
147
|
+
options.isTokenAutoRefreshEnabled = dataCollection;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// If that also was not defined, the default is documented as true.
|
|
152
|
+
if (!isBoolean(options.isTokenAutoRefreshEnabled)) {
|
|
153
|
+
options.isTokenAutoRefreshEnabled = true;
|
|
154
|
+
}
|
|
155
|
+
this.native.setTokenAutoRefreshEnabled(options.isTokenAutoRefreshEnabled);
|
|
156
|
+
|
|
157
|
+
if (!hasProviderOptions(options.provider)) {
|
|
158
|
+
throw new Error('Invalid configuration: no provider or no provider options defined.');
|
|
159
|
+
}
|
|
160
|
+
const provider = options.provider;
|
|
161
|
+
if (Platform.OS === 'android') {
|
|
162
|
+
if (!isString(provider.providerOptions?.android?.provider)) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
'Invalid configuration: no android provider configured while on android platform.',
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return this.native.configureProvider(
|
|
168
|
+
provider.providerOptions.android.provider,
|
|
169
|
+
provider.providerOptions.android.debugToken,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
|
|
173
|
+
if (!isString(provider.providerOptions?.apple?.provider)) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
'Invalid configuration: no apple provider configured while on apple platform.',
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return this.native.configureProvider(
|
|
179
|
+
provider.providerOptions.apple.provider,
|
|
180
|
+
provider.providerOptions.apple.debugToken,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
throw new Error('Unsupported platform: ' + Platform.OS);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
activate(
|
|
187
|
+
siteKeyOrProvider: string | AppCheckProvider,
|
|
188
|
+
isTokenAutoRefreshEnabled?: boolean,
|
|
189
|
+
): Promise<void> {
|
|
190
|
+
if (isOther) {
|
|
191
|
+
throw new Error('firebase.appCheck().activate(*) is not supported on other platforms');
|
|
192
|
+
}
|
|
193
|
+
if (!isString(siteKeyOrProvider)) {
|
|
194
|
+
throw new Error('siteKeyOrProvider must be a string value to match firebase-js-sdk API');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// We wrap our new flexible interface, with compatible defaults
|
|
198
|
+
const rnfbProvider = new ReactNativeFirebaseAppCheckProvider();
|
|
199
|
+
rnfbProvider.configure({
|
|
200
|
+
android: {
|
|
201
|
+
provider: 'playIntegrity',
|
|
202
|
+
},
|
|
203
|
+
apple: {
|
|
204
|
+
provider: 'deviceCheck',
|
|
205
|
+
},
|
|
206
|
+
web: {
|
|
207
|
+
provider: 'reCaptchaV3',
|
|
208
|
+
siteKey: 'none',
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return this.initializeAppCheck({ provider: rnfbProvider, isTokenAutoRefreshEnabled });
|
|
213
|
+
}
|
|
20
214
|
|
|
21
|
-
//
|
|
22
|
-
|
|
215
|
+
// TODO this is an async call
|
|
216
|
+
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void {
|
|
217
|
+
this.native.setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {
|
|
221
|
+
if (!forceRefresh) {
|
|
222
|
+
return this.native.getToken(false);
|
|
223
|
+
} else {
|
|
224
|
+
return this.native.getToken(true);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
getLimitedUseToken(): Promise<AppCheckTokenResult> {
|
|
229
|
+
return this.native.getLimitedUseToken();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
onTokenChanged(
|
|
233
|
+
onNextOrObserver:
|
|
234
|
+
| PartialObserver<AppCheckTokenResult>
|
|
235
|
+
| ((tokenResult: AppCheckTokenResult) => void),
|
|
236
|
+
_onError?: (error: Error) => void,
|
|
237
|
+
_onCompletion?: () => void,
|
|
238
|
+
): () => void {
|
|
239
|
+
// iOS does not provide any native listening feature
|
|
240
|
+
if (isIOS) {
|
|
241
|
+
// eslint-disable-next-line no-console
|
|
242
|
+
console.warn('onTokenChanged is not implemented on IOS, only for Android');
|
|
243
|
+
return () => {};
|
|
244
|
+
}
|
|
245
|
+
const nextFn = parseListenerOrObserver(
|
|
246
|
+
onNextOrObserver as
|
|
247
|
+
| ((value: AppCheckTokenResult) => void)
|
|
248
|
+
| { next: (value: AppCheckTokenResult) => void },
|
|
249
|
+
);
|
|
250
|
+
// let errorFn = function () { };
|
|
251
|
+
// if (onNextOrObserver.error != null) {
|
|
252
|
+
// errorFn = onNextOrObserver.error.bind(onNextOrObserver);
|
|
253
|
+
// }
|
|
254
|
+
// else if (onError) {
|
|
255
|
+
// errorFn = onError;
|
|
256
|
+
// }
|
|
257
|
+
const subscription = this.emitter.addListener(
|
|
258
|
+
this.eventNameForApp('onAppCheckTokenChanged'),
|
|
259
|
+
nextFn,
|
|
260
|
+
);
|
|
261
|
+
if (this._listenerCount === 0) this.native.addAppCheckListener();
|
|
262
|
+
|
|
263
|
+
this._listenerCount++;
|
|
264
|
+
return () => {
|
|
265
|
+
subscription.remove();
|
|
266
|
+
this._listenerCount--;
|
|
267
|
+
if (this._listenerCount === 0) this.native.removeAppCheckListener();
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const config: ModuleConfig = {
|
|
273
|
+
namespace: 'appCheck',
|
|
274
|
+
nativeModuleName,
|
|
275
|
+
nativeEvents: ['appCheck_token_changed'],
|
|
276
|
+
hasMultiAppSupport: true,
|
|
277
|
+
hasCustomUrlOrRegionSupport: false,
|
|
278
|
+
turboModule: true,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export const SDK_VERSION = version;
|
|
282
|
+
|
|
283
|
+
export { CustomProvider, ReactNativeFirebaseAppCheckProvider } from './providers';
|
|
284
|
+
|
|
285
|
+
function getModularAppCheck(app?: FirebaseApp): AppCheck {
|
|
286
|
+
return getOrCreateModularInstance(FirebaseAppCheckModule, config, app) as unknown as AppCheck;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Initializes App Check for the given Firebase app.
|
|
291
|
+
*
|
|
292
|
+
* @remarks Returns synchronously for firebase-js-sdk parity; native provider setup continues in
|
|
293
|
+
* the background. On native platforms use {@link ReactNativeFirebaseAppCheckProvider} to configure
|
|
294
|
+
* Device Check, App Attest, Play Integrity, or debug providers. firebase-js-sdk
|
|
295
|
+
* `ReCaptchaEnterpriseProvider` / `ReCaptchaV3Provider` are **web only** and have no RN equivalent.
|
|
296
|
+
*/
|
|
297
|
+
export function initializeAppCheck(app?: FirebaseApp, options?: AppCheckOptions): AppCheck {
|
|
298
|
+
if (!isObject(options)) {
|
|
299
|
+
throw new Error('Invalid configuration: no options defined.');
|
|
300
|
+
}
|
|
301
|
+
validateProviderName(options);
|
|
302
|
+
const appCheck = getModularAppCheck(app);
|
|
303
|
+
void (appCheck as AppCheckInternal).initializeAppCheck(options);
|
|
304
|
+
return appCheck;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function getToken(
|
|
308
|
+
appCheckInstance: AppCheck,
|
|
309
|
+
forceRefresh?: boolean,
|
|
310
|
+
): Promise<AppCheckTokenResult> {
|
|
311
|
+
return (appCheckInstance as AppCheckInternal).getToken(forceRefresh);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult> {
|
|
315
|
+
return (appCheckInstance as AppCheckInternal).getLimitedUseToken();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function setTokenAutoRefreshEnabled(
|
|
319
|
+
appCheckInstance: AppCheck,
|
|
320
|
+
isAutoRefreshEnabled: boolean,
|
|
321
|
+
): void {
|
|
322
|
+
(appCheckInstance as AppCheckInternal).setTokenAutoRefreshEnabled(isAutoRefreshEnabled);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function onTokenChanged(
|
|
326
|
+
appCheckInstance: AppCheck,
|
|
327
|
+
observer: PartialObserver<AppCheckTokenResult>,
|
|
328
|
+
): Unsubscribe;
|
|
329
|
+
|
|
330
|
+
export function onTokenChanged(
|
|
331
|
+
appCheckInstance: AppCheck,
|
|
332
|
+
onNext: (tokenResult: AppCheckTokenResult) => void,
|
|
333
|
+
onError?: (error: Error) => void,
|
|
334
|
+
onCompletion?: () => void,
|
|
335
|
+
): Unsubscribe;
|
|
336
|
+
|
|
337
|
+
export function onTokenChanged(
|
|
338
|
+
appCheckInstance: AppCheck,
|
|
339
|
+
onNextOrObserver:
|
|
340
|
+
| PartialObserver<AppCheckTokenResult>
|
|
341
|
+
| ((tokenResult: AppCheckTokenResult) => void),
|
|
342
|
+
onError?: (error: Error) => void,
|
|
343
|
+
onCompletion?: () => void,
|
|
344
|
+
): Unsubscribe {
|
|
345
|
+
return (appCheckInstance as AppCheckInternal).onTokenChanged(
|
|
346
|
+
onNextOrObserver,
|
|
347
|
+
onError,
|
|
348
|
+
onCompletion,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export type * from './types/appcheck';
|
|
23
353
|
|
|
24
|
-
|
|
25
|
-
export type { FirebaseAppCheckTypes } from './types/namespaced';
|
|
26
|
-
export * from './namespaced';
|
|
27
|
-
export { default } from './namespaced';
|
|
354
|
+
setReactNativeModule(nativeModuleName, fallBackModule as unknown as Record<string, unknown>);
|
package/lib/types/appcheck.ts
CHANGED
|
@@ -97,6 +97,12 @@ export interface AppCheckTokenResult {
|
|
|
97
97
|
readonly token: string;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Callback invoked when the App Check token changes.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export type AppCheckTokenListener = (token: AppCheckTokenResult) => void;
|
|
105
|
+
|
|
100
106
|
/**
|
|
101
107
|
* An App Check provider. This can be either the built-in reCAPTCHA provider
|
|
102
108
|
* or a custom provider. For more on custom providers, see
|
package/lib/types/internal.ts
CHANGED
|
@@ -157,6 +157,6 @@ export interface RNFBAppCheckModule {
|
|
|
157
157
|
|
|
158
158
|
declare module '@react-native-firebase/app/dist/module/internal/NativeModules' {
|
|
159
159
|
interface ReactNativeFirebaseNativeModules {
|
|
160
|
-
|
|
160
|
+
NativeRNFBTurboAppCheck: RNFBAppCheckModule;
|
|
161
161
|
}
|
|
162
162
|
}
|
package/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '26.1.0';
|