@zernio/node 0.2.1521 → 0.2.1523

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -25989,6 +25989,10 @@ type ValidatePostResponse = (({
25989
25989
  errors?: Array<{
25990
25990
  platform?: string;
25991
25991
  error?: string;
25992
+ /**
25993
+ * Present on media errors. MEDIA_UNDECODABLE means the bytes at the URL are not a valid image, video or PDF.
25994
+ */
25995
+ code?: 'MEDIA_UNDECODABLE';
25992
25996
  }>;
25993
25997
  warnings?: Array<{
25994
25998
  platform?: string;
@@ -26011,13 +26015,39 @@ type ValidateMediaResponse = ({
26011
26015
  * Error message if valid is false
26012
26016
  */
26013
26017
  error?: string;
26018
+ /**
26019
+ * Stable reason when valid is false. MEDIA_UNDECODABLE: the bytes are not a valid image, video or PDF. MEDIA_URL_UNREACHABLE: HTTP error, timeout or network failure. MEDIA_URL_NOT_ALLOWED: not a public HTTP(S) URL.
26020
+ */
26021
+ code?: 'MEDIA_UNDECODABLE' | 'MEDIA_URL_UNREACHABLE' | 'MEDIA_URL_NOT_ALLOWED';
26022
+ /**
26023
+ * Content-Type header the server sent (may disagree with the detected format)
26024
+ */
26014
26025
  contentType?: string;
26015
26026
  /**
26016
26027
  * File size in bytes
26017
26028
  */
26018
26029
  size?: (number) | null;
26019
26030
  sizeFormatted?: string;
26020
- type?: 'image' | 'video' | 'unknown';
26031
+ /**
26032
+ * Detected from the file bytes
26033
+ */
26034
+ type?: 'image' | 'video' | 'document';
26035
+ /**
26036
+ * Detected format (jpeg, png, webp, gif, heif, mp4, mov, webm, pdf, ...)
26037
+ */
26038
+ format?: string;
26039
+ /**
26040
+ * Image width in pixels (images only)
26041
+ */
26042
+ width?: number;
26043
+ /**
26044
+ * Image height in pixels (images only)
26045
+ */
26046
+ height?: number;
26047
+ /**
26048
+ * How deeply the content was verified. decoded: every pixel decoded. header: file signature and header verified (videos, PDFs, HEIC/AVIF, images over 32 MB).
26049
+ */
26050
+ inspection?: 'decoded' | 'header';
26021
26051
  /**
26022
26052
  * Per-platform size limit comparison (only present when size and type are known)
26023
26053
  */
package/dist/index.d.ts CHANGED
@@ -25989,6 +25989,10 @@ type ValidatePostResponse = (({
25989
25989
  errors?: Array<{
25990
25990
  platform?: string;
25991
25991
  error?: string;
25992
+ /**
25993
+ * Present on media errors. MEDIA_UNDECODABLE means the bytes at the URL are not a valid image, video or PDF.
25994
+ */
25995
+ code?: 'MEDIA_UNDECODABLE';
25992
25996
  }>;
25993
25997
  warnings?: Array<{
25994
25998
  platform?: string;
@@ -26011,13 +26015,39 @@ type ValidateMediaResponse = ({
26011
26015
  * Error message if valid is false
26012
26016
  */
26013
26017
  error?: string;
26018
+ /**
26019
+ * Stable reason when valid is false. MEDIA_UNDECODABLE: the bytes are not a valid image, video or PDF. MEDIA_URL_UNREACHABLE: HTTP error, timeout or network failure. MEDIA_URL_NOT_ALLOWED: not a public HTTP(S) URL.
26020
+ */
26021
+ code?: 'MEDIA_UNDECODABLE' | 'MEDIA_URL_UNREACHABLE' | 'MEDIA_URL_NOT_ALLOWED';
26022
+ /**
26023
+ * Content-Type header the server sent (may disagree with the detected format)
26024
+ */
26014
26025
  contentType?: string;
26015
26026
  /**
26016
26027
  * File size in bytes
26017
26028
  */
26018
26029
  size?: (number) | null;
26019
26030
  sizeFormatted?: string;
26020
- type?: 'image' | 'video' | 'unknown';
26031
+ /**
26032
+ * Detected from the file bytes
26033
+ */
26034
+ type?: 'image' | 'video' | 'document';
26035
+ /**
26036
+ * Detected format (jpeg, png, webp, gif, heif, mp4, mov, webm, pdf, ...)
26037
+ */
26038
+ format?: string;
26039
+ /**
26040
+ * Image width in pixels (images only)
26041
+ */
26042
+ width?: number;
26043
+ /**
26044
+ * Image height in pixels (images only)
26045
+ */
26046
+ height?: number;
26047
+ /**
26048
+ * How deeply the content was verified. decoded: every pixel decoded. header: file signature and header verified (videos, PDFs, HEIC/AVIF, images over 32 MB).
26049
+ */
26050
+ inspection?: 'decoded' | 'header';
26021
26051
  /**
26022
26052
  * Per-platform size limit comparison (only present when size and type are known)
26023
26053
  */
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(index_exports);
36
36
  // package.json
37
37
  var package_default = {
38
38
  name: "@zernio/node",
39
- version: "0.2.1521",
39
+ version: "0.2.1523",
40
40
  description: "The official Node.js library for the Zernio API",
41
41
  main: "dist/index.js",
42
42
  module: "dist/index.mjs",
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5
5
  // package.json
6
6
  var package_default = {
7
7
  name: "@zernio/node",
8
- version: "0.2.1521",
8
+ version: "0.2.1523",
9
9
  description: "The official Node.js library for the Zernio API",
10
10
  main: "dist/index.js",
11
11
  module: "dist/index.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zernio/node",
3
- "version": "0.2.1521",
3
+ "version": "0.2.1523",
4
4
  "description": "The official Node.js library for the Zernio API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -43,7 +43,13 @@ export const validatePostLength = <ThrowOnError extends boolean = false>(options
43
43
  * Validate post content
44
44
  * Dry-run the full post validation pipeline without publishing. Catches issues like missing media for Instagram/TikTok/YouTube, hashtag limits, invalid thread formats, Facebook Reel requirements, and character limit violations.
45
45
  *
46
- * Accepts the same body as POST /v1/posts. Does NOT validate accounts, process media, or track usage. Account lookups are limit-only: a twitter accountId is resolved, scoped to the caller, only to pick the 280 vs 25000 character limit. Missing, foreign, or invalid ids fall back to 280 and never error.
46
+ * Accepts the same body as POST /v1/posts. Does NOT validate accounts, transform media, or track usage. Account lookups are limit-only: a twitter accountId is resolved, scoped to the caller, only to pick the 280 vs 25000 character limit. Missing, foreign, or invalid ids fall back to 280 and never error.
47
+ *
48
+ * Every image, gif and video URL in `mediaItems` and `customMedia` is fetched and checked:
49
+ *
50
+ * - A file that is not a real image, video or PDF (wrong bytes, truncated, corrupt) is an error with code `MEDIA_UNDECODABLE`.
51
+ * - Images are checked at header level. The full file is decoded only when the header is not enough. Use POST /v1/tools/validate/media for a full pixel decode.
52
+ * - A URL our servers cannot fetch is a warning, not an error, because the platform may still reach it.
47
53
  *
48
54
  * Returns errors for failures and warnings for near-limit content (>90% of character limit).
49
55
  *
@@ -57,9 +63,15 @@ export const validatePost = <ThrowOnError extends boolean = false>(options: Opti
57
63
 
58
64
  /**
59
65
  * Validate media URL
60
- * Check if a media URL is accessible and return metadata (content type, file size) plus per-platform size limit comparisons.
66
+ * Check that a media URL is reachable and that its bytes are a real image, video or PDF, then return metadata (detected format, file size, dimensions) plus per-platform size limit comparisons.
67
+ *
68
+ * `valid: true` means the content was verified, not just the extension or Content-Type:
61
69
  *
62
- * Performs a HEAD request (with GET fallback) to detect content type and size. Rejects private/localhost URLs for SSRF protection.
70
+ * - Images up to 32 MB are fully decoded (`inspection: decoded`).
71
+ * - Videos, PDFs and larger images are verified by their file signature and header (`inspection: header`).
72
+ * - The type and format come from the bytes, not the Content-Type header.
73
+ * - Corrupt, truncated or non-media files return `valid: false` with code `MEDIA_UNDECODABLE`.
74
+ * - Private/localhost URLs are rejected for SSRF protection.
63
75
  *
64
76
  * Platform limits are sourced from each platform's actual upload constraints.
65
77
  *
@@ -24716,6 +24716,10 @@ export type ValidatePostResponse = (({
24716
24716
  errors?: Array<{
24717
24717
  platform?: string;
24718
24718
  error?: string;
24719
+ /**
24720
+ * Present on media errors. MEDIA_UNDECODABLE means the bytes at the URL are not a valid image, video or PDF.
24721
+ */
24722
+ code?: 'MEDIA_UNDECODABLE';
24719
24723
  }>;
24720
24724
  warnings?: Array<{
24721
24725
  platform?: string;
@@ -24741,13 +24745,39 @@ export type ValidateMediaResponse = ({
24741
24745
  * Error message if valid is false
24742
24746
  */
24743
24747
  error?: string;
24748
+ /**
24749
+ * Stable reason when valid is false. MEDIA_UNDECODABLE: the bytes are not a valid image, video or PDF. MEDIA_URL_UNREACHABLE: HTTP error, timeout or network failure. MEDIA_URL_NOT_ALLOWED: not a public HTTP(S) URL.
24750
+ */
24751
+ code?: 'MEDIA_UNDECODABLE' | 'MEDIA_URL_UNREACHABLE' | 'MEDIA_URL_NOT_ALLOWED';
24752
+ /**
24753
+ * Content-Type header the server sent (may disagree with the detected format)
24754
+ */
24744
24755
  contentType?: string;
24745
24756
  /**
24746
24757
  * File size in bytes
24747
24758
  */
24748
24759
  size?: (number) | null;
24749
24760
  sizeFormatted?: string;
24750
- type?: 'image' | 'video' | 'unknown';
24761
+ /**
24762
+ * Detected from the file bytes
24763
+ */
24764
+ type?: 'image' | 'video' | 'document';
24765
+ /**
24766
+ * Detected format (jpeg, png, webp, gif, heif, mp4, mov, webm, pdf, ...)
24767
+ */
24768
+ format?: string;
24769
+ /**
24770
+ * Image width in pixels (images only)
24771
+ */
24772
+ width?: number;
24773
+ /**
24774
+ * Image height in pixels (images only)
24775
+ */
24776
+ height?: number;
24777
+ /**
24778
+ * How deeply the content was verified. decoded: every pixel decoded. header: file signature and header verified (videos, PDFs, HEIC/AVIF, images over 32 MB).
24779
+ */
24780
+ inspection?: 'decoded' | 'header';
24751
24781
  /**
24752
24782
  * Per-platform size limit comparison (only present when size and type are known)
24753
24783
  */