react-native-consumet 0.4.3 → 0.6.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/android/build.gradle +1 -0
- package/android/generated/java/com/consumet/NativeConsumetSpec.java +8 -0
- package/android/generated/jni/RNConsumetSpec-generated.cpp +12 -0
- package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI-generated.cpp +14 -0
- package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI.h +18 -0
- package/android/src/main/java/com/consumet/ConsumetModule.kt +63 -38
- package/android/src/main/java/com/consumet/DdosGuardModule.kt +142 -0
- package/ios/generated/RNConsumetSpec/RNConsumetSpec-generated.mm +14 -0
- package/ios/generated/RNConsumetSpec/RNConsumetSpec.h +6 -0
- package/ios/generated/RNConsumetSpecJSI-generated.cpp +14 -0
- package/ios/generated/RNConsumetSpecJSI.h +18 -0
- package/lib/commonjs/NativeConsumet.ts +2 -0
- package/lib/commonjs/index.js +10 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/index.js.map +1 -1
- package/lib/commonjs/models/proxy.js +80 -25
- package/lib/commonjs/models/proxy.js.map +1 -1
- package/lib/commonjs/models/types.js.map +1 -1
- package/lib/commonjs/providers/anime/animekai.js +19 -14
- package/lib/commonjs/providers/anime/animekai.js.map +1 -1
- package/lib/commonjs/providers/anime/animepahe.js +59 -9
- package/lib/commonjs/providers/anime/animepahe.js.map +1 -1
- package/lib/commonjs/providers/anime/zoro.js +26 -19
- package/lib/commonjs/providers/anime/zoro.js.map +1 -1
- package/lib/commonjs/providers/meta/anilist.js +38 -208
- package/lib/commonjs/providers/meta/anilist.js.map +1 -1
- package/lib/commonjs/providers/meta/mal.js +4 -4
- package/lib/commonjs/providers/meta/mal.js.map +1 -1
- package/lib/commonjs/providers/meta/tmdb.js +6 -15
- package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
- package/lib/commonjs/providers/movies/multimovies.js +33 -13
- package/lib/commonjs/providers/movies/multimovies.js.map +1 -1
- package/lib/commonjs/utils/index.js +4 -4
- package/lib/commonjs/utils/utils.js +140 -4
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/module/NativeConsumet.ts +2 -0
- package/lib/module/index.js +6 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/index.js.map +1 -1
- package/lib/module/models/proxy.js +80 -25
- package/lib/module/models/proxy.js.map +1 -1
- package/lib/module/models/types.js.map +1 -1
- package/lib/module/providers/anime/animekai.js +18 -14
- package/lib/module/providers/anime/animekai.js.map +1 -1
- package/lib/module/providers/anime/animepahe.js +60 -10
- package/lib/module/providers/anime/animepahe.js.map +1 -1
- package/lib/module/providers/anime/zoro.js +25 -19
- package/lib/module/providers/anime/zoro.js.map +1 -1
- package/lib/module/providers/meta/anilist.js +39 -209
- package/lib/module/providers/meta/anilist.js.map +1 -1
- package/lib/module/providers/meta/mal.js +5 -5
- package/lib/module/providers/meta/mal.js.map +1 -1
- package/lib/module/providers/meta/tmdb.js +7 -16
- package/lib/module/providers/meta/tmdb.js.map +1 -1
- package/lib/module/providers/movies/multimovies.js +33 -13
- package/lib/module/providers/movies/multimovies.js.map +1 -1
- package/lib/module/utils/index.js +2 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/utils.js +126 -1
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts +4 -0
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +6 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/proxy.d.ts +6 -7
- package/lib/typescript/commonjs/src/models/proxy.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/types.d.ts +4 -1
- package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animekai.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animepahe.d.ts +7 -3
- package/lib/typescript/commonjs/src/providers/anime/animepahe.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/zoro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts +0 -3
- package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multimovies.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/utils.d.ts +15 -1
- package/lib/typescript/commonjs/src/utils/utils.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeConsumet.d.ts +4 -0
- package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +6 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/index.d.ts +2 -2
- package/lib/typescript/module/src/models/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/proxy.d.ts +6 -7
- package/lib/typescript/module/src/models/proxy.d.ts.map +1 -1
- package/lib/typescript/module/src/models/types.d.ts +4 -1
- package/lib/typescript/module/src/models/types.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animekai.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animepahe.d.ts +7 -3
- package/lib/typescript/module/src/providers/anime/animepahe.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/zoro.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/meta/anilist.d.ts +0 -3
- package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/multimovies.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/index.d.ts +2 -2
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/utils.d.ts +15 -1
- package/lib/typescript/module/src/utils/utils.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/NativeConsumet.ts +2 -0
- package/src/index.tsx +5 -3
- package/src/models/index.ts +2 -0
- package/src/models/proxy.ts +80 -30
- package/src/models/types.ts +6 -1
- package/src/providers/anime/animekai.ts +17 -14
- package/src/providers/anime/animepahe.ts +70 -10
- package/src/providers/anime/zoro.ts +25 -20
- package/src/providers/meta/anilist.ts +71 -325
- package/src/providers/meta/mal.ts +5 -5
- package/src/providers/meta/tmdb.ts +7 -16
- package/src/providers/movies/multimovies.ts +28 -19
- package/src/utils/index.ts +2 -2
- package/src/utils/utils.ts +162 -1
package/android/build.gradle
CHANGED
|
@@ -93,6 +93,7 @@ dependencies {
|
|
|
93
93
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
94
94
|
implementation "androidx.annotation:annotation:1.5.0"
|
|
95
95
|
implementation "androidx.webkit:webkit:1.8.0"
|
|
96
|
+
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
react {
|
|
@@ -35,4 +35,12 @@ public abstract class NativeConsumetSpec extends ReactContextBaseJavaModule impl
|
|
|
35
35
|
@ReactMethod
|
|
36
36
|
@DoNotStrip
|
|
37
37
|
public abstract void getSources(String xrax, Promise promise);
|
|
38
|
+
|
|
39
|
+
@ReactMethod
|
|
40
|
+
@DoNotStrip
|
|
41
|
+
public abstract void bypassDdosGuard(String url, Promise promise);
|
|
42
|
+
|
|
43
|
+
@ReactMethod
|
|
44
|
+
@DoNotStrip
|
|
45
|
+
public abstract void getDdosGuardCookiesWithWebView(String url, Promise promise);
|
|
38
46
|
}
|
|
@@ -17,9 +17,21 @@ static facebook::jsi::Value __hostFunction_NativeConsumetSpecJSI_getSources(face
|
|
|
17
17
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getSources", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeConsumetSpecJSI_bypassDdosGuard(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "bypassDdosGuard", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static facebook::jsi::Value __hostFunction_NativeConsumetSpecJSI_getDdosGuardCookiesWithWebView(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
26
|
+
static jmethodID cachedMethodId = nullptr;
|
|
27
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getDdosGuardCookiesWithWebView", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
NativeConsumetSpecJSI::NativeConsumetSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
21
31
|
: JavaTurboModule(params) {
|
|
22
32
|
methodMap_["getSources"] = MethodMetadata {1, __hostFunction_NativeConsumetSpecJSI_getSources};
|
|
33
|
+
methodMap_["bypassDdosGuard"] = MethodMetadata {1, __hostFunction_NativeConsumetSpecJSI_bypassDdosGuard};
|
|
34
|
+
methodMap_["getDdosGuardCookiesWithWebView"] = MethodMetadata {1, __hostFunction_NativeConsumetSpecJSI_getDdosGuardCookiesWithWebView};
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
std::shared_ptr<TurboModule> RNConsumetSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
@@ -17,10 +17,24 @@ static jsi::Value __hostFunction_NativeConsumetCxxSpecJSI_getSources(jsi::Runtim
|
|
|
17
17
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
+
static jsi::Value __hostFunction_NativeConsumetCxxSpecJSI_bypassDdosGuard(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
21
|
+
return static_cast<NativeConsumetCxxSpecJSI *>(&turboModule)->bypassDdosGuard(
|
|
22
|
+
rt,
|
|
23
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
static jsi::Value __hostFunction_NativeConsumetCxxSpecJSI_getDdosGuardCookiesWithWebView(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
27
|
+
return static_cast<NativeConsumetCxxSpecJSI *>(&turboModule)->getDdosGuardCookiesWithWebView(
|
|
28
|
+
rt,
|
|
29
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
20
32
|
|
|
21
33
|
NativeConsumetCxxSpecJSI::NativeConsumetCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
22
34
|
: TurboModule("Consumet", jsInvoker) {
|
|
23
35
|
methodMap_["getSources"] = MethodMetadata {1, __hostFunction_NativeConsumetCxxSpecJSI_getSources};
|
|
36
|
+
methodMap_["bypassDdosGuard"] = MethodMetadata {1, __hostFunction_NativeConsumetCxxSpecJSI_bypassDdosGuard};
|
|
37
|
+
methodMap_["getDdosGuardCookiesWithWebView"] = MethodMetadata {1, __hostFunction_NativeConsumetCxxSpecJSI_getDdosGuardCookiesWithWebView};
|
|
24
38
|
}
|
|
25
39
|
|
|
26
40
|
|
|
@@ -21,6 +21,8 @@ protected:
|
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
virtual jsi::Value getSources(jsi::Runtime &rt, jsi::String xrax) = 0;
|
|
24
|
+
virtual jsi::Value bypassDdosGuard(jsi::Runtime &rt, jsi::String url) = 0;
|
|
25
|
+
virtual jsi::Value getDdosGuardCookiesWithWebView(jsi::Runtime &rt, jsi::String url) = 0;
|
|
24
26
|
|
|
25
27
|
};
|
|
26
28
|
|
|
@@ -59,6 +61,22 @@ private:
|
|
|
59
61
|
return bridging::callFromJs<jsi::Value>(
|
|
60
62
|
rt, &T::getSources, jsInvoker_, instance_, std::move(xrax));
|
|
61
63
|
}
|
|
64
|
+
jsi::Value bypassDdosGuard(jsi::Runtime &rt, jsi::String url) override {
|
|
65
|
+
static_assert(
|
|
66
|
+
bridging::getParameterCount(&T::bypassDdosGuard) == 2,
|
|
67
|
+
"Expected bypassDdosGuard(...) to have 2 parameters");
|
|
68
|
+
|
|
69
|
+
return bridging::callFromJs<jsi::Value>(
|
|
70
|
+
rt, &T::bypassDdosGuard, jsInvoker_, instance_, std::move(url));
|
|
71
|
+
}
|
|
72
|
+
jsi::Value getDdosGuardCookiesWithWebView(jsi::Runtime &rt, jsi::String url) override {
|
|
73
|
+
static_assert(
|
|
74
|
+
bridging::getParameterCount(&T::getDdosGuardCookiesWithWebView) == 2,
|
|
75
|
+
"Expected getDdosGuardCookiesWithWebView(...) to have 2 parameters");
|
|
76
|
+
|
|
77
|
+
return bridging::callFromJs<jsi::Value>(
|
|
78
|
+
rt, &T::getDdosGuardCookiesWithWebView, jsInvoker_, instance_, std::move(url));
|
|
79
|
+
}
|
|
62
80
|
|
|
63
81
|
private:
|
|
64
82
|
friend class NativeConsumetCxxSpec;
|
|
@@ -7,19 +7,22 @@ import android.util.Log
|
|
|
7
7
|
import android.webkit.*
|
|
8
8
|
import com.facebook.react.bridge.Promise
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod
|
|
10
11
|
import com.facebook.react.module.annotations.ReactModule
|
|
11
12
|
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
12
13
|
import java.util.concurrent.CountDownLatch
|
|
13
14
|
import java.util.concurrent.TimeUnit
|
|
14
15
|
|
|
15
16
|
@ReactModule(name = ConsumetModule.NAME)
|
|
16
|
-
class ConsumetModule(private val reactContext: ReactApplicationContext) :
|
|
17
|
+
class ConsumetModule(private val reactContext: ReactApplicationContext) :
|
|
18
|
+
NativeConsumetSpec(reactContext), TurboModule {
|
|
17
19
|
private val handler by lazy { Handler(Looper.getMainLooper()) }
|
|
18
20
|
private val tag by lazy { javaClass.simpleName }
|
|
21
|
+
private val ddosGuardHelper by lazy { DdosGuardHelper(reactContext) }
|
|
19
22
|
|
|
20
23
|
class JsInterface(
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
private val latch: CountDownLatch,
|
|
25
|
+
private val context: ReactApplicationContext
|
|
23
26
|
) {
|
|
24
27
|
var result: String? = null
|
|
25
28
|
|
|
@@ -62,11 +65,13 @@ class ConsumetModule(private val reactContext: ReactApplicationContext) : Native
|
|
|
62
65
|
|
|
63
66
|
webview.addJavascriptInterface(jsi, "jsinterface")
|
|
64
67
|
|
|
65
|
-
webview.webViewClient =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
webview.webViewClient =
|
|
69
|
+
object : WebViewClient() {
|
|
70
|
+
override fun onPageFinished(view: WebView?, url: String?) {
|
|
71
|
+
super.onPageFinished(view, url)
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
val cdnScript =
|
|
74
|
+
"""
|
|
70
75
|
(async function() {
|
|
71
76
|
async function loadScriptWithFallback(url, localFilename) {
|
|
72
77
|
try {
|
|
@@ -87,9 +92,9 @@ class ConsumetModule(private val reactContext: ReactApplicationContext) : Native
|
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
try {
|
|
90
|
-
await loadScriptWithFallback("https://cdn.jsdelivr.net/gh/
|
|
91
|
-
await loadScriptWithFallback("https://cdn.jsdelivr.net/gh/
|
|
92
|
-
await loadScriptWithFallback("https://cdn.jsdelivr.net/gh/
|
|
95
|
+
await loadScriptWithFallback("https://cdn.jsdelivr.net/gh/Kohi-den/extensions-source@main/lib/megacloud-extractor/src/main/assets/crypto-js.js", "crypto-js.js");
|
|
96
|
+
await loadScriptWithFallback("https://cdn.jsdelivr.net/gh/Kohi-den/extensions-source@main/lib/megacloud-extractor/src/main/assets/megacloud.decodedpng.js", "megacloud.decodedpng.js");
|
|
97
|
+
await loadScriptWithFallback("https://cdn.jsdelivr.net/gh/Kohi-den/extensions-source@main/lib/megacloud-extractor/src/main/assets/megacloud.getsrcs.js", "megacloud.getsrcs.js");
|
|
93
98
|
|
|
94
99
|
console.log("Calling getSources...");
|
|
95
100
|
const result = await getSources("${xrax}");
|
|
@@ -101,21 +106,30 @@ class ConsumetModule(private val reactContext: ReactApplicationContext) : Native
|
|
|
101
106
|
})();
|
|
102
107
|
""".trimIndent()
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
view?.evaluateJavascript(cdnScript, null)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
override fun onReceivedError(
|
|
113
|
+
view: WebView?,
|
|
114
|
+
errorCode: Int,
|
|
115
|
+
description: String?,
|
|
116
|
+
failingUrl: String?
|
|
117
|
+
) {
|
|
118
|
+
Log.e(tag, "WebView error: $errorCode - $description @ $failingUrl")
|
|
119
|
+
super.onReceivedError(view, errorCode, description, failingUrl)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
webview.webChromeClient =
|
|
124
|
+
object : WebChromeClient() {
|
|
125
|
+
override fun onConsoleMessage(consoleMessage: ConsoleMessage?): Boolean {
|
|
126
|
+
Log.d(
|
|
127
|
+
tag,
|
|
128
|
+
"Console: [${consoleMessage?.messageLevel()}] ${consoleMessage?.message()}"
|
|
129
|
+
)
|
|
130
|
+
return super.onConsoleMessage(consoleMessage)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
119
133
|
|
|
120
134
|
val headers = mapOf("X-Requested-With" to "org.lineageos.jelly")
|
|
121
135
|
webview.loadUrl("https://megacloud.tv/about", headers)
|
|
@@ -123,24 +137,35 @@ class ConsumetModule(private val reactContext: ReactApplicationContext) : Native
|
|
|
123
137
|
|
|
124
138
|
// Await result or timeout
|
|
125
139
|
Thread {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
val success = latch.await(TIMEOUT_SEC, TimeUnit.SECONDS)
|
|
141
|
+
|
|
142
|
+
handler.post {
|
|
143
|
+
webView?.stopLoading()
|
|
144
|
+
webView?.destroy()
|
|
145
|
+
webView = null
|
|
146
|
+
|
|
147
|
+
if (success && jsi.result != null) {
|
|
148
|
+
promise.resolve(jsi.result)
|
|
149
|
+
} else {
|
|
150
|
+
promise.reject("ERROR", "Failed to get sources or timeout2")
|
|
151
|
+
}
|
|
152
|
+
}
|
|
137
153
|
}
|
|
138
|
-
|
|
139
|
-
}.start()
|
|
154
|
+
.start()
|
|
140
155
|
}
|
|
141
156
|
|
|
142
157
|
companion object {
|
|
143
158
|
const val NAME = "Consumet"
|
|
144
159
|
private const val TIMEOUT_SEC: Long = 90
|
|
145
160
|
}
|
|
161
|
+
|
|
162
|
+
@ReactMethod
|
|
163
|
+
override fun bypassDdosGuard(url: String, promise: Promise) {
|
|
164
|
+
ddosGuardHelper.bypassDdosGuard(url, promise)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@ReactMethod
|
|
168
|
+
override fun getDdosGuardCookiesWithWebView(url: String, promise: Promise) {
|
|
169
|
+
ddosGuardHelper.getDdosGuardCookiesWithWebView(url, promise)
|
|
170
|
+
}
|
|
146
171
|
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
package com.consumet
|
|
2
|
+
|
|
3
|
+
import android.webkit.CookieManager
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
7
|
+
import okhttp3.Cookie
|
|
8
|
+
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull // Updated import
|
|
9
|
+
import okhttp3.OkHttpClient
|
|
10
|
+
import okhttp3.Request
|
|
11
|
+
import java.util.regex.Pattern
|
|
12
|
+
import android.webkit.WebView
|
|
13
|
+
import android.webkit.WebViewClient
|
|
14
|
+
import android.os.Handler
|
|
15
|
+
import android.os.Looper
|
|
16
|
+
|
|
17
|
+
class DdosGuardHelper(private val reactContext: ReactApplicationContext) {
|
|
18
|
+
private val client = OkHttpClient.Builder().build()
|
|
19
|
+
private val cookieManager = CookieManager.getInstance()
|
|
20
|
+
|
|
21
|
+
fun bypassDdosGuard(url: String, promise: Promise) {
|
|
22
|
+
try {
|
|
23
|
+
val httpUrl = url.toHttpUrlOrNull() ?: run {
|
|
24
|
+
promise.reject("ERROR", "Invalid URL")
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
val cookies = cookieManager.getCookie(url)
|
|
29
|
+
val oldCookies = mutableListOf<Cookie>()
|
|
30
|
+
var ddg2Cookie: Cookie? = null
|
|
31
|
+
|
|
32
|
+
if (!cookies.isNullOrEmpty()) {
|
|
33
|
+
cookies.split(";").forEach { cookieStr ->
|
|
34
|
+
Cookie.parse(httpUrl, cookieStr.trim())?.let { cookie ->
|
|
35
|
+
oldCookies.add(cookie)
|
|
36
|
+
if (cookie.name == "__ddg2") {
|
|
37
|
+
ddg2Cookie = cookie
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (ddg2Cookie != null && !ddg2Cookie!!.value.isEmpty()) {
|
|
44
|
+
val result = WritableNativeMap()
|
|
45
|
+
result.putString("cookie", cookiesToHeaderString(oldCookies))
|
|
46
|
+
promise.resolve(result)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Get new cookie
|
|
51
|
+
val newCookie = getNewCookie(httpUrl) ?: run {
|
|
52
|
+
promise.reject("ERROR", "Failed to get DDos-Guard cookie")
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
oldCookies.add(newCookie)
|
|
57
|
+
val newCookieHeader = cookiesToHeaderString(oldCookies)
|
|
58
|
+
|
|
59
|
+
val result = WritableNativeMap()
|
|
60
|
+
result.putString("cookie", newCookieHeader)
|
|
61
|
+
promise.resolve(result)
|
|
62
|
+
} catch (e: Exception) {
|
|
63
|
+
promise.reject("ERROR", e.message, e)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private fun getNewCookie(url: okhttp3.HttpUrl): Cookie? {
|
|
68
|
+
val cookies = cookieManager.getCookie(url.toString())
|
|
69
|
+
val oldCookies = mutableListOf<Cookie>()
|
|
70
|
+
var ddg2Cookie: Cookie? = null
|
|
71
|
+
|
|
72
|
+
if (!cookies.isNullOrEmpty()) {
|
|
73
|
+
cookies.split(";").forEach { cookieStr ->
|
|
74
|
+
Cookie.parse(url, cookieStr.trim())?.let { cookie ->
|
|
75
|
+
oldCookies.add(cookie)
|
|
76
|
+
if (cookie.name == "__ddg2") {
|
|
77
|
+
ddg2Cookie = cookie
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (ddg2Cookie != null && !ddg2Cookie!!.value.isEmpty()) {
|
|
84
|
+
return ddg2Cookie
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
val checkJsRequest = Request.Builder()
|
|
88
|
+
.url("https://check.ddos-guard.net/check.js")
|
|
89
|
+
.get()
|
|
90
|
+
.build()
|
|
91
|
+
|
|
92
|
+
val checkJsResponse = client.newCall(checkJsRequest).execute()
|
|
93
|
+
val checkJsBody = checkJsResponse.body?.string() ?: ""
|
|
94
|
+
checkJsResponse.close()
|
|
95
|
+
|
|
96
|
+
// Extract well-known path from check.js
|
|
97
|
+
val pattern = Pattern.compile("'([^']*)'")
|
|
98
|
+
val matcher = pattern.matcher(checkJsBody)
|
|
99
|
+
if (!matcher.find()) {
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
val wellKnown = matcher.group(1)
|
|
103
|
+
|
|
104
|
+
val checkUrl = "${url.scheme}://${url.host}$wellKnown"
|
|
105
|
+
val checkRequest = Request.Builder()
|
|
106
|
+
.url(checkUrl)
|
|
107
|
+
.get()
|
|
108
|
+
.build()
|
|
109
|
+
|
|
110
|
+
val checkResponse = client.newCall(checkRequest).execute()
|
|
111
|
+
val setCookieHeader = checkResponse.header("set-cookie")
|
|
112
|
+
checkResponse.close()
|
|
113
|
+
|
|
114
|
+
return setCookieHeader?.let { Cookie.parse(url, it) }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private fun cookiesToHeaderString(cookies: List<Cookie>): String {
|
|
118
|
+
return cookies.joinToString("; ") { "${it.name}=${it.value}" }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
fun getDdosGuardCookiesWithWebView(url: String, promise: Promise) {
|
|
122
|
+
Handler(Looper.getMainLooper()).post {
|
|
123
|
+
val webView = WebView(reactContext)
|
|
124
|
+
webView.settings.javaScriptEnabled = true
|
|
125
|
+
webView.settings.domStorageEnabled = true
|
|
126
|
+
|
|
127
|
+
webView.webViewClient = object : WebViewClient() {
|
|
128
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
129
|
+
val cookieManager = android.webkit.CookieManager.getInstance()
|
|
130
|
+
val cookie = cookieManager.getCookie(url)
|
|
131
|
+
if (!cookie.isNullOrEmpty() && cookie.contains("__ddg2")) {
|
|
132
|
+
promise.resolve(cookie)
|
|
133
|
+
} else {
|
|
134
|
+
promise.reject("COOKIE_ERROR", "No __ddg2 cookie received")
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
webView.loadUrl(url)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -30,10 +30,24 @@ namespace facebook::react {
|
|
|
30
30
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getSources", @selector(getSources:resolve:reject:), args, count);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
static facebook::jsi::Value __hostFunction_NativeConsumetSpecJSI_bypassDdosGuard(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
34
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "bypassDdosGuard", @selector(bypassDdosGuard:resolve:reject:), args, count);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static facebook::jsi::Value __hostFunction_NativeConsumetSpecJSI_getDdosGuardCookiesWithWebView(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
38
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getDdosGuardCookiesWithWebView", @selector(getDdosGuardCookiesWithWebView:resolve:reject:), args, count);
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
NativeConsumetSpecJSI::NativeConsumetSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
34
42
|
: ObjCTurboModule(params) {
|
|
35
43
|
|
|
36
44
|
methodMap_["getSources"] = MethodMetadata {1, __hostFunction_NativeConsumetSpecJSI_getSources};
|
|
37
45
|
|
|
46
|
+
|
|
47
|
+
methodMap_["bypassDdosGuard"] = MethodMetadata {1, __hostFunction_NativeConsumetSpecJSI_bypassDdosGuard};
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
methodMap_["getDdosGuardCookiesWithWebView"] = MethodMetadata {1, __hostFunction_NativeConsumetSpecJSI_getDdosGuardCookiesWithWebView};
|
|
51
|
+
|
|
38
52
|
}
|
|
39
53
|
} // namespace facebook::react
|
|
@@ -38,6 +38,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
38
38
|
- (void)getSources:(NSString *)xrax
|
|
39
39
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
40
40
|
reject:(RCTPromiseRejectBlock)reject;
|
|
41
|
+
- (void)bypassDdosGuard:(NSString *)url
|
|
42
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
43
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
44
|
+
- (void)getDdosGuardCookiesWithWebView:(NSString *)url
|
|
45
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
46
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
41
47
|
|
|
42
48
|
@end
|
|
43
49
|
|
|
@@ -17,10 +17,24 @@ static jsi::Value __hostFunction_NativeConsumetCxxSpecJSI_getSources(jsi::Runtim
|
|
|
17
17
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
+
static jsi::Value __hostFunction_NativeConsumetCxxSpecJSI_bypassDdosGuard(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
21
|
+
return static_cast<NativeConsumetCxxSpecJSI *>(&turboModule)->bypassDdosGuard(
|
|
22
|
+
rt,
|
|
23
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
static jsi::Value __hostFunction_NativeConsumetCxxSpecJSI_getDdosGuardCookiesWithWebView(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
27
|
+
return static_cast<NativeConsumetCxxSpecJSI *>(&turboModule)->getDdosGuardCookiesWithWebView(
|
|
28
|
+
rt,
|
|
29
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
20
32
|
|
|
21
33
|
NativeConsumetCxxSpecJSI::NativeConsumetCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
22
34
|
: TurboModule("Consumet", jsInvoker) {
|
|
23
35
|
methodMap_["getSources"] = MethodMetadata {1, __hostFunction_NativeConsumetCxxSpecJSI_getSources};
|
|
36
|
+
methodMap_["bypassDdosGuard"] = MethodMetadata {1, __hostFunction_NativeConsumetCxxSpecJSI_bypassDdosGuard};
|
|
37
|
+
methodMap_["getDdosGuardCookiesWithWebView"] = MethodMetadata {1, __hostFunction_NativeConsumetCxxSpecJSI_getDdosGuardCookiesWithWebView};
|
|
24
38
|
}
|
|
25
39
|
|
|
26
40
|
|
|
@@ -21,6 +21,8 @@ protected:
|
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
virtual jsi::Value getSources(jsi::Runtime &rt, jsi::String xrax) = 0;
|
|
24
|
+
virtual jsi::Value bypassDdosGuard(jsi::Runtime &rt, jsi::String url) = 0;
|
|
25
|
+
virtual jsi::Value getDdosGuardCookiesWithWebView(jsi::Runtime &rt, jsi::String url) = 0;
|
|
24
26
|
|
|
25
27
|
};
|
|
26
28
|
|
|
@@ -59,6 +61,22 @@ private:
|
|
|
59
61
|
return bridging::callFromJs<jsi::Value>(
|
|
60
62
|
rt, &T::getSources, jsInvoker_, instance_, std::move(xrax));
|
|
61
63
|
}
|
|
64
|
+
jsi::Value bypassDdosGuard(jsi::Runtime &rt, jsi::String url) override {
|
|
65
|
+
static_assert(
|
|
66
|
+
bridging::getParameterCount(&T::bypassDdosGuard) == 2,
|
|
67
|
+
"Expected bypassDdosGuard(...) to have 2 parameters");
|
|
68
|
+
|
|
69
|
+
return bridging::callFromJs<jsi::Value>(
|
|
70
|
+
rt, &T::bypassDdosGuard, jsInvoker_, instance_, std::move(url));
|
|
71
|
+
}
|
|
72
|
+
jsi::Value getDdosGuardCookiesWithWebView(jsi::Runtime &rt, jsi::String url) override {
|
|
73
|
+
static_assert(
|
|
74
|
+
bridging::getParameterCount(&T::getDdosGuardCookiesWithWebView) == 2,
|
|
75
|
+
"Expected getDdosGuardCookiesWithWebView(...) to have 2 parameters");
|
|
76
|
+
|
|
77
|
+
return bridging::callFromJs<jsi::Value>(
|
|
78
|
+
rt, &T::getDdosGuardCookiesWithWebView, jsInvoker_, instance_, std::move(url));
|
|
79
|
+
}
|
|
62
80
|
|
|
63
81
|
private:
|
|
64
82
|
friend class NativeConsumetCxxSpec;
|
|
@@ -3,6 +3,8 @@ import { TurboModuleRegistry } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
export interface Spec extends TurboModule {
|
|
5
5
|
getSources(xrax: string): Promise<string>;
|
|
6
|
+
bypassDdosGuard(url: string): Promise<{ cookie: string }>;
|
|
7
|
+
getDdosGuardCookiesWithWebView(url: string): Promise<string>;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export default TurboModuleRegistry.getEnforcing<Spec>('Consumet');
|
package/lib/commonjs/index.js
CHANGED
|
@@ -225,14 +225,20 @@ Object.defineProperty(exports, "Voe", {
|
|
|
225
225
|
return _index2.Voe;
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
|
-
exports.getSources =
|
|
228
|
+
exports.getSources = exports.getDdosGuardCookiesWithWebView = exports.bypassDdosGuard = void 0;
|
|
229
|
+
require("react-native-url-polyfill/auto");
|
|
229
230
|
var _NativeConsumet = _interopRequireDefault(require("./NativeConsumet"));
|
|
230
231
|
var _index = require("./providers/index.js");
|
|
231
232
|
var _providersList = require("./utils/providers-list.js");
|
|
232
233
|
var _index2 = require("./extractors/index.js");
|
|
233
234
|
var _index3 = require("./models/index.js");
|
|
234
235
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
const {
|
|
237
|
+
getSources,
|
|
238
|
+
bypassDdosGuard,
|
|
239
|
+
getDdosGuardCookiesWithWebView
|
|
240
|
+
} = _NativeConsumet.default;
|
|
241
|
+
exports.getDdosGuardCookiesWithWebView = getDdosGuardCookiesWithWebView;
|
|
242
|
+
exports.bypassDdosGuard = bypassDdosGuard;
|
|
243
|
+
exports.getSources = getSources;
|
|
238
244
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["require","_NativeConsumet","_interopRequireDefault","_index","_providersList","_index2","_index3","e","__esModule","default","getSources","bypassDdosGuard","getDdosGuardCookiesWithWebView","Consumet","exports"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AACA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAwBA,IAAAM,OAAA,GAAAN,OAAA;AAuCkB,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAnEX,MAAM;EAAEG,UAAU;EAAEC,eAAe;EAAEC;AAA+B,CAAC,GAAGC,uBAAQ;AAACC,OAAA,CAAAF,8BAAA,GAAAA,8BAAA;AAAAE,OAAA,CAAAH,eAAA,GAAAA,eAAA;AAAAG,OAAA,CAAAJ,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_baseProvider","_interopRequireDefault","require","_baseParser","_animeParser","_bookParser","_comicParser","_videoExtractor","_mangaParser","_lightnovelParser","_movieParser","_newsParser","_types","_typeObjects","e","__esModule","default"],"sourceRoot":"..\\..\\..\\src","sources":["models/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,iBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,YAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,WAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;
|
|
1
|
+
{"version":3,"names":["_baseProvider","_interopRequireDefault","require","_baseParser","_animeParser","_bookParser","_comicParser","_videoExtractor","_mangaParser","_lightnovelParser","_movieParser","_newsParser","_types","_typeObjects","e","__esModule","default"],"sourceRoot":"..\\..\\..\\src","sources":["models/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,iBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,YAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,WAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AA0CA,IAAAW,YAAA,GAAAX,OAAA;AAAyE,SAAAD,uBAAAa,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|