@mdbase-dev/connect-protocol 0.1.0-beta.21 → 0.1.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect-problems.generated.d.ts +1067 -0
- package/dist/connect-problems.generated.js +364 -0
- package/dist/files.d.ts +253 -0
- package/dist/files.js +417 -0
- package/dist/index.d.ts +97 -16
- package/dist/index.js +6 -1
- package/package.json +2 -2
- package/schemas/catalog.json +3 -0
- package/schemas/connect-problem.v1.schema.json +3893 -0
- package/schemas/connect-problems.v1.catalog.json +238 -0
- package/schemas/connect-protocol.v1.schema.json +15 -26
- package/schemas/encrypted-relay.v1.schema.json +3 -11
- package/schemas/files.v1.schema.json +502 -0
- package/schemas/mdbase-app.schema.json +48 -0
- package/schemas/sync.v1.schema.json +189 -4
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
// Generated by scripts/generate-connect-problems.mjs. Do not edit directly.
|
|
2
|
+
export const CONNECT_PROBLEM_VERSION = 1;
|
|
3
|
+
export const CONNECT_PROBLEM_CATALOG = {
|
|
4
|
+
"access_denied": { category: "authorization", recovery: "reauthorize" },
|
|
5
|
+
"access_paused": { category: "availability", recovery: "resume_connector_access" },
|
|
6
|
+
"approval_window_blocked": { category: "authorization", recovery: "reauthorize" },
|
|
7
|
+
"authority_authorization_changed": { category: "authorization", recovery: "reauthorize" },
|
|
8
|
+
"authorization_cancelled": { category: "cancellation", recovery: "none" },
|
|
9
|
+
"authorization_expired": { category: "authorization", recovery: "reauthorize" },
|
|
10
|
+
"browser_required": { category: "compatibility", recovery: "none" },
|
|
11
|
+
"callback_url_required": { category: "validation", recovery: "fix_request" },
|
|
12
|
+
"change_cursor_reset": { category: "conflict", recovery: "refresh" },
|
|
13
|
+
"collection_access_denied": { category: "authorization", recovery: "reauthorize" },
|
|
14
|
+
"collection_configuration_invalid": { category: "validation", recovery: "repair_collection" },
|
|
15
|
+
"collection_contracts_missing": { category: "compatibility", recovery: "choose_collection" },
|
|
16
|
+
"collection_incompatible": { category: "compatibility", recovery: "choose_collection" },
|
|
17
|
+
"collection_invalid": { category: "validation", recovery: "repair_collection" },
|
|
18
|
+
"collection_kind_unsupported": { category: "compatibility", recovery: "choose_collection" },
|
|
19
|
+
"collection_mismatch": { category: "selection", recovery: "choose_collection" },
|
|
20
|
+
"collection_not_found": { category: "selection", recovery: "choose_collection" },
|
|
21
|
+
"collection_not_ready": { category: "selection", recovery: "choose_collection" },
|
|
22
|
+
"collection_not_selected": { category: "selection", recovery: "choose_collection" },
|
|
23
|
+
"collection_type_registry_invalid": { category: "validation", recovery: "repair_collection" },
|
|
24
|
+
"collection_version_unsupported": { category: "compatibility", recovery: "upgrade_collection" },
|
|
25
|
+
"concurrent_modification": { category: "conflict", recovery: "refresh" },
|
|
26
|
+
"connector_identity_changed": { category: "integrity", recovery: "reauthorize" },
|
|
27
|
+
"connector_offline": { category: "availability", recovery: "retry" },
|
|
28
|
+
"connector_upgrade_required": { category: "compatibility", recovery: "upgrade_connector" },
|
|
29
|
+
"device_authorization_failed": { category: "authorization", recovery: "reauthorize" },
|
|
30
|
+
"direct_operation_rejected": { category: "authorization", recovery: "reauthorize" },
|
|
31
|
+
"discovery_failed": { category: "availability", recovery: "retry" },
|
|
32
|
+
"encrypted_relay_rejected": { category: "authorization", recovery: "reauthorize" },
|
|
33
|
+
"encryption_required": { category: "authorization", recovery: "reauthorize" },
|
|
34
|
+
"expired_token": { category: "authorization", recovery: "reauthorize" },
|
|
35
|
+
"file_changed_during_move": { category: "conflict", recovery: "refresh" },
|
|
36
|
+
"file_changed_during_read": { category: "conflict", recovery: "refresh" },
|
|
37
|
+
"file_move_failed": { category: "internal", recovery: "contact_support" },
|
|
38
|
+
"file_mutation_conflict": { category: "conflict", recovery: "resolve_conflict" },
|
|
39
|
+
"file_not_found": { category: "conflict", recovery: "refresh" },
|
|
40
|
+
"file_source_mismatch": { category: "conflict", recovery: "refresh" },
|
|
41
|
+
"file_upload_incomplete": { category: "conflict", recovery: "retry" },
|
|
42
|
+
"hosted_provider_unavailable": { category: "availability", recovery: "retry" },
|
|
43
|
+
"insufficient_access": { category: "authorization", recovery: "reauthorize" },
|
|
44
|
+
"invalid_application_manifest": { category: "validation", recovery: "fix_request" },
|
|
45
|
+
"invalid_callback": { category: "validation", recovery: "fix_request" },
|
|
46
|
+
"invalid_device_authorization_response": { category: "integrity", recovery: "contact_support" },
|
|
47
|
+
"invalid_encrypted_response": { category: "integrity", recovery: "contact_support" },
|
|
48
|
+
"invalid_loopback_url": { category: "validation", recovery: "fix_request" },
|
|
49
|
+
"invalid_mutation_id": { category: "validation", recovery: "fix_request" },
|
|
50
|
+
"invalid_operation_response": { category: "integrity", recovery: "contact_support" },
|
|
51
|
+
"invalid_path": { category: "validation", recovery: "fix_request" },
|
|
52
|
+
"invalid_preflight": { category: "conflict", recovery: "refresh" },
|
|
53
|
+
"invalid_push_payload": { category: "validation", recovery: "fix_request" },
|
|
54
|
+
"invalid_push_subscription": { category: "validation", recovery: "fix_request" },
|
|
55
|
+
"invalid_request": { category: "validation", recovery: "fix_request" },
|
|
56
|
+
"invalid_token_response": { category: "integrity", recovery: "contact_support" },
|
|
57
|
+
"managed_fcm_not_declared": { category: "compatibility", recovery: "fix_request" },
|
|
58
|
+
"manifest_load_failed": { category: "availability", recovery: "retry" },
|
|
59
|
+
"manifest_required": { category: "validation", recovery: "fix_request" },
|
|
60
|
+
"missing_grant_key": { category: "authorization", recovery: "reauthorize" },
|
|
61
|
+
"no_pending_mutation": { category: "conflict", recovery: "refresh" },
|
|
62
|
+
"not_authorized": { category: "authorization", recovery: "reauthorize" },
|
|
63
|
+
"not_remote_authority": { category: "compatibility", recovery: "choose_collection" },
|
|
64
|
+
"notification_criterion_not_declared": { category: "validation", recovery: "fix_request" },
|
|
65
|
+
"notification_reauthorization_required": { category: "authorization", recovery: "reauthorize" },
|
|
66
|
+
"notification_registration_failed": { category: "availability", recovery: "retry" },
|
|
67
|
+
"notification_unregistration_failed": { category: "availability", recovery: "retry" },
|
|
68
|
+
"notifications_not_declared": { category: "compatibility", recovery: "fix_request" },
|
|
69
|
+
"notifications_unavailable": { category: "availability", recovery: "retry" },
|
|
70
|
+
"operation_cancelled": { category: "cancellation", recovery: "none" },
|
|
71
|
+
"operation_failed": { category: "internal", recovery: "contact_support" },
|
|
72
|
+
"operation_invalid": { category: "validation", recovery: "fix_request" },
|
|
73
|
+
"operation_outcome_unknown": { category: "conflict", recovery: "resolve_outcome" },
|
|
74
|
+
"path_occupied": { category: "conflict", recovery: "resolve_conflict" },
|
|
75
|
+
"pending_mutation_unresolved": { category: "conflict", recovery: "resolve_outcome" },
|
|
76
|
+
"query_snapshot_changed": { category: "conflict", recovery: "refresh" },
|
|
77
|
+
"rate_limited": { category: "availability", recovery: "retry" },
|
|
78
|
+
"redirect_uri_required": { category: "validation", recovery: "fix_request" },
|
|
79
|
+
"reference_updates_unsupported": { category: "compatibility", recovery: "fix_request" },
|
|
80
|
+
"relay_authorization_expired": { category: "authorization", recovery: "reauthorize" },
|
|
81
|
+
"relay_unavailable": { category: "availability", recovery: "retry" },
|
|
82
|
+
"sandbox_unsupported": { category: "compatibility", recovery: "fix_request" },
|
|
83
|
+
"scope_denied": { category: "authorization", recovery: "reauthorize" },
|
|
84
|
+
"stale_file_revision": { category: "conflict", recovery: "refresh" },
|
|
85
|
+
"storage_required": { category: "compatibility", recovery: "none" },
|
|
86
|
+
"sync_failed": { category: "availability", recovery: "retry" },
|
|
87
|
+
"temporarily_unavailable": { category: "availability", recovery: "retry" },
|
|
88
|
+
"timeout": { category: "availability", recovery: "retry" },
|
|
89
|
+
"token_exchange_failed": { category: "availability", recovery: "retry" },
|
|
90
|
+
"type_pack_provision_failed": { category: "validation", recovery: "repair_collection" },
|
|
91
|
+
"unknown_collection": { category: "selection", recovery: "choose_collection" },
|
|
92
|
+
"unsafe_file_path": { category: "validation", recovery: "fix_request" },
|
|
93
|
+
"unsupported_encryption": { category: "compatibility", recovery: "upgrade_application" },
|
|
94
|
+
"unsupported_operation": { category: "compatibility", recovery: "fix_request" }
|
|
95
|
+
};
|
|
96
|
+
const CONNECT_PROBLEM_DETAIL_SCHEMAS = {
|
|
97
|
+
"access_denied": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"required": [],
|
|
100
|
+
"properties": {
|
|
101
|
+
"return_to": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"approval_window_blocked": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"required": [
|
|
109
|
+
"user_code",
|
|
110
|
+
"verification_uri",
|
|
111
|
+
"verification_uri_complete",
|
|
112
|
+
"expires_at",
|
|
113
|
+
"interval_seconds"
|
|
114
|
+
],
|
|
115
|
+
"properties": {
|
|
116
|
+
"user_code": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
},
|
|
119
|
+
"verification_uri": {
|
|
120
|
+
"type": "string"
|
|
121
|
+
},
|
|
122
|
+
"verification_uri_complete": {
|
|
123
|
+
"type": "string"
|
|
124
|
+
},
|
|
125
|
+
"expires_at": {
|
|
126
|
+
"type": "integer"
|
|
127
|
+
},
|
|
128
|
+
"interval_seconds": {
|
|
129
|
+
"type": "integer"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"collection_configuration_invalid": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"required": [
|
|
136
|
+
"diagnostics"
|
|
137
|
+
],
|
|
138
|
+
"properties": {
|
|
139
|
+
"diagnostics": {
|
|
140
|
+
"type": "array",
|
|
141
|
+
"items": {
|
|
142
|
+
"type": "object"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"collection_contracts_missing": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"required": [
|
|
150
|
+
"contracts"
|
|
151
|
+
],
|
|
152
|
+
"properties": {
|
|
153
|
+
"contracts": {
|
|
154
|
+
"type": "array",
|
|
155
|
+
"items": {
|
|
156
|
+
"type": "object",
|
|
157
|
+
"required": [
|
|
158
|
+
"id",
|
|
159
|
+
"version"
|
|
160
|
+
],
|
|
161
|
+
"properties": {
|
|
162
|
+
"id": {
|
|
163
|
+
"type": "string"
|
|
164
|
+
},
|
|
165
|
+
"version": {
|
|
166
|
+
"type": "string"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"collection_invalid": {
|
|
174
|
+
"type": "object",
|
|
175
|
+
"required": [
|
|
176
|
+
"diagnostics"
|
|
177
|
+
],
|
|
178
|
+
"properties": {
|
|
179
|
+
"diagnostics": {
|
|
180
|
+
"type": "array",
|
|
181
|
+
"items": {
|
|
182
|
+
"type": "object"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"collection_type_registry_invalid": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"required": [
|
|
190
|
+
"diagnostics"
|
|
191
|
+
],
|
|
192
|
+
"properties": {
|
|
193
|
+
"diagnostics": {
|
|
194
|
+
"type": "array",
|
|
195
|
+
"items": {
|
|
196
|
+
"type": "object"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"collection_version_unsupported": {
|
|
202
|
+
"type": "object",
|
|
203
|
+
"required": [
|
|
204
|
+
"current_version",
|
|
205
|
+
"required_version"
|
|
206
|
+
],
|
|
207
|
+
"properties": {
|
|
208
|
+
"current_version": {
|
|
209
|
+
"type": "string"
|
|
210
|
+
},
|
|
211
|
+
"required_version": {
|
|
212
|
+
"type": "string"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"connector_offline": {
|
|
217
|
+
"type": "object",
|
|
218
|
+
"required": [],
|
|
219
|
+
"properties": {
|
|
220
|
+
"connector_name": {
|
|
221
|
+
"type": "string"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
"insufficient_access": {
|
|
226
|
+
"type": "object",
|
|
227
|
+
"required": [
|
|
228
|
+
"required_operations",
|
|
229
|
+
"granted_operations",
|
|
230
|
+
"missing_operations"
|
|
231
|
+
],
|
|
232
|
+
"properties": {
|
|
233
|
+
"required_operations": {
|
|
234
|
+
"type": "array",
|
|
235
|
+
"items": {
|
|
236
|
+
"type": "string"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"granted_operations": {
|
|
240
|
+
"type": "array",
|
|
241
|
+
"items": {
|
|
242
|
+
"type": "string"
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"missing_operations": {
|
|
246
|
+
"type": "array",
|
|
247
|
+
"items": {
|
|
248
|
+
"type": "string"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"operation_invalid": {
|
|
254
|
+
"type": "object",
|
|
255
|
+
"required": [
|
|
256
|
+
"diagnostics"
|
|
257
|
+
],
|
|
258
|
+
"properties": {
|
|
259
|
+
"diagnostics": {
|
|
260
|
+
"type": "array",
|
|
261
|
+
"items": {
|
|
262
|
+
"type": "object"
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"partial_result": {}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"rate_limited": {
|
|
269
|
+
"type": "object",
|
|
270
|
+
"required": [],
|
|
271
|
+
"properties": {
|
|
272
|
+
"retry_after_ms": {
|
|
273
|
+
"type": "integer"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
export function isConnectProblemCode(code) {
|
|
279
|
+
return Object.hasOwn(CONNECT_PROBLEM_CATALOG, code);
|
|
280
|
+
}
|
|
281
|
+
export function isConnectProblem(value) {
|
|
282
|
+
if (!isPlainObject(value))
|
|
283
|
+
return false;
|
|
284
|
+
const candidate = value;
|
|
285
|
+
if (candidate.problem_version !== CONNECT_PROBLEM_VERSION || typeof candidate.message !== "string" || candidate.message.length === 0)
|
|
286
|
+
return false;
|
|
287
|
+
if (candidate.operation_outcome !== undefined && candidate.operation_outcome !== "not_sent" && candidate.operation_outcome !== "rejected" && candidate.operation_outcome !== "unknown")
|
|
288
|
+
return false;
|
|
289
|
+
if (candidate.trace_id !== undefined && (typeof candidate.trace_id !== "string" || candidate.trace_id.length === 0))
|
|
290
|
+
return false;
|
|
291
|
+
if (candidate.code === "unknown") {
|
|
292
|
+
return typeof candidate.server_code === "string"
|
|
293
|
+
&& candidate.server_code.length > 0
|
|
294
|
+
&& candidate.category === "unknown"
|
|
295
|
+
&& candidate.recovery === "none";
|
|
296
|
+
}
|
|
297
|
+
if (typeof candidate.code !== "string" || !isConnectProblemCode(candidate.code) || candidate.server_code !== undefined)
|
|
298
|
+
return false;
|
|
299
|
+
const definition = CONNECT_PROBLEM_CATALOG[candidate.code];
|
|
300
|
+
const detailsSchema = CONNECT_PROBLEM_DETAIL_SCHEMAS[candidate.code];
|
|
301
|
+
const detailsMatch = detailsSchema === undefined
|
|
302
|
+
? candidate.details === undefined
|
|
303
|
+
: candidate.details === undefined
|
|
304
|
+
? (detailsSchema.required?.length ?? 0) === 0
|
|
305
|
+
: matchesDetailSchema(candidate.details, detailsSchema);
|
|
306
|
+
return candidate.category === definition.category
|
|
307
|
+
&& candidate.recovery === definition.recovery
|
|
308
|
+
&& detailsMatch;
|
|
309
|
+
}
|
|
310
|
+
function matchesDetailSchema(value, schema) {
|
|
311
|
+
if (schema.type === undefined)
|
|
312
|
+
return true;
|
|
313
|
+
if (schema.type === "string")
|
|
314
|
+
return typeof value === "string";
|
|
315
|
+
if (schema.type === "integer")
|
|
316
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
317
|
+
if (schema.type === "number")
|
|
318
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
319
|
+
if (schema.type === "boolean")
|
|
320
|
+
return typeof value === "boolean";
|
|
321
|
+
if (schema.type === "array")
|
|
322
|
+
return Array.isArray(value) && value.every((item) => matchesDetailSchema(item, schema.items ?? {}));
|
|
323
|
+
if (!isPlainObject(value))
|
|
324
|
+
return false;
|
|
325
|
+
if (!schema.properties)
|
|
326
|
+
return true;
|
|
327
|
+
const candidate = value;
|
|
328
|
+
if (!Object.keys(candidate).every((key) => Object.hasOwn(schema.properties, key)))
|
|
329
|
+
return false;
|
|
330
|
+
if (!(schema.required ?? []).every((key) => Object.hasOwn(candidate, key)))
|
|
331
|
+
return false;
|
|
332
|
+
return Object.entries(candidate).every(([key, item]) => matchesDetailSchema(item, schema.properties[key]));
|
|
333
|
+
}
|
|
334
|
+
function isPlainObject(value) {
|
|
335
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
336
|
+
}
|
|
337
|
+
export function normalizeConnectProblem(serverCode, message, options = {}) {
|
|
338
|
+
if (isConnectProblemCode(serverCode)) {
|
|
339
|
+
const definition = CONNECT_PROBLEM_CATALOG[serverCode];
|
|
340
|
+
const candidate = {
|
|
341
|
+
problem_version: CONNECT_PROBLEM_VERSION,
|
|
342
|
+
code: serverCode,
|
|
343
|
+
category: definition.category,
|
|
344
|
+
recovery: definition.recovery,
|
|
345
|
+
message,
|
|
346
|
+
...(options.details === undefined ? {} : { details: options.details }),
|
|
347
|
+
...(options.operation_outcome === undefined ? {} : { operation_outcome: options.operation_outcome }),
|
|
348
|
+
...(options.trace_id === undefined ? {} : { trace_id: options.trace_id })
|
|
349
|
+
};
|
|
350
|
+
if (isConnectProblem(candidate))
|
|
351
|
+
return candidate;
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
problem_version: CONNECT_PROBLEM_VERSION,
|
|
355
|
+
code: "unknown",
|
|
356
|
+
server_code: serverCode,
|
|
357
|
+
category: "unknown",
|
|
358
|
+
recovery: "none",
|
|
359
|
+
message,
|
|
360
|
+
...(options.details === undefined ? {} : { details: options.details }),
|
|
361
|
+
...(options.operation_outcome === undefined ? {} : { operation_outcome: options.operation_outcome }),
|
|
362
|
+
...(options.trace_id === undefined ? {} : { trace_id: options.trace_id })
|
|
363
|
+
};
|
|
364
|
+
}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
export declare const FILE_PROTOCOL_VERSION: 1;
|
|
2
|
+
export declare const FILE_TRANSFER_PROTOCOL_VERSION: 1;
|
|
3
|
+
export declare const DEFAULT_FILE_CHUNK_BYTES: number;
|
|
4
|
+
export declare const MAX_FILE_CHUNK_BYTES: number;
|
|
5
|
+
export declare const MAX_FILE_FRAME_HEADER_BYTES: number;
|
|
6
|
+
export declare const FILE_FRAME_PREFIX_BYTES = 16;
|
|
7
|
+
export declare const FILE_FRAME_MAGIC: "MDBF";
|
|
8
|
+
export declare const MAX_FILE_FRAME_BYTES: number;
|
|
9
|
+
export declare const RELAY_FILE_PROTOCOL_VERSION: 1;
|
|
10
|
+
export declare const RELAY_FILE_PREFIX_BYTES = 16;
|
|
11
|
+
export declare const MAX_RELAY_FILE_HEADER_BYTES = 1024;
|
|
12
|
+
export declare const MAX_RELAY_FILE_PAYLOAD_BYTES: number;
|
|
13
|
+
export declare const RELAY_FILE_MAGIC: "MDBR";
|
|
14
|
+
export type FileMediaClass = "image" | "audio" | "video" | "pdf" | "other";
|
|
15
|
+
/** Device-local projection. Folder exclusions apply to Markdown and files. */
|
|
16
|
+
export interface SelectiveSyncPolicy {
|
|
17
|
+
file_classes: FileMediaClass[];
|
|
18
|
+
excluded_folders: string[];
|
|
19
|
+
}
|
|
20
|
+
export type FileAction = "list" | "read" | "add" | "replace" | "move" | "delete";
|
|
21
|
+
export type FileTransferDirection = "upload" | "download";
|
|
22
|
+
export type FileTransferProtection = "grant_aead_v1" | "transport_tls";
|
|
23
|
+
export type FileTransferState = "open" | "committed" | "aborted" | "expired";
|
|
24
|
+
export type FileTransferStrategy = {
|
|
25
|
+
kind: "framed_chunks";
|
|
26
|
+
chunk_size: number;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "object_put";
|
|
29
|
+
} | {
|
|
30
|
+
kind: "object_multipart";
|
|
31
|
+
part_size: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "object_ranges";
|
|
34
|
+
part_size: number;
|
|
35
|
+
};
|
|
36
|
+
export type FileFrameKind = "upload_chunk" | "download_chunk";
|
|
37
|
+
export type RelayFileKind = "upload_chunk" | "upload_acknowledged" | "download_request" | "download_chunk" | "rejected";
|
|
38
|
+
export type FileScope = {
|
|
39
|
+
kind: "selected_folders";
|
|
40
|
+
folders: string[];
|
|
41
|
+
} | {
|
|
42
|
+
kind: "collection";
|
|
43
|
+
};
|
|
44
|
+
/** File intent declared by an application before an authority is selected. */
|
|
45
|
+
export interface ApplicationFileRequirement {
|
|
46
|
+
actions: FileAction[];
|
|
47
|
+
scope: FileScope;
|
|
48
|
+
}
|
|
49
|
+
export interface FileCapability {
|
|
50
|
+
kind: "files";
|
|
51
|
+
protocol_version: 1;
|
|
52
|
+
actions: FileAction[];
|
|
53
|
+
scope: FileScope;
|
|
54
|
+
}
|
|
55
|
+
export interface CollectionFileDescriptor {
|
|
56
|
+
file_id: string;
|
|
57
|
+
path: string;
|
|
58
|
+
revision: string;
|
|
59
|
+
content_digest: `sha256:${string}`;
|
|
60
|
+
size: number;
|
|
61
|
+
media_type?: string;
|
|
62
|
+
media_class: FileMediaClass;
|
|
63
|
+
modified_at: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ListFilesRequest {
|
|
66
|
+
protocol_version: 1;
|
|
67
|
+
type: "list_files";
|
|
68
|
+
folder?: string;
|
|
69
|
+
/** Opaque authority-issued continuation cursor. */
|
|
70
|
+
after?: string;
|
|
71
|
+
limit?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ListFilesPage {
|
|
74
|
+
protocol_version: 1;
|
|
75
|
+
type: "files_page";
|
|
76
|
+
files: CollectionFileDescriptor[];
|
|
77
|
+
/** Opaque continuation cursor; pass it back unchanged as `after`. */
|
|
78
|
+
next?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface OpenFileUploadRequest {
|
|
81
|
+
protocol_version: 1;
|
|
82
|
+
type: "open_file_upload";
|
|
83
|
+
transfer_id: string;
|
|
84
|
+
path: string;
|
|
85
|
+
size: number;
|
|
86
|
+
content_digest: `sha256:${string}`;
|
|
87
|
+
media_type?: string;
|
|
88
|
+
if_revision?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface OpenAuthorityImportFileUploadRequest {
|
|
91
|
+
protocol_version: 1;
|
|
92
|
+
type: "open_authority_import_file_upload";
|
|
93
|
+
transfer_id: string;
|
|
94
|
+
file_id: string;
|
|
95
|
+
}
|
|
96
|
+
export interface OpenFileDownloadRequest {
|
|
97
|
+
protocol_version: 1;
|
|
98
|
+
type: "open_file_download";
|
|
99
|
+
transfer_id: string;
|
|
100
|
+
file_id: string;
|
|
101
|
+
revision?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface MoveFileRequest {
|
|
104
|
+
protocol_version: 1;
|
|
105
|
+
type: "move_file";
|
|
106
|
+
mutation_id: string;
|
|
107
|
+
file_id: string;
|
|
108
|
+
if_revision: string;
|
|
109
|
+
from_path: string;
|
|
110
|
+
path: string;
|
|
111
|
+
update_references: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface MoveFileReceipt {
|
|
114
|
+
protocol_version: 1;
|
|
115
|
+
type: "file_moved";
|
|
116
|
+
mutation_id: string;
|
|
117
|
+
file: CollectionFileDescriptor;
|
|
118
|
+
}
|
|
119
|
+
export interface DeleteFileRequest {
|
|
120
|
+
protocol_version: 1;
|
|
121
|
+
type: "delete_file";
|
|
122
|
+
mutation_id: string;
|
|
123
|
+
file_id: string;
|
|
124
|
+
if_revision: string;
|
|
125
|
+
path: string;
|
|
126
|
+
}
|
|
127
|
+
export interface DeleteFileReceipt {
|
|
128
|
+
protocol_version: 1;
|
|
129
|
+
type: "file_deleted";
|
|
130
|
+
mutation_id: string;
|
|
131
|
+
file_id: string;
|
|
132
|
+
previous_path: string;
|
|
133
|
+
revision: string;
|
|
134
|
+
}
|
|
135
|
+
export interface FileTransferSession {
|
|
136
|
+
protocol_version: 1;
|
|
137
|
+
type: "file_transfer";
|
|
138
|
+
transfer_id: string;
|
|
139
|
+
direction: FileTransferDirection;
|
|
140
|
+
protection: FileTransferProtection;
|
|
141
|
+
strategy: FileTransferStrategy;
|
|
142
|
+
total_size: number;
|
|
143
|
+
expires_at: string;
|
|
144
|
+
received: number[];
|
|
145
|
+
/** R2/S3 part receipts for bandwidth-efficient multipart resume. */
|
|
146
|
+
uploaded_parts?: UploadedFilePart[];
|
|
147
|
+
}
|
|
148
|
+
export interface FileTransferStatus {
|
|
149
|
+
protocol_version: 1;
|
|
150
|
+
type: "file_transfer_status";
|
|
151
|
+
transfer_id: string;
|
|
152
|
+
state: FileTransferState;
|
|
153
|
+
received: number[];
|
|
154
|
+
received_bytes: number;
|
|
155
|
+
}
|
|
156
|
+
export interface PrepareFileUploadPartRequest {
|
|
157
|
+
protocol_version: 1;
|
|
158
|
+
type: "prepare_file_upload_part";
|
|
159
|
+
transfer_id: string;
|
|
160
|
+
part_number: number;
|
|
161
|
+
content_length: number;
|
|
162
|
+
}
|
|
163
|
+
export interface PreparedFilePart {
|
|
164
|
+
protocol_version: 1;
|
|
165
|
+
type: "file_part";
|
|
166
|
+
transfer_id: string;
|
|
167
|
+
part_index: number;
|
|
168
|
+
offset: number;
|
|
169
|
+
content_length: number;
|
|
170
|
+
method: string;
|
|
171
|
+
url: string;
|
|
172
|
+
headers: Record<string, string>;
|
|
173
|
+
expires_at: string;
|
|
174
|
+
}
|
|
175
|
+
export interface UploadedFilePart {
|
|
176
|
+
part_number: number;
|
|
177
|
+
etag: string;
|
|
178
|
+
}
|
|
179
|
+
export interface CommitFileUploadRequest {
|
|
180
|
+
protocol_version: 1;
|
|
181
|
+
type: "commit_file_upload";
|
|
182
|
+
transfer_id: string;
|
|
183
|
+
parts?: UploadedFilePart[];
|
|
184
|
+
}
|
|
185
|
+
export interface CommitFileUploadReceipt {
|
|
186
|
+
protocol_version: 1;
|
|
187
|
+
type: "file_upload_committed";
|
|
188
|
+
transfer_id: string;
|
|
189
|
+
file: CollectionFileDescriptor;
|
|
190
|
+
}
|
|
191
|
+
export interface AbortFileTransferRequest {
|
|
192
|
+
protocol_version: 1;
|
|
193
|
+
type: "abort_file_transfer";
|
|
194
|
+
transfer_id: string;
|
|
195
|
+
}
|
|
196
|
+
export interface GetFileTransferStatusRequest {
|
|
197
|
+
protocol_version: 1;
|
|
198
|
+
type: "get_file_transfer_status";
|
|
199
|
+
transfer_id: string;
|
|
200
|
+
}
|
|
201
|
+
export interface FileFrameHeader {
|
|
202
|
+
protocol_version: 1;
|
|
203
|
+
protection: FileTransferProtection;
|
|
204
|
+
grant_id: string;
|
|
205
|
+
authority_id: string;
|
|
206
|
+
collection_id: string;
|
|
207
|
+
transfer_id: string;
|
|
208
|
+
direction: FileTransferDirection;
|
|
209
|
+
chunk_size: number;
|
|
210
|
+
chunk_index: number;
|
|
211
|
+
offset: number;
|
|
212
|
+
plaintext_length: number;
|
|
213
|
+
total_size: number;
|
|
214
|
+
scope_epoch: number;
|
|
215
|
+
key_id?: string;
|
|
216
|
+
}
|
|
217
|
+
export interface FileFrame {
|
|
218
|
+
kind: FileFrameKind;
|
|
219
|
+
header: FileFrameHeader;
|
|
220
|
+
payload: Uint8Array;
|
|
221
|
+
}
|
|
222
|
+
export interface RelayFileHeader {
|
|
223
|
+
protocol_version: 1;
|
|
224
|
+
type: RelayFileKind;
|
|
225
|
+
request_id: string;
|
|
226
|
+
grant_id: string;
|
|
227
|
+
transfer_id: string;
|
|
228
|
+
chunk_index: number;
|
|
229
|
+
}
|
|
230
|
+
export interface RelayFileFrame {
|
|
231
|
+
kind: RelayFileKind;
|
|
232
|
+
header: RelayFileHeader;
|
|
233
|
+
payload: Uint8Array;
|
|
234
|
+
}
|
|
235
|
+
export interface FileFrameDecodeLimits {
|
|
236
|
+
maxHeaderBytes?: number;
|
|
237
|
+
maxPayloadBytes?: number;
|
|
238
|
+
}
|
|
239
|
+
export type FileFrameErrorCode = "invalid_magic" | "unsupported_version" | "invalid_kind" | "unsupported_flags" | "invalid_length" | "invalid_header" | "limit_exceeded";
|
|
240
|
+
export declare class FileFrameError extends Error {
|
|
241
|
+
readonly code: FileFrameErrorCode;
|
|
242
|
+
constructor(code: FileFrameErrorCode, message: string);
|
|
243
|
+
}
|
|
244
|
+
export declare class RelayFileFrameError extends Error {
|
|
245
|
+
readonly code: FileFrameErrorCode;
|
|
246
|
+
constructor(code: FileFrameErrorCode, message: string);
|
|
247
|
+
}
|
|
248
|
+
/** Prefix and canonical header authenticated by the file chunk AEAD profile. */
|
|
249
|
+
export declare function fileFrameAuthenticatedData(kind: FileFrameKind, input: FileFrameHeader): Uint8Array;
|
|
250
|
+
export declare function encodeFileFrame(frame: FileFrame): Uint8Array;
|
|
251
|
+
export declare function decodeFileFrame(bytes: Uint8Array, limits?: FileFrameDecodeLimits): FileFrame;
|
|
252
|
+
export declare function encodeRelayFileFrame(frame: RelayFileFrame): Uint8Array;
|
|
253
|
+
export declare function decodeRelayFileFrame(bytes: Uint8Array): RelayFileFrame;
|