NIP-05: Auto-provision identity on user creation #14

Open
opened 2026-04-01 17:35:54 +00:00 by padreug · 0 comments
Owner

Summary

When a user creates a Lightning.Pub wallet (via AddAppUser), they should automatically receive a NIP-05 identity and Lightning Address. Currently users must explicitly call nip05.claim with a chosen username — most users will never do this.

Problem

A Lightning.Pub user without a NIP-05 identity has:

  • No human-readable address (alice@domain.com)
  • No Lightning Address (can't receive payments via alice@domain.com)
  • No NIP-57 zap support
  • No discoverability on Nostr

This defeats the purpose of having the NIP-05 extension if it requires manual opt-in.

Proposed Solution

New extension hook: onUserCreated()

Add an onUserCreated callback to ExtensionContext:

interface ExtensionContext {
  // ... existing methods ...

  onUserCreated(callback: (user: {
    userId: string
    pubkeyHex: string
    applicationId: string
    identifier?: string    // app-provided identifier (e.g. "alice")
  }) => Promise<void>): void
}

When AppUserManager.AddAppUser() creates a new user, dispatch to all registered extension callbacks.

NIP-05 extension auto-provisioning

The NIP-05 extension subscribes to onUserCreated() and:

  1. If the app provides an identifier (e.g. "alice"), use that as the username
  2. If no identifier, derive from the pubkey: first 8 chars of npub bech32 (e.g. npub1abc@domain.com)
  3. If the derived username is taken, append a short random suffix
  4. Store as active identity — user immediately has a working NIP-05 + Lightning Address

User can still customize

  • nip05.claim releases the auto-assigned name and claims a new one
  • nip05.release removes the identity entirely (opt-out)
  • Auto-provisioning can be disabled via config: auto_provision: false

Config addition

interface Nip05Config {
  // ... existing fields ...

  /** Auto-provision NIP-05 identity on user creation (default: true) */
  auto_provision?: boolean

  /** Strategy for auto-generated usernames: 'identifier' | 'npub' (default: 'identifier') */
  auto_username_strategy?: 'identifier' | 'npub'

  /** Canonical domain for NIP-05 addresses (overrides Host header) */
  domain?: string
}

Implementation scope

  1. Extension system (types.ts, context.ts, loader.ts): Add onUserCreated hook
  2. Lightning.Pub core (appUserManager.ts): Dispatch user creation events to extension loader
  3. NIP-05 extension (nip05Manager.ts): Subscribe and auto-provision
  4. Config: Add domain, auto_provision, auto_username_strategy fields

Why this matters

The goal is: install Lightning.Pub + NIP-05 extension → every user automatically gets username@yourdomain.com as both a Nostr identity and a Lightning Address. Zero friction.

## Summary When a user creates a Lightning.Pub wallet (via `AddAppUser`), they should automatically receive a NIP-05 identity and Lightning Address. Currently users must explicitly call `nip05.claim` with a chosen username — most users will never do this. ## Problem A Lightning.Pub user without a NIP-05 identity has: - No human-readable address (`alice@domain.com`) - No Lightning Address (can't receive payments via `alice@domain.com`) - No NIP-57 zap support - No discoverability on Nostr This defeats the purpose of having the NIP-05 extension if it requires manual opt-in. ## Proposed Solution ### New extension hook: `onUserCreated()` Add an `onUserCreated` callback to `ExtensionContext`: ```typescript interface ExtensionContext { // ... existing methods ... onUserCreated(callback: (user: { userId: string pubkeyHex: string applicationId: string identifier?: string // app-provided identifier (e.g. "alice") }) => Promise<void>): void } ``` When `AppUserManager.AddAppUser()` creates a new user, dispatch to all registered extension callbacks. ### NIP-05 extension auto-provisioning The NIP-05 extension subscribes to `onUserCreated()` and: 1. If the app provides an `identifier` (e.g. `"alice"`), use that as the username 2. If no identifier, derive from the pubkey: first 8 chars of npub bech32 (e.g. `npub1abc@domain.com`) 3. If the derived username is taken, append a short random suffix 4. Store as active identity — user immediately has a working NIP-05 + Lightning Address ### User can still customize - `nip05.claim` releases the auto-assigned name and claims a new one - `nip05.release` removes the identity entirely (opt-out) - Auto-provisioning can be disabled via config: `auto_provision: false` ## Config addition ```typescript interface Nip05Config { // ... existing fields ... /** Auto-provision NIP-05 identity on user creation (default: true) */ auto_provision?: boolean /** Strategy for auto-generated usernames: 'identifier' | 'npub' (default: 'identifier') */ auto_username_strategy?: 'identifier' | 'npub' /** Canonical domain for NIP-05 addresses (overrides Host header) */ domain?: string } ``` ## Implementation scope 1. **Extension system** (`types.ts`, `context.ts`, `loader.ts`): Add `onUserCreated` hook 2. **Lightning.Pub core** (`appUserManager.ts`): Dispatch user creation events to extension loader 3. **NIP-05 extension** (`nip05Manager.ts`): Subscribe and auto-provision 4. **Config**: Add `domain`, `auto_provision`, `auto_username_strategy` fields ## Why this matters The goal is: install Lightning.Pub + NIP-05 extension → every user automatically gets `username@yourdomain.com` as both a Nostr identity and a Lightning Address. Zero friction.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: aiolabs/lightning-pub#14
No description provided.