@superbee/core 0.1.4 → 0.1.5
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/dist/document-mutation.d.ts.map +1 -1
- package/dist/document-mutation.js +16 -9
- package/dist/document-mutation.js.map +1 -1
- package/dist/document-write-policy.d.ts +16 -5
- package/dist/document-write-policy.d.ts.map +1 -1
- package/dist/document-write-policy.js +93 -34
- package/dist/document-write-policy.js.map +1 -1
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -1
- package/dist/freshness.d.ts +4 -2
- package/dist/freshness.d.ts.map +1 -1
- package/dist/freshness.js +15 -23
- package/dist/freshness.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/kinds.d.ts +1 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +1 -1
- package/dist/kinds.js.map +1 -1
- package/dist/okf-actor.d.ts +37 -0
- package/dist/okf-actor.d.ts.map +1 -0
- package/dist/okf-actor.js +87 -0
- package/dist/okf-actor.js.map +1 -0
- package/dist/okf-timestamps.d.ts +11 -0
- package/dist/okf-timestamps.d.ts.map +1 -0
- package/dist/okf-timestamps.js +75 -0
- package/dist/okf-timestamps.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/verification.d.ts +64 -0
- package/dist/verification.d.ts.map +1 -0
- package/dist/verification.js +175 -0
- package/dist/verification.js.map +1 -0
- package/dist/view-admission.d.ts +9 -0
- package/dist/view-admission.d.ts.map +1 -0
- package/dist/view-admission.js +22 -0
- package/dist/view-admission.js.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** One verification event. Producer extras beyond `by`/`at` are preserved, never interpreted. */
|
|
2
|
+
export interface VerificationEvent {
|
|
3
|
+
by: string;
|
|
4
|
+
at?: string;
|
|
5
|
+
[extra: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** Trust tiers, lowest to highest (SPEC 5.3). */
|
|
8
|
+
export type TrustTier = "unverified" | "machine-confirmed" | "human-reviewed";
|
|
9
|
+
/** The three tiers in ascending order — the one place a consumer iterates them. */
|
|
10
|
+
export declare const TRUST_TIERS: readonly TrustTier[];
|
|
11
|
+
/** The derived projection name surfaces expose (`list --fields trust`, receipts, status counts). */
|
|
12
|
+
export declare const TRUST_TIER_FIELD = "trust";
|
|
13
|
+
/**
|
|
14
|
+
* The document's verification events as the list the spec defines, or `[]` when the key is absent.
|
|
15
|
+
* A bare `{ by, at }` mapping reads as a one-element list (SPEC 5.2 MUST). Entries that carry no
|
|
16
|
+
* usable `by` cannot name a verifier and therefore cannot raise a tier; they are skipped here, and
|
|
17
|
+
* {@link appendVerificationEvent} refuses to write around them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function verificationEvents(frontmatter: Readonly<Record<string, unknown>>): VerificationEvent[];
|
|
20
|
+
/** Derive the trust tier (SPEC 5.3): keyed on the `human:` prefix of any verifier. */
|
|
21
|
+
export declare function trustTier(frontmatter: Readonly<Record<string, unknown>>): TrustTier;
|
|
22
|
+
/** The latest parseable `at` across the events ("how recently" per SPEC 5.2), or `undefined`. */
|
|
23
|
+
export declare function latestVerifiedAt(events: readonly VerificationEvent[]): string | undefined;
|
|
24
|
+
/** Documents per tier — the one fold `status` and `home` both render. */
|
|
25
|
+
export type TrustTierCounts = Record<TrustTier, number>;
|
|
26
|
+
export declare function trustTierCounts(docs: Iterable<{
|
|
27
|
+
frontmatter: Readonly<Record<string, unknown>>;
|
|
28
|
+
}>): TrustTierCounts;
|
|
29
|
+
/**
|
|
30
|
+
* Parse an instant a verifier supplies, or return `null`. Unlike `Date.parse`, this refuses what
|
|
31
|
+
* a caller did not say: an impossible calendar date (`2026-02-30`, a non-leap `02-29`), an
|
|
32
|
+
* out-of-range time, or a value without a zone designator (which would name a different instant
|
|
33
|
+
* on every host). Read-side consumers stay permissive (see {@link latestVerifiedAt}); this rule
|
|
34
|
+
* guards what gets WRITTEN. Defaults to millisecond truncation; `ceil` compares expiration
|
|
35
|
+
* deadlines against a millisecond clock without expiring before a fractional deadline.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseIsoInstant(raw: string, rounding?: "truncate" | "ceil"): number | null;
|
|
38
|
+
/**
|
|
39
|
+
* The instant a stored `at` denotes, for comparison and "how recently" selection: the strict
|
|
40
|
+
* grammar first (so every spelling the write path accepts resolves identically), then the
|
|
41
|
+
* permissive `Date.parse` for legacy producer spellings the read side must not drop. `null` when
|
|
42
|
+
* neither understands the value.
|
|
43
|
+
*/
|
|
44
|
+
export declare function storedInstant(value: unknown): number | null;
|
|
45
|
+
export interface AppendVerificationOptions {
|
|
46
|
+
/** The verifier; must satisfy the OKF actor convention (SPEC 7). */
|
|
47
|
+
by: string;
|
|
48
|
+
/** ISO-8601 instant of the confirmation, with a zone designator (see {@link parseIsoInstant}). */
|
|
49
|
+
at: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Return frontmatter with one more verification event appended. The result is always a list:
|
|
53
|
+
* an absent key becomes `[event]`, a bare mapping becomes `[existing, event]`, a list grows by one.
|
|
54
|
+
* Every other `verified` shape (a scalar, a list containing a non-event) is refused, because
|
|
55
|
+
* rewriting it would destroy trust history the caller did not ask to change.
|
|
56
|
+
*
|
|
57
|
+
* Idempotent: an event that already exists (same `by`, same instant) is already recorded, so the
|
|
58
|
+
* frontmatter is returned as-is and the caller's mutation converges to a no-op — repeating a
|
|
59
|
+
* satisfied verification never manufactures a duplicate confirmation or a new revision.
|
|
60
|
+
*/
|
|
61
|
+
export declare function appendVerificationEvent<F extends Readonly<Record<string, unknown>>>(frontmatter: F, options: AppendVerificationOptions): F & {
|
|
62
|
+
verified: VerificationEvent[];
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -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wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAM3D;AAED,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,kGAAkG;IAClG,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACjF,WAAW,EAAE,CAAC,EACd,OAAO,EAAE,yBAAyB,GACjC,CAAC,GAAG;IAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAAE,CAgCvC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OKF v0.2 `verified` events and the trust tier consumers derive from them (SPEC 5.2, 5.3).
|
|
3
|
+
*
|
|
4
|
+
* Read side: `verified` is a list of `{ by, at }` events. A producer MAY write a single event as
|
|
5
|
+
* a bare mapping; consumers MUST treat it as a one-element list. Every surface that classifies
|
|
6
|
+
* trust reads through {@link verificationEvents} so the normalization exists exactly once.
|
|
7
|
+
*
|
|
8
|
+
* Write side: {@link appendVerificationEvent} is the one policy that adds an event. It preserves
|
|
9
|
+
* existing events byte-for-byte (including producer extras such as `method`), normalizes a bare
|
|
10
|
+
* mapping into the list it already meant, and refuses to append onto a `verified` value that is
|
|
11
|
+
* not a list of events rather than silently replacing it.
|
|
12
|
+
*
|
|
13
|
+
* Pure and dependency-light on purpose: the browser UI consumes it through the
|
|
14
|
+
* `@superbee/core/verification` subpath without pulling the storage engine.
|
|
15
|
+
*/
|
|
16
|
+
import { InvalidInputError, OkfActorError } from "./errors.js";
|
|
17
|
+
import { isHumanActor, isOkfActor } from "./okf-actor.js";
|
|
18
|
+
/** The three tiers in ascending order — the one place a consumer iterates them. */
|
|
19
|
+
export const TRUST_TIERS = Object.freeze([
|
|
20
|
+
"unverified",
|
|
21
|
+
"machine-confirmed",
|
|
22
|
+
"human-reviewed",
|
|
23
|
+
]);
|
|
24
|
+
/** The derived projection name surfaces expose (`list --fields trust`, receipts, status counts). */
|
|
25
|
+
export const TRUST_TIER_FIELD = "trust";
|
|
26
|
+
function isRecord(value) {
|
|
27
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
function isEvent(value) {
|
|
30
|
+
return isRecord(value) && typeof value.by === "string" && value.by.trim() !== "";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The document's verification events as the list the spec defines, or `[]` when the key is absent.
|
|
34
|
+
* A bare `{ by, at }` mapping reads as a one-element list (SPEC 5.2 MUST). Entries that carry no
|
|
35
|
+
* usable `by` cannot name a verifier and therefore cannot raise a tier; they are skipped here, and
|
|
36
|
+
* {@link appendVerificationEvent} refuses to write around them.
|
|
37
|
+
*/
|
|
38
|
+
export function verificationEvents(frontmatter) {
|
|
39
|
+
const raw = frontmatter.verified;
|
|
40
|
+
if (raw === undefined || raw === null)
|
|
41
|
+
return [];
|
|
42
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
43
|
+
return entries.filter(isEvent).map((event) => ({ ...event }));
|
|
44
|
+
}
|
|
45
|
+
/** Derive the trust tier (SPEC 5.3): keyed on the `human:` prefix of any verifier. */
|
|
46
|
+
export function trustTier(frontmatter) {
|
|
47
|
+
const events = verificationEvents(frontmatter);
|
|
48
|
+
if (events.length === 0)
|
|
49
|
+
return "unverified";
|
|
50
|
+
return events.some((event) => isHumanActor(event.by)) ? "human-reviewed" : "machine-confirmed";
|
|
51
|
+
}
|
|
52
|
+
/** The latest parseable `at` across the events ("how recently" per SPEC 5.2), or `undefined`. */
|
|
53
|
+
export function latestVerifiedAt(events) {
|
|
54
|
+
let latest;
|
|
55
|
+
for (const event of events) {
|
|
56
|
+
if (typeof event.at !== "string")
|
|
57
|
+
continue;
|
|
58
|
+
const ms = storedInstant(event.at);
|
|
59
|
+
if (ms === null)
|
|
60
|
+
continue;
|
|
61
|
+
if (latest === undefined || ms > latest.ms)
|
|
62
|
+
latest = { at: event.at, ms };
|
|
63
|
+
}
|
|
64
|
+
return latest?.at;
|
|
65
|
+
}
|
|
66
|
+
export function trustTierCounts(docs) {
|
|
67
|
+
const counts = { unverified: 0, "machine-confirmed": 0, "human-reviewed": 0 };
|
|
68
|
+
for (const doc of docs)
|
|
69
|
+
counts[trustTier(doc.frontmatter)] += 1;
|
|
70
|
+
return counts;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Strict ISO-8601 instant grammar: calendar date, `T`, time, and a REQUIRED zone designator
|
|
74
|
+
* (`Z`, `±hh`, `±hhmm`, or `±hh:mm`). Fractional seconds optional. Lowercase `t`/`z` accepted as
|
|
75
|
+
* ISO permits.
|
|
76
|
+
*/
|
|
77
|
+
const ISO_INSTANT = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(?:([Zz])|([+-])(\d{2})(?::?(\d{2}))?)$/;
|
|
78
|
+
/**
|
|
79
|
+
* Parse an instant a verifier supplies, or return `null`. Unlike `Date.parse`, this refuses what
|
|
80
|
+
* a caller did not say: an impossible calendar date (`2026-02-30`, a non-leap `02-29`), an
|
|
81
|
+
* out-of-range time, or a value without a zone designator (which would name a different instant
|
|
82
|
+
* on every host). Read-side consumers stay permissive (see {@link latestVerifiedAt}); this rule
|
|
83
|
+
* guards what gets WRITTEN. Defaults to millisecond truncation; `ceil` compares expiration
|
|
84
|
+
* deadlines against a millisecond clock without expiring before a fractional deadline.
|
|
85
|
+
*/
|
|
86
|
+
export function parseIsoInstant(raw, rounding = "truncate") {
|
|
87
|
+
const match = ISO_INSTANT.exec(raw);
|
|
88
|
+
if (!match)
|
|
89
|
+
return null;
|
|
90
|
+
const [, y, mo, d, h, mi, sec = "0", frac = "0", zulu, sign, oh, om = "0"] = match;
|
|
91
|
+
const year = Number(y);
|
|
92
|
+
const month = Number(mo);
|
|
93
|
+
const day = Number(d);
|
|
94
|
+
const hour = Number(h);
|
|
95
|
+
const minute = Number(mi);
|
|
96
|
+
const second = Number(sec);
|
|
97
|
+
if (month < 1 || month > 12)
|
|
98
|
+
return null;
|
|
99
|
+
const probe = new Date(0);
|
|
100
|
+
probe.setUTCFullYear(year, month, 0); // day 0 of the NEXT month = last day of this one
|
|
101
|
+
if (day < 1 || day > probe.getUTCDate())
|
|
102
|
+
return null;
|
|
103
|
+
if (hour > 23 || minute > 59 || second > 59)
|
|
104
|
+
return null;
|
|
105
|
+
let offsetMinutes = 0;
|
|
106
|
+
if (!zulu) {
|
|
107
|
+
const offsetHours = Number(oh);
|
|
108
|
+
const offsetMins = Number(om);
|
|
109
|
+
if (offsetHours > 23 || offsetMins > 59)
|
|
110
|
+
return null;
|
|
111
|
+
offsetMinutes = (sign === "-" ? -1 : 1) * (offsetHours * 60 + offsetMins);
|
|
112
|
+
}
|
|
113
|
+
// Truncate, never round: a recorded instant must not be later than the one the caller supplied.
|
|
114
|
+
const millis = Number(frac.padEnd(3, "0").slice(0, 3));
|
|
115
|
+
const instant = new Date(0);
|
|
116
|
+
instant.setUTCFullYear(year, month - 1, day);
|
|
117
|
+
instant.setUTCHours(hour, minute, second, millis);
|
|
118
|
+
// Expiration consumers round up so a sub-millisecond deadline never expires early.
|
|
119
|
+
const remainder = rounding === "ceil" && /[1-9]/.test(frac.slice(3)) ? 1 : 0;
|
|
120
|
+
return instant.getTime() - offsetMinutes * 60_000 + remainder;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The instant a stored `at` denotes, for comparison and "how recently" selection: the strict
|
|
124
|
+
* grammar first (so every spelling the write path accepts resolves identically), then the
|
|
125
|
+
* permissive `Date.parse` for legacy producer spellings the read side must not drop. `null` when
|
|
126
|
+
* neither understands the value.
|
|
127
|
+
*/
|
|
128
|
+
export function storedInstant(value) {
|
|
129
|
+
if (typeof value !== "string")
|
|
130
|
+
return null;
|
|
131
|
+
const strict = parseIsoInstant(value.trim());
|
|
132
|
+
if (strict !== null)
|
|
133
|
+
return strict;
|
|
134
|
+
const legacy = Date.parse(value);
|
|
135
|
+
return Number.isNaN(legacy) ? null : legacy;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Return frontmatter with one more verification event appended. The result is always a list:
|
|
139
|
+
* an absent key becomes `[event]`, a bare mapping becomes `[existing, event]`, a list grows by one.
|
|
140
|
+
* Every other `verified` shape (a scalar, a list containing a non-event) is refused, because
|
|
141
|
+
* rewriting it would destroy trust history the caller did not ask to change.
|
|
142
|
+
*
|
|
143
|
+
* Idempotent: an event that already exists (same `by`, same instant) is already recorded, so the
|
|
144
|
+
* frontmatter is returned as-is and the caller's mutation converges to a no-op — repeating a
|
|
145
|
+
* satisfied verification never manufactures a duplicate confirmation or a new revision.
|
|
146
|
+
*/
|
|
147
|
+
export function appendVerificationEvent(frontmatter, options) {
|
|
148
|
+
if (!isOkfActor(options.by)) {
|
|
149
|
+
throw new OkfActorError(options.by, `OKF v0.2 verifier '${options.by}' must be human:<id>, process:<id>, or <producer>/<version>`);
|
|
150
|
+
}
|
|
151
|
+
const instant = typeof options.at === "string" ? parseIsoInstant(options.at) : null;
|
|
152
|
+
if (instant === null) {
|
|
153
|
+
throw new InvalidInputError("OKF v0.2 verified.at must be a real ISO-8601 date-time with a timezone designator (e.g. 2026-09-07T12:00:00Z)");
|
|
154
|
+
}
|
|
155
|
+
const raw = frontmatter.verified;
|
|
156
|
+
let existing;
|
|
157
|
+
if (raw === undefined || raw === null) {
|
|
158
|
+
existing = [];
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
162
|
+
if (!entries.every(isEvent)) {
|
|
163
|
+
throw new InvalidInputError("OKF v0.2 verified must be a list of { by, at } events (or one bare event) before a verification can be appended");
|
|
164
|
+
}
|
|
165
|
+
existing = entries;
|
|
166
|
+
}
|
|
167
|
+
// Same resolver as the read side, so any spelling the grammar accepts on write (including an
|
|
168
|
+
// imported `+02` offset) is recognized as the same instant on repeat.
|
|
169
|
+
const alreadyRecorded = existing.some((prior) => prior.by === options.by && storedInstant(prior.at) === instant);
|
|
170
|
+
if (alreadyRecorded)
|
|
171
|
+
return frontmatter;
|
|
172
|
+
const event = { by: options.by, at: options.at };
|
|
173
|
+
return { ...frontmatter, verified: [...existing, event] };
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../src/verification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAY1D,mFAAmF;AACnF,MAAM,CAAC,MAAM,WAAW,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC7D,YAAY;IACZ,mBAAmB;IACnB,gBAAgB;CACjB,CAAC,CAAC;AAEH,oGAAoG;AACpG,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACnF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAA8C;IAC/E,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC;IACjC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO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CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,iBAAiB,CACzB,iHAAiH,CAClH,CAAC;QACJ,CAAC;QACD,QAAQ,GAAG,OAAO,CAAC;IACrB,CAAC;IACD,6FAA6F;IAC7F,sEAAsE;IACtE,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC;IACjH,IAAI,eAAe;QAAE,OAAO,WAAoD,CAAC;IACjF,MAAM,KAAK,GAAsB,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;IACpE,OAAO,EAAE,GAAG,WAAW,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Byte-format admission only. Callers own bounded retrieval, registration,
|
|
2
|
+
* exact-version checks, isolation and authorization; this grants no execution authority. */
|
|
3
|
+
export declare const MAX_ACTIVE_VIEW_BYTES: number;
|
|
4
|
+
export declare const ACTIVE_VIEW_CONTENT_TYPE = "text/html; charset=utf-8";
|
|
5
|
+
export declare function admitActiveView(bytes: Uint8Array, contentType: string): {
|
|
6
|
+
bytes: Uint8Array;
|
|
7
|
+
contentType: typeof ACTIVE_VIEW_CONTENT_TYPE;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=view-admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-admission.d.ts","sourceRoot":"","sources":["../src/view-admission.ts"],"names":[],"mappings":"AAAA;4FAC4F;AAC5F,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAChD,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,OAAO,wBAAwB,CAAA;CAAE,CAerE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Byte-format admission only. Callers own bounded retrieval, registration,
|
|
2
|
+
* exact-version checks, isolation and authorization; this grants no execution authority. */
|
|
3
|
+
export const MAX_ACTIVE_VIEW_BYTES = 512 * 1024;
|
|
4
|
+
export const ACTIVE_VIEW_CONTENT_TYPE = "text/html; charset=utf-8";
|
|
5
|
+
export function admitActiveView(bytes, contentType) {
|
|
6
|
+
if (bytes.byteLength > MAX_ACTIVE_VIEW_BYTES) {
|
|
7
|
+
throw new Error("active View HTML must be at most 512 KiB");
|
|
8
|
+
}
|
|
9
|
+
const [mediaType, ...parameters] = contentType
|
|
10
|
+
.split(";")
|
|
11
|
+
.map((part) => part.trim().toLowerCase());
|
|
12
|
+
if (mediaType !== "text/html")
|
|
13
|
+
throw new Error("active View entries must use text/html");
|
|
14
|
+
for (const parameter of parameters) {
|
|
15
|
+
if (parameter && parameter !== "charset=utf-8" && parameter !== 'charset="utf-8"') {
|
|
16
|
+
throw new Error("active View entries may declare only UTF-8 HTML");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
20
|
+
return { bytes: bytes.slice(), contentType: ACTIVE_VIEW_CONTENT_TYPE };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=view-admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-admission.js","sourceRoot":"","sources":["../src/view-admission.ts"],"names":[],"mappings":"AAAA;4FAC4F;AAC5F,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,MAAM,UAAU,eAAe,CAC7B,KAAiB,EACjB,WAAmB;IAEnB,IAAI,KAAK,CAAC,UAAU,GAAG,qBAAqB,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,GAAG,WAAW;SAC3C,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,IAAI,SAAS,KAAK,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACzF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,SAAS,IAAI,SAAS,KAAK,eAAe,IAAI,SAAS,KAAK,iBAAiB,EAAE,CAAC;YAClF,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IACD,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;AACzE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superbee/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OKF store engine — bundle I/O, cross-links, derived backlinks, freshness, and versioned writes.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"exports": {
|
|
16
|
+
"./view-admission": {
|
|
17
|
+
"types": "./dist/view-admission.d.ts",
|
|
18
|
+
"default": "./dist/view-admission.js"
|
|
19
|
+
},
|
|
16
20
|
".": {
|
|
17
21
|
"types": "./dist/index.d.ts",
|
|
18
22
|
"default": "./dist/index.js"
|
|
@@ -45,6 +49,10 @@
|
|
|
45
49
|
"types": "./dist/mutation-attribution.d.ts",
|
|
46
50
|
"default": "./dist/mutation-attribution.js"
|
|
47
51
|
},
|
|
52
|
+
"./verification": {
|
|
53
|
+
"types": "./dist/verification.d.ts",
|
|
54
|
+
"default": "./dist/verification.js"
|
|
55
|
+
},
|
|
48
56
|
"./page": {
|
|
49
57
|
"types": "./dist/page.d.ts",
|
|
50
58
|
"default": "./dist/page.js"
|