32 lines
2.5 KiB
JavaScript
32 lines
2.5 KiB
JavaScript
// limbaj.mjs (quantum exposure report, C12): the LANGUAGE GATE. The report has exactly two classification labels, and a short list of
|
|
// words it must never use about an address, because each of them promises something that cannot be read from a chain (section 2.2,
|
|
// N8, of the project document). This is the one file that names those words, so the source scan of the test excludes it.
|
|
//
|
|
// verificaLimbaj(text) -> [] when clean, else the list of { word, index, context } hits (every hit, not the first)
|
|
|
|
export const ETICHETA = Object.freeze({
|
|
EXPUSA: 'exposed (on-chain evidence)',
|
|
FARA_DOVADA: 'no on-chain evidence of exposure',
|
|
});
|
|
export const ETICHETE = Object.freeze([ETICHETA.EXPUSA, ETICHETA.FARA_DOVADA]);
|
|
/** the state of an address the tool could not classify; it is NOT a label, it says the measurement did not happen */
|
|
export const NEMASURAT = 'unmeasured';
|
|
|
|
// case-insensitive patterns, bounded by letters and digits only: a hyphen or a space before or after does NOT shield a word ("PQ-safe",
|
|
// "fully-protected", "well-secured", "quantum-safe-signatures" are caught), and the compounds are caught written with a hyphen, a space or
|
|
// nothing ("quantum resistant", "quantumproof", "post-quantum-safe", "quantum-secure", "trust-less"); every form of "guarantee" /
|
|
// "guarantor"; "safely", "safer", "safest", "safety", "safekeeping"; "secure", "secured", "securely". The bare verb "protect", the noun
|
|
// "protection" and "security" (CNSA 2.0 is cited as a profile for "national security systems") are not on the list: the tool's own
|
|
// negations ("it does not protect ...") and citations must stay clean. Measured on 2026-10-12 before it was put here: zero hits on the
|
|
// tool's publishable sources (after one README negation was reworded) and on the reports of mode 1 and of the four adapters on the
|
|
// recorded fixtures; every form the previous list missed is caught
|
|
const INTERZISE = ['safe(?:ly|r|st|ty|keeping)?', 'unexposed', 'protect(?:ed|s|ing)', 'secure(?:d|ly)?', 'guarant\\w*', 'trust[\\s-]?less', '(?:post[\\s-]*)?(?:quantum|pq)[\\s-]*(?:safe|proof|resistant|secure)'];
|
|
const RX = new RegExp('(?<![A-Za-z0-9])(' + INTERZISE.join('|') + ')(?![A-Za-z0-9])', 'gi');
|
|
|
|
export function verificaLimbaj(text) {
|
|
const t = String(text ?? ''); const hits = [];
|
|
for (const m of t.matchAll(RX)) hits.push({ word: m[1].toLowerCase(), index: m.index, context: t.slice(Math.max(0, m.index - 30), m.index + m[1].length + 30).replace(/\s+/g, ' ') });
|
|
return hits;
|
|
}
|
|
export const CUVINTE_INTERZISE = Object.freeze([...INTERZISE]);
|