@openplanr/protocol 0.8.0 → 0.9.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 +11 -11
- package/registries/skills.json +86 -8
- 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/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 +90 -2
- 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 +97 -19
- 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
|
@@ -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
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Canonical resource limits; dependency-free for generated CLI projections. */
|
|
2
|
+
export const LARGE_OBJECT_LIMITS = Object.freeze({
|
|
3
|
+
uniqueHtmlBytes: 100 * 1024 * 1024,
|
|
4
|
+
decodedBytes: 128 * 1024 * 1024,
|
|
5
|
+
catalogBytes: 8 * 1024 * 1024,
|
|
6
|
+
manifestBytes: 64 * 1024,
|
|
7
|
+
chunkBytes: 1024 * 1024,
|
|
8
|
+
chunkPlaintextBytes: 1024 * 1024 - 16,
|
|
9
|
+
chunks: 129,
|
|
10
|
+
ciphertextBytes: 128 * 1024 * 1024 + 129 * 16,
|
|
11
|
+
sources: 256,
|
|
12
|
+
views: 4096,
|
|
13
|
+
resources: 1024,
|
|
14
|
+
eventBytes: 256 * 1024,
|
|
15
|
+
eventPageBytes: 1024 * 1024,
|
|
16
|
+
eventPageCount: 100,
|
|
17
|
+
});
|
package/src/registries.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const DESIGN_REVIEW_CONTEXT_SCHEMA: Readonly<Record<string, unknown>>;
|
|
2
2
|
export declare const DESIGN_FINGERPRINT_SCHEMA: Readonly<Record<string, unknown>>;
|
|
3
|
+
export declare const DESIGN_REVIEW_BUNDLE_V12_SCHEMA: Readonly<Record<string, unknown>>;
|
|
3
4
|
export declare const DESIGN_REVIEW_BUNDLE_V11_SCHEMA: Readonly<Record<string, unknown>>;
|
|
4
5
|
export declare const DESIGN_HANDOFF_CONTENT_SCHEMA: Readonly<Record<string, unknown>>;
|
|
5
6
|
export declare const DESIGN_HANDOFF_SCHEMA: Readonly<Record<string, unknown>>;
|
|
@@ -84,6 +84,25 @@ bundleV11.required.push('reviewContext', 'contextDigest', 'fingerprints');
|
|
|
84
84
|
/** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_V11_SCHEMA} */
|
|
85
85
|
export const DESIGN_REVIEW_BUNDLE_V11_SCHEMA = bundleV11;
|
|
86
86
|
|
|
87
|
+
const bundleV12 = /** @type {MutableSchema} */ (structuredClone(DESIGN_REVIEW_BUNDLE_V11_SCHEMA));
|
|
88
|
+
bundleV12.$id = 'https://openplanr.dev/schemas/v1.16.0/design-review-bundle.schema.json';
|
|
89
|
+
bundleV12['x-openplanr-contract'] = { id: 'design-review-bundle', version: '1.16.0' };
|
|
90
|
+
Object.assign(bundleV12.properties, {
|
|
91
|
+
schemaVersion: { const: '1.2.0' },
|
|
92
|
+
envelope: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
required: ['schemaVersion', 'sources', 'artifacts', 'viewer'],
|
|
95
|
+
properties: { schemaVersion: { const: '1.1.0' } },
|
|
96
|
+
},
|
|
97
|
+
entries: {
|
|
98
|
+
.../** @type {Record<string, unknown>} */ (bundleV12.properties.entries),
|
|
99
|
+
maxItems: 4096,
|
|
100
|
+
},
|
|
101
|
+
fingerprints: list(DESIGN_FINGERPRINT_SCHEMA, 4096),
|
|
102
|
+
});
|
|
103
|
+
/** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_V12_SCHEMA} */
|
|
104
|
+
export const DESIGN_REVIEW_BUNDLE_V12_SCHEMA = bundleV12;
|
|
105
|
+
|
|
87
106
|
const item = closed(
|
|
88
107
|
{
|
|
89
108
|
pinId: id,
|
|
@@ -218,11 +237,13 @@ export function assertDesignReviewMetadata(value) {
|
|
|
218
237
|
export function assertDesignReviewBundle(value) {
|
|
219
238
|
assertReviewExperience(
|
|
220
239
|
value,
|
|
221
|
-
value?.schemaVersion === '1.
|
|
222
|
-
?
|
|
223
|
-
:
|
|
240
|
+
value?.schemaVersion === '1.2.0'
|
|
241
|
+
? DESIGN_REVIEW_BUNDLE_V12_SCHEMA
|
|
242
|
+
: value?.schemaVersion === '1.1.0'
|
|
243
|
+
? DESIGN_REVIEW_BUNDLE_V11_SCHEMA
|
|
244
|
+
: DESIGN_REVIEW_BUNDLE_SCHEMA,
|
|
224
245
|
);
|
|
225
|
-
if (
|
|
246
|
+
if (['1.1.0', '1.2.0'].includes(value.schemaVersion)) {
|
|
226
247
|
if (
|
|
227
248
|
value.reviewContext.designId !== value.design.id ||
|
|
228
249
|
value.contextDigest !== sha256Hex(canonicalizeJson(value.reviewContext))
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export declare const ROOM_V3_VERSION: '3.0.0';
|
|
2
|
+
export declare const ROOM_V3_API: '/api/v2/rooms';
|
|
3
|
+
export declare const ROOM_V3_GENESIS_HASH: string;
|
|
4
|
+
export declare const ROOM_V3_CAPABILITIES: Readonly<{
|
|
5
|
+
read: 'room-read';
|
|
6
|
+
reviewer: 'reviewer-write';
|
|
7
|
+
owner: 'owner-verdict';
|
|
8
|
+
management: 'room-management';
|
|
9
|
+
}>;
|
|
10
|
+
export declare const SHARING_CRYPTO_VERSION: '2.0.0';
|
|
11
|
+
export declare const SHARING_CRYPTO_CONTEXT: string;
|
|
12
|
+
export declare const ROOM_V3_DESCRIPTOR_SCHEMA: Record<string, unknown>;
|
|
13
|
+
export declare const ROOM_V3_CREATE_SCHEMA: Record<string, unknown>;
|
|
14
|
+
export declare const ROOM_V3_EVENT_SCHEMA: Record<string, unknown>;
|
|
15
|
+
export declare const ROOM_V3_MANAGEMENT_SCHEMA: Record<string, unknown>;
|
|
16
|
+
export declare const PASTE_V2_SCHEMA: Record<string, unknown>;
|
|
17
|
+
export declare const SHARING_CRYPTO_AAD_SCHEMA: Record<string, unknown>;
|
|
18
|
+
export declare const SHARING_SECURITY_SCHEMAS: Readonly<Record<string, Record<string, unknown>>>;
|
|
19
|
+
export declare function assertSharingSecurityContract<T>(value: T, kind: string): T;
|
|
20
|
+
export declare function roomV3SignatureBytes(
|
|
21
|
+
type: 'create' | 'event' | 'management',
|
|
22
|
+
value: Record<string, unknown>,
|
|
23
|
+
): Uint8Array;
|
|
24
|
+
export declare function verifyRoomV3Signature(
|
|
25
|
+
type: 'create' | 'event' | 'management',
|
|
26
|
+
value: Record<string, unknown>,
|
|
27
|
+
publicKey: { algorithm: string; encoding: string; keyId: string; value: string },
|
|
28
|
+
options?: { crypto?: Crypto },
|
|
29
|
+
): Promise<boolean>;
|
|
30
|
+
|
|
31
|
+
export type PreviewBridgeMessage = { schemaVersion: '1.0.0'; channel: string; viewId: string } & (
|
|
32
|
+
| { type: 'ready' }
|
|
33
|
+
| { type: 'navigate'; screenId: string }
|
|
34
|
+
| { type: 'select'; elementId: string }
|
|
35
|
+
| {
|
|
36
|
+
type: 'state';
|
|
37
|
+
state: { session: Record<string, unknown>; forms: Record<string, Record<string, unknown>> };
|
|
38
|
+
}
|
|
39
|
+
| { type: 'failed' }
|
|
40
|
+
);
|
|
41
|
+
export declare const PREVIEW_BRIDGE_MESSAGE_SCHEMA: Record<string, unknown>;
|
|
42
|
+
export declare function assertPreviewBridgeMessage<T>(value: T): T;
|
|
43
|
+
|
|
44
|
+
export declare const ROOM_V3_READ_LIMITS: Readonly<{
|
|
45
|
+
pageBytes: number;
|
|
46
|
+
eventPageBytes: number;
|
|
47
|
+
eventPageCount: number;
|
|
48
|
+
aggregateBytes: number;
|
|
49
|
+
projectionBytes: number;
|
|
50
|
+
retainedEvents: number;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const ROOM_V3_READ_PAGE_SCHEMA: Record<string, unknown>;
|
|
53
|
+
|
|
54
|
+
export declare const ROOM_V3_APPEND_SCHEMA: Record<string, unknown>;
|
|
55
|
+
|
|
56
|
+
export interface RoomV3ManagementRequest {
|
|
57
|
+
schemaVersion: '3.0.0';
|
|
58
|
+
roomId: string;
|
|
59
|
+
operation: 'pause' | 'resume' | 'delete';
|
|
60
|
+
operationId: string;
|
|
61
|
+
expectedGeneration: number;
|
|
62
|
+
signature: string;
|
|
63
|
+
}
|