@venturekit-pro/social 0.0.0-dev.20260811233402 → 0.0.0-dev.20260814234200
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/README.md +36 -8
- package/dist/adapters/facebook.d.ts +14 -0
- package/dist/adapters/facebook.d.ts.map +1 -1
- package/dist/adapters/facebook.js +73 -34
- package/dist/adapters/facebook.js.map +1 -1
- package/dist/adapters/linkedin.d.ts +18 -1
- package/dist/adapters/linkedin.d.ts.map +1 -1
- package/dist/adapters/linkedin.js +100 -12
- package/dist/adapters/linkedin.js.map +1 -1
- package/dist/http.d.ts +11 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +12 -3
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +60 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +169 -0
- package/dist/media.js.map +1 -0
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -107,14 +107,42 @@ and passes it per call.
|
|
|
107
107
|
|
|
108
108
|
## Media staging
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
The adapters handle image uploads automatically — callers pass a plain
|
|
111
|
+
image URL (presigned S3, CDN, etc.) in `SocialMedia.url` and the
|
|
112
|
+
adapter does the rest:
|
|
113
|
+
|
|
114
|
+
- **Facebook** — downloads the image in-process and uploads the bytes
|
|
115
|
+
via multipart form data (`source` field) to `/<page-id>/photos`.
|
|
116
|
+
This works even when the URL is a private/presigned link that Meta's
|
|
117
|
+
servers can't reach (e.g. local dev MinIO, private VPC S3 without a
|
|
118
|
+
CDN).
|
|
119
|
+
- **LinkedIn** — if `media.url` is already a LinkedIn asset URN
|
|
120
|
+
(`urn:li:digitalmediaAsset:…`), uses it directly (backward compat for
|
|
121
|
+
callers that pre-stage). Otherwise, performs LinkedIn's two-step
|
|
122
|
+
staging automatically: `registerUpload` → PUT bytes → asset URN.
|
|
123
|
+
Images in unsupported formats (e.g. WebP) are converted to JPEG
|
|
124
|
+
before upload — this requires the optional `sharp` peer dependency
|
|
125
|
+
(`pnpm add sharp`).
|
|
126
|
+
- **Instagram** — passes the image URL to Meta's `/media` endpoint
|
|
127
|
+
(Meta fetches it server-side). A publicly reachable URL or CDN is
|
|
128
|
+
required.
|
|
129
|
+
- **X** — the caller stages the upload via X's chunk-upload endpoint
|
|
130
|
+
and passes the resulting `media_id_string` as `url`.
|
|
131
|
+
|
|
132
|
+
### Notes on byte uploads
|
|
133
|
+
|
|
134
|
+
- The upload format is decided from the payload's **magic number**, not
|
|
135
|
+
from `SocialMedia.mimeType` — stale catalog metadata (a WebP recorded
|
|
136
|
+
as `image/jpeg`) would otherwise skip conversion and be rejected by
|
|
137
|
+
the vendor. `mimeType` is only used when the format isn't recognised.
|
|
138
|
+
- Downloads are capped at the platform's `maxMediaSizeBytes` and time
|
|
139
|
+
out after 30s. Oversized payloads raise `SocialValidationError`
|
|
140
|
+
(permanent); transport failures raise `SocialPublishError`.
|
|
141
|
+
- Only `http(s)` media URLs are accepted. Because the **worker** now
|
|
142
|
+
fetches the URL rather than the vendor, callers that let end users
|
|
143
|
+
supply arbitrary media URLs must block internal targets (link-local,
|
|
144
|
+
RFC1918, cloud metadata endpoints) themselves — the package has no
|
|
145
|
+
way to know what is internal for a given deployment.
|
|
118
146
|
|
|
119
147
|
## Extending with a custom platform
|
|
120
148
|
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
* `credentials.authorRef` carries the Page id (e.g. `'page_12345'`).
|
|
13
13
|
* We strip the `'page_'` prefix when forming URLs — same convention
|
|
14
14
|
* the Instagram adapter uses.
|
|
15
|
+
*
|
|
16
|
+
* Photo posts upload the image bytes directly via multipart form data
|
|
17
|
+
* (`source` field) rather than passing a public URL (`url` field) that
|
|
18
|
+
* Meta's servers would have to fetch. This works in every environment
|
|
19
|
+
* — including local dev (MinIO on localhost) and prod without a CDN —
|
|
20
|
+
* because the adapter downloads the image in-process (where it CAN
|
|
21
|
+
* reach a presigned / private URL) and pushes the bytes to Meta.
|
|
22
|
+
*
|
|
23
|
+
* Meta's /photos endpoint accepts JPEG and PNG only. The format is
|
|
24
|
+
* read from the downloaded bytes rather than `media.mimeType`, and
|
|
25
|
+
* anything else (e.g. WebP, which the CMS uses for blog covers) is
|
|
26
|
+
* converted to JPEG before upload via the optional `sharp` peer
|
|
27
|
+
* dependency. The constraints allow WebP so validation doesn't block
|
|
28
|
+
* the post before the adapter can convert it.
|
|
15
29
|
*/
|
|
16
30
|
import type { SocialAdapter } from '../adapter.js';
|
|
17
31
|
import type { SocialPlatformConstraints } from '../types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facebook.d.ts","sourceRoot":"","sources":["../../src/adapters/facebook.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"facebook.d.ts","sourceRoot":"","sources":["../../src/adapters/facebook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAGV,yBAAyB,EAE1B,MAAM,aAAa,CAAC;AAerB,eAAO,MAAM,oBAAoB,EAAE,yBAYlC,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAClD;AAED,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,qBAA0B,GACjC,aAAa,CAyEf"}
|
|
@@ -12,17 +12,36 @@
|
|
|
12
12
|
* `credentials.authorRef` carries the Page id (e.g. `'page_12345'`).
|
|
13
13
|
* We strip the `'page_'` prefix when forming URLs — same convention
|
|
14
14
|
* the Instagram adapter uses.
|
|
15
|
+
*
|
|
16
|
+
* Photo posts upload the image bytes directly via multipart form data
|
|
17
|
+
* (`source` field) rather than passing a public URL (`url` field) that
|
|
18
|
+
* Meta's servers would have to fetch. This works in every environment
|
|
19
|
+
* — including local dev (MinIO on localhost) and prod without a CDN —
|
|
20
|
+
* because the adapter downloads the image in-process (where it CAN
|
|
21
|
+
* reach a presigned / private URL) and pushes the bytes to Meta.
|
|
22
|
+
*
|
|
23
|
+
* Meta's /photos endpoint accepts JPEG and PNG only. The format is
|
|
24
|
+
* read from the downloaded bytes rather than `media.mimeType`, and
|
|
25
|
+
* anything else (e.g. WebP, which the CMS uses for blog covers) is
|
|
26
|
+
* converted to JPEG before upload via the optional `sharp` peer
|
|
27
|
+
* dependency. The constraints allow WebP so validation doesn't block
|
|
28
|
+
* the post before the adapter can convert it.
|
|
15
29
|
*/
|
|
16
30
|
import { vendorFetch } from '../http.js';
|
|
31
|
+
import { downloadMedia, ensureUploadableImage, filenameForMime, } from '../media.js';
|
|
17
32
|
import { validatePost } from '../validation.js';
|
|
18
33
|
const META_GRAPH_BASE = 'https://graph.facebook.com';
|
|
19
34
|
const META_GRAPH_VERSION = 'v18.0';
|
|
35
|
+
/** MIME types Meta's /photos endpoint actually accepts. */
|
|
36
|
+
const FACEBOOK_UPLOAD_MIME = new Set(['image/jpeg', 'image/png']);
|
|
20
37
|
export const FACEBOOK_CONSTRAINTS = {
|
|
21
38
|
maxBodyChars: 63206, // Meta's published max; 2000 is the recommended ceiling
|
|
22
39
|
minBodyChars: 1,
|
|
23
40
|
minHashtags: 0,
|
|
24
41
|
maxHashtags: 30,
|
|
25
|
-
|
|
42
|
+
// WebP is allowed at validation time so the adapter can convert it
|
|
43
|
+
// to JPEG before uploading — Meta's /photos endpoint rejects WebP.
|
|
44
|
+
allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp'],
|
|
26
45
|
maxMediaCount: 1,
|
|
27
46
|
allowedAspectRatios: ['1:1', '4:3', '16:9', '4:5'],
|
|
28
47
|
maxMediaSizeBytes: 10 * 1024 * 1024,
|
|
@@ -45,51 +64,71 @@ export function createFacebookAdapter(config = {}) {
|
|
|
45
64
|
async publish(post, credentials) {
|
|
46
65
|
const pageId = stripPagePrefix(credentials.authorRef);
|
|
47
66
|
const hasMedia = (post.media?.length ?? 0) > 0;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
// Text / link posts hit /<page-id>/feed — no image, so the
|
|
68
|
+
// original JSON body path is correct.
|
|
69
|
+
if (!hasMedia) {
|
|
70
|
+
const endpoint = `/${version}/${encodeURIComponent(pageId)}/feed`;
|
|
71
|
+
const body = buildFeedBody(post);
|
|
72
|
+
const res = await vendorFetch('facebook', `${baseUrl}${endpoint}`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${credentials.accessToken}`,
|
|
76
|
+
'Content-Type': 'application/json',
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify(body),
|
|
79
|
+
});
|
|
80
|
+
return parseResult(res, post);
|
|
81
|
+
}
|
|
82
|
+
// Photo posts hit /<page-id>/photos with multipart form data.
|
|
83
|
+
// We download the image in-process and upload the bytes via the
|
|
84
|
+
// `source` field — Meta's servers don't need to fetch anything.
|
|
85
|
+
const media = post.media[0];
|
|
86
|
+
const endpoint = `/${version}/${encodeURIComponent(pageId)}/photos`;
|
|
87
|
+
const downloaded = await downloadMedia(media.url, 'facebook', {
|
|
88
|
+
maxBytes: constraints.maxMediaSizeBytes,
|
|
89
|
+
});
|
|
90
|
+
// Meta's /photos endpoint accepts JPEG and PNG only; anything
|
|
91
|
+
// else (e.g. WebP) is transcoded first.
|
|
92
|
+
const { bytes, mimeType } = await ensureUploadableImage(downloaded, media.mimeType, FACEBOOK_UPLOAD_MIME, 'facebook');
|
|
93
|
+
const form = new FormData();
|
|
94
|
+
form.append('message', post.body);
|
|
95
|
+
form.append('source', new Blob([bytes], { type: mimeType }), filenameForMime(mimeType));
|
|
96
|
+
// Do NOT set Content-Type manually — fetch() sets the multipart
|
|
97
|
+
// boundary automatically from FormData. A manual header would
|
|
98
|
+
// omit the boundary and Meta would reject the request.
|
|
52
99
|
const res = await vendorFetch('facebook', `${baseUrl}${endpoint}`, {
|
|
53
100
|
method: 'POST',
|
|
54
|
-
headers: {
|
|
55
|
-
|
|
56
|
-
'Content-Type': 'application/json',
|
|
57
|
-
},
|
|
58
|
-
body: JSON.stringify(body),
|
|
101
|
+
headers: { Authorization: `Bearer ${credentials.accessToken}` },
|
|
102
|
+
body: form,
|
|
59
103
|
});
|
|
60
|
-
|
|
61
|
-
const externalRef = json?.post_id ?? json?.id;
|
|
62
|
-
if (!externalRef) {
|
|
63
|
-
throw new Error('[social/facebook] Publish returned no id; vendor body: ' + res.bodyText.slice(0, 200));
|
|
64
|
-
}
|
|
65
|
-
// Public URL form: facebook.com/<pageId>/posts/<postRef> (Meta
|
|
66
|
-
// composes a more user-friendly canonical URL behind the
|
|
67
|
-
// scenes, but the raw form always works).
|
|
68
|
-
return {
|
|
69
|
-
externalRef,
|
|
70
|
-
publishedUrl: `https://www.facebook.com/${encodeURIComponent(externalRef)}`,
|
|
71
|
-
publishedAt: new Date().toISOString(),
|
|
72
|
-
idempotencyKey: post.idempotencyKey,
|
|
73
|
-
correlationId: post.correlationId,
|
|
74
|
-
raw: json,
|
|
75
|
-
};
|
|
104
|
+
return parseResult(res, post);
|
|
76
105
|
},
|
|
77
106
|
};
|
|
78
107
|
}
|
|
108
|
+
// ─── Internal helpers ─────────────────────────────────────────────────
|
|
79
109
|
function stripPagePrefix(authorRef) {
|
|
80
110
|
return authorRef.startsWith('page_') ? authorRef.slice(5) : authorRef;
|
|
81
111
|
}
|
|
82
|
-
function buildFeedBody(post
|
|
112
|
+
function buildFeedBody(post) {
|
|
83
113
|
const body = { message: post.body };
|
|
84
|
-
if (post.link
|
|
114
|
+
if (post.link) {
|
|
85
115
|
body.link = post.link;
|
|
86
116
|
}
|
|
87
|
-
if (hasMedia && post.media?.[0]) {
|
|
88
|
-
// For /<page-id>/photos, the `url` field carries the public
|
|
89
|
-
// image URL. Meta fetches it server-side. We pass through the
|
|
90
|
-
// post's first media URL verbatim.
|
|
91
|
-
body.url = post.media[0].url;
|
|
92
|
-
}
|
|
93
117
|
return body;
|
|
94
118
|
}
|
|
119
|
+
function parseResult(res, post) {
|
|
120
|
+
const json = res.body;
|
|
121
|
+
const externalRef = json?.post_id ?? json?.id;
|
|
122
|
+
if (!externalRef) {
|
|
123
|
+
throw new Error('[social/facebook] Publish returned no id; vendor body: ' + res.bodyText.slice(0, 200));
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
externalRef,
|
|
127
|
+
publishedUrl: `https://www.facebook.com/${encodeURIComponent(externalRef)}`,
|
|
128
|
+
publishedAt: new Date().toISOString(),
|
|
129
|
+
idempotencyKey: post.idempotencyKey,
|
|
130
|
+
correlationId: post.correlationId,
|
|
131
|
+
raw: json,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
95
134
|
//# sourceMappingURL=facebook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facebook.js","sourceRoot":"","sources":["../../src/adapters/facebook.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"facebook.js","sourceRoot":"","sources":["../../src/adapters/facebook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AASH,OAAO,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,eAAe,GAAG,4BAA4B,CAAC;AACrD,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,2DAA2D;AAC3D,MAAM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;QACX,YAAY,EAAE,4BAA4B,kBAAkB,CAAC,WAAW,CAAC,EAAE;QAC3E,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACrC,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,GAAG,EAAE,IAAI;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -6,10 +6,27 @@
|
|
|
6
6
|
* Author: `urn:li:organization:<id>` or `urn:li:person:<id>`
|
|
7
7
|
* — caller supplies via `credentials.authorRef`.
|
|
8
8
|
*
|
|
9
|
-
* The adapter
|
|
9
|
+
* The adapter implements text + image posts (the 95% case for
|
|
10
10
|
* editorial content). Article / video / multi-image carousels are
|
|
11
11
|
* out of scope for the v1 ship and require the staged-upload
|
|
12
12
|
* endpoint; deliberately deferred.
|
|
13
|
+
*
|
|
14
|
+
* Image staging:
|
|
15
|
+
* If `media.url` is already a LinkedIn asset URN
|
|
16
|
+
* (`urn:li:digitalmediaAsset:…`) — e.g. the caller pre-staged the
|
|
17
|
+
* upload — the adapter uses it directly. Otherwise the adapter
|
|
18
|
+
* performs LinkedIn's two-step staging automatically:
|
|
19
|
+
* 1. `POST /v2/assets?action=registerUpload` → upload URL + asset URN
|
|
20
|
+
* 2. `PUT` the image bytes to the upload URL
|
|
21
|
+
* 3. Use the asset URN in the UGC post's `media` field
|
|
22
|
+
* This means callers can pass a plain image URL (presigned S3, CDN,
|
|
23
|
+
* etc.) without implementing the staging protocol themselves.
|
|
24
|
+
*
|
|
25
|
+
* LinkedIn's feedshare-image recipe accepts JPEG and PNG only (not
|
|
26
|
+
* WebP). The format is read from the downloaded bytes rather than
|
|
27
|
+
* `media.mimeType`, and anything else is converted to JPEG before
|
|
28
|
+
* upload. Conversion requires the optional `sharp` peer dependency;
|
|
29
|
+
* if it's not installed, the adapter throws a clear error.
|
|
13
30
|
*/
|
|
14
31
|
import type { SocialAdapter } from '../adapter.js';
|
|
15
32
|
import type { SocialPlatformConstraints } from '../types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin.d.ts","sourceRoot":"","sources":["../../src/adapters/linkedin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"linkedin.d.ts","sourceRoot":"","sources":["../../src/adapters/linkedin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAIV,yBAAyB,EAG1B,MAAM,aAAa,CAAC;AAWrB,eAAO,MAAM,oBAAoB,EAAE,yBAUlC,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAClD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,qBAA0B,GACjC,aAAa,CA0Ef"}
|
|
@@ -6,14 +6,35 @@
|
|
|
6
6
|
* Author: `urn:li:organization:<id>` or `urn:li:person:<id>`
|
|
7
7
|
* — caller supplies via `credentials.authorRef`.
|
|
8
8
|
*
|
|
9
|
-
* The adapter
|
|
9
|
+
* The adapter implements text + image posts (the 95% case for
|
|
10
10
|
* editorial content). Article / video / multi-image carousels are
|
|
11
11
|
* out of scope for the v1 ship and require the staged-upload
|
|
12
12
|
* endpoint; deliberately deferred.
|
|
13
|
+
*
|
|
14
|
+
* Image staging:
|
|
15
|
+
* If `media.url` is already a LinkedIn asset URN
|
|
16
|
+
* (`urn:li:digitalmediaAsset:…`) — e.g. the caller pre-staged the
|
|
17
|
+
* upload — the adapter uses it directly. Otherwise the adapter
|
|
18
|
+
* performs LinkedIn's two-step staging automatically:
|
|
19
|
+
* 1. `POST /v2/assets?action=registerUpload` → upload URL + asset URN
|
|
20
|
+
* 2. `PUT` the image bytes to the upload URL
|
|
21
|
+
* 3. Use the asset URN in the UGC post's `media` field
|
|
22
|
+
* This means callers can pass a plain image URL (presigned S3, CDN,
|
|
23
|
+
* etc.) without implementing the staging protocol themselves.
|
|
24
|
+
*
|
|
25
|
+
* LinkedIn's feedshare-image recipe accepts JPEG and PNG only (not
|
|
26
|
+
* WebP). The format is read from the downloaded bytes rather than
|
|
27
|
+
* `media.mimeType`, and anything else is converted to JPEG before
|
|
28
|
+
* upload. Conversion requires the optional `sharp` peer dependency;
|
|
29
|
+
* if it's not installed, the adapter throws a clear error.
|
|
13
30
|
*/
|
|
31
|
+
import { SocialPublishError } from '../types.js';
|
|
14
32
|
import { vendorFetch } from '../http.js';
|
|
33
|
+
import { downloadMedia, ensureUploadableImage } from '../media.js';
|
|
15
34
|
import { validatePost } from '../validation.js';
|
|
16
35
|
const LINKEDIN_API_BASE = 'https://api.linkedin.com';
|
|
36
|
+
/** LinkedIn's feedshare-image recipe accepts JPEG and PNG only. */
|
|
37
|
+
const LINKEDIN_ACCEPTED_MIME = new Set(['image/jpeg', 'image/png']);
|
|
17
38
|
export const LINKEDIN_CONSTRAINTS = {
|
|
18
39
|
maxBodyChars: 3000,
|
|
19
40
|
minBodyChars: 1,
|
|
@@ -43,7 +64,20 @@ export function createLinkedInAdapter(config = {}) {
|
|
|
43
64
|
return validatePost(post, constraints);
|
|
44
65
|
},
|
|
45
66
|
async publish(post, credentials) {
|
|
46
|
-
|
|
67
|
+
// Stage images that aren't already LinkedIn URNs.
|
|
68
|
+
const media = post.media ?? [];
|
|
69
|
+
const stagedMedia = [];
|
|
70
|
+
for (const m of media) {
|
|
71
|
+
if (m.url.startsWith('urn:li:digitalmediaAsset:')) {
|
|
72
|
+
// Caller already staged the upload — use the URN directly.
|
|
73
|
+
stagedMedia.push(m.url);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Auto-stage: download → registerUpload → PUT bytes → URN.
|
|
77
|
+
stagedMedia.push(await stageImage(baseUrl, credentials, m, constraints.maxMediaSizeBytes));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const body = buildUgcPost(post, credentials, stagedMedia);
|
|
47
81
|
const headers = {
|
|
48
82
|
Authorization: `Bearer ${credentials.accessToken}`,
|
|
49
83
|
'Content-Type': 'application/json',
|
|
@@ -81,6 +115,64 @@ export function createLinkedInAdapter(config = {}) {
|
|
|
81
115
|
},
|
|
82
116
|
};
|
|
83
117
|
}
|
|
118
|
+
// ─── Internal: image staging ──────────────────────────────────────────
|
|
119
|
+
/**
|
|
120
|
+
* Download an image from a URL, convert to JPEG if needed, register
|
|
121
|
+
* the upload with LinkedIn, push the bytes, and return the asset URN.
|
|
122
|
+
*/
|
|
123
|
+
async function stageImage(baseUrl, credentials, media, maxBytes) {
|
|
124
|
+
// Download the image (the calling process can reach presigned /
|
|
125
|
+
// private URLs that LinkedIn's servers cannot), then transcode if
|
|
126
|
+
// the feedshare-image recipe won't take the format.
|
|
127
|
+
const downloaded = await downloadMedia(media.url, 'linkedin', { maxBytes });
|
|
128
|
+
const { bytes, mimeType } = await ensureUploadableImage(downloaded, media.mimeType, LINKEDIN_ACCEPTED_MIME, 'linkedin');
|
|
129
|
+
// Step 1: register the upload. Request SYNCHRONOUS_UPLOAD so
|
|
130
|
+
// LinkedIn confirms the image processed before we reference it.
|
|
131
|
+
const registerBody = {
|
|
132
|
+
registerUploadRequest: {
|
|
133
|
+
recipes: ['urn:li:digitalmediaRecipe:feedshare-image'],
|
|
134
|
+
owner: credentials.authorRef,
|
|
135
|
+
serviceRelationships: [
|
|
136
|
+
{
|
|
137
|
+
relationshipType: 'OWNER',
|
|
138
|
+
identifier: 'urn:li:userGeneratedContent',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
supportedUploadMechanism: ['SYNCHRONOUS_UPLOAD'],
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
const regRes = await vendorFetch('linkedin', `${baseUrl}/v2/assets?action=registerUpload`, {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: {
|
|
147
|
+
Authorization: `Bearer ${credentials.accessToken}`,
|
|
148
|
+
'Content-Type': 'application/json',
|
|
149
|
+
'X-Restli-Protocol-Version': '2.0.0',
|
|
150
|
+
},
|
|
151
|
+
body: JSON.stringify(registerBody),
|
|
152
|
+
});
|
|
153
|
+
const regJson = regRes.body;
|
|
154
|
+
const uploadMech = regJson?.value?.uploadMechanism?.['com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest'];
|
|
155
|
+
const uploadUrl = uploadMech?.uploadUrl;
|
|
156
|
+
const assetUrn = regJson?.value?.asset;
|
|
157
|
+
if (!uploadUrl || !assetUrn) {
|
|
158
|
+
throw new SocialPublishError('[social/linkedin] registerUpload returned no upload URL / asset URN; vendor body: ' +
|
|
159
|
+
regRes.bodyText.slice(0, 500), { platform: 'linkedin', status: regRes.status, raw: regRes.body });
|
|
160
|
+
}
|
|
161
|
+
// Step 2: upload the bytes. The upload URL is a one-shot signed
|
|
162
|
+
// endpoint rather than the LinkedIn API proper, but it still goes
|
|
163
|
+
// through `vendorFetch` so the call inherits the abort timeout and
|
|
164
|
+
// the status → typed-error mapping. Forward any headers LinkedIn
|
|
165
|
+
// asked us to echo back.
|
|
166
|
+
await vendorFetch('linkedin', uploadUrl, {
|
|
167
|
+
method: 'PUT',
|
|
168
|
+
headers: {
|
|
169
|
+
'Content-Type': mimeType,
|
|
170
|
+
...(uploadMech?.headers ?? {}),
|
|
171
|
+
},
|
|
172
|
+
body: bytes,
|
|
173
|
+
});
|
|
174
|
+
return assetUrn;
|
|
175
|
+
}
|
|
84
176
|
// ─── Internal: first-comment ──────────────────────────────────────────
|
|
85
177
|
/**
|
|
86
178
|
* Post a first-comment under a freshly-published UGC post via the
|
|
@@ -111,9 +203,8 @@ async function postFirstComment(baseUrl, credentials, postUrn, text) {
|
|
|
111
203
|
// Swallowed — see doc comment.
|
|
112
204
|
}
|
|
113
205
|
}
|
|
114
|
-
function buildUgcPost(post, credentials) {
|
|
115
|
-
const
|
|
116
|
-
const hasMedia = media.length > 0;
|
|
206
|
+
function buildUgcPost(post, credentials, stagedMedia) {
|
|
207
|
+
const hasMedia = stagedMedia.length > 0;
|
|
117
208
|
const hasArticleLink = !hasMedia && !!post.link;
|
|
118
209
|
const body = {
|
|
119
210
|
author: credentials.authorRef,
|
|
@@ -127,14 +218,11 @@ function buildUgcPost(post, credentials) {
|
|
|
127
218
|
visibility: { 'com.linkedin.ugc.MemberNetworkVisibility': 'PUBLIC' },
|
|
128
219
|
};
|
|
129
220
|
if (hasMedia) {
|
|
130
|
-
|
|
221
|
+
const altTexts = post.media ?? [];
|
|
222
|
+
body.specificContent['com.linkedin.ugc.ShareContent'].media = stagedMedia.map((urn, i) => ({
|
|
131
223
|
status: 'READY',
|
|
132
|
-
...(
|
|
133
|
-
|
|
134
|
-
// not a public URL. For v1 we assume the caller has already
|
|
135
|
-
// staged the upload + put the URN in `media.url`. Caller-side
|
|
136
|
-
// staging is documented in the README.
|
|
137
|
-
media: m.url,
|
|
224
|
+
...(altTexts[i]?.altText ? { description: { text: altTexts[i].altText } } : {}),
|
|
225
|
+
media: urn,
|
|
138
226
|
}));
|
|
139
227
|
}
|
|
140
228
|
else if (hasArticleLink) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin.js","sourceRoot":"","sources":["../../src/adapters/linkedin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"linkedin.js","sourceRoot":"","sources":["../../src/adapters/linkedin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAWH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,iBAAiB,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AC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChF,KAAK,EAAE,GAAG;SACX,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,IAAI,cAAc,EAAE,CAAC;QAC1B,IAAI,CAAC,eAAe,CAAC,+BAA+B,CAAC,CAAC,KAAK,GAAG;YAC5D;gBACE,MAAM,EAAE,OAAO;gBACf,WAAW,EAAE,IAAI,CAAC,IAAK;aACxB;SACF,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/http.d.ts
CHANGED
|
@@ -17,7 +17,17 @@ import { type SocialPlatformKey } from './types.js';
|
|
|
17
17
|
export interface FetchOptions {
|
|
18
18
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
19
19
|
headers?: Record<string, string>;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Request body.
|
|
22
|
+
*
|
|
23
|
+
* `FormData` (multipart uploads) and `Uint8Array` (raw binary
|
|
24
|
+
* uploads) are supported alongside the text forms so that adapters
|
|
25
|
+
* pushing image bytes can still go through this wrapper. Routing
|
|
26
|
+
* every vendor call through here is what keeps the timeout and the
|
|
27
|
+
* status → typed-error mapping uniform: an adapter that hand-rolls
|
|
28
|
+
* its own `fetch` silently loses 429 → `SocialRateLimitError`.
|
|
29
|
+
*/
|
|
30
|
+
body?: string | URLSearchParams | FormData | Uint8Array;
|
|
21
31
|
timeoutMs?: number;
|
|
22
32
|
/** Override the abort signal — e.g. when the caller propagates its own. */
|
|
23
33
|
signal?: AbortSignal;
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,QAAQ,GAAG,UAAU,CAAC;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,WAAW,CAAC,CAmGtB"}
|
package/dist/http.js
CHANGED
|
@@ -34,15 +34,17 @@ export async function vendorFetch(platform, url, opts = {}) {
|
|
|
34
34
|
}
|
|
35
35
|
opts.signal.addEventListener('abort', () => controller.abort(), { once: true });
|
|
36
36
|
}
|
|
37
|
+
// Only text bodies get the JSON default. `FormData` MUST be left
|
|
38
|
+
// alone so `fetch` can generate the multipart boundary, and binary
|
|
39
|
+
// bodies always carry an explicit type from the caller.
|
|
40
|
+
const defaultsToJson = typeof opts.body === 'string' && !hasHeader(opts.headers, 'content-type');
|
|
37
41
|
let response;
|
|
38
42
|
try {
|
|
39
43
|
response = await fetch(url, {
|
|
40
44
|
method: opts.method ?? 'GET',
|
|
41
45
|
headers: {
|
|
42
46
|
Accept: 'application/json',
|
|
43
|
-
...(
|
|
44
|
-
? { 'Content-Type': 'application/json' }
|
|
45
|
-
: {}),
|
|
47
|
+
...(defaultsToJson ? { 'Content-Type': 'application/json' } : {}),
|
|
46
48
|
...(opts.headers ?? {}),
|
|
47
49
|
},
|
|
48
50
|
body: opts.body,
|
|
@@ -109,6 +111,13 @@ export async function vendorFetch(platform, url, opts = {}) {
|
|
|
109
111
|
raw: parsedBody,
|
|
110
112
|
});
|
|
111
113
|
}
|
|
114
|
+
/** Case-insensitive header lookup — vendors and callers disagree on casing. */
|
|
115
|
+
function hasHeader(headers, name) {
|
|
116
|
+
if (!headers)
|
|
117
|
+
return false;
|
|
118
|
+
const target = name.toLowerCase();
|
|
119
|
+
return Object.keys(headers).some((k) => k.toLowerCase() === target);
|
|
120
|
+
}
|
|
112
121
|
function parseRetryAfter(header) {
|
|
113
122
|
if (!header)
|
|
114
123
|
return undefined;
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GAEtB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAA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AC;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,eAAe,CAAC,MAAqB;IAC5C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,iCAAiC;IACjC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3C,uCAAuC;IACvC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAChE,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export { createAdapterRegistry } from './registry.js';
|
|
|
24
24
|
export { validatePost, simplifyRatio } from './validation.js';
|
|
25
25
|
export { vendorFetch } from './http.js';
|
|
26
26
|
export type { FetchOptions, FetchResult } from './http.js';
|
|
27
|
+
export { downloadMedia, ensureUploadableImage, sniffImageMime, filenameForMime, } from './media.js';
|
|
28
|
+
export type { DownloadMediaOptions } from './media.js';
|
|
27
29
|
export { createLinkedInAdapter, LINKEDIN_CONSTRAINTS, createXAdapter, X_CONSTRAINTS, createFacebookAdapter, FACEBOOK_CONSTRAINTS, createInstagramAdapter, INSTAGRAM_CONSTRAINTS, } from './adapters/index.js';
|
|
28
30
|
export type { LinkedInAdapterConfig, XAdapterConfig, FacebookAdapterConfig, InstagramAdapterConfig, } from './adapters/index.js';
|
|
29
31
|
export { listSocialPlatforms, getSocialPlatformByKey, createSocialPlatform, patchSocialPlatform, deleteSocialPlatform, isUniqueViolation, isForeignKeyViolation, } from './catalog/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG3D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB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ACrB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,8 @@ export { createAdapterRegistry } from './registry.js';
|
|
|
22
22
|
export { validatePost, simplifyRatio } from './validation.js';
|
|
23
23
|
// ─── HTTP helper (exposed for adapter authors building their own) ───
|
|
24
24
|
export { vendorFetch } from './http.js';
|
|
25
|
+
// ─── Media helpers (byte-upload adapters) ────────────────────────────
|
|
26
|
+
export { downloadMedia, ensureUploadableImage, sniffImageMime, filenameForMime, } from './media.js';
|
|
25
27
|
// ─── V1 adapters ─────────────────────────────────────────────────────
|
|
26
28
|
export { createLinkedInAdapter, LINKEDIN_CONSTRAINTS, createXAdapter, X_CONSTRAINTS, createFacebookAdapter, FACEBOOK_CONSTRAINTS, createInstagramAdapter, INSTAGRAM_CONSTRAINTS, } from './adapters/index.js';
|
|
27
29
|
// ─── Platform catalog (vk_social_platforms CRUD) ─────────────────────
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAiBH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,wEAAwE;AACxE,OAAO,EAAE,YAAY,EAAE,aAAa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AiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAQ5B,wEAAwE;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared media helpers for adapters that upload image *bytes* instead
|
|
3
|
+
* of handing the platform a URL to fetch server-side.
|
|
4
|
+
*
|
|
5
|
+
* Meta's `/photos` endpoint and LinkedIn's `registerUpload` flow both
|
|
6
|
+
* need the raw payload, because the URLs the CMS produces (presigned
|
|
7
|
+
* S3 / MinIO on localhost / private-VPC buckets without a CDN) are
|
|
8
|
+
* reachable from the publishing worker but not from the vendor.
|
|
9
|
+
*
|
|
10
|
+
* Everything here is deliberately platform-neutral: the adapters pass
|
|
11
|
+
* their own `SocialPlatformKey` and their own accepted-MIME set, so
|
|
12
|
+
* the download + convert logic exists exactly once.
|
|
13
|
+
*/
|
|
14
|
+
import { type SocialPlatformKey } from './types.js';
|
|
15
|
+
export interface DownloadMediaOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Reject payloads larger than this, in bytes. Pass `-1` to disable
|
|
18
|
+
* the cap (matches `SocialPlatformConstraints.maxMediaSizeBytes`).
|
|
19
|
+
*/
|
|
20
|
+
maxBytes: number;
|
|
21
|
+
/** Abort the download after this long. Defaults to 30s. */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Download media bytes from a URL the calling process can reach.
|
|
26
|
+
*
|
|
27
|
+
* Throws `SocialValidationError` for problems that will never resolve
|
|
28
|
+
* on retry (unusable scheme, oversized payload) and
|
|
29
|
+
* `SocialPublishError` for transport failures the caller may retry.
|
|
30
|
+
*
|
|
31
|
+
* Only `http(s)` is accepted. The package cannot know which hosts are
|
|
32
|
+
* safe for a given deployment, so callers that accept user-supplied
|
|
33
|
+
* media URLs remain responsible for blocking internal targets
|
|
34
|
+
* (link-local, RFC1918, cloud metadata endpoints).
|
|
35
|
+
*/
|
|
36
|
+
export declare function downloadMedia(url: string, platform: SocialPlatformKey, opts: DownloadMediaOptions): Promise<Uint8Array>;
|
|
37
|
+
/**
|
|
38
|
+
* Normalise downloaded bytes into something the platform will accept.
|
|
39
|
+
*
|
|
40
|
+
* The effective format is read from the payload's magic number rather
|
|
41
|
+
* than `SocialMedia.mimeType`: that field is caller metadata and goes
|
|
42
|
+
* stale (a WebP recorded as `image/jpeg` is precisely the failure this
|
|
43
|
+
* module exists to prevent). The declared type is only a fallback for
|
|
44
|
+
* formats we don't recognise.
|
|
45
|
+
*
|
|
46
|
+
* Anything outside `accepted` is transcoded to JPEG via `sharp`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ensureUploadableImage(bytes: Uint8Array, declaredMimeType: string, accepted: ReadonlySet<string>, platform: SocialPlatformKey): Promise<{
|
|
49
|
+
bytes: Uint8Array;
|
|
50
|
+
mimeType: string;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Identify an image by its magic number. Returns `undefined` when the
|
|
54
|
+
* format isn't one of the raster types the adapters deal with, which
|
|
55
|
+
* lets the caller fall back to whatever it was told.
|
|
56
|
+
*/
|
|
57
|
+
export declare function sniffImageMime(bytes: Uint8Array): string | undefined;
|
|
58
|
+
/** Upload filename hint. Vendors key off the MIME type, but a matching extension avoids confusion in their dashboards. */
|
|
59
|
+
export declare function filenameForMime(mimeType: string): string;
|
|
60
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAQpB,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,UAAU,CAAC,CAoDrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,UAAU,EACjB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAMlD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CA4BpE;AAED,0HAA0H;AAC1H,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxD"}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared media helpers for adapters that upload image *bytes* instead
|
|
3
|
+
* of handing the platform a URL to fetch server-side.
|
|
4
|
+
*
|
|
5
|
+
* Meta's `/photos` endpoint and LinkedIn's `registerUpload` flow both
|
|
6
|
+
* need the raw payload, because the URLs the CMS produces (presigned
|
|
7
|
+
* S3 / MinIO on localhost / private-VPC buckets without a CDN) are
|
|
8
|
+
* reachable from the publishing worker but not from the vendor.
|
|
9
|
+
*
|
|
10
|
+
* Everything here is deliberately platform-neutral: the adapters pass
|
|
11
|
+
* their own `SocialPlatformKey` and their own accepted-MIME set, so
|
|
12
|
+
* the download + convert logic exists exactly once.
|
|
13
|
+
*/
|
|
14
|
+
import { SocialPublishError, SocialValidationError, } from './types.js';
|
|
15
|
+
/** The format every adapter in this package can fall back to. */
|
|
16
|
+
const JPEG_MIME = 'image/jpeg';
|
|
17
|
+
/** Matches `vendorFetch`'s default so all outbound calls behave alike. */
|
|
18
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
19
|
+
/**
|
|
20
|
+
* Download media bytes from a URL the calling process can reach.
|
|
21
|
+
*
|
|
22
|
+
* Throws `SocialValidationError` for problems that will never resolve
|
|
23
|
+
* on retry (unusable scheme, oversized payload) and
|
|
24
|
+
* `SocialPublishError` for transport failures the caller may retry.
|
|
25
|
+
*
|
|
26
|
+
* Only `http(s)` is accepted. The package cannot know which hosts are
|
|
27
|
+
* safe for a given deployment, so callers that accept user-supplied
|
|
28
|
+
* media URLs remain responsible for blocking internal targets
|
|
29
|
+
* (link-local, RFC1918, cloud metadata endpoints).
|
|
30
|
+
*/
|
|
31
|
+
export async function downloadMedia(url, platform, opts) {
|
|
32
|
+
assertFetchableUrl(url, platform);
|
|
33
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
36
|
+
let res;
|
|
37
|
+
try {
|
|
38
|
+
res = await fetch(url, { signal: controller.signal });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err.name === 'AbortError') {
|
|
42
|
+
throw new SocialPublishError(`[social/${platform}] Media download timed out after ${timeoutMs}ms — ${url}`, { platform });
|
|
43
|
+
}
|
|
44
|
+
throw new SocialPublishError(`[social/${platform}] Network error downloading media: ${err.message} — ${url}`, { platform });
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
}
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
throw new SocialPublishError(`[social/${platform}] Could not fetch media for upload: ` +
|
|
51
|
+
`${res.status} ${res.statusText} — ${url}`, { platform, status: res.status });
|
|
52
|
+
}
|
|
53
|
+
// Cheap pre-check so an oversized object is refused before it is
|
|
54
|
+
// buffered. Kept alongside the post-check below because `fetch`
|
|
55
|
+
// omits Content-Length on chunked responses (and servers can lie).
|
|
56
|
+
const declaredLength = Number(res.headers.get('content-length'));
|
|
57
|
+
if (Number.isFinite(declaredLength) && exceedsCap(declaredLength, opts.maxBytes)) {
|
|
58
|
+
throw new SocialValidationError(`[social/${platform}] Media too large (${declaredLength} bytes; max ${opts.maxBytes}) — ${url}`, { platform });
|
|
59
|
+
}
|
|
60
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
61
|
+
if (exceedsCap(bytes.byteLength, opts.maxBytes)) {
|
|
62
|
+
throw new SocialValidationError(`[social/${platform}] Media too large (${bytes.byteLength} bytes; max ${opts.maxBytes}) — ${url}`, { platform });
|
|
63
|
+
}
|
|
64
|
+
return bytes;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalise downloaded bytes into something the platform will accept.
|
|
68
|
+
*
|
|
69
|
+
* The effective format is read from the payload's magic number rather
|
|
70
|
+
* than `SocialMedia.mimeType`: that field is caller metadata and goes
|
|
71
|
+
* stale (a WebP recorded as `image/jpeg` is precisely the failure this
|
|
72
|
+
* module exists to prevent). The declared type is only a fallback for
|
|
73
|
+
* formats we don't recognise.
|
|
74
|
+
*
|
|
75
|
+
* Anything outside `accepted` is transcoded to JPEG via `sharp`.
|
|
76
|
+
*/
|
|
77
|
+
export async function ensureUploadableImage(bytes, declaredMimeType, accepted, platform) {
|
|
78
|
+
const mimeType = sniffImageMime(bytes) ?? declaredMimeType;
|
|
79
|
+
if (accepted.has(mimeType)) {
|
|
80
|
+
return { bytes, mimeType };
|
|
81
|
+
}
|
|
82
|
+
return { bytes: await convertToJpeg(bytes, platform), mimeType: JPEG_MIME };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Identify an image by its magic number. Returns `undefined` when the
|
|
86
|
+
* format isn't one of the raster types the adapters deal with, which
|
|
87
|
+
* lets the caller fall back to whatever it was told.
|
|
88
|
+
*/
|
|
89
|
+
export function sniffImageMime(bytes) {
|
|
90
|
+
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) {
|
|
91
|
+
return JPEG_MIME;
|
|
92
|
+
}
|
|
93
|
+
if (bytes.length >= 8 &&
|
|
94
|
+
bytes[0] === 0x89 &&
|
|
95
|
+
bytes[1] === 0x50 &&
|
|
96
|
+
bytes[2] === 0x4e &&
|
|
97
|
+
bytes[3] === 0x47 &&
|
|
98
|
+
bytes[4] === 0x0d &&
|
|
99
|
+
bytes[5] === 0x0a &&
|
|
100
|
+
bytes[6] === 0x1a &&
|
|
101
|
+
bytes[7] === 0x0a) {
|
|
102
|
+
return 'image/png';
|
|
103
|
+
}
|
|
104
|
+
if (bytes.length >= 12 && ascii(bytes, 0, 4) === 'RIFF' && ascii(bytes, 8, 12) === 'WEBP') {
|
|
105
|
+
return 'image/webp';
|
|
106
|
+
}
|
|
107
|
+
const gif = bytes.length >= 6 ? ascii(bytes, 0, 6) : '';
|
|
108
|
+
if (gif === 'GIF87a' || gif === 'GIF89a') {
|
|
109
|
+
return 'image/gif';
|
|
110
|
+
}
|
|
111
|
+
if (bytes.length >= 2 && bytes[0] === 0x42 && bytes[1] === 0x4d) {
|
|
112
|
+
return 'image/bmp';
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
/** Upload filename hint. Vendors key off the MIME type, but a matching extension avoids confusion in their dashboards. */
|
|
117
|
+
export function filenameForMime(mimeType) {
|
|
118
|
+
const ext = mimeType === 'image/png' ? 'png' : 'jpg';
|
|
119
|
+
return `upload.${ext}`;
|
|
120
|
+
}
|
|
121
|
+
// ─── Internal ──────────────────────────────────────────────────────────
|
|
122
|
+
function exceedsCap(bytes, maxBytes) {
|
|
123
|
+
return maxBytes > 0 && bytes > maxBytes;
|
|
124
|
+
}
|
|
125
|
+
function ascii(bytes, start, end) {
|
|
126
|
+
let out = '';
|
|
127
|
+
for (let i = start; i < end; i++) {
|
|
128
|
+
out += String.fromCharCode(bytes[i]);
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
function assertFetchableUrl(url, platform) {
|
|
133
|
+
let parsed;
|
|
134
|
+
try {
|
|
135
|
+
parsed = new URL(url);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new SocialValidationError(`[social/${platform}] Media URL is not a valid URL: ${url}`, { platform });
|
|
139
|
+
}
|
|
140
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
141
|
+
throw new SocialValidationError(`[social/${platform}] Media URL must be http(s); got '${parsed.protocol}' — ${url}`, { platform });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function convertToJpeg(bytes, platform) {
|
|
145
|
+
const sharp = await loadSharp(platform);
|
|
146
|
+
try {
|
|
147
|
+
return await sharp(bytes).jpeg({ quality: 90 }).toBuffer();
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
// A payload sharp can't decode will never decode — permanent.
|
|
151
|
+
throw new SocialValidationError(`[social/${platform}] Could not convert media to JPEG: ${err.message}`, { platform });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Lazy-import `sharp` so the native binary is only loaded when an
|
|
156
|
+
* image actually needs transcoding. It is declared as an optional peer
|
|
157
|
+
* dependency — deployments that only ever post JPEG/PNG never need it,
|
|
158
|
+
* and the build doesn't require it either (see `src/sharp.d.ts`).
|
|
159
|
+
*/
|
|
160
|
+
async function loadSharp(platform) {
|
|
161
|
+
try {
|
|
162
|
+
return (await import('sharp')).default;
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
throw new SocialPublishError(`[social/${platform}] The optional 'sharp' dependency is required to convert this ` +
|
|
166
|
+
`image to JPEG. Install it with 'pnpm add sharp'. (${err.message})`, { platform });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":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M,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAChE,MAAM,IAAI,qBAAqB,CAC7B,WAAW,QAAQ,qCAAqC,MAAM,CAAC,QAAQ,OAAO,GAAG,EAAE,EACnF,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,aAAa,CAC1B,KAAiB,EACjB,QAA2B;IAE3B,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,8DAA8D;QAC9D,MAAM,IAAI,qBAAqB,CAC7B,WAAW,QAAQ,sCAAuC,GAAa,CAAC,OAAO,EAAE,EACjF,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,SAAS,CAAC,QAA2B;IAClD,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,WAAW,QAAQ,gEAAgE;YACjF,qDAAsD,GAAa,CAAC,OAAO,GAAG,EAChF,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit-pro/social",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.20260814234200",
|
|
4
4
|
"description": "Social-platform publishing adapters + catalog for VentureKit applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,19 +55,24 @@
|
|
|
55
55
|
"publishing"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@venturekit/core": "0.0.0-dev.
|
|
58
|
+
"@venturekit/core": "0.0.0-dev.20260814234200"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@venturekit/data": "0.0.0-dev.
|
|
61
|
+
"@venturekit/data": "0.0.0-dev.20260814234200",
|
|
62
|
+
"sharp": ">=0.32"
|
|
62
63
|
},
|
|
63
64
|
"peerDependenciesMeta": {
|
|
64
65
|
"@venturekit/data": {
|
|
65
66
|
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"sharp": {
|
|
69
|
+
"optional": true
|
|
66
70
|
}
|
|
67
71
|
},
|
|
68
72
|
"devDependencies": {
|
|
69
|
-
"@types/node": "^26.1.
|
|
70
|
-
"@venturekit/data": "0.0.0-dev.
|
|
73
|
+
"@types/node": "^26.1.2",
|
|
74
|
+
"@venturekit/data": "0.0.0-dev.20260814234200",
|
|
75
|
+
"sharp": "^0.35.3",
|
|
71
76
|
"typescript": "^5.3.0"
|
|
72
77
|
},
|
|
73
78
|
"scripts": {
|