@sentropic/artifacts 0.2.16 → 0.2.17
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 +21 -0
- package/dist/content/handler.d.ts +7 -0
- package/dist/content/handler.js +28 -5
- package/dist/content/headers.d.ts +13 -0
- package/dist/content/headers.js +40 -2
- package/dist/mcp-core.d.ts +1 -1
- package/dist/mcp-core.js +1 -1
- package/dist/server/mime.d.ts +9 -0
- package/dist/server/mime.js +47 -0
- package/dist/server/upload-page.d.ts +7 -0
- package/dist/server/upload-page.js +16 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.17
|
|
4
|
+
|
|
5
|
+
- Application assets carry the worker's own same-origin/no-eval CSP; HTML inline hashes stay confined to HTML responses.
|
|
6
|
+
- Application content mode (host-configured, owner decision 05/11): the
|
|
7
|
+
generic host offers `safe` (historic strict regime, default, bit-for-bit
|
|
8
|
+
unchanged) and `application` (binding J1.0 policy: same-origin workers,
|
|
9
|
+
runtime-injected styles, history fallback to `index.html` for
|
|
10
|
+
extensionless HTML navigations). Service workers stay refused in both
|
|
11
|
+
modes; a missing asset stays 404, never the fallback. The policy lives in
|
|
12
|
+
one constant so the conductor can relay adjustments.
|
|
13
|
+
- Generic extension to MIME map: `.geojson` → `application/json`,
|
|
14
|
+
`.mjs` → `text/javascript`, `.woff2` → `font/woff2`; `.wasm` →
|
|
15
|
+
`application/wasm` and `.pbf` → `application/x-protobuf` stay mapped as
|
|
16
|
+
the owner asked. No `wasm-unsafe-eval` in any served policy.
|
|
17
|
+
- Generic grant contract (J1.3b): first-party grant route wired to
|
|
18
|
+
`grantWithFreshRights`, neutral host-parameterizable consent screen,
|
|
19
|
+
typed 403 `{ code, scopeId, retryable: false }` with a single prescribed
|
|
20
|
+
screen navigation, scopes and versions host-declared.
|
|
21
|
+
- No MCP tool definition changes (the 17 pre-existing definitions stay
|
|
22
|
+
byte-identical). Stays in `0.2.x` (cluster-mesh peer `>=0.2.0 <0.3.0`).
|
|
23
|
+
|
|
3
24
|
## 0.2.16
|
|
4
25
|
|
|
5
26
|
- Upload channel integrity, fail-closed (immo preprod, OVH S3 403): the
|
|
@@ -4,6 +4,7 @@ import type { LifecycleService } from '../server/lifecycle.js';
|
|
|
4
4
|
import { type SharingPolicyPort } from '../server/ports.js';
|
|
5
5
|
import type { PublicationBlobStore, PublicationService } from '../server/publication.js';
|
|
6
6
|
import { type GrantSigner, type TicketService } from './grants.js';
|
|
7
|
+
import { type ContentMode } from './headers.js';
|
|
7
8
|
export interface ContentRequest {
|
|
8
9
|
method: string;
|
|
9
10
|
host: string;
|
|
@@ -14,6 +15,8 @@ export interface ContentRequest {
|
|
|
14
15
|
ticket?: string;
|
|
15
16
|
/** Raw HTTP Range header, mapped by the host; absent ⇒ whole file. */
|
|
16
17
|
range?: string;
|
|
18
|
+
/** Raw HTTP Accept header, mapped by the host; absent ⇒ navigation fallback allowed. */
|
|
19
|
+
accept?: string;
|
|
17
20
|
}
|
|
18
21
|
export interface ContentResponse {
|
|
19
22
|
status: number;
|
|
@@ -37,6 +40,10 @@ export interface ContentHandlerDeps {
|
|
|
37
40
|
/** G1 lock 1 (deployment capability), absent ⇒ closed. */
|
|
38
41
|
allowPublicSharing?: boolean;
|
|
39
42
|
assetCacheSeconds?: number;
|
|
43
|
+
/** Host-configured mode (owner decision 05/11): `safe` default, `application` for real SPAs. */
|
|
44
|
+
contentMode?: ContentMode;
|
|
45
|
+
/** Per-release inline script hashes for the served HTML file, application mode only. */
|
|
46
|
+
getScriptHashes?: (filePath: string) => readonly string[] | undefined;
|
|
40
47
|
}
|
|
41
48
|
/** Create the content handler over injected host ports (no server). */
|
|
42
49
|
export declare function createContentHandler(deps: ContentHandlerDeps): {
|
package/dist/content/handler.js
CHANGED
|
@@ -18,6 +18,21 @@ import { combineSharingPolicy, resolveSharingPolicy } from '../server/ports.js';
|
|
|
18
18
|
import { CONTENT_GRANT_TTL_SECONDS } from './grants.js';
|
|
19
19
|
import { contentHeaders, grantCookie, parseGrantCookie } from './headers.js';
|
|
20
20
|
import { isServiceWorkerPath, parseContentHost, resolveContentPath } from './routing.js';
|
|
21
|
+
/**
|
|
22
|
+
* History fallback (application mode only): an extensionless HTML navigation
|
|
23
|
+
* serves the release entry instead of 404. Missing assets (extension
|
|
24
|
+
* present), reader protocol paths and non-HTML data fetches stay 404.
|
|
25
|
+
*/
|
|
26
|
+
function isHistoryFallback(filePath, accept) {
|
|
27
|
+
if (filePath === '_reader' || filePath.startsWith('_reader/'))
|
|
28
|
+
return false;
|
|
29
|
+
const last = filePath.split('/').pop() ?? '';
|
|
30
|
+
if (last.includes('.'))
|
|
31
|
+
return false;
|
|
32
|
+
if (accept === undefined)
|
|
33
|
+
return true;
|
|
34
|
+
return accept.split(',').some((part) => part.split(';')[0]?.trim() === 'text/html');
|
|
35
|
+
}
|
|
21
36
|
function jsonResponse(status, body, extra = {}) {
|
|
22
37
|
return { status, body, headers: {
|
|
23
38
|
...contentHeaders({ mimeType: 'application/json', size: Buffer.byteLength(JSON.stringify(body)) }),
|
|
@@ -83,16 +98,24 @@ export function createContentHandler(deps) {
|
|
|
83
98
|
const bytes = await deps.blobs.getBlob(key);
|
|
84
99
|
return bytes === undefined ? undefined : bytes.slice(start, end + 1);
|
|
85
100
|
}
|
|
86
|
-
async function serveFile(artifactId, manifest, filePath, rangeHeader) {
|
|
101
|
+
async function serveFile(artifactId, manifest, filePath, rangeHeader, accept) {
|
|
87
102
|
const acl = await deps.acls.getArtifactAcl(artifactId);
|
|
88
103
|
if (acl === undefined)
|
|
89
104
|
return fail(404);
|
|
90
105
|
if (acl.storageScopeId === undefined)
|
|
91
106
|
return fail(500);
|
|
107
|
+
const mode = deps.contentMode ?? 'safe';
|
|
92
108
|
const parsed = JSON.parse(manifest);
|
|
93
|
-
|
|
109
|
+
let file = (parsed.files ?? []).find((entry) => entry.path === filePath);
|
|
110
|
+
let servedPath = filePath;
|
|
111
|
+
if ((file === undefined || typeof file.digest !== 'string') &&
|
|
112
|
+
mode === 'application' && isHistoryFallback(filePath, accept)) {
|
|
113
|
+
file = (parsed.files ?? []).find((entry) => entry.path === 'index.html');
|
|
114
|
+
servedPath = 'index.html';
|
|
115
|
+
}
|
|
94
116
|
if (file === undefined || typeof file.digest !== 'string')
|
|
95
117
|
return fail(404);
|
|
118
|
+
const scriptHashes = mode === 'application' ? deps.getScriptHashes?.(servedPath) : undefined;
|
|
96
119
|
const hex = file.digest.startsWith('sha256:') ? file.digest.slice(7) : file.digest;
|
|
97
120
|
const key = `artifacts/${acl.storageScopeId}/blobs/sha256/${hex}`;
|
|
98
121
|
const mimeType = typeof file.mimeType === 'string' ? file.mimeType : 'application/octet-stream';
|
|
@@ -117,7 +140,7 @@ export function createContentHandler(deps) {
|
|
|
117
140
|
return {
|
|
118
141
|
status: 206,
|
|
119
142
|
headers: { ...contentHeaders({ mimeType, size: bytes.length,
|
|
120
|
-
assetCacheSeconds: deps.assetCacheSeconds }),
|
|
143
|
+
assetCacheSeconds: deps.assetCacheSeconds, mode, scriptHashes }),
|
|
121
144
|
'content-range': `bytes ${range.start}-${range.end}/${size}`,
|
|
122
145
|
'accept-ranges': 'bytes' },
|
|
123
146
|
bytes,
|
|
@@ -134,7 +157,7 @@ export function createContentHandler(deps) {
|
|
|
134
157
|
return {
|
|
135
158
|
status: 200,
|
|
136
159
|
headers: { ...contentHeaders({ mimeType, size: bytes.length,
|
|
137
|
-
assetCacheSeconds: deps.assetCacheSeconds }),
|
|
160
|
+
assetCacheSeconds: deps.assetCacheSeconds, mode, scriptHashes }),
|
|
138
161
|
'accept-ranges': 'bytes' },
|
|
139
162
|
bytes,
|
|
140
163
|
};
|
|
@@ -211,7 +234,7 @@ export function createContentHandler(deps) {
|
|
|
211
234
|
const filePath = resolveContentPath(request.path);
|
|
212
235
|
if (filePath === undefined || isServiceWorkerPath(filePath))
|
|
213
236
|
return fail(404);
|
|
214
|
-
return serveFile(artifactId, release.manifest, filePath, request.range);
|
|
237
|
+
return serveFile(artifactId, release.manifest, filePath, request.range, request.accept);
|
|
215
238
|
}
|
|
216
239
|
return {
|
|
217
240
|
async handle(request) {
|
|
@@ -11,11 +11,24 @@
|
|
|
11
11
|
* prefix: Secure, Path=/, no Domain attribute).
|
|
12
12
|
*/
|
|
13
13
|
export declare const GRANT_COOKIE_NAME = "__Host-artifacts_grant";
|
|
14
|
+
/** Host-configured content mode (owner decision 05/11): safe is the historic strict regime and the default. */
|
|
15
|
+
export type ContentMode = 'safe' | 'application';
|
|
16
|
+
/**
|
|
17
|
+
* Application-mode HTML policy (binding J1.0, measured on the real immo UI
|
|
18
|
+
* build): same-origin module workers, runtime-injected styles, blob media.
|
|
19
|
+
* No `unsafe-eval`, no `wasm-unsafe-eval`, no `blob:` worker. Kept as one
|
|
20
|
+
* constant so the conductor can relay adjustments.
|
|
21
|
+
*/
|
|
22
|
+
export declare const APPLICATION_HTML_CSP: string;
|
|
14
23
|
export interface ContentHeaderInput {
|
|
15
24
|
mimeType: string;
|
|
16
25
|
size: number;
|
|
17
26
|
/** Explicit host opt-in for non-HTML asset caching (seconds). */
|
|
18
27
|
assetCacheSeconds?: number;
|
|
28
|
+
/** Host-configured mode: `safe` (default, historic strict) or `application` (J1.0 policy). */
|
|
29
|
+
mode?: ContentMode;
|
|
30
|
+
/** Per-release inline script hashes, application mode only. */
|
|
31
|
+
scriptHashes?: readonly string[];
|
|
19
32
|
}
|
|
20
33
|
/** Security/cache headers for one served file (declared MIME wins). */
|
|
21
34
|
export declare function contentHeaders(input: ContentHeaderInput): Record<string, string>;
|
package/dist/content/headers.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* prefix: Secure, Path=/, no Domain attribute).
|
|
12
12
|
*/
|
|
13
13
|
export const GRANT_COOKIE_NAME = '__Host-artifacts_grant';
|
|
14
|
-
const
|
|
14
|
+
const SAFE_HTML_CSP = [
|
|
15
15
|
"default-src 'self'",
|
|
16
16
|
"script-src 'self' 'unsafe-inline'",
|
|
17
17
|
"style-src 'self' 'unsafe-inline'",
|
|
@@ -23,6 +23,39 @@ const HTML_CSP = [
|
|
|
23
23
|
"form-action 'none'",
|
|
24
24
|
"frame-ancestors 'none'",
|
|
25
25
|
].join('; ');
|
|
26
|
+
/**
|
|
27
|
+
* Application-mode HTML policy (binding J1.0, measured on the real immo UI
|
|
28
|
+
* build): same-origin module workers, runtime-injected styles, blob media.
|
|
29
|
+
* No `unsafe-eval`, no `wasm-unsafe-eval`, no `blob:` worker. Kept as one
|
|
30
|
+
* constant so the conductor can relay adjustments.
|
|
31
|
+
*/
|
|
32
|
+
export const APPLICATION_HTML_CSP = [
|
|
33
|
+
"default-src 'self'",
|
|
34
|
+
"script-src 'self'",
|
|
35
|
+
"style-src 'self' 'unsafe-inline'",
|
|
36
|
+
"img-src 'self' data: blob:",
|
|
37
|
+
"font-src 'self'",
|
|
38
|
+
"media-src 'self' blob:",
|
|
39
|
+
"connect-src 'self'",
|
|
40
|
+
"worker-src 'self'",
|
|
41
|
+
"child-src 'self'",
|
|
42
|
+
"frame-src 'none'",
|
|
43
|
+
"frame-ancestors 'none'",
|
|
44
|
+
"object-src 'none'",
|
|
45
|
+
"base-uri 'none'",
|
|
46
|
+
"form-action 'none'",
|
|
47
|
+
].join('; ');
|
|
48
|
+
const SCRIPT_HASH_RE = /^'sha256-[A-Za-z0-9+/=]+'$/;
|
|
49
|
+
/** Application policy with per-release inline script hashes appended to `script-src` only. */
|
|
50
|
+
function applicationCsp(scriptHashes) {
|
|
51
|
+
if (scriptHashes === undefined || scriptHashes.length === 0)
|
|
52
|
+
return APPLICATION_HTML_CSP;
|
|
53
|
+
for (const hash of scriptHashes) {
|
|
54
|
+
if (!SCRIPT_HASH_RE.test(hash))
|
|
55
|
+
throw new Error(`invalid inline script hash: ${hash}`);
|
|
56
|
+
}
|
|
57
|
+
return APPLICATION_HTML_CSP.replace("script-src 'self'", `script-src 'self' ${scriptHashes.join(' ')}`);
|
|
58
|
+
}
|
|
26
59
|
/**
|
|
27
60
|
* Active-content types that can script or navigate when navigated to
|
|
28
61
|
* directly get a sandboxed CSP in addition to `nosniff`: SVG (validated at
|
|
@@ -38,6 +71,11 @@ export function contentHeaders(input) {
|
|
|
38
71
|
const isHtml = mimeType === 'text/html';
|
|
39
72
|
const withCharset = mimeType.startsWith('text/') ? `${mimeType}; charset=utf-8` : mimeType;
|
|
40
73
|
const cacheable = !isHtml && input.assetCacheSeconds !== undefined && input.assetCacheSeconds > 0;
|
|
74
|
+
const mode = input.mode ?? 'safe';
|
|
75
|
+
// Workers enforce the script response's policy, not the document's CSP.
|
|
76
|
+
// Cover every application asset so alternate JavaScript MIME types cannot bypass it.
|
|
77
|
+
const csp = mode === 'application' ? applicationCsp(isHtml ? input.scriptHashes : undefined)
|
|
78
|
+
: isHtml ? SAFE_HTML_CSP : undefined;
|
|
41
79
|
return {
|
|
42
80
|
'content-type': withCharset,
|
|
43
81
|
'content-length': String(input.size),
|
|
@@ -46,7 +84,7 @@ export function contentHeaders(input) {
|
|
|
46
84
|
'cache-control': cacheable ? `private, max-age=${input.assetCacheSeconds}` : 'no-store',
|
|
47
85
|
'x-frame-options': 'DENY',
|
|
48
86
|
'referrer-policy': 'no-referrer',
|
|
49
|
-
...(
|
|
87
|
+
...(csp === undefined ? {} : { 'content-security-policy': csp }),
|
|
50
88
|
...(SANDBOXED_MIME_TYPES.has(mimeType) ? { 'content-security-policy': SANDBOX_CSP } : {}),
|
|
51
89
|
};
|
|
52
90
|
}
|
package/dist/mcp-core.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { createRadarKeyDerivation } from './server/command-identity.js';
|
|
|
10
10
|
export type { ArtifactKeyDerivationBinding } from './server/command-identity.js';
|
|
11
11
|
export declare const ARTIFACTS_PROVIDER_ID = "sentropic.artifacts";
|
|
12
12
|
export declare const ARTIFACTS_APP_ID = "sentropic-artifacts";
|
|
13
|
-
export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.
|
|
13
|
+
export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.17";
|
|
14
14
|
export declare const ARTIFACTS_TOOL_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2"];
|
|
15
15
|
export type ArtifactsToolName = (typeof ARTIFACTS_TOOL_NAMES)[number];
|
|
16
16
|
export interface ArtifactsToolDefinition {
|
package/dist/mcp-core.js
CHANGED
|
@@ -6,7 +6,7 @@ export * from './profile/index.js';
|
|
|
6
6
|
export { createRadarKeyDerivation } from './server/command-identity.js';
|
|
7
7
|
export const ARTIFACTS_PROVIDER_ID = 'sentropic.artifacts';
|
|
8
8
|
export const ARTIFACTS_APP_ID = 'sentropic-artifacts';
|
|
9
|
-
export const ARTIFACTS_PROVIDER_VERSION = '0.2.
|
|
9
|
+
export const ARTIFACTS_PROVIDER_VERSION = '0.2.17';
|
|
10
10
|
export const ARTIFACTS_TOOL_NAMES = ARTIFACT_CAPABILITY_NAMES;
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// Byte-stable tool definitions (MCP tool-definition stability rule).
|
package/dist/server/mime.d.ts
CHANGED
|
@@ -20,6 +20,15 @@ export declare const TEXT_MIME_RE: RegExp;
|
|
|
20
20
|
* single-label content origin, and sandbox CSP on SVG/PDF.
|
|
21
21
|
*/
|
|
22
22
|
export declare const SERVER_MIME_CEILING: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* J1.1a — generic extension to MIME map (binding J1.0 relay). `.geojson`
|
|
25
|
+
* serves as `application/json`, `.mjs` as `text/javascript` and `.woff2` as
|
|
26
|
+
* `font/woff2`; `.wasm` and `.pbf` stay mapped as the owner asked. Every
|
|
27
|
+
* value stays inside the server ceiling.
|
|
28
|
+
*/
|
|
29
|
+
export declare const EXTENSION_TO_MIME: Readonly<Record<string, string>>;
|
|
30
|
+
/** MIME type for a manifest path by extension, case-insensitive, undefined off-map. */
|
|
31
|
+
export declare function mimeTypeForPath(path: string): string | undefined;
|
|
23
32
|
/** True when the MIME type is inside the generic ceiling. */
|
|
24
33
|
export declare function isWithinMimeCeiling(mimeType: string): boolean;
|
|
25
34
|
/**
|
package/dist/server/mime.js
CHANGED
|
@@ -26,7 +26,49 @@ export const SERVER_MIME_CEILING = Object.freeze([
|
|
|
26
26
|
'application/pdf',
|
|
27
27
|
'font/woff', 'font/woff2', 'font/ttf', 'font/otf',
|
|
28
28
|
'video/mp4', 'video/webm',
|
|
29
|
+
// J1.1a: bound application assets. Served bytes can never compile without
|
|
30
|
+
// `wasm-unsafe-eval`, which no served policy carries.
|
|
31
|
+
'application/wasm',
|
|
32
|
+
'application/x-protobuf',
|
|
29
33
|
]);
|
|
34
|
+
/**
|
|
35
|
+
* J1.1a — generic extension to MIME map (binding J1.0 relay). `.geojson`
|
|
36
|
+
* serves as `application/json`, `.mjs` as `text/javascript` and `.woff2` as
|
|
37
|
+
* `font/woff2`; `.wasm` and `.pbf` stay mapped as the owner asked. Every
|
|
38
|
+
* value stays inside the server ceiling.
|
|
39
|
+
*/
|
|
40
|
+
export const EXTENSION_TO_MIME = Object.freeze({
|
|
41
|
+
'.html': 'text/html',
|
|
42
|
+
'.js': 'text/javascript',
|
|
43
|
+
'.mjs': 'text/javascript',
|
|
44
|
+
'.css': 'text/css',
|
|
45
|
+
'.json': 'application/json',
|
|
46
|
+
'.geojson': 'application/json',
|
|
47
|
+
'.svg': 'image/svg+xml',
|
|
48
|
+
'.png': 'image/png',
|
|
49
|
+
'.jpg': 'image/jpeg',
|
|
50
|
+
'.jpeg': 'image/jpeg',
|
|
51
|
+
'.gif': 'image/gif',
|
|
52
|
+
'.webp': 'image/webp',
|
|
53
|
+
'.avif': 'image/avif',
|
|
54
|
+
'.ico': 'image/x-icon',
|
|
55
|
+
'.pdf': 'application/pdf',
|
|
56
|
+
'.woff': 'font/woff',
|
|
57
|
+
'.woff2': 'font/woff2',
|
|
58
|
+
'.ttf': 'font/ttf',
|
|
59
|
+
'.otf': 'font/otf',
|
|
60
|
+
'.mp4': 'video/mp4',
|
|
61
|
+
'.webm': 'video/webm',
|
|
62
|
+
'.wasm': 'application/wasm',
|
|
63
|
+
'.pbf': 'application/x-protobuf',
|
|
64
|
+
});
|
|
65
|
+
/** MIME type for a manifest path by extension, case-insensitive, undefined off-map. */
|
|
66
|
+
export function mimeTypeForPath(path) {
|
|
67
|
+
const dot = path.lastIndexOf('.');
|
|
68
|
+
if (dot === -1)
|
|
69
|
+
return undefined;
|
|
70
|
+
return EXTENSION_TO_MIME[path.slice(dot).toLowerCase()];
|
|
71
|
+
}
|
|
30
72
|
/** True when the MIME type is inside the generic ceiling. */
|
|
31
73
|
export function isWithinMimeCeiling(mimeType) {
|
|
32
74
|
return SERVER_MIME_CEILING.includes(mimeType);
|
|
@@ -42,6 +84,7 @@ const MAGIC_BYTES = Object.freeze({
|
|
|
42
84
|
'application/pdf': [[0x25, 0x50, 0x44, 0x46, 0x2d]], // %PDF-
|
|
43
85
|
'font/woff': [[0x77, 0x4f, 0x46, 0x46]], // wOFF
|
|
44
86
|
'font/woff2': [[0x77, 0x4f, 0x46, 0x32]], // wOF2
|
|
87
|
+
'application/wasm': [[0x00, 0x61, 0x73, 0x6d]], // \0asm
|
|
45
88
|
'font/ttf': [[0x00, 0x01, 0x00, 0x00]],
|
|
46
89
|
'font/otf': [[0x4f, 0x54, 0x54, 0x4f]], // OTTO
|
|
47
90
|
'video/mp4': [[0x66, 0x74, 0x79, 0x70]], // ftyp (brand checked loosely: isom/iso2/mp41/mp42/avc1/dash/msdh/m4v...)
|
|
@@ -120,6 +163,10 @@ export function validateFileBytes(mimeType, bytes) {
|
|
|
120
163
|
throw new Error('mp4 magic bytes mismatch');
|
|
121
164
|
return;
|
|
122
165
|
}
|
|
166
|
+
// Opaque protobuf has no magic: any bytes pass (the ceiling allowlist and
|
|
167
|
+
// the serving policy without `wasm-unsafe-eval` stay the guards).
|
|
168
|
+
if (mimeType === 'application/x-protobuf')
|
|
169
|
+
return;
|
|
123
170
|
const magics = MAGIC_BYTES[mimeType];
|
|
124
171
|
if (magics === undefined)
|
|
125
172
|
throw new Error(`no magic-byte rule for ${mimeType}`);
|
|
@@ -50,6 +50,13 @@ export declare function buildUploadPageCookie(value: string, maxAgeSeconds: numb
|
|
|
50
50
|
export declare function parseUploadPageCookie(header: string | undefined): string | undefined;
|
|
51
51
|
/** Page CSP (§A.4): no external assets; S3 origins are host-supplied. */
|
|
52
52
|
export declare function uploadPageCsp(s3Origins: readonly string[]): string;
|
|
53
|
+
/**
|
|
54
|
+
* J1.1a — browser fallback MIME by extension for the upload page, used only
|
|
55
|
+
* when the browser reports no `File.type`: `.geojson` as `application/json`,
|
|
56
|
+
* `.mjs` as `text/javascript`, `.woff2` as `font/woff2`, plus owner-kept
|
|
57
|
+
* `.wasm` and `.pbf`. Rendered into the page as JSON.
|
|
58
|
+
*/
|
|
59
|
+
export declare const BROWSER_EXTENSION_FALLBACK_MIME: Readonly<Record<string, string>>;
|
|
53
60
|
/**
|
|
54
61
|
* Self-contained static upload page (no external assets). Bytes travel
|
|
55
62
|
* browser → S3 via raw PUT (FormData is banned: multipart wrapping changes
|
|
@@ -132,6 +132,21 @@ export function uploadPageCsp(s3Origins) {
|
|
|
132
132
|
'img-src \'self\' blob:', 'font-src \'self\'', `connect-src 'self' ${s3Origins.join(' ')}`,
|
|
133
133
|
'base-uri \'none\'', 'form-action \'none\'', 'frame-ancestors \'none\''].join('; ');
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* J1.1a — browser fallback MIME by extension for the upload page, used only
|
|
137
|
+
* when the browser reports no `File.type`: `.geojson` as `application/json`,
|
|
138
|
+
* `.mjs` as `text/javascript`, `.woff2` as `font/woff2`, plus owner-kept
|
|
139
|
+
* `.wasm` and `.pbf`. Rendered into the page as JSON.
|
|
140
|
+
*/
|
|
141
|
+
export const BROWSER_EXTENSION_FALLBACK_MIME = Object.freeze({
|
|
142
|
+
geojson: 'application/json',
|
|
143
|
+
mjs: 'text/javascript',
|
|
144
|
+
woff2: 'font/woff2',
|
|
145
|
+
wasm: 'application/wasm',
|
|
146
|
+
pbf: 'application/x-protobuf',
|
|
147
|
+
avif: 'image/avif',
|
|
148
|
+
ico: 'image/x-icon',
|
|
149
|
+
});
|
|
135
150
|
/**
|
|
136
151
|
* Self-contained static upload page (no external assets). Bytes travel
|
|
137
152
|
* browser → S3 via raw PUT (FormData is banned: multipart wrapping changes
|
|
@@ -181,7 +196,7 @@ const api = async (path, body, method) => {
|
|
|
181
196
|
if (!response.ok) throw new Error(path + ' failed: ' + response.status);
|
|
182
197
|
return response.json();
|
|
183
198
|
};
|
|
184
|
-
const EXT_TYPES = {
|
|
199
|
+
const EXT_TYPES = ${JSON.stringify(BROWSER_EXTENSION_FALLBACK_MIME)};
|
|
185
200
|
const chunked = (bytes, f) => {
|
|
186
201
|
const view = new Uint8Array(bytes);
|
|
187
202
|
let out = '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/artifacts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "Generic configurable artifacts MCP and artifact service: StorageScope/Artifact/Binding/Release model, canonical manifests, object authorization, idempotent intents (spec-v8 §9).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|