@sentropic/artifacts 0.2.10 → 0.2.13
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 +88 -0
- package/README.md +45 -10
- package/dist/adapters/postgres-management.js +3 -2
- package/dist/adapters/postgres-reader-consent.d.ts +11 -0
- package/dist/adapters/postgres-reader-consent.js +109 -0
- package/dist/adapters/postgres.js +4 -3
- package/dist/adapters/s3-uploads.d.ts +33 -0
- package/dist/adapters/s3-uploads.js +105 -0
- package/dist/content/headers.js +12 -0
- package/dist/http.d.ts +16 -2
- package/dist/http.js +325 -12
- package/dist/mcp-core.d.ts +3 -3
- package/dist/mcp-core.js +51 -4
- package/dist/profile/contracts.d.ts +1 -1
- package/dist/profile/contracts.js +3 -0
- package/dist/profile/index.js +33 -2
- package/dist/profile/radar.js +7 -0
- package/dist/profile/schemas.js +59 -0
- package/dist/profile/validation.d.ts +11 -0
- package/dist/profile/validation.js +71 -6
- package/dist/server/access.d.ts +2 -0
- package/dist/server/command-identity.d.ts +1 -1
- package/dist/server/command-identity.js +5 -3
- package/dist/server/consent.d.ts +65 -0
- package/dist/server/consent.js +42 -0
- package/dist/server/gc.d.ts +17 -0
- package/dist/server/gc.js +22 -0
- package/dist/server/management.d.ts +3 -1
- package/dist/server/management.js +48 -7
- package/dist/server/mime.d.ts +26 -2
- package/dist/server/mime.js +124 -2
- package/dist/server/ports.d.ts +29 -0
- package/dist/server/ports.js +11 -0
- package/dist/server/publication-limits.d.ts +12 -0
- package/dist/server/publication-limits.js +19 -1
- package/dist/server/publication.d.ts +44 -0
- package/dist/server/publication.js +90 -11
- package/dist/server/reader-store.d.ts +58 -0
- package/dist/server/reader-store.js +109 -0
- package/dist/server/templates.js +50 -2
- package/dist/server/uploads.d.ts +154 -18
- package/dist/server/uploads.js +227 -80
- package/migrations/0007_uploads.sql +43 -0
- package/migrations/0008_reader_consent.sql +48 -0
- package/package.json +22 -1
- package/sql/reader-consent.sql +47 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lot 1a — host port for the personal reader store, consent slice
|
|
3
|
+
* (design-merged §1.3, §3.1). One identity, one store: consent rows key on
|
|
4
|
+
* the same `(storageScopeId, readerAccountId, artifactId)` tuple as the
|
|
5
|
+
* personal KV and the `me/` subtree of lots 2–3. Server only: the page can
|
|
6
|
+
* neither read, write nor enumerate consent; it learns only the binary
|
|
7
|
+
* outcome of its own call. Absent port ⇒ closed: hosts without a wired
|
|
8
|
+
* store refuse consent routes with `capability_unavailable`.
|
|
9
|
+
*/
|
|
10
|
+
import { assertConsentScopeId, assertConsentScopeVersion } from './consent.js';
|
|
11
|
+
const sameKey = (row, key) => row.storageScopeId === key.storageScopeId &&
|
|
12
|
+
row.readerAccountId === key.readerAccountId && row.artifactId === key.artifactId &&
|
|
13
|
+
row.scopeId === key.scopeId && row.scopeVersion === key.scopeVersion;
|
|
14
|
+
const byGrantedThenId = (left, right) => left.grantedAt < right.grantedAt ? -1 : left.grantedAt > right.grantedAt ? 1
|
|
15
|
+
: left.consentId < right.consentId ? -1 : left.consentId > right.consentId ? 1 : 0;
|
|
16
|
+
/** In-memory double: single process, synchronous mutation plus audit, no clock (callers stamp). */
|
|
17
|
+
export function createMemoryReaderConsentStore() {
|
|
18
|
+
const rows = new Map();
|
|
19
|
+
const events = [];
|
|
20
|
+
const copy = (row) => ({ ...row });
|
|
21
|
+
return {
|
|
22
|
+
async findLiveConsent(key) {
|
|
23
|
+
for (const row of rows.values()) {
|
|
24
|
+
if (sameKey(row, key) && row.revokedAt === undefined)
|
|
25
|
+
return copy(row);
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
},
|
|
29
|
+
async grantConsent(record) {
|
|
30
|
+
assertConsentScopeId(record.scopeId);
|
|
31
|
+
assertConsentScopeVersion(record.scopeVersion);
|
|
32
|
+
const live = await this.findLiveConsent(record);
|
|
33
|
+
if (live !== undefined)
|
|
34
|
+
return live;
|
|
35
|
+
rows.set(record.consentId, copy(record));
|
|
36
|
+
events.push({ consentId: record.consentId, storageScopeId: record.storageScopeId,
|
|
37
|
+
readerAccountId: record.readerAccountId, artifactId: record.artifactId, scopeId: record.scopeId,
|
|
38
|
+
scopeVersion: record.scopeVersion, action: 'grant', actor: record.readerAccountId,
|
|
39
|
+
surface: 'screen', at: record.grantedAt });
|
|
40
|
+
return copy(record);
|
|
41
|
+
},
|
|
42
|
+
async revokeConsent(key, by, at, audit) {
|
|
43
|
+
const live = await this.findLiveConsent(key);
|
|
44
|
+
if (live === undefined)
|
|
45
|
+
return { changed: false };
|
|
46
|
+
const stored = rows.get(live.consentId);
|
|
47
|
+
stored.revokedAt = at;
|
|
48
|
+
stored.revokedBy = by;
|
|
49
|
+
events.push({ consentId: live.consentId, storageScopeId: key.storageScopeId,
|
|
50
|
+
readerAccountId: key.readerAccountId, artifactId: key.artifactId, scopeId: key.scopeId,
|
|
51
|
+
scopeVersion: key.scopeVersion, action: 'revoke', actor: audit.actor, surface: audit.surface, at });
|
|
52
|
+
return { changed: true, revokedAt: at };
|
|
53
|
+
},
|
|
54
|
+
async revokeAllConsents(key, by, at, audit) {
|
|
55
|
+
let revoked = 0;
|
|
56
|
+
for (const row of [...rows.values()]) {
|
|
57
|
+
if (row.storageScopeId === key.storageScopeId && row.readerAccountId === key.readerAccountId &&
|
|
58
|
+
row.artifactId === key.artifactId && (key.scopeId === undefined || row.scopeId === key.scopeId) &&
|
|
59
|
+
row.revokedAt === undefined) {
|
|
60
|
+
const stored = rows.get(row.consentId);
|
|
61
|
+
stored.revokedAt = at;
|
|
62
|
+
stored.revokedBy = by;
|
|
63
|
+
events.push({ consentId: row.consentId, storageScopeId: row.storageScopeId,
|
|
64
|
+
readerAccountId: row.readerAccountId, artifactId: row.artifactId, scopeId: row.scopeId,
|
|
65
|
+
scopeVersion: row.scopeVersion, action: 'revoke', actor: audit.actor, surface: audit.surface, at });
|
|
66
|
+
revoked += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { changed: revoked > 0, revoked };
|
|
70
|
+
},
|
|
71
|
+
async listConsentsForReader(scope, reader) {
|
|
72
|
+
return [...rows.values()]
|
|
73
|
+
.filter((row) => row.storageScopeId === scope && row.readerAccountId === reader)
|
|
74
|
+
.sort(byGrantedThenId).map(copy);
|
|
75
|
+
},
|
|
76
|
+
async listConsentEvents(scope, artifactId) {
|
|
77
|
+
return events
|
|
78
|
+
.filter((event) => event.storageScopeId === scope && event.artifactId === artifactId)
|
|
79
|
+
.map((event) => ({ ...event }));
|
|
80
|
+
},
|
|
81
|
+
async purgeForArtifact(scope, artifactId) {
|
|
82
|
+
for (const row of [...rows.values()]) {
|
|
83
|
+
if (row.storageScopeId === scope && row.artifactId === artifactId)
|
|
84
|
+
rows.delete(row.consentId);
|
|
85
|
+
}
|
|
86
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
87
|
+
if (events[index].storageScopeId === scope && events[index].artifactId === artifactId)
|
|
88
|
+
events.splice(index, 1);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
async purgeByPrincipal(scope, principalId) {
|
|
92
|
+
let consents = 0;
|
|
93
|
+
for (const row of [...rows.values()]) {
|
|
94
|
+
if (row.storageScopeId === scope && row.readerAccountId === principalId) {
|
|
95
|
+
rows.delete(row.consentId);
|
|
96
|
+
consents += 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
100
|
+
if (events[index].storageScopeId === scope && events[index].readerAccountId === principalId)
|
|
101
|
+
events.splice(index, 1);
|
|
102
|
+
}
|
|
103
|
+
return { consents, kv: 0, docs: 0 };
|
|
104
|
+
},
|
|
105
|
+
async exportByPrincipal(scope, principalId) {
|
|
106
|
+
return { consents: await this.listConsentsForReader(scope, principalId), kv: [], meDocs: [], sharedWriteRefs: [] };
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
package/dist/server/templates.js
CHANGED
|
@@ -62,8 +62,26 @@ const GUIDE_V1 = [
|
|
|
62
62
|
' the same key returns conflict with variant command_conflict.',
|
|
63
63
|
' MCP returns the complete artifacts-outcome/v2 JSON envelope: ok, invocationId,',
|
|
64
64
|
' commitState, replayed/output on success, or typed error details on failure.',
|
|
65
|
-
'- `artifacts_create_upload
|
|
66
|
-
' `
|
|
65
|
+
'- `artifacts_create_upload`: mint a presigned PUT for one staging key',
|
|
66
|
+
' (`artifacts/<scope>/staging/<uploadId>`, URL expiry <= 10 minutes). The',
|
|
67
|
+
' signature binds the content type and the exact declared content length;',
|
|
68
|
+
' the PUT must also carry `x-amz-checksum-sha256` (base64 SHA-256 of the',
|
|
69
|
+
' body) and S3 rejects a mismatching body. Perform the PUT yourself (curl,',
|
|
70
|
+
' SDK, CI) with exactly the returned `requiredHeaders` — no MCP call ever',
|
|
71
|
+
' carries file bytes. Open sessions per principal are quota-limited.',
|
|
72
|
+
'- `artifacts_commit_upload`: declare `{path, mimeType, digest, size}` for a',
|
|
73
|
+
' staged upload; the server re-reads the staged object once and re-verifies',
|
|
74
|
+
' size, SHA-256 digest and MIME (magic bytes / strict UTF-8 / SVG rules)',
|
|
75
|
+
' before promoting it to the digest-addressed blob store and pinning it.',
|
|
76
|
+
' A wrong size or digest is refused with `verification_failed` and nothing',
|
|
77
|
+
' is pinned. Commit creates no release by itself.',
|
|
78
|
+
'- `artifacts_publish_bundle`: one atomic release from inline `files` and/or',
|
|
79
|
+
' `assets` — each asset is `{path, uploadId}` (staged via create_upload +',
|
|
80
|
+
' PUT + commit_upload) or `{path, digest, size, mimeType}` (an already-pinned',
|
|
81
|
+
' blob of the same scope). `expectedCurrentReleaseId` is always required.',
|
|
82
|
+
' The release budget (files / bytes per file / total bytes) applies to the',
|
|
83
|
+
' union; a missing or digest-mismatched asset fails the whole publish and',
|
|
84
|
+
' commits nothing.',
|
|
67
85
|
'- `artifacts_list` / `artifacts_get`: discover (metadata included).',
|
|
68
86
|
'- `artifacts_list_versions`: full release history of one artifact —',
|
|
69
87
|
' per release: id, created at, author, state, whether it is current,',
|
|
@@ -78,6 +96,15 @@ const GUIDE_V1 = [
|
|
|
78
96
|
' history only grows. Purged releases are refused with `release_unavailable`.',
|
|
79
97
|
'- `artifacts_fork`: private independent copy (no ACL copied).',
|
|
80
98
|
'- `artifacts_set_access`: grant/revoke read or source, toggle public.',
|
|
99
|
+
' `principalId` is an opaque `userRef` from `artifacts_lookup_people`, or',
|
|
100
|
+
' a `sentropic:` sentinel: `sentropic:platform` = every approved account,',
|
|
101
|
+
' `sentropic:public` = anonymous (only while the sharing policy allows it).',
|
|
102
|
+
'- `artifacts_lookup_people`: search the host directory by name or email;',
|
|
103
|
+
' returns `userRef`s with masked email hints (approved callers only; ask the',
|
|
104
|
+
' user which entry to use when several match).',
|
|
105
|
+
'- `artifacts_list_access`: current sharing mode, owner and grant list of one',
|
|
106
|
+
' artifact; readers see only their own entry. A share covers all retained',
|
|
107
|
+
' versions of the artifact.',
|
|
81
108
|
'- `artifacts_promote`: explicit version selection (expected-current).',
|
|
82
109
|
'- `artifacts_renew`, `artifacts_delete`, `artifacts_restore`: lifecycle.',
|
|
83
110
|
'',
|
|
@@ -86,6 +113,27 @@ const GUIDE_V1 = [
|
|
|
86
113
|
'right. Pages never receive credentials; reader data access goes through',
|
|
87
114
|
'the host reader profile bound to the artifact and release.',
|
|
88
115
|
'',
|
|
116
|
+
'## Import an existing page',
|
|
117
|
+
'',
|
|
118
|
+
'Importing an already-built page (for example a 9.7 MB dossier of one HTML',
|
|
119
|
+
'file plus 40 screenshots) is a flow, not a single tool — the bytes never',
|
|
120
|
+
'enter the model context:',
|
|
121
|
+
'',
|
|
122
|
+
'1. `artifacts_ensure` to resolve the artifact.',
|
|
123
|
+
'2. Per file: `artifacts_create_upload {artifactId, mimeType, maxSize?}`,',
|
|
124
|
+
' then PUT the local file to the returned `uploadUrl` with exactly the',
|
|
125
|
+
' returned `requiredHeaders` plus `x-amz-checksum-sha256` (base64 SHA-256',
|
|
126
|
+
' of the body), then `artifacts_commit_upload {artifactId, uploadId, path,',
|
|
127
|
+
' mimeType, digest: "sha256:<hex>", size, idempotencyKey}`.',
|
|
128
|
+
'3. One `artifacts_publish_bundle {artifactId, idempotencyKey,',
|
|
129
|
+
' expectedCurrentReleaseId, assets: [{path, uploadId}, ...]}` — assets-only',
|
|
130
|
+
' is valid; put the page itself at `path: "index.html"`. The release is',
|
|
131
|
+
' atomic: all 41 files land in one release, or none do.',
|
|
132
|
+
'',
|
|
133
|
+
'Inline `files` in `artifacts_publish` / `artifacts_publish_bundle` stay',
|
|
134
|
+
'available for small text edits; the upload channel exists precisely so',
|
|
135
|
+
'bulk bytes skip the model.',
|
|
136
|
+
'',
|
|
89
137
|
'Tool definitions are stable: names, descriptions and schemas never change',
|
|
90
138
|
'between versions or profiles, so host permissions (for example claude.ai',
|
|
91
139
|
'"Always allow") survive upgrades. The active profile revision and result',
|
package/dist/server/uploads.d.ts
CHANGED
|
@@ -1,32 +1,168 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const UPLOAD_URL_TTL_SECONDS = 600;
|
|
2
|
+
export declare const UPLOAD_SESSION_TTL_MS: number;
|
|
3
|
+
export type UploadSessionState = 'open' | 'committed' | 'discarded' | 'expired';
|
|
4
|
+
export interface UploadSession {
|
|
5
|
+
readonly uploadId: string;
|
|
6
|
+
readonly artifactId: string;
|
|
7
|
+
readonly storageScopeId: string;
|
|
8
|
+
readonly ownerId: string;
|
|
9
|
+
readonly mimeType: string;
|
|
10
|
+
readonly maxSize: number;
|
|
11
|
+
readonly state: UploadSessionState;
|
|
12
|
+
readonly expiresAt: string;
|
|
13
|
+
readonly createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface StagedFileRecord {
|
|
16
|
+
readonly uploadId: string;
|
|
17
|
+
readonly artifactId: string;
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly mimeType: string;
|
|
20
|
+
readonly digest: string;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly createdAt: string;
|
|
23
|
+
}
|
|
24
|
+
/** Durable session ledger (Postgres in the host via migration 0007; memory double in tests). */
|
|
25
|
+
export interface UploadSessionStore {
|
|
26
|
+
create(session: UploadSession): Promise<void>;
|
|
27
|
+
get(uploadId: string): Promise<UploadSession | undefined>;
|
|
28
|
+
/** Open sessions of one principal in one scope (quota check). */
|
|
29
|
+
countOpen(storageScopeId: string, ownerId: string): Promise<number>;
|
|
30
|
+
/** Sessions still open whose expires_at passed (sweeper input). */
|
|
31
|
+
listExpiredOpen(now: Date): Promise<UploadSession[]>;
|
|
32
|
+
markCommitted(uploadId: string): Promise<void>;
|
|
33
|
+
markExpired(uploadId: string): Promise<void>;
|
|
34
|
+
recordStagedFile(record: StagedFileRecord): Promise<void>;
|
|
35
|
+
getStagedFile(uploadId: string): Promise<StagedFileRecord | undefined>;
|
|
36
|
+
listStagedFiles(artifactId: string): Promise<StagedFileRecord[]>;
|
|
4
37
|
}
|
|
38
|
+
/** Byte store under the staging prefix (S3 in the host; memory double in tests). */
|
|
5
39
|
export interface StagingStore {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
40
|
+
put(key: string, bytes: Uint8Array): Promise<void>;
|
|
41
|
+
get(key: string): Promise<Uint8Array | undefined>;
|
|
42
|
+
delete(key: string): Promise<void>;
|
|
43
|
+
listKeys(prefix: string): Promise<string[]>;
|
|
9
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Presigner port. The signature binds content-type, the EXACT content-length
|
|
47
|
+
* (declared size) and, when known at signing time, x-amz-checksum-sha256;
|
|
48
|
+
* no content-length range exists in a SigV4 presigned PUT (review finding 3).
|
|
49
|
+
*/
|
|
50
|
+
export interface UploadSignerPort {
|
|
51
|
+
signPut(input: {
|
|
52
|
+
key: string;
|
|
53
|
+
contentType: string;
|
|
54
|
+
contentLength: number;
|
|
55
|
+
/** Canonical `sha256:<hex>` digest, when known at signing time. */
|
|
56
|
+
checksumSha256?: string;
|
|
57
|
+
expiresInSeconds: number;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
url: string;
|
|
60
|
+
method: 'PUT';
|
|
61
|
+
/** Headers the client must send with exactly these values. */
|
|
62
|
+
headers: Record<string, string>;
|
|
63
|
+
expiresAt: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
export declare const STAGING_KEY_PATTERN: RegExp;
|
|
67
|
+
/** Staging key of one upload session. */
|
|
68
|
+
export declare function stagingKey(storageScopeId: string, uploadId: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Value of the `x-amz-checksum-sha256` header for a canonical `sha256:<hex>`
|
|
71
|
+
* digest: S3 expects the base64 of the raw digest bytes (no `sha256:` prefix).
|
|
72
|
+
*/
|
|
73
|
+
export declare function checksumHeaderValue(digest: string): string;
|
|
74
|
+
/** Reject anything but a staging key, before any I/O. */
|
|
75
|
+
export declare function assertStagingKey(key: string): void;
|
|
76
|
+
/** Reject empty or escaping staging prefixes before enumeration. */
|
|
77
|
+
export declare function assertStagingPrefix(prefix: string): void;
|
|
10
78
|
/** In-memory StagingStore double for unit tests. */
|
|
11
79
|
export declare function createMemoryStaging(): StagingStore;
|
|
12
|
-
|
|
80
|
+
/** In-memory UploadSessionStore double for unit tests. */
|
|
81
|
+
export declare function createMemoryUploadSessionStore(now?: () => Date): UploadSessionStore;
|
|
82
|
+
/**
|
|
83
|
+
* Memory signer double: records every signed PUT and simulates S3's
|
|
84
|
+
* enforcement of the signed headers (exact content-length equality) and of
|
|
85
|
+
* the checksum header (body must hash to it when present).
|
|
86
|
+
*/
|
|
87
|
+
export declare function createMemoryUploadSigner(): {
|
|
88
|
+
signer: UploadSignerPort;
|
|
89
|
+
signed: {
|
|
90
|
+
key: string;
|
|
91
|
+
contentType: string;
|
|
92
|
+
contentLength: number;
|
|
93
|
+
checksumSha256?: string | undefined;
|
|
94
|
+
expiresAt: string;
|
|
95
|
+
url: string;
|
|
96
|
+
}[];
|
|
97
|
+
/** Simulate the client PUT against "S3": signed headers are enforced exactly. */
|
|
98
|
+
put(signedPut: {
|
|
99
|
+
key: string;
|
|
100
|
+
contentType: string;
|
|
101
|
+
contentLength: number;
|
|
102
|
+
checksumSha256?: string;
|
|
103
|
+
}, bytes: Uint8Array, headers: Record<string, string>): void;
|
|
104
|
+
};
|
|
105
|
+
export interface CreateUploadInput {
|
|
106
|
+
artifactId: string;
|
|
107
|
+
storageScopeId: string;
|
|
108
|
+
ownerId: string;
|
|
13
109
|
mimeType: string;
|
|
110
|
+
/** Declared size; clamped to the host budget. Bound as the exact signed Content-Length. */
|
|
14
111
|
maxSize?: number;
|
|
15
112
|
}
|
|
113
|
+
export interface CreateUploadResult {
|
|
114
|
+
uploadId: string;
|
|
115
|
+
uploadUrl: string;
|
|
116
|
+
method: 'PUT';
|
|
117
|
+
/** Presigned-URL expiry (≤ 10 minutes). */
|
|
118
|
+
expiresAt: string;
|
|
119
|
+
maxSize: number;
|
|
120
|
+
/** Headers the client must send with exactly these values (bound by the signature). */
|
|
121
|
+
requiredHeaders: Record<string, string>;
|
|
122
|
+
/**
|
|
123
|
+
* The PUT must also carry this header with the base64 SHA-256 of the body;
|
|
124
|
+
* S3 validates it against the body (BadDigest on mismatch) and commit
|
|
125
|
+
* re-verifies size and digest server-side.
|
|
126
|
+
*/
|
|
127
|
+
checksumHeader: 'x-amz-checksum-sha256';
|
|
128
|
+
stagingKey: string;
|
|
129
|
+
}
|
|
130
|
+
export interface CommitUploadInput {
|
|
131
|
+
uploadId: string;
|
|
132
|
+
artifactId: string;
|
|
133
|
+
storageScopeId: string;
|
|
134
|
+
ownerId: string;
|
|
135
|
+
path: string;
|
|
136
|
+
mimeType: string;
|
|
137
|
+
digest: string;
|
|
138
|
+
size: number;
|
|
139
|
+
}
|
|
16
140
|
export interface UploadServiceOptions {
|
|
141
|
+
/** Host ceiling for one upload (min of profile releaseFileBytesMax and the server maximum). */
|
|
17
142
|
maxUploadBytes: number;
|
|
143
|
+
maxSessionsPerPrincipal: number;
|
|
144
|
+
now?: () => Date;
|
|
145
|
+
ids?: () => string;
|
|
18
146
|
}
|
|
19
147
|
export interface UploadService {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
148
|
+
create(input: CreateUploadInput): Promise<CreateUploadResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Load the session for commit: must exist, be open, unexpired and bound to
|
|
151
|
+
* the same artifact + scope + owner. Returns the session (caller reads the
|
|
152
|
+
* staged bytes once and verifies size/digest/MIME before pinning).
|
|
153
|
+
*/
|
|
154
|
+
sessionForCommit(input: CommitUploadInput): Promise<UploadSession>;
|
|
155
|
+
/** Verify the staged bytes against the declared size, digest and MIME type. */
|
|
156
|
+
verifyStaged(session: UploadSession, bytes: Uint8Array, expected: {
|
|
157
|
+
digest: string;
|
|
26
158
|
size: number;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
159
|
+
mimeType: string;
|
|
160
|
+
}): void;
|
|
161
|
+
/** Record the staged file and close the session after a successful promotion. */
|
|
162
|
+
completeCommit(session: UploadSession, record: Omit<StagedFileRecord, 'uploadId' | 'artifactId' | 'createdAt'>): Promise<StagedFileRecord>;
|
|
30
163
|
}
|
|
31
|
-
|
|
32
|
-
|
|
164
|
+
export declare function createUploadService(deps: {
|
|
165
|
+
sessions: UploadSessionStore;
|
|
166
|
+
staging: StagingStore;
|
|
167
|
+
signer: UploadSignerPort;
|
|
168
|
+
}, options: UploadServiceOptions): UploadService;
|