@knowcode/doc-builder 1.7.6 → 1.8.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.
Files changed (42) hide show
  1. package/.claude/settings.local.json +3 -1
  2. package/CHANGELOG.md +22 -0
  3. package/assets/css/notion-style.css +9 -1
  4. package/html/README.html +5 -19
  5. package/html/css/notion-style.css +9 -1
  6. package/html/documentation-index.html +5 -19
  7. package/html/guides/authentication-default-change.html +5 -19
  8. package/html/guides/authentication-guide.html +189 -262
  9. package/html/guides/claude-workflow-guide.html +5 -19
  10. package/html/guides/documentation-standards.html +5 -19
  11. package/html/guides/phosphor-icons-guide.html +5 -19
  12. package/html/guides/private-directory-authentication.html +352 -0
  13. package/html/guides/public-site-deployment.html +11 -24
  14. package/html/guides/search-engine-verification-guide.html +5 -19
  15. package/html/guides/seo-guide.html +5 -19
  16. package/html/guides/seo-optimization-guide.html +5 -19
  17. package/html/guides/troubleshooting-guide.html +5 -19
  18. package/html/guides/windows-setup-guide.html +5 -19
  19. package/html/index.html +5 -19
  20. package/html/private/cache-control-anti-pattern.html +347 -0
  21. package/html/private/launch/README.html +289 -0
  22. package/html/private/launch/auth-cleanup-summary.html +279 -0
  23. package/html/private/launch/bubble-plugin-specification.html +925 -0
  24. package/html/private/launch/go-to-market-strategy.html +655 -0
  25. package/html/private/launch/launch-announcements.html +585 -0
  26. package/html/private/launch/vercel-deployment-auth-setup.html +329 -0
  27. package/html/private/next-steps-walkthrough.html +624 -0
  28. package/html/private/supabase-auth-implementation-completed.html +372 -0
  29. package/html/private/supabase-auth-implementation-plan.html +529 -0
  30. package/html/private/supabase-auth-integration-plan.html +657 -0
  31. package/html/private/supabase-auth-setup-guide.html +484 -0
  32. package/html/private/test-private-doc.html +220 -0
  33. package/html/sitemap.xml +113 -29
  34. package/html/vercel-cli-setup-guide.html +5 -19
  35. package/html/vercel-first-time-setup-guide.html +5 -19
  36. package/lib/config.js +24 -0
  37. package/lib/core-builder.js +40 -6
  38. package/lib/supabase-auth.js +60 -11
  39. package/package.json +1 -1
  40. package/user-management/README.md +81 -0
  41. package/user-management/add-users.sh +357 -0
  42. package/user-management/users.txt +15 -0
@@ -0,0 +1,657 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="description" content="Transform @knowcode/doc-builder from basic client-side authentication to a sophisticated, centralized authentication system powered by Supabase that enables:">
7
+ <title>Supabase Authentication Integration Plan for @k...</title>
8
+
9
+ <meta name="author" content="Lindsay Smith">
10
+ <meta name="keywords" content="documentation, markdown, static site generator, vercel, notion-style, authentication, security">
11
+ <meta name="robots" content="index, follow">
12
+ <link rel="canonical" href="https://doc-builder-delta.vercel.app/private/supabase-auth-integration-plan.html">
13
+
14
+ <!-- Open Graph / Facebook -->
15
+ <meta property="og:type" content="article">
16
+ <meta property="og:url" content="https://doc-builder-delta.vercel.app/private/supabase-auth-integration-plan.html">
17
+ <meta property="og:title" content="Supabase Authentication Integration Plan for @k...">
18
+ <meta property="og:description" content="Transform @knowcode/doc-builder from basic client-side authentication to a sophisticated, centralized authentication system powered by Supabase that enables:">
19
+ <meta property="og:image" content="https://doc-builder-delta.vercel.app/og-default.png">
20
+ <meta property="og:site_name" content="@knowcode/doc-builder">
21
+ <meta property="og:locale" content="en_US">
22
+
23
+ <!-- Twitter Card -->
24
+ <meta name="twitter:card" content="summary_large_image">
25
+ <meta name="twitter:site" content="@planbbackups">
26
+ <meta name="twitter:creator" content="@planbbackups">
27
+ <meta name="twitter:title" content="Supabase Authentication Integration Plan for @k...">
28
+ <meta name="twitter:description" content="Transform @knowcode/doc-builder from basic client-side authentication to a sophisticated, centralized authentication system powered by Supabase that enables:">
29
+ <meta name="twitter:image" content="https://doc-builder-delta.vercel.app/og-default.png">
30
+
31
+ <!-- Custom Meta Tags -->
32
+ <meta name="google-site-verification" content="FtzcDTf5BQ9K5EfnGazQkgU2U4FiN3ITzM7gHwqUAqQ">
33
+ <meta name="msvalidate.01" content="B2D8C4C12C530D47AA962B24CAA09630">
34
+
35
+ <!-- Fonts -->
36
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
37
+
38
+ <!-- Icons -->
39
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
40
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@phosphor-icons/web@2.1.1/src/regular/style.css">
41
+
42
+ <!-- Mermaid -->
43
+ <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
44
+
45
+ <!-- Styles -->
46
+ <link rel="stylesheet" href="/css/notion-style.css">
47
+
48
+
49
+
50
+ <!-- Favicon -->
51
+ <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>✨</text></svg>">
52
+
53
+ <script type="application/ld+json">
54
+ {
55
+ "@context": "https://schema.org",
56
+ "@type": "TechArticle",
57
+ "headline": "Supabase Authentication Integration Plan for @knowcode/doc-builder",
58
+ "description": "Transform @knowcode/doc-builder from basic client-side authentication to a sophisticated, centralized authentication system powered by Supabase that enables:",
59
+ "author": {
60
+ "@type": "Person",
61
+ "name": "Lindsay Smith"
62
+ },
63
+ "publisher": {
64
+ "@type": "Organization",
65
+ "name": "Knowcode Ltd",
66
+ "url": "https://knowcode.tech"
67
+ },
68
+ "datePublished": "2025-07-26T09:59:23.010Z",
69
+ "dateModified": "2025-07-26T09:59:23.010Z",
70
+ "mainEntityOfPage": {
71
+ "@type": "WebPage",
72
+ "@id": "https://doc-builder-delta.vercel.app/private/supabase-auth-integration-plan.html"
73
+ },
74
+ "breadcrumb": {
75
+ "@type": "BreadcrumbList",
76
+ "itemListElement": [
77
+ {
78
+ "@type": "ListItem",
79
+ "position": 1,
80
+ "name": "@knowcode/doc-builder",
81
+ "item": "https://doc-builder-delta.vercel.app"
82
+ },
83
+ {
84
+ "@type": "ListItem",
85
+ "position": 2,
86
+ "name": "Private",
87
+ "item": "https://doc-builder-delta.vercel.app/private/"
88
+ },
89
+ {
90
+ "@type": "ListItem",
91
+ "position": 3,
92
+ "name": "Supabase Auth Integration Plan",
93
+ "item": "https://doc-builder-delta.vercel.app/private/supabase-auth-integration-plan.html"
94
+ }
95
+ ]
96
+ }
97
+ }
98
+ </script>
99
+ </head>
100
+ <body>
101
+ <!-- Header -->
102
+ <header class="header">
103
+ <div class="header-content">
104
+ <a href="/index.html" class="logo">@knowcode/doc-builder</a>
105
+
106
+ <div class="header-actions">
107
+ <div class="deployment-info">
108
+ <span class="deployment-date" title="Built with doc-builder v1.8.0">Last updated: Jul 26, 2025, 09:59 AM UTC</span>
109
+ </div>
110
+
111
+
112
+
113
+ <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
114
+ <i class="fas fa-moon"></i>
115
+ </button>
116
+
117
+ <button id="menu-toggle" class="menu-toggle" aria-label="Toggle menu">
118
+ <i class="fas fa-bars"></i>
119
+ </button>
120
+ </div>
121
+ </div>
122
+ </header>
123
+
124
+ <!-- Preview Banner -->
125
+ <div id="preview-banner" class="preview-banner">
126
+ <div class="banner-content">
127
+ <i class="fas fa-exclamation-triangle banner-icon"></i>
128
+ <span class="banner-text">This documentation is a preview version - some content may be incomplete</span>
129
+ <button id="dismiss-banner" class="banner-dismiss" aria-label="Dismiss banner">
130
+ <i class="fas fa-times"></i>
131
+ </button>
132
+ </div>
133
+ </div>
134
+
135
+ <!-- Breadcrumbs -->
136
+ <nav class="breadcrumbs" id="breadcrumbs">
137
+ <!-- Breadcrumbs will be generated by JavaScript -->
138
+ </nav>
139
+
140
+ <!-- Main Content -->
141
+ <div class="main-wrapper">
142
+ <!-- Sidebar -->
143
+ <aside class="sidebar">
144
+ <div class="sidebar-header">
145
+ <div class="filter-box">
146
+ <input type="text" placeholder="Filter items..." class="filter-input" id="nav-filter">
147
+ <i class="fas fa-search filter-icon"></i>
148
+ </div>
149
+ </div>
150
+ <nav class="navigation">
151
+
152
+ <div class="nav-section" data-level="0">
153
+ <a class="nav-title" href="/README.html" >
154
+ <i class="fas fa-home"></i> Documentation
155
+ </a>
156
+ <div class="nav-content" >
157
+ <a href="/README.html" class="nav-item" data-tooltip="@knowcode/doc-builder."><i class="fas fa-file-alt"></i> Overview</a>
158
+ <a href="/documentation-index.html" class="nav-item" data-tooltip="This directory contains additional documentation for the @knowcode/doc-builder project, organized by topic and purpose."><i class="fas fa-file-alt"></i> Documentation Index</a>
159
+ <a href="/vercel-cli-setup-guide.html" class="nav-item" data-tooltip="This guide provides comprehensive instructions for installing the Vercel CLI across different operating systems."><i class="fas fa-file-alt"></i> Vercel Cli Setup Guide</a>
160
+ <a href="/vercel-first-time-setup-guide.html" class="nav-item" data-tooltip="This guide walks you through the Vercel deployment process when using ."><i class="fas fa-file-alt"></i> Vercel First Time Setup Guide</a></div></div>
161
+ <div class="nav-section" data-level="1">
162
+ <a class="nav-title collapsible" href="#" data-target="nav-guides-1" >
163
+ <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Guides
164
+ </a>
165
+ <div class="nav-content collapsed" id="nav-guides-1">
166
+ <a href="/guides/authentication-default-change.html" class="nav-item" data-tooltip="Starting from version 1.7.4, @knowcode/doc-builder now defaults to no authentication for all documentation sites."><i class="fas fa-file-alt"></i> Authentication Default Change</a>
167
+ <a href="/guides/authentication-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform."><i class="fas fa-file-alt"></i> Authentication Guide</a>
168
+ <a href="/guides/claude-workflow-guide.html" class="nav-item" data-tooltip="This guide demonstrates an efficient workflow for using Claude Code with a refined CLAUDE.md file to create high-quality documentation and deploy it..."><i class="fas fa-file-alt"></i> Claude Workflow Guide</a>
169
+ <a href="/guides/documentation-standards.html" class="nav-item" data-tooltip="This document defines the documentation standards and conventions for the @knowcode/doc-builder project."><i class="fas fa-file-alt"></i> Documentation Standards</a>
170
+ <a href="/guides/phosphor-icons-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder automatically converts Unicode emojis in your markdown files to beautiful Phosphor icons in the generated HTML."><i class="fas fa-file-alt"></i> Phosphor Icons Guide</a>
171
+ <a href="/guides/private-directory-authentication.html" class="nav-item" data-tooltip="The @knowcode/doc-builder now includes automatic authentication for documents placed in a directory."><i class="fas fa-file-alt"></i> Private Directory Authentication</a>
172
+ <a href="/guides/public-site-deployment.html" class="nav-item" data-tooltip="The @knowcode/doc-builder now supports deploying public documentation sites without authentication."><i class="fas fa-file-alt"></i> Public Site Deployment</a>
173
+ <a href="/guides/search-engine-verification-guide.html" class="nav-item" data-tooltip="Search engine verification provides access to powerful webmaster tools:."><i class="fas fa-file-alt"></i> Search Engine Verification Guide</a>
174
+ <a href="/guides/seo-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder includes comprehensive SEO (Search Engine Optimization) features to help your documentation rank better in search results and..."><i class="fas fa-file-alt"></i> Seo Guide</a>
175
+ <a href="/guides/seo-optimization-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder includes comprehensive SEO (Search Engine Optimization) features that automatically optimize your documentation for search..."><i class="fas fa-file-alt"></i> Seo Optimization Guide</a>
176
+ <a href="/guides/troubleshooting-guide.html" class="nav-item" data-tooltip="This guide helps you resolve common issues when using @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Troubleshooting Guide</a>
177
+ <a href="/guides/windows-setup-guide.html" class="nav-item" data-tooltip="This guide helps Windows users set up the complete AI-powered documentation workflow using Claude Code, @knowcode/doc-builder, and Vercel."><i class="fas fa-file-alt"></i> Windows Setup Guide</a></div></div>
178
+ </nav>
179
+ <div class="resize-handle"></div>
180
+ </aside>
181
+
182
+ <!-- Content Area -->
183
+ <main class="content">
184
+ <div class="content-inner">
185
+ <h1>Supabase Authentication Integration Plan for @knowcode/doc-builder</h1>
186
+ <h2>Vision</h2>
187
+ <p>Transform @knowcode/doc-builder from basic client-side authentication to a sophisticated, centralized authentication system powered by Supabase that enables:</p>
188
+ <ul>
189
+ <li><strong>Single Sign-On (SSO)</strong> across all deployed documentation sites</li>
190
+ <li><strong>Multi-tenant support</strong> with fine-grained access control</li>
191
+ <li><strong>Enterprise-grade security</strong> with JWT tokens and Row Level Security</li>
192
+ <li><strong>Scalable user management</strong> for teams of any size</li>
193
+ <li><strong>Audit logging</strong> for compliance and security</li>
194
+ </ul>
195
+ <h2>Architecture Overview</h2>
196
+ <div class="mermaid-wrapper">
197
+ <div class="mermaid">graph TB
198
+ subgraph "Supabase Cloud"
199
+ DB[(PostgreSQL)]
200
+ AUTH[Auth Service]
201
+ RLS[Row Level Security]
202
+
203
+ DB --> |Protected by| RLS
204
+ AUTH --> |Issues| JWT[JWT Tokens]
205
+ end
206
+
207
+ subgraph "Documentation Sites"
208
+ Site1[docs.company1.com]
209
+ Site2[docs.company2.com]
210
+ Site3[internal.docs.com]
211
+ end
212
+
213
+ subgraph "Client Browser"
214
+ SDK[Supabase JS SDK]
215
+ Cookie[Secure Cookie]
216
+ end
217
+
218
+ AUTH --> SDK
219
+ SDK --> Cookie
220
+ Cookie --> Site1
221
+ Cookie --> Site2
222
+ Cookie --> Site3
223
+
224
+ style AUTH fill:#4ade80
225
+ style DB fill:#60a5fa
226
+ style RLS fill:#f87171</div>
227
+ </div>
228
+ <h2>Database Schema</h2>
229
+ <h3>Core Tables</h3>
230
+ <pre><code class="language-sql">-- Organizations table
231
+ CREATE TABLE organizations (
232
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
233
+ name TEXT NOT NULL,
234
+ slug TEXT UNIQUE NOT NULL,
235
+ created_at TIMESTAMPTZ DEFAULT NOW(),
236
+ settings JSONB DEFAULT &#39;{}&#39;::jsonb
237
+ );
238
+
239
+ -- Documentation sites table
240
+ CREATE TABLE doc_sites (
241
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
242
+ org_id UUID REFERENCES organizations(id),
243
+ name TEXT NOT NULL,
244
+ domain TEXT UNIQUE NOT NULL,
245
+ config JSONB DEFAULT &#39;{}&#39;::jsonb,
246
+ created_at TIMESTAMPTZ DEFAULT NOW(),
247
+ is_active BOOLEAN DEFAULT true
248
+ );
249
+
250
+ -- User access table (many-to-many)
251
+ CREATE TABLE user_site_access (
252
+ user_id UUID REFERENCES auth.users(id),
253
+ site_id UUID REFERENCES doc_sites(id),
254
+ role TEXT NOT NULL DEFAULT &#39;viewer&#39;,
255
+ granted_at TIMESTAMPTZ DEFAULT NOW(),
256
+ granted_by UUID REFERENCES auth.users(id),
257
+ expires_at TIMESTAMPTZ,
258
+ PRIMARY KEY (user_id, site_id)
259
+ );
260
+
261
+ -- Access logs for audit trail
262
+ CREATE TABLE access_logs (
263
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
264
+ user_id UUID REFERENCES auth.users(id),
265
+ site_id UUID REFERENCES doc_sites(id),
266
+ action TEXT NOT NULL,
267
+ metadata JSONB DEFAULT &#39;{}&#39;::jsonb,
268
+ ip_address INET,
269
+ user_agent TEXT,
270
+ created_at TIMESTAMPTZ DEFAULT NOW()
271
+ );
272
+
273
+ -- Invitation links
274
+ CREATE TABLE invitations (
275
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
276
+ site_id UUID REFERENCES doc_sites(id),
277
+ email TEXT NOT NULL,
278
+ role TEXT NOT NULL DEFAULT &#39;viewer&#39;,
279
+ token TEXT UNIQUE NOT NULL,
280
+ created_by UUID REFERENCES auth.users(id),
281
+ created_at TIMESTAMPTZ DEFAULT NOW(),
282
+ expires_at TIMESTAMPTZ NOT NULL,
283
+ claimed_at TIMESTAMPTZ,
284
+ claimed_by UUID REFERENCES auth.users(id)
285
+ );
286
+ </code></pre>
287
+ <h3>Row Level Security Policies</h3>
288
+ <pre><code class="language-sql">-- Users can only see sites they have access to
289
+ CREATE POLICY &quot;Users can view accessible sites&quot; ON doc_sites
290
+ FOR SELECT USING (
291
+ EXISTS (
292
+ SELECT 1 FROM user_site_access
293
+ WHERE site_id = doc_sites.id
294
+ AND user_id = auth.uid()
295
+ AND (expires_at IS NULL OR expires_at &gt; NOW())
296
+ )
297
+ );
298
+
299
+ -- Access logs are append-only
300
+ CREATE POLICY &quot;Insert access logs&quot; ON access_logs
301
+ FOR INSERT WITH CHECK (user_id = auth.uid());
302
+
303
+ -- Users can view their own access logs
304
+ CREATE POLICY &quot;View own access logs&quot; ON access_logs
305
+ FOR SELECT USING (user_id = auth.uid());
306
+ </code></pre>
307
+ <h2>Implementation Architecture</h2>
308
+ <h3>1. Authentication Flow</h3>
309
+ <div class="mermaid-wrapper">
310
+ <div class="mermaid">sequenceDiagram
311
+ participant User
312
+ participant DocSite
313
+ participant SupabaseSDK
314
+ participant SupabaseAuth
315
+ participant Database
316
+
317
+ User->>DocSite: Visit protected page
318
+ DocSite->>SupabaseSDK: Check session
319
+
320
+ alt No valid session
321
+ SupabaseSDK-->>DocSite: No session
322
+ DocSite->>User: Redirect to login
323
+ User->>DocSite: Enter credentials
324
+ DocSite->>SupabaseAuth: signInWithPassword()
325
+ SupabaseAuth->>Database: Verify credentials
326
+ Database-->>SupabaseAuth: User data + access
327
+ SupabaseAuth-->>DocSite: JWT token
328
+ DocSite->>DocSite: Store in secure cookie
329
+ end
330
+
331
+ DocSite->>Database: Check site access
332
+ Database-->>DocSite: Access granted/denied
333
+
334
+ alt Access granted
335
+ DocSite->>User: Show documentation
336
+ DocSite->>Database: Log access
337
+ else Access denied
338
+ DocSite->>User: Show 403 error
339
+ end</div>
340
+ </div>
341
+ <h3>2. Client-Side Implementation</h3>
342
+ <pre><code class="language-javascript">// lib/supabase-auth.js
343
+ import { createClient } from &#39;@supabase/supabase-js&#39;;
344
+
345
+ class SupabaseAuthManager {
346
+ constructor(config) {
347
+ this.supabase = createClient(
348
+ config.supabaseUrl,
349
+ config.supabaseAnonKey,
350
+ {
351
+ auth: {
352
+ persistSession: true,
353
+ autoRefreshToken: true,
354
+ detectSessionInUrl: true
355
+ }
356
+ }
357
+ );
358
+ this.siteId = config.siteId;
359
+ }
360
+
361
+ async checkAccess() {
362
+ const { data: { user } } = await this.supabase.auth.getUser();
363
+ if (!user) return false;
364
+
365
+ const { data, error } = await this.supabase
366
+ .from(&#39;user_site_access&#39;)
367
+ .select(&#39;role, expires_at&#39;)
368
+ .eq(&#39;user_id&#39;, user.id)
369
+ .eq(&#39;site_id&#39;, this.siteId)
370
+ .single();
371
+
372
+ if (error || !data) return false;
373
+ if (data.expires_at &amp;&amp; new Date(data.expires_at) &lt; new Date()) return false;
374
+
375
+ // Log access
376
+ await this.logAccess(&#39;page_view&#39;);
377
+
378
+ return data;
379
+ }
380
+
381
+ async signIn(email, password) {
382
+ const { data, error } = await this.supabase.auth.signInWithPassword({
383
+ email,
384
+ password
385
+ });
386
+
387
+ if (error) throw error;
388
+
389
+ // Check if user has access to this site
390
+ const access = await this.checkAccess();
391
+ if (!access) {
392
+ await this.supabase.auth.signOut();
393
+ throw new Error(&#39;You do not have access to this documentation site&#39;);
394
+ }
395
+
396
+ return data;
397
+ }
398
+
399
+ async signInWithMagicLink(email) {
400
+ const { error } = await this.supabase.auth.signInWithOtp({
401
+ email,
402
+ options: {
403
+ emailRedirectTo: window.location.origin
404
+ }
405
+ });
406
+
407
+ if (error) throw error;
408
+ }
409
+
410
+ async logAccess(action, metadata = {}) {
411
+ await this.supabase.from(&#39;access_logs&#39;).insert({
412
+ site_id: this.siteId,
413
+ action,
414
+ metadata,
415
+ ip_address: await this.getClientIP(),
416
+ user_agent: navigator.userAgent
417
+ });
418
+ }
419
+ }
420
+ </code></pre>
421
+ <h3>3. Build-Time Integration</h3>
422
+ <pre><code class="language-javascript">// lib/core-builder.js modifications
423
+ async function buildWithSupabaseAuth(config) {
424
+ if (config.features.authentication === &#39;supabase&#39;) {
425
+ // Inject Supabase configuration
426
+ const supabaseConfig = {
427
+ supabaseUrl: config.auth.supabaseUrl,
428
+ supabaseAnonKey: config.auth.supabaseAnonKey,
429
+ siteId: config.auth.siteId
430
+ };
431
+
432
+ // Create enhanced auth.js with Supabase integration
433
+ const authScript = generateSupabaseAuthScript(supabaseConfig);
434
+ await fs.writeFile(
435
+ path.join(outputDir, &#39;js&#39;, &#39;auth.js&#39;),
436
+ authScript
437
+ );
438
+
439
+ // Create login page with Supabase UI
440
+ const loginPage = generateSupabaseLoginPage(config);
441
+ await fs.writeFile(
442
+ path.join(outputDir, &#39;login.html&#39;),
443
+ loginPage
444
+ );
445
+
446
+ // Add Supabase SDK to dependencies
447
+ await injectSupabaseSDK(outputDir);
448
+ }
449
+ }
450
+ </code></pre>
451
+ <h2>Configuration Options</h2>
452
+ <h3>Enhanced doc-builder.config.js</h3>
453
+ <pre><code class="language-javascript">module.exports = {
454
+ siteName: &#39;Internal Documentation&#39;,
455
+
456
+ features: {
457
+ authentication: &#39;supabase&#39;, // &#39;basic&#39; | &#39;supabase&#39; | false
458
+ },
459
+
460
+ auth: {
461
+ // Supabase configuration
462
+ supabaseUrl: process.env.SUPABASE_URL,
463
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
464
+ siteId: process.env.DOC_SITE_ID,
465
+
466
+ // Optional: Custom login page styling
467
+ loginTheme: {
468
+ logo: &#39;/assets/logo.png&#39;,
469
+ primaryColor: &#39;#4F46E5&#39;,
470
+ backgroundImage: &#39;/assets/login-bg.jpg&#39;
471
+ },
472
+
473
+ // Optional: Authentication providers
474
+ providers: [&#39;email&#39;, &#39;google&#39;, &#39;github&#39;],
475
+
476
+ // Optional: Custom redirect after login
477
+ redirectUrl: &#39;/&#39;,
478
+
479
+ // Optional: Require email verification
480
+ requireEmailVerification: false,
481
+
482
+ // Optional: Session timeout (minutes)
483
+ sessionTimeout: 1440, // 24 hours
484
+
485
+ // Optional: Enable SSO
486
+ sso: {
487
+ enabled: true,
488
+ domain: &#39;company.com&#39;
489
+ }
490
+ }
491
+ };
492
+ </code></pre>
493
+ <h2>Migration Strategy</h2>
494
+ <h3>Phase 1: Backward Compatibility (Week 1-2)</h3>
495
+ <ol>
496
+ <li>Add Supabase as optional authentication method</li>
497
+ <li>Keep existing basic auth as default</li>
498
+ <li>Allow configuration to choose auth type</li>
499
+ <li>No breaking changes to existing deployments</li>
500
+ </ol>
501
+ <h3>Phase 2: Feature Parity (Week 3-4)</h3>
502
+ <ol>
503
+ <li>Implement core Supabase authentication</li>
504
+ <li>Add login/logout pages with Supabase UI</li>
505
+ <li>Implement access checking</li>
506
+ <li>Add basic user management CLI commands</li>
507
+ </ol>
508
+ <h3>Phase 3: Advanced Features (Week 5-6)</h3>
509
+ <ol>
510
+ <li>Multi-site SSO support</li>
511
+ <li>Role-based access control</li>
512
+ <li>Invitation system</li>
513
+ <li>Audit logging</li>
514
+ <li>Admin dashboard</li>
515
+ </ol>
516
+ <h3>Phase 4: Migration Tools (Week 7-8)</h3>
517
+ <ol>
518
+ <li>Migration script from basic auth to Supabase</li>
519
+ <li>Bulk user import</li>
520
+ <li>Documentation and guides</li>
521
+ <li>Deprecation notices for basic auth</li>
522
+ </ol>
523
+ <h2>CLI Commands</h2>
524
+ <h3>New Authentication Commands</h3>
525
+ <pre><code class="language-bash"># Initialize Supabase auth for a project
526
+ npx @knowcode/doc-builder auth init
527
+
528
+ # Add a user to documentation site
529
+ npx @knowcode/doc-builder auth add-user email@example.com --role editor
530
+
531
+ # Generate invitation link
532
+ npx @knowcode/doc-builder auth invite email@example.com --expires 7d
533
+
534
+ # List users with access
535
+ npx @knowcode/doc-builder auth list-users
536
+
537
+ # Revoke access
538
+ npx @knowcode/doc-builder auth revoke email@example.com
539
+
540
+ # View access logs
541
+ npx @knowcode/doc-builder auth logs --days 30
542
+ </code></pre>
543
+ <h2>Security Benefits</h2>
544
+ <h3>Current Basic Auth Vulnerabilities</h3>
545
+ <ul>
546
+ <li><i class="ph ph-x-circle" aria-label="error"></i> Credentials visible in browser</li>
547
+ <li><i class="ph ph-x-circle" aria-label="error"></i> No password hashing</li>
548
+ <li><i class="ph ph-x-circle" aria-label="error"></i> No session management</li>
549
+ <li><i class="ph ph-x-circle" aria-label="error"></i> No audit trail</li>
550
+ <li><i class="ph ph-x-circle" aria-label="error"></i> Single shared password</li>
551
+ </ul>
552
+ <h3>Supabase Auth Security</h3>
553
+ <ul>
554
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> Server-side authentication</li>
555
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> Bcrypt password hashing</li>
556
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> JWT tokens with expiration</li>
557
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> Row Level Security</li>
558
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> Comprehensive audit logs</li>
559
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> Multi-factor authentication support</li>
560
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> OAuth provider support</li>
561
+ </ul>
562
+ <h2>Cost Analysis</h2>
563
+ <h3>Supabase Free Tier</h3>
564
+ <ul>
565
+ <li>50,000 Monthly Active Users</li>
566
+ <li>Unlimited authentication providers</li>
567
+ <li>Row Level Security</li>
568
+ <li>Real-time subscriptions</li>
569
+ </ul>
570
+ <h3>Estimated Usage</h3>
571
+ <ul>
572
+ <li>Small teams (&lt; 100 users): <strong>Free</strong></li>
573
+ <li>Medium organizations (&lt; 5,000 users): <strong>Free</strong></li>
574
+ <li>Large enterprises (&lt; 50,000 users): <strong>Free</strong></li>
575
+ <li>Very large (&gt; 50,000 users): <strong>$25/month</strong> Pro tier</li>
576
+ </ul>
577
+ <h2>Implementation Timeline</h2>
578
+ <h3>Week 1-2: Foundation</h3>
579
+ <ul>
580
+ <li><input disabled="" type="checkbox"> Add Supabase SDK integration</li>
581
+ <li><input disabled="" type="checkbox"> Create database schema</li>
582
+ <li><input disabled="" type="checkbox"> Implement basic auth flow</li>
583
+ <li><input disabled="" type="checkbox"> Update configuration system</li>
584
+ </ul>
585
+ <h3>Week 3-4: Core Features</h3>
586
+ <ul>
587
+ <li><input disabled="" type="checkbox"> Build login/logout pages</li>
588
+ <li><input disabled="" type="checkbox"> Implement access checking</li>
589
+ <li><input disabled="" type="checkbox"> Add session management</li>
590
+ <li><input disabled="" type="checkbox"> Create CLI commands</li>
591
+ </ul>
592
+ <h3>Week 5-6: Advanced Features</h3>
593
+ <ul>
594
+ <li><input disabled="" type="checkbox"> Multi-site SSO</li>
595
+ <li><input disabled="" type="checkbox"> Role management</li>
596
+ <li><input disabled="" type="checkbox"> Invitation system</li>
597
+ <li><input disabled="" type="checkbox"> Audit logging</li>
598
+ </ul>
599
+ <h3>Week 7-8: Polish &amp; Migration</h3>
600
+ <ul>
601
+ <li><input disabled="" type="checkbox"> Migration tools</li>
602
+ <li><input disabled="" type="checkbox"> Documentation</li>
603
+ <li><input disabled="" type="checkbox"> Testing &amp; QA</li>
604
+ <li><input disabled="" type="checkbox"> Release preparation</li>
605
+ </ul>
606
+ <h2>Benefits Summary</h2>
607
+ <h3>For End Users</h3>
608
+ <ul>
609
+ <li><strong>Single Sign-On</strong>: One account for all documentation</li>
610
+ <li><strong>Better Security</strong>: Enterprise-grade authentication</li>
611
+ <li><strong>Password Recovery</strong>: Self-service password reset</li>
612
+ <li><strong>OAuth Login</strong>: Sign in with Google/GitHub</li>
613
+ </ul>
614
+ <h3>For Administrators</h3>
615
+ <ul>
616
+ <li><strong>User Management</strong>: Add/remove users easily</li>
617
+ <li><strong>Access Control</strong>: Fine-grained permissions</li>
618
+ <li><strong>Audit Trail</strong>: Complete access history</li>
619
+ <li><strong>Compliance</strong>: Meet security requirements</li>
620
+ </ul>
621
+ <h3>For Developers</h3>
622
+ <ul>
623
+ <li><strong>Easy Integration</strong>: Simple configuration</li>
624
+ <li><strong>Extensible</strong>: Add custom auth logic</li>
625
+ <li><strong>Well-Documented</strong>: Comprehensive guides</li>
626
+ <li><strong>Open Source</strong>: Fully transparent</li>
627
+ </ul>
628
+ <h2>Next Steps</h2>
629
+ <ol>
630
+ <li><strong>Validate Architecture</strong>: Review with team</li>
631
+ <li><strong>Create Prototype</strong>: Build proof of concept</li>
632
+ <li><strong>Security Review</strong>: Audit implementation</li>
633
+ <li><strong>Documentation</strong>: Write integration guides</li>
634
+ <li><strong>Beta Testing</strong>: Deploy to test sites</li>
635
+ <li><strong>Release</strong>: Publish new version</li>
636
+ </ol>
637
+ <h2>Conclusion</h2>
638
+ <p>This Supabase integration transforms @knowcode/doc-builder from a basic documentation generator into an enterprise-ready documentation platform with professional authentication and access control. The centralized auth approach enables organizations to manage documentation access across multiple sites while maintaining security and compliance.</p>
639
+
640
+ </div>
641
+ </main>
642
+ </div>
643
+
644
+ <!-- Scripts -->
645
+ <script>
646
+ // Pass configuration to frontend
647
+ window.docBuilderConfig = {
648
+ features: {
649
+ showPdfDownload: true,
650
+ menuDefaultOpen: false
651
+ }
652
+ };
653
+ </script>
654
+ <script src="/js/main.js"></script>
655
+
656
+ </body>
657
+ </html>