@livestore/sync-cf 0.4.0-dev.21 → 0.4.0-dev.23
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 +6 -7
- package/dist/.tsbuildinfo +1 -1
- package/dist/cf-worker/do/durable-object.d.ts.map +1 -1
- package/dist/cf-worker/do/durable-object.js +12 -8
- package/dist/cf-worker/do/durable-object.js.map +1 -1
- package/dist/cf-worker/do/layer.d.ts +1 -1
- package/dist/cf-worker/do/layer.d.ts.map +1 -1
- package/dist/cf-worker/do/layer.js +2 -2
- package/dist/cf-worker/do/layer.js.map +1 -1
- package/dist/cf-worker/do/pull.d.ts +7 -2
- package/dist/cf-worker/do/pull.d.ts.map +1 -1
- package/dist/cf-worker/do/pull.js +12 -6
- package/dist/cf-worker/do/pull.js.map +1 -1
- package/dist/cf-worker/do/push.d.ts +5 -4
- package/dist/cf-worker/do/push.d.ts.map +1 -1
- package/dist/cf-worker/do/push.js +18 -11
- package/dist/cf-worker/do/push.js.map +1 -1
- package/dist/cf-worker/do/sqlite.d.ts.map +1 -1
- package/dist/cf-worker/do/sqlite.js.map +1 -1
- package/dist/cf-worker/do/sync-storage.d.ts +1 -1
- package/dist/cf-worker/do/sync-storage.d.ts.map +1 -1
- package/dist/cf-worker/do/sync-storage.js +2 -1
- package/dist/cf-worker/do/sync-storage.js.map +1 -1
- package/dist/cf-worker/do/transport/do-rpc-server.d.ts.map +1 -1
- package/dist/cf-worker/do/transport/do-rpc-server.js +13 -7
- package/dist/cf-worker/do/transport/do-rpc-server.js.map +1 -1
- package/dist/cf-worker/do/transport/http-rpc-server.d.ts +2 -1
- package/dist/cf-worker/do/transport/http-rpc-server.d.ts.map +1 -1
- package/dist/cf-worker/do/transport/http-rpc-server.js +17 -14
- package/dist/cf-worker/do/transport/http-rpc-server.js.map +1 -1
- package/dist/cf-worker/do/transport/ws-rpc-server.d.ts +2 -1
- package/dist/cf-worker/do/transport/ws-rpc-server.d.ts.map +1 -1
- package/dist/cf-worker/do/transport/ws-rpc-server.js +30 -8
- package/dist/cf-worker/do/transport/ws-rpc-server.js.map +1 -1
- package/dist/cf-worker/shared.d.ts +60 -15
- package/dist/cf-worker/shared.d.ts.map +1 -1
- package/dist/cf-worker/shared.js +27 -0
- package/dist/cf-worker/shared.js.map +1 -1
- package/dist/cf-worker/worker.d.ts +31 -31
- package/dist/cf-worker/worker.d.ts.map +1 -1
- package/dist/cf-worker/worker.js +27 -30
- package/dist/cf-worker/worker.js.map +1 -1
- package/dist/client/transport/do-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/do-rpc-client.js +11 -7
- package/dist/client/transport/do-rpc-client.js.map +1 -1
- package/dist/client/transport/http-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/http-rpc-client.js +10 -6
- package/dist/client/transport/http-rpc-client.js.map +1 -1
- package/dist/client/transport/ws-rpc-client.d.ts.map +1 -1
- package/dist/client/transport/ws-rpc-client.js +11 -11
- package/dist/client/transport/ws-rpc-client.js.map +1 -1
- package/dist/common/do-rpc-schema.d.ts +3 -3
- package/dist/common/do-rpc-schema.d.ts.map +1 -1
- package/dist/common/do-rpc-schema.js +3 -3
- package/dist/common/do-rpc-schema.js.map +1 -1
- package/dist/common/http-rpc-schema.d.ts +3 -3
- package/dist/common/http-rpc-schema.d.ts.map +1 -1
- package/dist/common/http-rpc-schema.js +3 -3
- package/dist/common/http-rpc-schema.js.map +1 -1
- package/dist/common/sync-message-types.d.ts +2 -2
- package/dist/common/ws-rpc-schema.d.ts +3 -3
- package/dist/common/ws-rpc-schema.d.ts.map +1 -1
- package/dist/common/ws-rpc-schema.js +3 -3
- package/dist/common/ws-rpc-schema.js.map +1 -1
- package/package.json +71 -13
- package/src/cf-worker/do/durable-object.ts +18 -10
- package/src/cf-worker/do/layer.ts +4 -3
- package/src/cf-worker/do/pull.ts +28 -9
- package/src/cf-worker/do/push.ts +29 -10
- package/src/cf-worker/do/sqlite.ts +1 -0
- package/src/cf-worker/do/sync-storage.ts +4 -2
- package/src/cf-worker/do/transport/do-rpc-server.ts +18 -7
- package/src/cf-worker/do/transport/http-rpc-server.ts +27 -21
- package/src/cf-worker/do/transport/ws-rpc-server.ts +40 -12
- package/src/cf-worker/shared.ts +89 -11
- package/src/cf-worker/worker.ts +64 -47
- package/src/client/transport/do-rpc-client.ts +20 -14
- package/src/client/transport/http-rpc-client.ts +19 -13
- package/src/client/transport/ws-rpc-client.ts +39 -36
- package/src/common/do-rpc-schema.ts +4 -3
- package/src/common/http-rpc-schema.ts +4 -3
- package/src/common/ws-rpc-schema.ts +4 -3
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Effect, HttpApp, Layer, RpcSerialization, RpcServer } from '@livestore/utils/effect';
|
|
2
2
|
import { SyncHttpRpc } from "../../../common/http-rpc-schema.js";
|
|
3
3
|
import * as SyncMessage from "../../../common/sync-message-types.js";
|
|
4
|
+
import { headersRecordToMap } from "../../shared.js";
|
|
4
5
|
import { DoCtx } from "../layer.js";
|
|
5
6
|
import { makeEndingPullStream } from "../pull.js";
|
|
6
7
|
import { makePush } from "../push.js";
|
|
7
|
-
export const createHttpRpcHandler = ({ request, responseHeaders, })
|
|
8
|
-
const handlerLayer = createHttpRpcLayer;
|
|
8
|
+
export const createHttpRpcHandler = Effect.fn('createHttpRpcHandler')(function* ({ request, responseHeaders, forwardedHeaders, }) {
|
|
9
|
+
const handlerLayer = createHttpRpcLayer(forwardedHeaders);
|
|
9
10
|
const httpApp = RpcServer.toHttpApp(SyncHttpRpc).pipe(Effect.provide(handlerLayer));
|
|
10
11
|
const webHandler = yield* httpApp.pipe(Effect.map(HttpApp.toWebHandler));
|
|
11
12
|
const response = yield* Effect.promise(() => webHandler(request)).pipe(Effect.timeout(10000));
|
|
@@ -15,16 +16,18 @@ export const createHttpRpcHandler = ({ request, responseHeaders, }) => Effect.ge
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
return response;
|
|
18
|
-
})
|
|
19
|
-
const createHttpRpcLayer =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
});
|
|
20
|
+
const createHttpRpcLayer = (forwardedHeaders) => {
|
|
21
|
+
const headers = headersRecordToMap(forwardedHeaders);
|
|
22
|
+
// TODO implement admin requests
|
|
23
|
+
return SyncHttpRpc.toLayer({
|
|
24
|
+
'SyncHttpRpc.Pull': (req) => makeEndingPullStream({ req, payload: req.payload, headers }),
|
|
25
|
+
'SyncHttpRpc.Push': (req) => Effect.gen(function* () {
|
|
26
|
+
const { ctx, env, doOptions, storeId } = yield* DoCtx;
|
|
27
|
+
const push = makePush({ payload: undefined, headers, options: doOptions, storeId, ctx, env });
|
|
28
|
+
return yield* push(req);
|
|
29
|
+
}),
|
|
30
|
+
'SyncHttpRpc.Ping': () => Effect.succeed(SyncMessage.Pong.make({})),
|
|
31
|
+
}).pipe(Layer.provideMerge(RpcServer.layerProtocolHttp({ path: '/http-rpc' })), Layer.provideMerge(RpcSerialization.layerJson));
|
|
32
|
+
};
|
|
30
33
|
//# sourceMappingURL=http-rpc-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-rpc-server.js","sourceRoot":"","sources":["../../../../src/cf-worker/do/transport/http-rpc-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"http-rpc-server.js","sourceRoot":"","sources":["../../../../src/cf-worker/do/transport/http-rpc-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,KA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O,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAEpD,gCAAgC;IAChC,OAAO,WAAW,CAAC,OAAO,CAAC;QACzB,kBAAkB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAEzF,kBAAkB,EAAE,CAAC,GAAG,EAAE,EAAE,CAC1B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAClB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,KAAK,CAAA;YACrD,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;YAE7F,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC,CAAC;QAEJ,kBAAkB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACpE,CAAC,CAAC,IAAI,CACL,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,EACtE,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAC/C,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { WsContext } from '@livestore/common-cf';
|
|
1
2
|
import { Layer, RpcServer } from '@livestore/utils/effect';
|
|
2
3
|
import { type DoCtxInput } from '../layer.ts';
|
|
3
|
-
export declare const makeRpcServer: ({ doSelf, doOptions }: Omit<DoCtxInput, "from">) => Layer.Layer<never, never, RpcServer.Protocol>;
|
|
4
|
+
export declare const makeRpcServer: ({ doSelf, doOptions }: Omit<DoCtxInput, "from">) => Layer.Layer<never, never, RpcServer.Protocol | WsContext>;
|
|
4
5
|
//# sourceMappingURL=ws-rpc-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-rpc-server.d.ts","sourceRoot":"","sources":["../../../../src/cf-worker/do/transport/ws-rpc-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"ws-rpc-server.d.ts","sourceRoot":"","sources":["../../../../src/cf-worker/do/transport/ws-rpc-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAoB,KAAK,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAA;AAI5F,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAIpD,eAAO,MAAM,aAAa,GAAI,uBAAuB,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,8DAoC5E,CAAA"}
|
|
@@ -1,21 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { UnknownError } from '@livestore/common';
|
|
2
|
+
import { WsContext } from '@livestore/common-cf';
|
|
3
|
+
import { Effect, identity, Layer, RpcServer, Schema, Stream } from '@livestore/utils/effect';
|
|
3
4
|
import { SyncWsRpc } from "../../../common/ws-rpc-schema.js";
|
|
5
|
+
import { headersRecordToMap, WebSocketAttachmentSchema } from "../../shared.js";
|
|
4
6
|
import { DoCtx } from "../layer.js";
|
|
5
7
|
import { makeEndingPullStream } from "../pull.js";
|
|
6
8
|
import { makePush } from "../push.js";
|
|
7
9
|
export const makeRpcServer = ({ doSelf, doOptions }) => {
|
|
8
|
-
// TODO implement admin requests
|
|
9
10
|
const handlersLayer = SyncWsRpc.toLayer({
|
|
10
|
-
'SyncWsRpc.Pull': (req) =>
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
'SyncWsRpc.Pull': (req) => Effect.gen(function* () {
|
|
12
|
+
const headers = yield* getForwardedHeaders;
|
|
13
|
+
return makeEndingPullStream({ req, payload: req.payload, headers }).pipe(
|
|
14
|
+
// Needed to keep the stream alive on the client side for phase 2 (i.e. not send the `Exit` stream RPC message)
|
|
15
|
+
req.live === true ? Stream.concat(Stream.never) : identity, Stream.provideLayer(DoCtx.Default({ doSelf, doOptions, from: { storeId: req.storeId } })), Stream.mapError((cause) => cause._tag === 'UnknownError' || cause._tag === 'BackendIdMismatchError'
|
|
16
|
+
? cause
|
|
17
|
+
: new UnknownError({ cause })));
|
|
18
|
+
}).pipe(Stream.unwrap),
|
|
13
19
|
'SyncWsRpc.Push': (req) => Effect.gen(function* () {
|
|
14
20
|
const { doOptions, storeId, ctx, env } = yield* DoCtx;
|
|
15
|
-
const
|
|
21
|
+
const headers = yield* getForwardedHeaders;
|
|
22
|
+
const push = makePush({ options: doOptions, storeId, payload: req.payload, headers, ctx, env });
|
|
16
23
|
return yield* push(req);
|
|
17
|
-
}).pipe(Effect.provide(DoCtx.Default({ doSelf, doOptions, from: { storeId: req.storeId } })), Effect.mapError((cause) =>
|
|
24
|
+
}).pipe(Effect.provide(DoCtx.Default({ doSelf, doOptions, from: { storeId: req.storeId } })), Effect.mapError((cause) => cause._tag === 'UnknownError' || cause._tag === 'ServerAheadError' || cause._tag === 'BackendIdMismatchError'
|
|
25
|
+
? cause
|
|
26
|
+
: new UnknownError({ cause })), Effect.tapCauseLogPretty),
|
|
18
27
|
});
|
|
19
28
|
return RpcServer.layer(SyncWsRpc).pipe(Layer.provide(handlersLayer));
|
|
20
29
|
};
|
|
30
|
+
/** Extracts forwarded headers from the WebSocket attachment */
|
|
31
|
+
const getForwardedHeaders = Effect.gen(function* () {
|
|
32
|
+
const { ws } = yield* WsContext;
|
|
33
|
+
const attachment = ws.deserializeAttachment();
|
|
34
|
+
const decoded = Schema.decodeUnknownEither(WebSocketAttachmentSchema)(attachment);
|
|
35
|
+
if (decoded._tag === 'Left') {
|
|
36
|
+
yield* Effect.logError('Failed to decode WebSocket attachment for forwarded headers', { error: decoded.left });
|
|
37
|
+
ws.close(1011, 'invalid-attachment');
|
|
38
|
+
return yield* Effect.die('Invalid WebSocket attachment (headers decode failed)');
|
|
39
|
+
}
|
|
40
|
+
const headers = headersRecordToMap(decoded.right.headers);
|
|
41
|
+
return headers;
|
|
42
|
+
});
|
|
21
43
|
//# sourceMappingURL=ws-rpc-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-rpc-server.js","sourceRoot":"","sources":["../../../../src/cf-worker/do/transport/ws-rpc-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ws-rpc-server.js","sourceRoot":"","sources":["../../../../src/cf-worker/do/transport/ws-rpc-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAmB,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAA4B,EAAE,EAAE;IAC/E,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC;QACtC,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CACxB,MAAM,CAAC,GAA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,sDAAsD,CAAC,CAAA;IAClF,CAAC;IAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACzD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAC,CAAA"}
|
|
@@ -1,20 +1,60 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UnknownError } from '@livestore/common';
|
|
2
2
|
import type { CfTypes } from '@livestore/common-cf';
|
|
3
3
|
import { Effect, Schema } from '@livestore/utils/effect';
|
|
4
4
|
import type { SearchParams } from '../common/mod.ts';
|
|
5
5
|
import { SyncMessage } from '../common/mod.ts';
|
|
6
6
|
export type Env = {};
|
|
7
|
+
/** Headers forwarded from the request to callbacks */
|
|
8
|
+
export type ForwardedHeaders = ReadonlyMap<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for forwarding request headers to DO callbacks.
|
|
11
|
+
* - `string[]`: List of header names to forward (case-insensitive)
|
|
12
|
+
* - `(request) => Record<string, string>`: Custom extraction function (sync)
|
|
13
|
+
*/
|
|
14
|
+
export type ForwardHeadersOption = readonly string[] | ((request: CfTypes.Request) => Record<string, string>);
|
|
15
|
+
/** Context passed to onPush/onPull callbacks */
|
|
16
|
+
export type CallbackContext = {
|
|
17
|
+
storeId: StoreId;
|
|
18
|
+
payload?: Schema.JsonValue;
|
|
19
|
+
/** Headers forwarded from the request (only present if `forwardHeaders` is configured) */
|
|
20
|
+
headers?: ForwardedHeaders;
|
|
21
|
+
};
|
|
7
22
|
export type MakeDurableObjectClassOptions = {
|
|
8
|
-
onPush?: (message: SyncMessage.PushRequest, context:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
onPush?: (message: SyncMessage.PushRequest, context: CallbackContext) => Effect.SyncOrPromiseOrEffect<void>;
|
|
24
|
+
onPushRes?: (message: SyncMessage.PushAck | UnknownError) => Effect.SyncOrPromiseOrEffect<void>;
|
|
25
|
+
onPull?: (message: SyncMessage.PullRequest, context: CallbackContext) => Effect.SyncOrPromiseOrEffect<void>;
|
|
26
|
+
onPullRes?: (message: SyncMessage.PullResponse | UnknownError) => Effect.SyncOrPromiseOrEffect<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Forward request headers to `onPush`/`onPull` callbacks for authentication.
|
|
29
|
+
*
|
|
30
|
+
* This enables cookie-based or header-based authentication patterns where
|
|
31
|
+
* you need access to request headers inside the Durable Object.
|
|
32
|
+
*
|
|
33
|
+
* @example Forward specific headers by name (case-insensitive)
|
|
34
|
+
* ```ts
|
|
35
|
+
* makeDurableObject({
|
|
36
|
+
* forwardHeaders: ['cookie', 'authorization'],
|
|
37
|
+
* onPush: async (message, { headers }) => {
|
|
38
|
+
* const cookie = headers?.get('cookie')
|
|
39
|
+
* const session = await validateSession(cookie)
|
|
40
|
+
* },
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Custom extraction function for derived values
|
|
45
|
+
* ```ts
|
|
46
|
+
* makeDurableObject({
|
|
47
|
+
* forwardHeaders: (request) => ({
|
|
48
|
+
* 'x-user-id': request.headers.get('x-user-id') ?? '',
|
|
49
|
+
* 'x-session': request.headers.get('cookie')?.split('session=')[1]?.split(';')[0] ?? '',
|
|
50
|
+
* }),
|
|
51
|
+
* onPush: async (message, { headers }) => {
|
|
52
|
+
* const userId = headers?.get('x-user-id')
|
|
53
|
+
* },
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
forwardHeaders?: ForwardHeadersOption;
|
|
18
58
|
/**
|
|
19
59
|
* Storage engine for event persistence.
|
|
20
60
|
* - Default: `{ _tag: 'do-sqlite' }` (Durable Object SQLite)
|
|
@@ -95,8 +135,8 @@ export declare const encodeOutgoingMessage: (a: {
|
|
|
95
135
|
readonly eventEncoded: {
|
|
96
136
|
readonly name: string;
|
|
97
137
|
readonly args: any;
|
|
98
|
-
readonly seqNum:
|
|
99
|
-
readonly parentSeqNum:
|
|
138
|
+
readonly seqNum: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
|
|
139
|
+
readonly parentSeqNum: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
|
|
100
140
|
readonly clientId: string;
|
|
101
141
|
readonly sessionId: string;
|
|
102
142
|
};
|
|
@@ -129,8 +169,8 @@ export declare const encodeIncomingMessage: (a: {
|
|
|
129
169
|
readonly batch: readonly {
|
|
130
170
|
readonly name: string;
|
|
131
171
|
readonly args: any;
|
|
132
|
-
readonly seqNum:
|
|
133
|
-
readonly parentSeqNum:
|
|
172
|
+
readonly seqNum: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
|
|
173
|
+
readonly parentSeqNum: number & import("effect/Brand").Brand<"GlobalEventSequenceNumber">;
|
|
134
174
|
readonly clientId: string;
|
|
135
175
|
readonly sessionId: string;
|
|
136
176
|
}[];
|
|
@@ -171,5 +211,10 @@ export declare const WebSocketAttachmentSchema: Schema.transform<Schema.SchemaCl
|
|
|
171
211
|
storeId: typeof Schema.String;
|
|
172
212
|
payload: Schema.optional<Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>>;
|
|
173
213
|
pullRequestIds: Schema.Array$<typeof Schema.String>;
|
|
214
|
+
headers: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.String>>;
|
|
174
215
|
}>>;
|
|
216
|
+
/** Helper to extract headers from a request based on the forwardHeaders option */
|
|
217
|
+
export declare const extractForwardedHeaders: (request: CfTypes.Request, forwardHeaders: ForwardHeadersOption | undefined) => Record<string, string> | undefined;
|
|
218
|
+
/** Convert a headers record to a ReadonlyMap */
|
|
219
|
+
export declare const headersRecordToMap: (headers: Record<string, string> | undefined) => ForwardedHeaders | undefined;
|
|
175
220
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["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,CAAA;AAGD,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,SAAS,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,eAAe,EAAE,MAAM,CAAA;KACxB,CAAA;CACF,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sBAAsB,EAAE,KAAK,CAAA;IAC7B,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CACvE;AAED,eAAO,MAAM,yBAAyB;;;;;GAUrC,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,GAClC,SAAS,OAAO,CAAC,OAAO,EACxB,gBAAgB,oBAAoB,GAAG,SAAS,KAC/C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAkB3B,CAAA;AAED,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,KAAG,gBAAgB,GAAG,SAKnG,CAAA"}
|
package/dist/cf-worker/shared.js
CHANGED
|
@@ -39,5 +39,32 @@ export const WebSocketAttachmentSchema = Schema.parseJson(Schema.Struct({
|
|
|
39
39
|
// Different for each websocket connection
|
|
40
40
|
payload: Schema.optional(Schema.JsonValue),
|
|
41
41
|
pullRequestIds: Schema.Array(Schema.String),
|
|
42
|
+
// Headers forwarded from the initial request (via forwardHeaders option)
|
|
43
|
+
headers: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.String })),
|
|
42
44
|
}));
|
|
45
|
+
/** Helper to extract headers from a request based on the forwardHeaders option */
|
|
46
|
+
export const extractForwardedHeaders = (request, forwardHeaders) => {
|
|
47
|
+
if (forwardHeaders === undefined) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (typeof forwardHeaders === 'function') {
|
|
51
|
+
return forwardHeaders(request);
|
|
52
|
+
}
|
|
53
|
+
// Array of header names - extract them case-insensitively
|
|
54
|
+
const result = {};
|
|
55
|
+
for (const name of forwardHeaders) {
|
|
56
|
+
const value = request.headers.get(name);
|
|
57
|
+
if (value !== null) {
|
|
58
|
+
result[name.toLowerCase()] = value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
62
|
+
};
|
|
63
|
+
/** Convert a headers record to a ReadonlyMap */
|
|
64
|
+
export const headersRecordToMap = (headers) => {
|
|
65
|
+
if (headers === undefined) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return new Map(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
69
|
+
};
|
|
43
70
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/cf-worker/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/cf-worker/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAgHlE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAE3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC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CACrC,OAAwB,EACxB,cAAgD,EACZ,EAAE;IACtC,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;QACzC,OAAO,cAAc,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,0DAA0D;IAC1D,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAA;QACpC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;AAC5D,CAAC,CAAA;AAED,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAA2C,EAAgC,EAAE;IAC9G,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;AAC3F,CAAC,CAAA"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { HelperTypes } from '@livestore/common-cf';
|
|
2
2
|
import { Schema } from '@livestore/utils/effect';
|
|
3
3
|
import type { CfTypes, SearchParams } from '../common/mod.ts';
|
|
4
|
-
import { type Env } from './shared.ts';
|
|
4
|
+
import { type Env, type ForwardedHeaders } from './shared.ts';
|
|
5
5
|
export type CFWorker<TEnv extends Env = Env, _T extends CfTypes.Rpc.DurableObjectBranded | undefined = undefined> = {
|
|
6
6
|
fetch: <CFHostMetada = unknown>(request: CfTypes.Request<CFHostMetada>, env: TEnv, ctx: CfTypes.ExecutionContext) => Promise<CfTypes.Response>;
|
|
7
7
|
};
|
|
8
|
+
/** Context passed to validatePayload callback */
|
|
9
|
+
export type ValidatePayloadContext = {
|
|
10
|
+
storeId: string;
|
|
11
|
+
/** Request headers (raw, not filtered by forwardHeaders) */
|
|
12
|
+
headers: ForwardedHeaders;
|
|
13
|
+
};
|
|
8
14
|
/**
|
|
9
15
|
* Options accepted by {@link makeWorker}. The Durable Object binding has to be
|
|
10
16
|
* supplied explicitly so we never fall back to deprecated defaults when Cloudflare config changes.
|
|
@@ -14,11 +20,6 @@ export type MakeWorkerOptions<TEnv extends Env = Env, TSyncPayload = Schema.Json
|
|
|
14
20
|
* Binding name of the sync Durable Object declared in wrangler config.
|
|
15
21
|
*/
|
|
16
22
|
syncBackendBinding: HelperTypes.ExtractDurableObjectKeys<TEnv>;
|
|
17
|
-
/**
|
|
18
|
-
* Validates the payload during WebSocket connection establishment.
|
|
19
|
-
* Note: This runs only at connection time, not for individual push events.
|
|
20
|
-
* For push event validation, use the `onPush` callback in the Durable Object.
|
|
21
|
-
*/
|
|
22
23
|
/**
|
|
23
24
|
* Optionally pass a schema to decode the client-provided payload into a typed object
|
|
24
25
|
* before calling {@link validatePayload}. If omitted, the raw JSON value is forwarded.
|
|
@@ -26,11 +27,23 @@ export type MakeWorkerOptions<TEnv extends Env = Env, TSyncPayload = Schema.Json
|
|
|
26
27
|
syncPayloadSchema?: Schema.Schema<TSyncPayload>;
|
|
27
28
|
/**
|
|
28
29
|
* Validates the (optionally decoded) payload during WebSocket connection establishment.
|
|
29
|
-
* If {@link syncPayloadSchema} is provided, `payload` will be of the schema
|
|
30
|
+
* If {@link syncPayloadSchema} is provided, `payload` will be of the schema's inferred type.
|
|
31
|
+
*
|
|
32
|
+
* The context includes request headers for cookie-based or header-based authentication.
|
|
33
|
+
*
|
|
34
|
+
* @example Cookie-based authentication
|
|
35
|
+
* ```ts
|
|
36
|
+
* validatePayload: async (payload, { storeId, headers }) => {
|
|
37
|
+
* const cookie = headers.get('cookie')
|
|
38
|
+
* const session = await validateSessionFromCookie(cookie)
|
|
39
|
+
* if (!session) throw new Error('Unauthorized')
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Note: This runs only at connection time, not for individual push events.
|
|
44
|
+
* For push event validation, use the `onPush` callback in the Durable Object.
|
|
30
45
|
*/
|
|
31
|
-
validatePayload?: (payload: TSyncPayload, context:
|
|
32
|
-
storeId: string;
|
|
33
|
-
}) => void | Promise<void>;
|
|
46
|
+
validatePayload?: (payload: TSyncPayload, context: ValidatePayloadContext) => void | Promise<void>;
|
|
34
47
|
/** @default false */
|
|
35
48
|
enableCORS?: boolean;
|
|
36
49
|
};
|
|
@@ -45,34 +58,21 @@ export declare const makeWorker: <TEnv extends Env = Env, TDurableObjectRpc exte
|
|
|
45
58
|
/**
|
|
46
59
|
* Handles LiveStore sync requests (e.g. with search params `?storeId=...&transport=...`).
|
|
47
60
|
*
|
|
48
|
-
* @example
|
|
61
|
+
* @example Token-based authentication
|
|
49
62
|
* ```ts
|
|
50
63
|
* const validatePayload = (payload: Schema.JsonValue | undefined, context: { storeId: string }) => {
|
|
51
|
-
* console.log(`Validating connection for store: ${context.storeId}`)
|
|
52
64
|
* if (payload?.authToken !== 'insecure-token-change-me') {
|
|
53
65
|
* throw new Error('Invalid auth token')
|
|
54
66
|
* }
|
|
55
67
|
* }
|
|
68
|
+
* ```
|
|
56
69
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* return handleSyncRequest({
|
|
64
|
-
* request,
|
|
65
|
-
* searchParams,
|
|
66
|
-
* env,
|
|
67
|
-
* ctx,
|
|
68
|
-
* syncBackendBinding: 'SYNC_BACKEND_DO',
|
|
69
|
-
* headers: {},
|
|
70
|
-
* validatePayload,
|
|
71
|
-
* })
|
|
72
|
-
* }
|
|
73
|
-
*
|
|
74
|
-
* return new Response('Invalid path', { status: 400 })
|
|
75
|
-
* }
|
|
70
|
+
* @example Cookie-based authentication
|
|
71
|
+
* ```ts
|
|
72
|
+
* const validatePayload = async (payload: Schema.JsonValue | undefined, { storeId, headers }) => {
|
|
73
|
+
* const cookie = headers.get('cookie')
|
|
74
|
+
* const session = await validateSessionFromCookie(cookie)
|
|
75
|
+
* if (!session) throw new Error('Unauthorized')
|
|
76
76
|
* }
|
|
77
77
|
* ```
|
|
78
78
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAU,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE7D,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,gBAAgB,EAAoB,MAAM,aAAa,CAAA;AAM/E,MAAM,MAAM,QAAQ,CAAC,IAAI,SAAS,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,SAAS,GAAG,SAAS,IAAI;IAClH,KAAK,EAAE,CAAC,YAAY,GAAG,OAAO,EAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EACtC,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,OAAO,CAAC,gBAA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EAC/B,0JAQC;IACD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IACtC,YAAY,EAAE,YAAY,CAAA;IAC1B,GAAG,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;IACtB,wCAAwC;IACxC,GAAG,EAAE,OAAO,CAAC,gBAAgB,CAAA;IAC7B,sDAAsD;IACtD,kBAAkB,EAAE,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,oBAAoB,CAAC,CAAA;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,GAAG,SAAS,CAAA;IACzC,eAAe,CAAC,EAAE,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,iBAAiB,CAAC,CAAA;IAC1E,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,mBAAmB,CAAC,CAAA;CAC/E,KAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAiE0B,CAAA"}
|
package/dist/cf-worker/worker.js
CHANGED
|
@@ -13,14 +13,14 @@ export const makeWorker = (options) => {
|
|
|
13
13
|
return {
|
|
14
14
|
fetch: async (request, env, _ctx) => {
|
|
15
15
|
const url = new URL(request.url);
|
|
16
|
-
const corsHeaders = options.enableCORS
|
|
16
|
+
const corsHeaders = options.enableCORS === true
|
|
17
17
|
? {
|
|
18
18
|
'Access-Control-Allow-Origin': '*',
|
|
19
19
|
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
20
20
|
'Access-Control-Allow-Headers': request.headers.get('Access-Control-Request-Headers') ?? '*',
|
|
21
21
|
}
|
|
22
22
|
: {};
|
|
23
|
-
if (request.method === 'OPTIONS' && options.enableCORS) {
|
|
23
|
+
if (request.method === 'OPTIONS' && options.enableCORS === true) {
|
|
24
24
|
return new Response(null, {
|
|
25
25
|
status: 204,
|
|
26
26
|
headers: corsHeaders,
|
|
@@ -59,37 +59,32 @@ export const makeWorker = (options) => {
|
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
+
/** Convert CF Request headers to a ForwardedHeaders map */
|
|
63
|
+
const requestHeadersToMap = (request) => {
|
|
64
|
+
const result = new Map();
|
|
65
|
+
request.headers.forEach((value, key) => {
|
|
66
|
+
result.set(key.toLowerCase(), value);
|
|
67
|
+
});
|
|
68
|
+
return result;
|
|
69
|
+
};
|
|
62
70
|
/**
|
|
63
71
|
* Handles LiveStore sync requests (e.g. with search params `?storeId=...&transport=...`).
|
|
64
72
|
*
|
|
65
|
-
* @example
|
|
73
|
+
* @example Token-based authentication
|
|
66
74
|
* ```ts
|
|
67
75
|
* const validatePayload = (payload: Schema.JsonValue | undefined, context: { storeId: string }) => {
|
|
68
|
-
* console.log(`Validating connection for store: ${context.storeId}`)
|
|
69
76
|
* if (payload?.authToken !== 'insecure-token-change-me') {
|
|
70
77
|
* throw new Error('Invalid auth token')
|
|
71
78
|
* }
|
|
72
79
|
* }
|
|
80
|
+
* ```
|
|
73
81
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* return handleSyncRequest({
|
|
81
|
-
* request,
|
|
82
|
-
* searchParams,
|
|
83
|
-
* env,
|
|
84
|
-
* ctx,
|
|
85
|
-
* syncBackendBinding: 'SYNC_BACKEND_DO',
|
|
86
|
-
* headers: {},
|
|
87
|
-
* validatePayload,
|
|
88
|
-
* })
|
|
89
|
-
* }
|
|
90
|
-
*
|
|
91
|
-
* return new Response('Invalid path', { status: 400 })
|
|
92
|
-
* }
|
|
82
|
+
* @example Cookie-based authentication
|
|
83
|
+
* ```ts
|
|
84
|
+
* const validatePayload = async (payload: Schema.JsonValue | undefined, { storeId, headers }) => {
|
|
85
|
+
* const cookie = headers.get('cookie')
|
|
86
|
+
* const session = await validateSessionFromCookie(cookie)
|
|
87
|
+
* if (!session) throw new Error('Unauthorized')
|
|
93
88
|
* }
|
|
94
89
|
* ```
|
|
95
90
|
*
|
|
@@ -97,6 +92,8 @@ export const makeWorker = (options) => {
|
|
|
97
92
|
*/
|
|
98
93
|
export const handleSyncRequest = ({ request, searchParams: { storeId, payload, transport }, env: explicitlyProvidedEnv, syncBackendBinding, headers, validatePayload, syncPayloadSchema, }) => Effect.gen(function* () {
|
|
99
94
|
if (validatePayload !== undefined) {
|
|
95
|
+
// Convert request headers to a Map for the validation context
|
|
96
|
+
const requestHeaders = requestHeadersToMap(request);
|
|
100
97
|
// Always decode with the supplied schema when present, even if payload is undefined.
|
|
101
98
|
// This ensures required payloads are enforced by the schema.
|
|
102
99
|
if (syncPayloadSchema !== undefined) {
|
|
@@ -104,19 +101,19 @@ export const handleSyncRequest = ({ request, searchParams: { storeId, payload, t
|
|
|
104
101
|
if (decodedEither._tag === 'Left') {
|
|
105
102
|
const message = decodedEither.left.toString();
|
|
106
103
|
console.error('Invalid payload (decode failed)', message);
|
|
107
|
-
return new Response(message, { status: 400, headers });
|
|
104
|
+
return new Response(message, { status: 400, ...(headers !== undefined ? { headers } : {}) });
|
|
108
105
|
}
|
|
109
|
-
const result = yield* Effect.promise(async () => validatePayload(decodedEither.right, { storeId })).pipe(UnknownError.mapToUnknownError, Effect.either);
|
|
106
|
+
const result = yield* Effect.promise(async () => validatePayload(decodedEither.right, { storeId, headers: requestHeaders })).pipe(UnknownError.mapToUnknownError, Effect.either);
|
|
110
107
|
if (result._tag === 'Left') {
|
|
111
108
|
console.error('Invalid payload (validation failed)', result.left);
|
|
112
|
-
return new Response(result.left.toString(), { status: 400, headers });
|
|
109
|
+
return new Response(result.left.toString(), { status: 400, ...(headers !== undefined ? { headers } : {}) });
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
else {
|
|
116
|
-
const result = yield* Effect.promise(async () => validatePayload(payload, { storeId })).pipe(UnknownError.mapToUnknownError, Effect.either);
|
|
113
|
+
const result = yield* Effect.promise(async () => validatePayload(payload, { storeId, headers: requestHeaders })).pipe(UnknownError.mapToUnknownError, Effect.either);
|
|
117
114
|
if (result._tag === 'Left') {
|
|
118
115
|
console.error('Invalid payload (validation failed)', result.left);
|
|
119
|
-
return new Response(result.left.toString(), { status: 400, headers });
|
|
116
|
+
return new Response(result.left.toString(), { status: 400, ...(headers !== undefined ? { headers } : {}) });
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
}
|
|
@@ -124,7 +121,7 @@ export const handleSyncRequest = ({ request, searchParams: { storeId, payload, t
|
|
|
124
121
|
if (!(syncBackendBinding in env)) {
|
|
125
122
|
return new Response(`Failed dependency: Required Durable Object binding '${syncBackendBinding}' not available`, {
|
|
126
123
|
status: 424,
|
|
127
|
-
headers,
|
|
124
|
+
...(headers !== undefined ? { headers } : {}),
|
|
128
125
|
});
|
|
129
126
|
}
|
|
130
127
|
const durableObjectNamespace = env[syncBackendBinding];
|
|
@@ -135,7 +132,7 @@ export const handleSyncRequest = ({ request, searchParams: { storeId, payload, t
|
|
|
135
132
|
if (transport === 'ws' && (upgradeHeader === null || upgradeHeader !== 'websocket')) {
|
|
136
133
|
return new Response('Durable Object expected Upgrade: websocket', {
|
|
137
134
|
status: 426,
|
|
138
|
-
headers,
|
|
135
|
+
...(headers !== undefined ? { headers } : {}),
|
|
139
136
|
});
|
|
140
137
|
}
|
|
141
138
|
return yield* Effect.promise(() => durableObject.fetch(request));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,EA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S,KAAK,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,WAAW,CAAC,EAAE,CAAC;QACpF,OAAO,IAAI,QAAQ,CAAC,4CAA4C,EAAE;YAChE,MAAM,EAAE,GAAG;YACX,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;AAClE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"do-rpc-client.d.ts","sourceRoot":"","sources":["../../../src/client/transport/do-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"do-rpc-client.d.ts","sourceRoot":"","sources":["../../../src/client/transport/do-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,mBAAmB,CAAA;AAE7D,OAAO,EAAE,KAAK,OAAO,EAA8B,MAAM,sBAAsB,CAAA;AAgB/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAIxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEtE,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,iBAAiB,EAAE,uBAAuB;CAAG;AAMjG,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,eAAe,EAAE,kBAAkB,CAAA;IACnC,2GAA2G;IAC3G,oBAAoB,EAAE;QACpB,+CAA+C;QAC/C,WAAW,EAAE,MAAM,CAAA;QACnB,sCAAsC;QACtC,eAAe,EAAE,MAAM,CAAA;KACxB,CAAA;CACF;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACvB,2CAA2C,gBAAgB,KAAG,WAAW,CAAC,sBAAsB,CAAC,YAAY,CA8GnD,CAAA;AAE7D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,kBAckD,CAAA"}
|