@knowcode/doc-builder 1.2.1 → 1.2.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.
@@ -1,65 +0,0 @@
1
- /**
2
- * Simple Client-Side Authentication for JUNO Documentation
3
- * This runs on every page load to check authentication
4
- */
5
-
6
- (function() {
7
- 'use strict';
8
-
9
- // Skip auth check on login and logout pages
10
- const currentPage = window.location.pathname;
11
- if (currentPage === '/login.html' || currentPage === '/logout.html' || currentPage.includes('login') || currentPage.includes('logout')) {
12
- return;
13
- }
14
-
15
- // Check if user is authenticated
16
- function isAuthenticated() {
17
- const authToken = getCookie('juno-auth');
18
- if (!authToken) return false;
19
-
20
- try {
21
- // Decode and validate token
22
- const decoded = atob(authToken);
23
- const [username, password] = decoded.split(':');
24
-
25
- // Check against valid credentials
26
- return username === 'juno' && password === 'docs2025';
27
- } catch (error) {
28
- return false;
29
- }
30
- }
31
-
32
- // Get cookie value
33
- function getCookie(name) {
34
- const value = `; ${document.cookie}`;
35
- const parts = value.split(`; ${name}=`);
36
- if (parts.length === 2) return parts.pop().split(';').shift();
37
- return null;
38
- }
39
-
40
- // Redirect to login if not authenticated
41
- function redirectToLogin() {
42
- const currentUrl = window.location.pathname + window.location.search;
43
- const loginUrl = '/login.html' + (currentUrl !== '/' ? '?redirect=' + encodeURIComponent(currentUrl) : '');
44
- window.location.href = loginUrl;
45
- }
46
-
47
- // Check authentication on page load
48
- if (!isAuthenticated()) {
49
- redirectToLogin();
50
- }
51
-
52
- // Add logout functionality to logout buttons
53
- document.addEventListener('DOMContentLoaded', function() {
54
- const logoutLinks = document.querySelectorAll('a[href*="logout"]');
55
- logoutLinks.forEach(link => {
56
- link.addEventListener('click', function(e) {
57
- e.preventDefault();
58
- // Clear auth cookie
59
- document.cookie = 'juno-auth=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
60
- window.location.href = '/logout.html';
61
- });
62
- });
63
- });
64
-
65
- })();