deepspace 0.9.1 → 0.9.2

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/worker.d.ts CHANGED
@@ -2540,6 +2540,18 @@ declare function handleAwarenessMessage(awareness: Awareness, data: Uint8Array):
2540
2540
  */
2541
2541
  declare function getMessageType(data: Uint8Array): number;
2542
2542
 
2543
+ /** First source migration required by the canonical app identity cutover. */
2544
+ declare const CANONICAL_APP_IDENTITY_MIGRATION_ID = "2026-08-canonical-app-identity-wire";
2545
+ type AppMigrationIdsValidation = {
2546
+ valid: true;
2547
+ ids: string[];
2548
+ } | {
2549
+ valid: false;
2550
+ reason: string;
2551
+ };
2552
+ /** Validate the small, provider-neutral migration manifest shipped with an app bundle. */
2553
+ declare function validateAppMigrationIds(value: unknown): AppMigrationIdsValidation;
2554
+
2543
2555
  /**
2544
2556
  * Wildcard-aware CORS origin matching for the platform workers.
2545
2557
  *
@@ -4882,4 +4894,4 @@ interface AppLogsResponse {
4882
4894
  declare const APP_LOG_EVENT_KEYS: readonly ["id", "timestamp", "level", "eventType", "message", "source", "outcome", "request", "exception"];
4883
4895
  type AppLogEventKey = (typeof APP_LOG_EVENT_KEYS)[number];
4884
4896
 
4885
- export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, APP_LOG_EVENT_KEYS, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, type BaseMessage, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CLIENT_LOG_MARKER, CONVERSATION_SCHEMAS, COST_RATES, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type ClientErrorKind, type ClientErrorReport, type ClientMessage, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, type ConnectionAttachment, type ConvMemberData, type ConvMessageData, type ConvReactionData, type ConvReadCursorData, type ConvVoteData, type ConversationStateData, type CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DirectoryCommunityData, type DirectoryConversationData, type DirectoryMembershipData, type DirectoryPostData, type DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, GLOBAL_DO_TYPES, GLOBAL_DO_TYPE_NAMES, type GameInput, GameRoom, type GameRoomConfig, type GetActionData, type GlobalDOType, type HandlerContext, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, LOG_LEVELS, type LogLevel, MESSAGES_SCHEMA, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MessageHandlers, type MsgType, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type ProtocolMessage, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESOURCE_ID_RE, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, RegistryClientError, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, STRICT_APP_ID_RE, SYSTEM_COLLECTIONS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type ServerMessage, type SharedConnection, type StoredRecord, type Summarizer, type SyncResult, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, USERS_COLUMNS, type User, type UserAttachment, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, capToolResultSize, captureScreenshot, checkFieldPermissions, clientBuild, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDecoder, createDeepSpaceAI, createDeepSpaceAuth, createEncoder, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, enqueueJob, getChat, getGlobalDOSchemas, getGlobalDOType, getMessageType, getRolePermissions, handleAwarenessMessage, handleClientErrorReport, handleSyncMessage, hasContent, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, readVarUint, readVarUint8Array, registerClientErrorRoute, registryErrorJson, registryStub, resolveAppName, resolveColumn, rowToData, runMigrations, serverBuild, timingSafeEqualHex, timingSafeEqualStrings, toUint8Array, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema, writeVarUint, writeVarUint8Array };
4897
+ export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_ID_RE, APP_LOG_EVENT_KEYS, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, Awareness, type AwarenessState, type AwarenessStates, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, type BaseMessage, BaseRoom, CANONICAL_APP_IDENTITY_MIGRATION_ID, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CLIENT_LOG_MARKER, CONVERSATION_SCHEMAS, COST_RATES, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type ClientErrorKind, type ClientErrorReport, type ClientMessage, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, type ConnectionAttachment, type ConvMemberData, type ConvMessageData, type ConvReactionData, type ConvReadCursorData, type ConvVoteData, type ConversationStateData, type CronContext, type CronExecution, CronRoom, type CronRoomConfig, type CronTask, type CustomBinding, type CustomBindingManifest, DEFAULT_CONTEXT_CONFIG, DEFAULT_DO_MANIFEST, DEFAULT_QUERY_LIMIT, DEPLOYED_APPS_DEFAULTS, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DeepSpaceAIEnv, type DeepSpaceAIOptions, type DeepSpaceAuth, type DeepSpaceAuthConfig, type DirectoryCommunityData, type DirectoryConversationData, type DirectoryMembershipData, type DirectoryPostData, type DoMigrationDirective, type DoMigrationPlan, type ExistingDOBinding, GLOBAL_DO_TYPES, GLOBAL_DO_TYPE_NAMES, type GameInput, GameRoom, type GameRoomConfig, type GetActionData, type GlobalDOType, type HandlerContext, type Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, LOG_LEVELS, type LogLevel, MESSAGES_SCHEMA, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MessageHandlers, type MsgType, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type ProtocolMessage, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, REGISTRY_INSTANCE, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, RESOURCE_ID_RE, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_DEFAULT, RecordRoom, type RecordRoomConfig, RegistryClientError, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, STRICT_APP_ID_RE, SYSTEM_COLLECTIONS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotResult, type ServerMessage, type SharedConnection, type StoredRecord, type Summarizer, type SyncResult, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, USERS_COLUMNS, type User, type UserAttachment, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, buildCronContext, buildTableSelect, buildUiParts, callRegistry, canCreate, canDelete, canRead, canUpdate, capToolResultSize, captureScreenshot, checkFieldPermissions, clientBuild, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDecoder, createDeepSpaceAI, createDeepSpaceAuth, createEncoder, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, enqueueJob, getChat, getGlobalDOSchemas, getGlobalDOType, getMessageType, getRolePermissions, handleAwarenessMessage, handleClientErrorReport, handleSyncMessage, hasContent, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, matchOrigin, meterAi, meterUsage, meterVectorize, noopPermissionContext, parseQuotaLimit, platformCorsPatterns, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, readVarUint, readVarUint8Array, registerClientErrorRoute, registryErrorJson, registryStub, resolveAppName, resolveColumn, rowToData, runMigrations, serverBuild, timingSafeEqualHex, timingSafeEqualStrings, toUint8Array, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppMigrationIds, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema, writeVarUint, writeVarUint8Array };
package/dist/worker.js CHANGED
@@ -574,9 +574,12 @@ function lintSchema(schema) {
574
574
  }
575
575
  if (schema.ownerField) {
576
576
  const col = schema.columns.find((c) => c.name === schema.ownerField);
577
- if (col && !col.userBound) {
577
+ const spoofableRoles = Object.entries(schema.permissions).filter(
578
+ ([role, permissions]) => role !== "owner" && role !== "admin" && permissions.create === true
579
+ ).map(([role]) => role);
580
+ if (col && !col.userBound && spoofableRoles.length > 0) {
578
581
  warnings.push(
579
- `[${schema.name}] ownerField is '${schema.ownerField}' but that column is not marked userBound: true. A client can create a row with someone else's id in this field, bypassing 'own' permission checks. Add userBound: true (and ideally immutable: true) to the column.`
582
+ `[${schema.name}] ownerField is '${schema.ownerField}' but that column is not marked userBound: true. Client role(s) ${spoofableRoles.join(", ")} can create a row with someone else's id in this field, bypassing 'own' permission checks. Add userBound: true (and ideally immutable: true) to the column.`
580
583
  );
581
584
  }
582
585
  }
@@ -5425,8 +5428,18 @@ var CHANNELS_SCHEMA = {
5425
5428
  columns: [
5426
5429
  { name: "name", storage: "text", interpretation: "plain" },
5427
5430
  { name: "description", storage: "text", interpretation: "plain" },
5428
- { name: "type", storage: "text", interpretation: { kind: "select", options: ["public", "private", "dm"] } },
5429
- { name: "createdBy", storage: "text", interpretation: "plain" },
5431
+ {
5432
+ name: "type",
5433
+ storage: "text",
5434
+ interpretation: { kind: "select", options: ["public", "private", "dm"] }
5435
+ },
5436
+ {
5437
+ name: "createdBy",
5438
+ storage: "text",
5439
+ interpretation: "plain",
5440
+ userBound: true,
5441
+ immutable: true
5442
+ },
5430
5443
  { name: "archived", storage: "number", interpretation: { kind: "boolean" } }
5431
5444
  ],
5432
5445
  ownerField: "createdBy",
@@ -5441,7 +5454,13 @@ var MESSAGES_SCHEMA = {
5441
5454
  columns: [
5442
5455
  { name: "channelId", storage: "text", interpretation: "plain" },
5443
5456
  { name: "content", storage: "text", interpretation: "plain" },
5444
- { name: "authorId", storage: "text", interpretation: "plain" },
5457
+ {
5458
+ name: "authorId",
5459
+ storage: "text",
5460
+ interpretation: "plain",
5461
+ userBound: true,
5462
+ immutable: true
5463
+ },
5445
5464
  { name: "parentMessageId", storage: "text", interpretation: "plain" },
5446
5465
  { name: "edited", storage: "number", interpretation: { kind: "boolean" } },
5447
5466
  { name: "editedAt", storage: "text", interpretation: { kind: "datetime" } },
@@ -5463,7 +5482,7 @@ var REACTIONS_SCHEMA = {
5463
5482
  { name: "messageId", storage: "text", interpretation: "plain" },
5464
5483
  { name: "channelId", storage: "text", interpretation: "plain" },
5465
5484
  { name: "emoji", storage: "text", interpretation: "plain" },
5466
- { name: "userId", storage: "text", interpretation: "plain" }
5485
+ { name: "userId", storage: "text", interpretation: "plain", userBound: true, immutable: true }
5467
5486
  ],
5468
5487
  ownerField: "userId",
5469
5488
  uniqueOn: ["messageId", "emoji", "userId"],
@@ -5477,7 +5496,7 @@ var CHANNEL_MEMBERS_SCHEMA = {
5477
5496
  name: "channel-members",
5478
5497
  columns: [
5479
5498
  { name: "channelId", storage: "text", interpretation: "plain" },
5480
- { name: "userId", storage: "text", interpretation: "plain" },
5499
+ { name: "userId", storage: "text", interpretation: "plain", userBound: true, immutable: true },
5481
5500
  { name: "joinedAt", storage: "text", interpretation: { kind: "datetime" } }
5482
5501
  ],
5483
5502
  ownerField: "userId",
@@ -5491,10 +5510,33 @@ var CHANNEL_MEMBERS_SCHEMA = {
5491
5510
  var CHANNEL_INVITATIONS_SCHEMA = {
5492
5511
  name: "channel-invitations",
5493
5512
  columns: [
5494
- { name: "channelId", storage: "text", interpretation: "plain", required: true, immutable: true },
5495
- { name: "invitedUserId", storage: "text", interpretation: "plain", required: true, immutable: true },
5496
- { name: "invitedBy", storage: "text", interpretation: "plain", userBound: true, immutable: true },
5497
- { name: "status", storage: "text", interpretation: { kind: "select", options: ["pending", "accepted", "declined"] }, required: true }
5513
+ {
5514
+ name: "channelId",
5515
+ storage: "text",
5516
+ interpretation: "plain",
5517
+ required: true,
5518
+ immutable: true
5519
+ },
5520
+ {
5521
+ name: "invitedUserId",
5522
+ storage: "text",
5523
+ interpretation: "plain",
5524
+ required: true,
5525
+ immutable: true
5526
+ },
5527
+ {
5528
+ name: "invitedBy",
5529
+ storage: "text",
5530
+ interpretation: "plain",
5531
+ userBound: true,
5532
+ immutable: true
5533
+ },
5534
+ {
5535
+ name: "status",
5536
+ storage: "text",
5537
+ interpretation: { kind: "select", options: ["pending", "accepted", "declined"] },
5538
+ required: true
5539
+ }
5498
5540
  ],
5499
5541
  uniqueOn: ["channelId", "invitedUserId"],
5500
5542
  permissions: {
@@ -5507,7 +5549,7 @@ var READ_RECEIPTS_SCHEMA = {
5507
5549
  name: "read-receipts",
5508
5550
  columns: [
5509
5551
  { name: "channelId", storage: "text", interpretation: "plain" },
5510
- { name: "userId", storage: "text", interpretation: "plain" },
5552
+ { name: "userId", storage: "text", interpretation: "plain", userBound: true, immutable: true },
5511
5553
  { name: "lastReadAt", storage: "text", interpretation: { kind: "datetime" } }
5512
5554
  ],
5513
5555
  ownerField: "userId",
@@ -5951,6 +5993,35 @@ var RESERVED_COLLECTION_NAMES = new Set(
5951
5993
  GLOBAL_DO_TYPES.flatMap((t) => t.schemas.map((s) => s.name))
5952
5994
  );
5953
5995
 
5996
+ // src/shared/protocol/app-migrations.ts
5997
+ var APP_MIGRATION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/;
5998
+ var MAX_APP_MIGRATION_IDS = 256;
5999
+ var CANONICAL_APP_IDENTITY_MIGRATION_ID = "2026-08-canonical-app-identity-wire";
6000
+ function validateAppMigrationIds(value) {
6001
+ if (!Array.isArray(value)) {
6002
+ return { valid: false, reason: "app migrations must be a JSON string array" };
6003
+ }
6004
+ if (value.length > MAX_APP_MIGRATION_IDS) {
6005
+ return {
6006
+ valid: false,
6007
+ reason: `app migrations cannot contain more than ${MAX_APP_MIGRATION_IDS} entries`
6008
+ };
6009
+ }
6010
+ const ids = [];
6011
+ const seen = /* @__PURE__ */ new Set();
6012
+ for (const valueId of value) {
6013
+ if (typeof valueId !== "string" || !APP_MIGRATION_ID_RE.test(valueId)) {
6014
+ return { valid: false, reason: `invalid app migration id: ${String(valueId)}` };
6015
+ }
6016
+ if (seen.has(valueId)) {
6017
+ return { valid: false, reason: `duplicate app migration id: ${valueId}` };
6018
+ }
6019
+ seen.add(valueId);
6020
+ ids.push(valueId);
6021
+ }
6022
+ return { valid: true, ids };
6023
+ }
6024
+
5954
6025
  // src/server/utils/cors.ts
5955
6026
  function matchOrigin(origin, patterns) {
5956
6027
  if (!origin) return null;
@@ -7569,6 +7640,7 @@ export {
7569
7640
  BASE_USERS_SCHEMA,
7570
7641
  BUILT_IN_TOOLS,
7571
7642
  BaseRoom,
7643
+ CANONICAL_APP_IDENTITY_MIGRATION_ID,
7572
7644
  CHANNELS_SCHEMA,
7573
7645
  CHANNEL_INVITATIONS_SCHEMA,
7574
7646
  CHANNEL_MEMBERS_SCHEMA,
@@ -7703,6 +7775,7 @@ export {
7703
7775
  turnsToCoreMessages,
7704
7776
  unwrapToolOutput,
7705
7777
  updateChat,
7778
+ validateAppMigrationIds,
7706
7779
  validateAppName,
7707
7780
  validateBindingManifest,
7708
7781
  validateDoManifest,