pinokiod 3.262.0 → 3.264.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 +52 -24
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`, {
|
|
@@ -400,25 +417,33 @@
|
|
|
400
417
|
setStatus('Failed to logout: ' + err.message, 'error')
|
|
401
418
|
} finally {
|
|
402
419
|
hideLoader()
|
|
403
|
-
if (loginSection) {
|
|
404
|
-
loginSection.classList.remove('hidden')
|
|
405
|
-
}
|
|
406
|
-
if (httpSection) {
|
|
407
|
-
httpSection.classList.remove('hidden')
|
|
408
|
-
}
|
|
409
420
|
if (userSection) {
|
|
410
421
|
userSection.classList.add('hidden')
|
|
411
422
|
}
|
|
423
|
+
configureInitialView()
|
|
412
424
|
}
|
|
413
425
|
}
|
|
414
426
|
|
|
427
|
+
configureInitialView()
|
|
428
|
+
|
|
429
|
+
if (loginButton) {
|
|
430
|
+
loginButton.addEventListener('click', () => {
|
|
431
|
+
if (typeof window.startOAuthLogin === 'function') {
|
|
432
|
+
window.startOAuthLogin()
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
}
|
|
436
|
+
|
|
415
437
|
window.ensureValidToken = ensureValidToken
|
|
416
438
|
window.fetchUserInfo = fetchUserInfo
|
|
417
439
|
window.logout = logout
|
|
440
|
+
window.startOAuthLogin = () => {
|
|
441
|
+
console.warn('Login flow not available in this context')
|
|
442
|
+
}
|
|
418
443
|
</script>
|
|
419
444
|
|
|
420
|
-
<% if (protocol === "https") { %>
|
|
421
445
|
<script>
|
|
446
|
+
if (isSecureConnectContext) {
|
|
422
447
|
|
|
423
448
|
// Configuration
|
|
424
449
|
|
|
@@ -598,9 +623,12 @@
|
|
|
598
623
|
// Export makeAuthenticatedRequest for external use
|
|
599
624
|
window.makeAuthenticatedRequest = makeAuthenticatedRequest;
|
|
600
625
|
window.ensureValidToken = ensureValidToken;
|
|
626
|
+
window.startOAuthLogin = login;
|
|
627
|
+
}
|
|
601
628
|
</script>
|
|
602
|
-
|
|
629
|
+
|
|
603
630
|
<script>
|
|
631
|
+
if (!isSecureConnectContext) {
|
|
604
632
|
const SECURE_CONNECT_URL = 'https://pinokio.localhost/connect/<%=name%>'
|
|
605
633
|
const CONNECT_POLL_INTERVAL = 4000
|
|
606
634
|
const CONNECT_TIMEOUT = 120000
|
|
@@ -668,7 +696,7 @@
|
|
|
668
696
|
await fetchUserInfo(token)
|
|
669
697
|
}
|
|
670
698
|
})
|
|
699
|
+
}
|
|
671
700
|
</script>
|
|
672
|
-
<% } %>
|
|
673
701
|
</body>
|
|
674
702
|
</html>
|