diff --git a/.github/assets/profiles.xml b/.github/assets/profiles.xml new file mode 100644 index 0000000..b5a3e6c --- /dev/null +++ b/.github/assets/profiles.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.github/workflows/build-new-release.yaml b/.github/workflows/build-new-release.yaml index 4fb4ab3..46e6b3a 100644 --- a/.github/workflows/build-new-release.yaml +++ b/.github/workflows/build-new-release.yaml @@ -6,7 +6,7 @@ on: - 'v*.*.*' env: - TIZEN_STUDIO_VER: 4.5.1 + TIZEN_STUDIO_VER: 5.6 jobs: build: @@ -18,7 +18,7 @@ jobs: - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Install modules and build service + - name: Install modules and build standalone service working-directory: tizenbrew-app/TizenBrew/service run: | sudo apt install -y expect zip @@ -28,6 +28,13 @@ jobs: ncc build service.js rm -r node_modules + - name: Install modules and build updater service + working-directory: tizenbrew-updater/TizenBrewUpdater/service + run: | + npm install + ncc build service.js + rm -r node_modules + - name: Download Tizen-Studio run: | curl -o tizen-installer "https://download.tizen.org/sdk/Installer/tizen-studio_${TIZEN_STUDIO_VER}/web-cli_Tizen_Studio_${TIZEN_STUDIO_VER}_ubuntu-64.bin" @@ -41,50 +48,107 @@ jobs: - name: Prepare Tizen Certificate run: | - ./tizen-studio/tools/ide/bin/tizen certificate -a TizenBrew -p 1234 -c NZ -s Aukland -ct Aukland -o Tizen -n TizenBrew -e reis@tizentube.live -f tizencert - ./tizen-studio/tools/ide/bin/tizen security-profiles add -n TizenBrew -a "${GITHUB_WORKSPACE}/tizen-studio-data/keystore/author/tizencert.p12" -p 1234 + ${{ secrets.TIZEN_AUTHOR_KEY }} | base64 -d > "${GITHUB_WORKSPACE}/tizen-studio-data/keystore/author/tizenbrew-author.p12" ./tizen-studio/tools/ide/bin/tizen cli-config "profiles.path=${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" + cp .github/assets/profiles.xml "${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" + sed -i "s|\$GITHUB_WORKSPACE|${GITHUB_WORKSPACE}|g" "${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" + sed -i "s|\$KEY_PW|${{ secrets.TIZEN_AUTHOR_KEY_PW }}|g" "${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml" chmod 755 "./tizen-studio-data/profile/profiles.xml" - - name: Build + - name: Build TizenBrew working-directory: tizenbrew-app/TizenBrew run: | ${GITHUB_WORKSPACE}/tizen-studio/tools/ide/bin/tizen build-web -e ".*" -e "node_modules/*" -e "package*.json" -e "yarn.lock" - - name: Prepare for password prompt + - name: Build TizenBrew Updater + working-directory: tizenbrew-updater/TizenBrewUpdater run: | - sed -i "s|${GITHUB_WORKSPACE}/tizen-studio-data/keystore/author/tizencert.pwd|1234|g" ${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml - sed -i "s|${GITHUB_WORKSPACE}/tizen-studio-data/tools/certificate-generator/certificates/distributor/tizen-distributor-signer.pwd|tizenpkcs12passfordsigner|g" ${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml - sed -i 's|password=""|password="tizenpkcs12passfordsigner"|g' ${GITHUB_WORKSPACE}/tizen-studio-data/profile/profiles.xml - - - name: Package WGT + ${GITHUB_WORKSPACE}/tizen-studio/tools/ide/bin/tizen build-web -e ".*" -e "node_modules/*" -e "package*.json" -e "yarn.lock" + + - name: Package TizenBrew for Old Tizen + env: + PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} + APP_PATH: tizenbrew-app/TizenBrew + CERT: TizenBrew-Old + run: | + expect ./package.exp + mv tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt tizenbrew-app/TizenBrew/release/TizenBrewStandalone-Old.wgt + + - name: Package TizenBrew for New Tizen + env: + PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} + APP_PATH: tizenbrew-app/TizenBrew + CERT: TizenBrew-New + run: | + expect ./package.exp + mv tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt tizenbrew-app/TizenBrew/release/TizenBrewStandalone-New.wgt + + - name: Package TizenBrew Updater for Old Tizen + env: + PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} + APP_PATH: tizenbrew-updater/TizenBrewUpdater + CERT: TizenBrew-Old + run: | + expect ./package.exp + mv tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater.wgt tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-Old.wgt + + - name: Package TizenBrew Updater for New Tizen + env: + PASSWORD: ${{ secrets.TIZEN_AUTHOR_KEY_PW }} + APP_PATH: tizenbrew-updater/TizenBrewUpdater + CERT: TizenBrew-New run: | expect ./package.exp + mv tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater.wgt tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-New.wgt - - name: Package WGT as USB Demo Package + - name: Package TizenBrew as USB Demo Package run: | - wgt-to-usb tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt + wgt-to-usb tizenbrew-app/TizenBrew/release/TizenBrewStandalone-Old.wgt - - name: Upload Tizen package artifact + - name: Package Updater as USB Demo Package + run: | + wgt-to-usb tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-Old.wgt + + - name: Upload TizenBrew package artifact for Old Tizen + uses: actions/upload-artifact@v2 + with: + name: app-${{ github.sha }}-old.wgt + path: tizenbrew-app/TizenBrew/release/TizenBrewStandalone-Old.wgt + + - name: Upload TizenBrew package artifact for New Tizen uses: actions/upload-artifact@v2 with: - name: app-${{ github.sha }}.wgt - path: tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt + name: app-${{ github.sha }}-new.wgt + path: tizenbrew-app/TizenBrew/release/TizenBrewStandalone-New.wgt - - name: Release Build Result - uses: softprops/action-gh-release@v1 + - name: Upload TizenBrew Updater package artifact for Old Tizen + uses: actions/upload-artifact@v2 with: - tag_name: ${{ env.RELEASE_VERSION }} - files: | - tizenbrew-app/TizenBrew/release/TizenBrewStandalone.wgt + name: updater-${{ github.sha }}-old.wgt + path: tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-Old.wgt + - name: Upload TizenBrew Updater package artifact for New Tizen + uses: actions/upload-artifact@v2 + with: + name: updater-${{ github.sha }}-new.wgt + path: tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-New.wgt + - name: Zip USB Demo Package run: | zip -r tizenbrew-app/TizenBrew/release/TizenBrewStandaloneUSBDemo.zip userwidget/ - - - name: Release USB Demo Package + + - name: Zip Updater USB Demo Package + run: | + zip -r tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdaterUSBDemo.zip userwidget/ + + - name: Release TizenBrew Build Results uses: softprops/action-gh-release@v1 with: tag_name: ${{ env.RELEASE_VERSION }} files: | - tizenbrew-app/TizenBrew/release/TizenBrewStandaloneUSBDemo.zip \ No newline at end of file + tizenbrew-app/TizenBrew/release/TizenBrewStandalone-Old.wgt + tizenbrew-app/TizenBrew/release/TizenBrewStandalone-New.wgt + tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-Old.wgt + tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdater-New.wgt + tizenbrew-app/TizenBrew/release/TizenBrewStandaloneUSBDemo.zip + tizenbrew-updater/TizenBrewUpdater/release/TizenBrewUpdaterUSBDemo.zip \ No newline at end of file diff --git a/docs/MODULES.md b/docs/MODULES.md index 813b161..abcbb32 100644 --- a/docs/MODULES.md +++ b/docs/MODULES.md @@ -1,32 +1,42 @@ -# Making a module +# Creating modules for TizenBrew -There are two types of modules: apps and mods. The modules are normal NPM modules, but they only have files for the app or mods. +There are three types of modules: applications, site modifications and services. The modules itself are normal NPM/Node modules but special. -## Package.json format +## Application Modules -The format is pretty same as a normal package.json file, but with some differences. There are some properties that are required for the module to work. +Application modules are simply web pages without any modifications. They are not installed on the TV, but are served from a server. The module should contain a `package.json` file with the following properties: -`packageType`: The type of the module. Can be `app` or `mods`. Required. +- `packageType`: The type of the module. Should be `app`. +- `appName`: The name of the module (user friendly, like "TizenTube"). +- `appPath`: The path to the index.html file. (like `app/index.html`) +- `keys`: The keys that should be registered using the [TVInputDevice](https://developer.samsung.com/smarttv/develop/api-references/tizen-web-device-api-references/tvinputdevice-api.html) API. -`appName`: The name of the module (user friendly, like "TizenTube"). Required. +## Site Modification Modules -`appPath`: The path to the app folder. Required if `packageType` is `app`. +Site modification modules are basically the same as application modules, but they are used to modify a website. The modifications are basically JavaScript code that is injected into a website. The module should contain a `package.json` file with the following properties: -`websiteURL`: The URL of the website. Required if `packageType` is `mods`. +- `packageType`: The type of the module. Should be `mods` +- `appName`: The name of the module (user friendly, like "TizenTube"). +- `websiteURL`: The URL of the website. +- `main`: The JavaScript file to be injected to the website. +- `keys`: The keys that should be registered using the [TVInputDevice](https://developer.samsung.com/smarttv/develop/api-references/tizen-web-device-api-references/tvinputdevice-api.html) API. +- `tizenAppId`: The Tizen application ID of the application that should be modified. Will be used if it exists. -`main`: The main file of the mods module. Required if `packageType` is `mods`. +## Service Modules -`keys`: The keys that should be registered using the [TVInputDevice](https://developer.samsung.com/smarttv/develop/api-references/tizen-web-device-api-references/tvinputdevice-api.html) API. Not required. +Service modules are ran in the background using Node.js. They can be used to interact with the TV in the background. -Here's an example mods module: -```json -{ - "name": "@foxreis/tizentube", - "appName": "TizenTube", - "version": "1.0.0", - "description": "TizenTube is an ad-free and sponsor-free solution for your favourite streaming website on your Tizen (Samsung) TVs.", - "main": "userScript.js", - "packageType": "mods", - "websiteURL": "https://example.com" -} -``` \ No newline at end of file +Service modules is also an application module, but with a special property called `serviceFile`. This property should contain the path to the main JavaScript file of the service. + +The module should contain a `package.json` file with the following properties: + +- `packageType`: The type of the module. Should be `service`. +- `appName`: The name of the module (user friendly, like "TizenTube"). +- `serviceFile`: The main JavaScript file of the service. +- `appPath`: The path to the index.html file. (like `app/index.html`) +- `keys`: The keys that should be registered using the [TVInputDevice](https://developer.samsung.com/smarttv/develop/api-references/tizen-web-device-api-references/tvinputdevice-api.html) API. + + +## Examples + +See [TizenTube](https://github.com/reisxd/TizenTube) for an example of an site modification module and [Jellyfin-Tizen](https://github.com/GlenLowland/jellyfin-tizen-npm-publish) for an example of an application module. \ No newline at end of file diff --git a/package.exp b/package.exp index 4ec4590..fcabe7c 100644 --- a/package.exp +++ b/package.exp @@ -2,16 +2,8 @@ set timeout -1 -cd tizenbrew-app/TizenBrew +cd $env(APP_PATH) -spawn /home/runner/work/TizenBrew/TizenBrew/tizen-studio/tools/ide/bin/tizen package -t wgt -o ./release -s TizenBrew -- .buildResult - -expect "Author password:" - -send -- "1234\r" - -expect "Yes: (Y), No: (N) ?" - -send -- "N\r" +spawn /home/runner/work/TizenBrew/TizenBrew/tizen-studio/tools/ide/bin/tizen package -t wgt -o ./release -s $env(CERT) -- .buildResult expect eof \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/.settings/.jsdtscope b/tizenbrew-app/TizenBrew/.settings/.jsdtscope index c487c06..8fe9d0c 100644 --- a/tizenbrew-app/TizenBrew/.settings/.jsdtscope +++ b/tizenbrew-app/TizenBrew/.settings/.jsdtscope @@ -1,17 +1,17 @@ - - + - + - + - + + diff --git a/tizenbrew-app/TizenBrew/.tproject b/tizenbrew-app/TizenBrew/.tproject index acbcd01..f9fb40d 100644 --- a/tizenbrew-app/TizenBrew/.tproject +++ b/tizenbrew-app/TizenBrew/.tproject @@ -7,5 +7,6 @@ + diff --git a/tizenbrew-app/TizenBrew/config.xml b/tizenbrew-app/TizenBrew/config.xml index 3c6173f..22a1924 100644 --- a/tizenbrew-app/TizenBrew/config.xml +++ b/tizenbrew-app/TizenBrew/config.xml @@ -1,40 +1,40 @@ - - - - - - - - Reis Can - - - - - - - - - - - - - - - - - - - - - TizenBrewStandalone - - - - - TizenBrewService - TizenBrewService - + + + + + + + + Reis Can + + + + + + + + + + + + + + TizenBrewStandalone + + + + + + + + + + + + + TizenBrewService + TizenBrewService + + \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/index.html b/tizenbrew-app/TizenBrew/index.html index b9962ed..bc64f1f 100644 --- a/tizenbrew-app/TizenBrew/index.html +++ b/tizenbrew-app/TizenBrew/index.html @@ -110,6 +110,10 @@ var packageName = selectedItem.getAttribute("data-packagename"); var appPath = selectedItem.getAttribute("data-appPath"); + + var packageType = selectedItem.getAttribute("data-packageType"); + + var moduleType = selectedItem.getAttribute("data-moduleType"); if (!canLaunchModules) { alert("You can't launch modules while the service hasn't connected yet."); @@ -117,7 +121,10 @@ break; } - window.send({ type: "launch", packageName }); + if (packageType === 'service') { + window.send({ type: "startService", package: { name: packageName, type: moduleType } }); + } + window.send({ type: "launch", package: { name: packageName, type: moduleType }, isTizen3, tvIp: webapis.network.getIp() }); var keys = selectedItem.getAttribute("data-keys"); if (appPath.startsWith("http")) { if (keys.length > 0) { @@ -127,7 +134,9 @@ } } setTimeout(() => { - location.href = appPath; + if (selectedItem.getAttribute('data-moddedTizenApp') === 'false') { + location.href = appPath; + } }, 250); } diff --git a/tizenbrew-app/TizenBrew/js/index.js b/tizenbrew-app/TizenBrew/js/index.js index 50408a9..43e8b24 100644 --- a/tizenbrew-app/TizenBrew/js/index.js +++ b/tizenbrew-app/TizenBrew/js/index.js @@ -2,7 +2,7 @@ window.begin = function() { // Check if IP was set localStorage.setItem("ip", "127.0.0.1"); - if (localStorage.getItem('modules') == null) localStorage.setItem('modules', '[]'); + if (localStorage.getItem('modules') == null) localStorage.setItem('modules', '[{ "name": "@foxreis/tizentube", "type": "npm" }]'); if (localStorage.getItem('failedStartupAttempts') == null) localStorage.setItem('failedStartupAttempts', '0'); connect(); } \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/js/wsClient.js b/tizenbrew-app/TizenBrew/js/wsClient.js index 0754ce9..1b27b1f 100644 --- a/tizenbrew-app/TizenBrew/js/wsClient.js +++ b/tizenbrew-app/TizenBrew/js/wsClient.js @@ -39,6 +39,10 @@ function onMessage(msg) { localStorage.setItem('failedStartupAttempts', '0'); canLaunchModules = message.inDebug.webDebug; send({ type: 'loadModules', modules: JSON.parse(localStorage.getItem('modules')) }); + if (localStorage.getItem('autoLaunchService')) { + send({ type: 'startService', packageName: localStorage.getItem('autoLaunchService') }); + } + send({ type: 'getServiceStatuses' }); } else { send({ type: 'canLaunchInDebug' }); /* @@ -60,7 +64,7 @@ function onMessage(msg) { document.getElementById('appList').innerHTML = ''; for (const module of message.modules) { document.getElementById('appList').innerHTML += ` -
+

${module.appName}

@@ -92,9 +96,10 @@ function onMessage(msg) { document.getElementById('wsText').innerText = 'Connected to server.'; if (canAutoLaunch && localStorage.getItem('autoLaunch')) { - const app = document.querySelector(`[data-packagename="${localStorage.getItem('autoLaunch')}"]`); + const autoLaunch = JSON.parse(localStorage.getItem('autoLaunch')); + const app = document.querySelector(`[data-packagename="${autoLaunch.name}"]`); if (!app) { - showError(`Error: Could not find the module ${localStorage.getItem('autoLaunch')}.`); + showError(`Error: Could not find the module ${autoLaunch.name}.`); return; } else { const appPath = app.getAttribute('data-appPath'); @@ -105,10 +110,24 @@ function onMessage(msg) { tizen.tvinputdevice.registerKey(keys[i]); } } + var packageType = selectedItem.getAttribute("data-packageType"); + + var moduleType = selectedItem.getAttribute("data-moduleType"); + + if (!canLaunchModules) { + alert("You can't launch modules while the service hasn't connected yet."); + + break; + } + if (packageType === 'service') { + send({ type: "startService", package: autoLaunch }); + } setTimeout(() => { - send({ type: 'launch', packageName: localStorage.getItem('autoLaunch') }); - location.href = appPath; + send({ type: 'launch', package: autoLaunch, isTizen3, tvIp: webapis.network.getIp() }); + if (app.getAttribute('data-moddedTizenApp') === 'false') { + location.href = appPath; + } }, 250); } } @@ -128,6 +147,13 @@ function onMessage(msg) { } break; } + case 'serviceStatuses': { + const crashedServices = message.services.filter(service => service.hasCrashed); + if (crashedServices.length > 0) { + showError(`Error: The following services have crashed: ${crashedServices.map(service => service.name).join(', ')}`); + } + break; + } default: { // This should never happen. } diff --git a/tizenbrew-app/TizenBrew/moduleManager.html b/tizenbrew-app/TizenBrew/moduleManager.html index 48a47ce..ffaeb63 100644 --- a/tizenbrew-app/TizenBrew/moduleManager.html +++ b/tizenbrew-app/TizenBrew/moduleManager.html @@ -79,15 +79,16 @@ case 13: shouldIgnore = true; var packageName = selectedItem.getAttribute("data-packagename"); + var packageType = selectedItem.getAttribute("data-packagetype"); if (packageName != null) { var hasConfirmined = confirm(`Do you want to remove ${packageName}?`); if (hasConfirmined) { var modules = JSON.parse(localStorage.getItem("modules")); - var newModules = modules.filter((module) => module != packageName); + var newModules = modules.filter((module) => module.name != packageName && module.type != packageType); localStorage.setItem("modules", JSON.stringify(newModules)); location.reload(); } - } else newModuleDialog(); + } else newModuleDialog(packageType); break; case 404: location.href = "/index.html"; @@ -95,7 +96,11 @@ case 65376: var input = document.getElementById("appName"); var modules = JSON.parse(localStorage.getItem("modules")); - modules.push(input.value); + var type = selectedItem.getAttribute("data-packagetype"); + modules.push({ + name: input.value, + type + }); localStorage.setItem("modules", JSON.stringify(modules)); location.reload(); break; @@ -111,8 +116,8 @@ document.getElementById("appList").innerHTML = ""; for (const module of modules) { document.getElementById("appList").innerHTML += ` -
-

${module}

+
+

${module.name}

`; firstOne = false; @@ -131,8 +136,13 @@

${module}

function addButton(primary) { document.getElementById("appList").innerHTML += ` -
-

Add

+
+

Add NPM Module

+

This is primarily for production and for users.

+
+
+

Add GitHub Module

+

This is primarily for development and for developers.

`; if (primary) { @@ -141,12 +151,12 @@

Add

} } - function newModuleDialog() { + function newModuleDialog(type) { document.getElementById("appList").innerHTML = ""; document.getElementById("appList").innerHTML += ` -
+

Add Module

- +
`; @@ -156,7 +166,10 @@

Add Module

input.focus(); input.onblur = () => { var modules = JSON.parse(localStorage.getItem("modules")); - modules.push(input.value); + modules.push({ + name: input.value, + type + }); localStorage.setItem("modules", JSON.stringify(modules)); location.reload(); }; diff --git a/tizenbrew-app/TizenBrew/service/moduleLoader.js b/tizenbrew-app/TizenBrew/service/moduleLoader.js index 8a2254f..1cf1f41 100644 --- a/tizenbrew-app/TizenBrew/service/moduleLoader.js +++ b/tizenbrew-app/TizenBrew/service/moduleLoader.js @@ -4,34 +4,51 @@ const fetch = require('node-fetch'); function loadModules(moduleList) { const modulePromises = moduleList.map(module => { - return fetch(`https://cdn.jsdelivr.net/npm/${module}/package.json`) + return fetch(`https://cdn.jsdelivr.net/${module.type}/${module.name}/package.json`) .then(res => res.json()) .then(moduleJson => { let moduleData; if (moduleJson.packageType === 'app') { moduleData = { - name: module, + name: module.name, appName: moduleJson.appName, description: moduleJson.description, packageType: moduleJson.packageType, - appPath: `https://unpkg.com/${moduleJson.name}/${moduleJson.appPath}`, - keys: moduleJson.keys || [] + appPath: `http://127.0.0.1:8081/module/${module.type}/${encodeURIComponent(module.name)}/${moduleJson.appPath}`, + keys: moduleJson.keys || [], + moduleType: module.type + }; + } else if (moduleJson.packageType === 'service') { + moduleData = { + name: module.name, + appName: moduleJson.appName, + description: moduleJson.description, + packageType: moduleJson.packageType, + serviceFile: moduleJson.serviceFile, + appPath: `http://127.0.0.1:8081/module/${module.type}/${encodeURIComponent(module.name)}/${moduleJson.appPath}`, + keys: moduleJson.keys || [], + moduleType: module.type }; } else { moduleData = { - name: module, + name: module.name, appName: moduleJson.appName, description: moduleJson.description, appPath: moduleJson.websiteURL, packageType: moduleJson.packageType, mainFile: moduleJson.main, - keys: moduleJson.keys || [] + keys: moduleJson.keys || [], + tizenAppId: moduleJson.tizenAppId, + moduleType: module.type }; } return moduleData; }) .catch(e => { - console.log(`Error loading module ${module}: ${e}`); + return { + appName: module.name, + description: `Unknown module ${module.name}. Please check the module name and try again.` + } }); }); diff --git a/tizenbrew-app/TizenBrew/service/package-lock.json b/tizenbrew-app/TizenBrew/service/package-lock.json index 9854441..295fcef 100644 --- a/tizenbrew-app/TizenBrew/service/package-lock.json +++ b/tizenbrew-app/TizenBrew/service/package-lock.json @@ -6,20 +6,463 @@ "": { "dependencies": { "adbhost": "^0.0.2", + "express": "^4.19.2", "node-fetch": "^2.7.0", "ws": "^4.1.0" } }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/adbhost": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/adbhost/-/adbhost-0.0.2.tgz", "integrity": "sha512-8eF+KUEoqF+OAo6tRnGB6el0uXNZjPWM//QN62UKva+opguPPvt5ZTCWXAaT2cazKM0JKJ2ODhdKrxYlpLT/9Q==" }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, + "node_modules/body-parser": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.2", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.6.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -39,11 +482,250 @@ } } }, + "node_modules/object-inspect": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "dependencies": { + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/tizenbrew-app/TizenBrew/service/package.json b/tizenbrew-app/TizenBrew/service/package.json index 8911265..a9c7112 100644 --- a/tizenbrew-app/TizenBrew/service/package.json +++ b/tizenbrew-app/TizenBrew/service/package.json @@ -1,6 +1,7 @@ { "dependencies": { "adbhost": "^0.0.2", + "express": "^4.19.2", "node-fetch": "^2.7.0", "ws": "^4.1.0" } diff --git a/tizenbrew-app/TizenBrew/service/service.js b/tizenbrew-app/TizenBrew/service/service.js index cf2aa2c..440abe5 100644 --- a/tizenbrew-app/TizenBrew/service/service.js +++ b/tizenbrew-app/TizenBrew/service/service.js @@ -5,22 +5,52 @@ module.exports.onStart = function () { console.log('Service started.'); const adbhost = require('adbhost'); + const express = require('express'); const WebSocket = require('ws'); const startDebugging = require('./debugger.js'); + const fetch = require('node-fetch'); const loadModules = require('./moduleLoader.js'); - const server = new WebSocket.Server({ port: 8081 }); + const startService = require('./serviceLauncher.js'); + const path = require('path'); + const app = express(); + + // HTTP Proxy for modules + app.all('*', (req, res) => { + if (req.url.startsWith('/module/')) { + const splittedUrl = req.url.split('/'); + const moduleType = splittedUrl[2]; + const encodedModuleName = splittedUrl[3]; + const moduleName = decodeURIComponent(encodedModuleName); + fetch(`https://cdn.jsdelivr.net/${moduleType}/${moduleName}/${req.url.replace(`/module/${moduleType}/${encodedModuleName}/`, '')}`) + .then(fetchRes => { + return fetchRes.body.pipe(res); + }) + .then(() => { + res.setHeader('Access-Control-Allow-Origin', '*'); + res.type(path.basename(req.url.replace(`/module/${moduleType}/${encodedModuleName}/`, '')).split('.').slice(-1)[0].split('?')[0]); + }); + } else { + res.send('Hello from TizenBrew Standalone Service!'); + } + }); + + const server = new WebSocket.Server({ server: app.listen(8081) }); let adb; let canLaunchInDebug = null; + fetch('http://127.0.0.1:8001/api/v2/').then(res => res.json()) + .then(json => { + canLaunchInDebug = (json.device.developerIP === '127.0.0.1' || json.device.developerIP === '1.0.0.127') && json.device.developerMode === '1'; + }); + global.inDebug = { tizenDebug: false, webDebug: false }; global.currentClient = null; - createAdbConnection(null, null, true); + global.services = new Map(); - function createAdbConnection(isTizen3, ip, testConnection) { - let timeout = null; + function createAdbConnection(isTizen3, ip, appId) { if (adb) { if (adb._stream !== null || adb._stream !== undefined) { adb._stream.removeAllListeners('connect'); @@ -33,40 +63,22 @@ module.exports.onStart = function () { adb._stream.on('connect', () => { console.log('ADB connection established'); - if (!testConnection) { - //Launch app - const shellCmd = adb.createStream(`shell:0 debug xvvl3S1bvH.TizenBrewStandalone${isTizen3 ? ' 0' : ''}`); - shellCmd.on('data', function dataIncoming(data) { - const dataString = data.toString(); - if (dataString.includes('debug')) { - const port = dataString.substr(dataString.indexOf(':') + 1, 6).replace(' ', ''); - startDebugging(port, adb, ip); - } - }); - } else { - timeout = setTimeout(() => { - canLaunchInDebug = true; - adb._stream.removeAllListeners('close'); - adb._stream.end(); - }, 1000); - - } + //Launch app + const shellCmd = adb.createStream(`shell:0 debug ${appId ? appId : 'xvvl3S1bvH.TizenBrewStandalone'}${isTizen3 ? ' 0' : ''}`); + shellCmd.on('data', function dataIncoming(data) { + const dataString = data.toString(); + if (dataString.includes('debug')) { + const port = dataString.substr(dataString.indexOf(':') + 1, 6).replace(' ', ''); + startDebugging(port, adb, ip); + } + }); }); adb._stream.on('error', (e) => { console.log('ADB connection error. ' + e); - if (testConnection) { - clearTimeout(timeout); - canLaunchInDebug = false; - } }); adb._stream.on('close', () => { console.log('ADB connection closed.'); - clearTimeout(timeout); - if (testConnection) { - clearTimeout(timeout); - canLaunchInDebug = false; - } }); } @@ -87,12 +99,16 @@ module.exports.onStart = function () { break; } case 'canLaunchInDebug': { + fetch('http://127.0.0.1:8001/api/v2/').then(res => res.json()) + .then(json => { + canLaunchInDebug = (json.device.developerIP === '127.0.0.1' || json.device.developerIP === '1.0.0.127') && json.device.developerMode === '1'; + }); ws.send(JSON.stringify({ type: 'canLaunchInDebug', status: canLaunchInDebug })); break; } case 'relaunchInDebug': { setTimeout(() => { - createAdbConnection(message.isTizen3, message.tvIp, false); + createAdbConnection(message.isTizen3, message.tvIp); }, 1000); break; } @@ -103,8 +119,8 @@ module.exports.onStart = function () { break; } case 'launch': { - loadModules([message.packageName]).then(modules => { - const module = modules.find(m => m.name === message.packageName); + loadModules([message.package]).then(modules => { + const module = modules.find(m => m.name === message.package.name); if (!module) { ws.send(JSON.stringify({ type: 'error', message: 'Module not found.' })); return; @@ -112,17 +128,50 @@ module.exports.onStart = function () { if (module.packageType === 'mods') { global.currentModule = { type: 'mods', - path: `https://cdn.jsdelivr.net/npm/${module.name}/${module.mainFile}` + path: `https://cdn.jsdelivr.net/${message.package.type}/${message.package.name}/${module.mainFile}` + } + + if (module.tizenAppId) { + createAdbConnection(message.isTizen3, message.tvIp, module.tizenAppId); } } else { global.currentModule = { type: 'app', - path: `https://unpkg.com/${module.name}/${module.appPath}` + path: `http://127.0.0.1:8081/module/${message.package.type}/${encodeURIComponent(message.package.name)}/${module.appPath}` } } }); break; } + case 'startService': { + loadModules([message.package]).then(modules => { + const module = modules.find(m => m.name === message.package.name); + + if (!module) { + ws.send(JSON.stringify({ type: 'error', message: 'Module not found.' })); + return; + } + + if (global.services.has(message.package.name)) { + if (global.services.get(message.package.name).hasCrashed) { + global.services.delete(message.package.name); + startService(module, message.package.type); + } else ws.send(JSON.stringify({ type: 'error', message: 'Service already running.' })); + } else startService(module, message.package); + }); + break; + } + case 'getServiceStatuses': { + const serviceList = []; + global.services.forEach((key, value) => { + serviceList.push({ + name: key, + hasCrashed: value.hasCrashed + }); + }); + ws.send(JSON.stringify({ type: 'serviceStatuses', services: serviceList })); + break; + } default: { ws.send(JSON.stringify({ type: 'error', message: 'Invalid message type.' })); break; @@ -130,4 +179,4 @@ module.exports.onStart = function () { } }); }); -} +} \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/service/serviceLauncher.js b/tizenbrew-app/TizenBrew/service/serviceLauncher.js new file mode 100644 index 0000000..a458eff --- /dev/null +++ b/tizenbrew-app/TizenBrew/service/serviceLauncher.js @@ -0,0 +1,33 @@ +"use strict"; + +const vm = require('vm'); +const fetch = require('node-fetch'); + +function startService(module, pkg) { + let sandbox = {}; + + Object.getOwnPropertyNames(global).forEach(prop => { + const disAllowed = ['services', 'module', 'global', 'inDebug', 'currentClient', 'currentModule', 'process']; + if (disAllowed.includes(prop)) return; + sandbox[prop] = global[prop]; + }); + + + fetch(`https://cdn.jsdelivr.net/${pkg.type}/${pkg.name}/${module.serviceFile}`) + .then(res => res.text()) + .then(script => { + global.services.set(pkg.name, { + context: vm.createContext(sandbox), + hasCrashed: false + }); + + try { + vm.runInContext(script, global.services.get(pkg.name).context).catch(e => console.error(e)); + } catch (e) { + console.error(e); + global.services.get(pkg.name).hasCrashed = true; + } + }); +} + +module.exports = startService; \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/settings.html b/tizenbrew-app/TizenBrew/settings.html index 1944bd5..de8eb6d 100644 --- a/tizenbrew-app/TizenBrew/settings.html +++ b/tizenbrew-app/TizenBrew/settings.html @@ -32,6 +32,10 @@

Autolaunch Settings

Launch your favorite module automatically when you launch TizenBrew.

+
+

Autolaunch Settings for services

+

Launch your favorite service automatically when you launch TizenBrew.

+
+
+
+

+ + +
+ + + + + + + + \ No newline at end of file diff --git a/tizenbrew-updater/TizenBrewUpdater/js/wsClient.js b/tizenbrew-updater/TizenBrewUpdater/js/wsClient.js new file mode 100644 index 0000000..3e19c2d --- /dev/null +++ b/tizenbrew-updater/TizenBrewUpdater/js/wsClient.js @@ -0,0 +1,124 @@ +"use strict"; + +const isTV = navigator.userAgent.includes('Tizen'); +let isTizen8 = false; +let client; + +window.connect = function() { + try { + client = new WebSocket(`ws://127.0.0.1:8082`); + client.onmessage = onMessage; + client.onopen = onOpen; + client.onerror = () => { + window.location.reload(); + } + } catch (e) { + window.location.reload(); + } + +} + +window.send = (message) => { + client.send(JSON.stringify(message)); +} + +function onMessage(msg) { + const message = JSON.parse(msg.data); + switch (message.type) { + case 'canConnectToDaemon': { + if (message.status === null) { + setTimeout(() => { + send({ type: 'canConnectToDaemon' }); + }, 1000); + break; + } else if (message.status) { + hideError(); + send({ type: 'connectToDaemon' }); + } else { + showError(`Error: Could not connect to the server. Are you sure you changed the Host PC IP to 127.0.0.1? If you have, hold the power button till you see the Samsung logo.`); + } + break; + } + case 'connectedToDaemon': { + isTizen8 = document.getElementById('tizen8').checked; + document.getElementById('wsText').innerText = 'Connected to Daemon'; + try { + if (isTV) { + tizen.application.getAppInfo('xvvl3S1bvH.TizenBrewStandalone'); + send({ type: 'updateAvailable' }); + } else { + send({ type: 'isAppInstalled' }) + } + } catch { + addButtons(false); + } + break; + } + case 'updateAvailable': { + if (message.available) { + addButtons(true); + } else alert('TizenBrew is already up to date.'); + break; + } + case 'isAppInstalled': { + addButtons(message.status); + break; + } + case 'error': { + showError(message.message); + break; + } + case 'message': { + document.getElementById('wsText').innerText = message.msg; + if (message.msg === 'App installed') { + alert('TizenBrew has been installed. You can find TizenBrew by going into the app store and clicking the settings icon.'); + } + break; + } + } +} + +function addButtons(installed) { + document.getElementById('appList').innerHTML = ` +
+

${installed ? 'Update TizenBrew' : 'Install TizenBrew'}

+

${installed ? 'Get access to a newer version of TizenBrew.' : 'Get access to your favorite TizenBrew modules.' }

+
+ ` + + window.selectedItem = document.querySelector(".selected"); + + window.currentRow = selectedItem.parentElement.parentElement; + +} + +function onOpen() { + if (navigator.userAgent.includes('Tizen')) { + send({ type: 'canConnectToDaemon' }); + } else { + // Add TV IP input + document.getElementById('header').innerHTML += ` + + My TV is Tizen 8 or higher (2024+) + ` + document.getElementById('appList').innerHTML = ` +
+

Connect to your TV

+

Enter your TVs IP address above and click here.

+
+ `; + } +} + +window.manageTizenBrew = function(isUpdate) { + /* if (isUpdate) { + const uninstallDialog = confirm('TizenBrew cannot be updated normally, so TizenBrew has to get uninstalled first. This means that your data will be erased!\nAre you sure?'); + if (uninstallDialog) { + send({ type: 'uninstallApp' }); + setTimeout(() => send({ type: 'installApp' }), 2500); + } else alert('Canceled.') + } else { + send({ type: 'installApp' }); + }*/ + send({ type: 'installApp', type: isTizen8 ? 'New' : 'Old' }); +} \ No newline at end of file diff --git a/tizenbrew-updater/TizenBrewUpdater/service/filePush.js b/tizenbrew-updater/TizenBrewUpdater/service/filePush.js new file mode 100644 index 0000000..01857a6 --- /dev/null +++ b/tizenbrew-updater/TizenBrewUpdater/service/filePush.js @@ -0,0 +1,57 @@ +"use strict"; + +const AdbPacket = require('adbhost/lib/packet.js'); +const commands = AdbPacket.commands; + +module.exports = function (adb, path, fileName, data, cb) { + const shell = adb.createStream('sync:'); + setTimeout(() => { + const statBuffer = new Buffer(8); + statBuffer.write('STAT', 0); + statBuffer.writeUInt32LE(path.length, 4); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, statBuffer); + + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, new Buffer(path)) + + const filePath = `${path}/${fileName}`; + const sendBuffer = new Buffer(8); + sendBuffer.writeUInt32LE(0x444E4553, 0); + sendBuffer.writeUInt32LE(filePath.length + 6, 4); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, sendBuffer); + + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, new Buffer(`${filePath},33261`)) + + if (data.length > 1420) { + const chunk = data.slice(0, 1420); + const buffer = new Buffer(8 + chunk.length); + buffer.write('DATA'); + buffer.writeUInt32LE(chunk.length, 4); + chunk.copy(buffer, 8); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, buffer); + for (let i = 1420; i < data.length; i += 1420) { + const chunk = data.slice(i, i + 1420); + const buffer = new Buffer(8 + chunk.length); + buffer.write('DATA'); + buffer.writeUInt32LE(chunk.length, 4); + chunk.copy(buffer, 8); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, buffer); + } + } else { + const buffer = new Buffer(8 + data.length); + buffer.write('DATA'); + buffer.writeUInt32LE(data.length, 4); + data.copy(buffer, 8); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, buffer); + } + + const doneData = new Buffer(8); + doneData.write('DONE'); + doneData.writeUInt32LE(0x15f2b865, 4); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, doneData); + + const quitData = new Buffer(8); + quitData.write('QUIT'); + adb._writePacket(commands.WRTE, shell._localId, shell._remoteId, quitData); + cb(); + }, 1500); +} \ No newline at end of file diff --git a/tizenbrew-updater/TizenBrewUpdater/service/ghApi.js b/tizenbrew-updater/TizenBrewUpdater/service/ghApi.js new file mode 100644 index 0000000..4560395 --- /dev/null +++ b/tizenbrew-updater/TizenBrewUpdater/service/ghApi.js @@ -0,0 +1,26 @@ +"use strict"; + +const fetch = require('node-fetch'); + +function getLatestRelease(type) { + return fetch('https://api.github.com/repos/reisxd/TizenBrew/releases/latest') + .then(res => res.json()) + .then(json => { + const asset = json.assets.find(asset => asset.name === `TizenBrewStandalone-${type}.wgt`); + return asset.browser_download_url; + }); +} + +function getLatestReleaseTag() { + return fetch('https://api.github.com/repos/reisxd/TizenBrew/releases/latest') + .then(res => res.json()) + .then(json => json.tag_name); +} + +function downloadLatestRelease(type) { + return getLatestRelease(type) + .then(url => fetch(url)) + .then(res => res.buffer()) +} + +module.exports = { downloadLatestRelease, getLatestReleaseTag }; \ No newline at end of file diff --git a/tizenbrew-updater/TizenBrewUpdater/service/package-lock.json b/tizenbrew-updater/TizenBrewUpdater/service/package-lock.json new file mode 100644 index 0000000..9854441 --- /dev/null +++ b/tizenbrew-updater/TizenBrewUpdater/service/package-lock.json @@ -0,0 +1,76 @@ +{ + "name": "service", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "adbhost": "^0.0.2", + "node-fetch": "^2.7.0", + "ws": "^4.1.0" + } + }, + "node_modules/adbhost": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/adbhost/-/adbhost-0.0.2.tgz", + "integrity": "sha512-8eF+KUEoqF+OAo6tRnGB6el0uXNZjPWM//QN62UKva+opguPPvt5ZTCWXAaT2cazKM0JKJ2ODhdKrxYlpLT/9Q==" + }, + "node_modules/async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/ws": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz", + "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==", + "dependencies": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0" + } + }, + "node_modules/ws/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } +} diff --git a/tizenbrew-updater/TizenBrewUpdater/service/package.json b/tizenbrew-updater/TizenBrewUpdater/service/package.json new file mode 100644 index 0000000..8911265 --- /dev/null +++ b/tizenbrew-updater/TizenBrewUpdater/service/package.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "adbhost": "^0.0.2", + "node-fetch": "^2.7.0", + "ws": "^4.1.0" + } +} diff --git a/tizenbrew-updater/TizenBrewUpdater/service/service.js b/tizenbrew-updater/TizenBrewUpdater/service/service.js new file mode 100644 index 0000000..f24401b --- /dev/null +++ b/tizenbrew-updater/TizenBrewUpdater/service/service.js @@ -0,0 +1,174 @@ +"use strict"; +// TizenBrew Updater Service + +const isTV = process.platform === 'linux' && process.title.startsWith('/opt/usr/apps/'); +module.exports.onStart = function () { + console.log('Service started.'); + const adbhost = require('adbhost'); + const WebSocket = require('ws'); + const pushFile = require('./filePush.js'); + const ghApi = require('./ghApi.js'); + const server = new WebSocket.Server({ port: 8082 }); + + global.currentClient = null; + let adb; + let canConnectToDaemon = null; + + if (isTV) { + fetch('http://127.0.0.1:8001/api/v2/').then(res => res.json()) + .then(json => { + canConnectToDaemon = (json.device.developerIP === '127.0.0.1' || json.device.developerIP === '1.0.0.127') && json.device.developerMode === '1'; + }); + } + + function createAdbConnection(ip) { + if (adb) { + if (adb._stream !== null || adb._stream !== undefined) { + adb._stream.removeAllListeners('connect'); + adb._stream.removeAllListeners('error'); + adb._stream.removeAllListeners('close'); + } + } + + adb = adbhost.createConnection({ host: ip, port: 26101 }); + + adb._stream.on('connect', () => { + console.log('ADB connection established'); + global.currentClient.send(JSON.stringify({ type: 'connectedToDaemon' })); + }); + + adb._stream.on('error', (e) => { + console.log('ADB connection error. ' + e); + }); + + adb._stream.on('close', () => { + console.log('ADB connection closed.'); + }); + + } + + server.on('connection', (ws) => { + global.currentClient = ws; + ws.on('message', (msg) => { + let message; + try { + message = JSON.parse(msg); + } catch (e) { + return ws.send(JSON.stringify({ type: 'error', message: 'Invalid JSON.' })); + } + + switch (message.type) { + case 'canConnectToDaemon': { + if (isTV) { + fetch('http://127.0.0.1:8001/api/v2/').then(res => res.json()) + .then(json => { + canConnectToDaemon = (json.device.developerIP === '127.0.0.1' || json.device.developerIP === '1.0.0.127') && json.device.developerMode === '1'; + }); + } + ws.send(JSON.stringify({ type: 'canConnectToDaemon', status: canConnectToDaemon })); + break; + } + case 'connectToDaemon': { + createAdbConnection(message.ip); + break; + } + case 'isAppInstalled': { + const stream = adb.createStream('shell:0 vd_applist'); + let appList = ''; + stream.on('data', (data) => { + appList += data.toString(); + + if (appList.includes('spend time')) { + ws.send(JSON.stringify({ type: 'isAppInstalled', status: appList.includes('xvvl3S1bvH.TizenBrewStandalone') })); + } + }); + break; + } + case 'updateAvailable': { + ghApi.getLatestReleaseTag().then((tag) => { + const installedApp = tizen.application.getAppInfo('xvvl3S1bvH.TizenBrewStandalone'); + ws.send(JSON.stringify({ type: 'updateAvailable', available: tag.replace('v', '') !== installedApp.version })); + }); + break; + } + case 'uninstallApp': { + uninstallApp(); + break; + } + case 'installApp': { + let type = null; + if (isTV) { + const tvVersion = Number(tizen.systeminfo.getCapability('http://tizen.org/feature/platform.version').split('.')[0]); + if (tvVersion >= 8) { + type = 'New'; + } else type = 'Old'; + } else type = message.type; + + ghApi.downloadLatestRelease(type).then((data) => { + pushFile(adb, '/home/owner/share/tmp/sdk_tools', 'TizenBrewStandalone.wgt', data, () => installApp()); + }); + break; + } + default: { + ws.send(JSON.stringify({ type: 'error', message: 'Invalid message type.' })); + break; + } + } + }); + }); + + function installApp() { + const stream = adb.createStream('shell:0 vd_appinstall xvvl3S1bvH /home/owner/share/tmp/sdk_tools/TizenBrewStandalone.wgt'); + const installTimeout = setTimeout(() => { + const stream = adb.createStream('shell:0 vd_appinstall xvvl3S1bvH.TizenBrewStandalone /home/owner/share/tmp/sdk_tools/TizenBrewStandalone.wgt'); + const failedTimeout = setTimeout(() => global.currentClient.send(JSON.stringify({ type: 'error', message: 'Could not install app.' })), 2500); + stream.on('data', (data) => { + const string = data.toString(); + if (string.includes('18')) { + clearTimeout(failedTimeout); + } else if (string.includes('failed')) { + clearTimeout(failedTimeout); + global.currentClient.send(JSON.stringify({ type: 'error', message: `Could not install app. Reason: ${string}` })); + } else if (string.includes('100')) { + global.currentClient.send(JSON.stringify({ type: 'message', msg: 'App installed' })); + } + }); + }, 1500); + stream.on('data', (data) => { + const string = data.toString(); + if (string.includes('18')) { + clearTimeout(installTimeout); + } else if (string.includes('failed')) { + clearTimeout(installTimeout); + global.currentClient.send(JSON.stringify({ type: 'error', message: `Could not install app. Reason: ${string}` })); + } else if (string.includes('100')) { + global.currentClient.send(JSON.stringify({ type: 'message', msg: 'App installed' })); + } + }); + } + + function uninstallApp() { + const stream = adb.createStream('shell:0 vd_appuninstall xvvl3S1bvH'); + const uninstallTimeout = setTimeout(() => { + const stream = adb.createStream('shell:0 vd_appuninstall xvvl3S1bvH.TizenBrewStandalone'); + const failedTimeout = setTimeout(() => global.currentClient.send(JSON.stringify({ type: 'error', message: 'Could not uninstall app.' })), 1500); + stream.on('data', (data) => { + outputted = true; + clearTimeout(failedTimeout); + if (data.toString().includes('100')) { + global.currentClient.send(JSON.stringify({ type: 'message', msg: 'App uninstalled' })); + } + }); + }, 1500); + stream.on('data', (data) => { + clearTimeout(uninstallTimeout); + if (data.toString().includes('100')) { + global.currentClient.send(JSON.stringify({ type: 'message', msg: 'App uninstalled' })); + } + }); + } +} + +if (!isTV) { + module.exports.onStart(); +} \ No newline at end of file