deepspace 0.30.1 → 0.31.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.
package/dist/index.d.ts CHANGED
@@ -1371,6 +1371,10 @@ declare const BUILD_INJECTED_APP_ID_MIGRATION_ID = "2026-08-build-injected-app-i
1371
1371
  * session has none) instead of crashing on a non-null assertion, and the
1372
1372
  * file states the trust model actions run under. */
1373
1373
  declare const ACTION_ROUTES_BEARER_GUARD_MIGRATION_ID = "2026-08-action-routes-bearer-guard";
1374
+ /** The files proxy identifies a header-less same-origin read (an `<img>`,
1375
+ * `<audio>`, or `<video>` load) by the app-origin session cookie, so private
1376
+ * file URLs render for the signed-in user without tokens or signed URLs. */
1377
+ declare const FILES_SESSION_COOKIE_READS_MIGRATION_ID = "2026-09-files-session-cookie-reads";
1374
1378
  type AppMigrationIdsValidation = {
1375
1379
  valid: true;
1376
1380
  ids: string[];
@@ -3503,9 +3507,12 @@ declare function toConnectionStatus(queryStatus: string): ConnectionStatus;
3503
3507
  * request-size accident. Callers do nothing differently either way.
3504
3508
  *
3505
3509
  * Two scopes are supported via the `scope` option:
3506
- * - `'self'` (default): per-user storage. Reads require auth.
3510
+ * - `'self'` (default): per-user storage. Reads are private to the owner:
3511
+ * the URL works in `<img>`/`<audio>`/`<video>` for the signed-in user of
3512
+ * this origin (the session cookie identifies the load), and for nobody
3513
+ * else.
3507
3514
  * - `'app'`: app-wide storage. Reads are public — the upload URL works
3508
- * directly as an `<img src>`. Use for avatars, logos, etc.
3515
+ * for anyone, embedded anywhere. Use for logos, shared assets, etc.
3509
3516
  *
3510
3517
  * @example
3511
3518
  * ```tsx
@@ -3665,9 +3672,12 @@ interface UseR2FilesReturn {
3665
3672
  /**
3666
3673
  * Build a plain URL for a file. Accepts an R2FileInfo or a raw key string.
3667
3674
  *
3668
- * **Note**: This URL has no auth token attached. It works for `'app'`-scope
3669
- * files (which are publicly readable) but not for `'self'`-scope files —
3670
- * those require an Authorization header, so use `readFile` / `downloadFile`.
3675
+ * No token travels in the URL. An `'app'`-scope URL is readable by anyone.
3676
+ * A `'self'`-scope URL renders in `<img>`/`<audio>`/`<video>` for the
3677
+ * signed-in user on this origin only (see {@link R2Scope}); showing one
3678
+ * user's private file to another user is app-level authorization, not
3679
+ * something this URL can grant. Use `readFile` / `downloadFile` for the
3680
+ * bytes in code.
3671
3681
  */
3672
3682
  getUrl: (fileOrKey: R2FileInfo | string) => string;
3673
3683
  /** Whether an upload is currently in progress. */
@@ -3677,12 +3687,15 @@ interface UseR2FilesReturn {
3677
3687
  * Scope controls where files live and who can read them:
3678
3688
  *
3679
3689
  * - `'self'` (default) — `apps/<app>/users/<userId>/…`. Per-user storage.
3680
- * Reads require the caller's auth token; not usable from a plain `<img>`
3681
- * or unauthenticated browser request.
3690
+ * Reads need the caller's bearer token, or — for a plain `<img>`,
3691
+ * `<audio>`, or `<video>` load from this origin — the signed-in user's
3692
+ * session cookie. Nobody else can read the URL, and it cannot be
3693
+ * embedded from another origin; browsers that send no `Sec-Fetch-Site`
3694
+ * (Safari before 16.4) and cross-site links receive 401 by design.
3682
3695
  * - `'app'` — `apps/<app>/…`. Shared by everyone in the app. Reads are
3683
- * public (no auth header needed), so the upload URL works directly as
3684
- * an `<img src>`. Use this for avatars, logos, attachments, and other
3685
- * assets meant to be embedded in pages.
3696
+ * public (no auth at all), so the upload URL works as an `<img src>`
3697
+ * anywhere. Use this for logos, attachments, and other assets meant to
3698
+ * be embedded in pages for everyone.
3686
3699
  *
3687
3700
  * Uploads under `'app'` still require a signed-in user.
3688
3701
  */
@@ -3961,7 +3974,8 @@ declare function useIsDarkTheme(): boolean;
3961
3974
  * send the bare slug with no `message` at all, e.g. 409
3962
3975
  * `{ error: 'owner_connect_not_ready' }`). Consumers must never show the slug
3963
3976
  * to a person or make an agent parse the sentence — this module separates the
3964
- * two once, for the integration client, the billing hooks, and the CLI.
3977
+ * two once, for the integration client, server actions, billing hooks, and the
3978
+ * CLI.
3965
3979
  */
3966
3980
  /** One structured validation issue (Zod shape) from a `validation_failed` response. */
3967
3981
  interface ApiErrorIssue {
@@ -4649,4 +4663,4 @@ declare const ACCOUNT_STORAGE_LIMIT_BYTES: {
4649
4663
  declare function storageLimitForTier(tier: string | null | undefined): number;
4650
4664
  declare function formatBytes(bytes: number): string;
4651
4665
 
4652
- export { ACCOUNT_STORAGE_LIMIT_BYTES, ACTION_ROUTES_BEARER_GUARD_MIGRATION_ID, ACTION_TOOLS_DELETE_WHERE_MIGRATION_ID, ANONYMOUS_USER_ID_PREFIX, APP_LOG_EVENT_KEYS, ASYNC_RESOURCE_DEFAULTS, type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, type ApiErrorIssue, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AsyncResourceDefaults, type AsyncResourceState, type AsyncResourceStatus, AuthGate, type AuthGateProps, AuthOverlay, Awareness, type AwarenessState, type AwarenessStates, BUILD_INJECTED_APP_ID_MIGRATION_ID, type BaseMessage, type CanvasShapeClient, type Channel, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, type ClientMessage, type CollectionSchema, type ConnectionAttachment, type ConnectionStatus, type CronHistoryEntry, type CronMutationResult, type CronTaskState, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIProvider, type DeepSpaceAgentProfile, type DeepSpaceAgentProfileId, type DeepSpaceAgentSupport, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, type DeriveLoadStateInput, ENV, type Environment, type FileAttachment, type GroupedReaction, GuestBanner, type HandlerContext, type IntegrationResponse, type JobStatusView, type JobView, LOG_LEVELS, type LoadState, type LoadStateAuthInput, type LoadStateStatusInput, type LogLevel, MAX_LOG_TEXT_LENGTH, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type Message, type MessageHandlers, type MsgType, type NormalizedApiError, type PagedResourceFetchArgs, type PagedResourcePage, type PagedResourceState, type PagedResourceStatus, type PlanInfo, PlatformApiError, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2FileListPage, type R2Scope, type R2UploadResult, RECORD_NOT_FOUND, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordRoomNotReadyError, RecordScope, type RequestOptions, type ResolvedDeepSpaceAgentModel, type Role, type RoomUser, SECURE_ROOM_BOUNDARIES_MIGRATION_ID, type ScopeEntry, ScopeRegistryProvider, type ServerMessage, SignedIn, SignedOut, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, type SyncResult, type UseAsyncResourceOptions, type UseAuthProfileReadyOptions, type UseAuthStatusOptions, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseJobsResult, type UsePagedResourceOptions, type UsePresenceRoomResult, type UseR2FilesReturn, type UseVoiceAgentOptions, type UseVoiceAgentResult, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, type VoiceStatus, type VoiceTranscriptEntry, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, type WriteError, applyDeepSpaceTheme, applyUIThemeTokens, authClient, canAutoLoadPagedResource, clampPagedResourceItems, clearAuthToken, clearDeepSpaceTheme, clientBuild, createDecoder, createEncoder, decodeAiStreamChunk, deriveLoadState, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatBytes, formatFileSize, getApiUrl, getAuthToken, getAuthUrl, getDeepSpaceAIModel, getEnvironmentConfig, getMessageType, getPagedResourceCooldownMs, getPlatformWorkerUrl, getUserColor, handleAwarenessMessage, handleSyncMessage, hasContent, integration, isAnonymousUserId, isAsyncResourceSlow, isDarkColor, isImageFile, isLocalDev, isProduction, isWriterRole, listDeepSpaceAgentModels, logEventText, loggableError, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, resetEnvironmentCache, resolveDeepSpaceAgentModel, serverBuild, signIn, signOut, storageLimitForTier, toConnectionStatus, toUint8Array, truncateLogText, useAsyncResource, useAuth, useAuthProfileReady, useAuthStatus, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCronMonitor, useDisplayName, useIsDarkTheme, useJobs, useMessages, useMutations, usePagedResource, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useUser, useUserLookup, useUsers, useVoiceAgent, useYjsField, useYjsRoom, useYjsText, validateAppMigrationIds, writeVarUint, writeVarUint8Array };
4666
+ export { ACCOUNT_STORAGE_LIMIT_BYTES, ACTION_ROUTES_BEARER_GUARD_MIGRATION_ID, ACTION_TOOLS_DELETE_WHERE_MIGRATION_ID, ANONYMOUS_USER_ID_PREFIX, APP_LOG_EVENT_KEYS, ASYNC_RESOURCE_DEFAULTS, type AdHocChargeOpts, type AiStreamAction, type AiStreamChunk, type ApiErrorIssue, type AppLogEvent, type AppLogEventKey, type AppLogsResponse, type AppMigrationIdsValidation, type AsyncResourceDefaults, type AsyncResourceState, type AsyncResourceStatus, AuthGate, type AuthGateProps, AuthOverlay, Awareness, type AwarenessState, type AwarenessStates, BUILD_INJECTED_APP_ID_MIGRATION_ID, type BaseMessage, type CanvasShapeClient, type Channel, type ChannelMember, type ChargeOnceOpts, type ChargeOnceResult, type ClientMessage, type CollectionSchema, type ConnectionAttachment, type ConnectionStatus, type CronHistoryEntry, type CronMutationResult, type CronTaskState, DEEPSPACE_AGENT_PROFILES, DEEPSPACE_AI_DEFAULTS, DEEPSPACE_AI_MODELS, DEEPSPACE_MODEL_CATALOG_PROVENANCE, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, type DeepSpaceAIModel, type DeepSpaceAIModelId, type DeepSpaceAIProvider, type DeepSpaceAgentProfile, type DeepSpaceAgentProfileId, type DeepSpaceAgentSupport, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, type DeriveLoadStateInput, ENV, type Environment, FILES_SESSION_COOKIE_READS_MIGRATION_ID, type FileAttachment, type GroupedReaction, GuestBanner, type HandlerContext, type IntegrationResponse, type JobStatusView, type JobView, LOG_LEVELS, type LoadState, type LoadStateAuthInput, type LoadStateStatusInput, type LogLevel, MAX_LOG_TEXT_LENGTH, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type Message, type MessageHandlers, type MsgType, type NormalizedApiError, type PagedResourceFetchArgs, type PagedResourcePage, type PagedResourceState, type PagedResourceStatus, type PlanInfo, PlatformApiError, type PresencePeerClient, PricingTable, type PricingTablePlan, type PricingTablePrice, type ProductChargeOpts, type ProtocolMessage, type Purchase, type Query, type R2FileInfo, type R2FileListPage, type R2Scope, type R2UploadResult, RECORD_NOT_FOUND, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordRoomNotReadyError, RecordScope, type RequestOptions, type ResolvedDeepSpaceAgentModel, type Role, type RoomUser, SECURE_ROOM_BOUNDARIES_MIGRATION_ID, type ScopeEntry, ScopeRegistryProvider, type ServerMessage, SignedIn, SignedOut, type SubscribeOpts, type SubscribeResult, type SubscriptionState, type SubscriptionStatus, type SyncResult, type UseAsyncResourceOptions, type UseAuthProfileReadyOptions, type UseAuthStatusOptions, type UseCanvasResult, type UseCheckoutOpts, type UseCronMonitorResult, type UseJobsResult, type UsePagedResourceOptions, type UsePresenceRoomResult, type UseR2FilesReturn, type UseVoiceAgentOptions, type UseVoiceAgentResult, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, type VoiceStatus, type VoiceTranscriptEntry, WORKER_OWNED_NOT_FOUND_MIGRATION_ID, type WriteError, applyDeepSpaceTheme, applyUIThemeTokens, authClient, canAutoLoadPagedResource, clampPagedResourceItems, clearAuthToken, clearDeepSpaceTheme, clientBuild, createDecoder, createEncoder, decodeAiStreamChunk, deriveLoadState, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatBytes, formatFileSize, getApiUrl, getAuthToken, getAuthUrl, getDeepSpaceAIModel, getEnvironmentConfig, getMessageType, getPagedResourceCooldownMs, getPlatformWorkerUrl, getUserColor, handleAwarenessMessage, handleSyncMessage, hasContent, integration, isAnonymousUserId, isAsyncResourceSlow, isDarkColor, isImageFile, isLocalDev, isProduction, isWriterRole, listDeepSpaceAgentModels, logEventText, loggableError, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, resetEnvironmentCache, resolveDeepSpaceAgentModel, serverBuild, signIn, signOut, storageLimitForTier, toConnectionStatus, toUint8Array, truncateLogText, useAsyncResource, useAuth, useAuthProfileReady, useAuthStatus, useAuthUser, useCanvas, useChannelMembers, useChannels, useCheckout, useCronMonitor, useDisplayName, useIsDarkTheme, useJobs, useMessages, useMutations, usePagedResource, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useSubscription, useUser, useUserLookup, useUsers, useVoiceAgent, useYjsField, useYjsRoom, useYjsText, validateAppMigrationIds, writeVarUint, writeVarUint8Array };
package/dist/index.js CHANGED
@@ -756,6 +756,7 @@ var SECURE_ROOM_BOUNDARIES_MIGRATION_ID = "2026-08-secure-room-boundaries";
756
756
  var ACTION_TOOLS_DELETE_WHERE_MIGRATION_ID = "2026-08-action-tools-delete-where";
757
757
  var BUILD_INJECTED_APP_ID_MIGRATION_ID = "2026-08-build-injected-app-id";
758
758
  var ACTION_ROUTES_BEARER_GUARD_MIGRATION_ID = "2026-08-action-routes-bearer-guard";
759
+ var FILES_SESSION_COOKIE_READS_MIGRATION_ID = "2026-09-files-session-cookie-reads";
759
760
  function validateAppMigrationIds(value) {
760
761
  if (!Array.isArray(value)) {
761
762
  return { valid: false, reason: "app migrations must be a JSON string array" };
@@ -3866,7 +3867,10 @@ function useR2Files(options) {
3866
3867
  const headers = await authHeaders();
3867
3868
  const response = await fetch(getUrl(key), { headers });
3868
3869
  if (!response.ok) {
3869
- return { success: false, error: describeFilesFailure(response.status, await response.text()) };
3870
+ return {
3871
+ success: false,
3872
+ error: describeFilesFailure(response.status, await response.text())
3873
+ };
3870
3874
  }
3871
3875
  const disposition = response.headers.get("Content-Disposition");
3872
3876
  const dispositionName = disposition?.match(/filename="(.+?)"/)?.[1];
@@ -5696,6 +5700,7 @@ export {
5696
5700
  DeepSpaceAuthProvider,
5697
5701
  DeepSpaceThemeProvider,
5698
5702
  ENV,
5703
+ FILES_SESSION_COOKIE_READS_MIGRATION_ID,
5699
5704
  GuestBanner,
5700
5705
  LOG_LEVELS,
5701
5706
  MAX_LOG_TEXT_LENGTH,