@agentdock/wire 0.0.63 → 0.0.64
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/fileWhitelist.d.ts +55 -0
- package/dist/fileWhitelist.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File upload whitelist — single source of truth for personal-edition file
|
|
3
|
+
* upload validation, shared across web (PWA client), server (relay preflight),
|
|
4
|
+
* and daemon (receiver second-check).
|
|
5
|
+
*
|
|
6
|
+
* Contains ONLY isomorphic data + pure byte logic (no node:/DOM deps):
|
|
7
|
+
* - per-category extension lists and max sizes
|
|
8
|
+
* - blocked (executable) extensions
|
|
9
|
+
* - magic-byte signatures
|
|
10
|
+
* - category resolution + magic-byte verification over Uint8Array
|
|
11
|
+
*
|
|
12
|
+
* File reading differs per platform (File/FileReader on web, Buffer on
|
|
13
|
+
* server/daemon), so callers read the head bytes themselves and pass a
|
|
14
|
+
* Uint8Array in. Buffer is a Uint8Array subclass, so `verifyMagicBytes`
|
|
15
|
+
* works unchanged on both.
|
|
16
|
+
*/
|
|
17
|
+
export type FileCategory = 'text' | 'document' | 'code' | 'image';
|
|
18
|
+
export declare const TEXT_EXTS: readonly string[];
|
|
19
|
+
export declare const CODE_EXTS: readonly string[];
|
|
20
|
+
export declare const DOC_EXTS: readonly string[];
|
|
21
|
+
export declare const IMG_EXTS: readonly string[];
|
|
22
|
+
/** Per-category max upload size in bytes. */
|
|
23
|
+
export declare const FILE_CATEGORY_MAX_SIZE: Readonly<Record<FileCategory, number>>;
|
|
24
|
+
/** Executable / dangerous extensions — always rejected. */
|
|
25
|
+
export declare const BLOCKED_EXTS: ReadonlySet<string>;
|
|
26
|
+
/** All allowed extensions across every category. */
|
|
27
|
+
export declare const ALLOWED_EXTENSIONS: ReadonlySet<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Binary magic-byte signatures keyed by extension. `subSig` is checked at an
|
|
30
|
+
* offset immediately after `sig` (used by WEBP's RIFF...WEBP layout).
|
|
31
|
+
* Text-based formats (text/code/svg) are not here — they use UTF-8 validation.
|
|
32
|
+
*/
|
|
33
|
+
export declare const FILE_SIGNATURES: Readonly<Record<string, {
|
|
34
|
+
sig: number[];
|
|
35
|
+
subSigAt?: number;
|
|
36
|
+
subSig?: number[];
|
|
37
|
+
}>>;
|
|
38
|
+
/** Lowercased extension (including leading dot) or '' if none. */
|
|
39
|
+
export declare function getFileExt(filename: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the whitelist category for an extension.
|
|
42
|
+
* Returns null for blocked, unknown, or extension-less files.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveFileCategory(ext: string): FileCategory | null;
|
|
45
|
+
/**
|
|
46
|
+
* Verify head bytes match the expected type for `ext`.
|
|
47
|
+
* - text/code: valid UTF-8
|
|
48
|
+
* - svg: XML text sniff
|
|
49
|
+
* - binary formats: magic-byte signature (+ optional sub-signature)
|
|
50
|
+
*
|
|
51
|
+
* `ext` must already be lowercased (use getFileExt). Buffer is a Uint8Array
|
|
52
|
+
* subclass, so server/daemon can pass a Buffer directly.
|
|
53
|
+
*/
|
|
54
|
+
export declare function verifyMagicBytes(head: Uint8Array, ext: string): boolean;
|
|
55
|
+
//# sourceMappingURL=fileWhitelist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const TEXT_EXTS=[".txt",".md",".log",".csv",".json",".xml",".yaml",".yml",".toml",".env"],CODE_EXTS=[".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".css",".html",".sql",".sh"],DOC_EXTS=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx"],IMG_EXTS=[".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp"],FILE_CATEGORY_MAX_SIZE={text:1048576,document:2097152,code:1048576,image:1048576},BLOCKED_EXTS=new Set([".exe",".bat",".cmd",".msi",".dmg",".app",".com",".scr"]),ALLOWED_EXTENSIONS=new Set([...TEXT_EXTS,...CODE_EXTS,...DOC_EXTS,...IMG_EXTS]);const r={text:TEXT_EXTS,code:CODE_EXTS,document:DOC_EXTS,image:IMG_EXTS};export const FILE_SIGNATURES={".pdf":{sig:[37,80,68,70,45]},".doc":{sig:[208,207,17,224,161,177,26,225]},".xls":{sig:[208,207,17,224,161,177,26,225]},".ppt":{sig:[208,207,17,224,161,177,26,225]},".docx":{sig:[80,75,3,4]},".xlsx":{sig:[80,75,3,4]},".pptx":{sig:[80,75,3,4]},".png":{sig:[137,80,78,71,13,10,26,10]},".jpg":{sig:[255,216,255]},".jpeg":{sig:[255,216,255]},".gif":{sig:[71,73,70,56]},".webp":{sig:[82,73,70,70],subSigAt:8,subSig:[87,69,66,80]},".bmp":{sig:[66,77]}};export function getFileExt(t){const x=t.lastIndexOf(".");return x>=0?t.substring(x).toLowerCase():""}export function resolveFileCategory(t){if(t===""||BLOCKED_EXTS.has(t))return null;for(const x of Object.keys(r))if(r[x].includes(t))return x;return null}function i(t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}}function o(t){const x=i(t.subarray(0,Math.min(t.length,512)));if(x===null)return!1;const e=(x.charCodeAt(0)===65279?x.slice(1):x).trimStart();return e.startsWith("<?xml")||e.startsWith("<svg")||e.startsWith("<!DOCTYPE svg")}export function verifyMagicBytes(t,x){if(TEXT_EXTS.includes(x)||CODE_EXTS.includes(x))return i(t)!==null;if(x===".svg")return o(t);const e=FILE_SIGNATURES[x];if(!e||t.length<e.sig.length)return!1;for(let s=0;s<e.sig.length;s++)if(t[s]!==e.sig[s])return!1;if(e.subSig){const s=e.subSigAt??e.sig.length;if(t.length<s+e.subSig.length)return!1;for(let n=0;n<e.subSig.length;n++)if(t[s+n]!==e.subSig[n])return!1}return!0}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export { ModelUsageEntrySchema, DailyActivitySchema, DailyModelTokensSchema, Lon
|
|
|
21
21
|
export type { StatsOverview, ClaudeStatsData, ProjectSummary, ModelUsageEntry as WireModelUsageEntry, DailyActivity as WireDailyActivity, LongestSession as WireLongestSession, AgentTypeUsage, ActivityUpload, UsageReport, TokenTrendPoint, ModelBreakdownEntry, QuotaConfig, QuotaStatusSchema, QuotaStatus, } from './stats.js';
|
|
22
22
|
export { ControlLevel } from './controlLevel.js';
|
|
23
23
|
export type { ControlLevelType } from './controlLevel.js';
|
|
24
|
+
export { TEXT_EXTS, CODE_EXTS, DOC_EXTS, IMG_EXTS, FILE_CATEGORY_MAX_SIZE, BLOCKED_EXTS, ALLOWED_EXTENSIONS, FILE_SIGNATURES, getFileExt, resolveFileCategory, verifyMagicBytes, } from './fileWhitelist.js';
|
|
25
|
+
export type { FileCategory } from './fileWhitelist.js';
|
|
24
26
|
export { PairingState, PairingRequestSchema, PairingResponseSchema, PairingExchangeSchema, PairingDeliverSchema, PairingStatusSchema, parseVersionByte, encodeVersionByte, KNOWN_DERIVATION_VERSIONS, CURRENT_DERIVATION_VERSION, } from './pairing.js';
|
|
25
27
|
export type { PairingRequest, PairingResponse, PairingExchange, PairingDeliver, PairingStatus, } from './pairing.js';
|
|
26
28
|
export { PlatformSchema, SessionStatusSchema, MachineSummarySchema, MachineRegisterResultSchema, } from './machine.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{SessionTextEventSchema,SessionServiceEventSchema,SessionToolCallStartEventSchema,SessionToolCallEndEventSchema,SessionFileEventSchema,SessionTurnStartEventSchema,SessionTurnEndEventSchema,SessionTurnEndStatusSchema,TurnUsageSchema,SessionStartEventSchema,SessionStopEventSchema,SessionEventSchema,SessionPermissionResolvedEventSchema,PermissionActionSchema,SessionImageEventSchema,ImageAttachmentSchema}from"./events.js";export{QuestionOptionSchema,SessionQuestionEventSchema,SessionPermissionRequestEventSchema,SessionAnswerEventSchema,AnswerQuestionParamsSchema,ApprovePermissionParamsSchema,DenyPermissionParamsSchema,PermissionModeSchema}from"./interactionEvents.js";export{SessionRoleSchema,SessionEnvelopeSchema,createEnvelope}from"./envelope.js";export{AgentTypeSchema,MessageMetaSchema,AGENT_TYPES,SPAWNABLE_AGENTS,CLI_AGENT_TYPES}from"./messageMeta.js";export{AGENT_SUPPORTS_IMAGES}from"./messageMeta.js";export{SessionMessageContentSchema,SessionMessageSchema,SessionProtocolMessageSchema,MessageContentSchema}from"./messages.js";export{UserMessageSchema,AgentMessageSchema,LegacyMessageContentSchema}from"./legacyProtocol.js";export{VersionedEncryptedValueSchema,VersionedNullableEncryptedValueSchema,VersionedMachineEncryptedValueSchema,UpdateNewMessageBodySchema,UpdateSessionBodySchema,UpdateMachineBodySchema,UpdateSessionResetBodySchema,CoreUpdateBodySchema,CoreUpdateContainerSchema}from"./sync.js";export{RpcMethod,SESSION_RPC_METHODS,MACHINE_RPC_METHODS,DAEMON_REQUIRED_RPC_METHODS,RpcCallSchema,RpcResultSchema,SpawnSessionParamsSchema,GetMessagesParamsSchema,GetMessagesResponseSchema,MachineInfoResponseSchema,CheckPathParamsSchema,AGENT_ENV_NONE,AgentEnvConfigSchema,AgentSettingsSchema,LabsSettingsSchema,CustomModelSchema,SkillDefinitionSchema}from"./rpc.js";export{AGENT_CAPABILITIES,getAgentCapability,updateDynamicModes,getDynamicModes,normalizeModelId}from"./agentCapabilities.js";export{ModelUsageEntrySchema,DailyActivitySchema,DailyModelTokensSchema,LongestSessionSchema,ClaudeStatsDataSchema,ProjectSummarySchema,StatsOverviewSchema,AgentTypeUsageSchema,ActivityUploadSchema,UsageReportSchema,TokenTrendPointSchema,ModelBreakdownEntrySchema,QuotaConfigSchema}from"./stats.js";export{ControlLevel}from"./controlLevel.js";export{PairingState,PairingRequestSchema,PairingResponseSchema,PairingExchangeSchema,PairingDeliverSchema,PairingStatusSchema,parseVersionByte,encodeVersionByte,KNOWN_DERIVATION_VERSIONS,CURRENT_DERIVATION_VERSION}from"./pairing.js";export{PlatformSchema,SessionStatusSchema,MachineSummarySchema,MachineRegisterResultSchema}from"./machine.js";export{FEATURE_REGISTRY,isFeatureAvailable,getUnavailableFeatures,isSubFeatureAvailable,getSubFeatureMinVersion}from"./features.js";export{SessionResultSchema}from"./sessionResult.js";export{SpawnErrorCodeSchema,SpawnErrorSchema,createSpawnError}from"./spawnError.js";export{AGENT_INSTALL_GUIDE}from"./agentInstallGuide.js";export{AGENT_COMMON_ENV_VARS}from"./agentCommonEnv.js";export{RetryPolicySchema,MissedRunPolicySchema,ScheduledSpawnParamsSchema,TaskExecutionStatusSchema,TaskExecutionTriggerSchema,CreateScheduledTaskSchema,UpdateScheduledTaskSchema,ScheduledTaskSummarySchema,TaskExecutionSchema,CRON_RE}from"./scheduledTasks.js";export{PROTOCOL_VERSION}from"./protocol.js";export{parseSemver,compareVersions,satisfiesMin}from"./semver.js";export{createId}from"./utils.js";export{errorMessage}from"./errorMessage.js";export{BG_TASK_PREFIX,encodeBgTask,parseBgTask,isBgTaskLifecycleLine}from"./bgTask.js";export{BASH_TOOL_NAMES,isBashToolName,extractCommandSubject,MIN_SUBJECT_LENGTH}from"./permissionSubject.js";export{SOCKET_EVENTS}from"./socketEvents.js";export{TelemetryEventTypeSchema,TelemetryEventSchema,TelemetryReportPayloadSchema,sanitizeContext}from"./telemetry.js";export*from"./checkpointSchemas.js";export{OpsRpcMessageSchema,OpsMethodSchema,OpsRpcTypeSchema,FileEntrySchema,FileStatSchema,StorageUsageSchema,SyncUserSchema,SyncFullPayloadSchema,SyncUserCreatedPayloadSchema,SyncContainerStatusPayloadSchema,SyncUserPairedPayloadSchema}from"./ops.js";export*from"./edition.js";export{LicensePayloadSchema,LicenseFileSchema,EnterpriseLicenseSchema,PrivateLicenseSchema}from"./license.js";export{FeedbackTypeSchema,FeedbackStatusSchema,DeviceInfoSchema,MachineSnapshotSchema,CreateFeedbackSchema,UpdateFeedbackSchema,RunModeSchema,RunModesSchema,BugFieldsSchema,SettingsSnapshotSchema}from"./feedback.js";
|
|
1
|
+
"use strict";export{SessionTextEventSchema,SessionServiceEventSchema,SessionToolCallStartEventSchema,SessionToolCallEndEventSchema,SessionFileEventSchema,SessionTurnStartEventSchema,SessionTurnEndEventSchema,SessionTurnEndStatusSchema,TurnUsageSchema,SessionStartEventSchema,SessionStopEventSchema,SessionEventSchema,SessionPermissionResolvedEventSchema,PermissionActionSchema,SessionImageEventSchema,ImageAttachmentSchema}from"./events.js";export{QuestionOptionSchema,SessionQuestionEventSchema,SessionPermissionRequestEventSchema,SessionAnswerEventSchema,AnswerQuestionParamsSchema,ApprovePermissionParamsSchema,DenyPermissionParamsSchema,PermissionModeSchema}from"./interactionEvents.js";export{SessionRoleSchema,SessionEnvelopeSchema,createEnvelope}from"./envelope.js";export{AgentTypeSchema,MessageMetaSchema,AGENT_TYPES,SPAWNABLE_AGENTS,CLI_AGENT_TYPES}from"./messageMeta.js";export{AGENT_SUPPORTS_IMAGES}from"./messageMeta.js";export{SessionMessageContentSchema,SessionMessageSchema,SessionProtocolMessageSchema,MessageContentSchema}from"./messages.js";export{UserMessageSchema,AgentMessageSchema,LegacyMessageContentSchema}from"./legacyProtocol.js";export{VersionedEncryptedValueSchema,VersionedNullableEncryptedValueSchema,VersionedMachineEncryptedValueSchema,UpdateNewMessageBodySchema,UpdateSessionBodySchema,UpdateMachineBodySchema,UpdateSessionResetBodySchema,CoreUpdateBodySchema,CoreUpdateContainerSchema}from"./sync.js";export{RpcMethod,SESSION_RPC_METHODS,MACHINE_RPC_METHODS,DAEMON_REQUIRED_RPC_METHODS,RpcCallSchema,RpcResultSchema,SpawnSessionParamsSchema,GetMessagesParamsSchema,GetMessagesResponseSchema,MachineInfoResponseSchema,CheckPathParamsSchema,AGENT_ENV_NONE,AgentEnvConfigSchema,AgentSettingsSchema,LabsSettingsSchema,CustomModelSchema,SkillDefinitionSchema}from"./rpc.js";export{AGENT_CAPABILITIES,getAgentCapability,updateDynamicModes,getDynamicModes,normalizeModelId}from"./agentCapabilities.js";export{ModelUsageEntrySchema,DailyActivitySchema,DailyModelTokensSchema,LongestSessionSchema,ClaudeStatsDataSchema,ProjectSummarySchema,StatsOverviewSchema,AgentTypeUsageSchema,ActivityUploadSchema,UsageReportSchema,TokenTrendPointSchema,ModelBreakdownEntrySchema,QuotaConfigSchema}from"./stats.js";export{ControlLevel}from"./controlLevel.js";export{TEXT_EXTS,CODE_EXTS,DOC_EXTS,IMG_EXTS,FILE_CATEGORY_MAX_SIZE,BLOCKED_EXTS,ALLOWED_EXTENSIONS,FILE_SIGNATURES,getFileExt,resolveFileCategory,verifyMagicBytes}from"./fileWhitelist.js";export{PairingState,PairingRequestSchema,PairingResponseSchema,PairingExchangeSchema,PairingDeliverSchema,PairingStatusSchema,parseVersionByte,encodeVersionByte,KNOWN_DERIVATION_VERSIONS,CURRENT_DERIVATION_VERSION}from"./pairing.js";export{PlatformSchema,SessionStatusSchema,MachineSummarySchema,MachineRegisterResultSchema}from"./machine.js";export{FEATURE_REGISTRY,isFeatureAvailable,getUnavailableFeatures,isSubFeatureAvailable,getSubFeatureMinVersion}from"./features.js";export{SessionResultSchema}from"./sessionResult.js";export{SpawnErrorCodeSchema,SpawnErrorSchema,createSpawnError}from"./spawnError.js";export{AGENT_INSTALL_GUIDE}from"./agentInstallGuide.js";export{AGENT_COMMON_ENV_VARS}from"./agentCommonEnv.js";export{RetryPolicySchema,MissedRunPolicySchema,ScheduledSpawnParamsSchema,TaskExecutionStatusSchema,TaskExecutionTriggerSchema,CreateScheduledTaskSchema,UpdateScheduledTaskSchema,ScheduledTaskSummarySchema,TaskExecutionSchema,CRON_RE}from"./scheduledTasks.js";export{PROTOCOL_VERSION}from"./protocol.js";export{parseSemver,compareVersions,satisfiesMin}from"./semver.js";export{createId}from"./utils.js";export{errorMessage}from"./errorMessage.js";export{BG_TASK_PREFIX,encodeBgTask,parseBgTask,isBgTaskLifecycleLine}from"./bgTask.js";export{BASH_TOOL_NAMES,isBashToolName,extractCommandSubject,MIN_SUBJECT_LENGTH}from"./permissionSubject.js";export{SOCKET_EVENTS}from"./socketEvents.js";export{TelemetryEventTypeSchema,TelemetryEventSchema,TelemetryReportPayloadSchema,sanitizeContext}from"./telemetry.js";export*from"./checkpointSchemas.js";export{OpsRpcMessageSchema,OpsMethodSchema,OpsRpcTypeSchema,FileEntrySchema,FileStatSchema,StorageUsageSchema,SyncUserSchema,SyncFullPayloadSchema,SyncUserCreatedPayloadSchema,SyncContainerStatusPayloadSchema,SyncUserPairedPayloadSchema}from"./ops.js";export*from"./edition.js";export{LicensePayloadSchema,LicenseFileSchema,EnterpriseLicenseSchema,PrivateLicenseSchema}from"./license.js";export{FeedbackTypeSchema,FeedbackStatusSchema,DeviceInfoSchema,MachineSnapshotSchema,CreateFeedbackSchema,UpdateFeedbackSchema,RunModeSchema,RunModesSchema,BugFieldsSchema,SettingsSnapshotSchema}from"./feedback.js";
|