OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-identity commits / 6eaf378

Make WebIdentityProvider autoRegister configurable
Apps can now set autoRegister: false in AuthManager options to require explicit registration instead of auto-creating users on first auth. Default remains true (backward compatible with pear-git/hypernote). hyper-social-web uses autoRegister: false — anonymous visitors stay anonymous, Login button explicitly creates account. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6eaf378ee73bc564b2642c6aaa55ea68d4665c78
by plankatron <fleeky@gmail.com> · 2026-03-25T01:44:53.000Z

Changed files (2) +14 -4

lib/auth.js +3 -1
……@@ -54,7 +54,9 @@ export class AuthManager {
5454 // Register default providers based on what's available
5555 if (this.identityRegistry) {
5656 this.providers.push(
57 new WebIdentityProvider(this.identityRegistry, this.challengeManager)
57 new WebIdentityProvider(this.identityRegistry, this.challengeManager, {
58 autoRegister: options.autoRegister !== false // default: true
59 })
5860 )
5961
6062 if (options.IdentityKey) {
lib/auth/providers/web-identity.js +11 -3
……@@ -5,13 +5,17 @@ import { ANProto } from '../../anproto.js'
55 * WebIdentityProvider — Browser ANProto authentication
66 *
77 * Handles Ed25519 challenge-response auth for web clients.
8 * Supports both signed (challenge-based) and legacy (unsigned) auth.
8 *
9 * Options:
10 * autoRegister: true — auto-create user on first auth (default, pear-git/hypernote behavior)
11 * autoRegister: false — reject unknown keys, require explicit registration
912 */
1013export class WebIdentityProvider extends BaseProvider {
11 constructor (identityRegistry, challengeManager) {
14 constructor (identityRegistry, challengeManager, opts = {}) {
1215 super('web-identity')
1316 this.registry = identityRegistry
1417 this.challengeManager = challengeManager
18 this.autoRegister = opts.autoRegister !== false // default: true
1519 }
1620
1721 async extractCredentials (req) {
……@@ -40,10 +44,14 @@ export class WebIdentityProvider extends BaseProvider {
4044 await this.challengeManager.consume(challengeId)
4145 }
4246
43 // Look up or auto-register identity
47 // Look up identity
4448 let identity = await this.registry.getIdentityByPublicKey(publicKey)
4549
4650 if (!identity) {
51 if (!this.autoRegister) {
52 throw new Error('Unknown identity. Register first.')
53 }
54
4755 // Auto-register: creates user + identity atomically
4856 // First user gets admin, subsequent get read-only
4957 const result = await this.registry.autoRegister({