@adeli/sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +30 -2
- package/dist/comments-C_vDnwix.d.cts +8268 -0
- package/dist/comments-Dx3195Ty.d.ts +8268 -0
- package/dist/helpers/index.cjs +482 -0
- package/dist/helpers/index.cjs.map +1 -0
- package/dist/helpers/index.d.cts +207 -0
- package/dist/helpers/index.d.ts +207 -0
- package/dist/helpers/index.js +471 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.cjs +878 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +360 -0
- package/dist/index.d.ts +360 -0
- package/dist/index.js +860 -0
- package/dist/index.js.map +1 -0
- package/dist/uploads-MGVSU99R.d.cts +100 -0
- package/dist/uploads-MGVSU99R.d.ts +100 -0
- package/dist/uploads.cjs +45 -0
- package/dist/uploads.cjs.map +1 -0
- package/dist/uploads.d.cts +1 -0
- package/dist/uploads.d.ts +1 -0
- package/dist/uploads.js +41 -0
- package/dist/uploads.js.map +1 -0
- package/docs/api-reference.md +72 -0
- package/docs/availability.md +26 -0
- package/docs/client.md +72 -0
- package/docs/maintenance.md +30 -0
- package/docs/publishing.md +39 -0
- package/openapi/adeli.openapi.json +20505 -0
- package/openapi/docs-links.json +71 -0
- package/openapi/provenance.json +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { R as RequestOptions, A as ApiResponse } from '../uploads-MGVSU99R.cjs';
|
|
2
|
+
import { P as ProfilePath, C as ConnectionSession, F as FacebookPostStatusResponse, I as InstagramPostStatusResponse, T as TikTokPostStatusResponse, Y as YouTubeVideoStatusResponse, a as CommentsQuery, b as CommentsResponse } from '../comments-C_vDnwix.cjs';
|
|
3
|
+
|
|
4
|
+
type PublishStatusQuery = {
|
|
5
|
+
readonly accountId: string;
|
|
6
|
+
readonly profileId?: string;
|
|
7
|
+
readonly publishId: string;
|
|
8
|
+
};
|
|
9
|
+
type InstagramStatusQuery = {
|
|
10
|
+
readonly jobId: string;
|
|
11
|
+
readonly profileId?: string;
|
|
12
|
+
};
|
|
13
|
+
type VideoStatusQuery = {
|
|
14
|
+
readonly accountId: string;
|
|
15
|
+
readonly profileId?: string;
|
|
16
|
+
readonly videoId: string;
|
|
17
|
+
};
|
|
18
|
+
/** A bounded polling deadline and delay. Both values are required to make the side effect explicit. */
|
|
19
|
+
interface PollingOptions {
|
|
20
|
+
readonly timeoutMs: number;
|
|
21
|
+
readonly intervalMs: number;
|
|
22
|
+
readonly signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
type ConnectionMethod = (args: {
|
|
25
|
+
readonly path: ProfilePath & {
|
|
26
|
+
readonly connectionSessionId: string;
|
|
27
|
+
};
|
|
28
|
+
}, options?: RequestOptions) => Promise<ApiResponse<ConnectionSession>>;
|
|
29
|
+
type ConnectionPollingClient = {
|
|
30
|
+
readonly profiles: {
|
|
31
|
+
readonly getConnection: ConnectionMethod;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
readonly getConnection: ConnectionMethod;
|
|
35
|
+
};
|
|
36
|
+
type InstagramMethod = (args: {
|
|
37
|
+
readonly query: InstagramStatusQuery;
|
|
38
|
+
}, options?: RequestOptions) => Promise<ApiResponse<InstagramPostStatusResponse>>;
|
|
39
|
+
type TikTokMethod = (args: {
|
|
40
|
+
readonly query: PublishStatusQuery;
|
|
41
|
+
}, options?: RequestOptions) => Promise<ApiResponse<TikTokPostStatusResponse>>;
|
|
42
|
+
type FacebookMethod = (args: {
|
|
43
|
+
readonly query: PublishStatusQuery;
|
|
44
|
+
}, options?: RequestOptions) => Promise<ApiResponse<FacebookPostStatusResponse>>;
|
|
45
|
+
type YouTubeMethod = (args: {
|
|
46
|
+
readonly query: VideoStatusQuery;
|
|
47
|
+
}, options?: RequestOptions) => Promise<ApiResponse<YouTubeVideoStatusResponse>>;
|
|
48
|
+
type InstagramPollingClient = {
|
|
49
|
+
readonly posts: {
|
|
50
|
+
readonly getInstagramPostStatus: InstagramMethod;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
readonly getInstagramPostStatus: InstagramMethod;
|
|
54
|
+
};
|
|
55
|
+
type TikTokPollingClient = {
|
|
56
|
+
readonly posts: {
|
|
57
|
+
readonly getTikTokPostStatus: TikTokMethod;
|
|
58
|
+
};
|
|
59
|
+
} | {
|
|
60
|
+
readonly getTikTokPostStatus: TikTokMethod;
|
|
61
|
+
};
|
|
62
|
+
type FacebookPollingClient = {
|
|
63
|
+
readonly posts: {
|
|
64
|
+
readonly getFacebookPostStatus: FacebookMethod;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
readonly getFacebookPostStatus: FacebookMethod;
|
|
68
|
+
};
|
|
69
|
+
type YouTubePollingClient = {
|
|
70
|
+
readonly posts: {
|
|
71
|
+
readonly getYouTubeVideoStatus: YouTubeMethod;
|
|
72
|
+
};
|
|
73
|
+
} | {
|
|
74
|
+
readonly getYouTubeVideoStatus: YouTubeMethod;
|
|
75
|
+
};
|
|
76
|
+
/** A convenience structural type for clients that expose all post status methods under resources. */
|
|
77
|
+
type PostPollingClient = {
|
|
78
|
+
readonly posts: {
|
|
79
|
+
readonly getInstagramPostStatus: InstagramMethod;
|
|
80
|
+
readonly getTikTokPostStatus: TikTokMethod;
|
|
81
|
+
readonly getFacebookPostStatus: FacebookMethod;
|
|
82
|
+
readonly getYouTubeVideoStatus: YouTubeMethod;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/** Poll a typed connection session; Facebook Page selection can require a dashboard handoff. */
|
|
86
|
+
declare function waitForConnection(client: ConnectionPollingClient, args: {
|
|
87
|
+
readonly path: ProfilePath & {
|
|
88
|
+
readonly connectionSessionId: string;
|
|
89
|
+
};
|
|
90
|
+
}, options: PollingOptions): Promise<ApiResponse<ConnectionSession>>;
|
|
91
|
+
/** Poll durable Instagram publication through published, failed, or uncertain outcome. */
|
|
92
|
+
declare function waitForInstagramPost(client: InstagramPollingClient, args: {
|
|
93
|
+
readonly query: InstagramStatusQuery;
|
|
94
|
+
}, options: PollingOptions): Promise<ApiResponse<InstagramPostStatusResponse>>;
|
|
95
|
+
/** Poll TikTok processing. SEND_TO_USER_INBOX is not a public publication. */
|
|
96
|
+
declare function waitForTikTokPost(client: TikTokPollingClient, args: {
|
|
97
|
+
readonly query: PublishStatusQuery;
|
|
98
|
+
}, options: PollingOptions): Promise<ApiResponse<TikTokPostStatusResponse>>;
|
|
99
|
+
/** Poll Facebook video processing; Page selection is outside this status endpoint. */
|
|
100
|
+
declare function waitForFacebookPost(client: FacebookPollingClient, args: {
|
|
101
|
+
readonly query: PublishStatusQuery;
|
|
102
|
+
}, options: PollingOptions): Promise<ApiResponse<FacebookPostStatusResponse>>;
|
|
103
|
+
/** Poll YouTube processing. Published means processing completed, not public visibility. */
|
|
104
|
+
declare function waitForYouTubeVideo(client: YouTubePollingClient, args: {
|
|
105
|
+
readonly query: VideoStatusQuery;
|
|
106
|
+
}, options: PollingOptions): Promise<ApiResponse<YouTubeVideoStatusResponse>>;
|
|
107
|
+
|
|
108
|
+
type CommentIteratorQuery = Omit<CommentsQuery, 'platform'> & {
|
|
109
|
+
readonly platform: 'tiktok' | 'youtube';
|
|
110
|
+
};
|
|
111
|
+
interface CommentsClient {
|
|
112
|
+
readonly comments: {
|
|
113
|
+
listComments(args: {
|
|
114
|
+
readonly query: CommentsQuery;
|
|
115
|
+
}, options?: RequestOptions): Promise<ApiResponse<CommentsResponse>>;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface CommentIteratorOptions {
|
|
119
|
+
/** Maximum number of requests. The default is deliberately finite. */
|
|
120
|
+
readonly maxPages?: number;
|
|
121
|
+
/** Total wall-clock budget for all pages, including request time. */
|
|
122
|
+
readonly timeoutMs?: number;
|
|
123
|
+
readonly signal?: AbortSignal;
|
|
124
|
+
}
|
|
125
|
+
/** Yield complete page responses; `complete` describes cache freshness, not pagination. */
|
|
126
|
+
declare function iterateCommentPages(client: CommentsClient, args: {
|
|
127
|
+
readonly query: CommentIteratorQuery;
|
|
128
|
+
}, options?: CommentIteratorOptions): AsyncGenerator<ApiResponse<CommentsResponse>>;
|
|
129
|
+
/** Yield the original comment records without normalizing provider fields. */
|
|
130
|
+
declare function iterateComments(client: CommentsClient, args: {
|
|
131
|
+
readonly query: CommentIteratorQuery;
|
|
132
|
+
}, options?: CommentIteratorOptions): AsyncGenerator<CommentsResponse['comments'][number]>;
|
|
133
|
+
|
|
134
|
+
/** The raw request body exactly as received. Verify before parsing; re-serialized JSON will not match. */
|
|
135
|
+
type WebhookPayload = string | Uint8Array;
|
|
136
|
+
interface VerifyWebhookSignatureInput {
|
|
137
|
+
/** The raw request body. */
|
|
138
|
+
readonly payload: WebhookPayload;
|
|
139
|
+
/** The `Adeli-Signature` header: `t=<unix seconds>,v1=<hex HMAC-SHA256>`. */
|
|
140
|
+
readonly header: string | null | undefined;
|
|
141
|
+
/** The webhook's signing secret, returned once by `createWebhook`. */
|
|
142
|
+
readonly secret: string;
|
|
143
|
+
/** Maximum age (or clock skew) of the signed timestamp. Defaults to 300 seconds. */
|
|
144
|
+
readonly toleranceSeconds?: number;
|
|
145
|
+
/** Current time in unix seconds, for tests. Defaults to the system clock. */
|
|
146
|
+
readonly now?: number;
|
|
147
|
+
}
|
|
148
|
+
declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
149
|
+
/**
|
|
150
|
+
* Check an `Adeli-Signature` header against the raw body. Returns false for a
|
|
151
|
+
* malformed header, a timestamp outside the tolerance, or a signature mismatch;
|
|
152
|
+
* the comparison is constant-time. Throws only for a missing secret or an
|
|
153
|
+
* invalid tolerance, which are configuration mistakes rather than bad deliveries.
|
|
154
|
+
*/
|
|
155
|
+
declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): boolean;
|
|
156
|
+
interface WebhookEventEnvelope {
|
|
157
|
+
/** Stable per provider event; deduplicate redeliveries on it. */
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly createdAt: string;
|
|
160
|
+
readonly profileId: string;
|
|
161
|
+
readonly accountId: string;
|
|
162
|
+
}
|
|
163
|
+
interface CommentCreatedEvent extends WebhookEventEnvelope {
|
|
164
|
+
readonly type: 'comment.created';
|
|
165
|
+
readonly platform: 'instagram';
|
|
166
|
+
readonly data: {
|
|
167
|
+
readonly commentId: string;
|
|
168
|
+
readonly mediaId: string;
|
|
169
|
+
readonly parentId: string | null;
|
|
170
|
+
readonly text: string;
|
|
171
|
+
readonly from: {
|
|
172
|
+
readonly id: string | null;
|
|
173
|
+
readonly username: string | null;
|
|
174
|
+
};
|
|
175
|
+
/** True when the connected account wrote the comment itself. */
|
|
176
|
+
readonly isSelf: boolean;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
interface MessagePostbackEvent extends WebhookEventEnvelope {
|
|
180
|
+
readonly type: 'message.postback';
|
|
181
|
+
readonly platform: 'instagram';
|
|
182
|
+
readonly data: {
|
|
183
|
+
/** The person's Instagram-scoped id; reply with `sendInstagramMessage({ recipient: { id: senderId } })`. */
|
|
184
|
+
readonly senderId: string;
|
|
185
|
+
readonly payload: string;
|
|
186
|
+
readonly title: string | null;
|
|
187
|
+
readonly messageId: string | null;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** An event type (or platform) this SDK version does not know yet. `eventType` keeps the wire `type`. */
|
|
191
|
+
interface UnknownWebhookEvent extends WebhookEventEnvelope {
|
|
192
|
+
readonly type: 'unknown';
|
|
193
|
+
readonly eventType: string;
|
|
194
|
+
readonly platform: string;
|
|
195
|
+
readonly data: unknown;
|
|
196
|
+
}
|
|
197
|
+
type WebhookEvent = CommentCreatedEvent | MessagePostbackEvent | UnknownWebhookEvent;
|
|
198
|
+
type WebhookEventType = Exclude<WebhookEvent['type'], 'unknown'>;
|
|
199
|
+
/**
|
|
200
|
+
* Parse a verified webhook body into a typed event. Known types are validated
|
|
201
|
+
* field by field; an unrecognised type parses as `type: 'unknown'` so new event
|
|
202
|
+
* types stay additive. Throws `MalformedResponseError` for invalid JSON, a
|
|
203
|
+
* missing envelope field, or a known event whose data does not match.
|
|
204
|
+
*/
|
|
205
|
+
declare function parseWebhookEvent(payload: WebhookPayload): WebhookEvent;
|
|
206
|
+
|
|
207
|
+
export { type CommentCreatedEvent, type CommentIteratorOptions, type CommentIteratorQuery, type CommentsClient, type ConnectionPollingClient, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type FacebookPollingClient, type InstagramPollingClient, type MessagePostbackEvent, type PollingOptions, type PostPollingClient, type TikTokPollingClient, type UnknownWebhookEvent, type VerifyWebhookSignatureInput, type WebhookEvent, type WebhookEventType, type WebhookPayload, type YouTubePollingClient, iterateCommentPages, iterateComments, parseWebhookEvent, verifyWebhookSignature, waitForConnection, waitForFacebookPost, waitForInstagramPost, waitForTikTokPost, waitForYouTubeVideo };
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { R as RequestOptions, A as ApiResponse } from '../uploads-MGVSU99R.js';
|
|
2
|
+
import { P as ProfilePath, C as ConnectionSession, F as FacebookPostStatusResponse, I as InstagramPostStatusResponse, T as TikTokPostStatusResponse, Y as YouTubeVideoStatusResponse, a as CommentsQuery, b as CommentsResponse } from '../comments-Dx3195Ty.js';
|
|
3
|
+
|
|
4
|
+
type PublishStatusQuery = {
|
|
5
|
+
readonly accountId: string;
|
|
6
|
+
readonly profileId?: string;
|
|
7
|
+
readonly publishId: string;
|
|
8
|
+
};
|
|
9
|
+
type InstagramStatusQuery = {
|
|
10
|
+
readonly jobId: string;
|
|
11
|
+
readonly profileId?: string;
|
|
12
|
+
};
|
|
13
|
+
type VideoStatusQuery = {
|
|
14
|
+
readonly accountId: string;
|
|
15
|
+
readonly profileId?: string;
|
|
16
|
+
readonly videoId: string;
|
|
17
|
+
};
|
|
18
|
+
/** A bounded polling deadline and delay. Both values are required to make the side effect explicit. */
|
|
19
|
+
interface PollingOptions {
|
|
20
|
+
readonly timeoutMs: number;
|
|
21
|
+
readonly intervalMs: number;
|
|
22
|
+
readonly signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
type ConnectionMethod = (args: {
|
|
25
|
+
readonly path: ProfilePath & {
|
|
26
|
+
readonly connectionSessionId: string;
|
|
27
|
+
};
|
|
28
|
+
}, options?: RequestOptions) => Promise<ApiResponse<ConnectionSession>>;
|
|
29
|
+
type ConnectionPollingClient = {
|
|
30
|
+
readonly profiles: {
|
|
31
|
+
readonly getConnection: ConnectionMethod;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
readonly getConnection: ConnectionMethod;
|
|
35
|
+
};
|
|
36
|
+
type InstagramMethod = (args: {
|
|
37
|
+
readonly query: InstagramStatusQuery;
|
|
38
|
+
}, options?: RequestOptions) => Promise<ApiResponse<InstagramPostStatusResponse>>;
|
|
39
|
+
type TikTokMethod = (args: {
|
|
40
|
+
readonly query: PublishStatusQuery;
|
|
41
|
+
}, options?: RequestOptions) => Promise<ApiResponse<TikTokPostStatusResponse>>;
|
|
42
|
+
type FacebookMethod = (args: {
|
|
43
|
+
readonly query: PublishStatusQuery;
|
|
44
|
+
}, options?: RequestOptions) => Promise<ApiResponse<FacebookPostStatusResponse>>;
|
|
45
|
+
type YouTubeMethod = (args: {
|
|
46
|
+
readonly query: VideoStatusQuery;
|
|
47
|
+
}, options?: RequestOptions) => Promise<ApiResponse<YouTubeVideoStatusResponse>>;
|
|
48
|
+
type InstagramPollingClient = {
|
|
49
|
+
readonly posts: {
|
|
50
|
+
readonly getInstagramPostStatus: InstagramMethod;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
readonly getInstagramPostStatus: InstagramMethod;
|
|
54
|
+
};
|
|
55
|
+
type TikTokPollingClient = {
|
|
56
|
+
readonly posts: {
|
|
57
|
+
readonly getTikTokPostStatus: TikTokMethod;
|
|
58
|
+
};
|
|
59
|
+
} | {
|
|
60
|
+
readonly getTikTokPostStatus: TikTokMethod;
|
|
61
|
+
};
|
|
62
|
+
type FacebookPollingClient = {
|
|
63
|
+
readonly posts: {
|
|
64
|
+
readonly getFacebookPostStatus: FacebookMethod;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
readonly getFacebookPostStatus: FacebookMethod;
|
|
68
|
+
};
|
|
69
|
+
type YouTubePollingClient = {
|
|
70
|
+
readonly posts: {
|
|
71
|
+
readonly getYouTubeVideoStatus: YouTubeMethod;
|
|
72
|
+
};
|
|
73
|
+
} | {
|
|
74
|
+
readonly getYouTubeVideoStatus: YouTubeMethod;
|
|
75
|
+
};
|
|
76
|
+
/** A convenience structural type for clients that expose all post status methods under resources. */
|
|
77
|
+
type PostPollingClient = {
|
|
78
|
+
readonly posts: {
|
|
79
|
+
readonly getInstagramPostStatus: InstagramMethod;
|
|
80
|
+
readonly getTikTokPostStatus: TikTokMethod;
|
|
81
|
+
readonly getFacebookPostStatus: FacebookMethod;
|
|
82
|
+
readonly getYouTubeVideoStatus: YouTubeMethod;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/** Poll a typed connection session; Facebook Page selection can require a dashboard handoff. */
|
|
86
|
+
declare function waitForConnection(client: ConnectionPollingClient, args: {
|
|
87
|
+
readonly path: ProfilePath & {
|
|
88
|
+
readonly connectionSessionId: string;
|
|
89
|
+
};
|
|
90
|
+
}, options: PollingOptions): Promise<ApiResponse<ConnectionSession>>;
|
|
91
|
+
/** Poll durable Instagram publication through published, failed, or uncertain outcome. */
|
|
92
|
+
declare function waitForInstagramPost(client: InstagramPollingClient, args: {
|
|
93
|
+
readonly query: InstagramStatusQuery;
|
|
94
|
+
}, options: PollingOptions): Promise<ApiResponse<InstagramPostStatusResponse>>;
|
|
95
|
+
/** Poll TikTok processing. SEND_TO_USER_INBOX is not a public publication. */
|
|
96
|
+
declare function waitForTikTokPost(client: TikTokPollingClient, args: {
|
|
97
|
+
readonly query: PublishStatusQuery;
|
|
98
|
+
}, options: PollingOptions): Promise<ApiResponse<TikTokPostStatusResponse>>;
|
|
99
|
+
/** Poll Facebook video processing; Page selection is outside this status endpoint. */
|
|
100
|
+
declare function waitForFacebookPost(client: FacebookPollingClient, args: {
|
|
101
|
+
readonly query: PublishStatusQuery;
|
|
102
|
+
}, options: PollingOptions): Promise<ApiResponse<FacebookPostStatusResponse>>;
|
|
103
|
+
/** Poll YouTube processing. Published means processing completed, not public visibility. */
|
|
104
|
+
declare function waitForYouTubeVideo(client: YouTubePollingClient, args: {
|
|
105
|
+
readonly query: VideoStatusQuery;
|
|
106
|
+
}, options: PollingOptions): Promise<ApiResponse<YouTubeVideoStatusResponse>>;
|
|
107
|
+
|
|
108
|
+
type CommentIteratorQuery = Omit<CommentsQuery, 'platform'> & {
|
|
109
|
+
readonly platform: 'tiktok' | 'youtube';
|
|
110
|
+
};
|
|
111
|
+
interface CommentsClient {
|
|
112
|
+
readonly comments: {
|
|
113
|
+
listComments(args: {
|
|
114
|
+
readonly query: CommentsQuery;
|
|
115
|
+
}, options?: RequestOptions): Promise<ApiResponse<CommentsResponse>>;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface CommentIteratorOptions {
|
|
119
|
+
/** Maximum number of requests. The default is deliberately finite. */
|
|
120
|
+
readonly maxPages?: number;
|
|
121
|
+
/** Total wall-clock budget for all pages, including request time. */
|
|
122
|
+
readonly timeoutMs?: number;
|
|
123
|
+
readonly signal?: AbortSignal;
|
|
124
|
+
}
|
|
125
|
+
/** Yield complete page responses; `complete` describes cache freshness, not pagination. */
|
|
126
|
+
declare function iterateCommentPages(client: CommentsClient, args: {
|
|
127
|
+
readonly query: CommentIteratorQuery;
|
|
128
|
+
}, options?: CommentIteratorOptions): AsyncGenerator<ApiResponse<CommentsResponse>>;
|
|
129
|
+
/** Yield the original comment records without normalizing provider fields. */
|
|
130
|
+
declare function iterateComments(client: CommentsClient, args: {
|
|
131
|
+
readonly query: CommentIteratorQuery;
|
|
132
|
+
}, options?: CommentIteratorOptions): AsyncGenerator<CommentsResponse['comments'][number]>;
|
|
133
|
+
|
|
134
|
+
/** The raw request body exactly as received. Verify before parsing; re-serialized JSON will not match. */
|
|
135
|
+
type WebhookPayload = string | Uint8Array;
|
|
136
|
+
interface VerifyWebhookSignatureInput {
|
|
137
|
+
/** The raw request body. */
|
|
138
|
+
readonly payload: WebhookPayload;
|
|
139
|
+
/** The `Adeli-Signature` header: `t=<unix seconds>,v1=<hex HMAC-SHA256>`. */
|
|
140
|
+
readonly header: string | null | undefined;
|
|
141
|
+
/** The webhook's signing secret, returned once by `createWebhook`. */
|
|
142
|
+
readonly secret: string;
|
|
143
|
+
/** Maximum age (or clock skew) of the signed timestamp. Defaults to 300 seconds. */
|
|
144
|
+
readonly toleranceSeconds?: number;
|
|
145
|
+
/** Current time in unix seconds, for tests. Defaults to the system clock. */
|
|
146
|
+
readonly now?: number;
|
|
147
|
+
}
|
|
148
|
+
declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
149
|
+
/**
|
|
150
|
+
* Check an `Adeli-Signature` header against the raw body. Returns false for a
|
|
151
|
+
* malformed header, a timestamp outside the tolerance, or a signature mismatch;
|
|
152
|
+
* the comparison is constant-time. Throws only for a missing secret or an
|
|
153
|
+
* invalid tolerance, which are configuration mistakes rather than bad deliveries.
|
|
154
|
+
*/
|
|
155
|
+
declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): boolean;
|
|
156
|
+
interface WebhookEventEnvelope {
|
|
157
|
+
/** Stable per provider event; deduplicate redeliveries on it. */
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly createdAt: string;
|
|
160
|
+
readonly profileId: string;
|
|
161
|
+
readonly accountId: string;
|
|
162
|
+
}
|
|
163
|
+
interface CommentCreatedEvent extends WebhookEventEnvelope {
|
|
164
|
+
readonly type: 'comment.created';
|
|
165
|
+
readonly platform: 'instagram';
|
|
166
|
+
readonly data: {
|
|
167
|
+
readonly commentId: string;
|
|
168
|
+
readonly mediaId: string;
|
|
169
|
+
readonly parentId: string | null;
|
|
170
|
+
readonly text: string;
|
|
171
|
+
readonly from: {
|
|
172
|
+
readonly id: string | null;
|
|
173
|
+
readonly username: string | null;
|
|
174
|
+
};
|
|
175
|
+
/** True when the connected account wrote the comment itself. */
|
|
176
|
+
readonly isSelf: boolean;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
interface MessagePostbackEvent extends WebhookEventEnvelope {
|
|
180
|
+
readonly type: 'message.postback';
|
|
181
|
+
readonly platform: 'instagram';
|
|
182
|
+
readonly data: {
|
|
183
|
+
/** The person's Instagram-scoped id; reply with `sendInstagramMessage({ recipient: { id: senderId } })`. */
|
|
184
|
+
readonly senderId: string;
|
|
185
|
+
readonly payload: string;
|
|
186
|
+
readonly title: string | null;
|
|
187
|
+
readonly messageId: string | null;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** An event type (or platform) this SDK version does not know yet. `eventType` keeps the wire `type`. */
|
|
191
|
+
interface UnknownWebhookEvent extends WebhookEventEnvelope {
|
|
192
|
+
readonly type: 'unknown';
|
|
193
|
+
readonly eventType: string;
|
|
194
|
+
readonly platform: string;
|
|
195
|
+
readonly data: unknown;
|
|
196
|
+
}
|
|
197
|
+
type WebhookEvent = CommentCreatedEvent | MessagePostbackEvent | UnknownWebhookEvent;
|
|
198
|
+
type WebhookEventType = Exclude<WebhookEvent['type'], 'unknown'>;
|
|
199
|
+
/**
|
|
200
|
+
* Parse a verified webhook body into a typed event. Known types are validated
|
|
201
|
+
* field by field; an unrecognised type parses as `type: 'unknown'` so new event
|
|
202
|
+
* types stay additive. Throws `MalformedResponseError` for invalid JSON, a
|
|
203
|
+
* missing envelope field, or a known event whose data does not match.
|
|
204
|
+
*/
|
|
205
|
+
declare function parseWebhookEvent(payload: WebhookPayload): WebhookEvent;
|
|
206
|
+
|
|
207
|
+
export { type CommentCreatedEvent, type CommentIteratorOptions, type CommentIteratorQuery, type CommentsClient, type ConnectionPollingClient, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type FacebookPollingClient, type InstagramPollingClient, type MessagePostbackEvent, type PollingOptions, type PostPollingClient, type TikTokPollingClient, type UnknownWebhookEvent, type VerifyWebhookSignatureInput, type WebhookEvent, type WebhookEventType, type WebhookPayload, type YouTubePollingClient, iterateCommentPages, iterateComments, parseWebhookEvent, verifyWebhookSignature, waitForConnection, waitForFacebookPost, waitForInstagramPost, waitForTikTokPost, waitForYouTubeVideo };
|