iobroker.eos-admin 8.0.0 → 8.0.1

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.
Files changed (159) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +7 -6
  2. package/NEXOWATT_EOS_PREBUILT_MANIFEST.json +133 -51
  3. package/START_HERE_8.0.1.md +36 -0
  4. package/adminWww/.vite/manifest.json +39 -39
  5. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
  6. package/adminWww/assets/{AdapterUpdateDialog-B3y8RL_5.js → AdapterUpdateDialog-D3y2bGHM.js} +1 -1
  7. package/adminWww/assets/{Adapters-BDxfhfGe.js → Adapters-WMGNQt7g.js} +1 -1
  8. package/adminWww/assets/{ConfigManager-CFuOc_kb.js → ConfigManager-BMdQoiCg.js} +1 -1
  9. package/adminWww/assets/{Enums-CSzSzWm7.js → Enums-CHm2sGa-.js} +1 -1
  10. package/adminWww/assets/{Fields-DnckPMA8.js → Fields-Df7Llf6U.js} +1 -1
  11. package/adminWww/assets/{Files-CwUHx0pF.js → Files-Bwbw17Fb.js} +1 -1
  12. package/adminWww/assets/{Hosts-QkyuASJy.js → Hosts-BR0g-Wxo.js} +1 -1
  13. package/adminWww/assets/{Instances-BaWBemTT.js → Instances-BKydFSdw.js} +1 -1
  14. package/adminWww/assets/{Intro-DsfrPrWv.js → Intro-Dt2GzmtW.js} +1 -1
  15. package/adminWww/assets/{Logs-Cngy2Opt.js → Logs-hbcdBDN3.js} +1 -1
  16. package/adminWww/assets/{Objects-DY8KS7zK.js → Objects-HPx0yuOk.js} +1 -1
  17. package/adminWww/assets/{Overview-WwP6FjK-.js → Overview-CDvnM655.js} +1 -1
  18. package/adminWww/assets/{State-vP1o2BCL.js → State-Cc-tyuqB.js} +1 -1
  19. package/adminWww/assets/{UsedResources-CMTzFOX3.js → UsedResources-BIdU7UPm.js} +1 -1
  20. package/adminWww/assets/{Users-BjTGOjzL.js → Users-BruHA-yU.js} +1 -1
  21. package/adminWww/assets/{bootstrap-Bs4TZ7iA.js → bootstrap-D-7xcwTc.js} +3 -3
  22. package/adminWww/assets/{hostInit-2xIZYDSq.js → hostInit-huY-0clu.js} +1 -1
  23. package/adminWww/assets/{icons-material-BLgrEUSv.js → icons-material-Bu1f45BT.js} +1 -1
  24. package/adminWww/assets/{index-BZifaJHi.js → index-D8vmzGp8.js} +2 -2
  25. package/adminWww/assets/{installSVGRenderer-Pe6-VnD2.js → installSVGRenderer-BkdptYag.js} +1 -1
  26. package/adminWww/assets/{mf-entry-bootstrap-0-a6a54377.js → mf-entry-bootstrap-0-f6098d8b.js} +2 -2
  27. package/adminWww/index.html +21 -21
  28. package/adminWww/mf-manifest.json +1 -1
  29. package/adminWww/mf-stats.json +1 -1
  30. package/adminWww/{remoteEntry-eos-8.0.0.js → remoteEntry-eos-8.0.1.js} +1 -1
  31. package/adminWww/remoteEntry.js +1 -1
  32. package/build/lib/eosSessionSecurity.js +12 -4
  33. package/build/lib/eosSessionSecurity.js.map +1 -1
  34. package/build/lib/vendor/webserver/LICENSE +21 -0
  35. package/build/lib/vendor/webserver/README.md +506 -0
  36. package/build/lib/vendor/webserver/build/index.d.ts +9 -0
  37. package/build/lib/vendor/webserver/build/index.js +42 -0
  38. package/build/lib/vendor/webserver/build/index.js.map +1 -0
  39. package/build/lib/vendor/webserver/build/lib/acmeChallenge.d.ts +65 -0
  40. package/build/lib/vendor/webserver/build/lib/acmeChallenge.js +149 -0
  41. package/build/lib/vendor/webserver/build/lib/acmeChallenge.js.map +1 -0
  42. package/build/lib/vendor/webserver/build/lib/certificateManager.d.ts +60 -0
  43. package/build/lib/vendor/webserver/build/lib/certificateManager.js +128 -0
  44. package/build/lib/vendor/webserver/build/lib/certificateManager.js.map +1 -0
  45. package/build/lib/vendor/webserver/build/lib/http2Compat.d.ts +21 -0
  46. package/build/lib/vendor/webserver/build/lib/http2Compat.js +109 -0
  47. package/build/lib/vendor/webserver/build/lib/http2Compat.js.map +1 -0
  48. package/build/lib/vendor/webserver/build/lib/oauth2-authcode.d.ts +167 -0
  49. package/build/lib/vendor/webserver/build/lib/oauth2-authcode.js +619 -0
  50. package/build/lib/vendor/webserver/build/lib/oauth2-authcode.js.map +1 -0
  51. package/build/lib/vendor/webserver/build/lib/oauth2-clients.d.ts +92 -0
  52. package/build/lib/vendor/webserver/build/lib/oauth2-clients.js +230 -0
  53. package/build/lib/vendor/webserver/build/lib/oauth2-clients.js.map +1 -0
  54. package/build/lib/vendor/webserver/build/lib/oauth2-model.d.ts +84 -0
  55. package/build/lib/vendor/webserver/build/lib/oauth2-model.js +388 -0
  56. package/build/lib/vendor/webserver/build/lib/oauth2-model.js.map +1 -0
  57. package/build/lib/vendor/webserver/build/lib/oauth2.d.ts +75 -0
  58. package/build/lib/vendor/webserver/build/lib/oauth2.js +625 -0
  59. package/build/lib/vendor/webserver/build/lib/oauth2.js.map +1 -0
  60. package/build/lib/vendor/webserver/build/lib/securityChecker.d.ts +6 -0
  61. package/build/lib/vendor/webserver/build/lib/securityChecker.js +96 -0
  62. package/build/lib/vendor/webserver/build/lib/securityChecker.js.map +1 -0
  63. package/build/lib/vendor/webserver/build/lib/usedResources.d.ts +62 -0
  64. package/build/lib/vendor/webserver/build/lib/usedResources.js +231 -0
  65. package/build/lib/vendor/webserver/build/lib/usedResources.js.map +1 -0
  66. package/build/lib/vendor/webserver/build/lib/utils.d.ts +35 -0
  67. package/build/lib/vendor/webserver/build/lib/utils.js +110 -0
  68. package/build/lib/vendor/webserver/build/lib/utils.js.map +1 -0
  69. package/build/lib/vendor/webserver/build/lib/webServer.d.ts +164 -0
  70. package/build/lib/vendor/webserver/build/lib/webServer.js +454 -0
  71. package/build/lib/vendor/webserver/build/lib/webServer.js.map +1 -0
  72. package/build/lib/vendor/webserver/package.json +63 -0
  73. package/build/lib/web.js +1 -1
  74. package/build/lib/web.js.map +1 -1
  75. package/docs/ADMIN8_MIGRATION_8.0.0_DE.md +2 -0
  76. package/docs/cra/CRA_IEC_GAP_ANALYSIS_2026-09-30.md +5 -0
  77. package/docs/security/admin8-2026-11-04/development-1.log +3 -3
  78. package/docs/security/admin8-2026-11-04/development-2.log +248 -233
  79. package/docs/security/admin8-2026-11-05/copy-update/evidence-sha256.json +0 -5
  80. package/docs/security/admin8-2026-11-05/login-fix/BACKEND_DIAGNOSE_DE.md +48 -0
  81. package/docs/security/admin8-2026-11-05/login-fix/REPORT_DE.md +47 -0
  82. package/docs/security/admin8-2026-11-05/login-fix/REVIEW_DE.md +7 -0
  83. package/docs/security/admin8-2026-11-05/login-fix/controller-adapter-api.ts.txt +122 -0
  84. package/docs/security/admin8-2026-11-05/login-fix/controller-file-view.ts.txt +75 -0
  85. package/docs/security/admin8-2026-11-05/login-fix/controller-redis-view.ts.txt +471 -0
  86. package/docs/security/admin8-2026-11-05/login-fix/dependency/LICENSE-webserver-3.4.0 +21 -0
  87. package/docs/security/admin8-2026-11-05/login-fix/dependency/REPORT_DE.md +41 -0
  88. package/docs/security/admin8-2026-11-05/login-fix/dependency/evidence-sha256.json +116 -0
  89. package/docs/security/admin8-2026-11-05/login-fix/dependency/http-consumer-check.cjs +58 -0
  90. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/README_DE.md +9 -0
  91. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/REJECTED-webserver-3.4.0-eos-oauth.provenance.json +263 -0
  92. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/REJECTED-webserver-3.4.0-eos-oauth.tgz +0 -0
  93. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/admission.log +16 -0
  94. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-audit-stderr.log +1 -0
  95. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-audit.json +22 -0
  96. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-fixture-1.0.0.tgz +0 -0
  97. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-fixture-package.json +11 -0
  98. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-npm10-package-lock.json +387 -0
  99. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/consumer-npm11-package-lock.json +387 -0
  100. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/evidence-sha256.json +85 -0
  101. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/http-consumer-npm10-node22.json +11 -0
  102. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/http-consumer-npm11-node24.json +11 -0
  103. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/local-tests.json +38 -0
  104. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/tests-node22.log +168 -0
  105. package/docs/security/admin8-2026-11-05/login-fix/dependency/rejected-file-dependency/tests-node24.log +36 -0
  106. package/docs/security/admin8-2026-11-05/login-fix/dependency/source-vendor-tests-node22.log +224 -0
  107. package/docs/security/admin8-2026-11-05/login-fix/dependency/source-vendor-tests-node24.log +42 -0
  108. package/docs/security/admin8-2026-11-05/login-fix/dependency/source-vendor-tests.json +31 -0
  109. package/docs/security/admin8-2026-11-05/login-fix/dependency/webserver-3.4.0-upstream.tgz +0 -0
  110. package/docs/security/admin8-2026-11-05/login-fix/eos-session-8.0.0.js.txt +385 -0
  111. package/docs/security/admin8-2026-11-05/login-fix/evidence-sha256.json +59 -0
  112. package/docs/security/admin8-2026-11-05/login-fix/path-budget.json +6 -0
  113. package/docs/security/admin8-2026-11-05/login-fix/provenance.json +51 -0
  114. package/docs/security/admin8-2026-11-05/login-fix/release/admission.log +21 -0
  115. package/docs/security/admin8-2026-11-05/login-fix/release/archive-scan.json +13 -0
  116. package/docs/security/admin8-2026-11-05/login-fix/release/artifacts.log +6 -0
  117. package/docs/security/admin8-2026-11-05/login-fix/release/backend-build.log +5 -0
  118. package/docs/security/admin8-2026-11-05/login-fix/release/consumer-package-lock.json +3258 -0
  119. package/docs/security/admin8-2026-11-05/login-fix/release/copy-update-journal.json +165 -0
  120. package/docs/security/admin8-2026-11-05/login-fix/release/development.log +365 -0
  121. package/docs/security/admin8-2026-11-05/login-fix/release/frontend-build.log +149 -0
  122. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-audit.json +22 -0
  123. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-audit.stderr +2 -0
  124. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-final-install-node22.log +9 -0
  125. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node22.json +15 -0
  126. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node22.stderr +2 -0
  127. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node24.json +15 -0
  128. package/docs/security/admin8-2026-11-05/login-fix/release/full-consumer-http-node24.stderr +0 -0
  129. package/docs/security/admin8-2026-11-05/login-fix/release/inventory.log +8 -0
  130. package/docs/security/admin8-2026-11-05/login-fix/release/npm-pack-final.json +7809 -0
  131. package/docs/security/admin8-2026-11-05/login-fix/release/npm-pack-final.stderr +6 -0
  132. package/docs/security/admin8-2026-11-05/login-fix/release/overlay-final-publish-node22.json +10213 -0
  133. package/docs/security/admin8-2026-11-05/login-fix/release/overlay-final-publish-node22.stderr +282 -0
  134. package/docs/security/admin8-2026-11-05/login-fix/release/pipeline.json +72 -0
  135. package/docs/security/admin8-2026-11-05/login-fix/release/seal.log +6 -0
  136. package/docs/security/admin8-2026-11-05/login-fix/release/vendor-final-review-node24.log +18 -0
  137. package/docs/security/admin8-2026-11-05/login-fix/reproduce.cjs +79 -0
  138. package/docs/security/admin8-2026-11-05/login-fix/reproduction.json +80 -0
  139. package/docs/security/admin8-2026-11-05/login-fix/upstream-LICENSE.txt +22 -0
  140. package/docs/security/admin8-2026-11-05/login-fix/validation.json +85 -0
  141. package/docs/third-party/admin8/NOTICE-PROVENANCE.json +3 -3
  142. package/io-package.json +9 -10
  143. package/package.json +9 -4
  144. package/release-manifests/admin8-development-validation.json +114 -31
  145. package/reports/security/artifact-inventory.json +462 -227
  146. package/reports/security/inventory-summary.json +39 -17
  147. package/reports/security/sbom-backend-lock.cdx.json +108 -111
  148. package/reports/security/sbom-frontend-lock.cdx.json +5 -5
  149. package/reports/security/source-runtime-manifest.json +455 -65
  150. package/tools/nexowatt-artifact-inventory.cjs +8 -1
  151. package/tools/nexowatt-installer-ems-selftest.cjs +1 -1
  152. package/tools/nexowatt-lock-provenance-check.cjs +8 -3
  153. package/tools/nexowatt-repair-lock-metadata.cjs +3 -3
  154. package/tools/nexowatt-security-inventory.cjs +22 -1
  155. package/tools/nexowatt-user-area-selftest.cjs +1 -1
  156. package/tools/nexowatt-v7109-clean-core-selftest.cjs +1 -1
  157. package/tools/nexowatt-vendored-webserver.cjs +69 -0
  158. package/tools/vendor/eos-retired-release-files.json +73 -1
  159. package/tools/vendor/webserver-3.4.0-source.provenance.json +244 -0
@@ -0,0 +1,619 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizationCodeFlow = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const oauth2_clients_1 = require("./oauth2-clients");
6
+ const utils_1 = require("./utils");
7
+ /** How long an authorization code stays valid. Codes are single-use, so this only needs to cover the redirect. */
8
+ const CODE_TTL_SEC = 60;
9
+ /** How long the user has to complete login and consent. */
10
+ const REQUEST_TTL_SEC = 600;
11
+ /** Session key prefix for pending authorization requests. */
12
+ const REQUEST_PREFIX = 'oauthreq:';
13
+ /** Session key prefix for issued authorization codes. */
14
+ const CODE_PREFIX = 'oauthcode:';
15
+ /**
16
+ * Escape a string for inclusion in HTML text or a double-quoted attribute.
17
+ *
18
+ * @param text The raw text
19
+ */
20
+ function escapeHtml(text) {
21
+ return text
22
+ .replace(/&/g, '&')
23
+ .replace(/</g, '&lt;')
24
+ .replace(/>/g, '&gt;')
25
+ .replace(/"/g, '&quot;')
26
+ .replace(/'/g, '&#39;');
27
+ }
28
+ /**
29
+ * Read a query parameter that may legitimately appear more than once (e.g. `resource`).
30
+ * Only the first occurrence is used; anything that is not a string is ignored.
31
+ *
32
+ * @param value The raw value taken from `req.query`
33
+ */
34
+ function firstValue(value) {
35
+ if (typeof value === 'string') {
36
+ return value;
37
+ }
38
+ if (Array.isArray(value) && typeof value[0] === 'string') {
39
+ return value[0];
40
+ }
41
+ return undefined;
42
+ }
43
+ /**
44
+ * Build the CSP `form-action` source list that lets the browser follow the authorization response.
45
+ *
46
+ * The consent form posts back to us, but the answer to that POST is a redirect to the client's
47
+ * callback. Chromium and WebKit apply `form-action` to that redirect as well (Firefox does not), so
48
+ * a bare `'self'` makes them drop the response: the code is issued and then thrown away, and the
49
+ * user is left on the consent page. The redirect URI was validated against the client's registration
50
+ * before the page was rendered, so naming its origin here does not widen what the form can reach.
51
+ *
52
+ * @param redirectUri The verified redirect URI of the pending request
53
+ */
54
+ function formActionSources(redirectUri) {
55
+ let parsed;
56
+ try {
57
+ parsed = new URL(redirectUri);
58
+ }
59
+ catch (_a) {
60
+ // Unparseable URIs are rejected at registration time, so this cannot happen for a pending
61
+ // request — fall back to the strictest policy rather than guess.
62
+ return "'self'";
63
+ }
64
+ // Native apps get their callback on a private-use scheme (`myapp://cb`), for which there is no
65
+ // origin; those are allowed by scheme instead.
66
+ const client = parsed.origin && parsed.origin !== 'null' ? parsed.origin : parsed.protocol;
67
+ return `'self' ${client}`;
68
+ }
69
+ /**
70
+ * Compare two strings without leaking their contents through timing differences.
71
+ *
72
+ * @param a First value
73
+ * @param b Second value
74
+ */
75
+ function safeEqual(a, b) {
76
+ const bufA = Buffer.from(a, 'utf8');
77
+ const bufB = Buffer.from(b, 'utf8');
78
+ if (bufA.length !== bufB.length) {
79
+ return false;
80
+ }
81
+ return (0, node_crypto_1.timingSafeEqual)(bufA, bufB);
82
+ }
83
+ /**
84
+ * Implements the OAuth2 authorization code flow with PKCE (RFC 7636), dynamic client registration
85
+ * (RFC 7591) and authorization server metadata (RFC 8414) on top of an existing {@link OAuth2Model}.
86
+ *
87
+ * This is deliberately not built on `oauth2-server`: that package (3.x) has no PKCE support, and
88
+ * MCP clients require it. Token issuance still goes through the model, so access and refresh tokens
89
+ * are indistinguishable from those issued by the password grant.
90
+ */
91
+ class AuthorizationCodeFlow {
92
+ /**
93
+ * @param adapter ioBroker adapter used for session storage and logging
94
+ * @param options Flow options
95
+ */
96
+ constructor(adapter, options) {
97
+ this.adapter = adapter;
98
+ this.model = options.model;
99
+ this.clientStore = options.clientStore;
100
+ this.options = options;
101
+ this.productName = options.productName || 'ioBroker';
102
+ }
103
+ /**
104
+ * Register the endpoints that must be reachable without authentication: the discovery document
105
+ * and — when enabled — dynamic client registration.
106
+ *
107
+ * Must be called *before* the app-wide `authorize` middleware so these routes stay public.
108
+ */
109
+ registerPublicRoutes() {
110
+ const app = this.options.app;
111
+ app.get('/.well-known/oauth-authorization-server', (req, res) => {
112
+ const baseUrl = this.getBaseUrl(req);
113
+ res.set('Cache-Control', 'public, max-age=300');
114
+ res.json({
115
+ issuer: baseUrl,
116
+ authorization_endpoint: `${baseUrl}/oauth/authorize`,
117
+ token_endpoint: `${baseUrl}/oauth/token`,
118
+ registration_endpoint: this.options.dynamicClientRegistration === false ? undefined : `${baseUrl}/oauth/register`,
119
+ revocation_endpoint: `${baseUrl}/oauth/revoke`,
120
+ response_types_supported: ['code'],
121
+ grant_types_supported: ['authorization_code', 'refresh_token'],
122
+ code_challenge_methods_supported: ['S256'],
123
+ token_endpoint_auth_methods_supported: ['none'],
124
+ });
125
+ });
126
+ if (this.options.dynamicClientRegistration !== false) {
127
+ app.post('/oauth/register', (req, res) => {
128
+ this.guard(res, this.handleRegister(req, res), true);
129
+ });
130
+ }
131
+ app.post('/oauth/revoke', (req, res) => {
132
+ this.guard(res, this.handleRevoke(req, res), true);
133
+ });
134
+ }
135
+ /**
136
+ * Handle `POST /oauth/revoke` (RFC 7009), so a client can drop its tokens when the user
137
+ * disconnects it. Per the RFC an unknown token is not an error — the caller's goal is met either
138
+ * way, and reporting it would let anyone probe which tokens exist.
139
+ *
140
+ * @param req The incoming request
141
+ * @param res The response to write to
142
+ */
143
+ async handleRevoke(req, res) {
144
+ res.set('Cache-Control', 'no-store');
145
+ let body;
146
+ try {
147
+ body = await (0, utils_1.readRequestBody)(req);
148
+ }
149
+ catch (_a) {
150
+ res.status(400).json({ error: 'invalid_request' });
151
+ return;
152
+ }
153
+ const value = typeof body.token === 'string' ? body.token : '';
154
+ if (!value) {
155
+ res.status(400).json({ error: 'invalid_request', error_description: 'token is required' });
156
+ return;
157
+ }
158
+ // The hint is only an optimisation, so it is ignored: `revokeTokenPair` accepts either kind
159
+ // and drops the access and refresh token together (RFC 7009 §2.1).
160
+ const revoked = await this.model.revokeTokenPair(value);
161
+ if (revoked) {
162
+ this.adapter.log.debug('Revoked an OAuth2 token pair on client request');
163
+ }
164
+ res.status(200).end();
165
+ }
166
+ /**
167
+ * Register the endpoints that need to know whether the browser is already logged in.
168
+ *
169
+ * Must be called *after* the app-wide `authorize` middleware, which populates `req.user` from an
170
+ * `access_token` cookie — otherwise an already logged-in user would be asked for the password again.
171
+ */
172
+ registerAuthorizeRoutes() {
173
+ const app = this.options.app;
174
+ app.get('/oauth/authorize', (req, res) => {
175
+ this.guard(res, this.handleAuthorizeStart(req, res), false);
176
+ });
177
+ app.post('/oauth/authorize', (req, res) => {
178
+ this.guard(res, this.handleAuthorizeSubmit(req, res), false);
179
+ });
180
+ }
181
+ /**
182
+ * Determine the externally reachable base URL. Behind a reverse proxy the request-derived value
183
+ * is wrong unless the host app enabled `trust proxy`, which is why {@link AuthorizationCodeFlowOptions.baseUrl}
184
+ * exists.
185
+ *
186
+ * @param req The incoming request
187
+ */
188
+ getBaseUrl(req) {
189
+ return (0, utils_1.getBaseUrl)(req, this.options.baseUrl);
190
+ }
191
+ // ----- Dynamic client registration (RFC 7591) -----
192
+ /**
193
+ * Handle `POST /oauth/register`.
194
+ *
195
+ * @param req The incoming request
196
+ * @param res The response to write to
197
+ */
198
+ async handleRegister(req, res) {
199
+ res.set('Cache-Control', 'no-store');
200
+ let body;
201
+ try {
202
+ body = await (0, utils_1.readRequestBody)(req);
203
+ }
204
+ catch (e) {
205
+ res.status(400).json({ error: 'invalid_client_metadata', error_description: e.message });
206
+ return;
207
+ }
208
+ try {
209
+ const client = await this.clientStore.register(body, { dynamic: true });
210
+ this.adapter.log.info(`Registered OAuth2 client "${client.client_name || client.client_id}" (${client.client_id})`);
211
+ res.status(201).json({
212
+ client_id: client.client_id,
213
+ client_id_issued_at: client.client_id_issued_at,
214
+ client_name: client.client_name,
215
+ redirect_uris: client.redirect_uris,
216
+ grant_types: client.grant_types,
217
+ response_types: client.response_types,
218
+ token_endpoint_auth_method: client.token_endpoint_auth_method,
219
+ scope: client.scope,
220
+ });
221
+ }
222
+ catch (e) {
223
+ if (e instanceof oauth2_clients_1.ClientRegistrationError) {
224
+ this.adapter.log.warn(`Rejected OAuth2 client registration: ${e.message}`);
225
+ res.status(400).json({ error: e.code, error_description: e.message });
226
+ return;
227
+ }
228
+ this.adapter.log.error(`OAuth2 client registration failed: ${e.message}`);
229
+ res.status(500).json({ error: 'invalid_client_metadata', error_description: e.message });
230
+ }
231
+ }
232
+ // ----- Authorization endpoint -----
233
+ /**
234
+ * Handle `GET /oauth/authorize`: validate the request, then show either the login form or the
235
+ * consent page.
236
+ *
237
+ * @param req The incoming request
238
+ * @param res The response to write to
239
+ */
240
+ async handleAuthorizeStart(req, res) {
241
+ const query = req.query;
242
+ const clientId = firstValue(query.client_id);
243
+ if (!clientId) {
244
+ this.sendErrorPage(res, 400, 'Missing client_id', 'The authorization request has no client_id.');
245
+ return;
246
+ }
247
+ const client = await this.clientStore.get(clientId);
248
+ if (!client) {
249
+ this.sendErrorPage(res, 400, 'Unknown client', 'This application is not registered with this ioBroker installation.');
250
+ return;
251
+ }
252
+ // Resolving the redirect URI must happen before any error can be reported back to the client:
253
+ // redirecting to an unvalidated URI would turn this endpoint into an open redirector.
254
+ const requestedRedirect = firstValue(query.redirect_uri);
255
+ let redirectUri;
256
+ if (requestedRedirect) {
257
+ if (!client.redirect_uris.includes(requestedRedirect)) {
258
+ this.sendErrorPage(res, 400, 'Invalid redirect_uri', 'The requested callback address is not registered for this application.');
259
+ return;
260
+ }
261
+ redirectUri = requestedRedirect;
262
+ }
263
+ else if (client.redirect_uris.length === 1) {
264
+ redirectUri = client.redirect_uris[0];
265
+ }
266
+ else {
267
+ this.sendErrorPage(res, 400, 'Missing redirect_uri', 'This application has several registered callback addresses, so the request must name one.');
268
+ return;
269
+ }
270
+ const state = firstValue(query.state);
271
+ const responseType = firstValue(query.response_type);
272
+ if (responseType !== 'code') {
273
+ this.redirectWithError(res, redirectUri, 'unsupported_response_type', 'only "code" is supported', state);
274
+ return;
275
+ }
276
+ const codeChallenge = firstValue(query.code_challenge);
277
+ const codeChallengeMethod = firstValue(query.code_challenge_method);
278
+ if (!codeChallenge) {
279
+ this.redirectWithError(res, redirectUri, 'invalid_request', 'code_challenge is required (PKCE)', state);
280
+ return;
281
+ }
282
+ if (codeChallengeMethod !== 'S256') {
283
+ this.redirectWithError(res, redirectUri, 'invalid_request', 'code_challenge_method must be S256', state);
284
+ return;
285
+ }
286
+ const pending = {
287
+ clientId: client.client_id,
288
+ clientName: client.client_name || client.client_id,
289
+ redirectUri,
290
+ state,
291
+ codeChallenge,
292
+ scope: firstValue(query.scope),
293
+ resource: firstValue(query.resource),
294
+ user: req.user,
295
+ };
296
+ const requestId = (0, node_crypto_1.randomBytes)(32).toString('base64url');
297
+ await this.setSession(`${REQUEST_PREFIX}${requestId}`, REQUEST_TTL_SEC, pending);
298
+ this.sendAuthorizePage(res, requestId, pending);
299
+ }
300
+ /**
301
+ * Handle `POST /oauth/authorize`: the login form submission, the consent decision, or both in
302
+ * sequence.
303
+ *
304
+ * @param req The incoming request
305
+ * @param res The response to write to
306
+ */
307
+ async handleAuthorizeSubmit(req, res) {
308
+ let body;
309
+ try {
310
+ body = await (0, utils_1.readRequestBody)(req);
311
+ }
312
+ catch (e) {
313
+ this.sendErrorPage(res, 400, 'Bad request', e.message);
314
+ return;
315
+ }
316
+ const requestId = typeof body.request_id === 'string' ? body.request_id : '';
317
+ const pending = requestId ? await this.getSession(`${REQUEST_PREFIX}${requestId}`) : null;
318
+ if (!pending) {
319
+ this.sendErrorPage(res, 400, 'Request expired', 'This authorization request is no longer valid. Please start again from the application.');
320
+ return;
321
+ }
322
+ const action = typeof body.action === 'string' ? body.action : '';
323
+ if (action === 'deny') {
324
+ await this.destroySession(`${REQUEST_PREFIX}${requestId}`);
325
+ this.redirectWithError(res, pending.redirectUri, 'access_denied', 'the user denied the request', pending.state);
326
+ return;
327
+ }
328
+ if (action === 'login') {
329
+ const username = typeof body.username === 'string' ? body.username : '';
330
+ const password = typeof body.password === 'string' ? body.password : '';
331
+ const user = await this.model.getUser(username, password);
332
+ if (!user) {
333
+ // Keep the pending request alive so the user can retry without restarting the flow.
334
+ this.sendAuthorizePage(res, requestId, pending, 'Wrong user name or password.');
335
+ return;
336
+ }
337
+ pending.user = user.id;
338
+ await this.setSession(`${REQUEST_PREFIX}${requestId}`, REQUEST_TTL_SEC, pending);
339
+ // Logging in is not consenting — show the consent step now that we know who is asking.
340
+ this.sendAuthorizePage(res, requestId, pending);
341
+ return;
342
+ }
343
+ if (action !== 'allow') {
344
+ this.sendAuthorizePage(res, requestId, pending);
345
+ return;
346
+ }
347
+ if (!pending.user) {
348
+ this.sendAuthorizePage(res, requestId, pending, 'Please log in first.');
349
+ return;
350
+ }
351
+ // Consent given: issue the code and hand control back to the client.
352
+ await this.destroySession(`${REQUEST_PREFIX}${requestId}`);
353
+ const code = (0, node_crypto_1.randomBytes)(32).toString('base64url');
354
+ const stored = {
355
+ clientId: pending.clientId,
356
+ redirectUri: pending.redirectUri,
357
+ codeChallenge: pending.codeChallenge,
358
+ user: pending.user,
359
+ scope: pending.scope,
360
+ resource: pending.resource,
361
+ };
362
+ await this.setSession(`${CODE_PREFIX}${code}`, CODE_TTL_SEC, stored);
363
+ this.adapter.log.info(`Issued OAuth2 authorization code for client "${pending.clientName}" and user "${pending.user}"`);
364
+ const target = new URL(pending.redirectUri);
365
+ target.searchParams.set('code', code);
366
+ if (pending.state !== undefined) {
367
+ target.searchParams.set('state', pending.state);
368
+ }
369
+ res.redirect(target.toString());
370
+ }
371
+ // ----- Token endpoint (authorization_code grant) -----
372
+ /**
373
+ * Redeem an authorization code for tokens. Called from the `/oauth/token` route when the request
374
+ * carries `grant_type=authorization_code`.
375
+ *
376
+ * @param req The incoming request
377
+ * @param res The response to write to
378
+ */
379
+ async handleTokenRequest(req, res) {
380
+ res.set('Cache-Control', 'no-store');
381
+ res.set('Pragma', 'no-cache');
382
+ let body;
383
+ try {
384
+ body = await (0, utils_1.readRequestBody)(req);
385
+ }
386
+ catch (e) {
387
+ res.status(400).json({ error: 'invalid_request', error_description: e.message });
388
+ return;
389
+ }
390
+ const code = typeof body.code === 'string' ? body.code : '';
391
+ const codeVerifier = typeof body.code_verifier === 'string' ? body.code_verifier : '';
392
+ const redirectUri = typeof body.redirect_uri === 'string' ? body.redirect_uri : '';
393
+ const clientId = typeof body.client_id === 'string' ? body.client_id : '';
394
+ if (!code) {
395
+ res.status(400).json({ error: 'invalid_request', error_description: 'code is required' });
396
+ return;
397
+ }
398
+ if (!codeVerifier) {
399
+ res.status(400).json({ error: 'invalid_request', error_description: 'code_verifier is required (PKCE)' });
400
+ return;
401
+ }
402
+ if (!/^[A-Za-z0-9\-._~]{43,128}$/.test(codeVerifier)) {
403
+ res.status(400).json({ error: 'invalid_grant', error_description: 'malformed code_verifier' });
404
+ return;
405
+ }
406
+ const stored = await this.getSession(`${CODE_PREFIX}${code}`);
407
+ // Authorization codes are single-use: drop it before doing anything else, so a replayed or
408
+ // concurrently redeemed code cannot yield a second token.
409
+ await this.destroySession(`${CODE_PREFIX}${code}`);
410
+ if (!stored) {
411
+ res.status(400).json({
412
+ error: 'invalid_grant',
413
+ error_description: 'unknown or expired authorization code',
414
+ });
415
+ return;
416
+ }
417
+ if (clientId && clientId !== stored.clientId) {
418
+ res.status(400).json({ error: 'invalid_grant', error_description: 'client_id does not match the code' });
419
+ return;
420
+ }
421
+ if (redirectUri && redirectUri !== stored.redirectUri) {
422
+ res.status(400).json({ error: 'invalid_grant', error_description: 'redirect_uri does not match the code' });
423
+ return;
424
+ }
425
+ const challenge = (0, node_crypto_1.createHash)('sha256').update(codeVerifier).digest('base64url');
426
+ if (!safeEqual(challenge, stored.codeChallenge)) {
427
+ this.adapter.log.warn(`Rejected OAuth2 token request: PKCE verification failed for client ${stored.clientId}`);
428
+ res.status(400).json({ error: 'invalid_grant', error_description: 'PKCE verification failed' });
429
+ return;
430
+ }
431
+ // RFC 8707: when the client repeats the resource here it must be the one it was authorized for.
432
+ const requestedResource = typeof body.resource === 'string' ? body.resource : undefined;
433
+ if (requestedResource && stored.resource && requestedResource !== stored.resource) {
434
+ res.status(400).json({ error: 'invalid_target', error_description: 'resource does not match the code' });
435
+ return;
436
+ }
437
+ const token = await this.model.generateTokens(stored.user, {
438
+ clientId: stored.clientId,
439
+ aud: stored.resource,
440
+ scope: stored.scope,
441
+ });
442
+ this.adapter.log.debug(`Issued OAuth2 tokens for user "${stored.user}" via authorization code grant`);
443
+ res.json({ ...(0, utils_1.oauthTokenToResponse)(token), scope: stored.scope });
444
+ }
445
+ // ----- Session helpers -----
446
+ /**
447
+ * @param id Session key
448
+ * @param ttl Time to live in seconds
449
+ * @param data Payload to store
450
+ */
451
+ setSession(id, ttl, data) {
452
+ return new Promise((resolve, reject) => this.adapter.setSession(id, ttl, data, err => (err ? reject(err) : resolve())));
453
+ }
454
+ /**
455
+ * @param id Session key
456
+ */
457
+ getSession(id) {
458
+ return new Promise(resolve => this.adapter.getSession(id, (data) => resolve(data || null)));
459
+ }
460
+ /**
461
+ * @param id Session key
462
+ */
463
+ async destroySession(id) {
464
+ try {
465
+ await this.adapter.destroySession(id);
466
+ }
467
+ catch (_a) {
468
+ // A code that is already gone is exactly the state we wanted.
469
+ }
470
+ }
471
+ // ----- Rendering -----
472
+ /**
473
+ * Redirect back to the client with an OAuth2 error (RFC 6749 §4.1.2.1). Only ever called with a
474
+ * redirect URI that was verified against the client's registration.
475
+ *
476
+ * @param res The response to write to
477
+ * @param redirectUri Verified redirect URI
478
+ * @param error OAuth2 error code
479
+ * @param description Human-readable detail
480
+ * @param state The client's `state` value, echoed back unchanged
481
+ */
482
+ redirectWithError(res, redirectUri, error, description, state) {
483
+ const target = new URL(redirectUri);
484
+ target.searchParams.set('error', error);
485
+ target.searchParams.set('error_description', description);
486
+ if (state !== undefined) {
487
+ target.searchParams.set('state', state);
488
+ }
489
+ res.redirect(target.toString());
490
+ }
491
+ /**
492
+ * Answer an unexpected rejection from a route handler instead of letting it escape.
493
+ *
494
+ * These handlers are started from synchronous Express callbacks, so a rejection nobody catches
495
+ * is an unhandled rejection — which terminates the host adapter's process on current Node
496
+ * versions, and leaves the request hanging either way.
497
+ *
498
+ * @param res The response to write to
499
+ * @param handler The already started handler
500
+ * @param json Whether this endpoint answers with JSON rather than an HTML page
501
+ */
502
+ guard(res, handler, json) {
503
+ handler.catch((e) => {
504
+ this.adapter.log.error(`OAuth2 request failed: ${e.message}`);
505
+ if (res.headersSent) {
506
+ return;
507
+ }
508
+ if (json) {
509
+ res.status(500).json({ error: 'server_error' });
510
+ }
511
+ else {
512
+ this.sendErrorPage(res, 500, 'Server error', 'This request could not be processed. Please start again from the application.');
513
+ }
514
+ });
515
+ }
516
+ /**
517
+ * Render the login form or the consent page, depending on whether the request already knows its user.
518
+ *
519
+ * @param res The response to write to
520
+ * @param requestId Identifier of the pending request; doubles as CSRF token
521
+ * @param pending The pending authorization request
522
+ * @param error Optional error message to show above the form
523
+ */
524
+ sendAuthorizePage(res, requestId, pending, error) {
525
+ const clientName = escapeHtml(pending.clientName);
526
+ const errorBlock = error ? `<p class="error">${escapeHtml(error)}</p>` : '';
527
+ const body = pending.user
528
+ ? `<h1>Allow access?</h1>
529
+ <p><strong>${clientName}</strong> is asking for access to your ${escapeHtml(this.productName)} installation.</p>
530
+ <dl>
531
+ <dt>Signed in as</dt><dd>${escapeHtml(pending.user)}</dd>
532
+ ${pending.resource ? `<dt>Resource</dt><dd>${escapeHtml(pending.resource)}</dd>` : ''}
533
+ </dl>
534
+ <p class="hint">The application will be able to act with the permissions of this user.</p>
535
+ ${errorBlock}
536
+ <form method="post" action="authorize">
537
+ <input type="hidden" name="request_id" value="${escapeHtml(requestId)}">
538
+ <div class="buttons">
539
+ <button type="submit" name="action" value="deny" class="secondary">Deny</button>
540
+ <button type="submit" name="action" value="allow" class="primary">Allow</button>
541
+ </div>
542
+ </form>`
543
+ : `<h1>Sign in</h1>
544
+ <p><strong>${clientName}</strong> is asking for access to your ${escapeHtml(this.productName)} installation.</p>
545
+ ${errorBlock}
546
+ <form method="post" action="authorize">
547
+ <input type="hidden" name="request_id" value="${escapeHtml(requestId)}">
548
+ <label for="username">User name</label>
549
+ <input type="text" id="username" name="username" autocomplete="username" autofocus required>
550
+ <label for="password">Password</label>
551
+ <input type="password" id="password" name="password" autocomplete="current-password" required>
552
+ <div class="buttons">
553
+ <button type="submit" name="action" value="deny" class="secondary">Cancel</button>
554
+ <button type="submit" name="action" value="login" class="primary">Sign in</button>
555
+ </div>
556
+ </form>`;
557
+ res.set('Cache-Control', 'no-store');
558
+ res.set('Content-Security-Policy', `default-src 'none'; style-src 'unsafe-inline'; form-action ${formActionSources(pending.redirectUri)}`);
559
+ res.status(200).send(this.htmlPage('Authorize', body));
560
+ }
561
+ /**
562
+ * Render a terminal error page for problems that must not be reported back to the client
563
+ * application (unknown client, bad redirect URI, expired request).
564
+ *
565
+ * @param res The response to write to
566
+ * @param status HTTP status code
567
+ * @param title Short headline
568
+ * @param message Explanation shown to the user
569
+ */
570
+ sendErrorPage(res, status, title, message) {
571
+ res.set('Cache-Control', 'no-store');
572
+ res.status(status).send(this.htmlPage(title, `<h1>${escapeHtml(title)}</h1><p>${escapeHtml(message)}</p>`));
573
+ }
574
+ /**
575
+ * Wrap page content in the shared, dependency-free HTML shell.
576
+ *
577
+ * @param title Document title
578
+ * @param content Already escaped HTML body
579
+ */
580
+ htmlPage(title, content) {
581
+ return `<!DOCTYPE html>
582
+ <html lang="en">
583
+ <head>
584
+ <meta charset="utf-8">
585
+ <meta name="viewport" content="width=device-width, initial-scale=1">
586
+ <title>${escapeHtml(title)} – ${escapeHtml(this.productName)}</title>
587
+ <style>
588
+ :root { color-scheme: light dark; --bg: #f5f5f5; --card: #fff; --fg: #202020; --muted: #666; --line: #d8d8d8; --accent: #3399cc; }
589
+ @media (prefers-color-scheme: dark) {
590
+ :root { --bg: #1a1a1a; --card: #242424; --fg: #e8e8e8; --muted: #9a9a9a; --line: #3a3a3a; }
591
+ }
592
+ * { box-sizing: border-box; }
593
+ body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
594
+ background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
595
+ main { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
596
+ h1 { margin: 0 0 16px; font-size: 20px; font-weight: 600; }
597
+ p { margin: 0 0 16px; }
598
+ .hint, dt { color: var(--muted); font-size: 13px; }
599
+ dl { margin: 0 0 16px; padding: 12px; background: var(--bg); border-radius: 6px; }
600
+ dt { margin-bottom: 2px; }
601
+ dd { margin: 0 0 8px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; word-break: break-all; }
602
+ dd:last-child { margin-bottom: 0; }
603
+ .error { padding: 10px 12px; border-radius: 6px; background: #c0392b1a; color: #c0392b; font-size: 14px; }
604
+ label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
605
+ input[type=text], input[type=password] { width: 100%; margin-bottom: 14px; padding: 9px 11px; border: 1px solid var(--line);
606
+ border-radius: 6px; background: var(--bg); color: var(--fg); font-size: 15px; }
607
+ input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
608
+ .buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
609
+ button { padding: 9px 18px; border-radius: 6px; border: 1px solid var(--line); font-size: 14px; cursor: pointer; }
610
+ button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
611
+ button.secondary { background: transparent; color: var(--fg); }
612
+ </style>
613
+ </head>
614
+ <body><main>${content}</main></body>
615
+ </html>`;
616
+ }
617
+ }
618
+ exports.AuthorizationCodeFlow = AuthorizationCodeFlow;
619
+ //# sourceMappingURL=oauth2-authcode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2-authcode.js","sourceRoot":"","sources":["../../src/lib/oauth2-authcode.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AAIvE,qDAAmF;AACnF,mCAA4E;AAE5E,kHAAkH;AAClH,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,2DAA2D;AAC3D,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,6DAA6D;AAC7D,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,yDAAyD;AACzD,MAAM,WAAW,GAAG,YAAY,CAAC;AAgDjC;;;;GAIG;AACH,SAAS,UAAU,CAAC,IAAY;IAC5B,OAAO,IAAI;SACN,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,SAAS,UAAU,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAA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