NUB-RESOURCE: Sandboxed resource fetching (https / blossom / nostr / data)#13
Open
NUB-RESOURCE: Sandboxed resource fetching (https / blossom / nostr / data)#13
Conversation
Defines window.napplet.resource.bytes(url) -> Blob — the canonical fetch path for sandboxed napplets. Four schemes (data:, https:, blossom:, nostr:), 8-code error vocabulary, Default Resource Policy with SSRF block list at DNS-resolution time, SVG rasterization in sandboxed Worker with no network, Shell Guarantees MUST/SHOULD/MAY tables, and six Security Considerations subsections. Complements NIP-5D browser-enforced iframe isolation: napplets cannot fetch directly because the sandbox blocks it; network-sourced bytes flow through the host shell over postMessage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status: Draft
Namespace: `window.napplet.resource`
Discovery: `window.napplet.shell.supports("resource")`
Summary
NUB-RESOURCE defines a single scheme-pluggable primitive for sandboxed napplets to fetch byte-addressable resources through the host shell: `resource.bytes(url) → Blob`. Napplets address resources by URL only — they never see raw `fetch`, never open a socket, and never observe the upstream `Content-Type`. The shell mediates under a documented policy and returns a single `Blob` plus a shell-classified `mime` string.
This NUB is the canonical fetch path that complements the browser-enforced isolation defined by NIP-5D (`sandbox="allow-scripts"`, no `allow-same-origin`): napplets cannot fetch directly because the sandbox blocks it; everything network-sourced flows through the shell over `postMessage`.
Scope
Coexistence
Referenced by (to be amended separately):
Implementations
`(none yet)`
Next steps
Follow-up amendment PRs against NUB-RELAY / NUB-IDENTITY / NUB-MEDIA will reference this spec once merged.