Documentation
    Preparing search index...

    Function migrateAclState

    • Migrate ACL state from old 3-segment key format to new 2-segment key format.

      Converts entries stored under 'pubkey:dTag:hash' keys to 'dTag:hash' keys. If two old entries map to the same dTag:hash, merges them conservatively:

      • caps: OR of both bitfields (never removes a granted capability)
      • blocked: OR of both flags (blocks if either source was blocked)
      • quota: MAX of both values (keeps the higher allocation)

      Idempotent: if no 3-segment keys are found, returns the original state unchanged (same object reference).

      Parameters

      • state: AclState

        Current ACL state (may contain old-format entries)

      Returns AclState

      Migrated AclState with only 2-segment keys, or the original state unchanged if no migration was needed

      const oldState = deserialize(localStorage.getItem('napplet:acl') ?? '');
      const newState = migrateAclState(oldState);
      if (newState !== oldState) {
      // Migration occurred — persist the new format
      localStorage.setItem('napplet:acl', serialize(newState));
      }