pinokiod 3.262.0 → 3.263.0
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/package.json +1 -1
- package/server/views/connect/index.ejs +51 -18
package/package.json
CHANGED
|
@@ -227,23 +227,18 @@
|
|
|
227
227
|
<h1><%=name%> Connect</h1>
|
|
228
228
|
</header>
|
|
229
229
|
<div class="container">
|
|
230
|
-
<div id="status" class="status
|
|
231
|
-
<% if (protocol === "https") { %>
|
|
232
|
-
Checking authentication status...
|
|
233
|
-
<% } %>
|
|
230
|
+
<div id="status" class="status hidden">
|
|
234
231
|
</div>
|
|
235
232
|
|
|
236
|
-
|
|
237
|
-
<
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
</div>
|
|
246
|
-
<% } %>
|
|
233
|
+
<div id="login-section" class="hidden">
|
|
234
|
+
<p>Click below to authenticate with <%=name%>:</p>
|
|
235
|
+
<button class="btn" id="login-button">Login</button>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<div id="http-section" class="hidden">
|
|
239
|
+
<p>Click below to open the secure connection flow:</p>
|
|
240
|
+
<button class='btn' id="get-started-button">Get started</button>
|
|
241
|
+
</div>
|
|
247
242
|
|
|
248
243
|
<div id="user-section" class="hidden">
|
|
249
244
|
<div class="user-info">
|
|
@@ -263,11 +258,13 @@
|
|
|
263
258
|
|
|
264
259
|
<script>
|
|
265
260
|
const CONNECT_NAME = "<%=name%>"
|
|
261
|
+
const isSecureConnectContext = window.location.protocol === 'https:' && window.location.hostname === 'pinokio.localhost'
|
|
266
262
|
const statusElement = document.getElementById('status')
|
|
267
263
|
const loaderElement = document.getElementById('connect-loader')
|
|
268
264
|
const loaderMessageElement = document.getElementById('loader-message')
|
|
269
265
|
const loaderCancelButton = document.getElementById('loader-cancel')
|
|
270
266
|
const loginSection = document.getElementById('login-section')
|
|
267
|
+
const loginButton = document.getElementById('login-button')
|
|
271
268
|
const httpSection = document.getElementById('http-section')
|
|
272
269
|
const userSection = document.getElementById('user-section')
|
|
273
270
|
const userDetailsElement = document.getElementById('user-details')
|
|
@@ -322,6 +319,26 @@
|
|
|
322
319
|
loaderCancelHandler = null
|
|
323
320
|
}
|
|
324
321
|
|
|
322
|
+
function configureInitialView() {
|
|
323
|
+
if (isSecureConnectContext) {
|
|
324
|
+
if (loginSection) {
|
|
325
|
+
loginSection.classList.remove('hidden')
|
|
326
|
+
}
|
|
327
|
+
if (httpSection) {
|
|
328
|
+
httpSection.classList.add('hidden')
|
|
329
|
+
}
|
|
330
|
+
setStatus('Checking authentication status...', 'warning')
|
|
331
|
+
} else {
|
|
332
|
+
if (loginSection) {
|
|
333
|
+
loginSection.classList.add('hidden')
|
|
334
|
+
}
|
|
335
|
+
if (httpSection) {
|
|
336
|
+
httpSection.classList.remove('hidden')
|
|
337
|
+
}
|
|
338
|
+
setStatus('', 'hidden')
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
325
342
|
async function ensureValidToken() {
|
|
326
343
|
try {
|
|
327
344
|
const res = await fetch(`/connect/${CONNECT_NAME}/keys`, {
|
|
@@ -412,13 +429,26 @@
|
|
|
412
429
|
}
|
|
413
430
|
}
|
|
414
431
|
|
|
432
|
+
configureInitialView()
|
|
433
|
+
|
|
434
|
+
if (loginButton) {
|
|
435
|
+
loginButton.addEventListener('click', () => {
|
|
436
|
+
if (typeof window.startOAuthLogin === 'function') {
|
|
437
|
+
window.startOAuthLogin()
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
}
|
|
441
|
+
|
|
415
442
|
window.ensureValidToken = ensureValidToken
|
|
416
443
|
window.fetchUserInfo = fetchUserInfo
|
|
417
444
|
window.logout = logout
|
|
445
|
+
window.startOAuthLogin = () => {
|
|
446
|
+
console.warn('Login flow not available in this context')
|
|
447
|
+
}
|
|
418
448
|
</script>
|
|
419
449
|
|
|
420
|
-
<% if (protocol === "https") { %>
|
|
421
450
|
<script>
|
|
451
|
+
if (isSecureConnectContext) {
|
|
422
452
|
|
|
423
453
|
// Configuration
|
|
424
454
|
|
|
@@ -598,9 +628,12 @@
|
|
|
598
628
|
// Export makeAuthenticatedRequest for external use
|
|
599
629
|
window.makeAuthenticatedRequest = makeAuthenticatedRequest;
|
|
600
630
|
window.ensureValidToken = ensureValidToken;
|
|
631
|
+
window.startOAuthLogin = login;
|
|
632
|
+
}
|
|
601
633
|
</script>
|
|
602
|
-
|
|
634
|
+
|
|
603
635
|
<script>
|
|
636
|
+
if (!isSecureConnectContext) {
|
|
604
637
|
const SECURE_CONNECT_URL = 'https://pinokio.localhost/connect/<%=name%>'
|
|
605
638
|
const CONNECT_POLL_INTERVAL = 4000
|
|
606
639
|
const CONNECT_TIMEOUT = 120000
|
|
@@ -668,7 +701,7 @@
|
|
|
668
701
|
await fetchUserInfo(token)
|
|
669
702
|
}
|
|
670
703
|
})
|
|
704
|
+
}
|
|
671
705
|
</script>
|
|
672
|
-
<% } %>
|
|
673
706
|
</body>
|
|
674
707
|
</html>
|