@substrat-run/adapter-cloudflare 0.151.0 → 0.152.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.
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Nothing in this module reaches the network or the database. It is names and shapes.
11
11
  */
12
- import { type EntityRef, type PrincipalId, type ScopeId, type TenantId } from '@substrat-run/contracts';
12
+ import { type EntityRef, type ErrorCode, type LiveRefusal, type PrincipalId, type ScopeId, type TenantId } from '@substrat-run/contracts';
13
13
  import { type CheckedWithin, type VouchedWithin } from '@substrat-run/kernel';
14
14
  /**
15
15
  * The path the coordinator fetches on the scope stub to open a subscription.
@@ -97,6 +97,16 @@ export declare function decodeLiveWithin(header: string): LiveWithin | undefined
97
97
  * one file.
98
98
  */
99
99
  export { LIVE_CLOSE, LIVE_MODE_HEADER, type LiveRefusal } from '@substrat-run/contracts';
100
+ /** `liveRefusal` for a status the taxonomy has no code for (404, 426, 501): the `about:blank` form. */
101
+ export declare function liveRefusalStatus(status: number, detail: string, mode?: LiveRefusal): Response;
102
+ /**
103
+ * A refusal that is the taxonomy's own (`forbidden`, `internal`). `internal` never carries
104
+ * its `detail` on the wire: a 500 here is this package's bug, not the client's, so the
105
+ * sentence goes to the log instead, where a coordinator/DO skew can still be told apart.
106
+ * The sentences are fixed strings naming the assertion that failed — never a value, an id
107
+ * or a header's content.
108
+ */
109
+ export declare function liveRefusal(code: ErrorCode, detail: string, mode?: LiveRefusal): Response;
100
110
  /**
101
111
  * How many live sockets one principal may hold on one scope (#938). A tab holds one per
102
112
  * feed (the desk's, and one per open conversation in ticket0's portal), and each socket is
@@ -1 +1 @@
1
- {"version":3,"file":"live-reads.d.ts","sourceRoot":"","sources":["../src/live-reads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,yBAAyB,CA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I,CAAC,EAAE,WAAW,GAAG,QAAQ,CAE9F;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAGzF;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,sBAAsB,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2HAA2H;IAC3H,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,sFAAsF;IACtF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAsB7E;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,2FAA2F;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE1D"}
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Nothing in this module reaches the network or the database. It is names and shapes.
11
11
  */
12
- import { permissionKey, substratError, } from '@substrat-run/contracts';
12
+ import { LIVE_MODE_HEADER, permissionKey, problemForStatus, PROBLEM_CONTENT_TYPE, substratError, toProblem, } from '@substrat-run/contracts';
13
13
  import { isCheckedWithin, isVouchedWithin } from '@substrat-run/kernel';
14
14
  /**
15
15
  * The path the coordinator fetches on the scope stub to open a subscription.
@@ -130,6 +130,38 @@ export function decodeLiveWithin(header) {
130
130
  * one file.
131
131
  */
132
132
  export { LIVE_CLOSE, LIVE_MODE_HEADER } from '@substrat-run/contracts';
133
+ /**
134
+ * A refusal on this surface, answered as the problem document it is (#113).
135
+ *
136
+ * The door (`host.ts`) and the scope's `fetch` (`scope-do.ts`) both refuse with a
137
+ * `Response`, because a refusal here is a fact about the connection and not a throw, so the
138
+ * media type and the `LIVE_MODE_HEADER` pairing live in one place. `mode` is the value a
139
+ * client keys its fallback on; a refusal that is nobody's fallback (the DO's own 404, a 500
140
+ * that is this package's bug) carries none. Status, sentence and header values are the
141
+ * callers' own and are unchanged from the `text/plain` answers this replaces.
142
+ */
143
+ function serveLiveRefusal(body, mode) {
144
+ return new Response(JSON.stringify(body), {
145
+ status: body.status,
146
+ headers: { 'content-type': PROBLEM_CONTENT_TYPE, ...(mode === undefined ? {} : { [LIVE_MODE_HEADER]: mode }) },
147
+ });
148
+ }
149
+ /** `liveRefusal` for a status the taxonomy has no code for (404, 426, 501): the `about:blank` form. */
150
+ export function liveRefusalStatus(status, detail, mode) {
151
+ return serveLiveRefusal(problemForStatus(status, detail), mode);
152
+ }
153
+ /**
154
+ * A refusal that is the taxonomy's own (`forbidden`, `internal`). `internal` never carries
155
+ * its `detail` on the wire: a 500 here is this package's bug, not the client's, so the
156
+ * sentence goes to the log instead, where a coordinator/DO skew can still be told apart.
157
+ * The sentences are fixed strings naming the assertion that failed — never a value, an id
158
+ * or a header's content.
159
+ */
160
+ export function liveRefusal(code, detail, mode) {
161
+ if (code === 'internal')
162
+ console.error('substrat: live-read refused:', detail);
163
+ return serveLiveRefusal(toProblem(substratError(code, detail)), mode);
164
+ }
133
165
  /**
134
166
  * How many live sockets one principal may hold on one scope (#938). A tab holds one per
135
167
  * feed (the desk's, and one per open conversation in ticket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BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAoFD,oFAAoF;AACpF,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAwkB5E;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAmBtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAOxD;AAED,gHAAgH;AAChH,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,wBAAgB,aAAa,CAC3B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,GACxD,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,CA00O7E"}
package/dist/scope-do.js CHANGED
@@ -3,7 +3,7 @@ import { SYSTEM_DOOR_MOVED } from './system-door.js';
3
3
  import { DurableObject } from 'cloudflare:workers';
4
4
  import { ATTACHMENT_ADDED, ATTACHMENT_REMOVED, attachmentRecord, domainEvent, domainEventInput, eventId, instant, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, toWireFailure, grantRefFromProof, principalId, principalBecomeCapabilityInput, scopeId as scopeIdOf, tenantId as tenantIdOf, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, MAX_PENDING_SWEEP_RUNS, SWEEP_RUNS_KIND, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, listLimitOf, pageOf, countedPageOf, requestFingerprint, substratError, errorCodeOf, assertReplayableDump, REDRAIN_BATCH, } from '@substrat-run/contracts';
5
5
  import { ulid, DO_SQL_LIMITS, unknownRoleError, createUlid, assertAllowed, ConnectionSealingKeyUnavailableError, noSealingKeyMessage, sealTo, assertReadOnlyQuery, entitlementDenial, platformRequestHistoryQuery, platformRequestOf, PLATFORM_REQUEST_COLUMNS, PLATFORM_REQUEST_REDACTION_SQL, platformRequestRedactionParams, platformRequestRedactionQuery, intentPayloadCarriesSubject, redactSubjectJobRuns, eraseSubjectFromModules, moduleErasurePlan, redactSubjectScopeText, assertRowLimit, assertRowOffset, JOB_RUN_PATCH_SQL, JOB_RUN_CLAIM_SQL, JOB_RUN_RENEW_SQL, JOB_RUN_BEGIN_SQL, JOB_RUN_MISS_SQL, JOB_RUN_MISS_SETTLE_SQL, admissionMissOutcome, JOB_LEASE_EXPIRED_NOTE, JOB_STEP_RECORD_SQL, DELIVERY_ERROR_REDACTION_SQL, REDACTED_DELIVERY_NOTE, seatScopeTuple, delegatedRevokeSql, writeExplicitTupleIn, grantEntityShapeIn, topUpEntityGrantShapes, applyScopeRoleChange, changeScopeRole, revokeScopeRoles, scopeRoleHolders, effectiveRoleGrantQuery, switchRecordedOff, switchSystemSchedules, peerGrantsStatus, systemGrantsStatus, systemScheduleState, systemSwitchedOff, denialListQuery, refusalListQuery, mapRefusalRow, denialSummaryQuery, denialTotalsQuery, DENIAL_WINDOW_QUERY, mapDenialRow, mapDenialSummaryBuckets, PermissionDenied, assertImpersonationWrites, assertModuleEnqueueableKind, impersonationStampOf, createAtomic, NotSearchable, isSearchIndexTable, searchIndexPlans, NotListable, listIndexPlans, moduleMigrations, MIGRATION_DIGEST_FENCE_DDL, MIGRATION_DIGEST_MARK_LEGACY, assertJournalDumpCoherent, assertMigrationSql, migrationDivergence, migrationFailedError, migrationSetDivergence, migrationSteps, planMigrations, listQuery, cursorOf, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, attachmentRecordOfRow, enqueueAttachmentText, reconcileAttachmentText, queueAttachmentTextBackfill, startAttachmentTextBackfill, recordAttachmentText, searchAttachments, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, assertPermissionKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, entityVersionQuery, entityVersionOf, assertIfMatch, OUTBOX_ENTITY_INDEX, SCHEDULE_STATE_DDL, SCHEDULE_STATE_REBUILD, scheduleStateHasKind, VERTICAL_EVENTS_DDL, EXPORT_HOPS_SQL, emptyImportResult, IMPORT_CURSORS_SQL, IMPORT_CURSOR_OF_SQL, OUTBOX_MARK_SQL, exportedSinceQuery, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, SYSTEM_DOOR_WAIT, ancestorsWithin, } from '@substrat-run/kernel';
6
- import { isUpgradeRequest, readSubscription, LIVE_DECIDE_ATTEMPTS, LIVE_FANOUT_LIMIT, LIVE_MODE_HEADER, LIVE_PRINCIPAL_HEADER, LIVE_SCOPE_HEADER, LIVE_SUBSCRIBE_PATH, LIVE_TENANT_HEADER, LIVE_WITHIN_HEADER, LIVE_EXPIRES_HEADER, LIVE_CLOSE, LIVE_SOCKETS_PER_PRINCIPAL, decodeLiveWithin, liveInstant, } from './live-reads.js';
6
+ import { isUpgradeRequest, readSubscription, LIVE_DECIDE_ATTEMPTS, LIVE_FANOUT_LIMIT, LIVE_PRINCIPAL_HEADER, LIVE_SCOPE_HEADER, LIVE_SUBSCRIBE_PATH, LIVE_TENANT_HEADER, LIVE_WITHIN_HEADER, LIVE_EXPIRES_HEADER, LIVE_CLOSE, LIVE_SOCKETS_PER_PRINCIPAL, decodeLiveWithin, liveInstant, liveRefusal, liveRefusalStatus, } from './live-reads.js';
7
7
  import { replyOf } from './do-reply.js';
8
8
  import { OperationQueue } from './serialization.js';
9
9
  import { assertNoWorkerdStorage, doScopedSql, doBuiltColumnsOf, doRedactionSql, doSpineSql } from './sql.js';
@@ -859,6 +859,11 @@ export function defineScopeDO(modules, bareOps) {
859
859
  // -- module registration (port of SqliteScopeHost.registerModule) ---------
860
860
  registerModule(registration) {
861
861
  const manifest = registration.manifest;
862
+ // #2412: one id, one registration — the refusal the coordinator and the pure host make, so a
863
+ // module list they would turn away cannot start here.
864
+ if (this.modules.has(manifest.id)) {
865
+ throw new Error(`module already registered: ${manifest.id}`);
866
+ }
862
867
  // #1835: the binder's own value, or nothing registers — as in the pure adapter.
863
868
  assertBoundOperations(manifest.id, registration.operations);
864
869
  // #119: refused before anything is recorded, as in the pure adapter.
@@ -960,14 +965,20 @@ export function defineScopeDO(modules, bareOps) {
960
965
  }
961
966
  this.liveTargets.set(target.entityType, target.readPermission);
962
967
  }
968
+ // #2412: a module's own handler must not be silently unbound by its own manifest. The check
969
+ // sits inside the loop, so names earlier in the list are already deleted when it throws —
970
+ // as on the other two hosts, and harmless because the constructor throw discards the instance.
971
+ const ownOps = new Set(Object.keys(registration.operations?.handlers ?? {}));
963
972
  for (const name of manifest.withdraws ?? []) {
973
+ if (ownOps.has(name)) {
974
+ throw new Error(`${manifest.id} withdraws its own operation: ${name} (a module cannot withdraw itself — just don't register it)`);
975
+ }
964
976
  this.withdrawn.set(name, manifest.id);
965
977
  this.operations.delete(name);
966
978
  }
967
979
  // #893: a schema declared for an operation this module does not bind
968
980
  // enforces nothing while reading as coverage — refused, as in the pure adapter.
969
981
  const declaredInputs = registration.operations?.inputs ?? {};
970
- const ownOps = new Set(Object.keys(registration.operations?.handlers ?? {}));
971
982
  const unbound = Object.keys(declaredInputs).filter((name) => !ownOps.has(name));
972
983
  if (unbound.length > 0) {
973
984
  throw new Error(`${manifest.id} declares operations.inputs for unbound operation(s): ` +
@@ -2275,13 +2286,10 @@ export function defineScopeDO(modules, bareOps) {
2275
2286
  if (url.pathname !== LIVE_SUBSCRIBE_PATH) {
2276
2287
  // The DO has exactly one fetch surface. Anything else reaching here is a
2277
2288
  // coordinator bug, and a 404 says so without guessing at an intent.
2278
- return new Response('this scope has no such surface', { status: 404 });
2289
+ return liveRefusalStatus(404, 'this scope has no such surface');
2279
2290
  }
2280
2291
  if (!isUpgradeRequest(request)) {
2281
- return new Response('live reads are a WebSocket surface', {
2282
- status: 426,
2283
- headers: { [LIVE_MODE_HEADER]: 'not-an-upgrade' },
2284
- });
2292
+ return liveRefusalStatus(426, 'live reads are a WebSocket surface', 'not-an-upgrade');
2285
2293
  }
2286
2294
  const principal = request.headers.get(LIVE_PRINCIPAL_HEADER);
2287
2295
  const tenantId = request.headers.get(LIVE_TENANT_HEADER);
@@ -2291,9 +2299,7 @@ export function defineScopeDO(modules, bareOps) {
2291
2299
  // cannot be evaluated, and the only safe thing to do with a channel we cannot
2292
2300
  // filter is to refuse to open it. 500, not 400: the caller is the coordinator
2293
2301
  // in this same package, so a missing assertion is OUR bug, not the client's.
2294
- return new Response('live reads require an asserted principal, tenant and scope', {
2295
- status: 500,
2296
- });
2302
+ return liveRefusal('internal', 'live reads require an asserted principal, tenant and scope');
2297
2303
  }
2298
2304
  // A narrowing the coordinator sent but this end cannot read is refused, never
2299
2305
  // dropped: dropping it would open the whole scope's feed — to a vouched
@@ -2301,13 +2307,13 @@ export function defineScopeDO(modules, bareOps) {
2301
2307
  const withinHeader = request.headers.get(LIVE_WITHIN_HEADER);
2302
2308
  const within = withinHeader === null ? undefined : decodeLiveWithin(withinHeader);
2303
2309
  if (withinHeader !== null && !within) {
2304
- return new Response('live reads: unreadable within narrowing', { status: 500 });
2310
+ return liveRefusal('internal', 'live reads: unreadable within narrowing');
2305
2311
  }
2306
2312
  // The same for an expiry: dropping it would keep the socket open past its session.
2307
2313
  const expiresHeader = request.headers.get(LIVE_EXPIRES_HEADER);
2308
2314
  const expiresAt = expiresHeader === null ? undefined : liveInstant(expiresHeader);
2309
2315
  if (expiresHeader !== null && !expiresAt) {
2310
- return new Response('live reads: unreadable expiry', { status: 500 });
2316
+ return liveRefusal('internal', 'live reads: unreadable expiry');
2311
2317
  }
2312
2318
  // A subscriber arriving before the scope's migrations have run would be told
2313
2319
  // about events against a schema it cannot read back through. Same gate every
@@ -2331,10 +2337,7 @@ export function defineScopeDO(modules, bareOps) {
2331
2337
  const expired = expiresAt !== undefined && expiresAt <= new Date().toISOString();
2332
2338
  if (expired ||
2333
2339
  (within?.checked !== undefined && !(await this.mayWatchRoot(() => this.liveContext(subscriber), within)))) {
2334
- return new Response('live reads: the subscriber may not watch this root', {
2335
- status: 403,
2336
- headers: { [LIVE_MODE_HEADER]: 'forbidden' },
2337
- });
2340
+ return liveRefusal('forbidden', 'live reads: the subscriber may not watch this root', 'forbidden');
2338
2341
  }
2339
2342
  const pair = new WebSocketPair();
2340
2343
  const [client, server] = Object.values(pair);