@knowcode/doc-builder 1.8.2 → 1.8.3

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 (45) hide show
  1. package/CHANGELOG.md +23 -3
  2. package/README.md +4 -4
  3. package/cli.js +9 -40
  4. package/html/README.html +3 -3
  5. package/html/auth.js +1 -1
  6. package/html/documentation-index.html +3 -3
  7. package/html/guides/authentication-default-change.html +3 -3
  8. package/html/guides/authentication-guide.html +34 -45
  9. package/html/guides/claude-workflow-guide.html +3 -3
  10. package/html/guides/documentation-standards.html +3 -3
  11. package/html/guides/phosphor-icons-guide.html +3 -3
  12. package/html/guides/private-directory-authentication.html +35 -17
  13. package/html/guides/public-site-deployment.html +8 -9
  14. package/html/guides/search-engine-verification-guide.html +3 -3
  15. package/html/guides/seo-guide.html +3 -3
  16. package/html/guides/seo-optimization-guide.html +3 -3
  17. package/html/guides/troubleshooting-guide.html +3 -3
  18. package/html/guides/windows-setup-guide.html +3 -3
  19. package/html/index.html +3 -3
  20. package/html/js/auth.js +1 -1
  21. package/html/login.html +1 -1
  22. package/html/private/cache-control-anti-pattern.html +3 -3
  23. package/html/private/launch/README.html +3 -3
  24. package/html/private/launch/auth-cleanup-summary.html +3 -3
  25. package/html/private/launch/bubble-plugin-specification.html +3 -3
  26. package/html/private/launch/go-to-market-strategy.html +3 -3
  27. package/html/private/launch/launch-announcements.html +3 -3
  28. package/html/private/launch/vercel-deployment-auth-setup.html +25 -19
  29. package/html/private/next-steps-walkthrough.html +16 -43
  30. package/html/private/supabase-auth-implementation-completed.html +6 -6
  31. package/html/private/supabase-auth-implementation-plan.html +14 -31
  32. package/html/private/supabase-auth-integration-plan.html +32 -67
  33. package/html/private/supabase-auth-setup-guide.html +71 -82
  34. package/html/private/test-private-doc.html +3 -3
  35. package/html/private/user-management-tooling.html +7 -13
  36. package/html/sitemap.xml +44 -44
  37. package/html/vercel-cli-setup-guide.html +3 -3
  38. package/html/vercel-first-time-setup-guide.html +3 -3
  39. package/lib/config.js +3 -11
  40. package/lib/core-builder.js +1 -2
  41. package/lib/shared-auth-config.js +2 -10
  42. package/lib/supabase-auth.js +5 -11
  43. package/package.json +1 -1
  44. package/setup-database-v2.sql +53 -0
  45. package/user-management/README.md +9 -18
package/CHANGELOG.md CHANGED
@@ -5,22 +5,42 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.8.3] - 2025-07-26
9
+
10
+ ### Changed
11
+ - Complete overhaul of authentication system to use domain-based access instead of site IDs
12
+ - **BREAKING**: Removed site ID system entirely - authentication now uses `window.location.host`
13
+ - Simplified database schema to single `docbuilder_access` table with (user_id, domain) primary key
14
+ - No more site registration required - just grant users access to domains
15
+
16
+ ### Updated
17
+ - All documentation updated to reflect domain-based authentication
18
+ - CLI commands simplified - no more site ID parameters needed
19
+ - User management tools now work with domains directly
20
+
21
+ ### Developer Experience
22
+ - Much simpler setup - no site registration step
23
+ - Automatic domain detection from browser location
24
+ - Easier multi-site management - just use different domains
25
+
8
26
  ## [1.8.2] - 2025-07-26
9
27
 
10
28
  ### Added
11
29
  - **Automatic Supabase Credentials**: No more placeholder errors! Credentials are now built into the package
12
- - **Auto-generated Site IDs**: Each site gets a unique ID automatically when authentication is enabled
30
+ - **Domain-based Authentication**: No more site IDs! Authentication now uses the current domain automatically
13
31
  - Shared authentication database across all doc-builder sites for easier management
14
32
 
15
33
  ### Changed
16
34
  - Supabase URL and anonymous key are now provided by default via `shared-auth-config.js`
17
- - Site IDs are auto-generated using site name, timestamp, and random string
35
+ - **BREAKING**: Removed site ID system in favor of domain-based authentication
36
+ - Authentication now uses `window.location.host` for access control
37
+ - Simplified database schema to single `docbuilder_access` table
18
38
  - Updated documentation to reflect zero-configuration authentication
19
39
 
20
40
  ### Developer Experience
21
41
  - No need to configure Supabase credentials manually anymore
22
42
  - Just create a `private` directory and authentication works immediately
23
- - Site administrators only need to add the auto-generated site ID to the database
43
+ - Site administrators only need to grant users access to domains, no site registration needed
24
44
 
25
45
  ## [1.8.1] - 2025-07-26
26
46
 
package/README.md CHANGED
@@ -218,11 +218,11 @@ module.exports = {
218
218
  attachments: true // Copy PDFs, Excel files, etc. (default: true)
219
219
  },
220
220
 
221
- // Supabase Authentication
221
+ // Supabase Authentication (v1.8.2+ has built-in defaults)
222
222
  auth: {
223
- supabaseUrl: process.env.SUPABASE_URL,
224
- supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
225
- siteId: process.env.DOC_SITE_ID
223
+ supabaseUrl: process.env.SUPABASE_URL, // Optional
224
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY // Optional
225
+ // Domain-based auth - no siteId needed!
226
226
  }
227
227
  };
228
228
  ```
package/cli.js CHANGED
@@ -1506,7 +1506,6 @@ program
1506
1506
  console.log(chalk.yellow('\n🔐 Supabase Authentication:'));
1507
1507
  console.log(` • Supabase URL: ${config.auth?.supabaseUrl ? chalk.green('Configured') : chalk.red('Missing')}`);
1508
1508
  console.log(` • Anonymous Key: ${config.auth?.supabaseAnonKey ? chalk.green('Configured') : chalk.red('Missing')}`);
1509
- console.log(` • Site ID: ${config.auth?.siteId ? chalk.green('Configured') : chalk.red('Missing')}`);
1510
1509
  }
1511
1510
 
1512
1511
  if (config.seo?.enabled) {
@@ -1568,8 +1567,7 @@ program
1568
1567
 
1569
1568
  auth: {
1570
1569
  supabaseUrl: '${answers.supabaseUrl}',
1571
- supabaseAnonKey: '${answers.supabaseAnonKey}',
1572
- siteId: '' // Will be set after creating site in database
1570
+ supabaseAnonKey: '${answers.supabaseAnonKey}'
1573
1571
  }
1574
1572
  };`;
1575
1573
 
@@ -1577,51 +1575,22 @@ program
1577
1575
  console.log(chalk.green(`✓ Configuration saved to ${configPath}`));
1578
1576
 
1579
1577
  console.log(chalk.yellow('\n📋 Next steps:'));
1580
- console.log('1. Create the database tables in your Supabase project (see documentation)');
1581
- console.log('2. Add your site to the database using: doc-builder auth:add-site');
1582
- console.log('3. Update the siteId in your config file');
1578
+ console.log('1. Create the database tables in your Supabase project (see setup-database-v2.sql)');
1579
+ console.log('2. Grant users access by adding their domain to docbuilder_access table');
1583
1580
 
1584
1581
  } catch (error) {
1585
1582
  console.error(chalk.red('Error initializing auth:'), error.message);
1586
1583
  }
1587
1584
  });
1588
1585
 
1589
- program
1590
- .command('auth:add-site')
1591
- .description('Add a documentation site to Supabase database')
1592
- .requiredOption('--domain <domain>', 'site domain (e.g., docs.example.com)')
1593
- .requiredOption('--name <name>', 'site display name')
1594
- .option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
1595
- .action(async (options) => {
1596
- console.log(chalk.cyan('\n🌐 Add Documentation Site\n'));
1597
-
1598
- try {
1599
- const config = await loadConfig(options.config || 'doc-builder.config.js', {});
1600
-
1601
- if (config.features?.authentication !== 'supabase') {
1602
- console.error(chalk.red('Error: Supabase authentication is not configured. Run "doc-builder auth:init" first.'));
1603
- return;
1604
- }
1605
-
1606
- // This would connect to Supabase and create the site record
1607
- console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
1608
- console.log('For now, manually add to your Supabase database:');
1609
- console.log('');
1610
- console.log(chalk.gray('INSERT INTO docbuilder_sites (domain, name)'));
1611
- console.log(chalk.gray(`VALUES ('${options.domain}', '${options.name}');`));
1612
- console.log('');
1613
- console.log('Then update your config file with the returned site ID.');
1614
-
1615
- } catch (error) {
1616
- console.error(chalk.red('Error adding site:'), error.message);
1617
- }
1618
- });
1586
+ // Note: auth:add-site command is no longer needed with domain-based authentication
1587
+ // Sites don't need to be registered - just grant users access to domains directly
1619
1588
 
1620
1589
  program
1621
1590
  .command('auth:grant')
1622
1591
  .description('Grant user access to documentation site')
1623
1592
  .requiredOption('--email <email>', 'user email address')
1624
- .requiredOption('--site-id <id>', 'site ID from database')
1593
+ .requiredOption('--domain <domain>', 'site domain (e.g., docs.example.com)')
1625
1594
  .option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
1626
1595
  .action(async (options) => {
1627
1596
  console.log(chalk.cyan('\n👥 Grant User Access\n'));
@@ -1637,9 +1606,9 @@ program
1637
1606
  console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
1638
1607
  console.log('For now, manually add to your Supabase database:');
1639
1608
  console.log('');
1640
- console.log(chalk.gray('-- First, get the user ID from auth.users where email = \'user@example.com\''));
1641
- console.log(chalk.gray('INSERT INTO docbuilder_access (user_id, site_id)'));
1642
- console.log(chalk.gray(`VALUES ('user-uuid-here', '${options.siteId}');`));
1609
+ console.log(chalk.gray(`-- First, get the user ID from auth.users where email = '${options.email}'`));
1610
+ console.log(chalk.gray('INSERT INTO docbuilder_access (user_id, domain)'));
1611
+ console.log(chalk.gray(`VALUES ('user-uuid-here', '${options.domain}');`));
1643
1612
 
1644
1613
  } catch (error) {
1645
1614
  console.error(chalk.red('Error granting access:'), error.message);
package/html/README.html CHANGED
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.951Z",
102
- "dateModified": "2025-07-26T10:38:41.951Z",
101
+ "datePublished": "2025-07-26T11:11:45.854Z",
102
+ "dateModified": "2025-07-26T11:11:45.854Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/README.html"
@@ -132,7 +132,7 @@
132
132
 
133
133
  <div class="header-actions">
134
134
  <div class="deployment-info">
135
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
135
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
136
136
  </div>
137
137
 
138
138
 
package/html/auth.js CHANGED
@@ -51,7 +51,7 @@
51
51
  .from('docbuilder_access')
52
52
  .select('*')
53
53
  .eq('user_id', user.id)
54
- .eq('site_id', '-knowcode-doc-builder-1753526321904-eivutk')
54
+ .eq('site_id', '-knowcode-doc-builder-1753528305501-qlqnmw')
55
55
  .single();
56
56
 
57
57
  if (accessError || !access) {
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.963Z",
102
- "dateModified": "2025-07-26T10:38:41.963Z",
101
+ "datePublished": "2025-07-26T11:11:45.864Z",
102
+ "dateModified": "2025-07-26T11:11:45.864Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/documentation-index.html"
@@ -132,7 +132,7 @@
132
132
 
133
133
  <div class="header-actions">
134
134
  <div class="deployment-info">
135
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
135
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
136
136
  </div>
137
137
 
138
138
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.967Z",
102
- "dateModified": "2025-07-26T10:38:41.967Z",
101
+ "datePublished": "2025-07-26T11:11:45.867Z",
102
+ "dateModified": "2025-07-26T11:11:45.867Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/authentication-default-change.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.969Z",
102
- "dateModified": "2025-07-26T10:38:41.969Z",
101
+ "datePublished": "2025-07-26T11:11:45.870Z",
102
+ "dateModified": "2025-07-26T11:11:45.870Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/authentication-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -261,8 +261,10 @@
261
261
  <li>Create a new project</li>
262
262
  <li>Note your project URL and anon key</li>
263
263
  </ol>
264
- <h3>Step 2: Configure doc-builder</h3>
265
- <p>Create or update <code>doc-builder.config.js</code>:</p>
264
+ <h3>Step 2: Configure doc-builder (Mostly Automatic!)</h3>
265
+ <p>As of v1.8.2, Supabase credentials are automatically configured. You have two options:</p>
266
+ <p><strong>Option 1: Automatic (Recommended)</strong><br>Just create a <code>docs/private/</code> directory and authentication is automatically enabled with built-in credentials.</p>
267
+ <p><strong>Option 2: Custom Configuration</strong><br>Create or update <code>doc-builder.config.js</code> (only if using your own Supabase project):</p>
266
268
  <pre><code class="language-javascript">module.exports = {
267
269
  siteName: &#39;My Documentation&#39;,
268
270
 
@@ -271,64 +273,52 @@
271
273
  },
272
274
 
273
275
  auth: {
274
- supabaseUrl: &#39;https://your-project.supabase.co&#39;,
275
- supabaseAnonKey: &#39;your-anon-key&#39;,
276
- siteId: &#39;your-site-id&#39; // From database after setup
276
+ supabaseUrl: &#39;https://your-project.supabase.co&#39;, // Optional - has defaults
277
+ supabaseAnonKey: &#39;your-anon-key&#39; // Optional - has defaults
277
278
  }
278
279
  };
279
280
  </code></pre>
281
+ <p>Note: No more <code>siteId</code> needed! The system uses domains automatically.</p>
280
282
  <h3>Step 3: Set Up Database</h3>
281
- <p>Run these SQL commands in your Supabase SQL editor:</p>
282
- <pre><code class="language-sql">-- Create sites table
283
- CREATE TABLE docbuilder_sites (
284
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
285
- domain TEXT UNIQUE NOT NULL,
286
- name TEXT NOT NULL,
287
- created_at TIMESTAMPTZ DEFAULT NOW()
288
- );
289
-
290
- -- Create access table
283
+ <p>Run this SQL command in your Supabase SQL editor (or use setup-database-v2.sql):</p>
284
+ <pre><code class="language-sql">-- Single table for user access control
291
285
  CREATE TABLE docbuilder_access (
292
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
293
- user_id UUID NOT NULL REFERENCES auth.users(id),
294
- site_id UUID NOT NULL REFERENCES docbuilder_sites(id),
286
+ user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
287
+ domain TEXT NOT NULL,
295
288
  created_at TIMESTAMPTZ DEFAULT NOW(),
296
- UNIQUE(user_id, site_id)
289
+ PRIMARY KEY (user_id, domain)
297
290
  );
298
291
 
292
+ -- Create index for faster lookups
293
+ CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
294
+
299
295
  -- Enable Row Level Security
300
- ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
301
296
  ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
302
297
 
303
- -- Create policies
304
- CREATE POLICY &quot;Sites visible to users with access&quot; ON docbuilder_sites
305
- FOR SELECT USING (
306
- id IN (
307
- SELECT site_id FROM docbuilder_access
308
- WHERE user_id = auth.uid()
309
- )
310
- );
311
-
312
- CREATE POLICY &quot;Access visible to own user&quot; ON docbuilder_access
298
+ -- RLS Policy: Users can only see their own access
299
+ CREATE POLICY &quot;Users see own access&quot; ON docbuilder_access
313
300
  FOR SELECT USING (user_id = auth.uid());
314
301
  </code></pre>
315
- <h3>Step 4: Add Your Site</h3>
316
- <pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name)
317
- VALUES (&#39;your-domain.com&#39;, &#39;Your Documentation Name&#39;);
318
- </code></pre>
319
- <p>Note the returned ID - this is your <code>siteId</code> for the config.</p>
302
+ <h3>Step 4: No Site Registration Needed!</h3>
303
+ <p>With the new domain-based system, you don&#39;t need to register sites. The system automatically uses the current domain (e.g., docs.example.com) as the access key.</p>
320
304
  <h3>Step 5: Create Users</h3>
321
305
  <p>Users can sign up through Supabase Auth, or you can create them:</p>
322
306
  <pre><code class="language-sql">-- In Supabase dashboard, go to Authentication &gt; Users
323
307
  -- Click &quot;Invite user&quot; and enter their email
324
308
  </code></pre>
325
309
  <h3>Step 6: Grant Access</h3>
326
- <pre><code class="language-sql">-- Grant user access to your site
327
- INSERT INTO docbuilder_access (user_id, site_id)
310
+ <pre><code class="language-sql">-- Grant user access to your documentation domain
311
+ INSERT INTO docbuilder_access (user_id, domain)
328
312
  VALUES (
329
313
  (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;),
330
- &#39;your-site-id&#39;
314
+ &#39;docs.example.com&#39;
331
315
  );
316
+
317
+ -- Grant multiple users access
318
+ INSERT INTO docbuilder_access (user_id, domain)
319
+ SELECT id, &#39;docs.example.com&#39;
320
+ FROM auth.users
321
+ WHERE email IN (&#39;user1@example.com&#39;, &#39;user2@example.com&#39;, &#39;user3@example.com&#39;);
332
322
  </code></pre>
333
323
  <h2>Deployment</h2>
334
324
  <h3>Build with Authentication</h3>
@@ -370,11 +360,10 @@ npx @knowcode/doc-builder auth:list-users --site-id xxx
370
360
  </ul>
371
361
  <h3>Security Best Practices</h3>
372
362
  <ol>
373
- <li><p><strong>Use environment variables</strong> for sensitive config:</p>
363
+ <li><p><strong>Use environment variables</strong> for custom config (optional):</p>
374
364
  <pre><code class="language-javascript">auth: {
375
- supabaseUrl: process.env.SUPABASE_URL,
376
- supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
377
- siteId: process.env.DOC_SITE_ID
365
+ supabaseUrl: process.env.SUPABASE_URL || defaultUrl,
366
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY || defaultKey
378
367
  }
379
368
  </code></pre>
380
369
  </li>
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.973Z",
102
- "dateModified": "2025-07-26T10:38:41.973Z",
101
+ "datePublished": "2025-07-26T11:11:45.874Z",
102
+ "dateModified": "2025-07-26T11:11:45.874Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/claude-workflow-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.977Z",
102
- "dateModified": "2025-07-26T10:38:41.977Z",
101
+ "datePublished": "2025-07-26T11:11:45.878Z",
102
+ "dateModified": "2025-07-26T11:11:45.878Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/documentation-standards.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.979Z",
102
- "dateModified": "2025-07-26T10:38:41.979Z",
101
+ "datePublished": "2025-07-26T11:11:45.880Z",
102
+ "dateModified": "2025-07-26T11:11:45.880Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/phosphor-icons-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.982Z",
102
- "dateModified": "2025-07-26T10:38:41.982Z",
101
+ "datePublished": "2025-07-26T11:11:45.883Z",
102
+ "dateModified": "2025-07-26T11:11:45.883Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/private-directory-authentication.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -308,34 +308,52 @@ module.exports = {
308
308
  };
309
309
  </code></pre>
310
310
  <h3>2. Create Access Control Table</h3>
311
- <p>In your Supabase dashboard, run this SQL to create the access control table:</p>
311
+ <p>In your Supabase dashboard, run this SQL (or use setup-database-v2.sql):</p>
312
312
  <pre><code class="language-sql">CREATE TABLE docbuilder_access (
313
- id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
314
313
  user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
315
- site_id TEXT NOT NULL,
314
+ domain TEXT NOT NULL,
316
315
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
317
- UNIQUE(user_id, site_id)
316
+ PRIMARY KEY (user_id, domain)
318
317
  );
318
+
319
+ -- Create index for performance
320
+ CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
321
+
322
+ -- Enable Row Level Security
323
+ ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
324
+
325
+ -- RLS Policy
326
+ CREATE POLICY &quot;Users see own access&quot; ON docbuilder_access
327
+ FOR SELECT USING (user_id = auth.uid());
319
328
  </code></pre>
320
329
  <h3>3. Grant User Access</h3>
321
- <p>Add authorized users by inserting records:</p>
330
+ <p>Add authorized users by domain:</p>
322
331
  <pre><code class="language-sql">-- First, create a user in Supabase Auth
323
- -- Then grant them access to your documentation
324
- INSERT INTO docbuilder_access (user_id, site_id)
325
- VALUES (&#39;user-uuid-from-auth-users&#39;, &#39;your-site-id&#39;);
332
+ -- Then grant them access to your documentation domain
333
+ INSERT INTO docbuilder_access (user_id, domain)
334
+ VALUES (&#39;user-uuid-from-auth-users&#39;, &#39;docs.example.com&#39;);
335
+
336
+ -- Or grant access to multiple domains
337
+ INSERT INTO docbuilder_access (user_id, domain) VALUES
338
+ (&#39;user-uuid&#39;, &#39;docs.example.com&#39;),
339
+ (&#39;user-uuid&#39;, &#39;staging-docs.example.com&#39;),
340
+ (&#39;user-uuid&#39;, &#39;localhost:3000&#39;);
326
341
  </code></pre>
327
342
  <h3>Automatic Credential Configuration</h3>
328
- <p>Starting from version 1.8.2, Supabase credentials are automatically configured:</p>
343
+ <p>Starting from version 1.8.2, authentication is truly zero-configuration:</p>
329
344
  <ul>
330
345
  <li>All doc-builder sites share the same Supabase authentication database</li>
331
346
  <li>Credentials are built into the package - no manual configuration needed</li>
332
- <li>Each site gets a unique auto-generated site ID</li>
333
- <li>You just need to add the site ID to the database to grant user access</li>
347
+ <li>No site IDs needed - the system uses your domain automatically</li>
348
+ <li>Just grant users access to your domain in the database</li>
334
349
  </ul>
335
- <p><strong>Note</strong>: The auto-generated site ID is displayed during build:</p>
350
+ <p><strong>Note</strong>: When you build with a private directory:</p>
336
351
  <pre><code>🔐 Found private directory - automatically enabling Supabase authentication
337
- 📋 Generated site ID: documentation-1753525200000-abc123
338
- Note: Add this site ID to your Supabase database to enable user access
352
+ Note: Grant users access by adding domain to the docbuilder_access table
353
+ </code></pre>
354
+ <p><strong>Example</strong>: For a site at <code>docs.example.com</code>, grant access with:</p>
355
+ <pre><code class="language-sql">INSERT INTO docbuilder_access (user_id, domain)
356
+ VALUES (&#39;user-uuid&#39;, &#39;docs.example.com&#39;);
339
357
  </code></pre>
340
358
  <h2>Best Practices</h2>
341
359
  <h3>Choosing the Right Mode</h3>
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.983Z",
102
- "dateModified": "2025-07-26T10:38:41.983Z",
101
+ "datePublished": "2025-07-26T11:11:45.884Z",
102
+ "dateModified": "2025-07-26T11:11:45.884Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/public-site-deployment.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -270,9 +270,9 @@ npx @knowcode/doc-builder deploy -c public-doc-builder.config.js
270
270
  authentication: &#39;supabase&#39;
271
271
  },
272
272
  auth: {
273
- supabaseUrl: &#39;https://xxx.supabase.co&#39;,
274
- supabaseAnonKey: &#39;your-anon-key&#39;,
275
- siteId: &#39;your-site-id&#39;
273
+ supabaseUrl: &#39;https://xxx.supabase.co&#39;, // Optional - has defaults
274
+ supabaseAnonKey: &#39;your-anon-key&#39; // Optional - has defaults
275
+ // Domain-based auth - no siteId needed!
276
276
  }
277
277
  </code></pre>
278
278
  <ul>
@@ -338,11 +338,10 @@ npx @knowcode/doc-builder deploy -c public-config.js
338
338
  <p>If you were using Supabase authentication and want to make your site public:</p>
339
339
  <ol>
340
340
  <li><p><strong>Remove auth config</strong>:</p>
341
- <pre><code class="language-javascript">// Remove this:
341
+ <pre><code class="language-javascript">// Remove this (or keep for custom Supabase):
342
342
  auth: {
343
343
  supabaseUrl: &#39;https://xxx.supabase.co&#39;,
344
- supabaseAnonKey: &#39;xxx&#39;,
345
- siteId: &#39;xxx&#39;
344
+ supabaseAnonKey: &#39;xxx&#39;
346
345
  }
347
346
  </code></pre>
348
347
  </li>
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.985Z",
102
- "dateModified": "2025-07-26T10:38:41.985Z",
101
+ "datePublished": "2025-07-26T11:11:45.886Z",
102
+ "dateModified": "2025-07-26T11:11:45.886Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/search-engine-verification-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.988Z",
102
- "dateModified": "2025-07-26T10:38:41.988Z",
101
+ "datePublished": "2025-07-26T11:11:45.889Z",
102
+ "dateModified": "2025-07-26T11:11:45.889Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/seo-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:38:41.995Z",
102
- "dateModified": "2025-07-26T10:38:41.995Z",
101
+ "datePublished": "2025-07-26T11:11:45.895Z",
102
+ "dateModified": "2025-07-26T11:11:45.895Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/guides/seo-optimization-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144