effect 4.0.0-beta.44 → 4.0.0-beta.45
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/Equal.d.ts.map +1 -1
- package/dist/Equal.js +16 -0
- package/dist/Equal.js.map +1 -1
- package/dist/Hash.js +1 -1
- package/dist/Hash.js.map +1 -1
- package/dist/Semaphore.d.ts +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +1 -3
- package/dist/Semaphore.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +24 -21
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +0 -6
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +0 -5
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventGroup.d.ts +0 -2
- package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventGroup.js +0 -2
- package/dist/unstable/eventlog/EventGroup.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +22 -5
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +126 -67
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +88 -34
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +215 -141
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +9 -7
- package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +13 -15
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +228 -0
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogMessage.js +214 -0
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -0
- package/dist/unstable/eventlog/EventLogRemote.d.ts +109 -194
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +165 -320
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.d.ts +25 -47
- package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogServer.js +127 -198
- package/dist/unstable/eventlog/EventLogServer.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +60 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.js +166 -0
- package/dist/unstable/eventlog/EventLogServerEncrypted.js.map +1 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +183 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +461 -0
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts +117 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.js +284 -0
- package/dist/unstable/eventlog/EventLogSessionAuth.js.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogJournal.d.ts → SqlEventJournal.d.ts} +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogJournal.js → SqlEventJournal.js} +20 -14
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogServer.d.ts → SqlEventLogServerEncrypted.d.ts} +5 -5
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/{SqlEventLogServer.js → SqlEventLogServerEncrypted.js} +65 -24
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts +25 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +354 -0
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -0
- package/dist/unstable/eventlog/index.d.ts +22 -2
- package/dist/unstable/eventlog/index.d.ts.map +1 -1
- package/dist/unstable/eventlog/index.js +22 -2
- package/dist/unstable/eventlog/index.js.map +1 -1
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts +2 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.d.ts.map +1 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js +89 -0
- package/dist/unstable/eventlog/internal/identityRootSecretDerivation.js.map +1 -0
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -2
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +2 -2
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -2
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +3 -3
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +25 -4
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +26 -0
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +3 -13
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +47 -23
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +2 -2
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts +6 -0
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +44 -0
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +2 -2
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +2 -4
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +1 -12
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.d.ts.map +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Transferable.js.map +1 -1
- package/package.json +1 -1
- package/src/Equal.ts +17 -0
- package/src/Hash.ts +2 -2
- package/src/Semaphore.ts +2 -4
- package/src/unstable/ai/McpServer.ts +24 -22
- package/src/unstable/eventlog/Event.ts +0 -8
- package/src/unstable/eventlog/EventGroup.ts +0 -4
- package/src/unstable/eventlog/EventJournal.ts +144 -76
- package/src/unstable/eventlog/EventLog.ts +342 -221
- package/src/unstable/eventlog/EventLogEncryption.ts +16 -30
- package/src/unstable/eventlog/EventLogMessage.ts +277 -0
- package/src/unstable/eventlog/EventLogRemote.ts +261 -408
- package/src/unstable/eventlog/EventLogServer.ts +182 -274
- package/src/unstable/eventlog/EventLogServerEncrypted.ts +206 -0
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +749 -0
- package/src/unstable/eventlog/EventLogSessionAuth.ts +437 -0
- package/src/unstable/eventlog/{SqlEventLogJournal.ts → SqlEventJournal.ts} +26 -18
- package/src/unstable/eventlog/{SqlEventLogServer.ts → SqlEventLogServerEncrypted.ts} +102 -40
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +500 -0
- package/src/unstable/eventlog/index.ts +27 -2
- package/src/unstable/eventlog/internal/identityRootSecretDerivation.ts +153 -0
- package/src/unstable/reactivity/AtomHttpApi.ts +23 -8
- package/src/unstable/reactivity/AtomRpc.ts +16 -5
- package/src/unstable/rpc/Rpc.ts +42 -4
- package/src/unstable/rpc/RpcClient.ts +59 -24
- package/src/unstable/rpc/RpcGroup.ts +1 -1
- package/src/unstable/rpc/RpcMiddleware.ts +2 -2
- package/src/unstable/rpc/RpcServer.ts +5 -3
- package/src/unstable/rpc/Utils.ts +59 -0
- package/src/unstable/schema/Model.ts +4 -6
- package/src/unstable/schema/VariantSchema.ts +4 -17
- package/src/unstable/workers/Transferable.ts +9 -11
- package/dist/unstable/eventlog/SqlEventLogJournal.d.ts.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogServer.d.ts.map +0 -1
- package/dist/unstable/eventlog/SqlEventLogServer.js.map +0 -1
|
@@ -1,62 +1,40 @@
|
|
|
1
|
-
import type * as Cause from "../../Cause.ts";
|
|
2
1
|
import * as Context from "../../Context.ts";
|
|
3
2
|
import * as Effect from "../../Effect.ts";
|
|
4
3
|
import * as Layer from "../../Layer.ts";
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
import type * as
|
|
8
|
-
import type
|
|
9
|
-
import
|
|
10
|
-
import * as HttpServerResponse from "../http/HttpServerResponse.ts";
|
|
11
|
-
import type * as Socket from "../socket/Socket.ts";
|
|
12
|
-
import { type RemoteId } from "./EventJournal.ts";
|
|
13
|
-
import type { EncryptedRemoteEntry } from "./EventLogEncryption.ts";
|
|
4
|
+
import * as Stream from "../../Stream.ts";
|
|
5
|
+
import type * as Rpc from "../rpc/Rpc.ts";
|
|
6
|
+
import type * as RpcGroup from "../rpc/RpcGroup.ts";
|
|
7
|
+
import type { RemoteId } from "./EventJournal.ts";
|
|
8
|
+
import { EventLogAuthentication, EventLogProtocolError, EventLogRemoteRpcs, type StoreId } from "./EventLogMessage.ts";
|
|
14
9
|
/**
|
|
15
10
|
* @since 4.0.0
|
|
16
|
-
* @category
|
|
11
|
+
* @category Layers
|
|
17
12
|
*/
|
|
18
|
-
export declare const
|
|
13
|
+
export declare const layerAuthMiddleware: Layer.Layer<EventLogAuthentication>;
|
|
19
14
|
/**
|
|
20
15
|
* @since 4.0.0
|
|
21
|
-
* @category
|
|
16
|
+
* @category Layers
|
|
22
17
|
*/
|
|
23
|
-
export declare const
|
|
24
|
-
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
|
|
18
|
+
export declare const layerRpcHandlers: (options: {
|
|
19
|
+
readonly remoteId: RemoteId;
|
|
20
|
+
readonly getOrCreateSessionAuthBinding: (publicKey: string, signingPublicKey: Uint8Array<ArrayBuffer>) => Effect.Effect<Uint8Array<ArrayBuffer>>;
|
|
21
|
+
readonly onWrite: (data: Uint8Array<ArrayBuffer>) => Effect.Effect<void, EventLogProtocolError>;
|
|
22
|
+
readonly changes: (options: {
|
|
23
|
+
readonly publicKey: string;
|
|
24
|
+
readonly storeId: StoreId;
|
|
25
|
+
readonly startSequence: number;
|
|
26
|
+
}) => Stream.Stream<Uint8Array<ArrayBuffer>, unknown>;
|
|
27
|
+
}) => Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<typeof EventLogRemoteRpcs>> | EventLogAuthentication>;
|
|
28
|
+
declare const ChunkedMessageState_base: Context.Reference<Map<number, {
|
|
29
|
+
readonly parts: Array<Uint8Array>;
|
|
30
|
+
count: number;
|
|
31
|
+
bytes: number;
|
|
32
|
+
}>>;
|
|
29
33
|
/**
|
|
30
34
|
* @since 4.0.0
|
|
31
|
-
* @category
|
|
35
|
+
* @category ChunkedMessage state
|
|
32
36
|
*/
|
|
33
|
-
export declare class
|
|
34
|
-
/**
|
|
35
|
-
* @since 4.0.0
|
|
36
|
-
*/
|
|
37
|
-
get entryIdString(): string;
|
|
37
|
+
export declare class ChunkedMessageState extends ChunkedMessageState_base {
|
|
38
38
|
}
|
|
39
|
-
declare const Storage_base: Context.ServiceClass<Storage, "effect/eventlog/EventLogServer/Storage", {
|
|
40
|
-
readonly getId: Effect.Effect<RemoteId>;
|
|
41
|
-
readonly write: (publicKey: string, entries: ReadonlyArray<PersistedEntry>) => Effect.Effect<ReadonlyArray<EncryptedRemoteEntry>>;
|
|
42
|
-
readonly entries: (publicKey: string, startSequence: number) => Effect.Effect<ReadonlyArray<EncryptedRemoteEntry>>;
|
|
43
|
-
readonly changes: (publicKey: string, startSequence: number) => Effect.Effect<Queue.Dequeue<EncryptedRemoteEntry, Cause.Done>, never, Scope.Scope>;
|
|
44
|
-
}>;
|
|
45
|
-
/**
|
|
46
|
-
* @since 4.0.0
|
|
47
|
-
* @category storage
|
|
48
|
-
*/
|
|
49
|
-
export declare class Storage extends Storage_base {
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @since 4.0.0
|
|
53
|
-
* @category storage
|
|
54
|
-
*/
|
|
55
|
-
export declare const makeStorageMemory: Effect.Effect<Storage["Service"], never, Scope.Scope>;
|
|
56
|
-
/**
|
|
57
|
-
* @since 4.0.0
|
|
58
|
-
* @category storage
|
|
59
|
-
*/
|
|
60
|
-
export declare const layerStorageMemory: Layer.Layer<Storage>;
|
|
61
39
|
export {};
|
|
62
40
|
//# sourceMappingURL=EventLogServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventLogServer.d.ts","sourceRoot":"","sources":["../../../src/unstable/eventlog/EventLogServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventLogServer.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AAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAA;CACtD,KAAG,KAAK,CAAC,KAAK,CACb,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC,GAAG,sBAAsB,CAmH/E,CAAA;;oBAQiB,KAAK,CAAC,UAAU,CAAC;WAC1B,MAAM;WACN,MAAM;;AARjB;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,wBAQvC;CAAG"}
|
|
@@ -1,217 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
import * as Uuid from "uuid";
|
|
1
|
+
import * as Arr from "../../Array.js";
|
|
2
|
+
import * as Cache from "../../Cache.js";
|
|
5
3
|
import * as Context from "../../Context.js";
|
|
4
|
+
import * as Data from "../../Data.js";
|
|
6
5
|
import * as Effect from "../../Effect.js";
|
|
7
|
-
import * as
|
|
6
|
+
import * as Equal from "../../Equal.js";
|
|
7
|
+
import * as Hash from "../../Hash.js";
|
|
8
8
|
import * as Layer from "../../Layer.js";
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
15
|
-
import { EntryId, makeRemoteIdUnsafe } from "./EventJournal.js";
|
|
16
|
-
import { Ack, Changes, ChunkedMessage, decodeRequest, encodeResponse, Hello, Pong } from "./EventLogRemote.js";
|
|
17
|
-
const constChunkSize = 512_000;
|
|
9
|
+
import * as Option from "../../Option.js";
|
|
10
|
+
import * as Redacted from "../../Redacted.js";
|
|
11
|
+
import * as Stream from "../../Stream.js";
|
|
12
|
+
import * as EventLog from "./EventLog.js";
|
|
13
|
+
import { ChunkedMessage, EventLogAuthentication, EventLogProtocolError, EventLogRemoteRpcs, HelloResponse, SingleMessage } from "./EventLogMessage.js";
|
|
14
|
+
import * as EventLogSessionAuth from "./EventLogSessionAuth.js";
|
|
18
15
|
/**
|
|
19
16
|
* @since 4.0.0
|
|
20
|
-
* @category
|
|
17
|
+
* @category Layers
|
|
21
18
|
*/
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (response._tag !== "Changes" || data.byteLength <= constChunkSize) {
|
|
34
|
-
return yield* writeRaw(data);
|
|
35
|
-
}
|
|
36
|
-
const id = chunkId++;
|
|
37
|
-
for (const part of ChunkedMessage.split(id, data)) {
|
|
38
|
-
yield* writeRaw(yield* encodeResponse(part));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
yield* Effect.forkChild(Effect.orDie(write(new Hello({
|
|
42
|
-
remoteId
|
|
43
|
-
}))));
|
|
44
|
-
const handleRequest = request => {
|
|
45
|
-
switch (request._tag) {
|
|
46
|
-
case "Ping":
|
|
47
|
-
{
|
|
48
|
-
return Effect.orDie(write(new Pong({
|
|
49
|
-
id: request.id
|
|
50
|
-
})));
|
|
51
|
-
}
|
|
52
|
-
case "WriteEntries":
|
|
53
|
-
{
|
|
54
|
-
if (request.encryptedEntries.length === 0) {
|
|
55
|
-
return Effect.orDie(write(new Ack({
|
|
56
|
-
id: request.id,
|
|
57
|
-
sequenceNumbers: []
|
|
58
|
-
})));
|
|
59
|
-
}
|
|
60
|
-
return Effect.gen(function* () {
|
|
61
|
-
const entries = request.encryptedEntries.map(({
|
|
62
|
-
encryptedEntry,
|
|
63
|
-
entryId
|
|
64
|
-
}) => new PersistedEntry({
|
|
65
|
-
entryId,
|
|
66
|
-
iv: request.iv,
|
|
67
|
-
encryptedEntry
|
|
68
|
-
}));
|
|
69
|
-
const encrypted = yield* storage.write(request.publicKey, entries);
|
|
70
|
-
latestSequence = encrypted[encrypted.length - 1].sequence;
|
|
71
|
-
return yield* Effect.orDie(write(new Ack({
|
|
72
|
-
id: request.id,
|
|
73
|
-
sequenceNumbers: encrypted.map(entry => entry.sequence)
|
|
74
|
-
})));
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
case "RequestChanges":
|
|
78
|
-
{
|
|
79
|
-
return Effect.gen(function* () {
|
|
80
|
-
const changes = yield* storage.changes(request.publicKey, request.startSequence);
|
|
81
|
-
return yield* Queue.takeAll(changes).pipe(Effect.flatMap(entries => {
|
|
82
|
-
const latestEntries = [];
|
|
83
|
-
for (const entry of entries) {
|
|
84
|
-
if (entry.sequence <= latestSequence) continue;
|
|
85
|
-
latestEntries.push(entry);
|
|
86
|
-
latestSequence = entry.sequence;
|
|
87
|
-
}
|
|
88
|
-
if (latestEntries.length === 0) return Effect.void;
|
|
89
|
-
return Effect.orDie(write(new Changes({
|
|
90
|
-
publicKey: request.publicKey,
|
|
91
|
-
entries: latestEntries
|
|
92
|
-
})));
|
|
93
|
-
}), Effect.forever);
|
|
94
|
-
}).pipe(Effect.scoped, FiberMap.run(subscriptions, request.publicKey));
|
|
95
|
-
}
|
|
96
|
-
case "StopChanges":
|
|
97
|
-
{
|
|
98
|
-
return FiberMap.remove(subscriptions, request.publicKey);
|
|
99
|
-
}
|
|
100
|
-
case "ChunkedMessage":
|
|
101
|
-
{
|
|
102
|
-
const data = ChunkedMessage.join(chunks, request);
|
|
103
|
-
if (!data) return Effect.void;
|
|
104
|
-
return Effect.flatMap(Effect.orDie(decodeRequest(data)), handleRequest);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
yield* socket.run(data => Effect.flatMap(Effect.orDie(decodeRequest(data)), handleRequest)).pipe(Effect.catchCause(cause => Effect.logDebug(cause)));
|
|
109
|
-
}, Effect.scoped, Effect.annotateLogs({
|
|
110
|
-
module: "EventLogServer"
|
|
19
|
+
export const layerAuthMiddleware = /*#__PURE__*/Layer.succeed(EventLogAuthentication, (effect, {
|
|
20
|
+
client,
|
|
21
|
+
rpc
|
|
22
|
+
}) => {
|
|
23
|
+
const identity = Context.getOrUndefined(client.annotations, EventLog.Identity);
|
|
24
|
+
if (identity) return Effect.provideService(effect, EventLog.Identity, identity);
|
|
25
|
+
return Effect.fail(new EventLogProtocolError({
|
|
26
|
+
requestTag: rpc._tag,
|
|
27
|
+
publicKey: undefined,
|
|
28
|
+
code: "Forbidden",
|
|
29
|
+
message: "Unauthenticated request"
|
|
111
30
|
}));
|
|
112
31
|
});
|
|
113
32
|
/**
|
|
114
33
|
* @since 4.0.0
|
|
115
|
-
* @category
|
|
34
|
+
* @category Layers
|
|
116
35
|
*/
|
|
117
|
-
export const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const socket = yield* request.upgrade;
|
|
123
|
-
yield* handler(socket);
|
|
124
|
-
return HttpServerResponse.empty();
|
|
125
|
-
}).pipe(Effect.annotateLogs({
|
|
126
|
-
module: "EventLogServer"
|
|
127
|
-
}));
|
|
128
|
-
});
|
|
129
|
-
/**
|
|
130
|
-
* @since 4.0.0
|
|
131
|
-
* @category storage
|
|
132
|
-
*/
|
|
133
|
-
export class PersistedEntry extends /*#__PURE__*/Schema.Class("effect/eventlog/EventLogServer/PersistedEntry")({
|
|
134
|
-
entryId: EntryId,
|
|
135
|
-
iv: Schema.Uint8Array,
|
|
136
|
-
encryptedEntry: Schema.Uint8Array
|
|
137
|
-
}) {
|
|
138
|
-
/**
|
|
139
|
-
* @since 4.0.0
|
|
140
|
-
*/
|
|
141
|
-
get entryIdString() {
|
|
142
|
-
return Uuid.stringify(this.entryId);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* @since 4.0.0
|
|
147
|
-
* @category storage
|
|
148
|
-
*/
|
|
149
|
-
export class Storage extends /*#__PURE__*/Context.Service()("effect/eventlog/EventLogServer/Storage") {}
|
|
150
|
-
/**
|
|
151
|
-
* @since 4.0.0
|
|
152
|
-
* @category storage
|
|
153
|
-
*/
|
|
154
|
-
export const makeStorageMemory = /*#__PURE__*/Effect.gen(function* () {
|
|
155
|
-
const knownIds = new Map();
|
|
156
|
-
const journals = new Map();
|
|
157
|
-
const remoteId = makeRemoteIdUnsafe();
|
|
158
|
-
const ensureJournal = publicKey => {
|
|
159
|
-
let journal = journals.get(publicKey);
|
|
160
|
-
if (journal) return journal;
|
|
161
|
-
journal = [];
|
|
162
|
-
journals.set(publicKey, journal);
|
|
163
|
-
return journal;
|
|
164
|
-
};
|
|
165
|
-
const pubsubs = yield* RcMap.make({
|
|
166
|
-
lookup: _publicKey => Effect.acquireRelease(PubSub.unbounded(), PubSub.shutdown),
|
|
167
|
-
idleTimeToLive: 60000
|
|
36
|
+
export const layerRpcHandlers = options => EventLogRemoteRpcs.toLayer(Effect.gen(function* () {
|
|
37
|
+
const clientChallenges = yield* Cache.make({
|
|
38
|
+
lookup: _clientId => Effect.orDie(EventLogSessionAuth.makeSessionAuthChallenge),
|
|
39
|
+
capacity: Number.MAX_SAFE_INTEGER,
|
|
40
|
+
timeToLive: EventLogSessionAuth.SessionAuthChallengeTimeToLiveMillis
|
|
168
41
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
42
|
+
let chunkedIdCounter = 0;
|
|
43
|
+
const persistedSigningPublicKeys = yield* Cache.make({
|
|
44
|
+
lookup: key => options.getOrCreateSessionAuthBinding(key.publicKey, key.signingPublicKey).pipe(Effect.catchCause(_ => Effect.fail(new EventLogProtocolError({
|
|
45
|
+
requestTag: "Authenticate",
|
|
46
|
+
publicKey: key.publicKey,
|
|
47
|
+
code: "Forbidden",
|
|
48
|
+
message: "Session auth binding lookup failed"
|
|
49
|
+
})))),
|
|
50
|
+
capacity: 4096
|
|
51
|
+
});
|
|
52
|
+
return EventLogRemoteRpcs.of({
|
|
53
|
+
"EventLog.Hello": Effect.fnUntraced(function* (_, {
|
|
54
|
+
client
|
|
55
|
+
}) {
|
|
56
|
+
const challenge = yield* Cache.get(clientChallenges, client.id);
|
|
57
|
+
return new HelloResponse({
|
|
58
|
+
remoteId: options.remoteId,
|
|
59
|
+
challenge
|
|
60
|
+
});
|
|
61
|
+
}),
|
|
62
|
+
"EventLog.Authenticate": Effect.fnUntraced(function* (request, {
|
|
63
|
+
client
|
|
64
|
+
}) {
|
|
65
|
+
const challenge = Option.getOrNull(yield* Cache.getOption(clientChallenges, client.id));
|
|
66
|
+
if (!challenge) {
|
|
67
|
+
return new EventLogProtocolError({
|
|
68
|
+
requestTag: "Authenticate",
|
|
69
|
+
publicKey: request.publicKey,
|
|
70
|
+
code: "Forbidden",
|
|
71
|
+
message: "Session auth challenge has expired"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
yield* Cache.invalidate(clientChallenges, client.id);
|
|
75
|
+
const signingPublicKey = yield* Cache.get(persistedSigningPublicKeys, new SessionAuthCacheKey({
|
|
76
|
+
publicKey: request.publicKey,
|
|
77
|
+
signingPublicKey: request.signingPublicKey
|
|
78
|
+
}));
|
|
79
|
+
const verified = yield* EventLogSessionAuth.verifySessionAuthenticateRequest({
|
|
80
|
+
remoteId: options.remoteId,
|
|
81
|
+
challenge,
|
|
82
|
+
publicKey: request.publicKey,
|
|
83
|
+
signingPublicKey,
|
|
84
|
+
signature: request.signature,
|
|
85
|
+
algorithm: request.algorithm
|
|
86
|
+
}).pipe(Effect.catch(() => Effect.succeed(false)));
|
|
87
|
+
if (!verified) {
|
|
88
|
+
return yield* new EventLogProtocolError({
|
|
89
|
+
requestTag: "Authenticate",
|
|
90
|
+
publicKey: request.publicKey,
|
|
91
|
+
code: "Forbidden",
|
|
92
|
+
message: "Session auth signature verification failed"
|
|
93
|
+
});
|
|
179
94
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
95
|
+
client.annotate(EventLog.Identity, {
|
|
96
|
+
publicKey: request.publicKey,
|
|
97
|
+
privateKey: constEmptyPrivateKey
|
|
98
|
+
}).annotate(ChunkedMessageState, new Map());
|
|
99
|
+
}),
|
|
100
|
+
"EventLog.WriteSingle": Effect.fnUntraced(function* (request) {
|
|
101
|
+
yield* options.onWrite(request.data);
|
|
102
|
+
}),
|
|
103
|
+
"EventLog.WriteChunked": Effect.fnUntraced(function* (request, {
|
|
104
|
+
client
|
|
105
|
+
}) {
|
|
106
|
+
const state = Context.get(client.annotations, ChunkedMessageState);
|
|
107
|
+
const data = ChunkedMessage.join(state, request);
|
|
108
|
+
if (!data) return;
|
|
109
|
+
yield* options.onWrite(data);
|
|
110
|
+
}),
|
|
111
|
+
"EventLog.Changes": request => options.changes({
|
|
112
|
+
publicKey: request.publicKey,
|
|
113
|
+
storeId: request.storeId,
|
|
114
|
+
startSequence: request.startSequence
|
|
115
|
+
}).pipe(Stream.mapArray(Arr.flatMap(data => {
|
|
116
|
+
if (data.byteLength <= ChunkedMessage.chunkSize) {
|
|
117
|
+
return [new SingleMessage({
|
|
118
|
+
data
|
|
119
|
+
})];
|
|
197
120
|
}
|
|
198
|
-
return
|
|
199
|
-
}).
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
yield* Queue.offerAll(queue, ensureJournal(publicKey).slice(startSequence));
|
|
206
|
-
yield* PubSub.takeAll(subscription).pipe(Effect.flatMap(chunk => Queue.offerAll(queue, chunk)), Effect.forever, Effect.forkScoped);
|
|
207
|
-
yield* Effect.addFinalizer(() => Queue.shutdown(queue));
|
|
208
|
-
return Queue.asDequeue(queue);
|
|
209
|
-
})
|
|
121
|
+
return ChunkedMessage.split(chunkedIdCounter++, data);
|
|
122
|
+
})), Stream.catchCause(_ => Stream.fail(new EventLogProtocolError({
|
|
123
|
+
requestTag: "Changes",
|
|
124
|
+
publicKey: request.publicKey,
|
|
125
|
+
code: "InternalServerError",
|
|
126
|
+
message: "Decoding failure"
|
|
127
|
+
}))))
|
|
210
128
|
});
|
|
211
|
-
});
|
|
129
|
+
})).pipe(Layer.merge(layerAuthMiddleware));
|
|
212
130
|
/**
|
|
213
131
|
* @since 4.0.0
|
|
214
|
-
* @category
|
|
132
|
+
* @category ChunkedMessage state
|
|
215
133
|
*/
|
|
216
|
-
export
|
|
134
|
+
export class ChunkedMessageState extends /*#__PURE__*/Context.Reference("effect/eventlog/EventLogServer/ChunkedMessageState", {
|
|
135
|
+
defaultValue: () => new Map()
|
|
136
|
+
}) {}
|
|
137
|
+
class SessionAuthCacheKey extends Data.Class {
|
|
138
|
+
[Equal.symbol](that) {
|
|
139
|
+
return this.publicKey === that.publicKey;
|
|
140
|
+
}
|
|
141
|
+
[Hash.symbol]() {
|
|
142
|
+
return Hash.string(this.publicKey);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const constEmptyPrivateKey = /*#__PURE__*/Redacted.make(/*#__PURE__*/new Uint8Array(32));
|
|
217
146
|
//# sourceMappingURL=EventLogServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventLogServer.js","names":["
|
|
1
|
+
{"version":3,"file":"EventLogServer.js","names":["Arr","Cache","Context","Data","Effect","Equal","Hash","Layer","Option","Redacted","Stream","EventLog","ChunkedMessage","EventLogAuthentication","EventLogProtocolError","EventLogRemoteRpcs","HelloResponse","SingleMessage","EventLogSessionAuth","layerAuthMiddleware","succeed","effect","client","rpc","identity","getOrUndefined","annotations","Identity","provideService","fail","requestTag","_tag","publicKey","undefined","code","message","layerRpcHandlers","options","toLayer","gen","clientChallenges","make","lookup","_clientId","orDie","makeSessionAuthChallenge","capacity","Number","MAX_SAFE_INTEGER","timeToLive","SessionAuthChallengeTimeToLiveMillis","chunkedIdCounter","persistedSigningPublicKeys","key","getOrCreateSessionAuthBinding","signingPublicKey","pipe","catchCause","_","of","fnUntraced","challenge","get","id","remoteId","request","getOrNull","getOption","invalidate","SessionAuthCacheKey","verified","verifySessionAuthenticateRequest","signature","algorithm","catch","annotate","privateKey","constEmptyPrivateKey","ChunkedMessageState","Map","onWrite","data","state","join","changes","storeId","startSequence","mapArray","flatMap","byteLength","chunkSize","split","merge","Reference","defaultValue","Class","symbol","that","string","Uint8Array"],"sources":["../../../src/unstable/eventlog/EventLogServer.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,GAAG,MAAM,gBAAgB;AACrC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,OAAO,MAAM,kBAAkB;AAC3C,OAAO,KAAKC,IAAI,MAAM,eAAe;AACrC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AACzC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,IAAI,MAAM,eAAe;AACrC,OAAO,KAAKC,KAAK,MAAM,gBAAgB;AACvC,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AACzC,OAAO,KAAKC,QAAQ,MAAM,mBAAmB;AAC7C,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AAIzC,OAAO,KAAKC,QAAQ,MAAM,eAAe;AACzC,SACEC,cAAc,EACdC,sBAAsB,EACtBC,qBAAqB,EACrBC,kBAAkB,EAClBC,aAAa,EACbC,aAAa,QAER,sBAAsB;AAC7B,OAAO,KAAKC,mBAAmB,MAAM,0BAA0B;AAE/D;;;;AAIA,OAAO,MAAMC,mBAAmB,gBAE5BZ,KAAK,CAACa,OAAO,CAACP,sBAAsB,EAAE,CAACQ,MAAM,EAAE;EAAEC,MAAM;EAAEC;AAAG,CAAE,KAAI;EACpE,MAAMC,QAAQ,GAAGtB,OAAO,CAACuB,cAAc,CAACH,MAAM,CAACI,WAAW,EAAEf,QAAQ,CAACgB,QAAQ,CAAC;EAC9E,IAAIH,QAAQ,EAAE,OAAOpB,MAAM,CAACwB,cAAc,CAACP,MAAM,EAAEV,QAAQ,CAAC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* as Effect from "../../Effect.ts";
|
|
3
|
+
import * as Layer from "../../Layer.ts";
|
|
4
|
+
import * as Schema from "../../Schema.ts";
|
|
5
|
+
import type * as Scope from "../../Scope.ts";
|
|
6
|
+
import * as Stream from "../../Stream.ts";
|
|
7
|
+
import * as RpcServer from "../rpc/RpcServer.ts";
|
|
8
|
+
import * as Transferable from "../workers/Transferable.ts";
|
|
9
|
+
import { type RemoteId } from "./EventJournal.ts";
|
|
10
|
+
import type { EncryptedRemoteEntry } from "./EventLogEncryption.ts";
|
|
11
|
+
import { type StoreId } from "./EventLogMessage.ts";
|
|
12
|
+
/**
|
|
13
|
+
* @since 4.0.0
|
|
14
|
+
* @category Layers
|
|
15
|
+
*/
|
|
16
|
+
export declare const layerRpcHandlers: Layer.Layer<import("./EventLogMessage.ts").EventLogAuthentication | import("../rpc/Rpc.ts").Handler<"EventLog.Hello"> | import("../rpc/Rpc.ts").Handler<"EventLog.Authenticate"> | import("../rpc/Rpc.ts").Handler<"EventLog.WriteChunked"> | import("../rpc/Rpc.ts").Handler<"EventLog.WriteSingle"> | import("../rpc/Rpc.ts").Handler<"EventLog.Changes">, never, Storage>;
|
|
17
|
+
/**
|
|
18
|
+
* @since 4.0.0
|
|
19
|
+
* @category Layers
|
|
20
|
+
*/
|
|
21
|
+
export declare const layer: Layer.Layer<never, never, RpcServer.Protocol | Storage>;
|
|
22
|
+
declare const PersistedEntry_base: Schema.Class<PersistedEntry, Schema.Struct<{
|
|
23
|
+
readonly entryId: Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, "effect/eventlog/EventJournal/EntryId">;
|
|
24
|
+
readonly iv: Transferable.Transferable<Schema.instanceOf<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
25
|
+
readonly encryptedEntry: Transferable.Transferable<Schema.instanceOf<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
26
|
+
}>, {}>;
|
|
27
|
+
/**
|
|
28
|
+
* @since 4.0.0
|
|
29
|
+
* @category storage
|
|
30
|
+
*/
|
|
31
|
+
export declare class PersistedEntry extends PersistedEntry_base {
|
|
32
|
+
/**
|
|
33
|
+
* @since 4.0.0
|
|
34
|
+
*/
|
|
35
|
+
get entryIdString(): string;
|
|
36
|
+
}
|
|
37
|
+
declare const Storage_base: Context.ServiceClass<Storage, "effect/eventlog/EventLogServer/Storage", {
|
|
38
|
+
readonly getId: Effect.Effect<RemoteId>;
|
|
39
|
+
readonly getOrCreateSessionAuthBinding: (publicKey: string, signingPublicKey: Uint8Array<ArrayBuffer>) => Effect.Effect<Uint8Array<ArrayBuffer>>;
|
|
40
|
+
readonly write: (publicKey: string, storeId: StoreId, entries: ReadonlyArray<PersistedEntry>) => Effect.Effect<ReadonlyArray<EncryptedRemoteEntry>>;
|
|
41
|
+
readonly changes: (publicKey: string, storeId: StoreId, startSequence: number) => Stream.Stream<EncryptedRemoteEntry>;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* @since 4.0.0
|
|
45
|
+
* @category storage
|
|
46
|
+
*/
|
|
47
|
+
export declare class Storage extends Storage_base {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @since 4.0.0
|
|
51
|
+
* @category storage
|
|
52
|
+
*/
|
|
53
|
+
export declare const makeStorageMemory: Effect.Effect<Storage["Service"], never, Scope.Scope>;
|
|
54
|
+
/**
|
|
55
|
+
* @since 4.0.0
|
|
56
|
+
* @category storage
|
|
57
|
+
*/
|
|
58
|
+
export declare const layerStorageMemory: Layer.Layer<Storage>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=EventLogServerEncrypted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogServerEncrypted.d.ts","sourceRoot":"","sources":["../../../src/unstable/eventlog/EventLogServerEncrypted.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,O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