@doist/todoist-sdk 9.2.0 → 9.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/cjs/clients/app-client.js +17 -17
- package/dist/cjs/clients/comment-client.js +3 -4
- package/dist/cjs/clients/folder-client.js +3 -4
- package/dist/cjs/clients/insights-client.js +6 -7
- package/dist/cjs/clients/label-client.js +3 -4
- package/dist/cjs/clients/project-client.js +8 -9
- package/dist/cjs/clients/section-client.js +5 -6
- package/dist/cjs/clients/task-client.js +6 -7
- package/dist/cjs/clients/ui-extension-client.js +4 -5
- package/dist/cjs/clients/workspace-client.js +3 -4
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/webhooks/envelope.js +26 -0
- package/dist/cjs/types/webhooks/index.js +19 -0
- package/dist/cjs/types/webhooks/tasks.js +68 -0
- package/dist/cjs/types/webhooks/types.js +34 -0
- package/dist/cjs/utils/index.js +4 -1
- package/dist/cjs/utils/validators.js +7 -2
- package/dist/cjs/utils/webhook-parser.js +60 -0
- package/dist/esm/clients/app-client.js +18 -18
- package/dist/esm/clients/comment-client.js +4 -5
- package/dist/esm/clients/folder-client.js +4 -5
- package/dist/esm/clients/insights-client.js +7 -8
- package/dist/esm/clients/label-client.js +4 -5
- package/dist/esm/clients/project-client.js +9 -10
- package/dist/esm/clients/section-client.js +6 -7
- package/dist/esm/clients/task-client.js +7 -8
- package/dist/esm/clients/ui-extension-client.js +5 -6
- package/dist/esm/clients/workspace-client.js +4 -5
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/webhooks/envelope.js +23 -0
- package/dist/esm/types/webhooks/index.js +3 -0
- package/dist/esm/types/webhooks/tasks.js +65 -0
- package/dist/esm/types/webhooks/types.js +31 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/validators.js +5 -0
- package/dist/esm/utils/webhook-parser.js +56 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/webhooks/envelope.d.ts +34 -0
- package/dist/types/types/webhooks/index.d.ts +3 -0
- package/dist/types/types/webhooks/tasks.d.ts +981 -0
- package/dist/types/types/webhooks/types.d.ts +893 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/validators.d.ts +2 -0
- package/dist/types/utils/webhook-parser.d.ts +48 -0
- package/package.json +1 -1
|
@@ -3,3 +3,5 @@ export * from './sanitization.js';
|
|
|
3
3
|
export { getTaskUrl, getProjectUrl, getSectionUrl } from './url-helpers.js';
|
|
4
4
|
export { createCommand } from './sync-helpers.js';
|
|
5
5
|
export * from './project-helpers.js';
|
|
6
|
+
export { parseWebhookPayload, verifyWebhookSignature } from './webhook-parser.js';
|
|
7
|
+
export type { VerifyWebhookSignatureArgs } from './webhook-parser.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type WebhookPayload } from '../types/webhooks/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parses an incoming webhook request body into a typed payload.
|
|
4
|
+
*
|
|
5
|
+
* The backend sends snake_case keys (e.g. `event_name`, `user_id`, `added_at`);
|
|
6
|
+
* this converts them to camelCase and validates against
|
|
7
|
+
* {@link WebhookPayloadSchema}. Event-specific `eventData` is returned as
|
|
8
|
+
* `unknown` for events that are not yet narrowed per-resource.
|
|
9
|
+
*
|
|
10
|
+
* Pass the parsed JSON body (or any unknown value) — validation throws on
|
|
11
|
+
* unexpected shape.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseWebhookPayload(raw: unknown): WebhookPayload;
|
|
14
|
+
/**
|
|
15
|
+
* Arguments for {@link verifyWebhookSignature}.
|
|
16
|
+
*/
|
|
17
|
+
export type VerifyWebhookSignatureArgs = {
|
|
18
|
+
/**
|
|
19
|
+
* The raw (unparsed) request body exactly as received. Parsing and
|
|
20
|
+
* re-serialising JSON before hashing will change whitespace and byte order
|
|
21
|
+
* and cause verification to fail.
|
|
22
|
+
*/
|
|
23
|
+
rawBody: string | Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* The value of the `X-Todoist-Hmac-SHA256` request header — a base64
|
|
26
|
+
* encoded HMAC-SHA256 digest.
|
|
27
|
+
*/
|
|
28
|
+
signature: string;
|
|
29
|
+
/**
|
|
30
|
+
* The app's OAuth client secret, used as the HMAC key.
|
|
31
|
+
*/
|
|
32
|
+
clientSecret: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Verifies a webhook request's HMAC signature.
|
|
36
|
+
*
|
|
37
|
+
* Todoist signs webhook deliveries with an HMAC-SHA256 of the raw request body
|
|
38
|
+
* using the app's `client_secret` as the key, base64-encoded in the
|
|
39
|
+
* `X-Todoist-Hmac-SHA256` header.
|
|
40
|
+
*
|
|
41
|
+
* Uses the Web Crypto API (`crypto.subtle`), which is available in Node ≥ 20,
|
|
42
|
+
* modern browsers, React Native (with polyfills), and edge runtimes. The
|
|
43
|
+
* comparison is constant-time.
|
|
44
|
+
*
|
|
45
|
+
* @returns `true` when the signature is valid, `false` otherwise. Never throws
|
|
46
|
+
* on malformed input.
|
|
47
|
+
*/
|
|
48
|
+
export declare function verifyWebhookSignature({ rawBody, signature, clientSecret, }: VerifyWebhookSignatureArgs): Promise<boolean>;
|
package/package.json
CHANGED