storage.clear is NOT in the canonical @napplet/nap/storage union (it was a
kehto unilateral extension); attempts produce a storage.clear.result envelope
with an error field set. Internal lifecycle cleanup still uses the
cleanupNappState() helper below — it is not napplet-reachable.
Per-instance scope (NAP-STORAGE / napplet/naps#3): each request MAY carry
scope: "shared" | "instance" (default "shared"). "instance" addresses a
per-window sub-namespace keyed by windowId, so multiple windows of the same
napplet keep isolated state; "shared" (or absent) addresses the napplet-wide
namespace, byte-identical to historical behavior. An unrecognized scope value
is an invalid request and produces a .result envelope with error set.
Deviation note (Phase 15 to decide): Set/remove results emit both ok
(legacy compat) and an error field on failure. Canonical @napplet/nap/storage
only specifies the optional error; napplets check !result.error for success.
Emitting ok preserves backward compatibility with existing in-tree callers.
Phase 15 (v1.2 release prep) decides whether to drop ok pre-release.
Handle a NIP-5D NAP storage message from a napplet. Routes to the canonical four
@napplet/nap/storageactions:storage.get→storage.get.result{ value: string | null }storage.set→storage.set.result{ ok: boolean }(canonical only checkserror)storage.remove→storage.remove.result{ ok: boolean }storage.keys→storage.keys.result{ keys: string[] }storage.clearis NOT in the canonical@napplet/nap/storageunion (it was a kehto unilateral extension); attempts produce astorage.clear.resultenvelope with anerrorfield set. Internal lifecycle cleanup still uses thecleanupNappState()helper below — it is not napplet-reachable.Per-instance scope (NAP-STORAGE / napplet/naps#3): each request MAY carry
scope: "shared" | "instance"(default"shared")."instance"addresses a per-window sub-namespace keyed bywindowId, so multiple windows of the same napplet keep isolated state;"shared"(or absent) addresses the napplet-wide namespace, byte-identical to historical behavior. An unrecognizedscopevalue is an invalid request and produces a.resultenvelope witherrorset.Deviation note (Phase 15 to decide): Set/remove results emit both
ok(legacy compat) and anerrorfield on failure. Canonical@napplet/nap/storageonly specifies the optionalerror; napplets check!result.errorfor success. Emittingokpreserves backward compatibility with existing in-tree callers. Phase 15 (v1.2 release prep) decides whether to dropokpre-release.