orez-sync-cf-host 0.5.17 → 0.5.19
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 +140 -10
- package/package.json +15 -4
- package/src/bun-wasm-loader.ts +16 -0
- package/src/config.ts +32 -0
- package/src/generated/sync_wasm.d.ts +37 -2
- package/src/generated/sync_wasm.js +100 -2
- package/src/generated/sync_wasm_bg.wasm +0 -0
- package/src/harness-config.ts +105 -1
- package/src/harness-worker.ts +22 -2
- package/src/host.ts +498 -179
- package/src/index.ts +26 -1
- package/src/ingest-harness-worker.ts +172 -6
- package/src/mutation-error.ts +28 -0
- package/src/platform-probe-worker.ts +122 -9
- package/src/post-commit.ts +40 -0
- package/src/query-compiler.ts +16 -0
- package/src/sql-storage-adapter.ts +88 -19
- package/src/transaction-query.ts +494 -0
- package/src/types.ts +39 -17
- package/src/wasm-platform.ts +10 -0
- package/src/wasm.ts +34 -0
- package/src/write-safeguards.ts +14 -15
package/src/harness-worker.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { harnessConfig } from './harness-config.js'
|
|
1
|
+
import { harnessConfig, mintHarnessWakeToken } from './harness-config.js'
|
|
2
2
|
import { createSyncDurableObject, createSyncWorker } from './index.js'
|
|
3
3
|
|
|
4
4
|
import type { SyncHostEnv } from './index.js'
|
|
@@ -8,6 +8,26 @@ interface Env extends SyncHostEnv {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const config = harnessConfig<Env>()
|
|
11
|
+
const syncWorker = createSyncWorker(config)
|
|
11
12
|
|
|
12
13
|
export const SyncDurableObject = createSyncDurableObject(config)
|
|
13
|
-
export default
|
|
14
|
+
export default {
|
|
15
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
16
|
+
const url = new URL(request.url)
|
|
17
|
+
const namespace = config.namespace(request)
|
|
18
|
+
const route = url.pathname.split('/').slice(2).join('/')
|
|
19
|
+
if (namespace && route === 'auth/wake-token') {
|
|
20
|
+
const claims = await config.authenticate(request, env)
|
|
21
|
+
if (!claims) {
|
|
22
|
+
return Response.json({ error: 'missing authentication' }, { status: 401 })
|
|
23
|
+
}
|
|
24
|
+
if (!env.ADMIN_KEY) {
|
|
25
|
+
return Response.json({ error: 'wake token minting unavailable' }, { status: 503 })
|
|
26
|
+
}
|
|
27
|
+
return Response.json(
|
|
28
|
+
await mintHarnessWakeToken(namespace, claims.userID, env.ADMIN_KEY)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
return syncWorker.fetch!(request, env, ctx)
|
|
32
|
+
},
|
|
33
|
+
} satisfies ExportedHandler<Env>
|