add qr scanner for creator app and android app
This commit is contained in:
1 parent
2bad03c542
commit
be69b94560
18 files changed
+397
-15
No files matched your search
@@ -64,6 +64,7 @@ dependencies {
|
||||
implementation(libs.androidx.constraintlayout)
|
||||
implementation(libs.androidx.viewpager2)
|
||||
implementation(libs.androidx.recyclerview)
|
||||
implementation(libs.zxing.android.embedded)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
@@ -34,6 +39,13 @@
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.QrCaptureActivity"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:stateNotNeeded="true"
|
||||
android:theme="@style/zxing_CaptureTheme"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<service
|
||||
android:name=".tunnel.TunnelVpnService"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||
|
||||
@@ -33,6 +33,12 @@ class AddDestinationSheet : BottomSheetDialogFragment() {
|
||||
val buttonCancel = view.findViewById<Button>(R.id.buttonCancel)
|
||||
val buttonSave = view.findViewById<Button>(R.id.buttonSave)
|
||||
|
||||
val prefillLink = arguments?.getString(ARG_PREFILL_LINK).orEmpty()
|
||||
if (prefillLink.isNotEmpty()) {
|
||||
inputLink.setText(prefillLink)
|
||||
inputName.setText(CallConfig.suggestNameFor(prefillLink))
|
||||
}
|
||||
|
||||
pasteChip.setOnClickListener {
|
||||
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = clipboard.primaryClip
|
||||
@@ -80,8 +86,14 @@ class AddDestinationSheet : BottomSheetDialogFragment() {
|
||||
companion object {
|
||||
const val TAG = "AddDestinationSheet"
|
||||
|
||||
fun show(manager: FragmentManager) {
|
||||
AddDestinationSheet().show(manager, TAG)
|
||||
private const val ARG_PREFILL_LINK = "prefill_link"
|
||||
|
||||
fun show(manager: FragmentManager, prefillLink: String = "") {
|
||||
val sheet = AddDestinationSheet()
|
||||
if (prefillLink.isNotEmpty()) {
|
||||
sheet.arguments = Bundle().apply { putString(ARG_PREFILL_LINK, prefillLink) }
|
||||
}
|
||||
sheet.show(manager, TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,18 @@ import bypass.whitelist.tunnel.CallPlatform
|
||||
import bypass.whitelist.tunnel.TunnelMode
|
||||
import bypass.whitelist.tunnel.VpnStatus
|
||||
import bypass.whitelist.util.Prefs
|
||||
import com.journeyapps.barcodescanner.ScanContract
|
||||
import com.journeyapps.barcodescanner.ScanOptions
|
||||
|
||||
class MainFragment : Fragment(R.layout.fragment_main_screen) {
|
||||
|
||||
private val scanQrLauncher = registerForActivityResult(ScanContract()) { result ->
|
||||
val scanned = result.contents?.trim().orEmpty()
|
||||
if (scanned.isNotEmpty()) {
|
||||
AddDestinationSheet.show(parentFragmentManager, scanned)
|
||||
}
|
||||
}
|
||||
|
||||
private var content: MainFragmentView? = null
|
||||
private var pendingStatus: VpnStatus? = null
|
||||
private var connectedSinceMs: Long = 0L
|
||||
@@ -44,6 +53,16 @@ class MainFragment : Fragment(R.layout.fragment_main_screen) {
|
||||
container.onAddCallClicked = {
|
||||
AddDestinationSheet.show(parentFragmentManager)
|
||||
}
|
||||
container.onScanQrClicked = {
|
||||
scanQrLauncher.launch(
|
||||
ScanOptions()
|
||||
.setDesiredBarcodeFormats(ScanOptions.QR_CODE)
|
||||
.setPrompt(getString(R.string.scan_qr_prompt))
|
||||
.setBeepEnabled(false)
|
||||
.setOrientationLocked(false)
|
||||
.setCaptureActivity(QrCaptureActivity::class.java)
|
||||
)
|
||||
}
|
||||
container.onHeroPressed = {
|
||||
if (isHostConnected() || isHostConnecting()) {
|
||||
host()?.onDisconnectPressed()
|
||||
|
||||
@@ -21,6 +21,7 @@ class MainFragmentView(private val root: View) {
|
||||
|
||||
private val headerSub: TextView = root.findViewById(R.id.headerSub)
|
||||
private val addButton: View = root.findViewById(R.id.headerAddButton)
|
||||
private val scanButton: View = root.findViewById(R.id.headerScanButton)
|
||||
private val hero: View = root.findViewById(R.id.heroButton)
|
||||
private val heroLabel: TextView = root.findViewById(R.id.heroLabel)
|
||||
private val heroPowerIcon: ImageView = root.findViewById(R.id.heroPowerIcon)
|
||||
@@ -43,6 +44,7 @@ class MainFragmentView(private val root: View) {
|
||||
private val statMode: TextView = root.findViewById(R.id.statMode)
|
||||
|
||||
var onAddCallClicked: Callback? = null
|
||||
var onScanQrClicked: Callback? = null
|
||||
var onHeroPressed: Callback? = null
|
||||
var onPingPressed: Callback? = null
|
||||
var onCallSelected: ParamCallback<CallConfig>? = null
|
||||
@@ -58,6 +60,7 @@ class MainFragmentView(private val root: View) {
|
||||
emptyCta.clipToOutline = true
|
||||
pingButton.clipToOutline = true
|
||||
addButton.setOnClickListener { onAddCallClicked?.invoke() }
|
||||
scanButton.setOnClickListener { onScanQrClicked?.invoke() }
|
||||
emptyCta.setOnClickListener { onAddCallClicked?.invoke() }
|
||||
hero.setOnTouchListener { v, event ->
|
||||
when (event.action) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package bypass.whitelist.ui
|
||||
|
||||
import com.journeyapps.barcodescanner.CaptureActivity
|
||||
|
||||
class QrCaptureActivity : CaptureActivity()
|
||||
@@ -0,0 +1,40 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeWidth="1.8"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:pathData="M4,9 L4,6 A2,2 0 0,1 6,4 L9,4" />
|
||||
<path
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeWidth="1.8"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:pathData="M15,4 L18,4 A2,2 0 0,1 20,6 L20,9" />
|
||||
<path
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeWidth="1.8"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:pathData="M20,15 L20,18 A2,2 0 0,1 18,20 L15,20" />
|
||||
<path
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeWidth="1.8"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:pathData="M9,20 L6,20 A2,2 0 0,1 4,18 L4,15" />
|
||||
<path
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeWidth="1.8"
|
||||
android:strokeLineCap="round"
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:pathData="M4,12 L20,12" />
|
||||
</vector>
|
||||
@@ -38,6 +38,18 @@
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/headerScanButton"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/bg_icon_button"
|
||||
android:contentDescription="@string/scan_qr_title"
|
||||
android:padding="8dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_qr"
|
||||
app:tint="@color/ink_2" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/headerAddButton"
|
||||
android:layout_width="36dp"
|
||||
|
||||
@@ -97,6 +97,8 @@
|
||||
|
||||
<string name="paste_from_clipboard">Paste from clipboard</string>
|
||||
<string name="clipboard_empty">Clipboard is empty</string>
|
||||
<string name="scan_qr_title">Scan QR code</string>
|
||||
<string name="scan_qr_prompt">Point the camera at the QR code shown in the creator app</string>
|
||||
|
||||
|
||||
<string name="settings_row_tunnel_mode">Tunnel mode</string>
|
||||
|
||||
@@ -11,6 +11,7 @@ activity = "1.12.4"
|
||||
constraintlayout = "2.2.1"
|
||||
viewpager2 = "1.1.0"
|
||||
recyclerview = "1.3.2"
|
||||
zxing = "4.3.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
@@ -23,6 +24,7 @@ androidx-activity = { group = "androidx.activity", name = "activity", version.re
|
||||
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
androidx-viewpager2 = { group = "androidx.viewpager2", name = "viewpager2", version.ref = "viewpager2" }
|
||||
androidx-recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
|
||||
zxing-android-embedded = { group = "com.journeyapps", name = "zxing-android-embedded", version.ref = "zxing" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
@@ -71,6 +71,10 @@
|
||||
<div class="headless-call-info" id="headlessCallInfoDion">
|
||||
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessDionJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessDionJoinLink" title="Copy"></div>
|
||||
</div>
|
||||
<div class="headless-qr" id="headlessQrWrap" style="display:none">
|
||||
<img id="headlessQr" alt="Join link QR code">
|
||||
<div class="headless-qr-hint">Scan in the Android app</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="logs" id="logsPanel" style="display:none">
|
||||
|
||||
Generated
+211
-12
@@ -8,11 +8,13 @@
|
||||
"name": "whitelist-bypass-creator",
|
||||
"version": "0.3.7",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.7.0"
|
||||
"node-fetch": "^2.7.0",
|
||||
"qrcode": "^1.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"electron": "^33.0.0",
|
||||
"electron-builder": "^25.0.0",
|
||||
"typescript": "^5.6.0"
|
||||
@@ -771,6 +773,16 @@
|
||||
"xmlbuilder": ">=11.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/qrcode": {
|
||||
"version": "1.5.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
|
||||
"integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/responselike": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz",
|
||||
@@ -892,7 +904,6 @@
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -902,7 +913,6 @@
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
@@ -1519,6 +1529,15 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/camelcase": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
|
||||
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
@@ -1665,7 +1684,6 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
@@ -1678,7 +1696,6 @@
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/color-support": {
|
||||
@@ -1911,6 +1928,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/decamelize": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
|
||||
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/decompress-response": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
|
||||
@@ -2036,6 +2062,12 @@
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/dijkstrajs": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
|
||||
"integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dir-compare": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-4.2.0.tgz",
|
||||
@@ -2434,7 +2466,6 @@
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/encoding": {
|
||||
@@ -2658,6 +2689,19 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/find-up": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
|
||||
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"locate-path": "^5.0.0",
|
||||
"path-exists": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/foreground-child": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz",
|
||||
@@ -2783,7 +2827,6 @@
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "6.* || 8.* || >= 10.*"
|
||||
@@ -3264,7 +3307,6 @@
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -3487,6 +3529,18 @@
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
||||
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"p-locate": "^4.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.18.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
|
||||
@@ -4147,6 +4201,33 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/p-locate": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
|
||||
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"p-limit": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/p-locate/node_modules/p-limit": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
|
||||
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"p-try": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/p-map": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz",
|
||||
@@ -4163,6 +4244,15 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/p-try": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
||||
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/package-json-from-dist": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
||||
@@ -4170,6 +4260,15 @@
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0"
|
||||
},
|
||||
"node_modules/path-exists": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
|
||||
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
@@ -4268,6 +4367,15 @@
|
||||
"node": ">=10.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pngjs": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
|
||||
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
@@ -4328,6 +4436,89 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
|
||||
"integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dijkstrajs": "^1.0.1",
|
||||
"pngjs": "^5.0.0",
|
||||
"yargs": "^15.3.1"
|
||||
},
|
||||
"bin": {
|
||||
"qrcode": "bin/qrcode"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode/node_modules/cliui": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
|
||||
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^4.2.0",
|
||||
"strip-ansi": "^6.0.0",
|
||||
"wrap-ansi": "^6.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode/node_modules/wrap-ansi": {
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
||||
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.0.0",
|
||||
"string-width": "^4.1.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode/node_modules/y18n": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
|
||||
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/qrcode/node_modules/yargs": {
|
||||
"version": "15.4.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
|
||||
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cliui": "^6.0.0",
|
||||
"decamelize": "^1.2.0",
|
||||
"find-up": "^4.1.0",
|
||||
"get-caller-file": "^2.0.1",
|
||||
"require-directory": "^2.1.1",
|
||||
"require-main-filename": "^2.0.0",
|
||||
"set-blocking": "^2.0.0",
|
||||
"string-width": "^4.2.0",
|
||||
"which-module": "^2.0.0",
|
||||
"y18n": "^4.0.0",
|
||||
"yargs-parser": "^18.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode/node_modules/yargs-parser": {
|
||||
"version": "18.1.3",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
|
||||
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"camelcase": "^5.0.0",
|
||||
"decamelize": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/quick-lru": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
|
||||
@@ -4417,12 +4608,17 @@
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/require-main-filename": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
|
||||
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/resedit": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/resedit/-/resedit-1.7.2.tgz",
|
||||
@@ -4608,7 +4804,6 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
|
||||
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
@@ -4803,7 +4998,6 @@
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
@@ -4834,7 +5028,6 @@
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
@@ -5168,6 +5361,12 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/which-module": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
|
||||
"integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/wide-align": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
"start:dev": "electron ."
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.7.0"
|
||||
"node-fetch": "^2.7.0",
|
||||
"qrcode": "^1.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"electron": "^33.0.0",
|
||||
"electron-builder": "^25.0.0",
|
||||
"typescript": "^5.6.0"
|
||||
|
||||
@@ -64,6 +64,7 @@ export enum IPC {
|
||||
GET_DION_CREDENTIALS = 'get-dion-credentials',
|
||||
SET_DION_CREDENTIALS = 'set-dion-credentials',
|
||||
EXPORT_COOKIES_ZIP = 'export-cookies-zip',
|
||||
RENDER_QR = 'render-qr',
|
||||
RELAY_LOG = 'relay-log',
|
||||
CREATE_BOT_TAB = 'create-bot-tab',
|
||||
CLOSE_BOT_TAB = 'close-bot-tab',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs/promises';
|
||||
import * as QRCode from 'qrcode';
|
||||
import { TabManager } from './tab-manager';
|
||||
import { BotManager } from '../bot/bot-manager';
|
||||
import { IPC } from '../constants';
|
||||
@@ -17,6 +18,19 @@ export function registerIpcHandlers(tabManager: TabManager): void {
|
||||
return fs.readFile(filePath, 'utf8');
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.RENDER_QR, async (_e, text: string) => {
|
||||
if (!text) return '';
|
||||
try {
|
||||
return await QRCode.toDataURL(text, {
|
||||
errorCorrectionLevel: 'M',
|
||||
margin: 1,
|
||||
scale: 6,
|
||||
});
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.SET_TUNNEL_MODE, (_e, tabId: string, mode: string, platform?: string) => {
|
||||
if (!Object.values(TunnelMode).includes(mode as TunnelMode)) return;
|
||||
tabManager.setTunnelMode(tabId, mode as TunnelMode, platform as Platform | undefined);
|
||||
|
||||
@@ -50,6 +50,9 @@ import { IPC } from '../constants';
|
||||
exportCookiesZip() {
|
||||
return ipcRenderer.invoke(IPC.EXPORT_COOKIES_ZIP);
|
||||
},
|
||||
renderQr(text: string) {
|
||||
return ipcRenderer.invoke(IPC.RENDER_QR, text);
|
||||
},
|
||||
startHeadless(tabId: string, platform: string, args: any) {
|
||||
return ipcRenderer.invoke(IPC.START_HEADLESS, tabId, platform, args);
|
||||
},
|
||||
|
||||
@@ -114,10 +114,14 @@ export function renderContent(tm: RendererTabManager): void {
|
||||
document.getElementById('headlessTurn')!.textContent = callInfo.turn || '';
|
||||
document.getElementById('headlessProtocol')!.textContent = callInfo.protocol || '';
|
||||
}
|
||||
renderJoinQr(callInfo.joinLink || '');
|
||||
} else {
|
||||
renderJoinQr('');
|
||||
}
|
||||
} else {
|
||||
toolbar.style.display = 'flex';
|
||||
headlessInfo.style.display = 'none';
|
||||
renderJoinQr('');
|
||||
const isVK = activeTab.platform === Platform.VK && activeTab.url.includes('vk.ru');
|
||||
const modeSelect = document.getElementById('modeSelect') as HTMLSelectElement;
|
||||
const tunnelLabel = document.getElementById('tunnelLabel') as HTMLElement;
|
||||
@@ -296,6 +300,34 @@ export function exportCookiesZip(): void {
|
||||
});
|
||||
}
|
||||
|
||||
let renderedQrText = '';
|
||||
|
||||
function renderJoinQr(link: string): void {
|
||||
const wrap = document.getElementById('headlessQrWrap') as HTMLElement | null;
|
||||
const image = document.getElementById('headlessQr') as HTMLImageElement | null;
|
||||
if (!wrap || !image) return;
|
||||
if (!link) {
|
||||
renderedQrText = '';
|
||||
wrap.style.display = 'none';
|
||||
image.removeAttribute('src');
|
||||
return;
|
||||
}
|
||||
if (link === renderedQrText) {
|
||||
wrap.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
renderedQrText = link;
|
||||
(window as any).bridge.renderQr(link).then((dataUrl: string) => {
|
||||
if (renderedQrText !== link) return;
|
||||
if (!dataUrl) {
|
||||
wrap.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
image.src = dataUrl;
|
||||
wrap.style.display = 'block';
|
||||
});
|
||||
}
|
||||
|
||||
export function copyToClipboard(text: string): void {
|
||||
navigator.clipboard.writeText(text);
|
||||
}
|
||||
|
||||
@@ -296,6 +296,25 @@ body {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.headless-qr {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.headless-qr img {
|
||||
width: 180px;
|
||||
height: 180px;
|
||||
display: block;
|
||||
background: #fff;
|
||||
padding: 8px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.headless-qr-hint {
|
||||
margin-top: 6px;
|
||||
color: #888;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.headless-link {
|
||||
color: #4fc3f7;
|
||||
cursor: pointer;
|
||||
|
||||
Reference in new issue
Block a user