@securecoms/agent-bridge 0.37.0 → 0.38.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.
@@ -95,9 +95,41 @@ export interface ReceiveDeps {
95
95
  mkdirp(dir: string): Promise<void>;
96
96
  writeFile(p: string, data: Uint8Array): Promise<void>;
97
97
  }
98
- /** Reduce any name to a safe basename inside the target dir. Strips path
98
+ /** Reduce any name to a safe basename inside the target dir. Strips control
99
+ * and bidi characters (review r1 M1: "invoice\u202Efdp.exe"), path
99
100
  * separators and `..`; falls back when nothing usable remains. */
100
101
  export declare function sanitizeFilename(name: string, fallback: string): string;
102
+ /**
103
+ * The image type from a file's leading bytes (PNG, JPEG, GIF, WEBP), or
104
+ * undefined. Review r1 H1: the reported mime of a received file is derived
105
+ * from its decrypted bytes, never the sender's claim. Twin of the connectors'
106
+ * sniffImageMime / sniff_image_mime.
107
+ */
108
+ export declare function sniffImageMime(b: Uint8Array): string | undefined;
109
+ /** A channel or message id that is not a canonical lowercase UUID would become
110
+ * a path segment of the attachments dir. Content-free: the id is never echoed. */
111
+ export declare class InvalidAttachmentTargetError extends Error {
112
+ constructor();
113
+ }
114
+ /** mkdir -p with 0700, then refuse the leaf if it is not a real directory
115
+ * (a symlink planted at <attachmentsDir>/<channel> is never written through). */
116
+ export declare function mkdirPrivateNoFollow(dir: string): Promise<void>;
117
+ /** Byte cap on a saved attachment's name: with the "<uuid>-" prefix and the
118
+ * ".<uuid>.part" temp suffix the entry stays far below NAME_MAX (255). */
119
+ export declare const MAX_FILENAME_BYTES = 150;
120
+ /** Truncate `name` to at most `maxBytes` UTF-8 bytes, cutting only between
121
+ * code points and keeping a short extension. */
122
+ export declare function truncateFilename(name: string, maxBytes?: number): string;
123
+ /**
124
+ * Review r1 M4: write `data` to `path` without following a symlink and
125
+ * without writing into an existing file. The bytes go to a fresh temp name
126
+ * opened O_CREAT|O_EXCL|O_NOFOLLOW (0600), then rename() moves it into place.
127
+ * rename replaces a directory ENTRY, never writes through a link at `path`,
128
+ * and keeps a redelivered message (same id, same path) idempotent: a plain
129
+ * exclusive create of `path` itself would fail the redelivery, and the
130
+ * fail-soft share path would ack it and lose the file.
131
+ */
132
+ export declare function writeFileExclusiveNoFollow(path: string, data: Uint8Array): Promise<void>;
101
133
  export declare function mimeForName(name: string): string;
102
134
  export interface SendDeps {
103
135
  /** Warm libsodium before any WASM-backed call. See src/sodium-ready.ts. */