@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.
Files changed (45) hide show
  1. package/dist/cjs/clients/app-client.js +17 -17
  2. package/dist/cjs/clients/comment-client.js +3 -4
  3. package/dist/cjs/clients/folder-client.js +3 -4
  4. package/dist/cjs/clients/insights-client.js +6 -7
  5. package/dist/cjs/clients/label-client.js +3 -4
  6. package/dist/cjs/clients/project-client.js +8 -9
  7. package/dist/cjs/clients/section-client.js +5 -6
  8. package/dist/cjs/clients/task-client.js +6 -7
  9. package/dist/cjs/clients/ui-extension-client.js +4 -5
  10. package/dist/cjs/clients/workspace-client.js +3 -4
  11. package/dist/cjs/types/index.js +1 -0
  12. package/dist/cjs/types/webhooks/envelope.js +26 -0
  13. package/dist/cjs/types/webhooks/index.js +19 -0
  14. package/dist/cjs/types/webhooks/tasks.js +68 -0
  15. package/dist/cjs/types/webhooks/types.js +34 -0
  16. package/dist/cjs/utils/index.js +4 -1
  17. package/dist/cjs/utils/validators.js +7 -2
  18. package/dist/cjs/utils/webhook-parser.js +60 -0
  19. package/dist/esm/clients/app-client.js +18 -18
  20. package/dist/esm/clients/comment-client.js +4 -5
  21. package/dist/esm/clients/folder-client.js +4 -5
  22. package/dist/esm/clients/insights-client.js +7 -8
  23. package/dist/esm/clients/label-client.js +4 -5
  24. package/dist/esm/clients/project-client.js +9 -10
  25. package/dist/esm/clients/section-client.js +6 -7
  26. package/dist/esm/clients/task-client.js +7 -8
  27. package/dist/esm/clients/ui-extension-client.js +5 -6
  28. package/dist/esm/clients/workspace-client.js +4 -5
  29. package/dist/esm/types/index.js +1 -0
  30. package/dist/esm/types/webhooks/envelope.js +23 -0
  31. package/dist/esm/types/webhooks/index.js +3 -0
  32. package/dist/esm/types/webhooks/tasks.js +65 -0
  33. package/dist/esm/types/webhooks/types.js +31 -0
  34. package/dist/esm/utils/index.js +1 -0
  35. package/dist/esm/utils/validators.js +5 -0
  36. package/dist/esm/utils/webhook-parser.js +56 -0
  37. package/dist/types/types/index.d.ts +1 -0
  38. package/dist/types/types/webhooks/envelope.d.ts +34 -0
  39. package/dist/types/types/webhooks/index.d.ts +3 -0
  40. package/dist/types/types/webhooks/tasks.d.ts +981 -0
  41. package/dist/types/types/webhooks/types.d.ts +893 -0
  42. package/dist/types/utils/index.d.ts +2 -0
  43. package/dist/types/utils/validators.d.ts +2 -0
  44. package/dist/types/utils/webhook-parser.d.ts +48 -0
  45. 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';
@@ -1,4 +1,6 @@
1
+ import { z } from 'zod';
1
2
  import { type SyncResponse } from '../types/sync/response.js';
3
+ export declare const IdSchema: z.ZodString;
2
4
  export declare const validateTask: (input: unknown) => {
3
5
  isUncompletable: boolean;
4
6
  url: string;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "9.2.0",
3
+ "version": "9.4.0",
4
4
  "description": "The official TypeScript SDK for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "https://github.com/Doist/todoist-sdk-typescript",