@postfetch/core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @postfetch/core
2
+
3
+ Zero-dependency typed core that turns Instagram, TikTok and YouTube post URLs into media files. Part of [postfetch](https://github.com/chelokot/postfetch).
4
+
5
+ ```ts
6
+ import { postfetch, download, archive, toResponse, PostfetchError } from "@postfetch/core";
7
+
8
+ const result = await postfetch("https://vt.tiktok.com/ZSxpHvCUM/");
9
+ for (const item of result.items) {
10
+ console.log(item.kind, item.mime, item.url);
11
+ }
12
+ ```
13
+
14
+ `postfetch(url, options?)` detects the platform and resolves its media into a typed `PostfetchResult` (URLs plus the headers needed to fetch them). It performs no side effects beyond the lookup — `download`, `archive` and `toResponse` turn the result into bytes or an HTTP `Response`.
15
+
16
+ - `PostfetchOptions` — `{ fetch?: typeof fetch; preferredWidth?: number }`. Inject `fetch` to unit-test resolvers offline.
17
+ - Every request rotates a consistent browser/app fingerprint, so a fixed user-agent never gets the whole fleet blocked.
18
+ - No runtime dependencies, no `ffmpeg` / `yt-dlp`, no cookies.
19
+
20
+ See the [root README](https://github.com/chelokot/postfetch#readme) for the full API table, supported inputs and the fingerprint design.
@@ -0,0 +1,12 @@
1
+ import { type MediaItem, type PostfetchResult } from "./internal";
2
+ export type DownloadOptions = {
3
+ fetch?: typeof fetch;
4
+ };
5
+ export type Archive = {
6
+ bytes: Uint8Array;
7
+ filename: string;
8
+ mime: "application/zip";
9
+ };
10
+ export declare function download(item: MediaItem, options?: DownloadOptions): Promise<Response>;
11
+ export declare function archive(result: PostfetchResult, options?: DownloadOptions): Promise<Archive>;
12
+ export declare function toResponse(result: PostfetchResult, options?: DownloadOptions): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ import { type ResolveContext, type PostfetchResult } from "./internal";
2
+ export declare function resolveFacebook(input: ResolveContext): Promise<PostfetchResult>;
@@ -0,0 +1,11 @@
1
+ export type BrowserFingerprint = {
2
+ acceptLanguage: string;
3
+ secChUa: string;
4
+ secChUaPlatform: string;
5
+ userAgent: string;
6
+ };
7
+ export declare function browserFingerprint(): BrowserFingerprint;
8
+ export declare function navigationHeaders(): Record<string, string>;
9
+ export declare function browserUserAgent(): string;
10
+ export declare function firefoxUserAgent(): string;
11
+ export declare function instagramAppUserAgent(): string;
@@ -0,0 +1,4 @@
1
+ export { postfetch, detect, type PostfetchOptions } from "./postfetch";
2
+ export { download, archive, toResponse, type Archive, type DownloadOptions } from "./download";
3
+ export { PostfetchError } from "./internal";
4
+ export type { MediaItem, MediaKind, Platform, PostfetchResult } from "./internal";