react-native-security-suite 0.6.5 → 0.6.6
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/LICENSE +1 -1
- package/README.md +2 -2
- package/android/build.gradle +45 -28
- package/android/src/main/AndroidManifest.xml +47 -0
- package/android/src/main/{AndroidManifestDeprecated.xml → AndroidManifestNew.xml} +1 -2
- package/android/src/main/java/com/securitysuite/NetworkLogger.java +25 -0
- package/android/src/main/java/com/securitysuite/Sslpinning.java +38 -54
- package/android/src/main/java/com/securitysuite/api/BodyDecoder.kt +35 -0
- package/android/src/main/java/com/securitysuite/api/Chucker.kt +108 -0
- package/android/src/main/java/com/securitysuite/api/ChuckerCollector.kt +129 -0
- package/android/src/main/java/com/securitysuite/api/ChuckerInterceptor.kt +280 -0
- package/android/src/main/java/com/securitysuite/api/ExportFormat.kt +12 -0
- package/android/src/main/java/com/securitysuite/api/RetentionManager.kt +109 -0
- package/android/src/main/java/com/securitysuite/internal/data/entity/HttpHeader.kt +8 -0
- package/android/src/main/java/com/securitysuite/internal/data/entity/HttpTransaction.kt +344 -0
- package/android/src/main/java/com/securitysuite/internal/data/entity/HttpTransactionTuple.kt +62 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/Har.kt +13 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/Log.kt +24 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/Browser.kt +11 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/Creator.kt +11 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/Entry.kt +49 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/Page.kt +14 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/Cache.kt +12 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/Header.kt +17 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/Request.kt +35 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/Response.kt +33 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/Timings.kt +25 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/cache/SecondaryRequest.kt +13 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/request/PostData.kt +20 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/request/QueryString.kt +23 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/request/postdata/Params.kt +13 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/entry/response/Content.kt +30 -0
- package/android/src/main/java/com/securitysuite/internal/data/har/log/page/PageTimings.kt +11 -0
- package/android/src/main/java/com/securitysuite/internal/data/model/DialogData.kt +8 -0
- package/android/src/main/java/com/securitysuite/internal/data/repository/HttpTransactionDatabaseRepository.kt +60 -0
- package/android/src/main/java/com/securitysuite/internal/data/repository/HttpTransactionRepository.kt +33 -0
- package/android/src/main/java/com/securitysuite/internal/data/repository/RepositoryProvider.kt +38 -0
- package/android/src/main/java/com/securitysuite/internal/data/room/ChuckerDatabase.kt +22 -0
- package/android/src/main/java/com/securitysuite/internal/data/room/HttpTransactionDao.kt +53 -0
- package/android/src/main/java/com/securitysuite/internal/support/BitmapUtils.kt +45 -0
- package/android/src/main/java/com/securitysuite/internal/support/CacheDirectoryProvider.kt +11 -0
- package/android/src/main/java/com/securitysuite/internal/support/ChessboardDrawable.kt +76 -0
- package/android/src/main/java/com/securitysuite/internal/support/ChuckerFileProvider.kt +9 -0
- package/android/src/main/java/com/securitysuite/internal/support/ClearDatabaseJobIntentServiceReceiver.kt +14 -0
- package/android/src/main/java/com/securitysuite/internal/support/ClearDatabaseService.kt +32 -0
- package/android/src/main/java/com/securitysuite/internal/support/ContextExt.kt +22 -0
- package/android/src/main/java/com/securitysuite/internal/support/DepletingSource.kt +37 -0
- package/android/src/main/java/com/securitysuite/internal/support/FileFactory.kt +30 -0
- package/android/src/main/java/com/securitysuite/internal/support/FileSaver.kt +41 -0
- package/android/src/main/java/com/securitysuite/internal/support/FormatUtils.kt +117 -0
- package/android/src/main/java/com/securitysuite/internal/support/FormattedUrl.kt +76 -0
- package/android/src/main/java/com/securitysuite/internal/support/HarUtils.kt +28 -0
- package/android/src/main/java/com/securitysuite/internal/support/HttpUrlUtils.kt +11 -0
- package/android/src/main/java/com/securitysuite/internal/support/JsonConverter.kt +19 -0
- package/android/src/main/java/com/securitysuite/internal/support/LimitingSource.kt +22 -0
- package/android/src/main/java/com/securitysuite/internal/support/LiveDataUtils.kt +68 -0
- package/android/src/main/java/com/securitysuite/internal/support/Logger.kt +43 -0
- package/android/src/main/java/com/securitysuite/internal/support/NotificationHelper.kt +149 -0
- package/android/src/main/java/com/securitysuite/internal/support/OkHttpUtils.kt +86 -0
- package/android/src/main/java/com/securitysuite/internal/support/OkioUtils.kt +34 -0
- package/android/src/main/java/com/securitysuite/internal/support/PlainTextDecoder.kt +30 -0
- package/android/src/main/java/com/securitysuite/internal/support/ReportingSink.kt +114 -0
- package/android/src/main/java/com/securitysuite/internal/support/RequestProcessor.kt +102 -0
- package/android/src/main/java/com/securitysuite/internal/support/ResponseProcessor.kt +170 -0
- package/android/src/main/java/com/securitysuite/internal/support/SearchHighlightUtil.kt +80 -0
- package/android/src/main/java/com/securitysuite/internal/support/Sharable.kt +86 -0
- package/android/src/main/java/com/securitysuite/internal/support/SpanTextUtil.kt +202 -0
- package/android/src/main/java/com/securitysuite/internal/support/TeeSource.kt +68 -0
- package/android/src/main/java/com/securitysuite/internal/support/TransactionCurlCommandSharable.kt +46 -0
- package/android/src/main/java/com/securitysuite/internal/support/TransactionDetailsHarSharable.kt +11 -0
- package/android/src/main/java/com/securitysuite/internal/support/TransactionDetailsSharable.kt +73 -0
- package/android/src/main/java/com/securitysuite/internal/support/TransactionDiffCallback.kt +26 -0
- package/android/src/main/java/com/securitysuite/internal/support/TransactionListDetailsSharable.kt +23 -0
- package/android/src/main/java/com/securitysuite/internal/ui/BaseChuckerActivity.kt +35 -0
- package/android/src/main/java/com/securitysuite/internal/ui/MainActivity.kt +375 -0
- package/android/src/main/java/com/securitysuite/internal/ui/MainViewModel.kt +47 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/PayloadType.kt +6 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/ProtocolResources.kt +14 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionActivity.kt +186 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionAdapter.kt +139 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionOverviewFragment.kt +100 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionPagerAdapter.kt +29 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionPayloadAdapter.kt +269 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionPayloadFragment.kt +529 -0
- package/android/src/main/java/com/securitysuite/internal/ui/transaction/TransactionViewModel.kt +69 -0
- package/android/src/main/res/A.java +12 -0
- package/android/src/main/res/color/chucker_fab_background_colour.xml +5 -0
- package/android/src/main/res/drawable/chucker_empty_payload.xml +10 -0
- package/android/src/main/res/drawable/chucker_ic_arrow_down.xml +10 -0
- package/android/src/main/res/drawable/chucker_ic_copy.xml +12 -0
- package/android/src/main/res/drawable/chucker_ic_decoded_url_white.xml +10 -0
- package/android/src/main/res/drawable/chucker_ic_delete_white.xml +9 -0
- package/android/src/main/res/drawable/chucker_ic_encoded_url_white.xml +11 -0
- package/android/src/main/res/drawable/chucker_ic_graphql.xml +27 -0
- package/android/src/main/res/drawable/chucker_ic_http.xml +10 -0
- package/android/src/main/res/drawable/chucker_ic_https.xml +9 -0
- package/android/src/main/res/drawable/chucker_ic_launcher_foreground.xml +14 -0
- package/android/src/main/res/drawable/chucker_ic_save_white.xml +9 -0
- package/android/src/main/res/drawable/chucker_ic_search_white.xml +9 -0
- package/android/src/main/res/drawable/chucker_ic_share_white.xml +9 -0
- package/android/src/main/res/drawable/chucker_ic_transaction_notification.xml +9 -0
- package/android/src/main/res/layout/activity_main.xml +83 -0
- package/android/src/main/res/layout/activity_transaction.xml +48 -0
- package/android/src/main/res/layout/fragment_transaction_overview.xml +365 -0
- package/android/src/main/res/layout/fragment_transaction_payload.xml +132 -0
- package/android/src/main/res/layout/list_item_transaction.xml +122 -0
- package/android/src/main/res/layout/transaction_item_body_line.xml +13 -0
- package/android/src/main/res/layout/transaction_item_copy.xml +19 -0
- package/android/src/main/res/layout/transaction_item_headers.xml +12 -0
- package/android/src/main/res/layout/transaction_item_image.xml +16 -0
- package/android/src/main/res/menu/chucker_transaction.xml +46 -0
- package/android/src/main/res/menu/chucker_transactions_list.xml +41 -0
- package/android/src/main/res/mipmap-anydpi-v26/chucker_ic_launcher.xml +5 -0
- package/android/src/main/res/mipmap-hdpi/chucker_ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/chucker_ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/chucker_ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/chucker_ic_launcher.png +0 -0
- package/android/src/main/res/values/chucker_ic_launcher_background.xml +4 -0
- package/android/src/main/res/values/colors.xml +38 -0
- package/android/src/main/res/values/dimens.xml +10 -0
- package/android/src/main/res/values/public.xml +5 -0
- package/android/src/main/res/values/strings.xml +77 -0
- package/android/src/main/res/values/styles.xml +44 -0
- package/android/src/main/res/values-es/strings.xml +75 -0
- package/android/src/main/res/values-night/colors.xml +32 -0
- package/android/src/main/res/xml/chucker_provider_paths.xml +4 -0
- package/ios/SecuritySuite.swift +0 -2
- package/ios/SslPinning.swift +0 -26
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/index.js +23 -40
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/helpers.js +3 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/index.js +21 -33
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/helpers.d.ts.map +1 -0
- package/lib/typescript/{index.d.ts → commonjs/src/index.d.ts} +1 -6
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/helpers.d.ts +3 -0
- package/lib/typescript/module/src/helpers.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +72 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +70 -43
- package/react-native-security-suite.podspec +23 -15
- package/src/helpers.ts +1 -1
- package/src/index.tsx +5 -18
- package/android/src/main/java/com/securitysuite/AndroidLogger.kt +0 -19
- package/android/src/main/java/com/securitysuite/modifier/Base64Decoder.kt +0 -11
- package/android/src/main/java/com/securitysuite/modifier/BasicAuthorizationHeaderModifier.kt +0 -16
- package/ios/SecuritySuite.xcodeproj/project.pbxproj +0 -293
- package/ios/SecuritySuite.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/SecuritySuite.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/SecuritySuite.xcodeproj/project.xcworkspace/xcuserdata/m.navabifar.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/SecuritySuite.xcodeproj/xcuserdata/m.navabifar.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/lib/typescript/helpers.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- /package/lib/typescript/{helpers.d.ts → commonjs/src/helpers.d.ts} +0 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Mohammad Navabi
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
|
6
6
|
in the Software without restriction, including without limitation the rights
|
package/README.md
CHANGED
|
@@ -14,11 +14,11 @@ You can use any of the following:
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
|
-
yarn add react-native-security-suite
|
|
17
|
+
yarn add react-native-security-suite @react-native-async-storage/async-storage
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
|
-
npm install react-native-security-suite
|
|
21
|
+
npm install react-native-security-suite @react-native-async-storage/async-storage
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Usage
|
package/android/build.gradle
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
apply plugin: "com.android.library"
|
|
2
|
-
apply plugin: "kotlin-android"
|
|
3
|
-
|
|
4
1
|
buildscript {
|
|
5
|
-
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SecuritySuite_kotlinVersion"]
|
|
6
4
|
|
|
7
5
|
repositories {
|
|
8
6
|
google()
|
|
@@ -11,18 +9,27 @@ buildscript {
|
|
|
11
9
|
|
|
12
10
|
dependencies {
|
|
13
11
|
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
13
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
def reactNativeArchitectures() {
|
|
18
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
def isNewArchitectureEnabled() {
|
|
19
23
|
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
apply plugin: "com.android.library"
|
|
23
26
|
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
plugins {
|
|
29
|
+
id "com.android.library"
|
|
30
|
+
id "kotlin-android"
|
|
31
|
+
id "com.google.devtools.ksp" version "1.9.21-1.0.15"
|
|
32
|
+
}
|
|
26
33
|
|
|
27
34
|
if (isNewArchitectureEnabled()) {
|
|
28
35
|
apply plugin: "com.facebook.react"
|
|
@@ -42,20 +49,16 @@ def supportsNamespace() {
|
|
|
42
49
|
def minor = parsed[1].toInteger()
|
|
43
50
|
|
|
44
51
|
// Namespace support was added in 7.3.0
|
|
45
|
-
|
|
46
|
-
return true
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return major >= 8
|
|
52
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
android {
|
|
53
56
|
if (supportsNamespace()) {
|
|
54
57
|
namespace "com.securitysuite"
|
|
55
|
-
|
|
58
|
+
|
|
56
59
|
sourceSets {
|
|
57
60
|
main {
|
|
58
|
-
manifest.srcFile "src/main/
|
|
61
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -65,8 +68,9 @@ android {
|
|
|
65
68
|
defaultConfig {
|
|
66
69
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
67
70
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
68
|
-
|
|
71
|
+
|
|
69
72
|
}
|
|
73
|
+
|
|
70
74
|
buildTypes {
|
|
71
75
|
release {
|
|
72
76
|
minifyEnabled false
|
|
@@ -78,35 +82,48 @@ android {
|
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
compileOptions {
|
|
81
|
-
sourceCompatibility JavaVersion.
|
|
82
|
-
targetCompatibility JavaVersion.
|
|
85
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
86
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
83
87
|
}
|
|
84
88
|
|
|
89
|
+
kotlin {
|
|
90
|
+
jvmToolchain(17)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
buildFeatures {
|
|
94
|
+
dataBinding true
|
|
95
|
+
}
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
repositories {
|
|
88
99
|
mavenCentral()
|
|
89
100
|
google()
|
|
90
|
-
jcenter()
|
|
91
101
|
}
|
|
92
102
|
|
|
93
|
-
def kotlin_version = getExtOrDefault(
|
|
103
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
94
104
|
|
|
95
105
|
dependencies {
|
|
96
106
|
// For < 0.71, this will be from the local maven repo
|
|
97
107
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
98
108
|
//noinspection GradleDynamicVersion
|
|
99
109
|
implementation "com.facebook.react:react-native:+"
|
|
100
|
-
implementation "com.squareup.okhttp3:okhttp:3.0.1"
|
|
101
|
-
implementation "com.scottyab:rootbeer-lib:0.1.0"
|
|
102
|
-
implementation "com.github.mrmike:ok2curl:0.8.0"
|
|
103
110
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
104
|
-
}
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
implementation "com.squareup.okhttp3:okhttp:4.12.0"
|
|
113
|
+
implementation "com.scottyab:rootbeer-lib:0.1.0"
|
|
114
|
+
|
|
115
|
+
implementation "com.google.android.material:material:1.12.0"
|
|
116
|
+
implementation "com.google.code.gson:gson:2.11.0"
|
|
117
|
+
implementation "org.brotli:dec:0.1.2"
|
|
118
|
+
implementation "androidx.databinding:viewbinding:8.7.3"
|
|
119
|
+
implementation "androidx.constraintlayout:constraintlayout:2.2.0"
|
|
120
|
+
implementation "androidx.palette:palette-ktx:1.0.0"
|
|
121
|
+
implementation "androidx.activity:activity-ktx:1.9.3"
|
|
122
|
+
implementation "androidx.fragment:fragment-ktx:1.8.5"
|
|
123
|
+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7"
|
|
124
|
+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.7"
|
|
125
|
+
implementation "androidx.room:room-ktx:2.6.1"
|
|
126
|
+
implementation "androidx.room:room-runtime:2.6.1"
|
|
127
|
+
ksp "androidx.room:room-compiler:2.6.1"
|
|
112
128
|
}
|
|
129
|
+
|
|
@@ -1,2 +1,49 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
1
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
|
|
4
|
+
<queries>
|
|
5
|
+
<intent>
|
|
6
|
+
<action android:name="android.intent.action.CREATE_DOCUMENT" />
|
|
7
|
+
<data android:mimeType="*/*" />
|
|
8
|
+
</intent>
|
|
9
|
+
</queries>
|
|
10
|
+
|
|
11
|
+
<uses-permission
|
|
12
|
+
android:name="android.permission.WAKE_LOCK"
|
|
13
|
+
android:maxSdkVersion="25" />
|
|
14
|
+
|
|
15
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
|
16
|
+
|
|
17
|
+
<application>
|
|
18
|
+
<activity
|
|
19
|
+
android:name="com.securitysuite.internal.ui.MainActivity"
|
|
20
|
+
android:label="@string/chucker_name"
|
|
21
|
+
android:launchMode="singleTask"
|
|
22
|
+
android:taskAffinity="com.securitysuite.task"
|
|
23
|
+
android:theme="@style/Chucker.Theme" />
|
|
24
|
+
|
|
25
|
+
<activity
|
|
26
|
+
android:name="com.securitysuite.internal.ui.transaction.TransactionActivity"
|
|
27
|
+
android:parentActivityName="com.securitysuite.internal.ui.MainActivity"
|
|
28
|
+
android:theme="@style/Chucker.Theme" />
|
|
29
|
+
|
|
30
|
+
<service
|
|
31
|
+
android:name="com.securitysuite.internal.support.ClearDatabaseService"
|
|
32
|
+
android:exported="false"
|
|
33
|
+
android:permission="android.permission.BIND_JOB_SERVICE" />
|
|
34
|
+
|
|
35
|
+
<receiver
|
|
36
|
+
android:name="com.securitysuite.internal.support.ClearDatabaseJobIntentServiceReceiver"
|
|
37
|
+
android:exported="false" />
|
|
38
|
+
|
|
39
|
+
<provider
|
|
40
|
+
android:name="com.securitysuite.internal.support.ChuckerFileProvider"
|
|
41
|
+
android:authorities="${applicationId}.com.securitysuite.provider"
|
|
42
|
+
android:exported="false"
|
|
43
|
+
android:grantUriPermissions="true">
|
|
44
|
+
<meta-data
|
|
45
|
+
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
46
|
+
android:resource="@xml/chucker_provider_paths" />
|
|
47
|
+
</provider>
|
|
48
|
+
</application>
|
|
2
49
|
</manifest>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.securitysuite;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.modules.network.OkHttpClientFactory;
|
|
6
|
+
import com.facebook.react.modules.network.ReactCookieJarContainer;
|
|
7
|
+
import com.securitysuite.api.ChuckerInterceptor;
|
|
8
|
+
|
|
9
|
+
import okhttp3.OkHttpClient;
|
|
10
|
+
public class NetworkLogger implements OkHttpClientFactory {
|
|
11
|
+
private Context context;
|
|
12
|
+
|
|
13
|
+
public NetworkLogger(Context context) {
|
|
14
|
+
this.context = context;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public OkHttpClient createNewNetworkModuleClient() {
|
|
18
|
+
OkHttpClient client = new OkHttpClient.Builder()
|
|
19
|
+
.addInterceptor(new ChuckerInterceptor.Builder(context).build())
|
|
20
|
+
.cookieJar(new ReactCookieJarContainer())
|
|
21
|
+
.build();
|
|
22
|
+
|
|
23
|
+
return client;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
package com.securitysuite;
|
|
2
2
|
|
|
3
|
-
import com.securitysuite.modifier.Base64Decoder;
|
|
4
|
-
import com.securitysuite.modifier.BasicAuthorizationHeaderModifier;
|
|
5
|
-
|
|
6
3
|
import android.content.Context;
|
|
7
4
|
import android.net.Uri;
|
|
8
5
|
|
|
6
|
+
import com.facebook.react.modules.network.OkHttpClientProvider;
|
|
9
7
|
import com.facebook.react.bridge.Arguments;
|
|
10
8
|
import com.facebook.react.bridge.Callback;
|
|
11
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -15,10 +13,6 @@ import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
|
15
13
|
import com.facebook.react.bridge.ReadableType;
|
|
16
14
|
import com.facebook.react.bridge.WritableMap;
|
|
17
15
|
|
|
18
|
-
import com.moczul.ok2curl.modifier.HeaderModifier;
|
|
19
|
-
import com.moczul.ok2curl.Configuration;
|
|
20
|
-
import com.moczul.ok2curl.CurlInterceptor;
|
|
21
|
-
|
|
22
16
|
import org.json.JSONException;
|
|
23
17
|
|
|
24
18
|
import java.io.BufferedOutputStream;
|
|
@@ -32,9 +26,8 @@ import java.net.SocketTimeoutException;
|
|
|
32
26
|
import java.net.URI;
|
|
33
27
|
import java.net.URISyntaxException;
|
|
34
28
|
|
|
35
|
-
import java.
|
|
29
|
+
import java.nio.charset.StandardCharsets;
|
|
36
30
|
import java.util.HashMap;
|
|
37
|
-
import java.util.List;
|
|
38
31
|
import java.util.Map;
|
|
39
32
|
import java.util.concurrent.TimeUnit;
|
|
40
33
|
|
|
@@ -53,46 +46,41 @@ import okio.Buffer;
|
|
|
53
46
|
|
|
54
47
|
public class Sslpinning {
|
|
55
48
|
private ReactApplicationContext context;
|
|
49
|
+
private static String hostname = "";
|
|
56
50
|
private static String content_type = "application/json; charset=utf-8";
|
|
57
51
|
public static MediaType mediaType = MediaType.parse(content_type);
|
|
58
52
|
String responseBodyString = "{}";
|
|
59
|
-
|
|
53
|
+
Callback callback;
|
|
60
54
|
|
|
61
55
|
public Sslpinning(ReactApplicationContext context) {
|
|
62
56
|
this.context = context;
|
|
63
57
|
}
|
|
64
58
|
|
|
65
59
|
public void fetch(String url, final ReadableMap options, SecretKey sharedKey, Callback callback) {
|
|
60
|
+
this.callback = callback;
|
|
61
|
+
|
|
66
62
|
if (!isValidUrl(url)) {
|
|
67
63
|
callback.invoke(null, "url is invalid!");
|
|
68
64
|
return;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
|
-
String hostname;
|
|
72
67
|
try {
|
|
73
|
-
hostname = getHostname(url);
|
|
68
|
+
this.hostname = getHostname(url);
|
|
74
69
|
} catch (URISyntaxException e) {
|
|
75
|
-
hostname = url;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (!options.hasKey("certificates")) {
|
|
79
|
-
callback.invoke(null, "certificates is required!");
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
ReadableArray hashes = options.getArray("certificates");
|
|
84
|
-
if (hashes == null || hashes.size() == 0) {
|
|
85
|
-
callback.invoke(null, "certificates is empty!");
|
|
86
|
-
return;
|
|
70
|
+
this.hostname = url;
|
|
87
71
|
}
|
|
88
72
|
|
|
89
73
|
try {
|
|
90
|
-
|
|
91
|
-
OkHttpClient client = getClient(options, certificatePinner);
|
|
74
|
+
OkHttpClient client = getClient(options);
|
|
92
75
|
|
|
93
76
|
Headers header = setHeader(options);
|
|
94
|
-
RequestBody requestBody = setBody(context, options);
|
|
95
77
|
String method = getMethod(options);
|
|
78
|
+
RequestBody requestBody = setBody(options);
|
|
79
|
+
|
|
80
|
+
if (!method.equals("GET") && requestBody == null) {
|
|
81
|
+
this.callback.invoke(null, "For " + method + " method body option is Required!");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
96
84
|
|
|
97
85
|
// JWS handler
|
|
98
86
|
String jwsHeader = "";
|
|
@@ -129,11 +117,10 @@ public class Sslpinning {
|
|
|
129
117
|
int responseCode = response.code();
|
|
130
118
|
|
|
131
119
|
byte[] bytes = response.body().bytes();
|
|
132
|
-
responseBodyString = new String(bytes,
|
|
120
|
+
responseBodyString = new String(bytes, StandardCharsets.UTF_8);
|
|
133
121
|
|
|
134
122
|
output.putInt("status", responseCode);
|
|
135
123
|
output.putString("url", request.url().toString());
|
|
136
|
-
output.putString("curl", curl.getCurl());
|
|
137
124
|
|
|
138
125
|
// response time
|
|
139
126
|
long tx = response.sentRequestAtMillis();
|
|
@@ -162,44 +149,37 @@ public class Sslpinning {
|
|
|
162
149
|
}
|
|
163
150
|
}
|
|
164
151
|
|
|
165
|
-
private CertificatePinner getCertificatePinner(
|
|
152
|
+
private CertificatePinner getCertificatePinner(ReadableMap options) {
|
|
166
153
|
CertificatePinner.Builder certificatePinner = new CertificatePinner.Builder();
|
|
167
154
|
|
|
168
155
|
ReadableArray hashes = options.getArray("certificates");
|
|
169
156
|
for (int i = 0; i < hashes.size(); i++) {
|
|
170
|
-
certificatePinner.add(hostname, "sha256/" + hashes.getString(i).replaceAll("sha256/", ""));
|
|
157
|
+
certificatePinner.add(this.hostname, "sha256/" + hashes.getString(i).replaceAll("sha256/", ""));
|
|
171
158
|
}
|
|
172
159
|
|
|
173
160
|
return certificatePinner.build();
|
|
174
161
|
}
|
|
175
162
|
|
|
176
|
-
private OkHttpClient getClient(ReadableMap options
|
|
177
|
-
|
|
163
|
+
private OkHttpClient getClient(ReadableMap options) throws JSONException {
|
|
164
|
+
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
|
165
|
+
|
|
166
|
+
if (options.hasKey("certificates")) {
|
|
167
|
+
CertificatePinner certificatePinner = getCertificatePinner(options);
|
|
168
|
+
builder.certificatePinner(certificatePinner);
|
|
169
|
+
}
|
|
178
170
|
|
|
179
171
|
if (options.hasKey("timeout")) {
|
|
180
172
|
int timeout = options.getInt("timeout");
|
|
181
|
-
|
|
182
|
-
.connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
|
173
|
+
builder.connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
|
183
174
|
.readTimeout(timeout, TimeUnit.MILLISECONDS)
|
|
184
|
-
.writeTimeout(timeout, TimeUnit.MILLISECONDS)
|
|
185
|
-
.certificatePinner(certificatePinner)
|
|
186
|
-
.addInterceptor(curlInterceptor)
|
|
187
|
-
.build();
|
|
188
|
-
} else {
|
|
189
|
-
return new OkHttpClient.Builder()
|
|
190
|
-
.certificatePinner(certificatePinner)
|
|
191
|
-
.build();
|
|
175
|
+
.writeTimeout(timeout, TimeUnit.MILLISECONDS);
|
|
192
176
|
}
|
|
193
|
-
}
|
|
194
177
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
headerModifiers.add(modifier);
|
|
199
|
-
Configuration config = new Configuration(headerModifiers);
|
|
200
|
-
CurlInterceptor curlInterceptor = new CurlInterceptor(curl = new AndroidLogger(), config);
|
|
178
|
+
if (options.hasKey("loggerIsEnabled") && options.getBoolean("loggerIsEnabled")) {
|
|
179
|
+
OkHttpClientProvider.setOkHttpClientFactory(new NetworkLogger(context));
|
|
180
|
+
}
|
|
201
181
|
|
|
202
|
-
return
|
|
182
|
+
return builder.build();
|
|
203
183
|
}
|
|
204
184
|
|
|
205
185
|
private static String getHostname(String url) throws URISyntaxException {
|
|
@@ -267,12 +247,13 @@ public class Sslpinning {
|
|
|
267
247
|
return value.hasKey("type") && (value.hasKey("uri") || value.hasKey("path"));
|
|
268
248
|
}
|
|
269
249
|
|
|
270
|
-
private RequestBody setBody(
|
|
250
|
+
private RequestBody setBody(ReadableMap options) {
|
|
251
|
+
RequestBody body = null;
|
|
252
|
+
|
|
271
253
|
if (!options.hasKey("body")) {
|
|
272
|
-
return
|
|
254
|
+
return body;
|
|
273
255
|
}
|
|
274
256
|
|
|
275
|
-
RequestBody body = null;
|
|
276
257
|
ReadableType bodyType = options.getType("body");
|
|
277
258
|
switch (bodyType) {
|
|
278
259
|
case String:
|
|
@@ -285,9 +266,12 @@ public class Sslpinning {
|
|
|
285
266
|
body = getBody(formData);
|
|
286
267
|
} else if (bodyMap.hasKey("_parts")) {
|
|
287
268
|
body = getBody(bodyMap);
|
|
269
|
+
} else {
|
|
270
|
+
body = RequestBody.create(mediaType, bodyMap.toString());
|
|
288
271
|
}
|
|
289
272
|
break;
|
|
290
273
|
}
|
|
274
|
+
|
|
291
275
|
return body;
|
|
292
276
|
}
|
|
293
277
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package com.securitysuite.api
|
|
2
|
+
|
|
3
|
+
import okhttp3.Request
|
|
4
|
+
import okhttp3.Response
|
|
5
|
+
import okio.ByteString
|
|
6
|
+
import okio.IOException
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Decodes HTTP request and response bodies to human–readable texts.
|
|
10
|
+
*/
|
|
11
|
+
public interface BodyDecoder {
|
|
12
|
+
/**
|
|
13
|
+
* Returns a text representation of [body] that will be displayed in Chucker UI transaction,
|
|
14
|
+
* or `null` if [request] cannot be handled by this decoder. [Body][body] is no longer than
|
|
15
|
+
* [max content length][ChuckerInterceptor.Builder.maxContentLength] and is guaranteed to be
|
|
16
|
+
* uncompressed even if [request] has gzip or br header.
|
|
17
|
+
*/
|
|
18
|
+
@Throws(IOException::class)
|
|
19
|
+
public fun decodeRequest(
|
|
20
|
+
request: Request,
|
|
21
|
+
body: ByteString,
|
|
22
|
+
): String?
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns a text representation of [body] that will be displayed in Chucker UI transaction,
|
|
26
|
+
* or `null` if [response] cannot be handled by this decoder. [Body][body] is no longer than
|
|
27
|
+
* [max content length][ChuckerInterceptor.Builder.maxContentLength] and is guaranteed to be
|
|
28
|
+
* uncompressed even if [response] has gzip or br header.
|
|
29
|
+
*/
|
|
30
|
+
@Throws(IOException::class)
|
|
31
|
+
public fun decodeResponse(
|
|
32
|
+
response: Response,
|
|
33
|
+
body: ByteString,
|
|
34
|
+
): String?
|
|
35
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package com.securitysuite.api
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.content.pm.ShortcutInfo
|
|
6
|
+
import android.content.pm.ShortcutManager
|
|
7
|
+
import android.graphics.drawable.Icon
|
|
8
|
+
import android.os.Build
|
|
9
|
+
import android.util.Log
|
|
10
|
+
import androidx.core.content.getSystemService
|
|
11
|
+
import com.securitysuite.R
|
|
12
|
+
import com.securitysuite.internal.support.Logger
|
|
13
|
+
import com.securitysuite.internal.support.NotificationHelper
|
|
14
|
+
import com.securitysuite.internal.ui.MainActivity
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Chucker methods and utilities to interact with the library.
|
|
18
|
+
*/
|
|
19
|
+
public object Chucker {
|
|
20
|
+
private const val SHORTCUT_ID = "chuckerShortcutId"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Keep track of latest show notifications value from ChuckerCollector.
|
|
24
|
+
*/
|
|
25
|
+
internal var showNotifications: Boolean = true
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Check if this instance is the operation one or no-op.
|
|
29
|
+
* @return `true` if this is the operation instance.
|
|
30
|
+
*/
|
|
31
|
+
@Suppress("MayBeConst ") // https://github.com/ChuckerTeam/chucker/pull/169#discussion_r362341353
|
|
32
|
+
public val isOp: Boolean = true
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get an Intent to launch the Chucker UI directly.
|
|
36
|
+
* @param context An Android [Context].
|
|
37
|
+
* @return An Intent for the main Chucker Activity that can be started with [Context.startActivity].
|
|
38
|
+
*/
|
|
39
|
+
@JvmStatic
|
|
40
|
+
public fun getLaunchIntent(context: Context): Intent {
|
|
41
|
+
return Intent(context, MainActivity::class.java)
|
|
42
|
+
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a shortcut to launch Chucker UI.
|
|
47
|
+
* @param context An Android [Context].
|
|
48
|
+
*/
|
|
49
|
+
internal fun createShortcut(context: Context) {
|
|
50
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
val shortcutManager = context.getSystemService<ShortcutManager>() ?: return
|
|
55
|
+
if (shortcutManager.dynamicShortcuts.any { it.id == SHORTCUT_ID }) {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
val shortcut =
|
|
60
|
+
ShortcutInfo.Builder(context, SHORTCUT_ID)
|
|
61
|
+
.setShortLabel(context.getString(R.string.chucker_shortcut_label))
|
|
62
|
+
.setLongLabel(context.getString(R.string.chucker_shortcut_label))
|
|
63
|
+
.setIcon(Icon.createWithResource(context, R.mipmap.chucker_ic_launcher))
|
|
64
|
+
.setIntent(getLaunchIntent(context).setAction(Intent.ACTION_VIEW))
|
|
65
|
+
.build()
|
|
66
|
+
try {
|
|
67
|
+
shortcutManager.addDynamicShortcuts(listOf(shortcut))
|
|
68
|
+
} catch (e: IllegalArgumentException) {
|
|
69
|
+
Logger.warn("ShortcutManager addDynamicShortcuts failed ", e)
|
|
70
|
+
} catch (e: IllegalStateException) {
|
|
71
|
+
Logger.warn("ShortcutManager addDynamicShortcuts failed ", e)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Dismisses all previous Chucker notifications.
|
|
77
|
+
*/
|
|
78
|
+
@JvmStatic
|
|
79
|
+
public fun dismissNotifications(context: Context) {
|
|
80
|
+
NotificationHelper(context).dismissNotifications()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
internal var logger: Logger =
|
|
84
|
+
object : Logger {
|
|
85
|
+
val TAG = "Chucker"
|
|
86
|
+
|
|
87
|
+
override fun info(
|
|
88
|
+
message: String,
|
|
89
|
+
throwable: Throwable?,
|
|
90
|
+
) {
|
|
91
|
+
Log.i(TAG, message, throwable)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
override fun warn(
|
|
95
|
+
message: String,
|
|
96
|
+
throwable: Throwable?,
|
|
97
|
+
) {
|
|
98
|
+
Log.w(TAG, message, throwable)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun error(
|
|
102
|
+
message: String,
|
|
103
|
+
throwable: Throwable?,
|
|
104
|
+
) {
|
|
105
|
+
Log.e(TAG, message, throwable)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|