loro-repo 0.21.2 → 0.22.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 +13 -2
- package/dist/transport/streams.cjs +18 -1
- package/dist/transport/streams.cjs.map +1 -1
- package/dist/transport/streams.d.cts +8 -1
- package/dist/transport/streams.d.ts +8 -1
- package/dist/transport/streams.js +18 -2
- package/dist/transport/streams.js.map +1 -1
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -290,10 +290,21 @@ CRDT import and before `beforeRemoteCursorSave`; the adapter keeps the existing
|
|
|
290
290
|
"persist CRDT state, then advance cursor" boundary. Each room owns an independent
|
|
291
291
|
instance, so one room's failure does not stop other rooms.
|
|
292
292
|
|
|
293
|
-
This API requires `@loro-dev/streams-crdt@^0.
|
|
293
|
+
This API requires `@loro-dev/streams-crdt@^0.16.2`, specifically its common
|
|
294
294
|
protected-payload boundary and `payloadProtectionRequired` guard. No 0.12.x
|
|
295
295
|
encryption compatibility shim is retained; the adapter passes the published
|
|
296
|
-
|
|
296
|
+
opaque `streamUrl` transport target directly.
|
|
297
|
+
|
|
298
|
+
A trusted snapshot-admission host can import
|
|
299
|
+
`encodeStreamsRoomAdditionalData(namespace, room, envelopeAdditionalData)` from
|
|
300
|
+
`loro-repo/transport/streams` to reconstruct the exact AAD supplied to the provider.
|
|
301
|
+
Use authenticated application namespace and logical room, not uploaded identity
|
|
302
|
+
claims or routing URLs. This helper changes no wire bytes and does not perform
|
|
303
|
+
signature verification or grant publication permission.
|
|
304
|
+
|
|
305
|
+
Structured errors retain a whitelisted `payloadProtectionReason`, including
|
|
306
|
+
`missing_read_key` versus `decrypt_failed`, on `RepoTransportError`. Provider
|
|
307
|
+
messages and causes remain sanitized. See the [compatibility decision](../../docs/plans/2026-10-10-streams-protection-host.md).
|
|
297
308
|
|
|
298
309
|
## Replica-bound Streams checkpoints (IndexedDB)
|
|
299
310
|
|
|
@@ -55,6 +55,14 @@ const codes = [
|
|
|
55
55
|
"unknown",
|
|
56
56
|
"payload_protection_error"
|
|
57
57
|
];
|
|
58
|
+
const protectionReasons = [
|
|
59
|
+
"plaintext_forbidden",
|
|
60
|
+
"missing_read_key",
|
|
61
|
+
"decrypt_failed",
|
|
62
|
+
"invalid_envelope",
|
|
63
|
+
"wrong_payload_kind",
|
|
64
|
+
"encrypt_failed"
|
|
65
|
+
];
|
|
58
66
|
const sources = [
|
|
59
67
|
"fetch",
|
|
60
68
|
"http",
|
|
@@ -164,6 +172,7 @@ function projectStreamsError(error) {
|
|
|
164
172
|
"unsupported"
|
|
165
173
|
]) ?? "unknown";
|
|
166
174
|
const retry = field(error, "retryable");
|
|
175
|
+
const payloadProtectionReason = streamsCode === "payload_protection_error" ? member(field(error, "reason"), protectionReasons) : void 0;
|
|
167
176
|
const retryable = typeof retry === "boolean" ? retry : void 0;
|
|
168
177
|
const raw = field(error, "context");
|
|
169
178
|
let streamsContext;
|
|
@@ -202,7 +211,8 @@ function projectStreamsError(error) {
|
|
|
202
211
|
streamsCode,
|
|
203
212
|
retryable,
|
|
204
213
|
streamsContext,
|
|
205
|
-
failureKind
|
|
214
|
+
failureKind,
|
|
215
|
+
...payloadProtectionReason !== void 0 ? { payloadProtectionReason } : {}
|
|
206
216
|
};
|
|
207
217
|
}
|
|
208
218
|
|
|
@@ -391,6 +401,12 @@ function createActiveRoomRestartError() {
|
|
|
391
401
|
}
|
|
392
402
|
const STREAMS_ROOM_AAD_DOMAIN = new TextEncoder().encode("loro-repo/streams-room-aad");
|
|
393
403
|
const STREAMS_ROOM_AAD_VERSION = new Uint8Array([1]);
|
|
404
|
+
/**
|
|
405
|
+
* Reconstruct the exact provider AAD for trusted host-side verification, e.g.
|
|
406
|
+
* snapshot admission. Namespace and logical room must come from authenticated
|
|
407
|
+
* application context, never from an uploaded envelope or a routing URL.
|
|
408
|
+
* This is the same encoding used by the transport's provider wrapper.
|
|
409
|
+
*/
|
|
394
410
|
function encodeStreamsRoomAdditionalData(namespace, room, envelopeAdditionalData) {
|
|
395
411
|
const encoder = new TextEncoder();
|
|
396
412
|
const namespaceBytes = encoder.encode(namespace);
|
|
@@ -2010,4 +2026,5 @@ var StreamsTransportAdapter = class {
|
|
|
2010
2026
|
exports.StreamsDurabilityError = StreamsDurabilityError;
|
|
2011
2027
|
exports.StreamsTransportAdapter = StreamsTransportAdapter;
|
|
2012
2028
|
exports.createRepoStreamsPersistence = createRepoStreamsPersistence;
|
|
2029
|
+
exports.encodeStreamsRoomAdditionalData = encodeStreamsRoomAdditionalData;
|
|
2013
2030
|
//# sourceMappingURL=streams.cjs.map
|