Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions docs/ns-builtin-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,23 @@ works; adding them is a change to this specification first.

Debug builds additionally carry `canonicalizeHttpUrlKey(url)`, a pure test
diagnostic that takes a string and throws
`canonicalizeHttpUrlKey expects a URL string` otherwise; release builds omit
it. Missing members are simply absent — never
`canonicalizeHttpUrlKey expects a URL string` otherwise, and
`remoteUrlMatchesAllowlist(url, entries)`, which returns whether a release
build with `allowRemoteModules` on would fetch `url` under a
`security.remoteModuleAllowlist` of `entries` (`true` for `[]`) and throws
`remoteUrlMatchesAllowlist expects a URL string and an array of strings`
otherwise; release builds omit both. Missing members are simply absent — never
present-but-throwing — so feature checks work. The module is registered in
every build: the security boundary for remote module loading sits at the
network layer (`security.allowRemoteModules` in nativescript.config, enforced
by the HTTP loader), not at the module registry and not at `ns:runtime`.

A `security.remoteModuleAllowlist` array with at least one item is in force:
a URL is fetched only when an entry matches it as a prefix ending at `/`, `?`,
`#` or the end of the URL. When the key is absent, not an array, or an empty
array, every URL is allowed. An item that is not a string, is empty, or is not
valid Unicode matches nothing but still keeps the list in force.

#### Import maps and scopes

`importMap` takes the WHATWG shape:
Expand Down Expand Up @@ -541,7 +551,10 @@ A **scope key is matched as a plain prefix of the importing module's canonical
registry key** — an absolute `http(s)` URL for a served module, or a canonical
absolute path for a file on disk. That key is this runtime's analogue of the
web's resolved referrer URL, which is what scope prefixes match in a browser.
End a scope key with `/` to keep it on a directory boundary. Resolution
An `http(s)` scope key is spelled the way registry keys are (see
[Registry canonicalization](#registry-canonicalization)) when the map is
installed, ending in `/` exactly when it is written so. End a scope key with
`/` to keep it on a directory boundary. Resolution
consults the most specific matching scope first (longest prefix wins), then
progressively less specific ones, then `imports` — so a scope can override a
global mapping for one subtree and fall through to it everywhere else. The
Expand All @@ -563,23 +576,28 @@ session's vocabulary. Every message is prefixed `configureLoader: `.
| any import-map section other than `imports`/`scopes` | `unsupported import-map section '<name>'; only "imports" and "scopes" are supported` |
| `imports` is not an object | `the "imports" section must be an object` |
| `scopes` is not an object | `the "scopes" section must be an object` |
| non-string scope key | `scopes: every scope key must be a string` |
| non-string scope key, or one with a lone surrogate | `scopes: every scope key must be a string` |
| empty scope key | `scopes: a scope key must not be empty` |
| a scope's value is not an object | `scopes: the map for scope '<scope>' must be an object` |

Inside either section — labelled `imports` or `scope '<scope>'`:

| condition | message |
|---|---|
| non-string specifier key | `<section>: every key must be a string` |
| non-string specifier key, or one with a lone surrogate | `<section>: every key must be a string` |
| empty specifier key | `<section>: a specifier key must not be empty` |
| non-string target | `<section>: the target for '<specifier>' must be a string` |
| non-string target, or one with a lone surrogate | `<section>: the target for '<specifier>' must be a string` |
| empty target | `<section>: the target for '<specifier>' must not be empty` |
| target containing U+0000 | `<section>: the target for '<specifier>' must not contain U+0000` |
| trailing-slash key, non-trailing-slash target | `<section>: the target for '<specifier>' must end with '/' because the specifier key does` |

#### Registry canonicalization

The registry keys modules by a canonical URL. The mechanism — fragment strip,
The registry keys modules by a canonical URL. Before the vocabulary applies,
an absolute http(s) URL is spelled by the WHATWG URL parser with its authority
as written, whichever way it arrives — a specifier from any importer, an
import-map target, or `invalidateModules` — so `HTTP://host/a/../x.js` and
`http:/host/x.js` key as `http://host/x.js`. The mechanism — fragment strip,
cache-buster param drop, param sort — is the runtime's; the *vocabulary* is
server policy, supplied here:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
globalThis.__nsNulDecoyDynamicEvaluated = true;

export const decoy = "nul-decoy-dynamic";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
globalThis.__nsNulDecoyStaticEvaluated = true;

export const decoy = "nul-decoy-static";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function load(spec) {
return import(spec);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { decoy } from "./decoy-static.mjs\u0000junk";

export const value = decoy;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as dep from "ns-tooling-url-static";
Loading
Loading