iobroker.eos-admin 8.0.0 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEXOWATT_EOS_BUILD_INFO.json +7 -6
- package/NEXOWATT_EOS_PREBUILT_MANIFEST.json +195 -107
- package/START_HERE_8.0.1.md +36 -0
- package/START_HERE_8.0.2.md +41 -0
- package/adminWww/.vite/manifest.json +278 -278
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +333 -329
- package/adminWww/assets/{AccessTime-Dpa6PKHY.js → AccessTime-5f47qrw7.js} +1 -1
- package/adminWww/assets/{AceEditor-DTzNaeVy.js → AceEditor-CJ-_Ev2E.js} +1 -1
- package/adminWww/assets/{AdapterUpdateDialog-B3y8RL_5.js → AdapterUpdateDialog-QwlPbETd.js} +3 -3
- package/adminWww/assets/Adapters-gKngfaOu.js +7 -0
- package/adminWww/assets/{AdminUtils-DDT_kD8H.js → AdminUtils-CopxRJZ2.js} +1 -1
- package/adminWww/assets/{Apps-C8LE9l6Z.js → Apps-BKnx1gzD.js} +1 -1
- package/adminWww/assets/{Book-QmHxDaHb.js → Book-DrhneQH0.js} +1 -1
- package/adminWww/assets/{Cached-f77QQBQD.js → Cached-XJmxLN4E.js} +1 -1
- package/adminWww/assets/{Computer-DFIUq-fL.js → Computer-DDMBRY5r.js} +1 -1
- package/adminWww/assets/{Config-BZDUILCW.js → Config-BwTa1LdH.js} +1 -1
- package/adminWww/assets/{ConfigManager-CFuOc_kb.js → ConfigManager-DYwC4yq9.js} +1 -1
- package/adminWww/assets/{CustomModal-B8vdCRn1.js → CustomModal-DjI4oCb8.js} +1 -1
- package/adminWww/assets/{CustomTab-DSPqif6P.js → CustomTab-_HYUrXsZ.js} +1 -1
- package/adminWww/assets/{DeleteForever-BnEM-6_v.js → DeleteForever-Caoe64_y.js} +1 -1
- package/adminWww/assets/EasyMode-CCRqFtQq.js +1 -0
- package/adminWww/assets/Enums-BTurn3-x.js +92 -0
- package/adminWww/assets/{Extension-DU1jqvic.js → Extension-D-tNJv4S.js} +1 -1
- package/adminWww/assets/{Fields-DnckPMA8.js → Fields-C2Bn4V04.js} +1 -1
- package/adminWww/assets/{Files-CwUHx0pF.js → Files-XdmhxGOR.js} +1 -1
- package/adminWww/assets/Hosts-DiTMe9fw.js +120 -0
- package/adminWww/assets/{InfoOutlined-l86Si1qa.js → InfoOutlined-DIGDQvu6.js} +1 -1
- package/adminWww/assets/Instances-DA6FIgRs.js +4 -0
- package/adminWww/assets/Intro-CJpwLg8Q.js +2 -0
- package/adminWww/assets/{KeyboardArrowRight-zZUJhG9e.js → KeyboardArrowRight-DVPBjTKi.js} +1 -1
- package/adminWww/assets/Logs-CA0mEMlO.js +2 -0
- package/adminWww/assets/{MoreHoriz-CR2kD-dc.js → MoreHoriz-BYaCptH0.js} +1 -1
- package/adminWww/assets/Objects-B2IC3Bce.js +301 -0
- package/adminWww/assets/{Overview-WwP6FjK-.js → Overview-HG8fAMFM.js} +2 -2
- package/adminWww/assets/{Pageview-DBITLOzI.js → Pageview-DFHddrKX.js} +1 -1
- package/adminWww/assets/{PersonOff-ANdO5Nu4.js → PersonOff-BwYQLD1M.js} +1 -1
- package/adminWww/assets/{PushPinOutlined-DvxsqPHo.js → PushPinOutlined-CEBeTmNm.js} +1 -1
- package/adminWww/assets/Remove-BPxvNccW.js +1 -0
- package/adminWww/assets/{Schedule-BMMrgd7j.js → Schedule-BQlh1nhQ.js} +1 -1
- package/adminWww/assets/{Star-DNdm064z.js → Star-ChMjBwLn.js} +1 -1
- package/adminWww/assets/State-UGfoS6qW.js +1 -0
- package/adminWww/assets/Storage-DrC3j-wf.js +1 -0
- package/adminWww/assets/{TextSnippet-Bywi1YuG.js → TextSnippet-BQ4TSmvS.js} +1 -1
- package/adminWww/assets/{Timeline-IQCnSLiw.js → Timeline-CEyldmz2.js} +1 -1
- package/adminWww/assets/{Timer-Be9yF62g.js → Timer-I0twtyWh.js} +1 -1
- package/adminWww/assets/{UnfoldMore-Du7-8wYn.js → UnfoldMore-_DDSfPKk.js} +1 -1
- package/adminWww/assets/{Usb-Ca47vqRv.js → Usb-Dwk7qdYu.js} +1 -1
- package/adminWww/assets/{UsedResources-CMTzFOX3.js → UsedResources-B6HWeXGX.js} +2 -2
- package/adminWww/assets/Users-DFeYuC5y.js +1 -0
- package/adminWww/assets/{ViewCompact-C3SC0jFF.js → ViewCompact-BbfomOIi.js} +1 -1
- package/adminWww/assets/ViewList-1pB5VinA.js +1 -0
- package/adminWww/assets/{ViewSidebar-kHvah-XS.js → ViewSidebar-DdedDirX.js} +1 -1
- package/adminWww/assets/{VpnKey-iMA7KrB-.js → VpnKey-o8QeqmnU.js} +1 -1
- package/adminWww/assets/{WifiTethering-Da8nW7Do.js → WifiTethering-Cp63fmkC.js} +1 -1
- package/adminWww/assets/{_virtual_mf-localSharedImportMap___mfe_internal__iobroker_admin__mf_owner__1-CpelrCgN.js → _virtual_mf-localSharedImportMap___mfe_internal__iobroker_admin__mf_owner__1-uaKFfE5p.js} +1 -1
- package/adminWww/assets/{bootstrap-Bs4TZ7iA.js → bootstrap-DSDOwKWU.js} +33 -33
- package/adminWww/assets/{date-fns-Bpgjk9P-.js → date-fns-ukillHs-.js} +1 -1
- package/adminWww/assets/helpers-CDcY0YJ-.js +1 -0
- package/adminWww/assets/{hostInit-2xIZYDSq.js → hostInit-Cd61hJHh.js} +1 -1
- package/adminWww/assets/{icons-material-BLgrEUSv.js → icons-material-Dms1APQk.js} +1 -1
- package/adminWww/assets/{index-BZifaJHi.js → index-D6uhIclX.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-Pe6-VnD2.js → installSVGRenderer-BR-zIijZ.js} +1 -1
- package/adminWww/assets/{lib-CE1B3iHH.js → lib-BZRGBDoe.js} +2 -2
- package/adminWww/assets/{loadShare-eager-CRNcc8D7.js → loadShare-eager-BpwDZfDr.js} +93 -93
- package/adminWww/assets/{mf-entry-bootstrap-0-a6a54377.js → mf-entry-bootstrap-0-2d631020.js} +3 -3
- package/adminWww/assets/{pendingShares-CuQbFsaK.js → pendingShares-D1Vr_qYv.js} +2 -2
- package/adminWww/assets/{sentry-B4uGc7ut.js → sentry-BFzW-2KQ.js} +1 -1
- package/adminWww/assets/{setYear-DurmWw03.js → setYear-DhVdgUBF.js} +1 -1
- package/adminWww/css/nexowatt-native-shell.css +72 -0
- package/adminWww/index.html +21 -21
- package/adminWww/js/eos-license-link.js +9 -16
- package/adminWww/js/nexowatt-native-shell.js +2 -2
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/mf-stats.json +1 -1
- package/adminWww/{remoteEntry-eos-8.0.0.js → remoteEntry-eos-8.0.2.js} +2 -2
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosSessionSecurity.js +12 -4
- package/build/lib/eosSessionSecurity.js.map +1 -1
- package/build/lib/vendor/webserver/LICENSE +21 -0
- package/build/lib/vendor/webserver/README.md +506 -0
- package/build/lib/vendor/webserver/build/index.d.ts +9 -0
- package/build/lib/vendor/webserver/build/index.js +42 -0
- package/build/lib/vendor/webserver/build/index.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/acmeChallenge.d.ts +65 -0
- package/build/lib/vendor/webserver/build/lib/acmeChallenge.js +149 -0
- package/build/lib/vendor/webserver/build/lib/acmeChallenge.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/certificateManager.d.ts +60 -0
- package/build/lib/vendor/webserver/build/lib/certificateManager.js +128 -0
- package/build/lib/vendor/webserver/build/lib/certificateManager.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/http2Compat.d.ts +21 -0
- package/build/lib/vendor/webserver/build/lib/http2Compat.js +109 -0
- package/build/lib/vendor/webserver/build/lib/http2Compat.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-authcode.d.ts +167 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-authcode.js +619 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-authcode.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-clients.d.ts +92 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-clients.js +230 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-clients.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-model.d.ts +84 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-model.js +388 -0
- package/build/lib/vendor/webserver/build/lib/oauth2-model.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/oauth2.d.ts +75 -0
- package/build/lib/vendor/webserver/build/lib/oauth2.js +625 -0
- package/build/lib/vendor/webserver/build/lib/oauth2.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/securityChecker.d.ts +6 -0
- package/build/lib/vendor/webserver/build/lib/securityChecker.js +96 -0
- package/build/lib/vendor/webserver/build/lib/securityChecker.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/usedResources.d.ts +62 -0
- package/build/lib/vendor/webserver/build/lib/usedResources.js +231 -0
- package/build/lib/vendor/webserver/build/lib/usedResources.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/utils.d.ts +35 -0
- package/build/lib/vendor/webserver/build/lib/utils.js +110 -0
- package/build/lib/vendor/webserver/build/lib/utils.js.map +1 -0
- package/build/lib/vendor/webserver/build/lib/webServer.d.ts +164 -0
- package/build/lib/vendor/webserver/build/lib/webServer.js +454 -0
- package/build/lib/vendor/webserver/build/lib/webServer.js.map +1 -0
- package/build/lib/vendor/webserver/package.json +63 -0
- package/build/lib/web.js +26 -6
- package/build/lib/web.js.map +1 -1
- package/docs/ADMIN8_MIGRATION_8.0.0_DE.md +4 -0
- package/docs/cra/CRA_IEC_GAP_ANALYSIS_2026-09-30.md +10 -0
- package/docs/security/admin8-2026-11-04/development-1.log +4 -4
- package/docs/security/admin8-2026-11-04/development-2.log +275 -233
- package/docs/security/admin8-2026-11-05/copy-update/evidence-sha256.json +0 -5
- package/docs/security/admin8-2026-11-05/login-fix/BACKEND_DIAGNOSE_DE.md +48 -0
- package/docs/security/admin8-2026-11-05/login-fix/REPORT_DE.md +47 -0
- package/docs/security/admin8-2026-11-05/login-fix/REVIEW_DE.md +7 -0
- package/docs/security/admin8-2026-11-05/login-fix/controller-adapter-api.ts.txt +122 -0
- package/docs/security/admin8-2026-11-05/login-fix/controller-file-view.ts.txt +75 -0
- package/docs/security/admin8-2026-11-05/login-fix/controller-redis-view.ts.txt +471 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/LICENSE-webserver-3.4.0 +21 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/REPORT_DE.md +41 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/evidence-sha256.json +116 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/http-consumer-check.cjs +58 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/README_DE.md +9 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/REJECTED-webserver-3.4.0-eos-oauth.provenance.json +263 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/REJECTED-webserver-3.4.0-eos-oauth.tgz +0 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/admission.log +16 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-audit-stderr.log +1 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-audit.json +22 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-fixture-1.0.0.tgz +0 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-fixture-package.json +11 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-npm10-package-lock.json +387 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-npm11-package-lock.json +387 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/evidence-sha256.json +85 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/http-consumer-npm10-node22.json +11 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/http-consumer-npm11-node24.json +11 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/local-tests.json +38 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/tests-node22.log +168 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/tests-node24.log +36 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/source-vendor-tests-node22.log +224 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/source-vendor-tests-node24.log +42 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/source-vendor-tests.json +31 -0
- package/docs/security/admin8-2026-11-05/login-fix/dependency/webserver-3.4.0-upstream.tgz +0 -0
- package/docs/security/admin8-2026-11-05/login-fix/eos-session-8.0.0.js.txt +385 -0
- package/docs/security/admin8-2026-11-05/login-fix/evidence-sha256.json +59 -0
- package/docs/security/admin8-2026-11-05/login-fix/path-budget.json +6 -0
- package/docs/security/admin8-2026-11-05/login-fix/provenance.json +51 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/admission.log +21 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/archive-scan.json +13 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/artifacts.log +6 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/backend-build.log +5 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/consumer-package-lock.json +3258 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/copy-update-journal.json +165 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/development.log +365 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/frontend-build.log +149 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-audit.json +22 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-audit.stderr +2 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-final-install-node22.log +9 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node22.json +15 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node22.stderr +2 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node24.json +15 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node24.stderr +0 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/inventory.log +8 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/npm-pack-final.json +7809 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/npm-pack-final.stderr +6 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/overlay-final-publish-node22.json +10213 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/overlay-final-publish-node22.stderr +282 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/pipeline.json +72 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/seal.log +6 -0
- package/docs/security/admin8-2026-11-05/login-fix/release/vendor-final-review-node24.log +18 -0
- package/docs/security/admin8-2026-11-05/login-fix/reproduce.cjs +79 -0
- package/docs/security/admin8-2026-11-05/login-fix/reproduction.json +80 -0
- package/docs/security/admin8-2026-11-05/login-fix/upstream-LICENSE.txt +22 -0
- package/docs/security/admin8-2026-11-05/login-fix/validation.json +85 -0
- package/docs/security/admin8-2026-11-05/system-fix/BACKEND_ROLE_REVIEW_DE.md +79 -0
- package/docs/security/admin8-2026-11-05/system-fix/NAVIGATION_DE.md +30 -0
- package/docs/security/admin8-2026-11-05/system-fix/REPORT_DE.md +51 -0
- package/docs/security/admin8-2026-11-05/system-fix/REVIEW_DE.md +65 -0
- package/docs/security/admin8-2026-11-05/system-fix/SCOPE_DE.md +21 -0
- package/docs/security/admin8-2026-11-05/system-fix/SYSTEM_DE.md +44 -0
- package/docs/security/admin8-2026-11-05/system-fix/archive-scan.json +12 -0
- package/docs/security/admin8-2026-11-05/system-fix/browser/README.md +46 -0
- package/docs/security/admin8-2026-11-05/system-fix/browser/integrity.json +16 -0
- package/docs/security/admin8-2026-11-05/system-fix/browser/system-browser-result.json +3607 -0
- package/docs/security/admin8-2026-11-05/system-fix/browser/system-browser.cjs +221 -0
- package/docs/security/admin8-2026-11-05/system-fix/browser/system-fixture.cjs +60 -0
- package/docs/security/admin8-2026-11-05/system-fix/evidence-sha256.json +49 -0
- package/docs/security/admin8-2026-11-05/system-fix/license-ui-tests-node22.log +80 -0
- package/docs/security/admin8-2026-11-05/system-fix/license-ui-tests-node24.log +19 -0
- package/docs/security/admin8-2026-11-05/system-fix/navigation/lint.log +0 -0
- package/docs/security/admin8-2026-11-05/system-fix/navigation/node22-tests.log +56 -0
- package/docs/security/admin8-2026-11-05/system-fix/navigation/node24-tests.log +15 -0
- package/docs/security/admin8-2026-11-05/system-fix/navigation/source-sha256.json +11 -0
- package/docs/security/admin8-2026-11-05/system-fix/path-budget.json +7 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/artifacts.log +6 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/audit-root.json +22 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/audit-root.stderr +1 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/backend-build.log +5 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/clean.log +6 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/consumer-audit.json +22 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/consumer-audit.stderr +2 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/consumer-install.log +4 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/consumer-package-lock.json +3258 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/development.log +392 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/frontend-build.log +149 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/http-node22.json +15 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/http-node24.json +15 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/inventory.log +8 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/overlay-journal.json +452 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/overlay-publish.log +10790 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/overlay-validation.json +12 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/pack.json +8104 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/pack.stderr +6 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/retired-801.json +68 -0
- package/docs/security/admin8-2026-11-05/system-fix/release/seal.log +6 -0
- package/docs/security/admin8-2026-11-05/system-fix/review-tests.log +30 -0
- package/docs/security/admin8-2026-11-05/system-fix/role-context-before.log +86 -0
- package/docs/security/admin8-2026-11-05/system-fix/role-context-lint.log +0 -0
- package/docs/security/admin8-2026-11-05/system-fix/role-context-node22.log +44 -0
- package/docs/security/admin8-2026-11-05/system-fix/role-context-test.log +13 -0
- package/docs/security/admin8-2026-11-05/system-fix/validation.json +90 -0
- package/docs/third-party/admin8/NOTICE-PROVENANCE.json +3 -3
- package/io-package.json +13 -15
- package/package.json +10 -4
- package/release-manifests/admin8-development-validation.json +136 -43
- package/reports/security/artifact-inventory.json +822 -587
- package/reports/security/inventory-summary.json +39 -17
- package/reports/security/sbom-backend-lock.cdx.json +108 -111
- package/reports/security/sbom-frontend-lock.cdx.json +5 -5
- package/reports/security/source-runtime-manifest.json +553 -163
- package/tools/nexowatt-admin8-development-check.cjs +8 -1
- package/tools/nexowatt-artifact-inventory.cjs +8 -1
- package/tools/nexowatt-installer-ems-selftest.cjs +1 -1
- package/tools/nexowatt-lock-provenance-check.cjs +8 -3
- package/tools/nexowatt-repair-lock-metadata.cjs +3 -3
- package/tools/nexowatt-role-security-selftest.cjs +2 -2
- package/tools/nexowatt-security-inventory.cjs +22 -1
- package/tools/nexowatt-user-area-selftest.cjs +1 -1
- package/tools/nexowatt-v7109-clean-core-selftest.cjs +1 -1
- package/tools/nexowatt-vendored-webserver.cjs +69 -0
- package/tools/vendor/eos-retired-release-files.json +268 -1
- package/tools/vendor/webserver-3.4.0-source.provenance.json +244 -0
- package/adminWww/assets/Adapters-BDxfhfGe.js +0 -7
- package/adminWww/assets/EasyMode-TwIN5yxu.js +0 -1
- package/adminWww/assets/Enums-CSzSzWm7.js +0 -92
- package/adminWww/assets/Hosts-QkyuASJy.js +0 -120
- package/adminWww/assets/Instances-BaWBemTT.js +0 -4
- package/adminWww/assets/Intro-DsfrPrWv.js +0 -2
- package/adminWww/assets/Logs-Cngy2Opt.js +0 -2
- package/adminWww/assets/Objects-DY8KS7zK.js +0 -301
- package/adminWww/assets/Remove-DplJatnC.js +0 -1
- package/adminWww/assets/State-vP1o2BCL.js +0 -1
- package/adminWww/assets/Storage-COo2RkS1.js +0 -1
- package/adminWww/assets/Users-BjTGOjzL.js +0 -1
- package/adminWww/assets/ViewList-DuKCnBnc.js +0 -1
- package/adminWww/assets/helpers-DBoACUHw.js +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkPublicIP = checkPublicIP;
|
|
7
|
+
const node_http_1 = __importDefault(require("node:http"));
|
|
8
|
+
const node_https_1 = __importDefault(require("node:https"));
|
|
9
|
+
const node_url_1 = require("node:url");
|
|
10
|
+
function _getPublicIP() {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
node_https_1.default
|
|
13
|
+
.get('https://ip.iobroker.in', res => {
|
|
14
|
+
const data = [];
|
|
15
|
+
res.on('data', chunk => data.push(chunk));
|
|
16
|
+
res.on('end', () => resolve(Buffer.concat(data).toString()));
|
|
17
|
+
})
|
|
18
|
+
.on('error', err => reject(new Error(err.message)));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function _checkURL(url, pattern, fullCompare) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const oldState = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
24
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
25
|
+
const urlParsed = new node_url_1.URL(url);
|
|
26
|
+
const options = {
|
|
27
|
+
host: urlParsed.hostname, // server uses this
|
|
28
|
+
port: urlParsed.port, // server uses this
|
|
29
|
+
method: 'GET', // client uses this
|
|
30
|
+
path: urlParsed.pathname, // client uses this
|
|
31
|
+
timeout: 2000, // timeout in 2 seconds if the server does not respond in time
|
|
32
|
+
};
|
|
33
|
+
const req = (url.startsWith('https') ? node_https_1.default : node_http_1.default).get(options, res => {
|
|
34
|
+
const data = [];
|
|
35
|
+
res.on('data', (chunk) => data.push(chunk));
|
|
36
|
+
res.on('end', () => {
|
|
37
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = oldState;
|
|
38
|
+
if (res.statusCode === 200) {
|
|
39
|
+
if (pattern) {
|
|
40
|
+
const file = Buffer.concat(data).toString();
|
|
41
|
+
if ((fullCompare && file === pattern) || file.includes(pattern)) {
|
|
42
|
+
return reject(new Error(`The URL "${url}" is reachable from internet without any protection!`));
|
|
43
|
+
}
|
|
44
|
+
return resolve(null);
|
|
45
|
+
}
|
|
46
|
+
reject(new Error(`The URL "${url}" is reachable from internet without any protection!`));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
resolve(null);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
req.on('timeout', () => {
|
|
54
|
+
req.destroy();
|
|
55
|
+
resolve(null);
|
|
56
|
+
});
|
|
57
|
+
req.on('error', () => {
|
|
58
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = oldState;
|
|
59
|
+
resolve(null);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Checks the public IP address of the server and tries to connect to it.
|
|
65
|
+
* Throws error if a connection is possible.
|
|
66
|
+
*/
|
|
67
|
+
async function checkPublicIP(port, pattern, customPath) {
|
|
68
|
+
if (typeof port === 'string') {
|
|
69
|
+
port = parseInt(port, 10);
|
|
70
|
+
}
|
|
71
|
+
let publicIP;
|
|
72
|
+
// we check the public ip address of the server
|
|
73
|
+
try {
|
|
74
|
+
publicIP = await _getPublicIP();
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
// Ignore. We just don't know the public IP
|
|
78
|
+
}
|
|
79
|
+
if (customPath && customPath[0] !== '/') {
|
|
80
|
+
customPath = `/${customPath}`;
|
|
81
|
+
}
|
|
82
|
+
if (publicIP) {
|
|
83
|
+
// check http://publicIP:port
|
|
84
|
+
await _checkURL(`http://${publicIP}:${port}${customPath}`, pattern, !!customPath);
|
|
85
|
+
// check https://publicIP:port
|
|
86
|
+
await _checkURL(`https://${publicIP}:${port}${customPath}`, pattern, !!customPath);
|
|
87
|
+
// check http://publicIP:80
|
|
88
|
+
if (port !== 80) {
|
|
89
|
+
await _checkURL(`http://${publicIP}:80${customPath}`, pattern, !!customPath);
|
|
90
|
+
}
|
|
91
|
+
if (port !== 443) {
|
|
92
|
+
await _checkURL(`https://${publicIP}:443${customPath}`, pattern, !!customPath);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=securityChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"securityChecker.js","sourceRoot":"","sources":["../../src/lib/securityChecker.ts"],"names":[],"mappings":";;;;;AAyGS,sCAAa;AAzGtB,0DAA6B;AAC7B,4DAA+B;AAC/B,uCAA+B;AAE/B,SAAS,YAAY;IACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,oBAAK;aACA,GAAG,CAAC,wBAAwB,EAAE,GAAG,CAAC,EAAE;YACjC,MAAM,IAAI,GAAiB,EAAE,CAAC;YAE9B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,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UAAmB;IACrF,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,QAAQ,CAAC;IACb,+CAA+C;IAC/C,IAAI,CAAC;QACD,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,CAAC;IAAC,WAAM,CAAC;QACL,2CAA2C;IAC/C,CAAC;IACD,IAAI,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACtC,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACX,6BAA6B;QAC7B,MAAM,SAAS,CAAC,UAAU,QAAQ,IAAI,IAAI,GAAG,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QAElF,8BAA8B;QAC9B,MAAM,SAAS,CAAC,WAAW,QAAQ,IAAI,IAAI,GAAG,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QAEnF,2BAA2B;QAC3B,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YACd,MAAM,SAAS,CAAC,UAAU,QAAQ,MAAM,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACf,MAAM,SAAS,CAAC,WAAW,QAAQ,OAAO,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QACnF,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type net from 'node:net';
|
|
2
|
+
/**
|
|
3
|
+
* Payload of the `tcpPort` resource type - `ioBroker.TcpPortResourceData` of js-controller 8.
|
|
4
|
+
*
|
|
5
|
+
* Declared here rather than taken from `@iobroker/types` because an adapter using this library may
|
|
6
|
+
* well be built against the types of js-controller 7, which do not know the registry at all.
|
|
7
|
+
*/
|
|
8
|
+
export interface UsedTcpPort {
|
|
9
|
+
/** TCP port number */
|
|
10
|
+
port: number;
|
|
11
|
+
/** Address the socket is bound to, `0.0.0.0` or `::` for every interface */
|
|
12
|
+
bind?: string;
|
|
13
|
+
/** Address family, only reported for a concrete bind address */
|
|
14
|
+
family?: 4 | 6;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether the registry of used resources can be spoken to at all.
|
|
18
|
+
*
|
|
19
|
+
* Both halves have to be asked, because they are two independent versions: the methods exist in the
|
|
20
|
+
* `@iobroker/adapter-core` the adapter was built with, the registry behind them exists in the
|
|
21
|
+
* js-controller that is running. A call to a host that knows no `registerUsedResource` is not
|
|
22
|
+
* refused, it is simply never answered - and every single one of them would sit out the five second
|
|
23
|
+
* timeout of the adapter API before rejecting.
|
|
24
|
+
*
|
|
25
|
+
* @param adapter the ioBroker adapter
|
|
26
|
+
* @returns whether resources may be registered and freed
|
|
27
|
+
*/
|
|
28
|
+
export declare function supportsUsedResources(adapter: ioBroker.Adapter): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Report a TCP port as occupied by this instance.
|
|
31
|
+
*
|
|
32
|
+
* Registering is additive, one call per port, so an adapter serving several of them reports each.
|
|
33
|
+
*
|
|
34
|
+
* @param adapter the ioBroker adapter
|
|
35
|
+
* @param data the port, and the address it is bound to if it is not every interface
|
|
36
|
+
* @returns whether the host accepted the registration
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerUsedPort(adapter: ioBroker.Adapter, data: UsedTcpPort): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Take a previously reported TCP port back.
|
|
41
|
+
*
|
|
42
|
+
* `data` is a filter and not the exact payload: every field it names has to match, fields it leaves
|
|
43
|
+
* out are ignored - so omitting it frees every TCP port of this instance. Freeing on shutdown is not
|
|
44
|
+
* needed, the host marks the entries of a stopped instance as no longer held by itself.
|
|
45
|
+
*
|
|
46
|
+
* @param adapter the ioBroker adapter
|
|
47
|
+
* @param data the fields identifying the ports to free; every TCP port of this instance without it
|
|
48
|
+
* @returns whether the host accepted the request
|
|
49
|
+
*/
|
|
50
|
+
export declare function freeUsedPort(adapter: ioBroker.Adapter, data?: Partial<UsedTcpPort>): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Report the port a server listens on for as long as it listens.
|
|
53
|
+
*
|
|
54
|
+
* The port is registered when the server starts listening - only then is it known, and a port taken
|
|
55
|
+
* from the configuration may not be the one that was really bound - and freed when it closes again.
|
|
56
|
+
* A server that is already listening is reported right away.
|
|
57
|
+
*
|
|
58
|
+
* @param adapter the ioBroker adapter
|
|
59
|
+
* @param server the server whose port is reported
|
|
60
|
+
* @returns a function that stops reporting and frees a port still registered
|
|
61
|
+
*/
|
|
62
|
+
export declare function trackUsedPort(adapter: ioBroker.Adapter, server: net.Server): () => void;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Reports the TCP port a server listens on to the per-host registry of exclusive resources
|
|
4
|
+
* js-controller 8 maintains (`system.host.<hostname>.usedResources.<type>`).
|
|
5
|
+
*
|
|
6
|
+
* The registry answers "which port is already spoken for on this host", so a user configuring a new
|
|
7
|
+
* instance can pick a free one instead of guessing and running into EADDRINUSE. For an adapter that
|
|
8
|
+
* does not declare anything, js-controller derives the entry from `native.port` - which is a guess
|
|
9
|
+
* about the configuration, not about what was really opened: an adapter listening on a second port,
|
|
10
|
+
* on a port taken from somewhere else than `native.port`, or not listening at all, is listed wrong.
|
|
11
|
+
*
|
|
12
|
+
* This module reports what the server actually bound to, which is only known once it listens, and
|
|
13
|
+
* takes the entry back when it closes again. The host is the only writer of the registry, so both
|
|
14
|
+
* are round-trips to it; they are queued so that a close following a listen cannot overtake it.
|
|
15
|
+
*
|
|
16
|
+
* Nothing here is required for the server to work - every failure is logged and swallowed.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.supportsUsedResources = supportsUsedResources;
|
|
20
|
+
exports.registerUsedPort = registerUsedPort;
|
|
21
|
+
exports.freeUsedPort = freeUsedPort;
|
|
22
|
+
exports.trackUsedPort = trackUsedPort;
|
|
23
|
+
/** Feature a js-controller announces once it maintains the registry. Since js-controller 8. */
|
|
24
|
+
const USED_RESOURCES_FEATURE = 'CONTROLLER_USED_RESOURCES';
|
|
25
|
+
/**
|
|
26
|
+
* Addresses that stand for every interface. A socket bound to one of them occupies the port in both
|
|
27
|
+
* address families (a wildcard listener is dual-stack), so the family must not be reported for it.
|
|
28
|
+
*/
|
|
29
|
+
const WILDCARD_ADDRESSES = ['0.0.0.0', '::', '*', ''];
|
|
30
|
+
/**
|
|
31
|
+
* Log without ever throwing.
|
|
32
|
+
*
|
|
33
|
+
* Everything here runs on a server event, and a `close` in particular arrives while the adapter is
|
|
34
|
+
* being torn down - at which point its logger can already be gone. A throwing log statement inside
|
|
35
|
+
* one of the queued tasks below would end up as a rejection nobody listens to, and that terminates
|
|
36
|
+
* the host adapter: a lot of damage for a line that only says a port was registered.
|
|
37
|
+
*
|
|
38
|
+
* @param adapter the ioBroker adapter
|
|
39
|
+
* @param level the log level to write with
|
|
40
|
+
* @param message what to write
|
|
41
|
+
*/
|
|
42
|
+
function log(adapter, level, message) {
|
|
43
|
+
try {
|
|
44
|
+
adapter.log[level](message);
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
// There is nothing left that could report this
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* How a port is named in the log. An IPv6 address is bracketed, otherwise its own colons run into
|
|
52
|
+
* the one before the port (`:::8082`).
|
|
53
|
+
*/
|
|
54
|
+
function describe(data) {
|
|
55
|
+
if (!data.bind) {
|
|
56
|
+
return `${data.port}`;
|
|
57
|
+
}
|
|
58
|
+
return data.bind.includes(':') ? `[${data.bind}]:${data.port}` : `${data.bind}:${data.port}`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether the registry of used resources can be spoken to at all.
|
|
62
|
+
*
|
|
63
|
+
* Both halves have to be asked, because they are two independent versions: the methods exist in the
|
|
64
|
+
* `@iobroker/adapter-core` the adapter was built with, the registry behind them exists in the
|
|
65
|
+
* js-controller that is running. A call to a host that knows no `registerUsedResource` is not
|
|
66
|
+
* refused, it is simply never answered - and every single one of them would sit out the five second
|
|
67
|
+
* timeout of the adapter API before rejecting.
|
|
68
|
+
*
|
|
69
|
+
* @param adapter the ioBroker adapter
|
|
70
|
+
* @returns whether resources may be registered and freed
|
|
71
|
+
*/
|
|
72
|
+
function supportsUsedResources(adapter) {
|
|
73
|
+
const api = adapter;
|
|
74
|
+
if (typeof api.registerUsedResource !== 'function' || typeof api.freeUsedResource !== 'function') {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
// Typed against a union of known features that does not contain this one in the types of
|
|
78
|
+
// js-controller 7, hence the loosely typed `supportsFeature` of `UsedResourcesApi`
|
|
79
|
+
return typeof api.supportsFeature === 'function' && api.supportsFeature(USED_RESOURCES_FEATURE);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether this instance may report its used resources to the host.
|
|
83
|
+
*
|
|
84
|
+
* All three reasons against it are perfectly normal - an older controller, an adapter built against
|
|
85
|
+
* an older `@iobroker/adapter-core`, an adapter that leaves the registry to the controller - so none
|
|
86
|
+
* of them is worth more than a debug line. The host would refuse the registration in the last case
|
|
87
|
+
* anyway, and asking it first only to be told so costs a message round-trip per start.
|
|
88
|
+
*
|
|
89
|
+
* @param adapter the ioBroker adapter
|
|
90
|
+
*/
|
|
91
|
+
function canReportUsedResources(adapter) {
|
|
92
|
+
var _a;
|
|
93
|
+
const api = adapter;
|
|
94
|
+
if (typeof api.registerUsedResource !== 'function' || typeof api.freeUsedResource !== 'function') {
|
|
95
|
+
// Told apart from the feature below only to name the half that is missing: the adapter can do
|
|
96
|
+
// something about this one by updating its @iobroker/adapter-core
|
|
97
|
+
log(adapter, 'debug', 'Used resources are not reported: @iobroker/adapter-core is older than js-controller 8');
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (!supportsUsedResources(adapter)) {
|
|
101
|
+
log(adapter, 'debug', 'Used resources are not reported: js-controller keeps no registry of used resources (feature "CONTROLLER_USED_RESOURCES")');
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (((_a = adapter.common) === null || _a === void 0 ? void 0 : _a.declareUsedResources) !== true) {
|
|
105
|
+
log(adapter, 'debug', 'Used resources are not reported: set "common.declareUsedResources" to true in io-package.json to report the port this adapter really listens on');
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Report a TCP port as occupied by this instance.
|
|
112
|
+
*
|
|
113
|
+
* Registering is additive, one call per port, so an adapter serving several of them reports each.
|
|
114
|
+
*
|
|
115
|
+
* @param adapter the ioBroker adapter
|
|
116
|
+
* @param data the port, and the address it is bound to if it is not every interface
|
|
117
|
+
* @returns whether the host accepted the registration
|
|
118
|
+
*/
|
|
119
|
+
async function registerUsedPort(adapter, data) {
|
|
120
|
+
if (!canReportUsedResources(adapter)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
await adapter.registerUsedResource('tcpPort', data);
|
|
125
|
+
log(adapter, 'debug', `Registered TCP port ${describe(data)} as used by this instance`);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
log(adapter, 'warn', `Could not register TCP port ${describe(data)} as used: ${e.message}`);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Take a previously reported TCP port back.
|
|
135
|
+
*
|
|
136
|
+
* `data` is a filter and not the exact payload: every field it names has to match, fields it leaves
|
|
137
|
+
* out are ignored - so omitting it frees every TCP port of this instance. Freeing on shutdown is not
|
|
138
|
+
* needed, the host marks the entries of a stopped instance as no longer held by itself.
|
|
139
|
+
*
|
|
140
|
+
* @param adapter the ioBroker adapter
|
|
141
|
+
* @param data the fields identifying the ports to free; every TCP port of this instance without it
|
|
142
|
+
* @returns whether the host accepted the request
|
|
143
|
+
*/
|
|
144
|
+
async function freeUsedPort(adapter, data) {
|
|
145
|
+
if (!canReportUsedResources(adapter)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
await adapter.freeUsedResource('tcpPort', data);
|
|
150
|
+
log(adapter, 'debug', `Freed TCP port ${data ? describe(data) : 'registrations'} of this instance`);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
log(adapter, 'warn', `Could not free TCP port ${data ? describe(data) : 'registrations'}: ${e.message}`);
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* What a listening server occupies, as the registry wants it.
|
|
160
|
+
*
|
|
161
|
+
* @param server the server to look at
|
|
162
|
+
* @returns the payload, or undefined when the server holds no TCP port
|
|
163
|
+
*/
|
|
164
|
+
function listeningPort(server) {
|
|
165
|
+
const address = server.address();
|
|
166
|
+
if (!address || typeof address === 'string') {
|
|
167
|
+
// A pipe or a UNIX socket - no port, and no resource type the registry knows for it
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
const data = { port: address.port, bind: address.address };
|
|
171
|
+
if (!WILDCARD_ADDRESSES.includes(address.address)) {
|
|
172
|
+
// Named only for a concrete address: on a wildcard one the port is occupied in both families,
|
|
173
|
+
// and the host treats a family it is not told about as "every family", which is exactly that.
|
|
174
|
+
data.family = address.family === 'IPv6' ? 6 : 4;
|
|
175
|
+
}
|
|
176
|
+
return data;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Report the port a server listens on for as long as it listens.
|
|
180
|
+
*
|
|
181
|
+
* The port is registered when the server starts listening - only then is it known, and a port taken
|
|
182
|
+
* from the configuration may not be the one that was really bound - and freed when it closes again.
|
|
183
|
+
* A server that is already listening is reported right away.
|
|
184
|
+
*
|
|
185
|
+
* @param adapter the ioBroker adapter
|
|
186
|
+
* @param server the server whose port is reported
|
|
187
|
+
* @returns a function that stops reporting and frees a port still registered
|
|
188
|
+
*/
|
|
189
|
+
function trackUsedPort(adapter, server) {
|
|
190
|
+
/** What was reported, so the same port can be taken back - the server has no address by then */
|
|
191
|
+
let reported;
|
|
192
|
+
/** Both calls go to the host, and a free must not arrive before the register it undoes */
|
|
193
|
+
let queue = Promise.resolve();
|
|
194
|
+
const enqueue = (task) => {
|
|
195
|
+
// The tasks report their own failures, so nothing is expected here - but a rejected promise
|
|
196
|
+
// nobody listens to terminates the host adapter, which no port registration is worth.
|
|
197
|
+
queue = queue.then(task, task).catch((e) => {
|
|
198
|
+
log(adapter, 'warn', `Could not report the used TCP port: ${e === null || e === void 0 ? void 0 : e.message}`);
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
const onListening = () => {
|
|
202
|
+
const data = listeningPort(server);
|
|
203
|
+
if (!data) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
reported = data;
|
|
207
|
+
enqueue(() => registerUsedPort(adapter, data));
|
|
208
|
+
};
|
|
209
|
+
const onClose = () => {
|
|
210
|
+
const data = reported;
|
|
211
|
+
if (!data) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
reported = undefined;
|
|
215
|
+
// Filtered by port and address only: the family was derived from the address, and a filter
|
|
216
|
+
// naming a field the entry does not have matches nothing.
|
|
217
|
+
enqueue(() => freeUsedPort(adapter, { port: data.port, bind: data.bind }));
|
|
218
|
+
};
|
|
219
|
+
server.on('listening', onListening);
|
|
220
|
+
server.on('close', onClose);
|
|
221
|
+
if (server.listening) {
|
|
222
|
+
// Attached to a server that is already up, so its `listening` event is long gone
|
|
223
|
+
onListening();
|
|
224
|
+
}
|
|
225
|
+
return () => {
|
|
226
|
+
server.off('listening', onListening);
|
|
227
|
+
server.off('close', onClose);
|
|
228
|
+
onClose();
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=usedResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usedResources.js","sourceRoot":"","sources":["../../src/lib/usedResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AA2FH,sDAUC;AAoDD,4CAaC;AAaD,oCAaC;AAsCD,sCA+CC;AAjRD,+FAA+F;AAC/F,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAE3D;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAqCtD;;;;;;;;;;;GAWG;AACH,SAAS,GAAG,CAAC,OAAyB,EAAE,KAAuB,EAAE,OAAe;IAC5E,IAAI,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,WAAM,CAAC;QACL,+CAA+C;IACnD,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CAAC,IAA0B;IACxC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;AACjG,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,qBAAqB,CAAC,OAAyB;IAC3D,MAAM,GAAG,GAAG,OAAsC,CAAC;IAEnD,IAAI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QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO;QACX,CAAC;QACD,QAAQ,GAAG,SAAS,CAAC;QACrB,2FAA2F;QAC3F,0DAA0D;QAC1D,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;IAEF,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE5B,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,iFAAiF;QACjF,WAAW,EAAE,CAAC;IAClB,CAAC;IAED,OAAO,GAAG,EAAE;QACR,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,EAAE,CAAC;IACd,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type OAuth2Server from 'oauth2-server';
|
|
2
|
+
import type { Request } from 'express';
|
|
3
|
+
export interface IobrokerOauthResponse {
|
|
4
|
+
access_token: string;
|
|
5
|
+
token_type: string;
|
|
6
|
+
expires_in: number;
|
|
7
|
+
refresh_token?: string;
|
|
8
|
+
refresh_token_expires_in: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Convert oauth2 token to JSON response
|
|
12
|
+
*
|
|
13
|
+
* @param token the created OAuth token
|
|
14
|
+
*/
|
|
15
|
+
export declare function oauthTokenToResponse(token: OAuth2Server.Token): IobrokerOauthResponse;
|
|
16
|
+
/**
|
|
17
|
+
* Determine the externally reachable base URL, without a trailing slash. Behind a reverse proxy the
|
|
18
|
+
* request-derived value is wrong (`http:` instead of `https:`, internal host) unless the host app
|
|
19
|
+
* enabled `trust proxy`, which is why it can be configured.
|
|
20
|
+
*
|
|
21
|
+
* @param req The incoming request
|
|
22
|
+
* @param baseUrl The configured base URL, or a function that derives it from the request
|
|
23
|
+
*/
|
|
24
|
+
export declare function getBaseUrl(req: Request, baseUrl?: string | ((req: Request) => string)): string;
|
|
25
|
+
/**
|
|
26
|
+
* Read and parse a request body without depending on a body parser being installed.
|
|
27
|
+
*
|
|
28
|
+
* Adapters differ in whether they install `body-parser` globally, so an already parsed body is used
|
|
29
|
+
* when there is one, and the stream is read directly otherwise. Supports `application/json` and
|
|
30
|
+
* `application/x-www-form-urlencoded`.
|
|
31
|
+
*
|
|
32
|
+
* @param req The incoming request
|
|
33
|
+
* @returns The parsed body; an empty object when there is none
|
|
34
|
+
*/
|
|
35
|
+
export declare function readRequestBody(req: Request): Promise<Record<string, any>>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oauthTokenToResponse = oauthTokenToResponse;
|
|
4
|
+
exports.getBaseUrl = getBaseUrl;
|
|
5
|
+
exports.readRequestBody = readRequestBody;
|
|
6
|
+
/** Upper bound for a request body we parse ourselves. */
|
|
7
|
+
const MAX_BODY_SIZE = 64 * 1024;
|
|
8
|
+
/**
|
|
9
|
+
* Convert oauth2 token to JSON response
|
|
10
|
+
*
|
|
11
|
+
* @param token the created OAuth token
|
|
12
|
+
*/
|
|
13
|
+
function oauthTokenToResponse(token) {
|
|
14
|
+
return {
|
|
15
|
+
access_token: token.accessToken,
|
|
16
|
+
token_type: 'Bearer',
|
|
17
|
+
expires_in: token.accessTokenExpiresAt
|
|
18
|
+
? Math.floor((token.accessTokenExpiresAt.getTime() - Date.now()) / 1000)
|
|
19
|
+
: 0,
|
|
20
|
+
refresh_token: token.refreshToken,
|
|
21
|
+
refresh_token_expires_in: token.refreshTokenExpiresAt
|
|
22
|
+
? Math.floor((token.refreshTokenExpiresAt.getTime() - Date.now()) / 1000)
|
|
23
|
+
: 0,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Determine the externally reachable base URL, without a trailing slash. Behind a reverse proxy the
|
|
28
|
+
* request-derived value is wrong (`http:` instead of `https:`, internal host) unless the host app
|
|
29
|
+
* enabled `trust proxy`, which is why it can be configured.
|
|
30
|
+
*
|
|
31
|
+
* @param req The incoming request
|
|
32
|
+
* @param baseUrl The configured base URL, or a function that derives it from the request
|
|
33
|
+
*/
|
|
34
|
+
function getBaseUrl(req, baseUrl) {
|
|
35
|
+
const configured = typeof baseUrl === 'function' ? baseUrl(req) : baseUrl;
|
|
36
|
+
if (configured) {
|
|
37
|
+
return configured.replace(/\/+$/, '');
|
|
38
|
+
}
|
|
39
|
+
return `${req.protocol}://${req.get('host') || 'localhost'}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read and parse a request body without depending on a body parser being installed.
|
|
43
|
+
*
|
|
44
|
+
* Adapters differ in whether they install `body-parser` globally, so an already parsed body is used
|
|
45
|
+
* when there is one, and the stream is read directly otherwise. Supports `application/json` and
|
|
46
|
+
* `application/x-www-form-urlencoded`.
|
|
47
|
+
*
|
|
48
|
+
* @param req The incoming request
|
|
49
|
+
* @returns The parsed body; an empty object when there is none
|
|
50
|
+
*/
|
|
51
|
+
async function readRequestBody(req) {
|
|
52
|
+
const existing = req.body;
|
|
53
|
+
if (Buffer.isBuffer(existing)) {
|
|
54
|
+
return parseBody(existing.toString('utf8'), req.headers['content-type']);
|
|
55
|
+
}
|
|
56
|
+
if (typeof existing === 'string') {
|
|
57
|
+
return parseBody(existing, req.headers['content-type']);
|
|
58
|
+
}
|
|
59
|
+
if (existing && typeof existing === 'object' && Object.keys(existing).length) {
|
|
60
|
+
return existing;
|
|
61
|
+
}
|
|
62
|
+
if (req.readableEnded) {
|
|
63
|
+
// A body parser already consumed the stream — an empty result is the real result.
|
|
64
|
+
return existing || {};
|
|
65
|
+
}
|
|
66
|
+
const raw = await new Promise((resolve, reject) => {
|
|
67
|
+
let data = '';
|
|
68
|
+
let size = 0;
|
|
69
|
+
req.setEncoding('utf8');
|
|
70
|
+
req.on('data', (chunk) => {
|
|
71
|
+
size += Buffer.byteLength(chunk, 'utf8');
|
|
72
|
+
if (size > MAX_BODY_SIZE) {
|
|
73
|
+
reject(new Error('Request body too large'));
|
|
74
|
+
req.destroy();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
data += chunk;
|
|
78
|
+
});
|
|
79
|
+
req.on('end', () => resolve(data));
|
|
80
|
+
req.on('error', reject);
|
|
81
|
+
});
|
|
82
|
+
return parseBody(raw, req.headers['content-type']);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parse a raw request body according to its content type.
|
|
86
|
+
*
|
|
87
|
+
* @param raw The raw body text
|
|
88
|
+
* @param contentType The `Content-Type` header value
|
|
89
|
+
*/
|
|
90
|
+
function parseBody(raw, contentType) {
|
|
91
|
+
if (!raw) {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
const type = (contentType || '').split(';')[0].trim().toLowerCase();
|
|
95
|
+
if (type === 'application/json') {
|
|
96
|
+
try {
|
|
97
|
+
const parsed = JSON.parse(raw);
|
|
98
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
99
|
+
}
|
|
100
|
+
catch (_a) {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const result = {};
|
|
105
|
+
for (const [key, value] of new URLSearchParams(raw).entries()) {
|
|
106
|
+
result[key] = value;
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;AAmBA,oDAYC;AAUD,gCAMC;AAYD,0CAmCC;AA3FD,y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