@ttt-productions/media-processing-core 0.8.16 → 0.8.18

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.
Files changed (141) hide show
  1. package/dist/audio/audio-processor.d.ts +2 -2
  2. package/dist/audio/audio-processor.d.ts.map +1 -1
  3. package/dist/audio/audio-processor.js +63 -50
  4. package/dist/audio/audio-processor.js.map +1 -1
  5. package/dist/audio/probe.d.ts +1 -1
  6. package/dist/audio/probe.d.ts.map +1 -1
  7. package/dist/audio/probe.js +6 -5
  8. package/dist/audio/probe.js.map +1 -1
  9. package/dist/duration/media-duration.d.ts +2 -13
  10. package/dist/duration/media-duration.d.ts.map +1 -1
  11. package/dist/duration/media-duration.js +24 -49
  12. package/dist/duration/media-duration.js.map +1 -1
  13. package/dist/image/formats.d.ts +2 -13
  14. package/dist/image/formats.d.ts.map +1 -1
  15. package/dist/image/formats.js +25 -35
  16. package/dist/image/formats.js.map +1 -1
  17. package/dist/image/image-processor.d.ts +2 -2
  18. package/dist/image/image-processor.d.ts.map +1 -1
  19. package/dist/image/image-processor.js +48 -57
  20. package/dist/image/image-processor.js.map +1 -1
  21. package/dist/image/resize.d.ts +2 -16
  22. package/dist/image/resize.d.ts.map +1 -1
  23. package/dist/image/resize.js +13 -28
  24. package/dist/image/resize.js.map +1 -1
  25. package/dist/index.d.ts +19 -16
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +18 -16
  28. package/dist/index.js.map +1 -1
  29. package/dist/inspection/inspect-media.d.ts +13 -20
  30. package/dist/inspection/inspect-media.d.ts.map +1 -1
  31. package/dist/inspection/inspect-media.js +197 -201
  32. package/dist/inspection/inspect-media.js.map +1 -1
  33. package/dist/io/fs.d.ts +1 -1
  34. package/dist/io/fs.d.ts.map +1 -1
  35. package/dist/io/fs.js +4 -5
  36. package/dist/io/fs.js.map +1 -1
  37. package/dist/io/local-input.d.ts +1 -21
  38. package/dist/io/local-input.d.ts.map +1 -1
  39. package/dist/io/local-input.js +15 -35
  40. package/dist/io/local-input.js.map +1 -1
  41. package/dist/io/types.d.ts +0 -3
  42. package/dist/io/types.d.ts.map +1 -1
  43. package/dist/io/types.js.map +1 -1
  44. package/dist/moderation/merge.d.ts +1 -1
  45. package/dist/moderation/merge.d.ts.map +1 -1
  46. package/dist/moderation/merge.js +1 -2
  47. package/dist/moderation/merge.js.map +1 -1
  48. package/dist/moderation/types.d.ts +3 -5
  49. package/dist/moderation/types.d.ts.map +1 -1
  50. package/dist/moderation/types.js.map +1 -1
  51. package/dist/process-media.d.ts +2 -3
  52. package/dist/process-media.d.ts.map +1 -1
  53. package/dist/process-media.js +9 -9
  54. package/dist/process-media.js.map +1 -1
  55. package/dist/processing/errors.d.ts.map +1 -1
  56. package/dist/processing/errors.js +1 -1
  57. package/dist/processing/errors.js.map +1 -1
  58. package/dist/processing/result.d.ts +2 -2
  59. package/dist/processing/result.js +1 -1
  60. package/dist/processing/result.js.map +1 -1
  61. package/dist/run-pipeline.d.ts +5 -22
  62. package/dist/run-pipeline.d.ts.map +1 -1
  63. package/dist/run-pipeline.js +72 -81
  64. package/dist/run-pipeline.js.map +1 -1
  65. package/dist/server/download-token.d.ts +0 -6
  66. package/dist/server/download-token.d.ts.map +1 -1
  67. package/dist/server/download-token.js +3 -13
  68. package/dist/server/download-token.js.map +1 -1
  69. package/dist/server/firebase-media-io.d.ts +3 -13
  70. package/dist/server/firebase-media-io.d.ts.map +1 -1
  71. package/dist/server/firebase-media-io.js +1 -6
  72. package/dist/server/firebase-media-io.js.map +1 -1
  73. package/dist/server/gcs-errors.d.ts +0 -8
  74. package/dist/server/gcs-errors.d.ts.map +1 -1
  75. package/dist/server/gcs-errors.js +2 -10
  76. package/dist/server/gcs-errors.js.map +1 -1
  77. package/dist/server/index.d.ts +7 -6
  78. package/dist/server/index.d.ts.map +1 -1
  79. package/dist/server/index.js +7 -6
  80. package/dist/server/index.js.map +1 -1
  81. package/dist/server/pending-media.d.ts +3 -34
  82. package/dist/server/pending-media.d.ts.map +1 -1
  83. package/dist/server/pending-media.js +13 -30
  84. package/dist/server/pending-media.js.map +1 -1
  85. package/dist/server/r2-retry.d.ts +4 -52
  86. package/dist/server/r2-retry.d.ts.map +1 -1
  87. package/dist/server/r2-retry.js +49 -134
  88. package/dist/server/r2-retry.js.map +1 -1
  89. package/dist/server/staged-object.d.ts +2 -46
  90. package/dist/server/staged-object.d.ts.map +1 -1
  91. package/dist/server/staged-object.js +4 -48
  92. package/dist/server/staged-object.js.map +1 -1
  93. package/dist/server/storage-ops.d.ts +5 -67
  94. package/dist/server/storage-ops.d.ts.map +1 -1
  95. package/dist/server/storage-ops.js +110 -185
  96. package/dist/server/storage-ops.js.map +1 -1
  97. package/dist/types.d.ts +2 -4
  98. package/dist/types.d.ts.map +1 -1
  99. package/dist/types.js.map +1 -1
  100. package/dist/utils/log.d.ts.map +1 -1
  101. package/dist/utils/log.js +3 -3
  102. package/dist/utils/log.js.map +1 -1
  103. package/dist/utils/paths.d.ts.map +1 -1
  104. package/dist/utils/paths.js +1 -4
  105. package/dist/utils/paths.js.map +1 -1
  106. package/dist/utils/safe-path.d.ts.map +1 -1
  107. package/dist/utils/safe-path.js +8 -9
  108. package/dist/utils/safe-path.js.map +1 -1
  109. package/dist/validation/validate-duration.d.ts.map +1 -1
  110. package/dist/validation/validate-duration.js.map +1 -1
  111. package/dist/validation/validate-mime.d.ts.map +1 -1
  112. package/dist/validation/validate-mime.js.map +1 -1
  113. package/dist/validation/validate-size.d.ts.map +1 -1
  114. package/dist/validation/validate-size.js.map +1 -1
  115. package/dist/video/ffmpeg.d.ts +1 -23
  116. package/dist/video/ffmpeg.d.ts.map +1 -1
  117. package/dist/video/ffmpeg.js +57 -64
  118. package/dist/video/ffmpeg.js.map +1 -1
  119. package/dist/video/probe.d.ts +1 -1
  120. package/dist/video/probe.d.ts.map +1 -1
  121. package/dist/video/probe.js +10 -8
  122. package/dist/video/probe.js.map +1 -1
  123. package/dist/video/video-processor.d.ts +2 -2
  124. package/dist/video/video-processor.d.ts.map +1 -1
  125. package/dist/video/video-processor.js +125 -96
  126. package/dist/video/video-processor.js.map +1 -1
  127. package/dist/workspace/temp.js +4 -4
  128. package/dist/workspace/temp.js.map +1 -1
  129. package/package.json +2 -2
  130. package/dist/audio/index.d.ts +0 -3
  131. package/dist/audio/index.d.ts.map +0 -1
  132. package/dist/audio/index.js +0 -3
  133. package/dist/audio/index.js.map +0 -1
  134. package/dist/image/index.d.ts +0 -4
  135. package/dist/image/index.d.ts.map +0 -1
  136. package/dist/image/index.js +0 -4
  137. package/dist/image/index.js.map +0 -1
  138. package/dist/video/index.d.ts +0 -4
  139. package/dist/video/index.d.ts.map +0 -1
  140. package/dist/video/index.js +0 -4
  141. package/dist/video/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"storage-ops.js","sourceRoot":"","sources":["../../src/server/storage-ops.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,iEAAiE;AACjE,6EAA6E;AAC7E,0CAA0C;AAC1C,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,iFAAiF;AACjF,qDAAqD;AACrD,gFAAgF;AAChF,qEAAqE;AACrE,+EAA+E;AAC/E,EAAE;AACF,8EAA8E;AAC9E,oEAAoE;AAEpE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,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CAAC;QAC1B,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,oBAAoB,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["// Final-media object-store chokepoint — every final-media write/copy/delete in\n// the system goes through a MediaObjectStore. Inline storage-provider calls for\n// FINAL media are forbidden outside this module. (Upload STAGING stays plain\n// Firebase Storage and is not this module's concern.)\n//\n// Implementations (the consuming app picks one per environment):\n// - R2 (S3-compatible) for deployed environments whose final media lives in\n// R2 and is served by an edge gateway.\n// - Firebase Storage for deployed environments whose final media lives in\n// Firebase Storage. Token-free: it writes and copies no download token, so\n// its objects are readable only through the app's own access path (Storage\n// rules). Firebase can still mint a token later (a client getDownloadURL, the\n// console); the app's read path must never do so.\n// - Firebase Storage emulator for local dev/tests — the Firebase Storage store\n// plus a FIXED caller-supplied download token on every object, so\n// deterministic emulator URLs work. Production NEVER mints download tokens.\n//\n// Writes return `{ key }` — never URLs. Display URLs are built at render time\n// from asset refs (see the consuming app's media-asset-url helper).\n\nimport { createReadStream, createWriteStream } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\nimport { Readable } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport { AwsClient } from \"aws4fetch\";\nimport type { getStorage } from \"firebase-admin/storage\";\nimport { NEUTRAL_CONTENT_TYPE } from \"@ttt-productions/media-schemas\";\nimport { isObjectNotFoundError } from \"./gcs-errors.js\";\nimport {\n defaultR2RetrySeams,\n fetchWithR2Retry,\n R2StorageError,\n type R2RetrySeams,\n} from \"./r2-retry.js\";\nimport { requireStorageObjectGeneration, UnreadableStorageObjectMetadataError } from \"./staged-object.js\";\n\n// Re-export the exhaustion error so callers can recognize an exhausted R2\n// operation. The rest of the retry helper stays private to this module.\nexport { R2StorageError };\n\n/**\n * A copy found an object at its destination key that is not this copy's result, and\n * wrote nothing; that object is untouched. The key is a PROPERTY, never message text, so\n * an escaping error never carries an object key to monitoring.\n */\nexport class ObjectAlreadyExistsError extends Error {\n constructor(public readonly key: string) {\n super(\"copy destination already holds another object\");\n this.name = \"ObjectAlreadyExistsError\";\n }\n}\n\n/** Firebase Admin Storage Bucket — inferred to avoid @google-cloud/storage dep. */\nexport type Bucket = ReturnType<ReturnType<typeof getStorage>[\"bucket\"]>;\n\nexport interface ObjectWriteResult {\n key: string;\n sizeBytes: number;\n contentType: string;\n}\n\nexport interface ObjectReadResult {\n sizeBytes: number;\n contentType: string;\n}\n\nexport interface ObjectCopyResult {\n key: string;\n /**\n * `true` when the destination already held this copy's result — the same source version,\n * committed by an earlier attempt whose answer was lost or by a concurrent identical\n * copy; `false` when this call committed it.\n */\n alreadyPresent: boolean;\n}\n\n/**\n * What `deleteCopy` found at the destination: `deleted` — a copy of the source, now removed;\n * `absent` — no object; `notThisCopy` — an object this package did not copy from that\n * source, left untouched.\n */\nexport type DeleteCopyResult = \"deleted\" | \"absent\" | \"notThisCopy\";\n\n// Every copy records on its destination which source version it holds. A copy whose\n// destination already exists compares this record with its own, so it recognizes its\n// own earlier result and never mistakes another writer's object for it. The values are\n// URI-encoded because R2 carries custom metadata in HTTP headers, which must be ASCII.\nconst COPY_SOURCE_METADATA_KEY = \"copy-source\";\nconst COPY_SOURCE_VERSION_METADATA_KEY = \"copy-source-version\";\n\ntype CopyProvenance = Record<typeof COPY_SOURCE_METADATA_KEY | typeof COPY_SOURCE_VERSION_METADATA_KEY, string>;\n\nfunction copyProvenance(fromKey: string, sourceVersion: string): CopyProvenance {\n return {\n [COPY_SOURCE_METADATA_KEY]: encodeURIComponent(fromKey),\n [COPY_SOURCE_VERSION_METADATA_KEY]: encodeURIComponent(sourceVersion),\n };\n}\n\n/** Whether an object's custom metadata, read through `readMetadata`, names exactly this provenance. */\nfunction holdsProvenance(readMetadata: (name: string) => unknown, provenance: CopyProvenance): boolean {\n return Object.entries(provenance).every(([name, value]) => readMetadata(name) === value);\n}\n\n/**\n * Whether an object's custom metadata records a copy of `fromKey`, of whichever source\n * version: `deleteCopy` reads only the destination, so it cannot know the source's version.\n * A record naming the source without a version is not provenance this package wrote.\n */\nfunction recordsCopyOf(readMetadata: (name: string) => unknown, fromKey: string): boolean {\n const version = readMetadata(COPY_SOURCE_VERSION_METADATA_KEY);\n return (\n readMetadata(COPY_SOURCE_METADATA_KEY) === encodeURIComponent(fromKey) &&\n typeof version === \"string\" &&\n version !== \"\"\n );\n}\n\n/** The content headers a copy carries from its source: HTTP header name → Cloud Storage field. */\nconst CARRIED_CONTENT_HEADERS = {\n \"content-type\": \"contentType\",\n \"cache-control\": \"cacheControl\",\n \"content-disposition\": \"contentDisposition\",\n \"content-encoding\": \"contentEncoding\",\n} as const;\n\ntype CarriedContentField = (typeof CARRIED_CONTENT_HEADERS)[keyof typeof CARRIED_CONTENT_HEADERS];\n\nexport interface MediaObjectStore {\n /**\n * Upload a local file to the store at `key`. Objects are written with a\n * one-year `immutable` cache-control, so keys are write-once: a replacement is\n * written under a NEW key and the app repoints its reference to it. Overwriting\n * an existing key would keep serving the old bytes from caches for up to a year.\n */\n putFile(args: { localPath: string; key: string; contentType?: string }): Promise<ObjectWriteResult>;\n /**\n * Server-side copy within the store. It never overwrites and is idempotent: it commits\n * only when `toKey` holds no object, in one call that writes the destination fully\n * formed (the source version's bytes and content headers, its provenance, and this\n * store's token policy). When `toKey` already holds this copy's result — a retry of\n * the same copy of the same source version — it resolves with `alreadyPresent: true`;\n * when it holds anything else, it throws `ObjectAlreadyExistsError` and leaves that\n * object untouched. It never deletes anything.\n */\n copy(args: { fromKey: string; toKey: string }): Promise<ObjectCopyResult>;\n /**\n * Download an object's bytes from the store to a local file (streamed, so a\n * large video never sits fully in memory). Used by safety evidence capture to\n * pull final media — which may live in a different backend (R2) — before\n * writing it into the separate (GCS) evidence vault: capture is inherently\n * read-here-then-write, NOT a server-side copy, because source and vault can\n * be different backends.\n */\n readToFile(args: { key: string; localPath: string }): Promise<ObjectReadResult>;\n /** Delete an object. Missing objects are a no-op, not an error. */\n delete(key: string): Promise<void>;\n /**\n * Delete `toKey` only when the object there is a copy of `fromKey` this package made: its\n * own recorded provenance must name `fromKey` as its source. Only the destination is read,\n * so this works after the source is gone. Any other object — a copy of another source, or\n * one with no provenance — is left untouched and answers `notThisCopy`.\n *\n * Firebase Storage deletes only the generation it checked; an object replaced after the\n * check is checked again, never deleted blind. R2's DeleteObject takes no precondition, so\n * there the delete follows the check unconditioned. That gap is harmless only under the key\n * contract: keys are write-once and a copy never replaces an object, so in the gap the\n * checked object can only be removed; and a copy's key is derived from its source, so the\n * only object that can land there afterwards is another copy of the same source.\n */\n deleteCopy(args: { fromKey: string; toKey: string }): Promise<DeleteCopyResult>;\n}\n\nconst DEFAULT_CACHE_CONTROL = \"public, max-age=31536000, immutable\";\n\n// ---------------------------------------------------------------------------\n// R2 (S3-compatible) store — deployed environments\n// ---------------------------------------------------------------------------\n\nexport interface CreateR2ObjectStoreArgs {\n accountId: string;\n accessKeyId: string;\n secretAccessKey: string;\n bucket: string;\n /** Override for tests; defaults to the real R2 S3 endpoint. */\n endpoint?: string;\n /** Override fetch for tests. */\n fetchImpl?: typeof fetch;\n /** Test seam: override the retry sleep (defaults to real `setTimeout`). */\n sleepImpl?: (ms: number) => Promise<void>;\n /** Test seam: override the backoff jitter source (defaults to `Math.random`). */\n randomImpl?: () => number;\n /** Test seam: override the clock used for HTTP-date `Retry-After` (defaults to `Date.now`). */\n nowImpl?: () => number;\n}\n\nexport function createR2ObjectStore(args: CreateR2ObjectStoreArgs): MediaObjectStore {\n const endpoint = (args.endpoint ?? `https://${args.accountId}.r2.cloudflarestorage.com`).replace(/\\/$/, \"\");\n const client = new AwsClient({\n accessKeyId: args.accessKeyId,\n secretAccessKey: args.secretAccessKey,\n service: \"s3\",\n region: \"auto\",\n });\n const doFetch = args.fetchImpl ?? fetch;\n\n // Retry seams: production defaults are internal; tests inject deterministic\n // sleep/random/now. putFile/copy/readToFile ride the bounded retry helper;\n // delete stays one-shot (never routes through it — see below).\n const defaults = defaultR2RetrySeams();\n const seams: R2RetrySeams = {\n sleep: args.sleepImpl ?? defaults.sleep,\n random: args.randomImpl ?? defaults.random,\n now: args.nowImpl ?? defaults.now,\n };\n\n const objectUrl = (key: string) =>\n `${endpoint}/${args.bucket}/${key.split(\"/\").map(encodeURIComponent).join(\"/\")}`;\n\n async function signedFetch(url: string, init: RequestInit & { headers?: Record<string, string> }) {\n const signed = await client.sign(url, { ...init, aws: { allHeaders: true } } as any);\n return doFetch(signed, { ...(init.body ? { duplex: \"half\" } : {}) } as any);\n }\n\n // A GET whose body is discarded unread, not a HEAD: a HEAD's error response carries no\n // body, so the S3 error code that tells a missing key from a missing bucket would be lost.\n async function readObjectHeaders(key: string, operation: \"copy\" | \"deleteCopy\"): Promise<Headers> {\n return fetchWithR2Retry({\n operation,\n bucket: args.bucket,\n key,\n seams,\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(key), { method: \"GET\" });\n if (!res.ok) return { kind: \"response\" as const, response: res };\n await res.body?.cancel();\n return { kind: \"success\" as const, value: res.headers };\n },\n });\n }\n\n // R2 exposes no object version id, so a source version is its ETag, last-modified time,\n // and size together: replacing the source changes at least one of them unless the new\n // content has the same MD5-derived ETag and lands within the same second. A multipart\n // upload's ETag is not the content's MD5, but it is the same kind of version token.\n function readSourceVersion(headers: Headers, key: string): { etag: string; version: string } {\n const etag = headers.get(\"etag\");\n if (!etag) throw new UnreadableStorageObjectMetadataError(args.bucket, key, \"etag\");\n const lastModified = headers.get(\"last-modified\");\n if (!lastModified) throw new UnreadableStorageObjectMetadataError(args.bucket, key, \"lastModified\");\n const size = headers.get(\"content-length\");\n if (!size) throw new UnreadableStorageObjectMetadataError(args.bucket, key, \"size\");\n return { etag, version: `${etag} ${lastModified} ${size}` };\n }\n\n return {\n async putFile({ localPath, key, contentType }) {\n // stat() once, outside the retry loop: a missing input file is a\n // deterministic local error and must fail immediately, never retry.\n const { size } = await stat(localPath);\n const ct = contentType ?? getMimeFromExt(extractExt(localPath));\n return fetchWithR2Retry({\n operation: \"putFile\",\n bucket: args.bucket,\n key,\n seams,\n // Fresh signed request AND a fresh read stream on every attempt — a\n // consumed stream is never reused.\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(key), {\n method: \"PUT\",\n headers: {\n \"content-type\": ct,\n \"content-length\": String(size),\n \"cache-control\": DEFAULT_CACHE_CONTROL,\n },\n body: createReadStream(localPath) as unknown as BodyInit,\n });\n if (res.ok) {\n return { kind: \"success\" as const, value: { key, sizeBytes: size, contentType: ct } };\n }\n return { kind: \"response\" as const, response: res };\n },\n });\n },\n\n async copy({ fromKey, toKey }) {\n const source = await readObjectHeaders(fromKey, \"copy\");\n const { etag, version } = readSourceVersion(source, fromKey);\n const provenance = copyProvenance(fromKey, version);\n const headers: Record<string, string> = {\n \"x-amz-copy-source\": `/${args.bucket}/${fromKey.split(\"/\").map(encodeURIComponent).join(\"/\")}`,\n // Pins the copy to the source version the provenance names.\n \"x-amz-copy-source-if-match\": etag,\n // R2's destination-conditional CopyObject extension, checked when the copy commits;\n // S3's x-amz-copy-source-if-* headers condition only the source.\n \"cf-copy-destination-if-none-match\": \"*\",\n // The destination takes exactly the headers below rather than the source's, so it\n // commits fully formed in this one call.\n \"x-amz-metadata-directive\": \"REPLACE\",\n };\n for (const name of Object.keys(CARRIED_CONTENT_HEADERS)) {\n const value = source.get(name);\n if (value !== null) headers[name] = value;\n }\n for (const [name, value] of Object.entries(provenance)) headers[`x-amz-meta-${name}`] = value;\n\n try {\n await fetchWithR2Retry({\n operation: \"copy\",\n bucket: args.bucket,\n key: toKey,\n seams,\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(toKey), { method: \"PUT\", headers });\n if (res.ok) return { kind: \"success\" as const, value: undefined };\n return { kind: \"response\" as const, response: res };\n },\n });\n return { key: toKey, alreadyPresent: false };\n } catch (e) {\n if (!(e instanceof R2StorageError && e.status === 412)) throw e;\n // R2 answers 412 both for an existing destination and for a source that changed\n // after it was read; only an existing destination can be this copy's result.\n let destination: Headers;\n try {\n destination = await readObjectHeaders(toKey, \"copy\");\n } catch (readError) {\n if (isObjectNotFoundError(readError)) throw e;\n throw readError;\n }\n if (holdsProvenance((name) => destination.get(`x-amz-meta-${name}`), provenance)) {\n return { key: toKey, alreadyPresent: true };\n }\n throw new ObjectAlreadyExistsError(toKey);\n }\n },\n\n async readToFile({ key, localPath }) {\n return fetchWithR2Retry({\n operation: \"readToFile\",\n bucket: args.bucket,\n key,\n seams,\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(key), { method: \"GET\" });\n if (!res.ok || !res.body) {\n return { kind: \"response\" as const, response: res };\n }\n const contentType = res.headers.get(\"content-type\") ?? NEUTRAL_CONTENT_TYPE;\n // Pipe ONLY after a successful response, and open the destination in\n // truncating mode ('w') on every attempt so a partial download from a\n // prior attempt can never prefix/corrupt this one. res.body is a web\n // ReadableStream; stream it to disk so large media never sits fully in\n // memory. A transient body/network stream failure here throws and is\n // retried by the helper; a deterministic local fs error is not.\n await pipeline(\n Readable.fromWeb(res.body as Parameters<typeof Readable.fromWeb>[0]),\n createWriteStream(localPath, { flags: \"w\" }),\n );\n const { size } = await stat(localPath);\n return { kind: \"success\" as const, value: { sizeBytes: size, contentType } };\n },\n });\n },\n\n async delete(key) {\n // Intentionally one-shot: delete is never retried (see r2-retry.ts header).\n const res = await signedFetch(objectUrl(key), { method: \"DELETE\" });\n // S3 DELETE returns 204 even for missing keys; anything else non-ok is real.\n if (!res.ok && res.status !== 404) {\n throw new R2StorageError({\n operation: \"delete\",\n bucket: args.bucket,\n key,\n attempts: 1,\n status: res.status,\n responseText: await safeText(res),\n });\n }\n },\n\n async deleteCopy({ fromKey, toKey }) {\n let destination: Headers;\n try {\n destination = await readObjectHeaders(toKey, \"deleteCopy\");\n } catch (e) {\n if (isObjectNotFoundError(e)) return \"absent\";\n throw e;\n }\n if (!recordsCopyOf((name) => destination.get(`x-amz-meta-${name}`), fromKey)) return \"notThisCopy\";\n // Unconditioned: R2's DeleteObject honors no precondition header, so none is sent — one\n // it silently ignored would only look like protection. `MediaObjectStore.deleteCopy`\n // states why the gap after the check is harmless. One-shot, like `delete`.\n const res = await signedFetch(objectUrl(toKey), { method: \"DELETE\" });\n if (res.ok) return \"deleted\";\n const error = new R2StorageError({\n operation: \"deleteCopy\",\n bucket: args.bucket,\n key: toKey,\n attempts: 1,\n status: res.status,\n responseText: await safeText(res),\n });\n if (isObjectNotFoundError(error)) return \"absent\";\n throw error;\n },\n };\n}\n\nasync function safeText(res: Response): Promise<string> {\n try {\n return (await res.text()).slice(0, 500);\n } catch {\n return \"<no body>\";\n }\n}\n\n// ---------------------------------------------------------------------------\n// Firebase Storage stores — deployed (token-free) and emulator (fixed token)\n// ---------------------------------------------------------------------------\n\n/** Custom-metadata key Firebase Storage reads download tokens from. */\nconst DOWNLOAD_TOKENS_METADATA_KEY = \"firebaseStorageDownloadTokens\";\n\n/**\n * How many times `deleteCopy` checks a Firebase Storage destination before giving up. Keys\n * are write-once, so one change between the check and the delete is already rare; an object\n * still changing after that is left alone and the precondition failure is rethrown.\n */\nconst DELETE_COPY_MAX_READS = 2;\n\nexport interface CreateFirebaseStorageObjectStoreArgs {\n bucket: Bucket;\n}\n\n/** Firebase Storage store for deployed environments. Token-free (see header). */\nexport function createFirebaseStorageObjectStore(args: CreateFirebaseStorageObjectStoreArgs): MediaObjectStore {\n return createFirebaseStore(args.bucket, null);\n}\n\nexport interface CreateEmulatorObjectStoreArgs extends CreateFirebaseStorageObjectStoreArgs {\n /** Fixed token attached to every object so deterministic emulator URLs work\n * (token URLs bypass rules in the emulator). Pass the app's constant. */\n downloadToken: string;\n}\n\n/** Local dev / tests only: the Firebase Storage store plus a fixed download token. */\nexport function createFirebaseEmulatorObjectStore(args: CreateEmulatorObjectStoreArgs): MediaObjectStore {\n return createFirebaseStore(args.bucket, args.downloadToken);\n}\n\n/** `downloadToken` is the store's token policy: `null` = token-free, a string = that token on every object. */\nfunction createFirebaseStore(bucket: Bucket, downloadToken: string | null): MediaObjectStore {\n async function deleteObject(key: string): Promise<void> {\n try {\n await bucket.file(key).delete();\n } catch (e) {\n if (isObjectNotFoundError(e)) return;\n throw e;\n }\n }\n\n return {\n async putFile({ localPath, key, contentType }) {\n const { size } = await stat(localPath);\n const ct = contentType ?? getMimeFromExt(extractExt(localPath));\n // An upload replaces the object and all of its metadata, so a token-free\n // put carries no custom metadata at all.\n await bucket.upload(localPath, {\n destination: key,\n metadata: {\n contentType: ct,\n cacheControl: DEFAULT_CACHE_CONTROL,\n ...(downloadToken === null ? {} : { metadata: { [DOWNLOAD_TOKENS_METADATA_KEY]: downloadToken } }),\n },\n });\n return { key, sizeBytes: size, contentType: ct };\n },\n\n async copy({ fromKey, toKey }) {\n const [source] = await bucket.file(fromKey).getMetadata();\n const generation = requireStorageObjectGeneration(source, { bucket: bucket.name, key: fromKey });\n const provenance = copyProvenance(fromKey, generation);\n const contentHeaders: Partial<Record<CarriedContentField, string>> = {};\n for (const field of Object.values(CARRIED_CONTENT_HEADERS)) {\n const value = source[field];\n if (typeof value === \"string\" && value !== \"\") contentHeaders[field] = value;\n }\n try {\n // A rewrite's resource REPLACES the destination's metadata rather than merging with\n // the source's, so this one call commits the destination fully formed: the source's\n // content headers, the provenance, and this store's token policy — never a token the\n // source carried. The source is pinned to the generation the provenance names, so a\n // 412 can only mean the destination exists; a replaced source fails as not-found.\n await bucket.file(fromKey, { generation }).copy(bucket.file(toKey), {\n ...contentHeaders,\n metadata: downloadToken === null ? provenance : { ...provenance, [DOWNLOAD_TOKENS_METADATA_KEY]: downloadToken },\n preconditionOpts: { ifGenerationMatch: 0 },\n });\n return { key: toKey, alreadyPresent: false };\n } catch (e) {\n if (!isPreconditionFailedError(e)) throw e;\n let destinationMetadata: Record<string, unknown> | undefined;\n try {\n const [destination] = await bucket.file(toKey).getMetadata();\n destinationMetadata = destination.metadata ?? undefined;\n } catch (readError) {\n if (isObjectNotFoundError(readError)) throw e;\n throw readError;\n }\n if (holdsProvenance((name) => destinationMetadata?.[name], provenance)) {\n return { key: toKey, alreadyPresent: true };\n }\n throw new ObjectAlreadyExistsError(toKey);\n }\n },\n\n async readToFile({ key, localPath }) {\n const file = bucket.file(key);\n await file.download({ destination: localPath });\n const [meta] = await file.getMetadata();\n const { size } = await stat(localPath);\n const contentType = (meta.contentType as string | undefined) ?? NEUTRAL_CONTENT_TYPE;\n return { sizeBytes: size, contentType };\n },\n\n delete: deleteObject,\n\n async deleteCopy({ fromKey, toKey }) {\n const file = bucket.file(toKey);\n for (let read = 1; ; read++) {\n let custom: Record<string, unknown> | undefined;\n let generation: string | number | null | undefined;\n try {\n const [destination] = await file.getMetadata();\n custom = destination.metadata ?? undefined;\n generation = destination.generation;\n } catch (e) {\n if (isObjectNotFoundError(e)) return \"absent\";\n throw e;\n }\n if (!recordsCopyOf((name) => custom?.[name], fromKey)) return \"notThisCopy\";\n // The delete names the generation just checked, so it can only remove that object.\n const checked = requireStorageObjectGeneration({ generation }, { bucket: bucket.name, key: toKey });\n try {\n await file.delete({ ifGenerationMatch: checked });\n return \"deleted\";\n } catch (e) {\n if (isObjectNotFoundError(e)) return \"absent\";\n // A 412 means the object changed after it was checked: check what is there now.\n if (!isPreconditionFailedError(e) || read >= DELETE_COPY_MAX_READS) throw e;\n }\n }\n },\n };\n}\n\n/** The Cloud Storage Admin SDK's numeric `412`: a generation precondition did not hold. */\nfunction isPreconditionFailedError(e: unknown): boolean {\n return (e as { code?: unknown } | null | undefined)?.code === 412;\n}\n\n// ---------------------------------------------------------------------------\n\nfunction extractExt(localPath: string): string {\n return localPath.split(\".\").pop() || \"\";\n}\n\nexport function getMimeFromExt(ext: string): string {\n switch (ext.toLowerCase()) {\n case \"jpg\":\n case \"jpeg\":\n return \"image/jpeg\";\n case \"png\":\n return \"image/png\";\n case \"webp\":\n return \"image/webp\";\n case \"mp4\":\n return \"video/mp4\";\n case \"webm\":\n return \"video/webm\";\n case \"m4a\":\n return \"audio/mp4\";\n case \"aac\":\n return \"audio/aac\";\n case \"mp3\":\n return \"audio/mpeg\";\n default:\n return NEUTRAL_CONTENT_TYPE;\n }\n}\n"]}
1
+ {"version":3,"file":"storage-ops.js","sourceRoot":"","sources":["../../src/server/storage-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,GAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACrB;IAA5B,YAA4B,GAAW;QACrC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAD7B,QAAG,GAAH,GAAG,CAAQ;QAErC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAuBD,gFAAgF;AAChF,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAC/C,MAAM,gCAAgC,GAAG,qBAAqB,CAAC;AAO/D,SAAS,cAAc,CAAC,OA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KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,WAAW,CAAC;QACrB,KAAK,KAAK;YACR,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,oBAAoB,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["import { createReadStream, createWriteStream } from 'node:fs';\nimport { stat } from 'node:fs/promises';\nimport { Readable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport { AwsClient } from 'aws4fetch';\nimport type { getStorage } from 'firebase-admin/storage';\nimport { NEUTRAL_CONTENT_TYPE } from '@ttt-productions/media-schemas';\nimport { isObjectNotFoundError } from './gcs-errors.js';\nimport {\n defaultR2RetrySeams,\n fetchWithR2Retry,\n R2StorageError,\n type R2RetrySeams,\n} from './r2-retry.js';\nimport {\n requireStorageObjectGeneration,\n UnreadableStorageObjectMetadataError,\n} from './staged-object.js';\n\nexport class ObjectAlreadyExistsError extends Error {\n constructor(public readonly key: string) {\n super('copy destination already holds another object');\n this.name = 'ObjectAlreadyExistsError';\n }\n}\n\n/** Inferred from usage so the package takes no @google-cloud/storage dependency. */\nexport type Bucket = ReturnType<ReturnType<typeof getStorage>['bucket']>;\n\nexport interface ObjectWriteResult {\n key: string;\n sizeBytes: number;\n contentType: string;\n}\n\nexport interface ObjectReadResult {\n sizeBytes: number;\n contentType: string;\n}\n\nexport interface ObjectCopyResult {\n key: string;\n alreadyPresent: boolean;\n}\n\nexport type DeleteCopyResult = 'deleted' | 'absent' | 'notThisCopy';\n\n// URI-encoded: R2 carries custom metadata in HTTP headers, which must be ASCII.\nconst COPY_SOURCE_METADATA_KEY = 'copy-source';\nconst COPY_SOURCE_VERSION_METADATA_KEY = 'copy-source-version';\n\ntype CopyProvenance = Record<\n typeof COPY_SOURCE_METADATA_KEY | typeof COPY_SOURCE_VERSION_METADATA_KEY,\n string\n>;\n\nfunction copyProvenance(fromKey: string, sourceVersion: string): CopyProvenance {\n return {\n [COPY_SOURCE_METADATA_KEY]: encodeURIComponent(fromKey),\n [COPY_SOURCE_VERSION_METADATA_KEY]: encodeURIComponent(sourceVersion),\n };\n}\n\nfunction holdsProvenance(\n readMetadata: (name: string) => unknown,\n provenance: CopyProvenance,\n): boolean {\n return Object.entries(provenance).every(([name, value]) => readMetadata(name) === value);\n}\n\nfunction recordsCopyOf(readMetadata: (name: string) => unknown, fromKey: string): boolean {\n const version = readMetadata(COPY_SOURCE_VERSION_METADATA_KEY);\n return (\n readMetadata(COPY_SOURCE_METADATA_KEY) === encodeURIComponent(fromKey) &&\n typeof version === 'string' &&\n version !== ''\n );\n}\n\nconst CARRIED_CONTENT_HEADERS = {\n 'content-type': 'contentType',\n 'cache-control': 'cacheControl',\n 'content-disposition': 'contentDisposition',\n 'content-encoding': 'contentEncoding',\n} as const;\n\ntype CarriedContentField = (typeof CARRIED_CONTENT_HEADERS)[keyof typeof CARRIED_CONTENT_HEADERS];\n\nexport interface MediaObjectStore {\n /** Objects carry a one-year `immutable` cache-control, so a key is write-once: an overwrite keeps serving the old bytes from caches. */\n putFile(args: {\n localPath: string;\n key: string;\n contentType?: string;\n }): Promise<ObjectWriteResult>;\n copy(args: { fromKey: string; toKey: string }): Promise<ObjectCopyResult>;\n readToFile(args: { key: string; localPath: string }): Promise<ObjectReadResult>;\n delete(key: string): Promise<void>;\n deleteCopy(args: { fromKey: string; toKey: string }): Promise<DeleteCopyResult>;\n}\n\nconst DEFAULT_CACHE_CONTROL = 'public, max-age=31536000, immutable';\n\nexport interface CreateR2ObjectStoreArgs {\n accountId: string;\n accessKeyId: string;\n secretAccessKey: string;\n bucket: string;\n endpoint?: string;\n fetchImpl?: typeof fetch;\n sleepImpl?: (ms: number) => Promise<void>;\n randomImpl?: () => number;\n nowImpl?: () => number;\n}\n\nexport function createR2ObjectStore(args: CreateR2ObjectStoreArgs): MediaObjectStore {\n const endpoint = (args.endpoint ?? `https://${args.accountId}.r2.cloudflarestorage.com`).replace(\n /\\/$/,\n '',\n );\n const client = new AwsClient({\n accessKeyId: args.accessKeyId,\n secretAccessKey: args.secretAccessKey,\n service: 's3',\n region: 'auto',\n });\n const doFetch = args.fetchImpl ?? fetch;\n\n const defaults = defaultR2RetrySeams();\n const seams: R2RetrySeams = {\n sleep: args.sleepImpl ?? defaults.sleep,\n random: args.randomImpl ?? defaults.random,\n now: args.nowImpl ?? defaults.now,\n };\n\n const objectUrl = (key: string) =>\n `${endpoint}/${args.bucket}/${key.split('/').map(encodeURIComponent).join('/')}`;\n\n async function signedFetch(\n url: string,\n init: RequestInit & { headers?: Record<string, string> },\n ) {\n const signed = await client.sign(url, { ...init, aws: { allHeaders: true } } as any);\n return doFetch(signed, { ...(init.body ? { duplex: 'half' } : {}) } as any);\n }\n\n // A GET, not a HEAD: a HEAD's error response has no body, so the S3 error code would be lost.\n async function readObjectHeaders(\n key: string,\n operation: 'copy' | 'deleteCopy',\n ): Promise<Headers> {\n return fetchWithR2Retry({\n operation,\n bucket: args.bucket,\n key,\n seams,\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(key), { method: 'GET' });\n if (!res.ok) return { kind: 'response' as const, response: res };\n await res.body?.cancel();\n return { kind: 'success' as const, value: res.headers };\n },\n });\n }\n\n // R2 exposes no object version id, so a source version is its ETag, last-modified time, and size together.\n function readSourceVersion(headers: Headers, key: string): { etag: string; version: string } {\n const etag = headers.get('etag');\n if (!etag) throw new UnreadableStorageObjectMetadataError(args.bucket, key, 'etag');\n const lastModified = headers.get('last-modified');\n if (!lastModified)\n throw new UnreadableStorageObjectMetadataError(args.bucket, key, 'lastModified');\n const size = headers.get('content-length');\n if (!size) throw new UnreadableStorageObjectMetadataError(args.bucket, key, 'size');\n return { etag, version: `${etag} ${lastModified} ${size}` };\n }\n\n return {\n async putFile({ localPath, key, contentType }) {\n const { size } = await stat(localPath);\n const ct = contentType ?? getMimeFromExt(extractExt(localPath));\n return fetchWithR2Retry({\n operation: 'putFile',\n bucket: args.bucket,\n key,\n seams,\n // A fresh signed request and read stream on every attempt: a consumed stream cannot be re-read.\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(key), {\n method: 'PUT',\n headers: {\n 'content-type': ct,\n 'content-length': String(size),\n 'cache-control': DEFAULT_CACHE_CONTROL,\n },\n body: createReadStream(localPath) as unknown as BodyInit,\n });\n if (res.ok) {\n return { kind: 'success' as const, value: { key, sizeBytes: size, contentType: ct } };\n }\n return { kind: 'response' as const, response: res };\n },\n });\n },\n\n async copy({ fromKey, toKey }) {\n const source = await readObjectHeaders(fromKey, 'copy');\n const { etag, version } = readSourceVersion(source, fromKey);\n const provenance = copyProvenance(fromKey, version);\n const headers: Record<string, string> = {\n 'x-amz-copy-source': `/${args.bucket}/${fromKey.split('/').map(encodeURIComponent).join('/')}`,\n 'x-amz-copy-source-if-match': etag,\n // R2's destination-conditional CopyObject extension; S3's x-amz-copy-source-if-* headers condition only the source.\n 'cf-copy-destination-if-none-match': '*',\n 'x-amz-metadata-directive': 'REPLACE',\n };\n for (const name of Object.keys(CARRIED_CONTENT_HEADERS)) {\n const value = source.get(name);\n if (value !== null) headers[name] = value;\n }\n for (const [name, value] of Object.entries(provenance)) headers[`x-amz-meta-${name}`] = value;\n\n try {\n await fetchWithR2Retry({\n operation: 'copy',\n bucket: args.bucket,\n key: toKey,\n seams,\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(toKey), { method: 'PUT', headers });\n if (res.ok) return { kind: 'success' as const, value: undefined };\n return { kind: 'response' as const, response: res };\n },\n });\n return { key: toKey, alreadyPresent: false };\n } catch (e) {\n if (!(e instanceof R2StorageError && e.status === 412)) throw e;\n // R2 answers 412 both for an existing destination and for a source that changed after it was read.\n let destination: Headers;\n try {\n destination = await readObjectHeaders(toKey, 'copy');\n } catch (readError) {\n if (isObjectNotFoundError(readError)) throw e;\n throw readError;\n }\n if (holdsProvenance((name) => destination.get(`x-amz-meta-${name}`), provenance)) {\n return { key: toKey, alreadyPresent: true };\n }\n throw new ObjectAlreadyExistsError(toKey);\n }\n },\n\n async readToFile({ key, localPath }) {\n return fetchWithR2Retry({\n operation: 'readToFile',\n bucket: args.bucket,\n key,\n seams,\n runAttempt: async () => {\n const res = await signedFetch(objectUrl(key), { method: 'GET' });\n if (!res.ok || !res.body) {\n return { kind: 'response' as const, response: res };\n }\n const contentType = res.headers.get('content-type') ?? NEUTRAL_CONTENT_TYPE;\n // Truncating mode ('w') on every attempt, so a partial earlier download never prefixes this one.\n await pipeline(\n Readable.fromWeb(res.body as Parameters<typeof Readable.fromWeb>[0]),\n createWriteStream(localPath, { flags: 'w' }),\n );\n const { size } = await stat(localPath);\n return { kind: 'success' as const, value: { sizeBytes: size, contentType } };\n },\n });\n },\n\n async delete(key) {\n const res = await signedFetch(objectUrl(key), { method: 'DELETE' });\n // S3 DELETE returns 204 even for missing keys; anything else non-ok is real.\n if (!res.ok && res.status !== 404) {\n throw new R2StorageError({\n operation: 'delete',\n bucket: args.bucket,\n key,\n attempts: 1,\n status: res.status,\n responseText: await safeText(res),\n });\n }\n },\n\n async deleteCopy({ fromKey, toKey }) {\n let destination: Headers;\n try {\n destination = await readObjectHeaders(toKey, 'deleteCopy');\n } catch (e) {\n if (isObjectNotFoundError(e)) return 'absent';\n throw e;\n }\n if (!recordsCopyOf((name) => destination.get(`x-amz-meta-${name}`), fromKey))\n return 'notThisCopy';\n // R2's DeleteObject honors no precondition header, so none is sent.\n const res = await signedFetch(objectUrl(toKey), { method: 'DELETE' });\n if (res.ok) return 'deleted';\n const error = new R2StorageError({\n operation: 'deleteCopy',\n bucket: args.bucket,\n key: toKey,\n attempts: 1,\n status: res.status,\n responseText: await safeText(res),\n });\n if (isObjectNotFoundError(error)) return 'absent';\n throw error;\n },\n };\n}\n\nasync function safeText(res: Response): Promise<string> {\n try {\n return (await res.text()).slice(0, 500);\n } catch {\n return '<no body>';\n }\n}\n\nconst DOWNLOAD_TOKENS_METADATA_KEY = 'firebaseStorageDownloadTokens';\n\nconst DELETE_COPY_MAX_READS = 2;\n\nexport interface CreateFirebaseStorageObjectStoreArgs {\n bucket: Bucket;\n}\n\nexport function createFirebaseStorageObjectStore(\n args: CreateFirebaseStorageObjectStoreArgs,\n): MediaObjectStore {\n return createFirebaseStore(args.bucket, null);\n}\n\nexport interface CreateEmulatorObjectStoreArgs extends CreateFirebaseStorageObjectStoreArgs {\n downloadToken: string;\n}\n\nexport function createFirebaseEmulatorObjectStore(\n args: CreateEmulatorObjectStoreArgs,\n): MediaObjectStore {\n return createFirebaseStore(args.bucket, args.downloadToken);\n}\n\nfunction createFirebaseStore(bucket: Bucket, downloadToken: string | null): MediaObjectStore {\n async function deleteObject(key: string): Promise<void> {\n try {\n await bucket.file(key).delete();\n } catch (e) {\n if (isObjectNotFoundError(e)) return;\n throw e;\n }\n }\n\n return {\n async putFile({ localPath, key, contentType }) {\n const { size } = await stat(localPath);\n const ct = contentType ?? getMimeFromExt(extractExt(localPath));\n await bucket.upload(localPath, {\n destination: key,\n metadata: {\n contentType: ct,\n cacheControl: DEFAULT_CACHE_CONTROL,\n ...(downloadToken === null\n ? {}\n : { metadata: { [DOWNLOAD_TOKENS_METADATA_KEY]: downloadToken } }),\n },\n });\n return { key, sizeBytes: size, contentType: ct };\n },\n\n async copy({ fromKey, toKey }) {\n const [source] = await bucket.file(fromKey).getMetadata();\n const generation = requireStorageObjectGeneration(source, {\n bucket: bucket.name,\n key: fromKey,\n });\n const provenance = copyProvenance(fromKey, generation);\n const contentHeaders: Partial<Record<CarriedContentField, string>> = {};\n for (const field of Object.values(CARRIED_CONTENT_HEADERS)) {\n const value = source[field];\n if (typeof value === 'string' && value !== '') contentHeaders[field] = value;\n }\n try {\n // A rewrite's resource replaces the destination's metadata rather than merging with the source's.\n await bucket.file(fromKey, { generation }).copy(bucket.file(toKey), {\n ...contentHeaders,\n metadata:\n downloadToken === null\n ? provenance\n : { ...provenance, [DOWNLOAD_TOKENS_METADATA_KEY]: downloadToken },\n preconditionOpts: { ifGenerationMatch: 0 },\n });\n return { key: toKey, alreadyPresent: false };\n } catch (e) {\n if (!isPreconditionFailedError(e)) throw e;\n let destinationMetadata: Record<string, unknown> | undefined;\n try {\n const [destination] = await bucket.file(toKey).getMetadata();\n destinationMetadata = destination.metadata ?? undefined;\n } catch (readError) {\n if (isObjectNotFoundError(readError)) throw e;\n throw readError;\n }\n if (holdsProvenance((name) => destinationMetadata?.[name], provenance)) {\n return { key: toKey, alreadyPresent: true };\n }\n throw new ObjectAlreadyExistsError(toKey);\n }\n },\n\n async readToFile({ key, localPath }) {\n const file = bucket.file(key);\n await file.download({ destination: localPath });\n const [meta] = await file.getMetadata();\n const { size } = await stat(localPath);\n const contentType = (meta.contentType as string | undefined) ?? NEUTRAL_CONTENT_TYPE;\n return { sizeBytes: size, contentType };\n },\n\n delete: deleteObject,\n\n async deleteCopy({ fromKey, toKey }) {\n const file = bucket.file(toKey);\n for (let read = 1; ; read++) {\n let custom: Record<string, unknown> | undefined;\n let generation: string | number | null | undefined;\n try {\n const [destination] = await file.getMetadata();\n custom = destination.metadata ?? undefined;\n generation = destination.generation;\n } catch (e) {\n if (isObjectNotFoundError(e)) return 'absent';\n throw e;\n }\n if (!recordsCopyOf((name) => custom?.[name], fromKey)) return 'notThisCopy';\n const checked = requireStorageObjectGeneration(\n { generation },\n { bucket: bucket.name, key: toKey },\n );\n try {\n await file.delete({ ifGenerationMatch: checked });\n return 'deleted';\n } catch (e) {\n if (isObjectNotFoundError(e)) return 'absent';\n if (!isPreconditionFailedError(e) || read >= DELETE_COPY_MAX_READS) throw e;\n }\n }\n },\n };\n}\n\nfunction isPreconditionFailedError(e: unknown): boolean {\n return (e as { code?: unknown } | null | undefined)?.code === 412;\n}\n\nfunction extractExt(localPath: string): string {\n return localPath.split('.').pop() || '';\n}\n\nexport function getMimeFromExt(ext: string): string {\n switch (ext.toLowerCase()) {\n case 'jpg':\n case 'jpeg':\n return 'image/jpeg';\n case 'png':\n return 'image/png';\n case 'webp':\n return 'image/webp';\n case 'mp4':\n return 'video/mp4';\n case 'webm':\n return 'video/webm';\n case 'm4a':\n return 'audio/mp4';\n case 'aac':\n return 'audio/aac';\n case 'mp3':\n return 'audio/mpeg';\n default:\n return NEUTRAL_CONTENT_TYPE;\n }\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -1,14 +1,12 @@
1
- import type { MediaProcessingResult, MediaProcessingSpec } from "@ttt-productions/media-schemas";
1
+ import type { MediaProcessingResult, MediaProcessingSpec } from '@ttt-productions/media-schemas';
2
2
  export interface MediaPipelineProgress {
3
- phase: "read_input" | "moderation_input" | "process" | "persist_outputs" | "moderation_output" | "done";
4
- /** 0..1 when known */
3
+ phase: 'read_input' | 'moderation_input' | 'process' | 'persist_outputs' | 'moderation_output' | 'done';
5
4
  percent?: number;
6
5
  detail?: Record<string, unknown>;
7
6
  }
8
7
  export interface ProcessMediaContext {
9
8
  inputPath: string;
10
9
  outputBasePath: string;
11
- /** optional mime hint from caller */
12
10
  inputMime?: string;
13
11
  }
14
12
  export interface ProcessMediaOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAEjG,MAAM,WAAW,qBAAqB;IACpC,KAAK,EACD,YAAY,GACZ,kBAAkB,GAClB,SAAS,GACT,iBAAiB,GACjB,mBAAmB,GACnB,MAAM,CAAC;IACX,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAA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ACxB,IAAI,CAAC,EAAE,mBAAmB,KACvB,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,cAAc,CAAC;CACvB"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MediaProcessingResult, MediaProcessingSpec } from \"@ttt-productions/media-schemas\";\n\nexport interface MediaPipelineProgress {\n phase:\n | \"read_input\"\n | \"moderation_input\"\n | \"process\"\n | \"persist_outputs\"\n | \"moderation_output\"\n | \"done\";\n /** 0..1 when known */\n percent?: number;\n detail?: Record<string, unknown>;\n}\n\nexport interface ProcessMediaContext {\n inputPath: string;\n outputBasePath: string;\n /** optional mime hint from caller */\n inputMime?: string;\n}\n\nexport interface ProcessMediaOptions {\n signal?: AbortSignal;\n onProgress?: (p: MediaPipelineProgress) => void;\n}\n\nexport type ProcessMediaFn = (\n spec: MediaProcessingSpec,\n ctx: ProcessMediaContext,\n opts?: ProcessMediaOptions\n) => Promise<MediaProcessingResult>;\n\nexport interface MediaProcessors {\n image: ProcessMediaFn;\n video: ProcessMediaFn;\n audio: ProcessMediaFn;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MediaProcessingResult, MediaProcessingSpec } from '@ttt-productions/media-schemas';\n\nexport interface MediaPipelineProgress {\n phase:\n | 'read_input'\n | 'moderation_input'\n | 'process'\n | 'persist_outputs'\n | 'moderation_output'\n | 'done';\n percent?: number;\n detail?: Record<string, unknown>;\n}\n\nexport interface ProcessMediaContext {\n inputPath: string;\n outputBasePath: string;\n inputMime?: string;\n}\n\nexport interface ProcessMediaOptions {\n signal?: AbortSignal;\n onProgress?: (p: MediaPipelineProgress) => void;\n}\n\nexport type ProcessMediaFn = (\n spec: MediaProcessingSpec,\n ctx: ProcessMediaContext,\n opts?: ProcessMediaOptions,\n) => Promise<MediaProcessingResult>;\n\nexport interface MediaProcessors {\n image: ProcessMediaFn;\n video: ProcessMediaFn;\n audio: ProcessMediaFn;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAEnC;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAEtC;AAED,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAEvC"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAErC;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAEtC;AAED,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAEvC"}
package/dist/utils/log.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export function log(...args) {
2
- console.log("[media-processing]", ...args);
2
+ console.log('[media-processing]', ...args);
3
3
  }
4
4
  export function warn(...args) {
5
- console.warn("[media-processing]", ...args);
5
+ console.warn('[media-processing]', ...args);
6
6
  }
7
7
  export function error(...args) {
8
- console.error("[media-processing]", ...args);
8
+ console.error('[media-processing]', ...args);
9
9
  }
10
10
  //# sourceMappingURL=log.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,GAAG,IAAe;IAClC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAG,IAAe;IACtC,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["export function log(...args: unknown[]) {\n console.log(\"[media-processing]\", ...args);\n }\n \n export function warn(...args: unknown[]) {\n console.warn(\"[media-processing]\", ...args);\n }\n \n export function error(...args: unknown[]) {\n console.error(\"[media-processing]\", ...args);\n }\n "]}
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,GAAG,IAAe;IACpC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAG,IAAe;IACtC,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["export function log(...args: unknown[]) {\n console.log('[media-processing]', ...args);\n}\n\nexport function warn(...args: unknown[]) {\n console.warn('[media-processing]', ...args);\n}\n\nexport function error(...args: unknown[]) {\n console.error('[media-processing]', ...args);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,UAKxC"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,UAE1C"}
@@ -1,7 +1,4 @@
1
1
  export function joinPath(...parts) {
2
- return parts
3
- .filter(Boolean)
4
- .join("/")
5
- .replace(/\/+/g, "/");
2
+ return parts.filter(Boolean).join('/').replace(/\/+/g, '/');
6
3
  }
7
4
  //# sourceMappingURL=paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAe;IACvC,OAAO,KAAK;SACT,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["export function joinPath(...parts: string[]) {\n return parts\n .filter(Boolean)\n .join(\"/\")\n .replace(/\\/+/g, \"/\");\n }\n "]}
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAe;IACzC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["export function joinPath(...parts: string[]) {\n return parts.filter(Boolean).join('/').replace(/\\/+/g, '/');\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"safe-path.d.ts","sourceRoot":"","sources":["../../src/utils/safe-path.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAchF"}
1
+ {"version":3,"file":"safe-path.d.ts","sourceRoot":"","sources":["../../src/utils/safe-path.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAchF"}
@@ -1,22 +1,21 @@
1
- import path from "node:path";
2
- // Very conservative key sanitizer. Prevents path traversal / separators.
1
+ import path from 'node:path';
3
2
  export function sanitizeKey(key) {
4
- const k = String(key ?? "");
5
- const stripped = k.replace(/[\\/]+/g, "_");
6
- const cleaned = stripped.replace(/\.+/g, "."); // collapse long dot runs
7
- const safe = cleaned.replace(/[^a-zA-Z0-9._-]/g, "_");
8
- return safe.slice(0, 80) || "file";
3
+ const k = String(key ?? '');
4
+ const stripped = k.replace(/[\\/]+/g, '_');
5
+ const cleaned = stripped.replace(/\.+/g, '.');
6
+ const safe = cleaned.replace(/[^a-zA-Z0-9._-]/g, '_');
7
+ return safe.slice(0, 80) || 'file';
9
8
  }
10
9
  export function safeOutputPathFor(base, key, ext) {
11
10
  const safeKey = sanitizeKey(key);
12
- const safeExt = sanitizeKey(ext).replace(/^\./, "");
11
+ const safeExt = sanitizeKey(ext).replace(/^\./, '');
13
12
  const dir = path.dirname(base);
14
13
  const baseName = path.basename(base);
15
14
  const out = path.join(dir, `${baseName}_${safeKey}.${safeExt}`);
16
15
  const resolvedDir = path.resolve(dir);
17
16
  const resolvedOut = path.resolve(out);
18
17
  if (!resolvedOut.startsWith(resolvedDir + path.sep) && resolvedOut !== resolvedDir) {
19
- throw new Error("Unsafe output path");
18
+ throw new Error('Unsafe output path');
20
19
  }
21
20
  return out;
22
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"safe-path.js","sourceRoot":"","sources":["../../src/utils/safe-path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,yEAAyE;AACzE,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,CAAC,GAAG,MAAM,CAAC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path traversal / separators.\nexport function sanitizeKey(key: string): string {\n const k = String(key ?? \"\");\n const stripped = k.replace(/[\\\\/]+/g, \"_\");\n const cleaned = stripped.replace(/\\.+/g, \".\"); // collapse long dot runs\n const safe = cleaned.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n return safe.slice(0, 80) || \"file\";\n}\n\nexport function safeOutputPathFor(base: string, key: string, ext: string): string {\n const safeKey = sanitizeKey(key);\n const safeExt = sanitizeKey(ext).replace(/^\\./, \"\");\n const dir = path.dirname(base);\n const baseName = path.basename(base);\n const out = path.join(dir, `${baseName}_${safeKey}.${safeExt}`);\n\n const resolvedDir = path.resolve(dir);\n const resolvedOut = path.resolve(out);\n if (!resolvedOut.startsWith(resolvedDir + path.sep) && resolvedOut !== resolvedDir) {\n throw new Error(\"Unsafe output path\");\n }\n\n return out;\n}\n"]}
1
+ {"version":3,"file":"safe-path.js","sourceRoot":"","sources":["../../src/utils/safe-path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,GAAW,EAAE,GAAW;IACtE,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;IAEhE,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,WAAW,KAAK,WAAW,EAAE,CAAC;QACnF,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import path from 'node:path';\n\nexport function sanitizeKey(key: string): string {\n const k = String(key ?? '');\n const stripped = k.replace(/[\\\\/]+/g, '_');\n const cleaned = stripped.replace(/\\.+/g, '.');\n const safe = cleaned.replace(/[^a-zA-Z0-9._-]/g, '_');\n return safe.slice(0, 80) || 'file';\n}\n\nexport function safeOutputPathFor(base: string, key: string, ext: string): string {\n const safeKey = sanitizeKey(key);\n const safeExt = sanitizeKey(ext).replace(/^\\./, '');\n const dir = path.dirname(base);\n const baseName = path.basename(base);\n const out = path.join(dir, `${baseName}_${safeKey}.${safeExt}`);\n\n const resolvedDir = path.resolve(dir);\n const resolvedOut = path.resolve(out);\n if (!resolvedOut.startsWith(resolvedDir + path.sep) && resolvedOut !== resolvedDir) {\n throw new Error('Unsafe output path');\n }\n\n return out;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-duration.d.ts","sourceRoot":"","sources":["../../src/validation/validate-duration.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAET"}
1
+ {"version":3,"file":"validate-duration.d.ts","sourceRoot":"","sources":["../../src/validation/validate-duration.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAErF"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-duration.js","sourceRoot":"","sources":["../../src/validation/validate-duration.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAC5B,WAAmB,EACnB,cAAsB;IAEtB,OAAO,WAAW,IAAI,cAAc,CAAC;AACvC,CAAC","sourcesContent":["export function validateDuration(\n durationSec: number,\n maxDurationSec: number\n ): boolean {\n return durationSec <= maxDurationSec;\n }\n "]}
1
+ {"version":3,"file":"validate-duration.js","sourceRoot":"","sources":["../../src/validation/validate-duration.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,cAAsB;IAC1E,OAAO,WAAW,IAAI,cAAc,CAAC;AACvC,CAAC","sourcesContent":["export function validateDuration(durationSec: number, maxDurationSec: number): boolean {\n return durationSec <= maxDurationSec;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-mime.d.ts","sourceRoot":"","sources":["../../src/validation/validate-mime.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAET"}
1
+ {"version":3,"file":"validate-mime.d.ts","sourceRoot":"","sources":["../../src/validation/validate-mime.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAErE"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-mime.js","sourceRoot":"","sources":["../../src/validation/validate-mime.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CACxB,IAAY,EACZ,OAAiB;IAEjB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["export function validateMime(\n mime: string,\n allowed: string[]\n ): boolean {\n return allowed.includes(mime);\n }\n "]}
1
+ {"version":3,"file":"validate-mime.js","sourceRoot":"","sources":["../../src/validation/validate-mime.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAiB;IAC1D,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["export function validateMime(mime: string, allowed: string[]): boolean {\n return allowed.includes(mime);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-size.d.ts","sourceRoot":"","sources":["../../src/validation/validate-size.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CACxB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAET"}
1
+ {"version":3,"file":"validate-size.d.ts","sourceRoot":"","sources":["../../src/validation/validate-size.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErE"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate-size.js","sourceRoot":"","sources":["../../src/validation/validate-size.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CACxB,KAAa,EACb,QAAgB;IAEhB,OAAO,KAAK,IAAI,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["export function validateSize(\n bytes: number,\n maxBytes: number\n ): boolean {\n return bytes <= maxBytes;\n }\n "]}
1
+ {"version":3,"file":"validate-size.js","sourceRoot":"","sources":["../../src/validation/validate-size.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,QAAgB;IAC1D,OAAO,KAAK,IAAI,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["export function validateSize(bytes: number, maxBytes: number): boolean {\n return bytes <= maxBytes;\n}\n"]}
@@ -1,51 +1,29 @@
1
1
  export interface RunCmdResult {
2
- /** The exit code; `-1` when the process was ended by a signal, so a child
3
- * killed partway (a crash, an outside kill) never reads as a clean exit. */
4
2
  code: number;
5
3
  stdout: string;
6
4
  stderr: string;
7
- /** True when the process was killed by the wall-clock timeout (see runCmd
8
- * opts.timeoutMs). Callers must treat a timed-out result as INVALID —
9
- * never parse its partial output as an answer. */
10
5
  timedOut?: boolean;
11
- /** True when a captured stream hit the 1 MiB cap — the output is truncated
12
- * and must not be parsed as complete (e.g. incomplete probe JSON). */
13
6
  truncated?: boolean;
14
7
  }
15
- export type FfmpegProgressPhase = "transcode" | "poster";
8
+ export type FfmpegProgressPhase = 'transcode' | 'poster';
16
9
  export interface RunFfmpegOptions {
17
10
  cwd?: string;
18
11
  signal?: AbortSignal;
19
- /** Optional total duration in milliseconds (used to compute percent). */
20
12
  durationMs?: number;
21
13
  onProgress?: (p: {
22
14
  phase: FfmpegProgressPhase;
23
15
  percent?: number;
24
16
  outTimeMs?: number;
25
17
  }) => void;
26
- /** Which phase to report in callbacks. */
27
18
  phase?: FfmpegProgressPhase;
28
19
  }
29
- /** Wall-clock ceiling for an ffprobe call that opens a file and reads its
30
- * stream table (metadata only, never every packet). */
31
20
  export declare const DEFAULT_PROBE_TIMEOUT_MS = 20000;
32
21
  export declare function runCmd(cmd: string, args: string[], opts?: {
33
22
  cwd?: string;
34
- /** Hard wall-clock ceiling; on expiry the child is SIGKILLed and the
35
- * result resolves with `timedOut: true`. A malformed/adversarial input
36
- * must never be able to wedge a warm instance. */
37
23
  timeoutMs?: number;
38
- /** Abort kills the child immediately (same SIGKILL path as the timeout). */
39
24
  signal?: AbortSignal;
40
- /** Receives stdout one line at a time instead of capturing it, so a
41
- * listing of any length is read in bounded memory; `stdout` is then
42
- * empty. A single line over the capture cap sets `truncated`. */
43
25
  onStdoutLine?: (line: string) => void;
44
26
  }): Promise<RunCmdResult>;
45
- /**
46
- * Runs ffmpeg with optional AbortSignal + progress reporting.
47
- * If onProgress is provided, ffmpeg is invoked with "-progress pipe:1".
48
- */
49
27
  export declare function runFfmpeg(args: string[], opts?: RunFfmpegOptions): Promise<RunCmdResult>;
50
28
  export declare function ensureFfmpegAvailable(): Promise<{
51
29
  ok: true;
@@ -1 +1 @@
1
- {"version":3,"file":"ffmpeg.d.ts","sourceRoot":"","sources":["../../src/video/ffmpeg.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B;iFAC6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf;;uDAEmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;2EACuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,KAAK,EAAE,mBAAmB,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/F,0CAA0C;IAC1C,KAAK,CAAC,EAAE,mBAAmB,CAAC;CAC7B;AAID;wDACwD;AACxD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAK/C,wBAAgB,MAAM,CACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,CAAC,EAAE;IACL,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;uDAEmD;IACnD,SAAS,CA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