@opencoredev/social-sdk 0.2.1 → 0.4.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/dist/cli-request.d.ts +15 -0
- package/dist/cli-request.js +193 -0
- package/dist/cli.d.ts +4 -3
- package/dist/cli.js +19 -21
- package/dist/cloud/common.d.ts +7 -6
- package/dist/cloud/common.js +35 -54
- package/dist/cloud/lifecycle.js +31 -35
- package/dist/cloud/media.d.ts +2 -2
- package/dist/cloud/media.js +13 -3
- package/dist/cloud/outcomes.d.ts +4 -3
- package/dist/cloud/outcomes.js +8 -15
- package/dist/cloud/post-for-me.js +41 -49
- package/dist/cloud/zernio.js +58 -98
- package/dist/core/client.js +79 -99
- package/dist/core/fields.d.ts +14 -0
- package/dist/core/fields.js +14 -0
- package/dist/core/idempotency.d.ts +7 -2
- package/dist/core/idempotency.js +37 -20
- package/dist/core/pagination.js +8 -7
- package/dist/core/types.d.ts +3 -2
- package/dist/platforms/bluesky.d.ts +65 -1
- package/dist/platforms/bluesky.js +675 -276
- package/dist/platforms/instagram.d.ts +2 -0
- package/dist/platforms/instagram.js +130 -105
- package/dist/platforms/linkedin.d.ts +58 -1
- package/dist/platforms/linkedin.js +877 -107
- package/dist/platforms/threads.d.ts +13 -1
- package/dist/platforms/threads.js +204 -302
- package/dist/platforms/tiktok.d.ts +4 -0
- package/dist/platforms/tiktok.js +140 -124
- package/dist/platforms/webhook-adapter.d.ts +9 -0
- package/dist/platforms/webhook-adapter.js +24 -0
- package/dist/platforms/x-engagement.js +7 -12
- package/dist/platforms/x-stream.d.ts +83 -0
- package/dist/platforms/x-stream.js +350 -0
- package/dist/platforms/x.d.ts +87 -0
- package/dist/platforms/x.js +648 -120
- package/dist/platforms/youtube-upload.d.ts +1 -1
- package/dist/platforms/youtube-upload.js +6 -2
- package/dist/platforms/youtube.d.ts +28 -4
- package/dist/platforms/youtube.js +291 -133
- package/dist/server/bluesky-oauth.d.ts +177 -0
- package/dist/server/bluesky-oauth.js +1229 -0
- package/dist/server/connections.d.ts +14 -0
- package/dist/server/connections.js +10 -2
- package/dist/server/egress.d.ts +14 -0
- package/dist/server/egress.js +115 -0
- package/dist/server/oauth-internal.d.ts +6 -0
- package/dist/server/oauth-internal.js +66 -0
- package/dist/server/oauth.d.ts +1 -1
- package/dist/server/oauth.js +46 -99
- package/dist/server/webhooks.d.ts +136 -3
- package/dist/server/webhooks.js +639 -25
- package/dist/testing/index.js +14 -28
- package/dist/transport/http.d.ts +1 -1
- package/dist/transport/http.js +0 -1
- package/dist/transport/json.d.ts +7 -0
- package/dist/transport/json.js +32 -4
- package/dist/transport/upload.d.ts +1 -1
- package/dist/transport/upload.js +46 -38
- package/dist/transport/validation.d.ts +16 -5
- package/dist/transport/validation.js +29 -7
- package/package.json +2 -2
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { JsonObject } from "../core/types.js";
|
|
2
|
+
export type WebhookVerificationMethod = "hmac-sha1" | "hmac-sha256" | "hmac-sha384" | "hmac-sha512" | "shared-secret-header";
|
|
2
3
|
export interface VerifiedWebhook {
|
|
3
4
|
readonly valid: true;
|
|
4
|
-
readonly method:
|
|
5
|
+
readonly method: WebhookVerificationMethod;
|
|
5
6
|
readonly bodyAuthenticated: boolean;
|
|
6
|
-
|
|
7
|
+
/** True only when the provider signs a delivery timestamp together with the body. */
|
|
8
|
+
readonly signedTimestamp: boolean;
|
|
9
|
+
/** ISO time of the signed delivery timestamp, when the provider signs one. */
|
|
10
|
+
readonly signedAt?: string;
|
|
7
11
|
}
|
|
8
12
|
export declare function verifyZernioWebhook(input: {
|
|
9
13
|
secret: string;
|
|
@@ -21,7 +25,7 @@ export interface SocialEvent {
|
|
|
21
25
|
readonly version: 1;
|
|
22
26
|
readonly id: string;
|
|
23
27
|
readonly backend: string;
|
|
24
|
-
readonly provider: "zernio" | "post-for-me";
|
|
28
|
+
readonly provider: "zernio" | "post-for-me" | DirectWebhookPlatform;
|
|
25
29
|
readonly type: "publication.updated" | "post.removed" | "backend-record.deleted" | "account.updated" | "message.received" | "comment.received" | "unknown";
|
|
26
30
|
readonly identity: "provider-event-id" | "body-digest";
|
|
27
31
|
readonly originalType: string;
|
|
@@ -55,3 +59,132 @@ export declare function acceptWebhook(input: {
|
|
|
55
59
|
state: "accepted" | "duplicate";
|
|
56
60
|
quarantined: boolean;
|
|
57
61
|
}>;
|
|
62
|
+
export type DirectWebhookPlatform = "instagram" | "threads" | "x" | "youtube" | "tiktok" | "linkedin";
|
|
63
|
+
/** Framework-neutral answer to a provider GET handshake. */
|
|
64
|
+
export interface WebhookChallengeResponse {
|
|
65
|
+
readonly status: 200;
|
|
66
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
67
|
+
readonly body: string;
|
|
68
|
+
}
|
|
69
|
+
export interface XWebhookChallengeResponse extends WebhookChallengeResponse {
|
|
70
|
+
readonly responseToken: string;
|
|
71
|
+
}
|
|
72
|
+
export interface YouTubeWebhookChallengeResponse extends WebhookChallengeResponse {
|
|
73
|
+
readonly mode: "subscribe" | "unsubscribe";
|
|
74
|
+
readonly topic: string;
|
|
75
|
+
readonly leaseSeconds?: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Verify a Meta webhook POST for Instagram or Threads. Meta signs the raw body with
|
|
79
|
+
* HMAC-SHA256 using the app secret and sends `X-Hub-Signature-256: sha256=<hex>`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function verifyMetaWebhook(input: {
|
|
82
|
+
secret: string;
|
|
83
|
+
headers: Headers;
|
|
84
|
+
body: Uint8Array;
|
|
85
|
+
maxBytes?: number;
|
|
86
|
+
}): Promise<VerifiedWebhook>;
|
|
87
|
+
/**
|
|
88
|
+
* Answer Meta's GET verification request. The verify token is compared in constant
|
|
89
|
+
* time and only a bounded, token-safe `hub.challenge` is echoed.
|
|
90
|
+
*/
|
|
91
|
+
export declare function answerMetaWebhookChallenge(input: {
|
|
92
|
+
verifyToken: string;
|
|
93
|
+
query: URLSearchParams;
|
|
94
|
+
}): Promise<WebhookChallengeResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Verify an X webhook POST. X signs the raw body with HMAC-SHA256 and sends
|
|
97
|
+
* `sha256=<base64>` in `X-Twitter-Webhooks-Signature-OAuth2` (OAuth 2.0 client secret)
|
|
98
|
+
* or the legacy `X-Twitter-Webhooks-Signature` (OAuth 1.0 consumer secret). When the
|
|
99
|
+
* OAuth 2.0 header is present it alone decides; the legacy header is checked only when
|
|
100
|
+
* the OAuth 2.0 header is absent. Pass the secret that matches the header X sends.
|
|
101
|
+
*/
|
|
102
|
+
export declare function verifyXWebhook(input: {
|
|
103
|
+
secret: string;
|
|
104
|
+
headers: Headers;
|
|
105
|
+
body: Uint8Array;
|
|
106
|
+
maxBytes?: number;
|
|
107
|
+
}): Promise<VerifiedWebhook>;
|
|
108
|
+
/**
|
|
109
|
+
* Answer X's CRC GET request with `{"response_token":"sha256=<base64>"}`, an
|
|
110
|
+
* HMAC-SHA256 of `crc_token` keyed with the same secret used for signatures.
|
|
111
|
+
*/
|
|
112
|
+
export declare function answerXWebhookChallenge(input: {
|
|
113
|
+
secret: string;
|
|
114
|
+
query: URLSearchParams;
|
|
115
|
+
}): Promise<XWebhookChallengeResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Verify a YouTube push notification delivered through the PubSubHubbub hub. The
|
|
118
|
+
* hub only signs deliveries when the subscription was created with `hub.secret`; it
|
|
119
|
+
* sends `X-Hub-Signature: <method>=<hex>`, and the reported method is returned.
|
|
120
|
+
*/
|
|
121
|
+
export declare function verifyYouTubeWebhook(input: {
|
|
122
|
+
secret: string;
|
|
123
|
+
headers: Headers;
|
|
124
|
+
body: Uint8Array;
|
|
125
|
+
maxBytes?: number;
|
|
126
|
+
}): Promise<VerifiedWebhook>;
|
|
127
|
+
/**
|
|
128
|
+
* Answer the hub's GET verification of intent. The topic must be one the
|
|
129
|
+
* application is currently subscribing to or unsubscribing from; otherwise this
|
|
130
|
+
* throws `not_found`, which WebSub expects as an HTTP 404.
|
|
131
|
+
*/
|
|
132
|
+
export declare function answerYouTubeWebhookChallenge(input: {
|
|
133
|
+
query: URLSearchParams;
|
|
134
|
+
topics: readonly string[];
|
|
135
|
+
}): YouTubeWebhookChallengeResponse;
|
|
136
|
+
/**
|
|
137
|
+
* Verify a TikTok webhook POST. `TikTok-Signature: t=<unix seconds>,s=<hex>` carries an
|
|
138
|
+
* HMAC-SHA256 of `<t>.<raw body>` keyed with the app's client secret. TikTok leaves
|
|
139
|
+
* the replay window to the receiver; this defaults to 300 seconds.
|
|
140
|
+
*/
|
|
141
|
+
export declare function verifyTikTokWebhook(input: {
|
|
142
|
+
secret: string;
|
|
143
|
+
headers: Headers;
|
|
144
|
+
body: Uint8Array;
|
|
145
|
+
maxBytes?: number;
|
|
146
|
+
toleranceSeconds?: number;
|
|
147
|
+
now?: () => Date;
|
|
148
|
+
}): Promise<VerifiedWebhook>;
|
|
149
|
+
/**
|
|
150
|
+
* Verify a LinkedIn webhook POST. `X-LI-Signature` carries only the lowercase hex
|
|
151
|
+
* HMAC-SHA256 of the literal `hmacsha256=` followed by the raw body, keyed with the
|
|
152
|
+
* app's client secret. LinkedIn sends no signed timestamp.
|
|
153
|
+
*/
|
|
154
|
+
export declare function verifyLinkedInWebhook(input: {
|
|
155
|
+
secret: string;
|
|
156
|
+
headers: Headers;
|
|
157
|
+
body: Uint8Array;
|
|
158
|
+
maxBytes?: number;
|
|
159
|
+
}): Promise<VerifiedWebhook>;
|
|
160
|
+
export interface LinkedInWebhookChallengeResponse extends WebhookChallengeResponse {
|
|
161
|
+
readonly challengeCode: string;
|
|
162
|
+
readonly challengeResponse: string;
|
|
163
|
+
readonly applicationId?: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Answer LinkedIn's GET validation, which LinkedIn repeats every 2 hours. The
|
|
167
|
+
* response is `{ challengeCode, challengeResponse }`, where `challengeResponse` is the
|
|
168
|
+
* lowercase hex HMAC-SHA256 of `challengeCode` keyed with the client secret. For
|
|
169
|
+
* parent-child applications LinkedIn adds `applicationId`; pass `secretForApplication`
|
|
170
|
+
* to pick that application's client secret. An unknown application is refused.
|
|
171
|
+
*/
|
|
172
|
+
export declare function answerLinkedInWebhookChallenge(input: {
|
|
173
|
+
secret: string;
|
|
174
|
+
query: URLSearchParams;
|
|
175
|
+
secretForApplication?: (applicationId: string) => string | undefined;
|
|
176
|
+
}): Promise<LinkedInWebhookChallengeResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Decode a verified direct-platform delivery into one normalized event. A single
|
|
179
|
+
* delivery can batch several notifications (Meta batches up to 1000 updates); the
|
|
180
|
+
* event keeps them all in `data` and reports a specific `type` only when every
|
|
181
|
+
* notification maps to the same type. None of these platforms sends a delivery ID,
|
|
182
|
+
* so identity is always an exact-body digest.
|
|
183
|
+
*/
|
|
184
|
+
export declare function decodePlatformWebhook(input: {
|
|
185
|
+
platform: DirectWebhookPlatform;
|
|
186
|
+
backend: string;
|
|
187
|
+
body: Uint8Array;
|
|
188
|
+
receivedAt?: string;
|
|
189
|
+
maxBytes?: number;
|
|
190
|
+
}): Promise<SocialEvent>;
|