deepspace 0.5.1 → 0.5.3

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/server.d.ts CHANGED
@@ -651,11 +651,11 @@ declare function composioTools(env: ApiWorkerEnv, options: ComposioToolsOptions)
651
651
  * `null` on any non-2xx — callers should treat as "no preview available"
652
652
  * and surface their own fallback UX.
653
653
  *
654
- * Auth is the same HMAC-of-appName pattern `/internal/files` uses:
655
- * x-app-identity-token = hmac(PLATFORM_IDENTITY_SECRET, APP_NAME)
656
- * x-app-name = APP_NAME
654
+ * Auth is the same HMAC-of-appId pattern `/internal/files` uses:
655
+ * x-app-identity-token = hmac(PLATFORM_IDENTITY_SECRET, DEEPSPACE_APP_ID)
656
+ * x-app-id = DEEPSPACE_APP_ID
657
657
  *
658
- * Apps already have both as bindings (APP_IDENTITY_TOKEN + APP_NAME),
658
+ * Apps already have both as bindings (APP_IDENTITY_TOKEN + DEEPSPACE_APP_ID),
659
659
  * so this helper is a thin wrapper — no extra secrets to manage.
660
660
  */
661
661
 
@@ -670,7 +670,8 @@ interface ScreenshotOptions {
670
670
  fullPage?: boolean;
671
671
  }
672
672
  interface ScreenshotEnv extends PlatformWorkerEnv {
673
- APP_NAME: string;
673
+ /** Immutable app id — the identity the platform verifies (HMAC input). */
674
+ DEEPSPACE_APP_ID: string;
674
675
  /** Absent until the app's first deploy registers it — see appendAppIdentity. */
675
676
  APP_IDENTITY_TOKEN?: string;
676
677
  }
@@ -3053,6 +3054,12 @@ declare function verifyJwt(config: JwtVerifierConfig, token: string | null | und
3053
3054
  */
3054
3055
  declare function computeHmacHex(secret: string, payload: string): Promise<string>;
3055
3056
  declare function timingSafeEqualHex(a: string, b: string): Promise<boolean>;
3057
+ /**
3058
+ * Constant-time equality for arbitrary strings (hash-then-compare: SHA-256
3059
+ * normalizes lengths so neither length nor content short-circuits). The one
3060
+ * implementation every worker's bearer/secret checks share.
3061
+ */
3062
+ declare function timingSafeEqualStrings(a: string, b: string): Promise<boolean>;
3056
3063
 
3057
3064
  declare function decodeJwtPayload(token: string | null | undefined): TokenDebugInfo | undefined;
3058
3065
 
@@ -4027,7 +4034,8 @@ interface SubscriptionRead {
4027
4034
  interface StarterAppEnv$1 extends ApiWorkerEnv {
4028
4035
  /** Absent until the app's first deploy registers it — see appendAppIdentity. */
4029
4036
  APP_IDENTITY_TOKEN?: string;
4030
- APP_NAME: string;
4037
+ /** Immutable app id — the identity the platform verifies (HMAC input). */
4038
+ DEEPSPACE_APP_ID: string;
4031
4039
  }
4032
4040
  declare function getSubscription(c: Context<{
4033
4041
  Bindings: StarterAppEnv$1;
@@ -4115,7 +4123,8 @@ declare class CancelSubscriptionError extends Error {
4115
4123
  interface StarterAppEnv extends ApiWorkerEnv {
4116
4124
  /** Absent until the app's first deploy registers it — see appendAppIdentity. */
4117
4125
  APP_IDENTITY_TOKEN?: string;
4118
- APP_NAME: string;
4126
+ /** Immutable app id — the identity the platform verifies (HMAC input). */
4127
+ DEEPSPACE_APP_ID: string;
4119
4128
  }
4120
4129
  interface RefundResult {
4121
4130
  success: boolean;
@@ -4137,4 +4146,4 @@ declare class RefundError extends Error {
4137
4146
  constructor(message: string, status: number);
4138
4147
  }
4139
4148
 
4140
- export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CancelSubscriptionError, type CancelSubscriptionOpts, type CancelSubscriptionResult, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, 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, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DebugApiContext, 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 Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MESSAGES_SCHEMA, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlanInfo, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, type RecordContext, RecordRoom, type RecordRoomConfig, RefundError, type RefundOpts, type RefundResult, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotOptions, type ScreenshotResult, type SharedConnection, type StoredRecord, SubscriptionAuthError, type SubscriptionContext, type SubscriptionRead, SubscriptionRequiredError, type SubscriptionStatus, type Summarizer, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, type ToolsApiContext, USERS_COLUMNS, type User, type UserAttachment, type UserContext, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, deleteRecord, enqueueJob, executeQuery, getAllUsers, getChat, getGlobalDOSchemas, getGlobalDOType, getOrCreateYjsDoc, getRecord, getRolePermissions, getSubscription, getUser, getYjsDocKey, handleApiRequest, handleDelete, handlePut, handleSetRole, handleSubscribe, handleToolsRequest, handleUnsubscribe, handleUserList, handleUserUpdate, handleYjsBinaryMessage, handleYjsJoin, handleYjsLeave, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, meterAi, meterUsage, meterVectorize, noopPermissionContext, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, requireSubscription, resolveAppName, resolveColumn, rowToData, runMigrations, saveYjsDoc, timingSafeEqualHex, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema };
4149
+ export { AI_CHATS_SCHEMA, AI_MESSAGES_SCHEMA, ALLOWED_BINDING_TYPES, APP_NAME_RULES, AUTO_PROVISIONABLE_TYPES, AUTO_PROVISION_SENTINEL, type ActionContext, type ActionHandler, type ActionResult, type ActionTools, type ApiWorkerEnv, type AppNameResolution, type AppNameValidation, type AuthWorkerEnv, BASE_USERS_SCHEMA, BUILT_IN_TOOLS, BaseRoom, CHANNELS_SCHEMA, CHANNEL_INVITATIONS_SCHEMA, CHANNEL_MEMBERS_SCHEMA, CONVERSATION_SCHEMAS, COST_RATES, CancelSubscriptionError, type CancelSubscriptionOpts, type CancelSubscriptionResult, CanvasRoom, type CanvasShape, type ChatContextConfig, type ChatMessageRow, type ChatRow, type ChatTurn, type CollectionPermissionSummary, type CollectionSchema, type ColumnDefinition, type ColumnInterpretation, type ComposioToolsOptions, 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, DIRECTORY_SCHEMAS, type DOBindings, type DOManifest, type DOManifestEntry, type DebugApiContext, 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 Job, type JobContext, JobRoom, type JobRoomConfig, type JobStatus, type JwtClaims, type JwtVerifierConfig, MESSAGES_SCHEMA, type MutateActionData, type PermissionAnalysis, type PermissionContext, type PermissionLevel, type PermissionSource, type PlanInfo, type PlatformWorkerEnv, type Player, type PrefixResult, type PresencePeer, PresenceRoom, type QueryActionData, REACTIONS_SCHEMA, READ_RECEIPTS_SCHEMA, RESERVED_BINDING_NAMES, RESERVED_COLLECTION_NAMES, type RecordContext, RecordRoom, type RecordRoomConfig, RefundError, type RefundOpts, type RefundResult, type ResolvedColumn, type ResolvedPermission, type RolePermissions, type RunMigrationsResult, SYSTEM_COLLECTION_SCHEMAS, SYSTEM_MANAGED_COLUMNS, SchemaRegistry, type ScopeContext, type ScopedR2Auth, type ScopedR2Config, type ScopedR2Handler, type ScreenshotEnv, type ScreenshotOptions, type ScreenshotResult, type SharedConnection, type StoredRecord, SubscriptionAuthError, type SubscriptionContext, type SubscriptionRead, SubscriptionRequiredError, type SubscriptionStatus, type Summarizer, TEST_ACCOUNT_EMAIL_SUFFIX, type TokenDebugInfo, type ToolResult, type ToolSchema, type ToolsApiContext, USERS_COLUMNS, type User, type UserAttachment, type UserContext, VOTING_SCHEMAS, type ValidationError, type VerifiedAuth, type VerifyOutcome, type VerifyResult, type Viewport, WORKSPACE_SCHEMAS, type YjsContext, YjsRoom, analyzePermissions, apiWorkerFetch, appendMessage, applyAiToolDefaults, applySlidingWindow, authWorkerFetch, bindingManifestFromOutputConfig, broadcastChange, broadcastYjsUpdate, buildCronContext, buildTableSelect, buildUiParts, canCreate, canDelete, canRead, canUpdate, cancelSubscription, capToolResultSize, captureScreenshot, checkFieldPermissions, coerceValue, collectionTableName, columnId, composioTools, computeDoMigration, computeHmacHex, createChat, createDeepSpaceAI, createDeepSpaceAuth, createScopedR2Handler, dataToColumnValues, decodeJwtPayload, deleteChatCascade, deleteRecord, enqueueJob, executeQuery, getAllUsers, getChat, getGlobalDOSchemas, getGlobalDOType, getOrCreateYjsDoc, getRecord, getRolePermissions, getSubscription, getUser, getYjsDocKey, handleApiRequest, handleDelete, handlePut, handleSetRole, handleSubscribe, handleToolsRequest, handleUnsubscribe, handleUserList, handleUserUpdate, handleYjsBinaryMessage, handleYjsJoin, handleYjsLeave, isAutoProvision, isOwner, isTestAccountClaims, isTestAccountEmail, isTestAccountTier, lintSchema, loadMessages, makeDefaultSummarizer, meterAi, meterUsage, meterVectorize, noopPermissionContext, platformWorkerFetch, prepareMessagesWithCompaction, priceBindingUsageEvent, putRecord, readRecord, recordMatchesSubscription, refundInvoice, registerUser, requireSubscription, resolveAppName, resolveColumn, rowToData, runMigrations, saveYjsDoc, timingSafeEqualHex, timingSafeEqualStrings, totalChars, truncateOldToolResults, turnsToCoreMessages, unwrapToolOutput, updateChat, validateAppName, validateBindingManifest, validateDoManifest, verifyJwt, workspaceAccountsSchema, workspaceContentSharesSchema, workspaceEmailHandlesSchema, workspaceFormResponsesSchema, workspacePeopleSchema, workspaceProjectsSchema, workspaceTagsSchema, workspaceTasksSchema, workspaceTeamMembersSchema, workspaceTeamsSchema, workspaceTransactionsSchema };
package/dist/server.js CHANGED
@@ -672,10 +672,10 @@ async function composioTools(env, options) {
672
672
  // src/server/utils/app-identity.ts
673
673
  function appendAppIdentity(headers, env) {
674
674
  headers.delete("x-app-identity-token");
675
- headers.delete("x-app-name");
675
+ headers.delete("x-app-id");
676
676
  if (!env.APP_IDENTITY_TOKEN) return;
677
677
  headers.set("x-app-identity-token", env.APP_IDENTITY_TOKEN);
678
- headers.set("x-app-name", env.APP_NAME);
678
+ headers.set("x-app-id", env.DEEPSPACE_APP_ID);
679
679
  }
680
680
 
681
681
  // src/server/utils/screenshot.ts
@@ -6845,6 +6845,18 @@ async function timingSafeEqualHex(a, b) {
6845
6845
  }
6846
6846
  return diff === 0;
6847
6847
  }
6848
+ async function timingSafeEqualStrings(a, b) {
6849
+ const encoder = new TextEncoder();
6850
+ const [aHash, bHash] = await Promise.all([
6851
+ crypto.subtle.digest("SHA-256", encoder.encode(a)),
6852
+ crypto.subtle.digest("SHA-256", encoder.encode(b))
6853
+ ]);
6854
+ const aBytes = new Uint8Array(aHash);
6855
+ const bBytes = new Uint8Array(bHash);
6856
+ let diff = 0;
6857
+ for (let i = 0; i < aBytes.length; i++) diff |= aBytes[i] ^ bBytes[i];
6858
+ return diff === 0;
6859
+ }
6848
6860
 
6849
6861
  // src/server/auth/testAccounts.ts
6850
6862
  var TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
@@ -7015,7 +7027,7 @@ async function cancelSubscription(c, opts) {
7015
7027
  authorization: authz
7016
7028
  },
7017
7029
  body: JSON.stringify({
7018
- appName: c.env.APP_NAME,
7030
+ appId: c.env.DEEPSPACE_APP_ID,
7019
7031
  userId: opts.userId,
7020
7032
  planSlug: opts.planSlug,
7021
7033
  atPeriodEnd: opts.atPeriodEnd,
@@ -7200,6 +7212,7 @@ export {
7200
7212
  runMigrations,
7201
7213
  saveYjsDoc,
7202
7214
  timingSafeEqualHex,
7215
+ timingSafeEqualStrings,
7203
7216
  totalChars,
7204
7217
  truncateOldToolResults,
7205
7218
  turnsToCoreMessages,