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:
Idempotent: if no 3-segment keys are found, returns the original state unchanged (same object reference).
Current ACL state (may contain old-format entries)
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));} Copy
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));}
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:
Idempotent: if no 3-segment keys are found, returns the original state unchanged (same object reference).