@nac3/runtime 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +827 -0
- package/README.md +110 -3
- package/SPEC.md +1364 -30
- package/contract-head.json +4 -4
- package/dist/cli-harness.mjs +468 -0
- package/dist/cli-levels.json +56 -15
- package/dist/cli-lint.mjs +718 -24
- package/dist/cli-url.mjs +234 -80
- package/dist/cli.js +317 -12
- package/dist/dom-harness.mjs +578 -0
- package/dist/nac-chat-client.browser.js +47 -6
- package/dist/nac-chat-client.cjs +47 -6
- package/dist/nac-chat-client.mjs +47 -6
- package/dist/nac-v2-extensions.browser.js +359 -18
- package/dist/nac-v2-extensions.cjs +359 -18
- package/dist/nac-v2-extensions.d.ts +1 -1
- package/dist/nac-v2-extensions.mjs +359 -18
- package/dist/nac.browser.js +1942 -68
- package/dist/nac.cjs +1942 -68
- package/dist/nac.d.ts +78 -2
- package/dist/nac.mjs +1942 -68
- package/package.json +27 -3
package/dist/nac.browser.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
=====================================================================
|
|
7
7
|
|
|
8
8
|
AUTHORITATIVE VERSION CONSTANT: see the global.NAC export at the
|
|
9
|
-
bottom of this file. `version: '2.
|
|
9
|
+
bottom of this file. `version: '2.8.0', spec_version: '2.8'`
|
|
10
10
|
is the normative declaration. The dated changelog sections below are
|
|
11
11
|
historical notes; if they ever drift from the export, the export
|
|
12
12
|
wins.
|
|
@@ -313,6 +313,12 @@
|
|
|
313
313
|
|
|
314
314
|
if (global.NAC && global.NAC.__nac_v1_installed) return;
|
|
315
315
|
|
|
316
|
+
/* The tier this runtime declares when a host does not override it.
|
|
317
|
+
ONE declaration: the versioning gate and the NAC export both read
|
|
318
|
+
it. See the long note at the `conformance_tier` export for why a
|
|
319
|
+
tier is not a level, and RFC V24-04 sec 6 for the vocabulary. */
|
|
320
|
+
const DEFAULT_CONFORMANCE_TIER = 'NAC-3-versioned';
|
|
321
|
+
|
|
316
322
|
/* ---------- Errors ---------------------------------------------- */
|
|
317
323
|
|
|
318
324
|
function NacError(code, message, extra) {
|
|
@@ -323,6 +329,29 @@
|
|
|
323
329
|
return e;
|
|
324
330
|
}
|
|
325
331
|
|
|
332
|
+
/* 2.7.0 (SPEC sec 19.3) -- fail closed where there is no document.
|
|
333
|
+
|
|
334
|
+
The DOM primitives of sections 1-14 address NODES: they resolve a
|
|
335
|
+
name by querying the document. Called where no document exists --
|
|
336
|
+
Node, a worker, an SSR build, a screenless assistant -- they used
|
|
337
|
+
to throw a raw "ReferenceError: document is not defined" from
|
|
338
|
+
whatever line happened to touch it first, which tells the caller
|
|
339
|
+
nothing about the contract and is not a code anybody can branch
|
|
340
|
+
on. validate_global was worse: it returned {ok: true} for a tree
|
|
341
|
+
that does not exist, which is a false green.
|
|
342
|
+
|
|
343
|
+
So they refuse by name. The headless profile (sec 19) is the other
|
|
344
|
+
half of the same rule: a surface with no document is reached
|
|
345
|
+
through the extension contract (sec 15), never through these. */
|
|
346
|
+
function _nac_requireDocument(where) {
|
|
347
|
+
if (typeof document !== 'undefined' && document) return;
|
|
348
|
+
throw NacError('no_document',
|
|
349
|
+
'NAC.' + where + ': no document in this context, so there is no node to resolve. ' +
|
|
350
|
+
'Reach a declared surface through the extension contract -- NAC.call / NAC.read / ' +
|
|
351
|
+
'NAC.subscribe (SPEC sec 15) -- and see the headless profile (SPEC sec 19).',
|
|
352
|
+
{ primitive: where });
|
|
353
|
+
}
|
|
354
|
+
|
|
326
355
|
/* ================================================================
|
|
327
356
|
v2.5 / RFC V24-01: Plugin slug uniqueness gate (spec sec 7.4)
|
|
328
357
|
================================================================
|
|
@@ -718,13 +747,58 @@
|
|
|
718
747
|
over the canonical bytes, truncated to the leading 128 bits
|
|
719
748
|
(16 bytes), encoded as 32 lowercase hex chars. */
|
|
720
749
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
750
|
+
/* ONE definition of "visible" (TF-A12).
|
|
751
|
+
|
|
752
|
+
Until 2.7.0 there were two, both published, and they disagreed:
|
|
753
|
+
|
|
754
|
+
_hashIsEffectivelyVisible fed the `visible` key of the
|
|
755
|
+
concurrency hash. Looked at
|
|
756
|
+
aria-hidden and offsetParent. Did
|
|
757
|
+
NOT look at opacity.
|
|
758
|
+
_isVisible fed the `visible` key the AGENT
|
|
759
|
+
reads from a state snapshot. Looked
|
|
760
|
+
at opacity. Did NOT look at
|
|
761
|
+
aria-hidden.
|
|
762
|
+
|
|
763
|
+
So an element with `opacity: 0` was visible to one and invisible
|
|
764
|
+
to the other, and one with `aria-hidden="true"` was the reverse.
|
|
765
|
+
Two answers to one word, in one runtime, both shipped -- and the
|
|
766
|
+
word is load-bearing twice over: an agent decides whether to act
|
|
767
|
+
on an element by it, and the optimistic-concurrency gate decides
|
|
768
|
+
whether the page moved under the agent by it.
|
|
769
|
+
|
|
770
|
+
There was a third difference, and it was a crash rather than a
|
|
771
|
+
disagreement: _isVisible reached el.ownerDocument.defaultView
|
|
772
|
+
.getComputedStyle with NO GUARD, while this one checked for
|
|
773
|
+
window.getComputedStyle first. In an environment without a
|
|
774
|
+
defaultView -- a detached document, a server-side render, a test
|
|
775
|
+
harness -- one threw and the other did not.
|
|
776
|
+
|
|
777
|
+
THE DECISION, and the reasoning rather than just the outcome. The
|
|
778
|
+
union is the right answer, and specifically the agent's question
|
|
779
|
+
is the one that governs: "can this be perceived and acted on?"
|
|
780
|
+
Every one of the five conditions below answers no to it.
|
|
781
|
+
aria-hidden belongs in it because NAC3 sits next to the
|
|
782
|
+
accessibility tree and an element explicitly removed from that
|
|
783
|
+
tree is not something an agent may act on. opacity: 0 belongs in
|
|
784
|
+
it because a user cannot see it.
|
|
785
|
+
|
|
786
|
+
The hash gets the same predicate, which makes it slightly
|
|
787
|
+
stricter: a control fading to opacity 0 now changes the hash.
|
|
788
|
+
That is more correct for a concurrency check, not less -- it IS a
|
|
789
|
+
change in the observable state, which is exactly what the hash
|
|
790
|
+
exists to notice.
|
|
791
|
+
|
|
792
|
+
Cheap first, expensive last: the attribute and the layout box are
|
|
793
|
+
free, getComputedStyle is not. */
|
|
794
|
+
function _isPerceivable(el) {
|
|
724
795
|
if (!el || el.nodeType !== 1) return false;
|
|
796
|
+
/* 1. explicitly removed from the accessibility tree */
|
|
725
797
|
if (el.getAttribute && el.getAttribute('aria-hidden') === 'true') return false;
|
|
798
|
+
/* 2. not laid out. position:fixed legitimately has no
|
|
799
|
+
offsetParent, so a zero-sized rect is what decides, not the
|
|
800
|
+
null parent on its own. */
|
|
726
801
|
if (typeof el.offsetParent === 'object' && el.offsetParent === null) {
|
|
727
|
-
/* position:fixed escapes offsetParent=null. Use rect fallback. */
|
|
728
802
|
if (typeof el.getBoundingClientRect === 'function') {
|
|
729
803
|
const r = el.getBoundingClientRect();
|
|
730
804
|
if (r.width === 0 && r.height === 0) return false;
|
|
@@ -732,13 +806,35 @@
|
|
|
732
806
|
return false;
|
|
733
807
|
}
|
|
734
808
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
809
|
+
/* 3. a zero-sized box, however it got that way */
|
|
810
|
+
if (typeof el.getBoundingClientRect === 'function') {
|
|
811
|
+
const r = el.getBoundingClientRect();
|
|
812
|
+
if (r.width === 0 && r.height === 0) return false;
|
|
813
|
+
}
|
|
814
|
+
/* 4..5. display / visibility / opacity, if anyone can tell us.
|
|
815
|
+
GUARDED on both paths: the document's own view first, the
|
|
816
|
+
global second, and neither is assumed to exist. Returning true
|
|
817
|
+
when nothing can be computed is deliberate -- an element we
|
|
818
|
+
cannot measure is reported as present rather than silently
|
|
819
|
+
vanishing from a snapshot. */
|
|
820
|
+
const view = (el.ownerDocument && el.ownerDocument.defaultView)
|
|
821
|
+
|| (typeof window !== 'undefined' ? window : null);
|
|
822
|
+
if (view && typeof view.getComputedStyle === 'function') {
|
|
823
|
+
const cs = view.getComputedStyle(el);
|
|
824
|
+
if (cs && (cs.display === 'none' || cs.visibility === 'hidden' || cs.opacity === '0')) {
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
738
827
|
}
|
|
739
828
|
return true;
|
|
740
829
|
}
|
|
741
830
|
|
|
831
|
+
/* Kept as a name because the hash code reads better with it, and
|
|
832
|
+
because a reader looking for the old function should land on the
|
|
833
|
+
explanation above rather than on nothing. */
|
|
834
|
+
function _hashIsEffectivelyVisible(el) {
|
|
835
|
+
return _isPerceivable(el);
|
|
836
|
+
}
|
|
837
|
+
|
|
742
838
|
function _hashReadValue(el) {
|
|
743
839
|
if (!el || el.nodeType !== 1) return null;
|
|
744
840
|
const tag = (el.tagName || '').toLowerCase();
|
|
@@ -1018,7 +1114,7 @@
|
|
|
1018
1114
|
and a runtime that declares NAC-3 must NOT silently honor any
|
|
1019
1115
|
expected_*. */
|
|
1020
1116
|
const tier = (typeof window !== 'undefined' && window.NAC &&
|
|
1021
|
-
window.NAC.conformance_tier) ||
|
|
1117
|
+
window.NAC.conformance_tier) || DEFAULT_CONFORMANCE_TIER;
|
|
1022
1118
|
if (tier === 'NAC-3' && hasAny) {
|
|
1023
1119
|
throw NacError('feature_not_supported',
|
|
1024
1120
|
'Runtime tier is NAC-3 (non-versioned); expected_* parameters are not honored.',
|
|
@@ -1225,6 +1321,26 @@
|
|
|
1225
1321
|
of identical warnings per session. Key by (event_type, field).
|
|
1226
1322
|
Reset by calling NAC.__resetLegacyWarnDedup() (test-only). */
|
|
1227
1323
|
const _legacyWarnSeen = Object.create(null);
|
|
1324
|
+
/* 2.7.0 (TF-A03) -- THE REMOVAL PROMISE IS WITHDRAWN, and this
|
|
1325
|
+
message is where it was being made. It said "Will be removed in
|
|
1326
|
+
v2.0" to every adopter's console; v2.0 shipped, so did 2.1
|
|
1327
|
+
through 2.6, and the fields are all still here. A promise that
|
|
1328
|
+
outlives three majors is not a deprecation, it is noise that
|
|
1329
|
+
teaches authors to ignore the warning.
|
|
1330
|
+
|
|
1331
|
+
It is withdrawn rather than kept and honoured because the fields
|
|
1332
|
+
are LOAD-BEARING, which no document noticed: the event matcher
|
|
1333
|
+
that decides whether an event belongs to an element READS
|
|
1334
|
+
from_nac_id / target_nac_id / over_nac_id / nac_id / id /
|
|
1335
|
+
step_id as resolution keys (see _eventMatchesElement below).
|
|
1336
|
+
Removing them would not retire six lines, it would silently
|
|
1337
|
+
break wait_for() and assert_event_fired() on any host that
|
|
1338
|
+
emits only the alias -- which is exactly the shape of host the
|
|
1339
|
+
aliases exist for.
|
|
1340
|
+
|
|
1341
|
+
So: the alias stays, the canonical is still the one to write,
|
|
1342
|
+
and the warning says that without naming a version it cannot
|
|
1343
|
+
keep. Decision D-12, owner delegation of 2026-11-24. */
|
|
1228
1344
|
function _legacyWarn(eventType, field, canonical) {
|
|
1229
1345
|
const key = eventType + '::' + field;
|
|
1230
1346
|
if (_legacyWarnSeen[key]) return;
|
|
@@ -1232,7 +1348,9 @@
|
|
|
1232
1348
|
if (typeof console !== 'undefined' && console.warn) {
|
|
1233
1349
|
console.warn('[NAC] legacy_event_field: ' + eventType +
|
|
1234
1350
|
' detail.' + field + ' is a legacy alias. Use detail.' +
|
|
1235
|
-
canonical + ' instead.
|
|
1351
|
+
canonical + ' instead. The alias is frozen, not scheduled ' +
|
|
1352
|
+
'for removal: the event matcher resolves it (SPEC 7.4, ' +
|
|
1353
|
+
'decision D-12).');
|
|
1236
1354
|
}
|
|
1237
1355
|
}
|
|
1238
1356
|
|
|
@@ -1513,6 +1631,60 @@
|
|
|
1513
1631
|
return null;
|
|
1514
1632
|
}
|
|
1515
1633
|
|
|
1634
|
+
/* 2.7.0 -- `undrivable_until`, the declaration of a gated surface.
|
|
1635
|
+
|
|
1636
|
+
THE DEFECT IT ANSWERS, measured on this project's own landing page
|
|
1637
|
+
on 2026-11-25 with the probe that 2.7.0 added:
|
|
1638
|
+
`validate_global({probe: true})` reported seven
|
|
1639
|
+
nac_id_declared_not_reachable findings -- chat.lang, chat.tts,
|
|
1640
|
+
chat.mic, chat.voice.always_on, chat.log, chat.input, chat.send.
|
|
1641
|
+
All seven are real, all seven are declared, and all seven live
|
|
1642
|
+
inside a panel that stays behind `aria-hidden="true"` until
|
|
1643
|
+
somebody opens it.
|
|
1644
|
+
|
|
1645
|
+
Before this field the protocol had no way to say that, so the two
|
|
1646
|
+
parties both lost. An AGENT read a manifest advertising seven
|
|
1647
|
+
addressable ids, called click() on one of them and got
|
|
1648
|
+
NacError('hidden') with nothing to do about it -- the surface
|
|
1649
|
+
exists, is declared, and the one thing it needed to know (open the
|
|
1650
|
+
panel first) was the one thing nobody wrote down. And an AUTHOR
|
|
1651
|
+
with a legitimately gated panel had no honest way to reach
|
|
1652
|
+
conformance level 3, which asks for zero findings: the only moves
|
|
1653
|
+
available were to stop declaring the surface (worse for the agent)
|
|
1654
|
+
or to stop painting it until opened (a rewrite of the widget).
|
|
1655
|
+
|
|
1656
|
+
So an element may now declare the id that opens it:
|
|
1657
|
+
|
|
1658
|
+
{ id: 'chat.mic', role: 'action',
|
|
1659
|
+
undrivable_until: 'nac_landing.chat.toggle' }
|
|
1660
|
+
|
|
1661
|
+
and three things follow. The probe stops calling it a defect and
|
|
1662
|
+
reports it in its own `gated` bucket, which is NOT a finding.
|
|
1663
|
+
click() still refuses it while it is hidden -- the element really
|
|
1664
|
+
is unreachable, and failing closed is the whole point -- but the
|
|
1665
|
+
rejection now NAMES the gate, so the agent's next move is in the
|
|
1666
|
+
error it just got. And the declaration is checked: a gate that is
|
|
1667
|
+
not declared, not mounted, or itself unreachable is an ERROR, a
|
|
1668
|
+
harder finding than the warn it replaces. A promised way in that
|
|
1669
|
+
does not open is worse than no promise, because an agent will
|
|
1670
|
+
wait for it.
|
|
1671
|
+
|
|
1672
|
+
Fail-closed by construction: no field means no change, for every
|
|
1673
|
+
page already published. */
|
|
1674
|
+
function _resolveGate(nac_id) {
|
|
1675
|
+
for (const slug in _manifests) {
|
|
1676
|
+
const m = _manifests[slug];
|
|
1677
|
+
if (!m) continue;
|
|
1678
|
+
const all = (m.elements || []).concat(m.tabs || []);
|
|
1679
|
+
for (let i = 0; i < all.length; i++) {
|
|
1680
|
+
const e = all[i];
|
|
1681
|
+
if (!e || e.id !== nac_id) continue;
|
|
1682
|
+
return e.undrivable_until ? String(e.undrivable_until) : null;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1516
1688
|
function _hasCapability(cap) {
|
|
1517
1689
|
if (!cap) return true;
|
|
1518
1690
|
if (Array.isArray(cap)) {
|
|
@@ -1566,9 +1738,109 @@
|
|
|
1566
1738
|
'draggable', 'drop-target',
|
|
1567
1739
|
/* Tolerated for legacy buttons that just need to be clickable
|
|
1568
1740
|
without contract. Falls back to action behaviour at runtime. */
|
|
1569
|
-
'button'
|
|
1741
|
+
'button',
|
|
1742
|
+
|
|
1743
|
+
/* ---- v2.8.0: the surface vocabulary (SPEC.md 1.2) ------------
|
|
1744
|
+
THE DEFECT THIS CLOSES. Measured on this tree on 2026-11-25:
|
|
1745
|
+
the normative table declared 20 roles, the tree USED 67, and
|
|
1746
|
+
52 of those were declared nowhere -- not here, not in the
|
|
1747
|
+
spec table, not in the click completion map. Every one of
|
|
1748
|
+
them had been written into a page by somebody who needed the
|
|
1749
|
+
word, and the protocol's answer was to treat it as `action`
|
|
1750
|
+
and wait five seconds for an event that role never emits.
|
|
1751
|
+
|
|
1752
|
+
This Set is the runtime's half of the contract and section 1
|
|
1753
|
+
of SPEC.md is the document's half. They are hand-written in
|
|
1754
|
+
two places on purpose -- the runtime must refuse an unknown
|
|
1755
|
+
role with no network and no spec file at hand -- and from
|
|
1756
|
+
2.8.0 scripts/check-role-registries.mjs refuses the build
|
|
1757
|
+
when the two halves disagree. Before that gate existed the
|
|
1758
|
+
two lists had already drifted once (the spec table carried
|
|
1759
|
+
draggable / drop-target for four minor versions while the
|
|
1760
|
+
lint's copy did not), so this is not a hypothetical. */
|
|
1761
|
+
|
|
1762
|
+
/* Maps. The interior is drawn, not marked up. */
|
|
1763
|
+
'map', 'map-layer', 'map-marker',
|
|
1764
|
+
/* Charts: chart-series is the operable part, chart-point the
|
|
1765
|
+
readable one. */
|
|
1766
|
+
'chart', 'chart-series', 'chart-point',
|
|
1767
|
+
'calendar', 'calendar-event',
|
|
1768
|
+
/* tree-children exists as a role because a collapsed subtree is
|
|
1769
|
+
IN the DOM and not operable, and that is the distinction an
|
|
1770
|
+
agent has to be able to make. */
|
|
1771
|
+
'tree', 'tree-node', 'tree-children',
|
|
1772
|
+
'timeline', 'timeline-item',
|
|
1773
|
+
'carousel', 'carousel-slide',
|
|
1774
|
+
/* Live regions. One-to-one with ARIA on purpose. `feedback` is
|
|
1775
|
+
narrower than `status` and is what NAC.read_feedback() reads. */
|
|
1776
|
+
'status', 'log', 'toast', 'toast-region', 'banner', 'feedback',
|
|
1777
|
+
/* Overlays. `modal` is the general case of `confirm-dialog`. */
|
|
1778
|
+
'modal', 'drawer', 'bottom-sheet',
|
|
1779
|
+
/* Controls whose value is not their text: these are what tell an
|
|
1780
|
+
agent to resolve through options() instead of typing. */
|
|
1781
|
+
'combobox', 'listbox', 'slider', 'richtext',
|
|
1782
|
+
/* The containers of controls that were already declared. */
|
|
1783
|
+
'tablist', 'tabpanel', 'stepper', 'accordion-section',
|
|
1784
|
+
'breadcrumb', 'pagination-control',
|
|
1785
|
+
/* Identity, and the state of the interface itself. `skeleton`
|
|
1786
|
+
means NOT LOADED YET and `empty-state` means NOTHING HERE,
|
|
1787
|
+
AND THAT IS NOT AN ERROR -- the difference between waiting,
|
|
1788
|
+
moving on, and reporting a problem. */
|
|
1789
|
+
'avatar', 'presence-indicator', 'skeleton', 'empty-state',
|
|
1790
|
+
/* Structure. Every one of these is consumed by something: three
|
|
1791
|
+
are queried by this runtime, `list` hosts reorder(), and
|
|
1792
|
+
`canvas` is the door section 15.12 assigned to that surface. */
|
|
1793
|
+
'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas'
|
|
1570
1794
|
]);
|
|
1571
1795
|
|
|
1796
|
+
/* ---- Declared aliases (SPEC.md 1.5) ---------------------------
|
|
1797
|
+
Seven spellings this tree had grown for roles that already had a
|
|
1798
|
+
name. They are RESOLVED, not rejected: a spelling that ever
|
|
1799
|
+
worked keeps working (section 12 promise 2), and the migration
|
|
1800
|
+
of a tree is a decision its owner makes one page at a time, not
|
|
1801
|
+
something an upgrade imposes.
|
|
1802
|
+
|
|
1803
|
+
Resolution happens in _canonicalRole() below, before anything
|
|
1804
|
+
else in the runtime looks at a role -- so an alias reaches the
|
|
1805
|
+
known-role check, the click completion map and the manifest
|
|
1806
|
+
validator already spelled canonically. The static lint reports
|
|
1807
|
+
them as `dom_role_legacy_spelling` at severity warn, which is
|
|
1808
|
+
how a tree gets migrated deliberately.
|
|
1809
|
+
|
|
1810
|
+
NOT in this table, measured and kept as roles of their own:
|
|
1811
|
+
`feedback` (NAC.read_feedback() filters on it), `label`, `row`,
|
|
1812
|
+
`toast`, `toast-region` and `banner` (this runtime queries each
|
|
1813
|
+
of them by selector). A role the implementation reads is part
|
|
1814
|
+
of the contract whether the document said so or not. */
|
|
1815
|
+
const _ROLE_ALIASES = {
|
|
1816
|
+
'treenode': 'tree-node',
|
|
1817
|
+
'timeline-entry': 'timeline-item',
|
|
1818
|
+
'input': 'field',
|
|
1819
|
+
'textbox': 'field',
|
|
1820
|
+
'panel': 'region',
|
|
1821
|
+
'fab': 'action',
|
|
1822
|
+
'dropzone': 'drop-target'
|
|
1823
|
+
};
|
|
1824
|
+
|
|
1825
|
+
/* Roles registered at runtime by a host (NAC.register_role, v2.8).
|
|
1826
|
+
Kept apart from _KNOWN_ROLES_V22 so introspection can always
|
|
1827
|
+
say which half of the vocabulary a role came from: the protocol
|
|
1828
|
+
or this page. */
|
|
1829
|
+
const _REGISTERED_ROLES = new Map();
|
|
1830
|
+
|
|
1831
|
+
function _canonicalRole(role) {
|
|
1832
|
+
if (!role) return role;
|
|
1833
|
+
const r = String(role);
|
|
1834
|
+
return Object.prototype.hasOwnProperty.call(_ROLE_ALIASES, r)
|
|
1835
|
+
? _ROLE_ALIASES[r]
|
|
1836
|
+
: r;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
function _roleIsKnown(role) {
|
|
1840
|
+
const r = _canonicalRole(role);
|
|
1841
|
+
return _KNOWN_ROLES_V22.has(r) || _REGISTERED_ROLES.has(r);
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1572
1844
|
function _v22Emit(severity, code, nac_id, message, detail) {
|
|
1573
1845
|
const fn = severity === 'error'
|
|
1574
1846
|
? (typeof console !== 'undefined' && console.error ? console.error.bind(console) : null)
|
|
@@ -1592,7 +1864,7 @@
|
|
|
1592
1864
|
if (!id) return; /* spec-level error caught elsewhere */
|
|
1593
1865
|
|
|
1594
1866
|
/* Check 1: role enumeration. */
|
|
1595
|
-
if (role && !
|
|
1867
|
+
if (role && !_roleIsKnown(role)) {
|
|
1596
1868
|
findings.push({
|
|
1597
1869
|
code: 'manifest_role_unknown',
|
|
1598
1870
|
nac_id: id,
|
|
@@ -1601,6 +1873,26 @@
|
|
|
1601
1873
|
detail: { plugin: slug, source: source, role: role }
|
|
1602
1874
|
});
|
|
1603
1875
|
}
|
|
1876
|
+
/* v2.8.0: a declared alias (SPEC.md 1.5) is legal, and is
|
|
1877
|
+
REPORTED WITHOUT JOINING `findings` -- emitted straight at
|
|
1878
|
+
warn severity instead.
|
|
1879
|
+
|
|
1880
|
+
That distinction is the whole point, and the first draft of
|
|
1881
|
+
this block got it wrong: every entry of `findings` is emitted
|
|
1882
|
+
as an error AND makes register() throw under
|
|
1883
|
+
STRICT_VALIDATION, which has been the default since 2.3. So
|
|
1884
|
+
pushing this one would have meant that a page using a spelling
|
|
1885
|
+
v2.8 declares legal stops registering at all on upgrade --
|
|
1886
|
+
breaking exactly the adopter the alias table exists to
|
|
1887
|
+
protect, in the same release that promised not to. The suite
|
|
1888
|
+
that caught it is runtime/test/role-vocabulary.mjs. */
|
|
1889
|
+
if (role && role !== _canonicalRole(role)) {
|
|
1890
|
+
_v22Emit('warn', 'manifest_role_legacy_spelling', id,
|
|
1891
|
+
'plugin "' + slug + '" id="' + id + '" uses the legacy role spelling "' +
|
|
1892
|
+
role + '"; the canonical role is "' + _canonicalRole(role) +
|
|
1893
|
+
'" (SPEC.md 1.5). The alias resolves, so nothing is broken today.',
|
|
1894
|
+
{ plugin: slug, source: source, role: role, canonical: _canonicalRole(role) });
|
|
1895
|
+
}
|
|
1604
1896
|
|
|
1605
1897
|
/* Check 2: tab-id naming convention -- id like "tab.X" MUST
|
|
1606
1898
|
have role 'tab'. Catches the role drift class that broke
|
|
@@ -2112,10 +2404,60 @@
|
|
|
2112
2404
|
_emitAck('nac_editor.delete_selection');
|
|
2113
2405
|
}
|
|
2114
2406
|
async function aiCorrectSyntax() {
|
|
2115
|
-
status.textContent = 'asking AI...';
|
|
2116
2407
|
const original = textarea.value;
|
|
2408
|
+
|
|
2409
|
+
/* OFF UNTIL THE HOST SAYS WHERE (TF-A11).
|
|
2410
|
+
|
|
2411
|
+
What this did before 2.7.0: it POSTed the ENTIRE contents of
|
|
2412
|
+
the edited textarea to
|
|
2413
|
+
|
|
2414
|
+
(window.NacChat && window.NacChat._endpoint)
|
|
2415
|
+
|| '/crm/api/v1/yujin/nac-demo'
|
|
2416
|
+
|
|
2417
|
+
-- a default nobody on the host side had declared. The matter
|
|
2418
|
+
is narrower than it first looks and worth stating precisely:
|
|
2419
|
+
the path is RELATIVE, so the request went to the host's own
|
|
2420
|
+
origin, not to a third party. This was never a leak to
|
|
2421
|
+
yujin.app from an adopter's page.
|
|
2422
|
+
|
|
2423
|
+
It was still wrong, for two reasons that survive that
|
|
2424
|
+
correction:
|
|
2425
|
+
|
|
2426
|
+
1. a library does not get to send the user's text anywhere,
|
|
2427
|
+
not even to the host's own server, without the host
|
|
2428
|
+
asking. The host may have no handler on that path, may
|
|
2429
|
+
log request bodies, may be under a data-handling
|
|
2430
|
+
agreement that says what leaves the browser. That is the
|
|
2431
|
+
host's call to make and it was made for them.
|
|
2432
|
+
2. the only way to change it lived in ANOTHER FILE. An
|
|
2433
|
+
adopter who loads js/nac.js alone -- the documented way
|
|
2434
|
+
to get the runtime -- had no handle to redirect it and no
|
|
2435
|
+
way to switch it off.
|
|
2436
|
+
|
|
2437
|
+
So the endpoint is now declared, and on THIS file's export so
|
|
2438
|
+
loading the runtime alone is enough:
|
|
2439
|
+
|
|
2440
|
+
NAC.editor_ai_endpoint = '/my/own/handler';
|
|
2441
|
+
|
|
2442
|
+
With nothing declared and no chat client loaded, nothing is
|
|
2443
|
+
sent and the control says so. The action stays declared in the
|
|
2444
|
+
manifest and the button stays bound: an agent that invokes it
|
|
2445
|
+
gets an honest "not configured" instead of the control
|
|
2446
|
+
vanishing from the contract between one page and the next.
|
|
2447
|
+
NacChat's endpoint is still honoured when the host loaded the
|
|
2448
|
+
chat client, because that IS the host declaring one. */
|
|
2449
|
+
const endpoint = (global.NAC && global.NAC.editor_ai_endpoint)
|
|
2450
|
+
|| (window.NacChat && window.NacChat._endpoint)
|
|
2451
|
+
|| null;
|
|
2452
|
+
if (!endpoint) {
|
|
2453
|
+
status.textContent = 'AI correction is not configured: set NAC.editor_ai_endpoint'
|
|
2454
|
+
+ ' to the handler that should receive the text. Nothing was sent.';
|
|
2455
|
+
_emitAck('nac_editor.ai_correct_syntax');
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
status.textContent = 'asking AI...';
|
|
2117
2460
|
try {
|
|
2118
|
-
const endpoint = (window.NacChat && window.NacChat._endpoint) || '/crm/api/v1/yujin/nac-demo';
|
|
2119
2461
|
const resp = await fetch(endpoint, {
|
|
2120
2462
|
method: 'POST',
|
|
2121
2463
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -2205,18 +2547,37 @@
|
|
|
2205
2547
|
let manifest;
|
|
2206
2548
|
if (typeof arg1 === 'string' && arg2 && typeof arg2 === 'object') {
|
|
2207
2549
|
manifest = arg2;
|
|
2208
|
-
if (!manifest.plugin_slug) manifest.plugin_slug = arg1;
|
|
2209
2550
|
} else {
|
|
2210
2551
|
manifest = arg1;
|
|
2211
2552
|
}
|
|
2212
2553
|
if (!manifest || typeof manifest !== 'object') {
|
|
2213
2554
|
throw NacError('invalid', 'manifest object required');
|
|
2214
2555
|
}
|
|
2556
|
+
/* 2.7.0 (sec 7.2): the signed body is the manifest AS THE HOST
|
|
2557
|
+
BUILT IT. Snapshot it here, before the three defaults below
|
|
2558
|
+
change the bytes -- a host that signs {plugin_slug, elements}
|
|
2559
|
+
and calls register('invoice', m) would otherwise sign one
|
|
2560
|
+
object and have the runtime verify another, and the failure
|
|
2561
|
+
would look like a bad secret. */
|
|
2562
|
+
const _signedBody = (manifest.provenance && manifest.provenance.signature)
|
|
2563
|
+
? _manifestCanonicalString(manifest)
|
|
2564
|
+
: null;
|
|
2565
|
+
if (typeof arg1 === 'string' && arg2 === manifest && !manifest.plugin_slug) {
|
|
2566
|
+
manifest.plugin_slug = arg1;
|
|
2567
|
+
}
|
|
2215
2568
|
const slug = String(manifest.plugin_slug || '').trim();
|
|
2216
2569
|
if (!slug) throw NacError('invalid', 'manifest.plugin_slug required');
|
|
2217
2570
|
if (!manifest.version) manifest.version = '1.0.0';
|
|
2218
2571
|
if (!manifest.nac_version) manifest.nac_version = '1.0';
|
|
2219
2572
|
|
|
2573
|
+
/* 2.7.0 (sec 7.2, TF-A17): manifest authenticity. Throws when a
|
|
2574
|
+
provenance.signature is present and no registered tenant secret
|
|
2575
|
+
matches it; records what it could tell either way, so a
|
|
2576
|
+
validator can ask NAC.manifest_provenance(slug) instead of
|
|
2577
|
+
assuming. No secret registered = no check and no change for
|
|
2578
|
+
every adopter who never set one. */
|
|
2579
|
+
_recordManifestProvenance(slug, manifest, _signedBody);
|
|
2580
|
+
|
|
2220
2581
|
/* v2.5 / RFC V24-01 -- synchronous slug uniqueness gate.
|
|
2221
2582
|
Throws NacError('duplicate_plugin_no_instance_id', ...) when
|
|
2222
2583
|
the DOM already contains multiple roots for this slug and any
|
|
@@ -2419,6 +2780,12 @@
|
|
|
2419
2780
|
function unregister(slug) {
|
|
2420
2781
|
delete _manifests[slug];
|
|
2421
2782
|
delete _instances[slug];
|
|
2783
|
+
/* 2.7.0 (sec 7.2): the authenticity record is about the manifest
|
|
2784
|
+
that WAS registered. Leaving it behind would let a validator
|
|
2785
|
+
read "verified" for a plugin that is no longer mounted. */
|
|
2786
|
+
if (typeof _manifestProvenance !== 'undefined') {
|
|
2787
|
+
delete _manifestProvenance[slug];
|
|
2788
|
+
}
|
|
2422
2789
|
}
|
|
2423
2790
|
|
|
2424
2791
|
function manifest(slug) {
|
|
@@ -2450,17 +2817,24 @@
|
|
|
2450
2817
|
in one atomic step. Single source of truth for OCC. */
|
|
2451
2818
|
function syncPlugin(arg1, arg2) {
|
|
2452
2819
|
let m;
|
|
2820
|
+
let twoArg = false;
|
|
2453
2821
|
if (typeof arg1 === 'string' && arg2 && typeof arg2 === 'object') {
|
|
2454
2822
|
/* (slug, manifest) form -- match register's calling convention. */
|
|
2455
2823
|
m = Object.assign({}, arg2);
|
|
2456
|
-
|
|
2824
|
+
twoArg = true;
|
|
2825
|
+
/* 2.7.0 (sec 7.2): plugin_slug used to be injected HERE, which
|
|
2826
|
+
changed the bytes of a signed manifest before register() could
|
|
2827
|
+
hash them -- a host that signed {elements} and called
|
|
2828
|
+
syncPlugin('invoice', m) got a signature_mismatch that looked
|
|
2829
|
+
like a wrong secret. register() injects it now, after taking
|
|
2830
|
+
its snapshot, and both call forms go through that one place. */
|
|
2457
2831
|
} else if (arg1 && typeof arg1 === 'object') {
|
|
2458
2832
|
m = arg1;
|
|
2459
2833
|
} else {
|
|
2460
2834
|
throw NacError('invalid',
|
|
2461
2835
|
'syncPlugin: requires (manifest) or (slug, manifest)');
|
|
2462
2836
|
}
|
|
2463
|
-
const slug = m.plugin_slug;
|
|
2837
|
+
const slug = m.plugin_slug || (twoArg ? arg1 : null);
|
|
2464
2838
|
if (!slug || typeof slug !== 'string') {
|
|
2465
2839
|
throw NacError('invalid',
|
|
2466
2840
|
'syncPlugin: manifest.plugin_slug required (non-empty string)');
|
|
@@ -2476,7 +2850,7 @@
|
|
|
2476
2850
|
/* Delegate to register() so validation + storage code-path stays
|
|
2477
2851
|
exactly one place. If register throws (strict validation), the
|
|
2478
2852
|
prior entry is GONE -- caller's responsibility to handle. */
|
|
2479
|
-
register(m);
|
|
2853
|
+
if (twoArg) register(arg1, m); else register(m);
|
|
2480
2854
|
/* Bump V24-04 OCC version on REPLACE only. First-add is a normal
|
|
2481
2855
|
register: the boot tree_version already reflects the new plugin
|
|
2482
2856
|
and subscribers do not need to refresh anything that did not
|
|
@@ -2527,7 +2901,14 @@
|
|
|
2527
2901
|
|
|
2528
2902
|
Provenance on document:
|
|
2529
2903
|
nac:authority:requested / :granted / :denied / :revoked / :expired
|
|
2530
|
-
nac:action:confirmed
|
|
2904
|
+
nac:action:confirmed
|
|
2905
|
+
|
|
2906
|
+
(2.8.0: this comment used to name `nac:action:rejected` as well.
|
|
2907
|
+
No call site produces it -- the comment was the only place that
|
|
2908
|
+
name existed, which is the same defect as an event the spec names
|
|
2909
|
+
and the runtime never emits, one layer in. Found by
|
|
2910
|
+
scripts/check-event-vocabulary.mjs, which now refuses both
|
|
2911
|
+
directions.) */
|
|
2531
2912
|
|
|
2532
2913
|
const _V25_SCOPE_RANK = { low: 1, medium: 2, high: 3 };
|
|
2533
2914
|
const _v25_authority_grants = new Map();
|
|
@@ -2787,10 +3168,12 @@
|
|
|
2787
3168
|
}
|
|
2788
3169
|
|
|
2789
3170
|
function _allElements() {
|
|
3171
|
+
_nac_requireDocument('find');
|
|
2790
3172
|
return _deepQueryAll('[data-nac-id]', document, 0);
|
|
2791
3173
|
}
|
|
2792
3174
|
|
|
2793
3175
|
function _activePlugin() {
|
|
3176
|
+
_nac_requireDocument('find');
|
|
2794
3177
|
/* Most recently mounted plugin with state=ready wins. Falls back
|
|
2795
3178
|
to topmost plugin root in the DOM order. */
|
|
2796
3179
|
const plugins = Array.prototype.slice.call(
|
|
@@ -2901,17 +3284,18 @@
|
|
|
2901
3284
|
return null;
|
|
2902
3285
|
}
|
|
2903
3286
|
|
|
3287
|
+
/* The agent-facing `visible`. One predicate with the hash since
|
|
3288
|
+
2.7.0 -- see the long note on _isPerceivable for why the two used
|
|
3289
|
+
to disagree and which way the disagreement was settled. This also
|
|
3290
|
+
stops throwing in an environment with no defaultView. */
|
|
2904
3291
|
function _isVisible(el) {
|
|
2905
|
-
|
|
2906
|
-
const r = el.getBoundingClientRect();
|
|
2907
|
-
if (r.width === 0 && r.height === 0) return false;
|
|
2908
|
-
const cs = el.ownerDocument.defaultView.getComputedStyle(el);
|
|
2909
|
-
return cs.display !== 'none' && cs.visibility !== 'hidden' && cs.opacity !== '0';
|
|
3292
|
+
return _isPerceivable(el);
|
|
2910
3293
|
}
|
|
2911
3294
|
|
|
2912
3295
|
/* ---------- Public read API ------------------------------------- */
|
|
2913
3296
|
|
|
2914
3297
|
function describe() {
|
|
3298
|
+
_nac_requireDocument('describe');
|
|
2915
3299
|
const plugins = Array.prototype.slice.call(
|
|
2916
3300
|
document.querySelectorAll('[data-nac-plugin]')
|
|
2917
3301
|
).map(function (root) {
|
|
@@ -2980,6 +3364,152 @@
|
|
|
2980
3364
|
});
|
|
2981
3365
|
}
|
|
2982
3366
|
|
|
3367
|
+
/* ---- NAC.register_role(name, spec) (v2.8.0, SPEC.md 1.4) ------
|
|
3368
|
+
THE PROBLEM THIS SOLVES. The nineteen pieces of work that built
|
|
3369
|
+
the v2.8 vocabulary all shared one assumption: that adding a
|
|
3370
|
+
role means editing the protocol. Six layers, two of them
|
|
3371
|
+
published, one of them in nine languages. That is why the 52
|
|
3372
|
+
undeclared roles of 2026-11-25 existed at all -- somebody
|
|
3373
|
+
needed a word, the only door open was writing it into the HTML
|
|
3374
|
+
and hoping nobody looked, and for four years nobody did,
|
|
3375
|
+
because no rule compared the markup against the vocabulary.
|
|
3376
|
+
|
|
3377
|
+
So the vocabulary gets a door. A host declares a role at
|
|
3378
|
+
runtime, with the completion events it answers with, and from
|
|
3379
|
+
that moment:
|
|
3380
|
+
- the manifest validator accepts it instead of reporting
|
|
3381
|
+
manifest_role_unknown,
|
|
3382
|
+
- click() waits for ITS events instead of falling back to the
|
|
3383
|
+
action family and timing out at five seconds,
|
|
3384
|
+
- describe() / roles() report where it came from.
|
|
3385
|
+
|
|
3386
|
+
THE HARD PART, and how it is answered. A registered role exists
|
|
3387
|
+
only while the page is loaded, and the static lint runs with no
|
|
3388
|
+
page -- reading files. A role registered in JavaScript is
|
|
3389
|
+
invisible to it, so the lint would report a page as wrong for
|
|
3390
|
+
using a role that page itself declares. The answer is NOT to
|
|
3391
|
+
make the lint execute the page (a validator that runs the code
|
|
3392
|
+
it is validating has stopped being a validator). It is a second
|
|
3393
|
+
declaration the lint CAN read: a `nac3.roles.json` next to the
|
|
3394
|
+
markup, with the same shape as this argument. Two declarations
|
|
3395
|
+
of one fact is exactly the producer/consumer asymmetry this
|
|
3396
|
+
release spent its time removing, so it is not left to good
|
|
3397
|
+
intentions: `npx nac3 lint` reports role_registration_undeclared
|
|
3398
|
+
when a page calls register_role for a role its
|
|
3399
|
+
nac3.roles.json does not carry, and role_registration_orphan in
|
|
3400
|
+
the other direction.
|
|
3401
|
+
|
|
3402
|
+
WHAT IT REFUSES, and why each refusal is not negotiable:
|
|
3403
|
+
- a canonical role (SPEC.md 1.1 / 1.2). A page cannot
|
|
3404
|
+
redefine `action`: an agent that trusted the protocol's
|
|
3405
|
+
meaning of a canonical role would be reading a different
|
|
3406
|
+
contract on every page. This is the whole value of a closed
|
|
3407
|
+
vocabulary and a registry does not get to open it.
|
|
3408
|
+
- a declared alias (SPEC.md 1.5). Same reason, one level down.
|
|
3409
|
+
- a name that is not /^[a-z][a-z0-9-]*$/. Ids are opaque and
|
|
3410
|
+
roles are not: a role is compared, printed and published.
|
|
3411
|
+
- an event name that is not `nac:*`. A completion event that
|
|
3412
|
+
does not belong to this protocol cannot be waited for by
|
|
3413
|
+
anything that speaks it.
|
|
3414
|
+
Re-registering the SAME role with the SAME spec is idempotent
|
|
3415
|
+
and returns ok -- a page that registers on every render must not
|
|
3416
|
+
fail on the second one. Re-registering with a DIFFERENT spec
|
|
3417
|
+
throws: that is the one case where silence would leave two
|
|
3418
|
+
meanings for one word, which is where this release started. */
|
|
3419
|
+
function register_role(name, spec) {
|
|
3420
|
+
const raw = String(name == null ? '' : name);
|
|
3421
|
+
if (!/^[a-z][a-z0-9-]*$/.test(raw)) {
|
|
3422
|
+
throw NacError('invalid_role',
|
|
3423
|
+
'register_role: "' + raw + '" is not a legal role name. A role is lowercase'
|
|
3424
|
+
+ ' letters, digits and hyphens, starting with a letter (SPEC.md 1.4).');
|
|
3425
|
+
}
|
|
3426
|
+
if (_KNOWN_ROLES_V22.has(raw)) {
|
|
3427
|
+
throw NacError('role_is_canonical',
|
|
3428
|
+
'register_role: "' + raw + '" is a canonical role of SPEC.md section 1 and cannot be'
|
|
3429
|
+
+ ' redefined. An agent relies on a canonical role meaning the same thing on every'
|
|
3430
|
+
+ ' page; a page that could change it would be publishing a different protocol.');
|
|
3431
|
+
}
|
|
3432
|
+
if (Object.prototype.hasOwnProperty.call(_ROLE_ALIASES, raw)) {
|
|
3433
|
+
throw NacError('role_is_alias',
|
|
3434
|
+
'register_role: "' + raw + '" is a declared alias of "' + _ROLE_ALIASES[raw] +
|
|
3435
|
+
'" (SPEC.md 1.5) and cannot be redefined.');
|
|
3436
|
+
}
|
|
3437
|
+
spec = spec || {};
|
|
3438
|
+
const events = Array.isArray(spec.events) ? spec.events.slice(0, 2) : [];
|
|
3439
|
+
for (const ev of events) {
|
|
3440
|
+
if (typeof ev !== 'string' || ev.indexOf('nac:') !== 0) {
|
|
3441
|
+
throw NacError('invalid_role',
|
|
3442
|
+
'register_role("' + raw + '"): completion event "' + String(ev) + '" is not a NAC3'
|
|
3443
|
+
+ ' event name. A completion event must be nac:<family>:<name> so anything that'
|
|
3444
|
+
+ ' speaks this protocol can wait for it (SPEC.md 6.4).');
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
const entry = {
|
|
3448
|
+
role: raw,
|
|
3449
|
+
events: events,
|
|
3450
|
+
clickable: events.length > 0,
|
|
3451
|
+
describes: (typeof spec.describes === 'string') ? spec.describes : null,
|
|
3452
|
+
plugin: (typeof spec.plugin === 'string') ? spec.plugin : null,
|
|
3453
|
+
source: 'registered'
|
|
3454
|
+
};
|
|
3455
|
+
const prior = _REGISTERED_ROLES.get(raw);
|
|
3456
|
+
if (prior) {
|
|
3457
|
+
/* Idempotent on an identical re-registration: a page that
|
|
3458
|
+
registers its roles on every render must not fail on the
|
|
3459
|
+
second render. Different spec, same name -> throw, because
|
|
3460
|
+
that is two meanings for one word. */
|
|
3461
|
+
if (JSON.stringify(prior) === JSON.stringify(entry)) {
|
|
3462
|
+
return { ok: true, role: raw, already: true };
|
|
3463
|
+
}
|
|
3464
|
+
throw NacError('role_conflict',
|
|
3465
|
+
'register_role("' + raw + '"): already registered with a different definition.'
|
|
3466
|
+
+ ' Prior events=[' + prior.events.join(', ') + '], new events=[' +
|
|
3467
|
+
events.join(', ') + ']. Two definitions of one role is the drift this'
|
|
3468
|
+
+ ' registry exists to prevent.');
|
|
3469
|
+
}
|
|
3470
|
+
_REGISTERED_ROLES.set(raw, entry);
|
|
3471
|
+
try {
|
|
3472
|
+
document.dispatchEvent(new CustomEvent('nac:role_registered', {
|
|
3473
|
+
detail: { role: raw, events: events, clickable: entry.clickable,
|
|
3474
|
+
describes: entry.describes, plugin: entry.plugin },
|
|
3475
|
+
bubbles: true
|
|
3476
|
+
}));
|
|
3477
|
+
} catch (_) { /* headless (section 19): no document to dispatch on */ }
|
|
3478
|
+
return { ok: true, role: raw, already: false };
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
/* NAC.roles() -- the vocabulary, with the provenance of every
|
|
3482
|
+
word. Built so a consumer never has to ask which half of the
|
|
3483
|
+
contract a role came from: `canonical` is the protocol,
|
|
3484
|
+
`registered` is this page, `aliases` is what resolves to what.
|
|
3485
|
+
Published as data for the same reason section 1 is: a list a
|
|
3486
|
+
consumer has to reconstruct from prose is a list that rots. */
|
|
3487
|
+
function roles() {
|
|
3488
|
+
const registered = [];
|
|
3489
|
+
_REGISTERED_ROLES.forEach(function (v) { registered.push(v); });
|
|
3490
|
+
const click_events = {};
|
|
3491
|
+
for (const r in _CLICK_EVENT_FAMILY) {
|
|
3492
|
+
if (Object.prototype.hasOwnProperty.call(_CLICK_EVENT_FAMILY, r)) {
|
|
3493
|
+
click_events[r] = _CLICK_EVENT_FAMILY[r].slice();
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
return {
|
|
3497
|
+
spec_version: '2.8',
|
|
3498
|
+
canonical: Array.from(_KNOWN_ROLES_V22),
|
|
3499
|
+
aliases: Object.assign({}, _ROLE_ALIASES),
|
|
3500
|
+
registered: registered,
|
|
3501
|
+
click_events: click_events,
|
|
3502
|
+
no_click_event: Array.from(_CLICK_NO_EVENT_ROLES)
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
/* NAC.canonical_role(role) -- what a spelling means. One line, and
|
|
3507
|
+
it exists because every consumer that compares a role to a
|
|
3508
|
+
constant needs the same answer this runtime gives itself. */
|
|
3509
|
+
function canonical_role(role) {
|
|
3510
|
+
return _canonicalRole(role);
|
|
3511
|
+
}
|
|
3512
|
+
|
|
2983
3513
|
function snapshot_state() {
|
|
2984
3514
|
const errs = _allElements()
|
|
2985
3515
|
.filter(function (el) {
|
|
@@ -3143,7 +3673,11 @@
|
|
|
3143
3673
|
const _CLICK_EVENT_FAMILY = {
|
|
3144
3674
|
'action': ['nac:action:succeeded', 'nac:action:failed'],
|
|
3145
3675
|
'option': ['nac:field:changed'],
|
|
3146
|
-
|
|
3676
|
+
/* v2.8.0: the failure half. nac:tab:activation_failed has been
|
|
3677
|
+
emitted since v2.2 and was not in this map, so click() on a
|
|
3678
|
+
tab whose activation was REFUSED waited out its full timeout
|
|
3679
|
+
instead of rejecting the moment the refusal arrived. */
|
|
3680
|
+
'tab': ['nac:tab:activated', 'nac:tab:activation_failed'],
|
|
3147
3681
|
'breadcrumb-item': ['nac:breadcrumb:navigated'],
|
|
3148
3682
|
'accordion-toggle': ['nac:accordion:expanded', 'nac:accordion:collapsed'],
|
|
3149
3683
|
'step': ['nac:step:advanced'],
|
|
@@ -3164,8 +3698,104 @@
|
|
|
3164
3698
|
column_nac_id and filter_nac_id as nac_id matches. */
|
|
3165
3699
|
'sort-control': ['nac:table:sort_changed'],
|
|
3166
3700
|
'filter-control': ['nac:table:filter_changed'],
|
|
3701
|
+
/* v2.7.0: `button` made EXPLICIT. SPEC.md section 1 says the
|
|
3702
|
+
runtime treats this role as `action`, and it did -- but only by
|
|
3703
|
+
falling through the `||` below, which is indistinguishable from
|
|
3704
|
+
a role nobody thought about. The fallback was right for this one
|
|
3705
|
+
role and wrong for the other eight, and nothing told them
|
|
3706
|
+
apart. Declaring it costs one line and removes the ambiguity
|
|
3707
|
+
that let the other eight hide. */
|
|
3708
|
+
'button': ['nac:action:succeeded', 'nac:action:failed'],
|
|
3709
|
+
|
|
3710
|
+
/* ---- v2.8.0: the twelve clickable surface roles -------------
|
|
3711
|
+
Each line removes one five-second timeout that blamed the
|
|
3712
|
+
page. The runtime ALREADY emitted every event named here --
|
|
3713
|
+
nac:map:marker_selected has existed since 2.5 -- so the
|
|
3714
|
+
defect was never that the signal was missing: it was that
|
|
3715
|
+
click() did not know the signal belonged to that role, took
|
|
3716
|
+
the `|| _CLICK_EVENT_FAMILY['action']` fallback below, waited
|
|
3717
|
+
for nac:action:succeeded, heard nothing and reported that the
|
|
3718
|
+
WIDGET had not acknowledged. The project paid this twice
|
|
3719
|
+
before (v1.6.4 for `field`, v1.6.6 for `sort-control`, both
|
|
3720
|
+
comments above) and both times fixed one role instead of the
|
|
3721
|
+
class. These twelve are the class.
|
|
3722
|
+
|
|
3723
|
+
Where two events existed for the same thing, the canonical
|
|
3724
|
+
one is here and the other stays emitted (SPEC.md 6.4). */
|
|
3725
|
+
'map-marker': ['nac:map:marker_selected'],
|
|
3726
|
+
'map-layer': ['nac:map:layer_toggled'],
|
|
3727
|
+
'chart-series': ['nac:chart:series_toggled'],
|
|
3728
|
+
'calendar-event': ['nac:calendar:event_selected'],
|
|
3729
|
+
'tree-node': ['nac:tree:selected'],
|
|
3730
|
+
'carousel-slide': ['nac:carousel:slide_changed'],
|
|
3731
|
+
'toast': ['nac:toast:dismissed'],
|
|
3732
|
+
'banner': ['nac:banner:dismissed'],
|
|
3733
|
+
'combobox': ['nac:field:changed'],
|
|
3734
|
+
'listbox': ['nac:field:changed'],
|
|
3735
|
+
'slider': ['nac:slider:value_changed'],
|
|
3736
|
+
'richtext': ['nac:richtext:format_applied'],
|
|
3167
3737
|
};
|
|
3168
3738
|
|
|
3739
|
+
/* The canonical roles that have NO completion event of their own,
|
|
3740
|
+
declared rather than left to the fallback.
|
|
3741
|
+
|
|
3742
|
+
THE DEFECT THIS CLOSES (TF-A14). _CLICK_EVENT_FAMILY knew 11 of
|
|
3743
|
+
the 20 canonical roles of SPEC.md section 1, and click() on
|
|
3744
|
+
anything else took `|| _CLICK_EVENT_FAMILY['action']` -- so it
|
|
3745
|
+
waited for nac:action:succeeded, heard nothing, timed out after
|
|
3746
|
+
five seconds and reported that the WIDGET had not acked. An agent
|
|
3747
|
+
doing exactly what the protocol tells it to do about one of these
|
|
3748
|
+
roles paid five seconds and got a message blaming the page.
|
|
3749
|
+
|
|
3750
|
+
And it is not hypothetical. The comments above record the same
|
|
3751
|
+
shape twice already: v1.6.4 for `field`, v1.6.6 for
|
|
3752
|
+
`sort-control`. Both were found by someone watching a click hang.
|
|
3753
|
+
|
|
3754
|
+
These nine are STRUCTURAL -- a plugin, a section, a region, a
|
|
3755
|
+
navigation landmark, a data-table host, a confirm dialog -- or
|
|
3756
|
+
are driven by their own verb rather than by click: a draggable and
|
|
3757
|
+
a drop target are what drag_drop() moves. None of them has a
|
|
3758
|
+
completion event in the protocol, so there is nothing for click()
|
|
3759
|
+
to wait for.
|
|
3760
|
+
|
|
3761
|
+
WHAT DOES NOT CHANGE, on purpose: click() still clicks them and
|
|
3762
|
+
still listens for the action family, because a host is free to
|
|
3763
|
+
make a region clickable and emit nac:action:succeeded, and that
|
|
3764
|
+
works today. Refusing outright would break those hosts for the
|
|
3765
|
+
sake of a tidier error. What changes is that the TIMEOUT now says
|
|
3766
|
+
what actually happened instead of blaming the widget -- see the
|
|
3767
|
+
rejection in click(). */
|
|
3768
|
+
const _CLICK_NO_EVENT_ROLES = new Set([
|
|
3769
|
+
'plugin', 'section', 'region', 'navigation', 'data-table',
|
|
3770
|
+
'confirm-dialog', 'draggable', 'drop-target',
|
|
3771
|
+
|
|
3772
|
+
/* ---- v2.8.0 ------------------------------------------------
|
|
3773
|
+
Thirty-three more, and declaring them is the whole point: a
|
|
3774
|
+
role in this Set gets a timeout message that says "this role
|
|
3775
|
+
has no completion event in the protocol", and a role in
|
|
3776
|
+
NEITHER map gets "no completion event is declared for this
|
|
3777
|
+
role" -- which is the protocol admitting a gap instead of
|
|
3778
|
+
blaming the widget. Until 2.8.0 these thirty-three were in
|
|
3779
|
+
neither map and were indistinguishable from a typo.
|
|
3780
|
+
|
|
3781
|
+
Why each is here rather than in the family map above: four
|
|
3782
|
+
are structural hosts (map, chart, calendar, tree, timeline,
|
|
3783
|
+
carousel, list), six are containers whose CONTROL carries the
|
|
3784
|
+
event (tablist, tabpanel, stepper, accordion-section,
|
|
3785
|
+
breadcrumb, pagination-control, toast-region), and the rest
|
|
3786
|
+
are read-only. Putting a read-only role in the family map
|
|
3787
|
+
would make click() promise a completion nobody emits, which
|
|
3788
|
+
is worse than the omission it would be fixing. */
|
|
3789
|
+
'map', 'chart', 'chart-point', 'calendar',
|
|
3790
|
+
'tree', 'tree-children', 'timeline', 'timeline-item',
|
|
3791
|
+
'carousel', 'status', 'log', 'toast-region', 'feedback',
|
|
3792
|
+
'modal', 'drawer', 'bottom-sheet',
|
|
3793
|
+
'tablist', 'tabpanel', 'stepper', 'accordion-section',
|
|
3794
|
+
'breadcrumb', 'pagination-control',
|
|
3795
|
+
'avatar', 'presence-indicator', 'skeleton', 'empty-state',
|
|
3796
|
+
'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas',
|
|
3797
|
+
]);
|
|
3798
|
+
|
|
3169
3799
|
/* v1.6.4: field types whose click() act on a value (toggle).
|
|
3170
3800
|
For these, the runtime synthesises nac:field:changed after
|
|
3171
3801
|
el.click() so an automation runner sees a deterministic
|
|
@@ -3235,15 +3865,52 @@
|
|
|
3235
3865
|
var rect = el.getBoundingClientRect();
|
|
3236
3866
|
hiddenByLayout = (rect.width === 0 && rect.height === 0);
|
|
3237
3867
|
}
|
|
3238
|
-
|
|
3868
|
+
/* 2.7.0: the ANCESTOR reasons too, through the same function the
|
|
3869
|
+
probe uses.
|
|
3870
|
+
|
|
3871
|
+
Found on 2026-11-25 by the suite written for undrivable_until.
|
|
3872
|
+
The two checks above read the element ITSELF, while
|
|
3873
|
+
validate_global's probe reads `closest('[aria-hidden="true"]')`,
|
|
3874
|
+
`closest('[inert]')` and the computed style -- so the two
|
|
3875
|
+
disagreed about a button inside a hidden PANEL, which is the
|
|
3876
|
+
commonest shape there is. And section 10.1 publishes the
|
|
3877
|
+
agreement as a fact: the unreachable bucket is "exactly what
|
|
3878
|
+
NAC.click() refuses with NacError('hidden')". It was not. The
|
|
3879
|
+
probe called the seven chat ids of this project's own landing
|
|
3880
|
+
page unreachable and click() would have fired into the closed
|
|
3881
|
+
panel, where the host handler never runs and the agent waits out
|
|
3882
|
+
the five-second completion timeout for a click nobody could
|
|
3883
|
+
see -- the silent damage, arriving as a timeout instead of a
|
|
3884
|
+
reason. _probeUnreachable IS the definition now, for the verb
|
|
3885
|
+
and for the validator, so a disagreement between them is not
|
|
3886
|
+
expressible. Decided rather than registered because the
|
|
3887
|
+
normative text already promised this behaviour and the code was
|
|
3888
|
+
the half that was wrong (working agreement rule 10; the owner
|
|
3889
|
+
delegated the call for this session on 2026-11-25). */
|
|
3890
|
+
var hiddenByAncestor = _probeUnreachable(el);
|
|
3891
|
+
if (hiddenByAria || hiddenByLayout || hiddenByAncestor) {
|
|
3892
|
+
/* 2.7.0: if the manifest declared what opens this element, the
|
|
3893
|
+
rejection carries it. The refusal itself does not change --
|
|
3894
|
+
the element is hidden and clicking it would be a lie -- but an
|
|
3895
|
+
agent that gets "open nac_landing.chat.toggle first" has its
|
|
3896
|
+
next move, and one that gets "is not visible" has nothing.
|
|
3897
|
+
That gap was measured on this project's own landing page:
|
|
3898
|
+
seven declared ids behind a closed panel. */
|
|
3899
|
+
var gateId = _resolveGate(nac_id);
|
|
3900
|
+
var msg = 'Element ' + nac_id + ' is not visible'
|
|
3901
|
+
+ (gateId ? ': it is declared undrivable until "' + gateId
|
|
3902
|
+
+ '" is operated -- do that first, then retry' : '');
|
|
3239
3903
|
_emitCommandRejected({
|
|
3240
3904
|
command_method: 'click',
|
|
3241
3905
|
command_target: nac_id,
|
|
3242
3906
|
reason: 'hidden',
|
|
3243
|
-
message:
|
|
3907
|
+
message: msg,
|
|
3908
|
+
gate: gateId || undefined,
|
|
3244
3909
|
source: (opts && opts.source) || undefined,
|
|
3245
3910
|
});
|
|
3246
|
-
|
|
3911
|
+
var hiddenErr = NacError('hidden', msg);
|
|
3912
|
+
if (gateId) hiddenErr.gate = gateId;
|
|
3913
|
+
throw hiddenErr;
|
|
3247
3914
|
}
|
|
3248
3915
|
/* v1.9.0 ARIA preflight (sec 7.3.3): inert ancestor + aria-busy
|
|
3249
3916
|
block click before the host handler runs. Disabled is already
|
|
@@ -3272,8 +3939,13 @@
|
|
|
3272
3939
|
await _resolveVersionExpectations(opts, el);
|
|
3273
3940
|
}
|
|
3274
3941
|
}
|
|
3275
|
-
|
|
3276
|
-
|
|
3942
|
+
/* v2.8.0: resolve a declared alias (SPEC.md 1.5) BEFORE picking
|
|
3943
|
+
the family, so a page that still writes `treenode` gets the
|
|
3944
|
+
tree-node completion event instead of the action fallback. */
|
|
3945
|
+
const role = _canonicalRole(el.getAttribute('data-nac-role') || 'action');
|
|
3946
|
+
const family = _CLICK_EVENT_FAMILY[role]
|
|
3947
|
+
|| (_REGISTERED_ROLES.has(role) && _REGISTERED_ROLES.get(role).events)
|
|
3948
|
+
|| _CLICK_EVENT_FAMILY['action'];
|
|
3277
3949
|
/* The first event in each family is the "success" signal; if a
|
|
3278
3950
|
second entry exists it is the "failure" signal. Some families
|
|
3279
3951
|
(option, tab, breadcrumb, step, pagination) have no failure
|
|
@@ -3284,8 +3956,19 @@
|
|
|
3284
3956
|
const successEvents = [family[0]];
|
|
3285
3957
|
const failureEvents = family.length > 1 ? [family[1]] : [];
|
|
3286
3958
|
if (role !== 'action') {
|
|
3287
|
-
|
|
3288
|
-
|
|
3959
|
+
/* Deduplicated since 2.7.0. A role with no family of its own
|
|
3960
|
+
falls back to the action family above and then had it pushed
|
|
3961
|
+
again, so the timeout message read "did not emit any of
|
|
3962
|
+
[nac:action:succeeded, nac:action:succeeded,
|
|
3963
|
+
nac:action:failed, nac:action:failed]" -- which makes a reader
|
|
3964
|
+
hunt for two contracts where there is one. Harmless to the
|
|
3965
|
+
listeners, confusing in the one place anybody reads. */
|
|
3966
|
+
if (successEvents.indexOf('nac:action:succeeded') < 0) {
|
|
3967
|
+
successEvents.push('nac:action:succeeded');
|
|
3968
|
+
}
|
|
3969
|
+
if (failureEvents.indexOf('nac:action:failed') < 0) {
|
|
3970
|
+
failureEvents.push('nac:action:failed');
|
|
3971
|
+
}
|
|
3289
3972
|
}
|
|
3290
3973
|
/* v1.6.5: cache plugin slug + option value/text BEFORE el.click()
|
|
3291
3974
|
fires. The host's click handler may DETACH el from the DOM
|
|
@@ -3331,10 +4014,28 @@
|
|
|
3331
4014
|
if (settled) return;
|
|
3332
4015
|
settled = true;
|
|
3333
4016
|
cleanup();
|
|
4017
|
+
/* Say WHY nothing arrived (TF-A14). The old message named the
|
|
4018
|
+
events and the elapsed time, which reads as "the widget did
|
|
4019
|
+
not ack" -- and for a role with no completion event in the
|
|
4020
|
+
protocol that is the wrong diagnosis in the one case where
|
|
4021
|
+
the runtime already knows the answer. Five seconds and a
|
|
4022
|
+
misattributed failure, per control. */
|
|
4023
|
+
const knownFamily = Object.prototype.hasOwnProperty.call(_CLICK_EVENT_FAMILY, role);
|
|
4024
|
+
let why = '';
|
|
4025
|
+
if (_CLICK_NO_EVENT_ROLES.has(role)) {
|
|
4026
|
+
why = ' -- role "' + role + '" has no completion event in NAC3: it is structural, or'
|
|
4027
|
+
+ ' it is driven by its own verb (a draggable and a drop-target are what drag_drop()'
|
|
4028
|
+
+ ' moves). If this control is meant to be clickable, have its handler emit'
|
|
4029
|
+
+ ' nac:action:succeeded (NAC.bindAction does it for you).';
|
|
4030
|
+
} else if (!knownFamily) {
|
|
4031
|
+
why = ' -- role "' + role + '" is not one of the canonical roles of SPEC.md section 1,'
|
|
4032
|
+
+ ' so this runtime waited for the action family by default. Declare a canonical'
|
|
4033
|
+
+ ' role, or emit nac:action:succeeded from the handler.';
|
|
4034
|
+
}
|
|
3334
4035
|
reject(NacError('timeout',
|
|
3335
4036
|
'click(' + nac_id + ', role=' + role + ') did not emit any of [' +
|
|
3336
4037
|
successEvents.concat(failureEvents).join(', ') + '] within ' +
|
|
3337
|
-
timeout_ms + 'ms'));
|
|
4038
|
+
timeout_ms + 'ms' + why));
|
|
3338
4039
|
}, timeout_ms);
|
|
3339
4040
|
successEvents.forEach(function (n) { document.addEventListener(n, onSucceeded); });
|
|
3340
4041
|
failureEvents.forEach(function (n) { document.addEventListener(n, onFailed); });
|
|
@@ -3403,7 +4104,13 @@
|
|
|
3403
4104
|
d.stepper_id === nac_id || d.carousel_id === nac_id ||
|
|
3404
4105
|
d.timeline_id === nac_id || d.option_id === nac_id ||
|
|
3405
4106
|
d.table_id === nac_id ||
|
|
3406
|
-
/* v1.6.x legacy aliases
|
|
4107
|
+
/* v1.6.x legacy aliases. NOT deprecated-with-a-date any
|
|
4108
|
+
more (D-12, 2026-11-24): these six are RESOLUTION KEYS
|
|
4109
|
+
-- this is the code that reads them -- so the v2.0
|
|
4110
|
+
removal the comment used to announce would have broken
|
|
4111
|
+
event resolution for any host emitting only an alias.
|
|
4112
|
+
Frozen: they resolve for good, the canonical field is
|
|
4113
|
+
still the one to emit. */
|
|
3407
4114
|
d.nac_id === nac_id || d.from_nac_id === nac_id ||
|
|
3408
4115
|
d.target_nac_id === nac_id || d.id === nac_id ||
|
|
3409
4116
|
d.column_nac_id === nac_id || d.filter_nac_id === nac_id ||
|
|
@@ -4713,13 +5420,63 @@
|
|
|
4713
5420
|
emission.)
|
|
4714
5421
|
|
|
4715
5422
|
A NAC-3 codebase that wants drift to be a CI blocker should run
|
|
4716
|
-
this in addition to the per-plugin validate(slug) loop.
|
|
4717
|
-
|
|
5423
|
+
this in addition to the per-plugin validate(slug) loop.
|
|
5424
|
+
|
|
5425
|
+
THE opts ARGUMENT (2.7.0, audit N-35 / TF-A16). SPEC.md section
|
|
5426
|
+
5.2 has published the signature as
|
|
5427
|
+
validate_global(opts?: {probe?: boolean}) since 2.5, and section
|
|
5428
|
+
8 keys two conformance levels on it: level 2 wants
|
|
5429
|
+
validate_global({probe: false}) with zero error findings, level 3
|
|
5430
|
+
wants validate_global({probe: true}) with zero findings of ANY
|
|
5431
|
+
severity. This function TOOK NO ARGUMENTS. Passing {probe:true}
|
|
5432
|
+
was accepted and ignored, so the level 3 check was the level 2
|
|
5433
|
+
check with a stricter threshold and the word "probe" meant
|
|
5434
|
+
nothing -- measured while building the reference validator, and
|
|
5435
|
+
written into scripts/contract-api.meta.json as the reason no tool
|
|
5436
|
+
could decide that requirement.
|
|
5437
|
+
|
|
5438
|
+
What probing IS, now that it is defined: the static half of this
|
|
5439
|
+
validator compares two LISTS -- the manifests and the ids present
|
|
5440
|
+
in the DOM. It never asks whether a declared element can actually
|
|
5441
|
+
be reached, so the two failures an agent hits most do not appear
|
|
5442
|
+
in the report:
|
|
5443
|
+
|
|
5444
|
+
ambiguous the same nac_id is on 2+ DOM nodes under ONE
|
|
5445
|
+
manifest. find() takes the first, so click()
|
|
5446
|
+
silently operates on whichever node the document
|
|
5447
|
+
happens to list first. The duplicates bucket does
|
|
5448
|
+
NOT cover this: it compares manifests to each
|
|
5449
|
+
other, not the DOM to itself.
|
|
5450
|
+
unreachable the element is mounted but an agent cannot touch
|
|
5451
|
+
it -- an aria-hidden or inert ancestor, or a box
|
|
5452
|
+
that is not displayed. click() would reject it
|
|
5453
|
+
with NacError('hidden'), so the manifest declares
|
|
5454
|
+
a surface the protocol cannot operate.
|
|
5455
|
+
|
|
5456
|
+
Both buckets exist in the report ALWAYS, and are empty unless
|
|
5457
|
+
probe is true: a consumer reading the shape does not have to
|
|
5458
|
+
branch on the argument, and a caller who never passes opts gets
|
|
5459
|
+
exactly the report 2.5 gave them. Probing reads the DOM and
|
|
5460
|
+
reads computed style; it clicks nothing and mutates nothing. */
|
|
5461
|
+
function validate_global(opts) {
|
|
5462
|
+
_nac_requireDocument('validate_global');
|
|
5463
|
+
const probe = !!(opts && opts.probe);
|
|
4718
5464
|
const out = {
|
|
4719
5465
|
ok: true,
|
|
5466
|
+
probed: probe,
|
|
4720
5467
|
duplicates: [],
|
|
4721
5468
|
orphans: [],
|
|
4722
5469
|
unmounted: [],
|
|
5470
|
+
ambiguous: [],
|
|
5471
|
+
unreachable: [],
|
|
5472
|
+
/* 2.7.0: declared-and-gated surfaces. This bucket is NOT a
|
|
5473
|
+
findings bucket -- an element that declares what opens it is
|
|
5474
|
+
keeping the contract, not breaking it -- and like the two
|
|
5475
|
+
probe buckets above it is always present and empty unless the
|
|
5476
|
+
caller asked to probe. It is reported because an agent reading
|
|
5477
|
+
the validation output is exactly who needs to know that four
|
|
5478
|
+
of these ids need a panel opened first. */
|
|
5479
|
+
gated: [],
|
|
4723
5480
|
convention_violations: [],
|
|
4724
5481
|
/* v2.5 / RFC V24-01: plugin slug uniqueness findings live in
|
|
4725
5482
|
their own bucket so CI integrations can gate on them
|
|
@@ -4779,12 +5536,15 @@
|
|
|
4779
5536
|
- if not in idIndex, it is an orphan.
|
|
4780
5537
|
- track DOM-side seen ids to compute unmounted = manifest \ DOM. */
|
|
4781
5538
|
const inDom = Object.create(null);
|
|
5539
|
+
const domNodes = Object.create(null);
|
|
4782
5540
|
if (typeof document !== 'undefined') {
|
|
4783
5541
|
const all = document.querySelectorAll('[data-nac-id]');
|
|
4784
5542
|
Array.prototype.forEach.call(all, function (el) {
|
|
4785
5543
|
const id = el.getAttribute('data-nac-id');
|
|
4786
5544
|
if (!id) return;
|
|
4787
5545
|
inDom[id] = true;
|
|
5546
|
+
if (!domNodes[id]) domNodes[id] = [];
|
|
5547
|
+
domNodes[id].push(el);
|
|
4788
5548
|
if (!idIndex[id]) {
|
|
4789
5549
|
/* Orphan in DOM but not in any manifest. Note: tabs
|
|
4790
5550
|
frequently are declared in DOM-only because the host
|
|
@@ -4815,6 +5575,80 @@
|
|
|
4815
5575
|
}
|
|
4816
5576
|
}
|
|
4817
5577
|
|
|
5578
|
+
/* 2.7.0: the probe pass (opts.probe). Only declared ids are
|
|
5579
|
+
probed: an id nothing declares is already reported as an
|
|
5580
|
+
orphan, and a brownfield page full of them is the normal case
|
|
5581
|
+
this validator was built to tolerate. */
|
|
5582
|
+
if (probe && typeof document !== 'undefined') {
|
|
5583
|
+
for (const id in idIndex) {
|
|
5584
|
+
const nodes = domNodes[id] || [];
|
|
5585
|
+
if (nodes.length >= 2) {
|
|
5586
|
+
out.ambiguous.push({
|
|
5587
|
+
code: 'nac_id_ambiguous_in_dom',
|
|
5588
|
+
severity: 'error',
|
|
5589
|
+
nac_id: id, count: nodes.length,
|
|
5590
|
+
plugin: idIndex[id][0],
|
|
5591
|
+
hint: 'find() resolves the first match, so which element an '
|
|
5592
|
+
+ 'agent operates depends on document order',
|
|
5593
|
+
});
|
|
5594
|
+
}
|
|
5595
|
+
if (nodes.length === 1) {
|
|
5596
|
+
const why = _probeUnreachable(nodes[0]);
|
|
5597
|
+
if (why) {
|
|
5598
|
+
/* 2.7.0: a surface that DECLARES what opens it is not a
|
|
5599
|
+
defect -- it is a gated surface, and the agent now has
|
|
5600
|
+
its next move. The declaration is only honoured when the
|
|
5601
|
+
gate itself holds up; see _resolveGate. */
|
|
5602
|
+
const gate = _resolveGate(id);
|
|
5603
|
+
const gateNodes = gate ? (domNodes[gate] || []) : [];
|
|
5604
|
+
/* The four ways a declared gate fails to be a way in. They
|
|
5605
|
+
are separate values because they are separate fixes: one
|
|
5606
|
+
is a manifest that forgot the gate, one is a view that
|
|
5607
|
+
has not mounted it, one is an id on two nodes -- where
|
|
5608
|
+
find() picks by document order, so "operate the gate"
|
|
5609
|
+
does not name one thing -- and one is a gate behind its
|
|
5610
|
+
own closed container. */
|
|
5611
|
+
const gateBad = !gate ? null
|
|
5612
|
+
: (!idIndex[gate] ? 'gate_not_declared'
|
|
5613
|
+
: (gateNodes.length === 0 ? 'gate_not_mounted'
|
|
5614
|
+
: (gateNodes.length >= 2 ? 'gate_ambiguous'
|
|
5615
|
+
: (_probeUnreachable(gateNodes[0]) ? 'gate_not_reachable'
|
|
5616
|
+
: null))));
|
|
5617
|
+
if (gate && !gateBad) {
|
|
5618
|
+
out.gated.push({
|
|
5619
|
+
code: 'nac_id_undrivable_until_gate',
|
|
5620
|
+
severity: 'info',
|
|
5621
|
+
nac_id: id, reason: why, gate: gate,
|
|
5622
|
+
plugin: idIndex[id][0],
|
|
5623
|
+
hint: 'declared as undrivable until "' + gate + '" is operated; '
|
|
5624
|
+
+ 'click() refuses it until then and says so',
|
|
5625
|
+
});
|
|
5626
|
+
} else if (gate) {
|
|
5627
|
+
out.unreachable.push({
|
|
5628
|
+
code: 'nac_id_undrivable_gate_unusable',
|
|
5629
|
+
severity: 'error',
|
|
5630
|
+
nac_id: id, reason: why, gate: gate, gate_problem: gateBad,
|
|
5631
|
+
plugin: idIndex[id][0],
|
|
5632
|
+
hint: 'undrivable_until names "' + gate + '", and that gate is '
|
|
5633
|
+
+ gateBad.replace(/_/g, ' ') + ' -- a promised way in that '
|
|
5634
|
+
+ 'does not open is worse than none, an agent waits for it',
|
|
5635
|
+
});
|
|
5636
|
+
} else {
|
|
5637
|
+
out.unreachable.push({
|
|
5638
|
+
code: 'nac_id_declared_not_reachable',
|
|
5639
|
+
severity: 'warn',
|
|
5640
|
+
nac_id: id, reason: why,
|
|
5641
|
+
plugin: idIndex[id][0],
|
|
5642
|
+
hint: 'click() would reject this id with NacError(hidden). If the '
|
|
5643
|
+
+ 'surface is gated on purpose, declare undrivable_until with '
|
|
5644
|
+
+ 'the id that opens it',
|
|
5645
|
+
});
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
|
|
4818
5652
|
/* v1.6.1: tolerated_violations support. Hosts retiring historic
|
|
4819
5653
|
findings incrementally can register a tolerated set via
|
|
4820
5654
|
NAC.set_validation_tolerance({tolerated:[...]}); each finding
|
|
@@ -4832,7 +5666,8 @@
|
|
|
4832
5666
|
const k = String(t.kind || '') + '::' + String(t.nac_id || '');
|
|
4833
5667
|
tolSet[k] = t.until || true;
|
|
4834
5668
|
});
|
|
4835
|
-
['duplicates', 'orphans', 'unmounted', '
|
|
5669
|
+
['duplicates', 'orphans', 'unmounted', 'ambiguous', 'unreachable',
|
|
5670
|
+
'convention_violations'].forEach(function (kind) {
|
|
4836
5671
|
const kept = [];
|
|
4837
5672
|
out[kind].forEach(function (item) {
|
|
4838
5673
|
const k = kind + '::' + item.nac_id;
|
|
@@ -4849,15 +5684,49 @@
|
|
|
4849
5684
|
});
|
|
4850
5685
|
}
|
|
4851
5686
|
|
|
4852
|
-
|
|
5687
|
+
/* 2.7.0: ambiguous joins duplicates in the hard-error gate. Both
|
|
5688
|
+
mean the same thing to an agent -- an id that does not resolve
|
|
5689
|
+
to one element -- and the bucket is empty unless the caller
|
|
5690
|
+
asked to probe, so a 2.5 caller sees the same booleans. */
|
|
5691
|
+
out.ok = !out.duplicates.length && !out.ambiguous.length;
|
|
4853
5692
|
/* v1.6.1: explicit has_errors flag for CI integration. Drift
|
|
4854
5693
|
findings (duplicates) are hard-errors per spec sec 7.3.2;
|
|
4855
5694
|
orphans + unmounted + convention_violations stay informative
|
|
4856
5695
|
unless the host explicitly opts in via tolerance config. */
|
|
4857
|
-
out.has_errors = out.duplicates.length > 0;
|
|
5696
|
+
out.has_errors = out.duplicates.length > 0 || out.ambiguous.length > 0;
|
|
4858
5697
|
return out;
|
|
4859
5698
|
}
|
|
4860
5699
|
|
|
5700
|
+
/* Why an element a manifest declares cannot be operated, or null.
|
|
5701
|
+
The three reasons are the ones click() itself refuses on, so the
|
|
5702
|
+
probe and the verb agree: a probe that reported something click()
|
|
5703
|
+
accepts, or missed something it rejects, would be worse than no
|
|
5704
|
+
probe. Everything is in a try: a host whose getComputedStyle
|
|
5705
|
+
throws gets a report without this bucket, not an exception out of
|
|
5706
|
+
a validator. */
|
|
5707
|
+
function _probeUnreachable(el) {
|
|
5708
|
+
if (!el) return null;
|
|
5709
|
+
try {
|
|
5710
|
+
if (el.closest && el.closest('[aria-hidden="true"]')) return 'aria_hidden';
|
|
5711
|
+
} catch (_) {}
|
|
5712
|
+
try {
|
|
5713
|
+
if (el.closest && el.closest('[inert]')) return 'inert_ancestor';
|
|
5714
|
+
} catch (_) {}
|
|
5715
|
+
try {
|
|
5716
|
+
const view = (el.ownerDocument && el.ownerDocument.defaultView)
|
|
5717
|
+
|| (typeof window !== 'undefined' ? window : null);
|
|
5718
|
+
if (view && typeof view.getComputedStyle === 'function') {
|
|
5719
|
+
const st = view.getComputedStyle(el);
|
|
5720
|
+
if (st) {
|
|
5721
|
+
if (st.display === 'none') return 'not_displayed';
|
|
5722
|
+
if (st.visibility === 'hidden') return 'not_displayed';
|
|
5723
|
+
if (String(st.opacity) === '0') return 'not_displayed';
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5726
|
+
} catch (_) {}
|
|
5727
|
+
return null;
|
|
5728
|
+
}
|
|
5729
|
+
|
|
4861
5730
|
/* v1.6.1: tolerance config storage + setter. The shape:
|
|
4862
5731
|
{
|
|
4863
5732
|
tolerated: [
|
|
@@ -4888,14 +5757,51 @@
|
|
|
4888
5757
|
are wrapped automatically when no resolver is set. */
|
|
4889
5758
|
const _optionResolvers = Object.create(null);
|
|
4890
5759
|
|
|
5760
|
+
/* The resolver key, which has to be INJECTIVE (TF-A05).
|
|
5761
|
+
|
|
5762
|
+
It used to be:
|
|
5763
|
+
|
|
5764
|
+
String(plugin || '') + '::' + String(field_id || '')
|
|
5765
|
+
|
|
5766
|
+
and that collided in two independent ways:
|
|
5767
|
+
|
|
5768
|
+
1. `String(x || '')` maps undefined, null, '', 0 and false all
|
|
5769
|
+
onto the empty string, so a resolver registered with no
|
|
5770
|
+
plugin and one registered with plugin '' were the same entry
|
|
5771
|
+
-- the second silently replaced the first.
|
|
5772
|
+
2. '::' as a separator with nothing escaping it: ('a::b', 'c')
|
|
5773
|
+
and ('a', 'b::c') both produce 'a::b::c'. SPEC.md does not
|
|
5774
|
+
restrict the characters of a field_id, so a '::' inside one
|
|
5775
|
+
is legal, and two different fields could share a resolver.
|
|
5776
|
+
|
|
5777
|
+
The length prefix makes the split unambiguous: knowing how long
|
|
5778
|
+
the plugin part is, there is exactly one way to read the key back.
|
|
5779
|
+
The separator stays for readability in a debugger, but nothing
|
|
5780
|
+
depends on it being unique any more. */
|
|
4891
5781
|
function _resolverKey(plugin, field_id) {
|
|
4892
|
-
|
|
5782
|
+
const p = plugin == null ? '' : String(plugin);
|
|
5783
|
+
const f = field_id == null ? '' : String(field_id);
|
|
5784
|
+
return p.length + ':' + p + '::' + f;
|
|
4893
5785
|
}
|
|
4894
5786
|
|
|
4895
5787
|
function set_options_resolver(plugin, field_id, fn) {
|
|
4896
5788
|
if (typeof fn !== 'function') {
|
|
4897
5789
|
throw NacError('invalid', 'resolver fn required');
|
|
4898
5790
|
}
|
|
5791
|
+
/* And refuse the empty case outright rather than keying on ''.
|
|
5792
|
+
A resolver with no plugin or no field is a programming error,
|
|
5793
|
+
and before this it was an error that looked like success until
|
|
5794
|
+
something else overwrote the entry. The sibling guard above
|
|
5795
|
+
already throws for a missing fn; this is the same shape. */
|
|
5796
|
+
if (plugin == null || String(plugin) === '') {
|
|
5797
|
+
throw NacError('invalid',
|
|
5798
|
+
'set_options_resolver: plugin is required -- a resolver with no plugin'
|
|
5799
|
+
+ ' used to be stored under the empty key, where the next one replaced it');
|
|
5800
|
+
}
|
|
5801
|
+
if (field_id == null || String(field_id) === '') {
|
|
5802
|
+
throw NacError('invalid',
|
|
5803
|
+
'set_options_resolver: field_id is required -- see the note on plugin');
|
|
5804
|
+
}
|
|
4899
5805
|
_optionResolvers[_resolverKey(plugin, field_id)] = fn;
|
|
4900
5806
|
}
|
|
4901
5807
|
|
|
@@ -5678,6 +6584,10 @@
|
|
|
5678
6584
|
function step_to(stepper_id, n) {
|
|
5679
6585
|
const steps = _stepperSteps(stepper_id);
|
|
5680
6586
|
if (!steps.length) throw NacError('stepper_not_found', stepper_id);
|
|
6587
|
+
/* n slots for n steps, 0..n-1: this SELECTS one of the steps that
|
|
6588
|
+
exist. Same limit as reorder(), which also moves within n.
|
|
6589
|
+
drag_drop() bounds to n instead, because inserting into a list
|
|
6590
|
+
of n has n + 1 slots (TF-A07). */
|
|
5681
6591
|
n = Math.max(0, Math.min(steps.length - 1, Number(n)));
|
|
5682
6592
|
const prior = step_state(stepper_id).current;
|
|
5683
6593
|
steps.forEach(function (s, i) {
|
|
@@ -6222,6 +7132,15 @@
|
|
|
6222
7132
|
var siblings = Array.prototype.slice.call(list.querySelectorAll(
|
|
6223
7133
|
'[data-nac-role="draggable"]'));
|
|
6224
7134
|
var from_index = siblings.indexOf(item);
|
|
7135
|
+
/* Bounded to siblings.length - 1, NOT siblings.length, and the
|
|
7136
|
+
difference from drag_drop() is deliberate (TF-A07): this MOVES
|
|
7137
|
+
an item that is already one of the n, so there are n landing
|
|
7138
|
+
slots, 0..n-1. drag_drop() INSERTS an item the list does not
|
|
7139
|
+
hold yet, so it has n + 1. step_to() selects one of n existing
|
|
7140
|
+
steps: n slots, like here.
|
|
7141
|
+
Three bounds, two limits, one reason -- written at all three
|
|
7142
|
+
sites because it was written at none, and a reader comparing
|
|
7143
|
+
them could not tell a deliberate asymmetry from a slip. */
|
|
6225
7144
|
var bounded = Math.max(0, Math.min(to_index, siblings.length - 1));
|
|
6226
7145
|
if (from_index === -1) {
|
|
6227
7146
|
return Promise.reject(new NacError('invalid',
|
|
@@ -6235,13 +7154,36 @@
|
|
|
6235
7154
|
list.insertBefore(item, ref);
|
|
6236
7155
|
}
|
|
6237
7156
|
}
|
|
7157
|
+
/* Say whether the index was ACOTADO (TF-A06).
|
|
7158
|
+
|
|
7159
|
+
The old pair was: emit to_index = bounded, resolve { ok: true }.
|
|
7160
|
+
So a consumer asking for index 99 in a list of three got
|
|
7161
|
+
ok: true and no index at all from the promise, and the event
|
|
7162
|
+
reported 2 with nothing marking it as clamped. "I moved it where
|
|
7163
|
+
you asked" and "I moved it as far as it would go" were
|
|
7164
|
+
indistinguishable -- for an agent deciding whether its plan
|
|
7165
|
+
worked, those are different answers.
|
|
7166
|
+
|
|
7167
|
+
requested_index and bounded are ADDITIVE: to_index still means
|
|
7168
|
+
what it meant, so nothing reading it breaks. */
|
|
7169
|
+
var wasBounded = bounded !== to_index;
|
|
6238
7170
|
_emit('nac:list:reordered', {
|
|
6239
|
-
list_id:
|
|
6240
|
-
item_id:
|
|
6241
|
-
from_index:
|
|
6242
|
-
to_index:
|
|
7171
|
+
list_id: list_id,
|
|
7172
|
+
item_id: item_id,
|
|
7173
|
+
from_index: from_index,
|
|
7174
|
+
to_index: bounded,
|
|
7175
|
+
requested_index: to_index,
|
|
7176
|
+
bounded: wasBounded,
|
|
7177
|
+
});
|
|
7178
|
+
return Promise.resolve({
|
|
7179
|
+
ok: true,
|
|
7180
|
+
list_id: list_id,
|
|
7181
|
+
item_id: item_id,
|
|
7182
|
+
from_index: from_index,
|
|
7183
|
+
to_index: bounded,
|
|
7184
|
+
requested_index: to_index,
|
|
7185
|
+
bounded: wasBounded,
|
|
6243
7186
|
});
|
|
6244
|
-
return Promise.resolve({ ok: true });
|
|
6245
7187
|
}
|
|
6246
7188
|
|
|
6247
7189
|
/* ---------- v1.6.2: drag_drop (implements spec sec 13.4) -------- */
|
|
@@ -6341,6 +7283,8 @@
|
|
|
6341
7283
|
|
|
6342
7284
|
source.setAttribute('data-nac-state', 'dragging');
|
|
6343
7285
|
/* v1.7.0: emit canonical source_id + legacy from_nac_id alias.
|
|
7286
|
+
The alias is frozen, not pending removal (D-12): the matcher
|
|
7287
|
+
resolves events by it.
|
|
6344
7288
|
Plugin scope from the source's data-nac-plugin ancestor so
|
|
6345
7289
|
sec 6.2.1 universal base (plugin + plugin_instance_id) is
|
|
6346
7290
|
satisfied. v1.7 round 3 conformance FAILed without these. */
|
|
@@ -6353,11 +7297,34 @@
|
|
|
6353
7297
|
};
|
|
6354
7298
|
_emit('nac:drag:started', Object.assign({}, dragPluginCtx, {
|
|
6355
7299
|
source_id: source_nac_id,
|
|
6356
|
-
from_nac_id: source_nac_id, /* legacy,
|
|
7300
|
+
from_nac_id: source_nac_id, /* legacy alias, frozen (D-12) */
|
|
6357
7301
|
}));
|
|
6358
7302
|
|
|
6359
|
-
/*
|
|
6360
|
-
|
|
7303
|
+
/* The settle delay, now the HOST's choice (TF-A02).
|
|
7304
|
+
|
|
7305
|
+
Why it exists: a focus pulse on the source is only visible to a
|
|
7306
|
+
human reviewer if the DOM move waits for it. The 80 ms was this
|
|
7307
|
+
repository's demo UX, hard-coded into the library -- so every
|
|
7308
|
+
adopter paid it, including the ones with no reviewer watching
|
|
7309
|
+
and the ones driving a thousand moves in a test.
|
|
7310
|
+
|
|
7311
|
+
The DEFAULT STAYS 80. Dropping it to zero would change the
|
|
7312
|
+
timing of every existing adopter's drop for the sake of
|
|
7313
|
+
tidiness, and a host that liked the pulse would lose it without
|
|
7314
|
+
asking. What changes is that it can now be set:
|
|
7315
|
+
|
|
7316
|
+
NAC.drag_drop(a, b, { settle_ms: 0 }) per call
|
|
7317
|
+
NAC.drag_settle_ms = 0 per host
|
|
7318
|
+
|
|
7319
|
+
opts wins over the global, and the global defaults to the
|
|
7320
|
+
historical 80. Zero is honoured -- `|| 80` would have silently
|
|
7321
|
+
turned the useful value back into the default, which is the
|
|
7322
|
+
usual way an option like this ends up not working. */
|
|
7323
|
+
var settleMs = (opts && typeof opts.settle_ms === 'number')
|
|
7324
|
+
? Math.max(0, opts.settle_ms)
|
|
7325
|
+
: ((global.NAC && typeof global.NAC.drag_settle_ms === 'number')
|
|
7326
|
+
? Math.max(0, global.NAC.drag_settle_ms)
|
|
7327
|
+
: 80);
|
|
6361
7328
|
return new Promise(function (resolve, reject) {
|
|
6362
7329
|
setTimeout(function () {
|
|
6363
7330
|
try {
|
|
@@ -6365,17 +7332,66 @@
|
|
|
6365
7332
|
_emit('nac:drag:over', Object.assign({}, dragPluginCtx, {
|
|
6366
7333
|
source_id: source_nac_id, /* v1.7.0 canonical */
|
|
6367
7334
|
target_id: target_nac_id, /* v1.7.0 canonical */
|
|
6368
|
-
from_nac_id: source_nac_id, /* legacy,
|
|
6369
|
-
over_nac_id: target_nac_id, /* legacy,
|
|
7335
|
+
from_nac_id: source_nac_id, /* legacy, frozen D-12 */
|
|
7336
|
+
over_nac_id: target_nac_id, /* legacy, frozen D-12 */
|
|
6370
7337
|
}));
|
|
6371
|
-
/* Remove
|
|
6372
|
-
|
|
6373
|
-
|
|
7338
|
+
/* Remove a "drop here" placeholder, IF THE HOST DECLARED ONE.
|
|
7339
|
+
|
|
7340
|
+
TF-A01. Until 2.7.0 this line was:
|
|
7341
|
+
|
|
7342
|
+
var empty = target.querySelector('.ne-drag-empty');
|
|
7343
|
+
if (empty) empty.parentNode.removeChild(empty);
|
|
7344
|
+
|
|
7345
|
+
-- the runtime deleting a node out of the host's document
|
|
7346
|
+
because of a CSS class name that belongs to THIS
|
|
7347
|
+
repository's demo (css/example.css, js/example.js). The
|
|
7348
|
+
class is real here; what was never real is the agreement.
|
|
7349
|
+
Nothing obliges an adopter to avoid `ne-drag-empty`, and
|
|
7350
|
+
an adopter who happens to use it for anything else lost
|
|
7351
|
+
the element on the first drop, silently, with no way to
|
|
7352
|
+
switch it off.
|
|
7353
|
+
|
|
7354
|
+
A library may not reach into a document it did not write
|
|
7355
|
+
on a convention it invented. So the default is now to
|
|
7356
|
+
remove NOTHING, and a host that wants placeholder removal
|
|
7357
|
+
asks for it, in the idiom the rest of the protocol uses --
|
|
7358
|
+
an attribute on the element that owns the contract:
|
|
7359
|
+
|
|
7360
|
+
<ul data-nac-role="drop-target"
|
|
7361
|
+
data-nac-drop-placeholder=".ne-drag-empty">
|
|
7362
|
+
|
|
7363
|
+
NAC.drop_placeholder_selector is the tree-wide default for
|
|
7364
|
+
a host that wants it everywhere; it is null, and the
|
|
7365
|
+
per-target attribute wins over it. The selector is only
|
|
7366
|
+
ever queried INSIDE the target, so a host cannot be made
|
|
7367
|
+
to delete something elsewhere in its page by accident. */
|
|
7368
|
+
var placeholderSel = target.getAttribute('data-nac-drop-placeholder')
|
|
7369
|
+
|| (global.NAC && global.NAC.drop_placeholder_selector) || null;
|
|
7370
|
+
if (placeholderSel) {
|
|
7371
|
+
var stale = target.querySelectorAll(placeholderSel);
|
|
7372
|
+
for (var pi = 0; pi < stale.length; pi++) {
|
|
7373
|
+
if (stale[pi].parentNode) stale[pi].parentNode.removeChild(stale[pi]);
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
6374
7376
|
/* Optional to_index for ordered drop-targets; otherwise
|
|
6375
7377
|
append at end. */
|
|
6376
7378
|
if (typeof opts.to_index === 'number') {
|
|
6377
7379
|
var siblings = Array.prototype.slice.call(
|
|
6378
7380
|
target.querySelectorAll('[data-nac-role="draggable"]'));
|
|
7381
|
+
/* Bounded to siblings.length, NOT siblings.length - 1, and
|
|
7382
|
+
the difference from reorder() is deliberate (TF-A07).
|
|
7383
|
+
|
|
7384
|
+
This is an INSERT into a list the item is not in yet, so
|
|
7385
|
+
a list of n items has n + 1 landing slots: before each
|
|
7386
|
+
of the n, plus after the last. reorder() MOVES an item
|
|
7387
|
+
that is already among the n, so it has n slots, and
|
|
7388
|
+
bounds to n - 1. step_to() selects one of n existing
|
|
7389
|
+
steps: also n - 1.
|
|
7390
|
+
|
|
7391
|
+
Three bounds, two limits, one reason -- written down
|
|
7392
|
+
here because it was not, and a reader comparing the
|
|
7393
|
+
three had no way to tell a deliberate asymmetry from a
|
|
7394
|
+
copy-paste slip. */
|
|
6379
7395
|
var bounded = Math.max(0, Math.min(opts.to_index, siblings.length));
|
|
6380
7396
|
var ref = siblings[bounded] || null;
|
|
6381
7397
|
if (ref) target.insertBefore(source, ref);
|
|
@@ -6388,8 +7404,8 @@
|
|
|
6388
7404
|
_emit('nac:drag:dropped', Object.assign({}, dragPluginCtx, {
|
|
6389
7405
|
source_id: source_nac_id, /* v1.7.0 canonical */
|
|
6390
7406
|
target_id: target_nac_id, /* v1.7.0 canonical */
|
|
6391
|
-
from_nac_id: source_nac_id, /* legacy,
|
|
6392
|
-
target_nac_id: target_nac_id, /* legacy,
|
|
7407
|
+
from_nac_id: source_nac_id, /* legacy, frozen D-12 */
|
|
7408
|
+
target_nac_id: target_nac_id, /* legacy, frozen D-12 */
|
|
6393
7409
|
value: opts.value !== undefined ? opts.value : null,
|
|
6394
7410
|
}));
|
|
6395
7411
|
resolve({ ok: true, source: source_nac_id, target: target_nac_id });
|
|
@@ -6398,7 +7414,7 @@
|
|
|
6398
7414
|
target.setAttribute('data-nac-state', 'idle');
|
|
6399
7415
|
_emit('nac:drag:cancelled', Object.assign({}, dragPluginCtx, {
|
|
6400
7416
|
source_id: source_nac_id, /* v1.7.0 canonical */
|
|
6401
|
-
from_nac_id: source_nac_id, /* legacy,
|
|
7417
|
+
from_nac_id: source_nac_id, /* legacy, frozen D-12 */
|
|
6402
7418
|
reason: 'aborted',
|
|
6403
7419
|
error: err && err.message ? err.message : String(err),
|
|
6404
7420
|
}));
|
|
@@ -6416,7 +7432,7 @@
|
|
|
6416
7432
|
reject(err instanceof Error ? err :
|
|
6417
7433
|
new NacError('invalid', String(err)));
|
|
6418
7434
|
}
|
|
6419
|
-
},
|
|
7435
|
+
}, settleMs);
|
|
6420
7436
|
});
|
|
6421
7437
|
}
|
|
6422
7438
|
|
|
@@ -6870,6 +7886,413 @@
|
|
|
6870
7886
|
return hex;
|
|
6871
7887
|
}
|
|
6872
7888
|
|
|
7889
|
+
/* ---------- 2.7.0: manifest authenticity (sec 7.2) ------------
|
|
7890
|
+
|
|
7891
|
+
WHAT THIS CLOSES. Section 7.2 has published, since 1.9, a worked
|
|
7892
|
+
example of an HMAC-signed manifest: set the tenant secret, pass a
|
|
7893
|
+
provenance block to register(), and "the runtime computes the
|
|
7894
|
+
expected HMAC over a stable serialisation of the manifest
|
|
7895
|
+
(excluding the signature itself) and rejects manifests whose
|
|
7896
|
+
signature does not match". None of that existed. sign_provenance /
|
|
7897
|
+
verify_provenance (above) sign an EVENT's detail.source and have
|
|
7898
|
+
never looked at a manifest, and register() stored whatever object
|
|
7899
|
+
it was handed. So conformance level 3 -- whose first requirement
|
|
7900
|
+
is "carries HMAC-signed manifests" -- could not be asserted by any
|
|
7901
|
+
tool, which is the measured finding audit N-36 / PND-045 records
|
|
7902
|
+
and what scripts/contract-api.meta.json says in the note on that
|
|
7903
|
+
requirement: "the runtime exposes no manifest verification at all
|
|
7904
|
+
... which is why no tool can assert level 3 today".
|
|
7905
|
+
|
|
7906
|
+
WHY A HAND-WRITTEN SHA-256 AND NOT SubtleCrypto. Because
|
|
7907
|
+
register() is SYNCHRONOUS and throws -- that is its whole
|
|
7908
|
+
contract, and STRICT_VALIDATION made it a hard gate in 2.3.
|
|
7909
|
+
crypto.subtle.sign returns a Promise, so a register() built on it
|
|
7910
|
+
could only verify AFTER returning: the manifest would already be
|
|
7911
|
+
live, the host would already have gone on to click things, and the
|
|
7912
|
+
rejection would arrive as a console message in a later tick. That
|
|
7913
|
+
is silent damage with extra steps. A synchronous digest is ~70
|
|
7914
|
+
lines, has fixed test vectors anybody can check (FIPS 180-4 for
|
|
7915
|
+
the digest, RFC 4231 for the HMAC -- both are in
|
|
7916
|
+
runtime/test/manifest-hmac.mjs), needs no DOM, no network and no
|
|
7917
|
+
Node built-in, and lets the signature be refused at the only
|
|
7918
|
+
moment where refusing costs nothing.
|
|
7919
|
+
|
|
7920
|
+
WHAT IT DOES NOT DO, said plainly: it does not make a manifest
|
|
7921
|
+
trustworthy. The secret lives in the page, so an agent with
|
|
7922
|
+
user-level access reads it (sec 7.3 says exactly this). What it
|
|
7923
|
+
buys is the multi-tenant case 7.2 names -- tenant A cannot hand
|
|
7924
|
+
tenant B's host a manifest it did not sign -- and an answer to
|
|
7925
|
+
"can anything here say it verified this?" that is not "no". */
|
|
7926
|
+
|
|
7927
|
+
const _SHA256_K = [
|
|
7928
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
|
7929
|
+
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
7930
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
7931
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
7932
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
|
7933
|
+
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
7934
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
|
7935
|
+
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
7936
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
7937
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
7938
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
|
7939
|
+
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
7940
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
|
7941
|
+
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
7942
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
7943
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
7944
|
+
];
|
|
7945
|
+
|
|
7946
|
+
function _rotr32(x, n) { return ((x >>> n) | (x << (32 - n))) >>> 0; }
|
|
7947
|
+
|
|
7948
|
+
/* UTF-8 bytes without TextEncoder, so the digest works in any host
|
|
7949
|
+
that can run the rest of this file (old WebViews included). */
|
|
7950
|
+
function _utf8Bytes(str) {
|
|
7951
|
+
str = String(str);
|
|
7952
|
+
if (typeof TextEncoder !== 'undefined') {
|
|
7953
|
+
return new TextEncoder().encode(str);
|
|
7954
|
+
}
|
|
7955
|
+
const out = [];
|
|
7956
|
+
for (let i = 0; i < str.length; i++) {
|
|
7957
|
+
let c = str.charCodeAt(i);
|
|
7958
|
+
if (c < 0x80) { out.push(c); continue; }
|
|
7959
|
+
if (c < 0x800) {
|
|
7960
|
+
out.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
|
|
7961
|
+
continue;
|
|
7962
|
+
}
|
|
7963
|
+
if (c >= 0xd800 && c <= 0xdbff && i + 1 < str.length) {
|
|
7964
|
+
const lo = str.charCodeAt(i + 1);
|
|
7965
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
7966
|
+
c = 0x10000 + ((c - 0xd800) << 10) + (lo - 0xdc00);
|
|
7967
|
+
i++;
|
|
7968
|
+
out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 0x3f),
|
|
7969
|
+
0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
|
|
7970
|
+
continue;
|
|
7971
|
+
}
|
|
7972
|
+
}
|
|
7973
|
+
out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f),
|
|
7974
|
+
0x80 | (c & 0x3f));
|
|
7975
|
+
}
|
|
7976
|
+
return new Uint8Array(out);
|
|
7977
|
+
}
|
|
7978
|
+
|
|
7979
|
+
/* SHA-256 over bytes -> Uint8Array(32). FIPS 180-4. */
|
|
7980
|
+
function _sha256Bytes(bytes) {
|
|
7981
|
+
const H = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
|
7982
|
+
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
|
|
7983
|
+
const len = bytes.length;
|
|
7984
|
+
const padded = new Uint8Array((Math.floor((len + 8) / 64) + 1) * 64);
|
|
7985
|
+
padded.set(bytes);
|
|
7986
|
+
padded[len] = 0x80;
|
|
7987
|
+
const n = padded.length;
|
|
7988
|
+
const hiBits = Math.floor(len / 536870912); /* (len * 8) >> 32 */
|
|
7989
|
+
const loBits = (len * 8) >>> 0;
|
|
7990
|
+
padded[n - 8] = (hiBits >>> 24) & 0xff;
|
|
7991
|
+
padded[n - 7] = (hiBits >>> 16) & 0xff;
|
|
7992
|
+
padded[n - 6] = (hiBits >>> 8) & 0xff;
|
|
7993
|
+
padded[n - 5] = hiBits & 0xff;
|
|
7994
|
+
padded[n - 4] = (loBits >>> 24) & 0xff;
|
|
7995
|
+
padded[n - 3] = (loBits >>> 16) & 0xff;
|
|
7996
|
+
padded[n - 2] = (loBits >>> 8) & 0xff;
|
|
7997
|
+
padded[n - 1] = loBits & 0xff;
|
|
7998
|
+
const w = new Array(64);
|
|
7999
|
+
for (let off = 0; off < n; off += 64) {
|
|
8000
|
+
for (let i = 0; i < 16; i++) {
|
|
8001
|
+
const j = off + i * 4;
|
|
8002
|
+
w[i] = ((padded[j] << 24) | (padded[j + 1] << 16)
|
|
8003
|
+
| (padded[j + 2] << 8) | padded[j + 3]) >>> 0;
|
|
8004
|
+
}
|
|
8005
|
+
for (let i = 16; i < 64; i++) {
|
|
8006
|
+
const x = w[i - 15], y = w[i - 2];
|
|
8007
|
+
const s0 = (_rotr32(x, 7) ^ _rotr32(x, 18) ^ (x >>> 3)) >>> 0;
|
|
8008
|
+
const s1 = (_rotr32(y, 17) ^ _rotr32(y, 19) ^ (y >>> 10)) >>> 0;
|
|
8009
|
+
w[i] = (((w[i - 16] + s0) >>> 0) + ((w[i - 7] + s1) >>> 0)) >>> 0;
|
|
8010
|
+
}
|
|
8011
|
+
let a = H[0], b = H[1], c = H[2], d = H[3];
|
|
8012
|
+
let e = H[4], f = H[5], g = H[6], h = H[7];
|
|
8013
|
+
for (let i = 0; i < 64; i++) {
|
|
8014
|
+
const S1 = (_rotr32(e, 6) ^ _rotr32(e, 11) ^ _rotr32(e, 25)) >>> 0;
|
|
8015
|
+
const ch = ((e & f) ^ (~e & g)) >>> 0;
|
|
8016
|
+
const t1 = (((h + S1) >>> 0) + ((ch + _SHA256_K[i]) >>> 0)
|
|
8017
|
+
+ w[i]) >>> 0;
|
|
8018
|
+
const S0 = (_rotr32(a, 2) ^ _rotr32(a, 13) ^ _rotr32(a, 22)) >>> 0;
|
|
8019
|
+
const maj = ((a & b) ^ (a & c) ^ (b & c)) >>> 0;
|
|
8020
|
+
const t2 = (S0 + maj) >>> 0;
|
|
8021
|
+
h = g; g = f; f = e; e = (d + t1) >>> 0;
|
|
8022
|
+
d = c; c = b; b = a; a = (t1 + t2) >>> 0;
|
|
8023
|
+
}
|
|
8024
|
+
H[0] = (H[0] + a) >>> 0; H[1] = (H[1] + b) >>> 0;
|
|
8025
|
+
H[2] = (H[2] + c) >>> 0; H[3] = (H[3] + d) >>> 0;
|
|
8026
|
+
H[4] = (H[4] + e) >>> 0; H[5] = (H[5] + f) >>> 0;
|
|
8027
|
+
H[6] = (H[6] + g) >>> 0; H[7] = (H[7] + h) >>> 0;
|
|
8028
|
+
}
|
|
8029
|
+
const out = new Uint8Array(32);
|
|
8030
|
+
for (let i = 0; i < 8; i++) {
|
|
8031
|
+
out[i * 4] = (H[i] >>> 24) & 0xff;
|
|
8032
|
+
out[i * 4 + 1] = (H[i] >>> 16) & 0xff;
|
|
8033
|
+
out[i * 4 + 2] = (H[i] >>> 8) & 0xff;
|
|
8034
|
+
out[i * 4 + 3] = H[i] & 0xff;
|
|
8035
|
+
}
|
|
8036
|
+
return out;
|
|
8037
|
+
}
|
|
8038
|
+
|
|
8039
|
+
function _bytesToHex(arr) {
|
|
8040
|
+
let hex = '';
|
|
8041
|
+
for (let i = 0; i < arr.length; i++) {
|
|
8042
|
+
const b = arr[i].toString(16);
|
|
8043
|
+
hex += b.length === 1 ? '0' + b : b;
|
|
8044
|
+
}
|
|
8045
|
+
return hex;
|
|
8046
|
+
}
|
|
8047
|
+
|
|
8048
|
+
/* HMAC-SHA256, synchronous. RFC 2104 / tested against RFC 4231. */
|
|
8049
|
+
function _hmacSha256Hex(secret, message) {
|
|
8050
|
+
const BLOCK = 64;
|
|
8051
|
+
let key = _utf8Bytes(secret);
|
|
8052
|
+
if (key.length > BLOCK) key = _sha256Bytes(key);
|
|
8053
|
+
const k0 = new Uint8Array(BLOCK);
|
|
8054
|
+
k0.set(key);
|
|
8055
|
+
const msg = _utf8Bytes(message);
|
|
8056
|
+
const inner = new Uint8Array(BLOCK + msg.length);
|
|
8057
|
+
const outer = new Uint8Array(BLOCK + 32);
|
|
8058
|
+
for (let i = 0; i < BLOCK; i++) {
|
|
8059
|
+
inner[i] = k0[i] ^ 0x36;
|
|
8060
|
+
outer[i] = k0[i] ^ 0x5c;
|
|
8061
|
+
}
|
|
8062
|
+
inner.set(msg, BLOCK);
|
|
8063
|
+
outer.set(_sha256Bytes(inner), BLOCK);
|
|
8064
|
+
return _bytesToHex(_sha256Bytes(outer));
|
|
8065
|
+
}
|
|
8066
|
+
|
|
8067
|
+
/* Stable serialisation: keys sorted at every depth, undefined
|
|
8068
|
+
dropped, so two hosts that build the same manifest in a different
|
|
8069
|
+
key order sign the same bytes. */
|
|
8070
|
+
function _stableStringify(v) {
|
|
8071
|
+
if (v === undefined) return 'null';
|
|
8072
|
+
if (v === null || typeof v !== 'object') return JSON.stringify(v);
|
|
8073
|
+
if (Array.isArray(v)) {
|
|
8074
|
+
const items = [];
|
|
8075
|
+
for (let i = 0; i < v.length; i++) items.push(_stableStringify(v[i]));
|
|
8076
|
+
return '[' + items.join(',') + ']';
|
|
8077
|
+
}
|
|
8078
|
+
const keys = Object.keys(v).filter(function (k) {
|
|
8079
|
+
return v[k] !== undefined && typeof v[k] !== 'function';
|
|
8080
|
+
}).sort();
|
|
8081
|
+
const parts = keys.map(function (k) {
|
|
8082
|
+
return JSON.stringify(k) + ':' + _stableStringify(v[k]);
|
|
8083
|
+
});
|
|
8084
|
+
return '{' + parts.join(',') + '}';
|
|
8085
|
+
}
|
|
8086
|
+
|
|
8087
|
+
/* The signed body: the whole manifest, with provenance.signature
|
|
8088
|
+
removed and everything else of the provenance block KEPT -- the
|
|
8089
|
+
signature covers signed_at and signed_by, so a replay cannot
|
|
8090
|
+
relabel who signed it or when. */
|
|
8091
|
+
function _manifestCanonicalString(m) {
|
|
8092
|
+
const clone = {};
|
|
8093
|
+
Object.keys(m).forEach(function (k) {
|
|
8094
|
+
if (k === 'provenance') return;
|
|
8095
|
+
clone[k] = m[k];
|
|
8096
|
+
});
|
|
8097
|
+
if (m.provenance && typeof m.provenance === 'object') {
|
|
8098
|
+
const p = {};
|
|
8099
|
+
Object.keys(m.provenance).forEach(function (k) {
|
|
8100
|
+
if (k === 'signature') return;
|
|
8101
|
+
p[k] = m.provenance[k];
|
|
8102
|
+
});
|
|
8103
|
+
clone.provenance = p;
|
|
8104
|
+
}
|
|
8105
|
+
return _stableStringify(clone);
|
|
8106
|
+
}
|
|
8107
|
+
|
|
8108
|
+
/* Tenant secrets for MANIFEST verification. Separate store from the
|
|
8109
|
+
extensions module's event-provenance secrets, and deliberately so:
|
|
8110
|
+
register() lives in this file and cannot reach into that closure.
|
|
8111
|
+
NAC.set_provenance_secret (extensions) FORWARDS here, so the
|
|
8112
|
+
example published in section 7.2 works exactly as written. */
|
|
8113
|
+
let _manifestSecrets = [];
|
|
8114
|
+
|
|
8115
|
+
function set_manifest_secret(s) {
|
|
8116
|
+
if (typeof s === 'string') _manifestSecrets = [s];
|
|
8117
|
+
else if (Array.isArray(s)) _manifestSecrets = s.slice();
|
|
8118
|
+
else if (s == null) _manifestSecrets = [];
|
|
8119
|
+
else {
|
|
8120
|
+
throw NacError('invalid',
|
|
8121
|
+
'NAC.set_manifest_secret expects a string, an array of strings, or null');
|
|
8122
|
+
}
|
|
8123
|
+
return _manifestSecrets.length;
|
|
8124
|
+
}
|
|
8125
|
+
|
|
8126
|
+
/* NAC.sign_manifest(manifest, secret?) -> hex signature.
|
|
8127
|
+
Sign the object you are about to hand to register(): the digest
|
|
8128
|
+
covers it as you built it, BEFORE register() fills in its
|
|
8129
|
+
defaults (version, nac_version, plugin_slug from the two-argument
|
|
8130
|
+
form), which is why register() takes its snapshot first. */
|
|
8131
|
+
function sign_manifest(manifest, secret) {
|
|
8132
|
+
if (!manifest || typeof manifest !== 'object') {
|
|
8133
|
+
throw NacError('invalid', 'NAC.sign_manifest: manifest object required');
|
|
8134
|
+
}
|
|
8135
|
+
const key = (secret != null) ? secret : _manifestSecrets[0];
|
|
8136
|
+
if (typeof key !== 'string' || !key) {
|
|
8137
|
+
throw NacError('invalid',
|
|
8138
|
+
'NAC.sign_manifest: no secret. Pass one, or call NAC.set_manifest_secret first');
|
|
8139
|
+
}
|
|
8140
|
+
return _hmacSha256Hex(key, _manifestCanonicalString(manifest));
|
|
8141
|
+
}
|
|
8142
|
+
|
|
8143
|
+
/* NAC.verify_manifest(manifest, secret?) -> boolean.
|
|
8144
|
+
Constant-time compare against every registered secret, so a
|
|
8145
|
+
tenant rotating a secret can hold both for the window. */
|
|
8146
|
+
function verify_manifest(manifest, secret) {
|
|
8147
|
+
if (!manifest || typeof manifest !== 'object') return false;
|
|
8148
|
+
const prov = manifest.provenance;
|
|
8149
|
+
if (!prov || typeof prov !== 'object' || !prov.signature) return false;
|
|
8150
|
+
const keys = (secret != null) ? [secret] : _manifestSecrets;
|
|
8151
|
+
if (!keys.length) return false;
|
|
8152
|
+
const body = _manifestCanonicalString(manifest);
|
|
8153
|
+
const provided = String(prov.signature);
|
|
8154
|
+
let any = false;
|
|
8155
|
+
for (let i = 0; i < keys.length; i++) {
|
|
8156
|
+
if (typeof keys[i] !== 'string' || !keys[i]) continue;
|
|
8157
|
+
const expected = _hmacSha256Hex(keys[i], body);
|
|
8158
|
+
if (provided.length !== expected.length) continue;
|
|
8159
|
+
let diff = 0;
|
|
8160
|
+
for (let j = 0; j < provided.length; j++) {
|
|
8161
|
+
diff |= provided.charCodeAt(j) ^ expected.charCodeAt(j);
|
|
8162
|
+
}
|
|
8163
|
+
if (diff === 0) any = true;
|
|
8164
|
+
}
|
|
8165
|
+
return any;
|
|
8166
|
+
}
|
|
8167
|
+
|
|
8168
|
+
/* What register() recorded about each manifest's provenance, so a
|
|
8169
|
+
validator on the page can ask instead of guessing. Shape:
|
|
8170
|
+
{ signed, verified, reason, signed_by, signed_at }
|
|
8171
|
+
verified is true / false / null, and null is not a synonym for
|
|
8172
|
+
false: it means NOBODY COULD TELL (no secret registered). A tool
|
|
8173
|
+
that reports level 3 off this MUST treat null as unverified. */
|
|
8174
|
+
const _manifestProvenance = Object.create(null);
|
|
8175
|
+
|
|
8176
|
+
function manifest_provenance(slug) {
|
|
8177
|
+
if (slug === undefined) {
|
|
8178
|
+
const out = {};
|
|
8179
|
+
Object.keys(_manifestProvenance).forEach(function (k) {
|
|
8180
|
+
out[k] = Object.assign({}, _manifestProvenance[k]);
|
|
8181
|
+
});
|
|
8182
|
+
return out;
|
|
8183
|
+
}
|
|
8184
|
+
const rec = _manifestProvenance[String(slug)];
|
|
8185
|
+
return rec ? Object.assign({}, rec) : null;
|
|
8186
|
+
}
|
|
8187
|
+
|
|
8188
|
+
/* Called from register() with the canonical string captured BEFORE
|
|
8189
|
+
any default was applied. Throws when a signature is present and a
|
|
8190
|
+
secret says it is wrong; stays silent when there is no signature
|
|
8191
|
+
(section 7.2: a manifest MAY carry a provenance block) or no
|
|
8192
|
+
secret (nothing to check against, and an adopter who never set
|
|
8193
|
+
one must keep working exactly as before). */
|
|
8194
|
+
function _recordManifestProvenance(slug, manifest, canonical) {
|
|
8195
|
+
const prov = manifest && manifest.provenance;
|
|
8196
|
+
if (!prov || typeof prov !== 'object' || !prov.signature) {
|
|
8197
|
+
_manifestProvenance[slug] = {
|
|
8198
|
+
signed: false, verified: null, reason: 'no_provenance_block',
|
|
8199
|
+
signed_by: (prov && prov.signed_by) || null,
|
|
8200
|
+
signed_at: (prov && prov.signed_at) || null,
|
|
8201
|
+
};
|
|
8202
|
+
return;
|
|
8203
|
+
}
|
|
8204
|
+
if (!_manifestSecrets.length) {
|
|
8205
|
+
_manifestProvenance[slug] = {
|
|
8206
|
+
signed: true, verified: null, reason: 'no_secret_registered',
|
|
8207
|
+
signed_by: prov.signed_by || null,
|
|
8208
|
+
signed_at: prov.signed_at || null,
|
|
8209
|
+
};
|
|
8210
|
+
return;
|
|
8211
|
+
}
|
|
8212
|
+
const provided = String(prov.signature);
|
|
8213
|
+
let ok = false;
|
|
8214
|
+
for (let i = 0; i < _manifestSecrets.length; i++) {
|
|
8215
|
+
const key = _manifestSecrets[i];
|
|
8216
|
+
if (typeof key !== 'string' || !key) continue;
|
|
8217
|
+
const expected = _hmacSha256Hex(key, canonical);
|
|
8218
|
+
if (provided.length !== expected.length) continue;
|
|
8219
|
+
let diff = 0;
|
|
8220
|
+
for (let j = 0; j < provided.length; j++) {
|
|
8221
|
+
diff |= provided.charCodeAt(j) ^ expected.charCodeAt(j);
|
|
8222
|
+
}
|
|
8223
|
+
if (diff === 0) ok = true;
|
|
8224
|
+
}
|
|
8225
|
+
if (!ok) {
|
|
8226
|
+
delete _manifestProvenance[slug];
|
|
8227
|
+
throw NacError('invalid',
|
|
8228
|
+
'manifest "' + slug + '" carries a provenance.signature that does not '
|
|
8229
|
+
+ 'match the HMAC of its body under any registered tenant secret '
|
|
8230
|
+
+ '(SPEC.md sec 7.2). Either the manifest was altered after signing, '
|
|
8231
|
+
+ 'or it was signed for another tenant.');
|
|
8232
|
+
}
|
|
8233
|
+
_manifestProvenance[slug] = {
|
|
8234
|
+
signed: true, verified: true, reason: 'verified',
|
|
8235
|
+
signed_by: prov.signed_by || null,
|
|
8236
|
+
signed_at: prov.signed_at || null,
|
|
8237
|
+
};
|
|
8238
|
+
}
|
|
8239
|
+
|
|
8240
|
+
/* ---------- 2.7.0: NAC.set_source (sec 15.7) ------------------
|
|
8241
|
+
|
|
8242
|
+
Section 15.7 has published, since 2.5, that source on
|
|
8243
|
+
nac:plugin:invoked / :read / :event "defaults to 'agent'; hosts
|
|
8244
|
+
that wrap the runtime in a user-facing UI MAY override via the
|
|
8245
|
+
existing NAC.set_source(...) mechanism (sec 7)". The mechanism
|
|
8246
|
+
was not existing: there were zero occurrences of set_source in
|
|
8247
|
+
js/, so every dispatch from a host where a HUMAN pressed the
|
|
8248
|
+
button was sealed source:'agent', trusted:false, and an auditor
|
|
8249
|
+
reading the log could not tell the two apart (D-09).
|
|
8250
|
+
|
|
8251
|
+
It is an ATTESTATION BY THE HOST, not a measurement, and the
|
|
8252
|
+
threat model (7.3) already says an agent with user-level access
|
|
8253
|
+
can do anything the user can -- including calling this. What it
|
|
8254
|
+
buys is the honest case: a host with a confirmation UI in front
|
|
8255
|
+
of the dispatch can say so, and every change of the claim emits
|
|
8256
|
+
nac:source_changed so the override is itself in the log. */
|
|
8257
|
+
|
|
8258
|
+
let _dispatchSource = { source: 'agent', trusted: false };
|
|
8259
|
+
|
|
8260
|
+
function set_source(src) {
|
|
8261
|
+
let next;
|
|
8262
|
+
if (src == null) {
|
|
8263
|
+
next = { source: 'agent', trusted: false };
|
|
8264
|
+
} else if (typeof src === 'string') {
|
|
8265
|
+
if (!src.trim()) {
|
|
8266
|
+
throw NacError('invalid', 'NAC.set_source: source string must not be empty');
|
|
8267
|
+
}
|
|
8268
|
+
next = { source: src, trusted: false };
|
|
8269
|
+
} else if (typeof src === 'object') {
|
|
8270
|
+
const label = src.source !== undefined ? src.source : src.type;
|
|
8271
|
+
if (typeof label !== 'string' || !label.trim()) {
|
|
8272
|
+
throw NacError('invalid',
|
|
8273
|
+
'NAC.set_source: {source} must be a non-empty string');
|
|
8274
|
+
}
|
|
8275
|
+
next = { source: label, trusted: !!src.trusted };
|
|
8276
|
+
} else {
|
|
8277
|
+
throw NacError('invalid',
|
|
8278
|
+
'NAC.set_source expects a string, {source, trusted}, or null to reset');
|
|
8279
|
+
}
|
|
8280
|
+
const prev = _dispatchSource;
|
|
8281
|
+
_dispatchSource = next;
|
|
8282
|
+
try {
|
|
8283
|
+
document.dispatchEvent(new CustomEvent('nac:source_changed', {
|
|
8284
|
+
detail: {
|
|
8285
|
+
source: next.source, trusted: next.trusted,
|
|
8286
|
+
previous_source: prev.source, previous_trusted: prev.trusted,
|
|
8287
|
+
},
|
|
8288
|
+
bubbles: true, composed: true,
|
|
8289
|
+
}));
|
|
8290
|
+
} catch (_) { /* no document: the setter still took effect */ }
|
|
8291
|
+
return Object.assign({}, next);
|
|
8292
|
+
}
|
|
8293
|
+
|
|
8294
|
+
function get_source() { return Object.assign({}, _dispatchSource); }
|
|
8295
|
+
|
|
6873
8296
|
/* ---------- v1.9.0: recommended_remediation (sec 6.2.30) ----- */
|
|
6874
8297
|
|
|
6875
8298
|
const _REMEDIATION_BY_REASON = {
|
|
@@ -6949,6 +8372,34 @@
|
|
|
6949
8372
|
'emitter-listen': true,
|
|
6950
8373
|
};
|
|
6951
8374
|
|
|
8375
|
+
/* 2.7.0 (SPEC sec 19.1) -- which of those nine backends reach their
|
|
8376
|
+
surface WITHOUT a document. This is the whole predicate of the
|
|
8377
|
+
headless profile, and it is a property of the implementation, not
|
|
8378
|
+
an opinion: sdk-call walks a registered API handle or the global
|
|
8379
|
+
object, and emitter-listen subscribes to a library's own emitter.
|
|
8380
|
+
Neither ever calls document.querySelector. The other six do, which
|
|
8381
|
+
is why they are absent from this table.
|
|
8382
|
+
|
|
8383
|
+
'inherits' means the binding is DOM-free exactly when every state
|
|
8384
|
+
path it observes is: synthetic-poll only calls read() on the state
|
|
8385
|
+
paths it declares. */
|
|
8386
|
+
const _V25_DOM_FREE_BACKENDS = {
|
|
8387
|
+
'sdk-call': true,
|
|
8388
|
+
'emitter-listen': true,
|
|
8389
|
+
'synthetic-poll': 'inherits',
|
|
8390
|
+
};
|
|
8391
|
+
|
|
8392
|
+
/* Why each DOM-requiring backend needs one -- named, so the refusal a
|
|
8393
|
+
declared-headless manifest gets says what to change (sec 19.1). */
|
|
8394
|
+
const _V25_DOM_REASON = {
|
|
8395
|
+
'postmessage': 'posts to the contentWindow of an iframe matched by a CSS selector',
|
|
8396
|
+
'postmessage-listen': 'filters window.message by the iframe a CSS selector matches',
|
|
8397
|
+
'script-bridge': 'posts to the contentWindow of an iframe matched by a CSS selector',
|
|
8398
|
+
'dom-mirror': 'reads a DOM element matched by a CSS selector',
|
|
8399
|
+
'same-origin-window': 'reads into the contentWindow of an iframe matched by a CSS selector',
|
|
8400
|
+
'synthetic-mutation': 'observes DOM mutations with a MutationObserver',
|
|
8401
|
+
};
|
|
8402
|
+
|
|
6952
8403
|
/* The closed list of NacError codes the plugin contract raises
|
|
6953
8404
|
(SPEC.md sec 15.9), plus the namespace a plugin uses for a code
|
|
6954
8405
|
of its own (v2.6, RFC V26-01 hook E-6). Before this, `call` lifted
|
|
@@ -6967,6 +8418,16 @@
|
|
|
6967
8418
|
'state_unreadable': true,
|
|
6968
8419
|
'timeout': true,
|
|
6969
8420
|
'invalid': true,
|
|
8421
|
+
/* 2.7.0 (sec 19.3 / 19.4). no_document: a DOM primitive was called
|
|
8422
|
+
where there is no document, so there is nothing to resolve --
|
|
8423
|
+
raised instead of the raw ReferenceError the reference runtime
|
|
8424
|
+
used to let through. provenance_unobservable: a plugin that
|
|
8425
|
+
declares headless: true was called with no document AND no event
|
|
8426
|
+
sink, so its nac:plugin:* row would be dropped; refused before
|
|
8427
|
+
the effect, because a surface nobody can audit is the silent
|
|
8428
|
+
damage this protocol exists to remove. */
|
|
8429
|
+
'no_document': true,
|
|
8430
|
+
'provenance_unobservable': true,
|
|
6970
8431
|
};
|
|
6971
8432
|
const _V25_PLUGIN_CODE_PREFIX = 'plugin.';
|
|
6972
8433
|
|
|
@@ -7175,6 +8636,8 @@
|
|
|
7175
8636
|
}
|
|
7176
8637
|
|
|
7177
8638
|
function _v25_backend_dom_mirror(binding /*, args*/) {
|
|
8639
|
+
const miss = _v25_noDocument('dom-mirror');
|
|
8640
|
+
if (miss) return Promise.reject(miss);
|
|
7178
8641
|
const sel = binding.selector;
|
|
7179
8642
|
if (!sel) return Promise.reject(new Error('dom-mirror requires `selector` string'));
|
|
7180
8643
|
const el = document.querySelector(sel);
|
|
@@ -7199,6 +8662,8 @@
|
|
|
7199
8662
|
/* postmessage (verb): post a structured message to the iframe.contentWindow
|
|
7200
8663
|
of the target. `values` literal + `values_from_args` forward keys. */
|
|
7201
8664
|
function _v25_backend_postmessage(binding, args) {
|
|
8665
|
+
const miss = _v25_noDocument('postmessage');
|
|
8666
|
+
if (miss) return Promise.reject(miss);
|
|
7202
8667
|
const sel = binding.target;
|
|
7203
8668
|
if (!sel) return Promise.reject(new Error('postmessage requires `target` selector'));
|
|
7204
8669
|
const iframe = document.querySelector(sel);
|
|
@@ -7235,6 +8700,8 @@
|
|
|
7235
8700
|
flag the test sets explicitly; in real browsers the property access
|
|
7236
8701
|
throws a DOMException SecurityError which we map the same way. */
|
|
7237
8702
|
function _v25_backend_same_origin_window(binding /*, args*/) {
|
|
8703
|
+
const miss = _v25_noDocument('same-origin-window');
|
|
8704
|
+
if (miss) return Promise.reject(miss);
|
|
7238
8705
|
const sel = binding.target;
|
|
7239
8706
|
if (!sel) return Promise.reject(new Error('same-origin-window requires `target`'));
|
|
7240
8707
|
const iframe = document.querySelector(sel);
|
|
@@ -7279,6 +8746,8 @@
|
|
|
7279
8746
|
CallPythonScript pattern; generalises to any app that exposes a
|
|
7280
8747
|
RPC channel over postMessage. */
|
|
7281
8748
|
function _v25_backend_script_bridge(binding, args) {
|
|
8749
|
+
const miss = _v25_noDocument('script-bridge');
|
|
8750
|
+
if (miss) return Promise.reject(miss);
|
|
7282
8751
|
const sel = binding.target;
|
|
7283
8752
|
if (!sel) return Promise.reject(new Error('script-bridge requires `target`'));
|
|
7284
8753
|
const iframe = document.querySelector(sel);
|
|
@@ -7396,6 +8865,8 @@
|
|
|
7396
8865
|
fall back to synthetic-poll for those cases (declared, not
|
|
7397
8866
|
implicit). */
|
|
7398
8867
|
function _v25_subscribe_synthetic_mutation(plugin, event_path, binding, cb) {
|
|
8868
|
+
const miss = _v25_noDocument('synthetic-mutation');
|
|
8869
|
+
if (miss) throw miss;
|
|
7399
8870
|
if (typeof MutationObserver === 'undefined') {
|
|
7400
8871
|
throw new Error('synthetic-mutation requires MutationObserver in scope');
|
|
7401
8872
|
}
|
|
@@ -7654,6 +9125,8 @@
|
|
|
7654
9125
|
on the host window, filter by source iframe + MessageId, run the
|
|
7655
9126
|
extractor, fire the user callback. Returns a teardown closure. */
|
|
7656
9127
|
function _v25_subscribe_postmessage_listen(plugin, event_path, binding, cb) {
|
|
9128
|
+
const miss = _v25_noDocument('postmessage-listen');
|
|
9129
|
+
if (miss) throw miss;
|
|
7657
9130
|
const sel = binding.source;
|
|
7658
9131
|
const wantMsgId = binding.message;
|
|
7659
9132
|
if (!wantMsgId) throw new Error('postmessage-listen requires `message`');
|
|
@@ -7799,6 +9272,13 @@
|
|
|
7799
9272
|
const events = manifest.events || {};
|
|
7800
9273
|
_v25_validateText(manifest.label, 'manifest "' + slug + '"', 'label');
|
|
7801
9274
|
_v25_validateText(manifest.hint, 'manifest "' + slug + '"', 'hint');
|
|
9275
|
+
/* 2.7.0 (sec 19.1) -- headless is a boolean or it is absent. A
|
|
9276
|
+
string "true" is a typo that would silently leave the plugin
|
|
9277
|
+
outside the profile, so it is refused rather than coerced. */
|
|
9278
|
+
if (manifest.headless !== undefined && typeof manifest.headless !== 'boolean') {
|
|
9279
|
+
const e = new Error('manifest "' + slug + '": headless must be a boolean when declared');
|
|
9280
|
+
e.code = 'invalid'; throw e;
|
|
9281
|
+
}
|
|
7802
9282
|
/* Verbs: single binding each, backend in vocabulary. */
|
|
7803
9283
|
for (const vp in verbs) {
|
|
7804
9284
|
const b = verbs[vp];
|
|
@@ -7858,6 +9338,28 @@
|
|
|
7858
9338
|
e.code = 'invalid'; throw e;
|
|
7859
9339
|
}
|
|
7860
9340
|
}
|
|
9341
|
+
/* 2.7.0 (sec 19.1) -- a manifest that DECLARES the headless
|
|
9342
|
+
profile has to be in it. Checked here, at register time, so the
|
|
9343
|
+
adopter learns on the bench instead of discovering it on a
|
|
9344
|
+
device with no screen: every binding must reach its surface
|
|
9345
|
+
without a document, and the refusal names the ones that do not. */
|
|
9346
|
+
if (manifest.headless === true) {
|
|
9347
|
+
const need = _v25_domRequired({
|
|
9348
|
+
verbs: verbs, state: states, events: events,
|
|
9349
|
+
});
|
|
9350
|
+
if (need.length) {
|
|
9351
|
+
const first = need[0];
|
|
9352
|
+
const e = new Error('manifest "' + slug + '" declares headless: true but ' +
|
|
9353
|
+
need.length + ' binding' + (need.length === 1 ? '' : 's') + ' need' +
|
|
9354
|
+
(need.length === 1 ? 's' : '') + ' a document. First: ' + first.kind + ' "' +
|
|
9355
|
+
first.path + '" -- ' + first.why + '. Declare a DOM-free backend (sdk-call, ' +
|
|
9356
|
+
'emitter-listen, or synthetic-poll over DOM-free state) or drop the ' +
|
|
9357
|
+
'declaration (SPEC sec 19.1).');
|
|
9358
|
+
e.code = 'invalid';
|
|
9359
|
+
e.dom_required = need;
|
|
9360
|
+
throw e;
|
|
9361
|
+
}
|
|
9362
|
+
}
|
|
7861
9363
|
}
|
|
7862
9364
|
|
|
7863
9365
|
function registerPlugin(slug, manifest) {
|
|
@@ -7867,6 +9369,10 @@
|
|
|
7867
9369
|
slug: slug,
|
|
7868
9370
|
label: manifest.label != null ? manifest.label : null,
|
|
7869
9371
|
hint: manifest.hint != null ? manifest.hint : null,
|
|
9372
|
+
/* 2.7.0 (sec 19.1) -- the headless profile is DECLARED, never
|
|
9373
|
+
inferred. Absent means false, which is every manifest ever
|
|
9374
|
+
written before today. */
|
|
9375
|
+
headless: manifest.headless === true,
|
|
7870
9376
|
verbs: manifest.verbs || {},
|
|
7871
9377
|
state: manifest.state || {},
|
|
7872
9378
|
events: manifest.events || {},
|
|
@@ -7901,6 +9407,10 @@
|
|
|
7901
9407
|
slug: entry.slug,
|
|
7902
9408
|
label: entry.label != null ? entry.label : null,
|
|
7903
9409
|
hint: entry.hint != null ? entry.hint : null,
|
|
9410
|
+
/* 2.7.0 (sec 19.1): an agent that discovers a plugin learns
|
|
9411
|
+
from the descriptor whether it needs a page -- the same
|
|
9412
|
+
question NAC.profile answers in full. */
|
|
9413
|
+
headless: !!entry.headless,
|
|
7904
9414
|
verbs: [],
|
|
7905
9415
|
state: [],
|
|
7906
9416
|
events: [],
|
|
@@ -7980,6 +9490,192 @@
|
|
|
7980
9490
|
return _v25_describeEntry(_v25_plugins[slug]);
|
|
7981
9491
|
}
|
|
7982
9492
|
|
|
9493
|
+
/* ================================================================
|
|
9494
|
+
19. Headless profile -- the manifest as the surface (v2.7)
|
|
9495
|
+
================================================================
|
|
9496
|
+
|
|
9497
|
+
Owner decision D-26 (2026-11-25). Sections 1-14 address nodes and
|
|
9498
|
+
section 15 addresses a surface a node cannot reach. Neither says
|
|
9499
|
+
what happens when there is no document AT ALL -- a screenless
|
|
9500
|
+
assistant, an IVR, a voice device, a worker. The answer is that the
|
|
9501
|
+
extension contract already IS a capability interface: a plugin
|
|
9502
|
+
whose every binding is DOM-free is operable with no document, and
|
|
9503
|
+
plugins() + describePlugin() are the resolution surface, because
|
|
9504
|
+
they read the manifest and never the page.
|
|
9505
|
+
|
|
9506
|
+
What was missing was not routing. It was three things:
|
|
9507
|
+
|
|
9508
|
+
1. Nothing DECLARED it, so neither an agent nor the adopter could
|
|
9509
|
+
tell a manifest that needs a page from one that does not.
|
|
9510
|
+
profile() answers it from the manifest, mechanically.
|
|
9511
|
+
2. Provenance was silently LOST. Until 2.7.0 the emit helper
|
|
9512
|
+
below did document.dispatchEvent inside a try/catch, so with
|
|
9513
|
+
no document every nac:plugin:* row vanished and the call
|
|
9514
|
+
still reported success -- the exact silent damage section 7
|
|
9515
|
+
exists to prevent. setEventSink gives the same events the
|
|
9516
|
+
same shapes over a bus that is not the DOM.
|
|
9517
|
+
3. A DOM primitive crashed with a ReferenceError instead of
|
|
9518
|
+
refusing by name. _nac_requireDocument (sec 19.3) fixed that.
|
|
9519
|
+
|
|
9520
|
+
Nothing here is a new primitive and nothing here is implicit: a
|
|
9521
|
+
manifest written against 2.5 or 2.6 keeps working untouched, and
|
|
9522
|
+
the only way into the profile is to declare headless: true. */
|
|
9523
|
+
|
|
9524
|
+
/* The non-DOM provenance bus. Additive: when a document exists the
|
|
9525
|
+
events still go to it, so installing a sink in a browser gives an
|
|
9526
|
+
audit log without changing a single consumer. */
|
|
9527
|
+
let _v25_event_sink = null;
|
|
9528
|
+
const _v25_prov_stats = { to_document: 0, to_sink: 0, dropped: 0, sink_errors: 0 };
|
|
9529
|
+
|
|
9530
|
+
function setEventSink(fn) {
|
|
9531
|
+
if (fn !== null && fn !== undefined && typeof fn !== 'function') {
|
|
9532
|
+
throw _v25_buildNacError('invalid',
|
|
9533
|
+
'NAC.setEventSink: expects a function or null');
|
|
9534
|
+
}
|
|
9535
|
+
_v25_event_sink = (typeof fn === 'function') ? fn : null;
|
|
9536
|
+
return _v25_event_sink;
|
|
9537
|
+
}
|
|
9538
|
+
|
|
9539
|
+
function eventSink() { return _v25_event_sink; }
|
|
9540
|
+
|
|
9541
|
+
/* Is a provenance row observable by anybody at all right now? Two
|
|
9542
|
+
buses, and the answer is the OR of them. */
|
|
9543
|
+
function _v25_provObservable() {
|
|
9544
|
+
const hasDoc = (typeof document !== 'undefined' && !!document && !!document.dispatchEvent);
|
|
9545
|
+
return hasDoc || !!_v25_event_sink;
|
|
9546
|
+
}
|
|
9547
|
+
|
|
9548
|
+
function provenanceStatus() {
|
|
9549
|
+
return {
|
|
9550
|
+
document: (typeof document !== 'undefined' && !!document && !!document.dispatchEvent),
|
|
9551
|
+
sink: !!_v25_event_sink,
|
|
9552
|
+
observable: _v25_provObservable(),
|
|
9553
|
+
to_document: _v25_prov_stats.to_document,
|
|
9554
|
+
to_sink: _v25_prov_stats.to_sink,
|
|
9555
|
+
/* A row nobody received. Counted instead of swallowed: outside
|
|
9556
|
+
the headless profile the runtime does not refuse the call, so
|
|
9557
|
+
the loss has to be READABLE or it is still silent. */
|
|
9558
|
+
dropped: _v25_prov_stats.dropped,
|
|
9559
|
+
/* A sink that threw. The row is gone and the call is not undone;
|
|
9560
|
+
what the runtime owes the caller is the count, not a retry. */
|
|
9561
|
+
sink_errors: _v25_prov_stats.sink_errors,
|
|
9562
|
+
};
|
|
9563
|
+
}
|
|
9564
|
+
|
|
9565
|
+
function _v25_noDocument(backend) {
|
|
9566
|
+
if (typeof document !== 'undefined' && document) return null;
|
|
9567
|
+
return _v25_buildNacError('no_document',
|
|
9568
|
+
'backend "' + backend + '" needs a document: it ' +
|
|
9569
|
+
(_V25_DOM_REASON[backend] || 'reads the DOM') +
|
|
9570
|
+
'. With no document there is nothing to reach -- declare a DOM-free ' +
|
|
9571
|
+
'backend (sdk-call, emitter-listen) or run this plugin where a document exists ' +
|
|
9572
|
+
'(SPEC sec 19.1).',
|
|
9573
|
+
{ backend: backend });
|
|
9574
|
+
}
|
|
9575
|
+
|
|
9576
|
+
/* Classify ONE binding. Returns null when it is DOM-free, or the row
|
|
9577
|
+
that goes into profile().dom_required when it is not. */
|
|
9578
|
+
function _v25_bindingDomNeed(kind, path, binding, entry, seen) {
|
|
9579
|
+
const backend = (binding && binding.backend) || null;
|
|
9580
|
+
const free = backend ? _V25_DOM_FREE_BACKENDS[backend] : undefined;
|
|
9581
|
+
if (free === true) return null;
|
|
9582
|
+
if (free === 'inherits') {
|
|
9583
|
+
/* synthetic-poll is DOM-free exactly when every state path it
|
|
9584
|
+
observes is. Recursion is depth-guarded: a manifest may name
|
|
9585
|
+
the same state from two events. */
|
|
9586
|
+
const observe = Array.isArray(binding.observe) ? binding.observe : [];
|
|
9587
|
+
for (let i = 0; i < observe.length; i++) {
|
|
9588
|
+
const sp = observe[i];
|
|
9589
|
+
const key = 'state:' + sp;
|
|
9590
|
+
if (seen[key]) continue;
|
|
9591
|
+
seen[key] = true;
|
|
9592
|
+
const chain = (entry.state && entry.state[sp]) || null;
|
|
9593
|
+
if (!chain || !chain.length) {
|
|
9594
|
+
return { kind: kind, path: path, backend: backend, observes: sp,
|
|
9595
|
+
why: 'observes the state path "' + sp + '", which this manifest does not declare' };
|
|
9596
|
+
}
|
|
9597
|
+
for (let j = 0; j < chain.length; j++) {
|
|
9598
|
+
const need = _v25_bindingDomNeed('state', sp, chain[j], entry, seen);
|
|
9599
|
+
if (need) {
|
|
9600
|
+
return { kind: kind, path: path, backend: backend, observes: sp,
|
|
9601
|
+
why: 'observes the state path "' + sp + '", which needs a document: ' + need.why };
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
}
|
|
9605
|
+
return null;
|
|
9606
|
+
}
|
|
9607
|
+
return {
|
|
9608
|
+
kind: kind, path: path, backend: backend,
|
|
9609
|
+
why: backend
|
|
9610
|
+
? 'the ' + backend + ' backend ' + (_V25_DOM_REASON[backend] || 'reads the DOM')
|
|
9611
|
+
: 'the binding declares no backend',
|
|
9612
|
+
};
|
|
9613
|
+
}
|
|
9614
|
+
|
|
9615
|
+
/* Every binding of a plugin that would need a document. The state
|
|
9616
|
+
chain is checked WHOLE and not just its first link: a chain whose
|
|
9617
|
+
fallback is a dom-mirror works in a browser and degrades to
|
|
9618
|
+
nothing without one, which is a declaration error in a profile
|
|
9619
|
+
whose entire claim is that no page is needed. */
|
|
9620
|
+
function _v25_domRequired(entry) {
|
|
9621
|
+
const out = [];
|
|
9622
|
+
const seen = {};
|
|
9623
|
+
const verbPaths = Object.keys(entry.verbs || {}).sort();
|
|
9624
|
+
for (let i = 0; i < verbPaths.length; i++) {
|
|
9625
|
+
const need = _v25_bindingDomNeed('verb', verbPaths[i], entry.verbs[verbPaths[i]], entry, seen);
|
|
9626
|
+
if (need) out.push(need);
|
|
9627
|
+
}
|
|
9628
|
+
const statePaths = Object.keys(entry.state || {}).sort();
|
|
9629
|
+
for (let i = 0; i < statePaths.length; i++) {
|
|
9630
|
+
const chain = entry.state[statePaths[i]] || [];
|
|
9631
|
+
for (let j = 0; j < chain.length; j++) {
|
|
9632
|
+
const need = _v25_bindingDomNeed('state', statePaths[i], chain[j], entry, seen);
|
|
9633
|
+
if (need) { need.binding_index = j; out.push(need); }
|
|
9634
|
+
}
|
|
9635
|
+
}
|
|
9636
|
+
const eventPaths = Object.keys(entry.events || {}).sort();
|
|
9637
|
+
for (let i = 0; i < eventPaths.length; i++) {
|
|
9638
|
+
const need = _v25_bindingDomNeed('event', eventPaths[i], entry.events[eventPaths[i]], entry, seen);
|
|
9639
|
+
if (need) out.push(need);
|
|
9640
|
+
}
|
|
9641
|
+
return out;
|
|
9642
|
+
}
|
|
9643
|
+
|
|
9644
|
+
/* The public predicate. Answers for ANY registered plugin, declared
|
|
9645
|
+
or not: an agent can discover that a manifest written without the
|
|
9646
|
+
profile in mind happens to be operable with no page. */
|
|
9647
|
+
function profile(slug) {
|
|
9648
|
+
if (typeof slug !== 'string' || !slug) {
|
|
9649
|
+
throw _v25_buildNacError('invalid', 'NAC.profile: slug must be a non-empty string');
|
|
9650
|
+
}
|
|
9651
|
+
const entry = _v25_plugins[slug];
|
|
9652
|
+
if (!entry) {
|
|
9653
|
+
throw _v25_buildNacError('plugin_not_registered',
|
|
9654
|
+
'NAC.profile: plugin "' + slug + '" not registered');
|
|
9655
|
+
}
|
|
9656
|
+
const dom_required = _v25_domRequired(entry);
|
|
9657
|
+
return {
|
|
9658
|
+
slug: slug,
|
|
9659
|
+
declared_headless: !!entry.headless,
|
|
9660
|
+
headless: dom_required.length === 0,
|
|
9661
|
+
dom_required: _v25_copy(dom_required) || [],
|
|
9662
|
+
};
|
|
9663
|
+
}
|
|
9664
|
+
|
|
9665
|
+
/* The gate the profile buys: inside it, an unobservable call is
|
|
9666
|
+
refused BEFORE the effect. Outside it nothing changes -- which is
|
|
9667
|
+
why the profile is opt-in and not inferred. */
|
|
9668
|
+
function _v25_provGate(op, plugin, entry) {
|
|
9669
|
+
if (!entry || !entry.headless) return null;
|
|
9670
|
+
if (_v25_provObservable()) return null;
|
|
9671
|
+
return _v25_buildNacError('provenance_unobservable',
|
|
9672
|
+
'NAC.' + op + ': plugin "' + plugin + '" declares headless: true and there is ' +
|
|
9673
|
+
'neither a document nor an event sink, so its nac:plugin:* row would be dropped. ' +
|
|
9674
|
+
'Install one with NAC.setEventSink(fn) before driving a headless surface ' +
|
|
9675
|
+
'(SPEC sec 19.4).',
|
|
9676
|
+
{ plugin: plugin });
|
|
9677
|
+
}
|
|
9678
|
+
|
|
7983
9679
|
/* Provenance emit helper -- the kind is one of 'invoked', 'read',
|
|
7984
9680
|
'event'. Detail shape per SPEC.md sec 15.7. */
|
|
7985
9681
|
function _v25_emitProvenance(kind, plugin, path, backend, request_id, ok, error, duration_ms, extra) {
|
|
@@ -7987,8 +9683,11 @@
|
|
|
7987
9683
|
plugin: plugin,
|
|
7988
9684
|
backend: backend || null,
|
|
7989
9685
|
request_id: request_id,
|
|
7990
|
-
|
|
7991
|
-
|
|
9686
|
+
/* 2.7.0 (TF-A19): sec 15.7 publishes 'agent' as the DEFAULT and
|
|
9687
|
+
an override through NAC.set_source. _dispatchSource holds
|
|
9688
|
+
exactly that default until a host says otherwise. */
|
|
9689
|
+
source: _dispatchSource.source,
|
|
9690
|
+
trusted: _dispatchSource.trusted,
|
|
7992
9691
|
duration_ms: duration_ms,
|
|
7993
9692
|
ok: !!ok,
|
|
7994
9693
|
error: error || null,
|
|
@@ -7999,9 +9698,29 @@
|
|
|
7999
9698
|
if (extra) {
|
|
8000
9699
|
for (const k in extra) detail[k] = extra[k];
|
|
8001
9700
|
}
|
|
9701
|
+
/* 2.7.0 (sec 19.4): TWO buses, and a row that reached neither is
|
|
9702
|
+
COUNTED. Before this the dispatch was a lone try/catch, so with
|
|
9703
|
+
no document the row disappeared and nothing anywhere said so. */
|
|
9704
|
+
const type = 'nac:plugin:' + kind;
|
|
9705
|
+
let delivered = false;
|
|
8002
9706
|
try {
|
|
8003
|
-
document.dispatchEvent(new CustomEvent(
|
|
8004
|
-
|
|
9707
|
+
document.dispatchEvent(new CustomEvent(type, { detail: detail, bubbles: true }));
|
|
9708
|
+
delivered = true;
|
|
9709
|
+
_v25_prov_stats.to_document++;
|
|
9710
|
+
} catch (_) { /* no document, or a document without dispatchEvent */ }
|
|
9711
|
+
if (_v25_event_sink) {
|
|
9712
|
+
try {
|
|
9713
|
+
_v25_event_sink({ type: type, detail: detail });
|
|
9714
|
+
delivered = true;
|
|
9715
|
+
_v25_prov_stats.to_sink++;
|
|
9716
|
+
} catch (_) {
|
|
9717
|
+
/* A sink that throws is a host defect. The effect already
|
|
9718
|
+
happened, so the runtime does not undo it and does not
|
|
9719
|
+
retry -- it counts the loss where a caller can read it. */
|
|
9720
|
+
_v25_prov_stats.sink_errors++;
|
|
9721
|
+
}
|
|
9722
|
+
}
|
|
9723
|
+
if (!delivered) _v25_prov_stats.dropped++;
|
|
8005
9724
|
}
|
|
8006
9725
|
|
|
8007
9726
|
function _v25_buildNacError(code, message, extra) {
|
|
@@ -8023,6 +9742,8 @@
|
|
|
8023
9742
|
_v25_emitProvenance('invoked', plugin, verb_path, null, request_id, false, err.message, Date.now() - t0);
|
|
8024
9743
|
return Promise.reject(err);
|
|
8025
9744
|
}
|
|
9745
|
+
const gated = _v25_provGate('call', plugin, _v25_plugins[plugin]);
|
|
9746
|
+
if (gated) return Promise.reject(gated);
|
|
8026
9747
|
const binding = _v25_plugins[plugin].verbs[verb_path];
|
|
8027
9748
|
if (!binding) {
|
|
8028
9749
|
const err = _v25_buildNacError('verb_not_declared',
|
|
@@ -8075,6 +9796,8 @@
|
|
|
8075
9796
|
_v25_emitProvenance('read', plugin, state_path, null, request_id, false, err.message, Date.now() - t0);
|
|
8076
9797
|
return Promise.reject(err);
|
|
8077
9798
|
}
|
|
9799
|
+
const gated = _v25_provGate('read', plugin, _v25_plugins[plugin]);
|
|
9800
|
+
if (gated) return Promise.reject(gated);
|
|
8078
9801
|
const chain = _v25_plugins[plugin].state[state_path];
|
|
8079
9802
|
if (!chain) {
|
|
8080
9803
|
const err = _v25_buildNacError('state_not_declared',
|
|
@@ -8144,6 +9867,8 @@
|
|
|
8144
9867
|
throw _v25_buildNacError('plugin_not_registered',
|
|
8145
9868
|
'NAC.subscribe: plugin "' + plugin + '" not registered');
|
|
8146
9869
|
}
|
|
9870
|
+
const gated = _v25_provGate('subscribe', plugin, _v25_plugins[plugin]);
|
|
9871
|
+
if (gated) throw gated;
|
|
8147
9872
|
const binding = _v25_plugins[plugin].events[event_path];
|
|
8148
9873
|
if (!binding) {
|
|
8149
9874
|
throw _v25_buildNacError('event_not_declared',
|
|
@@ -8229,6 +9954,7 @@
|
|
|
8229
9954
|
}
|
|
8230
9955
|
|
|
8231
9956
|
function narrate(plugin, nac_id) {
|
|
9957
|
+
_nac_requireDocument('narrate');
|
|
8232
9958
|
if (typeof nac_id !== 'string' || !nac_id) return null;
|
|
8233
9959
|
/* Scope by plugin if provided -- look only inside [data-nac-plugin=plugin]
|
|
8234
9960
|
subtree. If plugin is omitted, fall back to global search. */
|
|
@@ -8241,7 +9967,27 @@
|
|
|
8241
9967
|
/* Use attribute selector with CSS-safe escape via JSON.stringify
|
|
8242
9968
|
to avoid injection when nac_id contains weird chars. */
|
|
8243
9969
|
const safeId = '"' + String(nac_id).replace(/["\\]/g, '\\$&') + '"';
|
|
8244
|
-
|
|
9970
|
+
/* The ROOT ITSELF counts (fixed 2.7.0, found by the first test
|
|
9971
|
+
this verb ever had).
|
|
9972
|
+
|
|
9973
|
+
querySelector searches DESCENDANTS, so when `plugin` was given
|
|
9974
|
+
and the asked-for id belonged to the plugin root -- the usual
|
|
9975
|
+
case, since a root normally carries both data-nac-plugin and
|
|
9976
|
+
data-nac-id -- narrate returned null. A plugin could not narrate
|
|
9977
|
+
itself.
|
|
9978
|
+
|
|
9979
|
+
It showed up through context(), whose breadcrumb walks up to and
|
|
9980
|
+
including the root and labels each entry with narrate(): the
|
|
9981
|
+
FIRST entry of every breadcrumb came back with label: null. An
|
|
9982
|
+
assistive consumer reading that breadcrumb aloud started with
|
|
9983
|
+
nothing. */
|
|
9984
|
+
let el = null;
|
|
9985
|
+
if (root !== document && root.getAttribute
|
|
9986
|
+
&& root.getAttribute('data-nac-id') === String(nac_id)) {
|
|
9987
|
+
el = root;
|
|
9988
|
+
} else {
|
|
9989
|
+
el = root.querySelector('[data-nac-id=' + safeId + ']');
|
|
9990
|
+
}
|
|
8245
9991
|
if (!el) return null;
|
|
8246
9992
|
/* 1. aria-label */
|
|
8247
9993
|
const aria = el.getAttribute('aria-label');
|
|
@@ -8280,6 +10026,7 @@
|
|
|
8280
10026
|
}
|
|
8281
10027
|
|
|
8282
10028
|
function context(plugin) {
|
|
10029
|
+
_nac_requireDocument('context');
|
|
8283
10030
|
const out = { breadcrumb: [] };
|
|
8284
10031
|
const root = _v25b_pluginRoot(plugin);
|
|
8285
10032
|
if (!root) return out;
|
|
@@ -8338,6 +10085,28 @@
|
|
|
8338
10085
|
Both delegate to NAC.read() so they inherit V25-01's full
|
|
8339
10086
|
fallback-chain semantics for free. */
|
|
8340
10087
|
|
|
10088
|
+
/* A value rendered for a human, that cannot throw. JSON.stringify
|
|
10089
|
+
fails on a cycle and on a DOM node it returns '{}', neither of
|
|
10090
|
+
which helps a reader; a DOM node is named by what it is. */
|
|
10091
|
+
function _v25_renderValue(v) {
|
|
10092
|
+
if (v === undefined) return 'undefined';
|
|
10093
|
+
if (v === null) return 'null';
|
|
10094
|
+
if (typeof v === 'string') return JSON.stringify(v);
|
|
10095
|
+
if (typeof v === 'number' || typeof v === 'boolean') return String(v);
|
|
10096
|
+
if (v && v.nodeType === 1 && typeof v.getAttribute === 'function') {
|
|
10097
|
+
const id = v.getAttribute('data-nac-id');
|
|
10098
|
+
return '<' + String(v.tagName || 'element').toLowerCase()
|
|
10099
|
+
+ (id ? ' data-nac-id="' + id + '"' : '') + '>'
|
|
10100
|
+
+ ' -- a DOM element: the binding has no `extract`, so it resolved the node itself';
|
|
10101
|
+
}
|
|
10102
|
+
try {
|
|
10103
|
+
const out = JSON.stringify(v);
|
|
10104
|
+
return out === undefined ? String(v) : out;
|
|
10105
|
+
} catch (e) {
|
|
10106
|
+
return '[unserialisable ' + (typeof v) + ': ' + (e && e.message ? e.message : 'cycle') + ']';
|
|
10107
|
+
}
|
|
10108
|
+
}
|
|
10109
|
+
|
|
8341
10110
|
function expect(plugin, statePath, value, opts) {
|
|
8342
10111
|
opts = opts || {};
|
|
8343
10112
|
const timeout = (typeof opts.timeout_ms === 'number') ? opts.timeout_ms : 5000;
|
|
@@ -8354,9 +10123,23 @@
|
|
|
8354
10123
|
catch (_) { matches = false; }
|
|
8355
10124
|
if (matches) { resolve(cur); return; }
|
|
8356
10125
|
if (Date.now() >= deadline) {
|
|
10126
|
+
/* The last value is rendered DEFENSIVELY (fixed 2.7.0,
|
|
10127
|
+
found by the first test this verb ever had).
|
|
10128
|
+
|
|
10129
|
+
It used to be a bare JSON.stringify(cur), and `cur` is
|
|
10130
|
+
whatever the host's state binding returned -- a
|
|
10131
|
+
dom-mirror binding with no extractor returns the ELEMENT
|
|
10132
|
+
itself, and app state can hold a reference cycle. On
|
|
10133
|
+
either of those, expect() threw a TypeError out of its
|
|
10134
|
+
own timeout path instead of rejecting with the timeout
|
|
10135
|
+
it promises, so the caller got "Converting circular
|
|
10136
|
+
structure to JSON" from inside a verb that was supposed
|
|
10137
|
+
to tell them their state never matched.
|
|
10138
|
+
An error path that can itself throw is worse than a
|
|
10139
|
+
vague message. */
|
|
8357
10140
|
reject(_v25_buildNacError('timeout',
|
|
8358
10141
|
'NAC.expect: state "' + statePath + '" did not match within ' +
|
|
8359
|
-
timeout + 'ms (last value: ' +
|
|
10142
|
+
timeout + 'ms (last value: ' + _v25_renderValue(cur) + ')'));
|
|
8360
10143
|
return;
|
|
8361
10144
|
}
|
|
8362
10145
|
setTimeout(tick, pollMs);
|
|
@@ -8399,6 +10182,7 @@
|
|
|
8399
10182
|
}
|
|
8400
10183
|
|
|
8401
10184
|
function tree(plugin, rootId) {
|
|
10185
|
+
_nac_requireDocument('tree');
|
|
8402
10186
|
const pluginRoot = _v25b_pluginRoot(plugin);
|
|
8403
10187
|
if (!pluginRoot) return [];
|
|
8404
10188
|
let start = pluginRoot;
|
|
@@ -8430,8 +10214,8 @@
|
|
|
8430
10214
|
|
|
8431
10215
|
global.NAC = {
|
|
8432
10216
|
__nac_v1_installed: true,
|
|
8433
|
-
version: '2.
|
|
8434
|
-
spec_version: '2.
|
|
10217
|
+
version: '2.8.0',
|
|
10218
|
+
spec_version: '2.8',
|
|
8435
10219
|
/* v2.2.0 (V22-01) -- strict validation toggle. When true,
|
|
8436
10220
|
NAC.register throws on findings (manifest_role_unknown,
|
|
8437
10221
|
tab_id_manifest_role_drift, manifest_dom_role_mismatch).
|
|
@@ -8445,7 +10229,18 @@
|
|
|
8445
10229
|
on the first slug uniqueness violation; the boot-time pass
|
|
8446
10230
|
paints a red banner + dispatches nac:fatal. Set false BEFORE
|
|
8447
10231
|
any register() call to opt out for a single migration window.
|
|
8448
|
-
|
|
10232
|
+
|
|
10233
|
+
2.7.0 (TF-A13) -- "The flag is removed in v2.6 (enforcement
|
|
10234
|
+
becomes unconditional)" is what this comment said while running
|
|
10235
|
+
INSIDE 2.6 with the flag present and consulted in four places.
|
|
10236
|
+
The removal is WITHDRAWN (D-13, owner delegation of
|
|
10237
|
+
2026-11-24), for two measured reasons: a host that set it false
|
|
10238
|
+
to get through a migration would start throwing on upgrade with
|
|
10239
|
+
no code change of its own -- the plainest form of breaking an
|
|
10240
|
+
adopter -- and the escape hatch is load-bearing in this
|
|
10241
|
+
repository too (runtime/test/stage11-plugin-id-dedup.mjs drives
|
|
10242
|
+
the opt-out path). The hatch is PERMANENT. What stays true is
|
|
10243
|
+
the default: enforcement is on unless a host says otherwise. */
|
|
8449
10244
|
HARD_DEDUP: true,
|
|
8450
10245
|
/* registry */
|
|
8451
10246
|
register: register,
|
|
@@ -8474,10 +10269,64 @@
|
|
|
8474
10269
|
verb (click/fill/select/invoke/tab/tab_by_label) honours the
|
|
8475
10270
|
gate, so STRICT_VERSIONING default flips to true: callers
|
|
8476
10271
|
MUST pass at least one expected_* or set STRICT_VERSIONING
|
|
8477
|
-
=false explicitly.
|
|
10272
|
+
=false explicitly.
|
|
10273
|
+
|
|
10274
|
+
2.7.0 (TF-A13) -- "Removed in v2.6 (becomes unconditional)" was
|
|
10275
|
+
written here and is withdrawn (D-13, owner delegation of
|
|
10276
|
+
2026-11-24), same reasoning as HARD_DEDUP above and one more
|
|
10277
|
+
that is specific to this one: made unconditional, every caller
|
|
10278
|
+
of every mutating verb MUST carry an expected_* snapshot, so an
|
|
10279
|
+
adopter driving click() without optimistic concurrency stops
|
|
10280
|
+
working on upgrade. The flag is PERMANENT and the default stays
|
|
10281
|
+
true. runtime/test/stage12-snapshot-versioning.mjs drives both
|
|
10282
|
+
sides of it. */
|
|
8478
10283
|
STRICT_VERSIONING: true,
|
|
8479
10284
|
eager_hashing: false,
|
|
8480
|
-
|
|
10285
|
+
/* v2.4 (RFC V24-04 sec 5.11) -- the runtime's self-described tier.
|
|
10286
|
+
|
|
10287
|
+
A TIER IS NOT A LEVEL, and that distinction is the whole point
|
|
10288
|
+
of this comment. There are two taxonomies in this project and
|
|
10289
|
+
their names look alike:
|
|
10290
|
+
|
|
10291
|
+
- a conformance TIER is what the RUNTIME supports, and the
|
|
10292
|
+
vocabulary is RFC V24-04 sec 6: 'NAC-3' (no versioning),
|
|
10293
|
+
'NAC-3-versioned' (honours expected_*), 'NAC-3-strict'. An
|
|
10294
|
+
agent reads it at boot to decide what it may send.
|
|
10295
|
+
- a conformance LEVEL is what a PAGE achieves, and the
|
|
10296
|
+
vocabulary is SPEC.md sec 8. `nac validate <url> --drive`
|
|
10297
|
+
reports one.
|
|
10298
|
+
|
|
10299
|
+
The published catalogue has said so in machine-readable form
|
|
10300
|
+
since 2.5.0 (audit N-29: until then api/ published this field as
|
|
10301
|
+
`type: "string"` and not its values, so a machine could see the
|
|
10302
|
+
field with no way to learn that 'NAC-3-versioned' is not a level
|
|
10303
|
+
name). The runtime export itself said nothing, which left the
|
|
10304
|
+
clarification only where a human was least likely to be
|
|
10305
|
+
reading. Now it is next to the value.
|
|
10306
|
+
|
|
10307
|
+
DEFAULT_CONFORMANCE_TIER is read, not retyped: the tier reject
|
|
10308
|
+
in the versioning gate used to carry its own copy of this
|
|
10309
|
+
string literal, which is audit N-17's shape in miniature. */
|
|
10310
|
+
conformance_tier: DEFAULT_CONFORMANCE_TIER,
|
|
10311
|
+
/* v2.7.0 (TF-A01). The selector drag_drop() removes from INSIDE a
|
|
10312
|
+
drop target before dropping. null = remove nothing, which is
|
|
10313
|
+
the default because a library may not delete a node out of a
|
|
10314
|
+
document it did not write. A target can override it with
|
|
10315
|
+
data-nac-drop-placeholder, which wins over this. */
|
|
10316
|
+
drop_placeholder_selector: null,
|
|
10317
|
+
/* v2.7.0 (TF-A02). The settle delay of drag_drop(), in ms. 80 is
|
|
10318
|
+
what this repository's demo UX needed and what every adopter
|
|
10319
|
+
paid; it stays the default so no existing drop changes timing,
|
|
10320
|
+
and opts.settle_ms overrides it per call. */
|
|
10321
|
+
drag_settle_ms: 80,
|
|
10322
|
+
/* v2.7.0 (TF-A11). Where the editor's "fix my grammar" control
|
|
10323
|
+
POSTs the text being edited. null = the feature is off and
|
|
10324
|
+
nothing is sent; the control reports that instead of guessing a
|
|
10325
|
+
path. It lives on THIS export on purpose: the only way to
|
|
10326
|
+
change it used to be a field of nac-chat-client.js, so an
|
|
10327
|
+
adopter loading the runtime alone could neither redirect it nor
|
|
10328
|
+
switch it off. */
|
|
10329
|
+
editor_ai_endpoint: null,
|
|
8481
10330
|
markHydrationComplete: markHydrationComplete,
|
|
8482
10331
|
versionHistory: versionHistory,
|
|
8483
10332
|
/* v2.3 preview (V23-02): introspection helper that returns the
|
|
@@ -8516,6 +10365,10 @@
|
|
|
8516
10365
|
list: list,
|
|
8517
10366
|
find: find,
|
|
8518
10367
|
read_feedback: read_feedback,
|
|
10368
|
+
/* v2.8.0 -- the role vocabulary, and the door into it. */
|
|
10369
|
+
roles: roles,
|
|
10370
|
+
canonical_role: canonical_role,
|
|
10371
|
+
register_role: register_role,
|
|
8519
10372
|
snapshot_state: snapshot_state,
|
|
8520
10373
|
/* write */
|
|
8521
10374
|
click: click,
|
|
@@ -8657,6 +10510,17 @@
|
|
|
8657
10510
|
/* v1.9.0 -- provenance authenticity (sec 6.2.1) */
|
|
8658
10511
|
sign_provenance: sign_provenance,
|
|
8659
10512
|
verify_provenance: verify_provenance,
|
|
10513
|
+
/* 2.7.0 -- manifest authenticity (sec 7.2). set_manifest_secret
|
|
10514
|
+
is the core entry point; NAC.set_provenance_secret in the
|
|
10515
|
+
extensions module forwards here so the example published in
|
|
10516
|
+
7.2 works as written. */
|
|
10517
|
+
set_manifest_secret: set_manifest_secret,
|
|
10518
|
+
sign_manifest: sign_manifest,
|
|
10519
|
+
verify_manifest: verify_manifest,
|
|
10520
|
+
manifest_provenance: manifest_provenance,
|
|
10521
|
+
/* 2.7.0 -- dispatch provenance override (sec 15.7) */
|
|
10522
|
+
set_source: set_source,
|
|
10523
|
+
get_source: get_source,
|
|
8660
10524
|
/* v1.9.0 -- recommended remediation (sec 6.2.30) */
|
|
8661
10525
|
recommended_remediation: recommended_remediation,
|
|
8662
10526
|
/* v1.2 -- error codes */
|
|
@@ -8689,6 +10553,16 @@
|
|
|
8689
10553
|
window (a React ref, a library instance held in a closure). */
|
|
8690
10554
|
plugins: plugins,
|
|
8691
10555
|
describePlugin: describePlugin,
|
|
10556
|
+
/* v2.7 -- the headless profile (SPEC.md sec 19 / decision D-26).
|
|
10557
|
+
profile() says whether a registered plugin needs a document at
|
|
10558
|
+
all; setEventSink() carries the nac:plugin:* family over a bus
|
|
10559
|
+
that is not the DOM, so a screenless host keeps its provenance;
|
|
10560
|
+
provenanceStatus() makes the delivery -- and any loss --
|
|
10561
|
+
readable instead of swallowed. */
|
|
10562
|
+
profile: profile,
|
|
10563
|
+
setEventSink: setEventSink,
|
|
10564
|
+
eventSink: eventSink,
|
|
10565
|
+
provenanceStatus: provenanceStatus,
|
|
8692
10566
|
registerApiHandle: registerApiHandle,
|
|
8693
10567
|
unregisterApiHandle: unregisterApiHandle,
|
|
8694
10568
|
apiHandles: apiHandles,
|