@openplanr/protocol 0.8.0 → 0.10.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/README.md +9 -0
- package/package.json +17 -1
- package/registries/commands.json +22 -22
- package/registries/skills.json +136 -58
- package/registry/v1.17.0/commands.json +88 -0
- package/schemas/v1.16.0/artifact-envelope.schema.json +408 -0
- package/schemas/v1.16.0/design-review-bundle.schema.json +590 -0
- package/schemas/v1.17.0/artifact-paste-v2.schema.json +52 -0
- package/schemas/v1.17.0/artifact-room-append-v3.schema.json +159 -0
- package/schemas/v1.17.0/artifact-room-create-v3.schema.json +111 -0
- package/schemas/v1.17.0/artifact-room-descriptor-v3.schema.json +92 -0
- package/schemas/v1.17.0/artifact-room-event-v3.schema.json +130 -0
- package/schemas/v1.17.0/artifact-room-management-v3.schema.json +47 -0
- package/schemas/v1.17.0/artifact-room-read-page-v3.schema.json +308 -0
- package/schemas/v1.17.0/company-resource-manifest.schema.json +128 -0
- package/schemas/v1.17.0/company-resource-upload-prepare.schema.json +164 -0
- package/schemas/v1.17.0/company-resource-upload-receipt.schema.json +63 -0
- package/schemas/v1.17.0/company-resource-upload-status.schema.json +123 -0
- package/schemas/v1.17.0/diagram-authoring-bundle.schema.json +1117 -0
- package/schemas/v1.17.0/diagram-edit-transaction.schema.json +3295 -0
- package/schemas/v1.17.0/diagram-presentation.schema.json +37 -0
- package/schemas/v1.17.0/diagram-review-bundle.schema.json +2439 -0
- package/schemas/v1.17.0/encrypted-resource-manifest.schema.json +131 -0
- package/schemas/v1.17.0/encrypted-upload-commit.schema.json +38 -0
- package/schemas/v1.17.0/encrypted-upload-prepare.schema.json +234 -0
- package/schemas/v1.17.0/encrypted-upload-receipt.schema.json +54 -0
- package/schemas/v1.17.0/encrypted-upload-status.schema.json +129 -0
- package/schemas/v1.17.0/encrypted-workspace-event-v2.schema.json +79 -0
- package/schemas/v1.17.0/encrypted-workspace-v2.schema.json +91 -0
- package/schemas/v1.17.0/enterprise-agent-handoff.schema.json +985 -0
- package/schemas/v1.17.0/enterprise-artifact-revision.schema.json +115 -0
- package/schemas/v1.17.0/enterprise-change-proposal.schema.json +379 -0
- package/schemas/v1.17.0/enterprise-evidence-reference.schema.json +159 -0
- package/schemas/v1.17.0/enterprise-review-thread.schema.json +298 -0
- package/schemas/v1.17.0/enterprise-sync-state.schema.json +189 -0
- package/schemas/v1.17.0/preview-bridge-message.schema.json +197 -0
- package/schemas/v1.17.0/resource-catalog.schema.json +145 -0
- package/schemas/v1.17.0/sharing-crypto-aad.schema.json +36 -0
- package/schemas/v1.17.0/workspace-management-v2.schema.json +45 -0
- package/schemas/v1.17.0/workspace-rotation-v2.schema.json +61 -0
- package/schemas/v1.18.0/runtime-lock.schema.json +122 -0
- package/src/bounded-json-data.d.mts +2 -0
- package/src/bounded-json-data.mjs +56 -0
- package/src/browser-contracts.d.mts +14 -1
- package/src/browser-contracts.mjs +16 -0
- package/src/canonical-json.mjs +17 -16
- package/src/contracts.d.mts +1 -1
- package/src/contracts.mjs +97 -3
- package/src/diagram-authoring-contracts.d.mts +12 -0
- package/src/diagram-authoring-contracts.mjs +174 -1
- package/src/enterprise-contract-validation.d.mts +44 -0
- package/src/enterprise-contract-validation.mjs +279 -0
- package/src/enterprise-contracts.mjs +25 -231
- package/src/enterprise-resource-contracts.d.mts +72 -0
- package/src/enterprise-resource-contracts.mjs +202 -0
- package/src/generated/artifact-envelope-metadata.mjs +769 -0
- package/src/generated/canonical-registries.mjs +158 -80
- package/src/index.d.mts +21 -0
- package/src/index.mjs +23 -0
- package/src/large-object-contracts.d.mts +107 -0
- package/src/large-object-contracts.mjs +473 -0
- package/src/large-object-limits.d.mts +16 -0
- package/src/large-object-limits.mjs +17 -0
- package/src/registries.mjs +1 -0
- package/src/review-experience-contracts.d.mts +1 -0
- package/src/review-experience-contracts.mjs +25 -4
- package/src/sharing-security-contracts.d.mts +63 -0
- package/src/sharing-security-contracts.mjs +403 -0
- package/src/studio-presentation-contracts.d.mts +92 -0
- package/src/studio-presentation-contracts.mjs +287 -0
package/src/index.d.mts
CHANGED
|
@@ -6,8 +6,29 @@ export * from './diagram-authoring-contracts.mjs';
|
|
|
6
6
|
export * from './diagram-contracts.mjs';
|
|
7
7
|
export * from './diagram-review-contracts.mjs';
|
|
8
8
|
export * from './enterprise-contracts.mjs';
|
|
9
|
+
export * from './enterprise-resource-contracts.mjs';
|
|
9
10
|
export * from './errors.mjs';
|
|
10
11
|
export * from './json-schema.mjs';
|
|
12
|
+
export * from './large-object-contracts.mjs';
|
|
11
13
|
export * from './planning-contracts.mjs';
|
|
12
14
|
export * from './registries.mjs';
|
|
15
|
+
export * from './sharing-security-contracts.mjs';
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
assertDiagramPresentation as assertDiagramReviewPresentation,
|
|
19
|
+
assertDiagramReviewBundleV11,
|
|
20
|
+
assertVersionedDiagramAuthoringBundle,
|
|
21
|
+
assertVersionedDiagramEditTransaction,
|
|
22
|
+
assertVersionedDiagramReviewBundle,
|
|
23
|
+
DIAGRAM_AUTHORING_BUNDLE_V11_SCHEMA,
|
|
24
|
+
DIAGRAM_EDIT_TRANSACTION_V11_SCHEMA,
|
|
25
|
+
DIAGRAM_PRESENTATION_SCHEMA,
|
|
26
|
+
DIAGRAM_REVIEW_BUNDLE_V11_SCHEMA,
|
|
27
|
+
legacyDiagramAuthoringProjection,
|
|
28
|
+
normalizeDiagramPresentation,
|
|
29
|
+
validateVersionedDiagramAuthoringBundle,
|
|
30
|
+
validateVersionedDiagramEditTransaction,
|
|
31
|
+
versionedDiagramAuthoringBundleDigest,
|
|
32
|
+
versionedDiagramReviewBundleDigest,
|
|
33
|
+
} from './studio-presentation-contracts.mjs';
|
|
13
34
|
export * from './task-contracts.mjs';
|
package/src/index.mjs
CHANGED
|
@@ -7,6 +7,8 @@ export {
|
|
|
7
7
|
PROTOCOL_V111_CONTRACTS,
|
|
8
8
|
PROTOCOL_V113_CONTRACTS,
|
|
9
9
|
PROTOCOL_V115_CONTRACTS,
|
|
10
|
+
PROTOCOL_V116_CONTRACTS,
|
|
11
|
+
PROTOCOL_V117_CONTRACTS,
|
|
10
12
|
protocolAssetUrl,
|
|
11
13
|
validateDiagramReviewArtifact,
|
|
12
14
|
} from './browser-contracts.mjs';
|
|
@@ -29,6 +31,7 @@ export {
|
|
|
29
31
|
} from './diagram-contracts.mjs';
|
|
30
32
|
export * from './diagram-review-contracts.mjs';
|
|
31
33
|
export * from './enterprise-contracts.mjs';
|
|
34
|
+
export * from './enterprise-resource-contracts.mjs';
|
|
32
35
|
export {
|
|
33
36
|
ARTIFACT_ERROR_CODES,
|
|
34
37
|
PIPELINE_ERROR_CODES,
|
|
@@ -37,6 +40,7 @@ export {
|
|
|
37
40
|
ProtocolError,
|
|
38
41
|
} from './errors.mjs';
|
|
39
42
|
export { validate, validateJson } from './json-schema.mjs';
|
|
43
|
+
export * from './large-object-contracts.mjs';
|
|
40
44
|
export {
|
|
41
45
|
normalizePlanningTask,
|
|
42
46
|
validatePlanningAcceptanceCoverage,
|
|
@@ -53,6 +57,25 @@ export {
|
|
|
53
57
|
routeLegacyTask,
|
|
54
58
|
validateCanonicalRegistries,
|
|
55
59
|
} from './registries.mjs';
|
|
60
|
+
export * from './sharing-security-contracts.mjs';
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
assertDiagramPresentation as assertDiagramReviewPresentation,
|
|
64
|
+
assertDiagramReviewBundleV11,
|
|
65
|
+
assertVersionedDiagramAuthoringBundle,
|
|
66
|
+
assertVersionedDiagramEditTransaction,
|
|
67
|
+
assertVersionedDiagramReviewBundle,
|
|
68
|
+
DIAGRAM_AUTHORING_BUNDLE_V11_SCHEMA,
|
|
69
|
+
DIAGRAM_EDIT_TRANSACTION_V11_SCHEMA,
|
|
70
|
+
DIAGRAM_PRESENTATION_SCHEMA,
|
|
71
|
+
DIAGRAM_REVIEW_BUNDLE_V11_SCHEMA,
|
|
72
|
+
legacyDiagramAuthoringProjection,
|
|
73
|
+
normalizeDiagramPresentation,
|
|
74
|
+
validateVersionedDiagramAuthoringBundle,
|
|
75
|
+
validateVersionedDiagramEditTransaction,
|
|
76
|
+
versionedDiagramAuthoringBundleDigest,
|
|
77
|
+
versionedDiagramReviewBundleDigest,
|
|
78
|
+
} from './studio-presentation-contracts.mjs';
|
|
56
79
|
export {
|
|
57
80
|
assertTaskManifestSemantics,
|
|
58
81
|
assertTaskOutputSemantics,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export { canonicalizeJson } from './canonical-json.mjs';
|
|
2
|
+
export interface ChunkDescriptor {
|
|
3
|
+
index: number;
|
|
4
|
+
byteLength: number;
|
|
5
|
+
iv: string;
|
|
6
|
+
sha256: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ResourceSpan {
|
|
9
|
+
offset: number;
|
|
10
|
+
encodedBytes: number;
|
|
11
|
+
decodedBytes: number;
|
|
12
|
+
codec: 'identity' | 'deflate-raw';
|
|
13
|
+
}
|
|
14
|
+
export interface EncryptedResourceManifest {
|
|
15
|
+
schemaVersion: '2.0.0';
|
|
16
|
+
kind: 'openplanr-encrypted-resource-manifest';
|
|
17
|
+
workspaceId: string;
|
|
18
|
+
revisionId: string;
|
|
19
|
+
epoch: number;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
plaintextBytes: number;
|
|
22
|
+
ciphertextBytes: number;
|
|
23
|
+
catalog: ResourceSpan;
|
|
24
|
+
chunks: ChunkDescriptor[];
|
|
25
|
+
signature: string;
|
|
26
|
+
}
|
|
27
|
+
export interface UploadReceipt {
|
|
28
|
+
schemaVersion: '2.0.0';
|
|
29
|
+
workspaceId: string;
|
|
30
|
+
operationId: string;
|
|
31
|
+
revisionId: string;
|
|
32
|
+
manifestSha256: string;
|
|
33
|
+
status: 'committed';
|
|
34
|
+
version: number;
|
|
35
|
+
committedAt: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UploadStatus {
|
|
38
|
+
schemaVersion: '2.0.0';
|
|
39
|
+
workspaceId: string;
|
|
40
|
+
operationId: string;
|
|
41
|
+
revisionId: string;
|
|
42
|
+
manifestSha256: string;
|
|
43
|
+
status: 'prepared' | 'committed';
|
|
44
|
+
receivedChunks: Omit<ChunkDescriptor, 'iv'>[];
|
|
45
|
+
receipt?: UploadReceipt;
|
|
46
|
+
}
|
|
47
|
+
export { LARGE_OBJECT_LIMITS } from './large-object-limits.mjs';
|
|
48
|
+
export declare const LARGE_OBJECT_VERSION: '2.0.0';
|
|
49
|
+
export declare const LARGE_OBJECT_CHUNK_CONTEXT: string;
|
|
50
|
+
export declare const RESOURCE_HTML_SEGMENT_ENCODING: 'openplanr.html-segments.utf8-v1';
|
|
51
|
+
export declare const ENCRYPTED_RESOURCE_MANIFEST_SCHEMA: Record<string, unknown>;
|
|
52
|
+
export declare const ENCRYPTED_UPLOAD_PREPARE_SCHEMA: Record<string, unknown>;
|
|
53
|
+
export declare const ENCRYPTED_UPLOAD_COMMIT_SCHEMA: Record<string, unknown>;
|
|
54
|
+
export declare const ENCRYPTED_UPLOAD_RECEIPT_SCHEMA: Record<string, unknown>;
|
|
55
|
+
export declare const ENCRYPTED_UPLOAD_STATUS_SCHEMA: Record<string, unknown>;
|
|
56
|
+
export declare const ENCRYPTED_WORKSPACE_V2_SCHEMA: Record<string, unknown>;
|
|
57
|
+
export declare const ENCRYPTED_WORKSPACE_EVENT_V2_SCHEMA: Record<string, unknown>;
|
|
58
|
+
export declare const RESOURCE_CATALOG_SCHEMA: Record<string, unknown>;
|
|
59
|
+
export declare const LARGE_OBJECT_SCHEMAS: Readonly<Record<string, Record<string, unknown>>>;
|
|
60
|
+
/** Inspect bounded, inert JSON data without invoking accessors or copying it. */
|
|
61
|
+
export declare function assertLargeObjectData<T>(value: T): T;
|
|
62
|
+
export declare function assertLargeObjectContract<T>(value: T, kind: string): T;
|
|
63
|
+
|
|
64
|
+
export interface CompanyResourceManifest {
|
|
65
|
+
schemaVersion: '2.0.0';
|
|
66
|
+
kind: 'openplanr-company-resource-manifest';
|
|
67
|
+
organizationId: string;
|
|
68
|
+
projectId: string;
|
|
69
|
+
artifactId: string;
|
|
70
|
+
revisionId: string;
|
|
71
|
+
contentDigest: string;
|
|
72
|
+
contentType: 'application/json';
|
|
73
|
+
byteLength: number;
|
|
74
|
+
decodedBytes: number;
|
|
75
|
+
catalog: ResourceSpan;
|
|
76
|
+
chunks: Omit<ChunkDescriptor, 'iv'>[];
|
|
77
|
+
}
|
|
78
|
+
export declare const COMPANY_RESOURCE_MANIFEST_SCHEMA: Record<string, unknown>;
|
|
79
|
+
export declare const COMPANY_RESOURCE_UPLOAD_PREPARE_SCHEMA: Record<string, unknown>;
|
|
80
|
+
export declare const COMPANY_RESOURCE_UPLOAD_RECEIPT_SCHEMA: Record<string, unknown>;
|
|
81
|
+
export declare const WORKSPACE_MANAGEMENT_V2_SCHEMA: Record<string, unknown>;
|
|
82
|
+
export declare const WORKSPACE_ROTATION_V2_SCHEMA: Record<string, unknown>;
|
|
83
|
+
|
|
84
|
+
export declare const COMPANY_RESOURCE_UPLOAD_STATUS_SCHEMA: Record<string, unknown>;
|
|
85
|
+
export declare const ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA: Record<string, unknown>;
|
|
86
|
+
|
|
87
|
+
export interface EncryptedUploadPrepare {
|
|
88
|
+
schemaVersion: '2.0.0';
|
|
89
|
+
workspaceId: string;
|
|
90
|
+
operationId: string;
|
|
91
|
+
expectedVersion: number;
|
|
92
|
+
epoch: number;
|
|
93
|
+
ownerPublicKey: { kty: 'EC'; crv: 'P-256'; x: string; y: string };
|
|
94
|
+
ownerAuthHash: string;
|
|
95
|
+
reviewerAuthHash: string;
|
|
96
|
+
keyring: { iv: string; ciphertext: string };
|
|
97
|
+
manifest: EncryptedResourceManifest;
|
|
98
|
+
signature: string;
|
|
99
|
+
}
|
|
100
|
+
export interface CompanyResourceUploadPrepare {
|
|
101
|
+
schemaVersion: '2.0.0';
|
|
102
|
+
operationId: string;
|
|
103
|
+
baseRevisionId: string | null;
|
|
104
|
+
manifest: CompanyResourceManifest;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export declare function assertArtifactEnvelopeMetadata<T>(value: T): T;
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/** Additive Protocol 1.17 contracts for bounded, resumable encrypted resources. */
|
|
2
|
+
import { assertLargeObjectData } from './bounded-json-data.mjs';
|
|
3
|
+
import { canonicalizeJson } from './canonical-json.mjs';
|
|
4
|
+
import {
|
|
5
|
+
assertEnterpriseContract,
|
|
6
|
+
ENTERPRISE_ARTIFACT_REVISION_SCHEMA,
|
|
7
|
+
} from './enterprise-contracts.mjs';
|
|
8
|
+
import {
|
|
9
|
+
assertEnterpriseResourceContract,
|
|
10
|
+
ENTERPRISE_RESOURCE_SCHEMAS,
|
|
11
|
+
} from './enterprise-resource-contracts.mjs';
|
|
12
|
+
import { ARTIFACT_ENVELOPE_METADATA_SCHEMAS } from './generated/artifact-envelope-metadata.mjs';
|
|
13
|
+
import { SHARING_SECURITY_SCHEMAS } from './sharing-security-contracts.mjs';
|
|
14
|
+
import {
|
|
15
|
+
DIAGRAM_AUTHORING_BUNDLE_V11_SCHEMA,
|
|
16
|
+
DIAGRAM_EDIT_TRANSACTION_V11_SCHEMA,
|
|
17
|
+
DIAGRAM_PRESENTATION_SCHEMA,
|
|
18
|
+
DIAGRAM_REVIEW_BUNDLE_V11_SCHEMA,
|
|
19
|
+
} from './studio-presentation-contracts.mjs';
|
|
20
|
+
|
|
21
|
+
export { assertLargeObjectData } from './bounded-json-data.mjs';
|
|
22
|
+
export { canonicalizeJson } from './canonical-json.mjs';
|
|
23
|
+
|
|
24
|
+
import { validateJson } from './json-schema.mjs';
|
|
25
|
+
import { LARGE_OBJECT_LIMITS } from './large-object-limits.mjs';
|
|
26
|
+
|
|
27
|
+
export { LARGE_OBJECT_LIMITS } from './large-object-limits.mjs';
|
|
28
|
+
|
|
29
|
+
export const LARGE_OBJECT_VERSION = '2.0.0';
|
|
30
|
+
export const LARGE_OBJECT_CHUNK_CONTEXT = 'openplanr.encrypted-resource.chunk.v2';
|
|
31
|
+
/** A zero-prefixed magic string, count and tagged length spans distinguish raw UTF-8 from legacy JSON. */
|
|
32
|
+
export const RESOURCE_HTML_SEGMENT_ENCODING = 'openplanr.html-segments.utf8-v1';
|
|
33
|
+
const id = { type: 'string', pattern: '^[A-Za-z0-9_-]{22,64}$' };
|
|
34
|
+
const digest = { type: 'string', pattern: '^[a-f0-9]{64}$' };
|
|
35
|
+
const signature = { type: 'string', pattern: '^[A-Za-z0-9_-]{86}$' };
|
|
36
|
+
const integer = (max, min = 0) => ({ type: 'integer', minimum: min, maximum: max });
|
|
37
|
+
const closed = (properties, required = Object.keys(properties)) => ({
|
|
38
|
+
type: 'object',
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
properties,
|
|
41
|
+
required,
|
|
42
|
+
});
|
|
43
|
+
const iso = { type: 'string', format: 'date-time', maxLength: 40 };
|
|
44
|
+
const codec = { enum: ['identity', 'deflate-raw'] };
|
|
45
|
+
const publicKey = closed({
|
|
46
|
+
kty: { const: 'EC' },
|
|
47
|
+
crv: { const: 'P-256' },
|
|
48
|
+
x: { type: 'string', pattern: '^[A-Za-z0-9_-]{43}$' },
|
|
49
|
+
y: { type: 'string', pattern: '^[A-Za-z0-9_-]{43}$' },
|
|
50
|
+
});
|
|
51
|
+
const keyring = closed({
|
|
52
|
+
iv: { type: 'string', pattern: '^[A-Za-z0-9_-]{16}$' },
|
|
53
|
+
ciphertext: { type: 'string', pattern: '^[A-Za-z0-9_-]+$', maxLength: 65536 },
|
|
54
|
+
});
|
|
55
|
+
const chunk = closed({
|
|
56
|
+
index: integer(128),
|
|
57
|
+
byteLength: integer(LARGE_OBJECT_LIMITS.chunkBytes, 17),
|
|
58
|
+
iv: { type: 'string', pattern: '^[A-Za-z0-9_-]{16}$' },
|
|
59
|
+
sha256: digest,
|
|
60
|
+
});
|
|
61
|
+
const catalogSpan = closed({
|
|
62
|
+
offset: integer(LARGE_OBJECT_LIMITS.decodedBytes),
|
|
63
|
+
encodedBytes: integer(LARGE_OBJECT_LIMITS.catalogBytes, 1),
|
|
64
|
+
decodedBytes: integer(LARGE_OBJECT_LIMITS.catalogBytes, 1),
|
|
65
|
+
codec,
|
|
66
|
+
});
|
|
67
|
+
const schema = (name, properties, required) => ({
|
|
68
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
69
|
+
$id: `https://openplanr.dev/schemas/v1.17.0/${name}.schema.json`,
|
|
70
|
+
'x-openplanr-contract': { id: name, version: '1.17.0' },
|
|
71
|
+
...closed(properties, required),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const ENCRYPTED_RESOURCE_MANIFEST_SCHEMA = schema('encrypted-resource-manifest', {
|
|
75
|
+
schemaVersion: { const: LARGE_OBJECT_VERSION },
|
|
76
|
+
kind: { const: 'openplanr-encrypted-resource-manifest' },
|
|
77
|
+
workspaceId: id,
|
|
78
|
+
revisionId: id,
|
|
79
|
+
epoch: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
80
|
+
createdAt: iso,
|
|
81
|
+
plaintextBytes: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
82
|
+
ciphertextBytes: integer(LARGE_OBJECT_LIMITS.ciphertextBytes, 17),
|
|
83
|
+
catalog: catalogSpan,
|
|
84
|
+
chunks: { type: 'array', minItems: 1, maxItems: LARGE_OBJECT_LIMITS.chunks, items: chunk },
|
|
85
|
+
signature,
|
|
86
|
+
});
|
|
87
|
+
export const ENCRYPTED_UPLOAD_PREPARE_SCHEMA = schema('encrypted-upload-prepare', {
|
|
88
|
+
schemaVersion: { const: LARGE_OBJECT_VERSION },
|
|
89
|
+
workspaceId: id,
|
|
90
|
+
operationId: id,
|
|
91
|
+
expectedVersion: integer(Number.MAX_SAFE_INTEGER),
|
|
92
|
+
epoch: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
93
|
+
ownerPublicKey: publicKey,
|
|
94
|
+
ownerAuthHash: digest,
|
|
95
|
+
reviewerAuthHash: digest,
|
|
96
|
+
keyring,
|
|
97
|
+
manifest: ENCRYPTED_RESOURCE_MANIFEST_SCHEMA,
|
|
98
|
+
signature,
|
|
99
|
+
});
|
|
100
|
+
export const ENCRYPTED_UPLOAD_COMMIT_SCHEMA = schema('encrypted-upload-commit', {
|
|
101
|
+
schemaVersion: { const: LARGE_OBJECT_VERSION },
|
|
102
|
+
workspaceId: id,
|
|
103
|
+
operationId: id,
|
|
104
|
+
manifestSha256: digest,
|
|
105
|
+
signature,
|
|
106
|
+
});
|
|
107
|
+
export const ENCRYPTED_UPLOAD_RECEIPT_SCHEMA = schema('encrypted-upload-receipt', {
|
|
108
|
+
schemaVersion: { const: LARGE_OBJECT_VERSION },
|
|
109
|
+
workspaceId: id,
|
|
110
|
+
operationId: id,
|
|
111
|
+
revisionId: id,
|
|
112
|
+
manifestSha256: digest,
|
|
113
|
+
status: { const: 'committed' },
|
|
114
|
+
version: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
115
|
+
committedAt: iso,
|
|
116
|
+
});
|
|
117
|
+
export const ENCRYPTED_UPLOAD_STATUS_SCHEMA = schema(
|
|
118
|
+
'encrypted-upload-status',
|
|
119
|
+
{
|
|
120
|
+
schemaVersion: { const: LARGE_OBJECT_VERSION },
|
|
121
|
+
workspaceId: id,
|
|
122
|
+
operationId: id,
|
|
123
|
+
revisionId: id,
|
|
124
|
+
manifestSha256: digest,
|
|
125
|
+
status: { enum: ['prepared', 'committed'] },
|
|
126
|
+
receivedChunks: {
|
|
127
|
+
type: 'array',
|
|
128
|
+
maxItems: LARGE_OBJECT_LIMITS.chunks,
|
|
129
|
+
items: closed({
|
|
130
|
+
index: integer(128),
|
|
131
|
+
sha256: digest,
|
|
132
|
+
byteLength: integer(LARGE_OBJECT_LIMITS.chunkBytes, 17),
|
|
133
|
+
}),
|
|
134
|
+
},
|
|
135
|
+
receipt: ENCRYPTED_UPLOAD_RECEIPT_SCHEMA,
|
|
136
|
+
},
|
|
137
|
+
[
|
|
138
|
+
'schemaVersion',
|
|
139
|
+
'workspaceId',
|
|
140
|
+
'operationId',
|
|
141
|
+
'revisionId',
|
|
142
|
+
'manifestSha256',
|
|
143
|
+
'status',
|
|
144
|
+
'receivedChunks',
|
|
145
|
+
],
|
|
146
|
+
);
|
|
147
|
+
export const ENCRYPTED_WORKSPACE_V2_SCHEMA = schema('encrypted-workspace-v2', {
|
|
148
|
+
schemaVersion: { const: LARGE_OBJECT_VERSION },
|
|
149
|
+
id,
|
|
150
|
+
version: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
151
|
+
epoch: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
152
|
+
currentRevision: id,
|
|
153
|
+
ownerPublicKey: publicKey,
|
|
154
|
+
keyring,
|
|
155
|
+
commentsPaused: { type: 'boolean' },
|
|
156
|
+
});
|
|
157
|
+
export const ENCRYPTED_WORKSPACE_EVENT_V2_SCHEMA = schema('encrypted-workspace-event-v2', {
|
|
158
|
+
id,
|
|
159
|
+
epoch: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
160
|
+
revisionId: id,
|
|
161
|
+
createdAt: iso,
|
|
162
|
+
iv: { type: 'string', pattern: '^[A-Za-z0-9_-]{16}$' },
|
|
163
|
+
ciphertext: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
pattern: '^[A-Za-z0-9_-]+$',
|
|
166
|
+
maxLength: Math.ceil((LARGE_OBJECT_LIMITS.eventBytes * 4) / 3),
|
|
167
|
+
},
|
|
168
|
+
authorPublicKey: publicKey,
|
|
169
|
+
signature,
|
|
170
|
+
});
|
|
171
|
+
const resource = closed({
|
|
172
|
+
id: { type: 'string', pattern: '^r[0-9]{1,4}$' },
|
|
173
|
+
type: { enum: ['html-segments', 'shared-block', 'asset'] },
|
|
174
|
+
offset: integer(LARGE_OBJECT_LIMITS.decodedBytes),
|
|
175
|
+
encodedBytes: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
176
|
+
decodedBytes: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
177
|
+
codec,
|
|
178
|
+
sha256: digest,
|
|
179
|
+
});
|
|
180
|
+
export const RESOURCE_CATALOG_SCHEMA = schema('resource-catalog', {
|
|
181
|
+
schemaVersion: { const: '1.0.0' },
|
|
182
|
+
kind: { const: 'openplanr-resource-catalog' },
|
|
183
|
+
bundle: { type: 'object' },
|
|
184
|
+
uniqueHtmlBytes: integer(LARGE_OBJECT_LIMITS.uniqueHtmlBytes),
|
|
185
|
+
totalDecodedBytes: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
186
|
+
resources: {
|
|
187
|
+
type: 'array',
|
|
188
|
+
minItems: 1,
|
|
189
|
+
maxItems: LARGE_OBJECT_LIMITS.resources,
|
|
190
|
+
items: resource,
|
|
191
|
+
},
|
|
192
|
+
sources: {
|
|
193
|
+
type: 'array',
|
|
194
|
+
minItems: 1,
|
|
195
|
+
maxItems: LARGE_OBJECT_LIMITS.sources,
|
|
196
|
+
items: closed({
|
|
197
|
+
id: { type: 'string', minLength: 1, maxLength: 128 },
|
|
198
|
+
resourceId: resource.properties.id,
|
|
199
|
+
htmlBytes: integer(LARGE_OBJECT_LIMITS.uniqueHtmlBytes, 1),
|
|
200
|
+
sha256: digest,
|
|
201
|
+
}),
|
|
202
|
+
},
|
|
203
|
+
viewSources: {
|
|
204
|
+
type: 'object',
|
|
205
|
+
maxProperties: LARGE_OBJECT_LIMITS.views,
|
|
206
|
+
additionalProperties: { type: 'string', minLength: 1, maxLength: 128 },
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
// Optional for plain company packs; encrypted review clients always bind the full review basis.
|
|
210
|
+
RESOURCE_CATALOG_SCHEMA.properties.reviewOf = digest;
|
|
211
|
+
const companyId = { type: 'string', pattern: '^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$' };
|
|
212
|
+
const companyScope = { organizationId: companyId, projectId: companyId, artifactId: companyId };
|
|
213
|
+
export const COMPANY_RESOURCE_MANIFEST_SCHEMA = schema('company-resource-manifest', {
|
|
214
|
+
schemaVersion: { const: '2.0.0' },
|
|
215
|
+
kind: { const: 'openplanr-company-resource-manifest' },
|
|
216
|
+
...companyScope,
|
|
217
|
+
revisionId: id,
|
|
218
|
+
contentDigest: { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' },
|
|
219
|
+
contentType: { const: 'application/json' },
|
|
220
|
+
byteLength: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
221
|
+
decodedBytes: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
222
|
+
catalog: catalogSpan,
|
|
223
|
+
chunks: {
|
|
224
|
+
type: 'array',
|
|
225
|
+
minItems: 1,
|
|
226
|
+
maxItems: 128,
|
|
227
|
+
items: closed({
|
|
228
|
+
index: integer(127),
|
|
229
|
+
byteLength: integer(LARGE_OBJECT_LIMITS.chunkBytes, 1),
|
|
230
|
+
sha256: digest,
|
|
231
|
+
}),
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
export const COMPANY_RESOURCE_UPLOAD_PREPARE_SCHEMA = schema('company-resource-upload-prepare', {
|
|
235
|
+
schemaVersion: { const: '2.0.0' },
|
|
236
|
+
operationId: id,
|
|
237
|
+
baseRevisionId: { oneOf: [id, { type: 'null' }] },
|
|
238
|
+
manifest: COMPANY_RESOURCE_MANIFEST_SCHEMA,
|
|
239
|
+
});
|
|
240
|
+
export const COMPANY_RESOURCE_UPLOAD_RECEIPT_SCHEMA = schema('company-resource-upload-receipt', {
|
|
241
|
+
schemaVersion: { const: '2.0.0' },
|
|
242
|
+
...companyScope,
|
|
243
|
+
operationId: id,
|
|
244
|
+
revisionId: id,
|
|
245
|
+
manifestSha256: digest,
|
|
246
|
+
contentDigest: { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' },
|
|
247
|
+
status: { const: 'committed' },
|
|
248
|
+
committedAt: iso,
|
|
249
|
+
});
|
|
250
|
+
export const COMPANY_RESOURCE_UPLOAD_STATUS_SCHEMA = schema(
|
|
251
|
+
'company-resource-upload-status',
|
|
252
|
+
{
|
|
253
|
+
schemaVersion: { const: '2.0.0' },
|
|
254
|
+
operationId: id,
|
|
255
|
+
status: { enum: ['prepared', 'committed'] },
|
|
256
|
+
receivedChunks: {
|
|
257
|
+
type: 'array',
|
|
258
|
+
maxItems: 128,
|
|
259
|
+
items: closed({
|
|
260
|
+
index: integer(127),
|
|
261
|
+
sha256: digest,
|
|
262
|
+
byteLength: integer(LARGE_OBJECT_LIMITS.chunkBytes, 1),
|
|
263
|
+
}),
|
|
264
|
+
},
|
|
265
|
+
receipt: COMPANY_RESOURCE_UPLOAD_RECEIPT_SCHEMA,
|
|
266
|
+
},
|
|
267
|
+
['schemaVersion', 'operationId', 'status', 'receivedChunks'],
|
|
268
|
+
);
|
|
269
|
+
export const ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA = structuredClone(
|
|
270
|
+
ENTERPRISE_ARTIFACT_REVISION_SCHEMA,
|
|
271
|
+
);
|
|
272
|
+
Object.assign(ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA, {
|
|
273
|
+
$id: 'https://openplanr.dev/schemas/v1.17.0/enterprise-artifact-revision.schema.json',
|
|
274
|
+
'x-openplanr-contract': { id: 'enterprise-artifact-revision', version: '1.17.0' },
|
|
275
|
+
});
|
|
276
|
+
Object.assign(ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA.properties, {
|
|
277
|
+
id,
|
|
278
|
+
parentRevisionId: {
|
|
279
|
+
anyOf: [id, structuredClone(ENTERPRISE_ARTIFACT_REVISION_SCHEMA.properties.parentRevisionId)],
|
|
280
|
+
},
|
|
281
|
+
schemaVersion: { const: '1.1.0' },
|
|
282
|
+
protocolVersion: { const: '1.17.0' },
|
|
283
|
+
contentDigest: { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' },
|
|
284
|
+
byteLength: integer(LARGE_OBJECT_LIMITS.decodedBytes, 1),
|
|
285
|
+
contentReference: closed({ transport: { const: 'resources-v2' }, manifestSha256: digest }),
|
|
286
|
+
});
|
|
287
|
+
ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA.required.push('contentReference', 'protocolVersion');
|
|
288
|
+
export const WORKSPACE_MANAGEMENT_V2_SCHEMA = schema('workspace-management-v2', {
|
|
289
|
+
operationId: id,
|
|
290
|
+
expectedVersion: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
291
|
+
epoch: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
292
|
+
action: { enum: ['pause', 'resume', 'revoke', 'delete'] },
|
|
293
|
+
signature,
|
|
294
|
+
});
|
|
295
|
+
export const WORKSPACE_ROTATION_V2_SCHEMA = schema('workspace-rotation-v2', {
|
|
296
|
+
operationId: id,
|
|
297
|
+
expectedVersion: integer(Number.MAX_SAFE_INTEGER, 1),
|
|
298
|
+
epoch: integer(Number.MAX_SAFE_INTEGER, 2),
|
|
299
|
+
reviewerAuthHash: digest,
|
|
300
|
+
keyring,
|
|
301
|
+
signature,
|
|
302
|
+
});
|
|
303
|
+
export const LARGE_OBJECT_SCHEMAS = Object.freeze({
|
|
304
|
+
...ENTERPRISE_RESOURCE_SCHEMAS,
|
|
305
|
+
...SHARING_SECURITY_SCHEMAS,
|
|
306
|
+
'diagram-authoring-bundle': DIAGRAM_AUTHORING_BUNDLE_V11_SCHEMA,
|
|
307
|
+
'diagram-edit-transaction': DIAGRAM_EDIT_TRANSACTION_V11_SCHEMA,
|
|
308
|
+
'diagram-presentation': DIAGRAM_PRESENTATION_SCHEMA,
|
|
309
|
+
'diagram-review-bundle': DIAGRAM_REVIEW_BUNDLE_V11_SCHEMA,
|
|
310
|
+
'encrypted-resource-manifest': ENCRYPTED_RESOURCE_MANIFEST_SCHEMA,
|
|
311
|
+
'encrypted-upload-prepare': ENCRYPTED_UPLOAD_PREPARE_SCHEMA,
|
|
312
|
+
'encrypted-upload-commit': ENCRYPTED_UPLOAD_COMMIT_SCHEMA,
|
|
313
|
+
'encrypted-upload-receipt': ENCRYPTED_UPLOAD_RECEIPT_SCHEMA,
|
|
314
|
+
'encrypted-upload-status': ENCRYPTED_UPLOAD_STATUS_SCHEMA,
|
|
315
|
+
'encrypted-workspace-v2': ENCRYPTED_WORKSPACE_V2_SCHEMA,
|
|
316
|
+
'encrypted-workspace-event-v2': ENCRYPTED_WORKSPACE_EVENT_V2_SCHEMA,
|
|
317
|
+
'resource-catalog': RESOURCE_CATALOG_SCHEMA,
|
|
318
|
+
'company-resource-manifest': COMPANY_RESOURCE_MANIFEST_SCHEMA,
|
|
319
|
+
'company-resource-upload-prepare': COMPANY_RESOURCE_UPLOAD_PREPARE_SCHEMA,
|
|
320
|
+
'company-resource-upload-receipt': COMPANY_RESOURCE_UPLOAD_RECEIPT_SCHEMA,
|
|
321
|
+
'company-resource-upload-status': COMPANY_RESOURCE_UPLOAD_STATUS_SCHEMA,
|
|
322
|
+
'enterprise-artifact-revision': ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA,
|
|
323
|
+
'workspace-management-v2': WORKSPACE_MANAGEMENT_V2_SCHEMA,
|
|
324
|
+
'workspace-rotation-v2': WORKSPACE_ROTATION_V2_SCHEMA,
|
|
325
|
+
});
|
|
326
|
+
export function assertLargeObjectContract(value, kind) {
|
|
327
|
+
assertLargeObjectData(value);
|
|
328
|
+
const selected = Object.hasOwn(LARGE_OBJECT_SCHEMAS, kind) ? LARGE_OBJECT_SCHEMAS[kind] : null;
|
|
329
|
+
if (!selected) throw new TypeError('Unknown large object contract.');
|
|
330
|
+
const errors = validateJson(value, selected);
|
|
331
|
+
if (errors.length) throw new TypeError(`Invalid ${kind}: ${errors[0].path} ${errors[0].detail}`);
|
|
332
|
+
const byteLength = new TextEncoder().encode(canonicalizeJson(value)).byteLength;
|
|
333
|
+
if (Object.hasOwn(ENTERPRISE_RESOURCE_SCHEMAS, kind)) {
|
|
334
|
+
return assertEnterpriseResourceContract(value, kind);
|
|
335
|
+
} else if (kind === 'enterprise-artifact-revision') {
|
|
336
|
+
assertEnterpriseContract(value, ENTERPRISE_ARTIFACT_REVISION_V11_SCHEMA);
|
|
337
|
+
if (value.id === value.parentRevisionId)
|
|
338
|
+
throw new TypeError('A revision cannot be its own parent.');
|
|
339
|
+
} else if (kind === 'encrypted-resource-manifest') {
|
|
340
|
+
if (byteLength > LARGE_OBJECT_LIMITS.manifestBytes)
|
|
341
|
+
throw new RangeError('Manifest exceeds its byte limit.');
|
|
342
|
+
let cipher = 0,
|
|
343
|
+
plain = 0;
|
|
344
|
+
const ivs = new Set();
|
|
345
|
+
for (const [index, part] of value.chunks.entries()) {
|
|
346
|
+
if (
|
|
347
|
+
part.index !== index ||
|
|
348
|
+
ivs.has(part.iv) ||
|
|
349
|
+
(index < value.chunks.length - 1 && part.byteLength !== LARGE_OBJECT_LIMITS.chunkBytes)
|
|
350
|
+
)
|
|
351
|
+
throw new TypeError('Invalid chunk sequence or repeated IV.');
|
|
352
|
+
ivs.add(part.iv);
|
|
353
|
+
cipher += part.byteLength;
|
|
354
|
+
plain += part.byteLength - 16;
|
|
355
|
+
}
|
|
356
|
+
if (
|
|
357
|
+
cipher !== value.ciphertextBytes ||
|
|
358
|
+
plain !== value.plaintextBytes ||
|
|
359
|
+
value.catalog.offset + value.catalog.encodedBytes !== plain ||
|
|
360
|
+
value.catalog.encodedBytes > value.catalog.decodedBytes
|
|
361
|
+
)
|
|
362
|
+
throw new TypeError('Invalid manifest byte accounting or catalog span.');
|
|
363
|
+
} else if (kind === 'company-resource-manifest') {
|
|
364
|
+
if (byteLength > LARGE_OBJECT_LIMITS.manifestBytes)
|
|
365
|
+
throw new RangeError('Company manifest exceeds its byte limit.');
|
|
366
|
+
let total = 0;
|
|
367
|
+
for (const [index, part] of value.chunks.entries()) {
|
|
368
|
+
if (
|
|
369
|
+
part.index !== index ||
|
|
370
|
+
(index < value.chunks.length - 1 && part.byteLength !== LARGE_OBJECT_LIMITS.chunkBytes)
|
|
371
|
+
)
|
|
372
|
+
throw new TypeError('Invalid company chunk sequence.');
|
|
373
|
+
total += part.byteLength;
|
|
374
|
+
}
|
|
375
|
+
if (
|
|
376
|
+
total !== value.byteLength ||
|
|
377
|
+
value.catalog.offset + value.catalog.encodedBytes !== total ||
|
|
378
|
+
value.byteLength > value.decodedBytes ||
|
|
379
|
+
value.catalog.encodedBytes > value.catalog.decodedBytes
|
|
380
|
+
)
|
|
381
|
+
throw new TypeError('Company resource byte accounting differs.');
|
|
382
|
+
} else if (kind === 'company-resource-upload-status') {
|
|
383
|
+
if (
|
|
384
|
+
new Set(value.receivedChunks.map((part) => part.index)).size !==
|
|
385
|
+
value.receivedChunks.length ||
|
|
386
|
+
(value.status === 'committed') !== Boolean(value.receipt) ||
|
|
387
|
+
(value.receipt && value.receipt.operationId !== value.operationId)
|
|
388
|
+
)
|
|
389
|
+
throw new TypeError('Company upload status differs.');
|
|
390
|
+
} else if (kind === 'company-resource-upload-prepare') {
|
|
391
|
+
assertLargeObjectContract(value.manifest, 'company-resource-manifest');
|
|
392
|
+
} else if (kind === 'encrypted-upload-prepare') {
|
|
393
|
+
assertLargeObjectContract(value.manifest, 'encrypted-resource-manifest');
|
|
394
|
+
if (value.workspaceId !== value.manifest.workspaceId || value.epoch !== value.manifest.epoch)
|
|
395
|
+
throw new TypeError('Upload and manifest identity differ.');
|
|
396
|
+
} else if (kind === 'encrypted-upload-status') {
|
|
397
|
+
if (
|
|
398
|
+
new Set(value.receivedChunks.map((part) => part.index)).size !==
|
|
399
|
+
value.receivedChunks.length ||
|
|
400
|
+
(value.status === 'committed') !== Boolean(value.receipt)
|
|
401
|
+
)
|
|
402
|
+
throw new TypeError('Invalid upload status.');
|
|
403
|
+
if (
|
|
404
|
+
value.receipt &&
|
|
405
|
+
['workspaceId', 'operationId', 'revisionId', 'manifestSha256'].some(
|
|
406
|
+
(key) => value[key] !== value.receipt[key],
|
|
407
|
+
)
|
|
408
|
+
)
|
|
409
|
+
throw new TypeError('Upload receipt identity differs.');
|
|
410
|
+
} else if (kind === 'resource-catalog') {
|
|
411
|
+
if (byteLength > LARGE_OBJECT_LIMITS.catalogBytes)
|
|
412
|
+
throw new RangeError('Catalog exceeds its byte limit.');
|
|
413
|
+
let nodes = 0;
|
|
414
|
+
const pending = [[value.bundle, 0]];
|
|
415
|
+
for (let next = pending.pop(); next; next = pending.pop()) {
|
|
416
|
+
const [item, depth] = next;
|
|
417
|
+
if (++nodes > 250000 || depth > 40)
|
|
418
|
+
throw new RangeError('Catalog metadata complexity exceeds its limit.');
|
|
419
|
+
if (item && typeof item === 'object')
|
|
420
|
+
for (const child of Object.values(item)) pending.push([child, depth + 1]);
|
|
421
|
+
}
|
|
422
|
+
const resources = new Map();
|
|
423
|
+
let offset = 0,
|
|
424
|
+
decoded = 0;
|
|
425
|
+
for (const part of value.resources) {
|
|
426
|
+
if (resources.has(part.id) || part.offset !== offset || part.encodedBytes > part.decodedBytes)
|
|
427
|
+
throw new TypeError('Invalid resource sequence.');
|
|
428
|
+
resources.set(part.id, part);
|
|
429
|
+
offset += part.encodedBytes;
|
|
430
|
+
decoded += part.decodedBytes;
|
|
431
|
+
}
|
|
432
|
+
const sources = new Set();
|
|
433
|
+
let html = 0;
|
|
434
|
+
for (const source of value.sources) {
|
|
435
|
+
if (sources.has(source.id) || resources.get(source.resourceId)?.type !== 'html-segments')
|
|
436
|
+
throw new TypeError('Invalid source resource.');
|
|
437
|
+
sources.add(source.id);
|
|
438
|
+
html += source.htmlBytes;
|
|
439
|
+
}
|
|
440
|
+
if (
|
|
441
|
+
html !== value.uniqueHtmlBytes ||
|
|
442
|
+
decoded > value.totalDecodedBytes ||
|
|
443
|
+
Object.keys(value.viewSources).length < 1 ||
|
|
444
|
+
Object.keys(value.viewSources).length > LARGE_OBJECT_LIMITS.views ||
|
|
445
|
+
Object.values(value.viewSources).some((id) => !sources.has(id))
|
|
446
|
+
)
|
|
447
|
+
throw new TypeError('Invalid catalog accounting or source references.');
|
|
448
|
+
}
|
|
449
|
+
return value;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// These are metadata projections of immutable published contracts. HTML is validated
|
|
453
|
+
// separately after selected resources pass authenticated digest and size checks.
|
|
454
|
+
export function assertArtifactEnvelopeMetadata(value) {
|
|
455
|
+
assertLargeObjectData(value);
|
|
456
|
+
const shared = value?.schemaVersion === '1.1.0';
|
|
457
|
+
const errors = validateJson(value, ARTIFACT_ENVELOPE_METADATA_SCHEMAS[shared ? 1 : 0]);
|
|
458
|
+
if (errors.length) throw new TypeError('Invalid artifact envelope metadata.');
|
|
459
|
+
const ids = new Set(value.artifacts.map((item) => item.id));
|
|
460
|
+
if (ids.size !== value.artifacts.length || !ids.has(value.viewer.activeArtifactId))
|
|
461
|
+
throw new TypeError('Invalid metadata view identity.');
|
|
462
|
+
if (shared) {
|
|
463
|
+
const sources = new Set(value.sources.map((item) => item.id));
|
|
464
|
+
const used = new Set(value.artifacts.map((item) => item.sourceId));
|
|
465
|
+
if (
|
|
466
|
+
sources.size !== value.sources.length ||
|
|
467
|
+
used.size !== sources.size ||
|
|
468
|
+
[...used].some((id) => !sources.has(id))
|
|
469
|
+
)
|
|
470
|
+
throw new TypeError('Invalid metadata source identity.');
|
|
471
|
+
}
|
|
472
|
+
return value;
|
|
473
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const LARGE_OBJECT_LIMITS: Readonly<{
|
|
2
|
+
uniqueHtmlBytes: number;
|
|
3
|
+
decodedBytes: number;
|
|
4
|
+
catalogBytes: number;
|
|
5
|
+
manifestBytes: number;
|
|
6
|
+
chunkBytes: number;
|
|
7
|
+
chunkPlaintextBytes: number;
|
|
8
|
+
chunks: number;
|
|
9
|
+
ciphertextBytes: number;
|
|
10
|
+
sources: number;
|
|
11
|
+
views: number;
|
|
12
|
+
resources: number;
|
|
13
|
+
eventBytes: number;
|
|
14
|
+
eventPageBytes: number;
|
|
15
|
+
eventPageCount: number;
|
|
16
|
+
}>;
|