@composio/core 0.31.0 → 0.33.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 (92) hide show
  1. package/dist/{CustomTool-9Vlb4XaS.mjs → CustomTool-B4dQn2M5.mjs} +1 -1
  2. package/dist/{CustomTool-Ds5aLDth.d.mts → CustomTool-C2kvAvzk.d.mts} +1 -1
  3. package/dist/{FileModifierErrors-WrqokuIF.mjs → FileModifierErrors-D-AKc3ds.mjs} +1 -1
  4. package/dist/{SsrfErrors-BSVMW915.mjs → SsrfErrors-BekZPeWY.mjs} +59 -12
  5. package/dist/{Telemetry-a7SOQXcg.mjs → Telemetry-CcCuFVUb.mjs} +2 -2
  6. package/dist/composio-BqE615oV.d.mts +20365 -0
  7. package/dist/{customTool.types-DHxXBU6E.d.mts → customTool.types-DnyEZmlx.d.mts} +510 -33
  8. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +20 -12
  9. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +28 -10
  10. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +96 -40
  11. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +8 -6
  12. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +4 -3
  13. package/dist/docs/reference/sdk-reference/typescript/index.mdx +4 -2
  14. package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +6 -3
  15. package/dist/docs/reference/sdk-reference/typescript/logs.mdx +5 -3
  16. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +53 -42
  17. package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -0
  18. package/dist/docs/reference/sdk-reference/typescript/remote-file.mdx +5 -14
  19. package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +5 -3
  20. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +7 -5
  21. package/dist/docs/reference/sdk-reference/typescript/session-webhooks.mdx +64 -0
  22. package/dist/docs/reference/sdk-reference/typescript/session.mdx +16 -16
  23. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +36 -8
  24. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +14 -11
  25. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +16 -18
  26. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +42 -30
  27. package/dist/docs/reference/sdk-reference/typescript/usage.mdx +6 -4
  28. package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +9 -7
  29. package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +13 -9
  30. package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +3 -1
  31. package/dist/{errors-xC13uvaA.mjs → errors-CtIKA9BH.mjs} +2 -2
  32. package/dist/experimental/index.d.mts +2 -2
  33. package/dist/experimental/index.mjs +1 -1
  34. package/dist/{fileUtils.node-CAwIbWYH.mjs → fileUtils.node-DPMtE0ER.mjs} +7 -71
  35. package/dist/index.d.mts +7 -245
  36. package/dist/index.mjs +573 -251
  37. package/dist/jsonSchema-CDHLYm7d.d.mts +237 -0
  38. package/dist/{jsonSchema-Cc4EtHRw.mjs → jsonSchema-CfZwBS13.mjs} +7 -3
  39. package/dist/models/Files.node.mjs +3 -3
  40. package/dist/{sensitiveFileUploadPaths-CSyJ3Ku8.mjs → sensitiveFileUploadPaths-6NcnFSyX.mjs} +82 -85
  41. package/dist/{ssrfGuard.node-CdIkwqVu.mjs → ssrfGuard.node-B749ae5Q.mjs} +1 -1
  42. package/dist/{types-DcdZy5Nc.d.mts → types-Cwr_Makk.d.mts} +2 -2
  43. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  44. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  45. package/dist/utils/json-schema.d.mts +2 -1
  46. package/dist/utils/json-schema.mjs +2 -1
  47. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  48. package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
  49. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  50. package/dist/utils/ssrfGuard.node.mjs +1 -1
  51. package/dist/utils/ssrfGuard.workerd.mjs +1 -1
  52. package/package.json +6 -6
  53. package/src/composio.ts +26 -7
  54. package/src/errors/ComposioError.ts +3 -2
  55. package/src/index.ts +19 -0
  56. package/src/lib/toolRouterParams.ts +38 -14
  57. package/src/models/AuthConfigs.ts +10 -3
  58. package/src/models/ConnectedAccounts.ts +101 -28
  59. package/src/models/CustomTool.ts +0 -10
  60. package/src/models/Keyring.ts +2 -1
  61. package/src/models/MCP.ts +43 -35
  62. package/src/models/SessionWebhooks.ts +136 -0
  63. package/src/models/ToolRouter.ts +39 -4
  64. package/src/models/ToolRouterSession.ts +2 -2
  65. package/src/models/ToolRouterSessionFileMount.ts +3 -1
  66. package/src/models/Toolkits.ts +1 -0
  67. package/src/models/Tools.ts +4 -8
  68. package/src/models/Triggers.ts +48 -213
  69. package/src/models/Webhooks.ts +2 -0
  70. package/src/provider/ComposioProvider.ts +0 -1
  71. package/src/telemetry/BatchProcessor.ts +1 -1
  72. package/src/telemetry/Telemetry.ts +1 -1
  73. package/src/types/connectedAccountAuthStates.types.ts +0 -1
  74. package/src/types/connectedAccounts.types.ts +59 -1
  75. package/src/types/provider.types.ts +0 -1
  76. package/src/types/sessionWebhooks.types.ts +292 -0
  77. package/src/types/toolRouter.types.ts +35 -5
  78. package/src/types/triggers.types.ts +4 -0
  79. package/src/utils/crypto.ts +6 -5
  80. package/src/utils/env.ts +2 -5
  81. package/src/utils/fileUtils.node.ts +5 -86
  82. package/src/utils/json-schema.ts +6 -0
  83. package/src/utils/jsonSchema.ts +17 -4
  84. package/src/utils/logger.ts +19 -9
  85. package/src/utils/mime.ts +25 -385
  86. package/src/utils/mimeTables.generated.ts +356 -0
  87. package/src/utils/pusher.ts +5 -2
  88. package/src/utils/readResponseBody.ts +30 -17
  89. package/src/utils/transformers/authConfigs.ts +0 -1
  90. package/src/utils/userCallback.ts +3 -1
  91. package/src/utils/webhookVerification.ts +211 -0
  92. package/dist/composio-Ba89XGHL.d.mts +0 -9736
@@ -42,7 +42,6 @@ import { PusherService } from '../services/pusher/Pusher';
42
42
  import {
43
43
  ComposioTriggerTypeNotFoundError,
44
44
  ComposioWebhookPayloadError,
45
- ComposioWebhookSignatureVerificationError,
46
45
  } from '../errors/TriggerErrors';
47
46
  import { transform } from '../utils/transform';
48
47
  import {
@@ -54,96 +53,28 @@ import {
54
53
  import { ToolkitVersionParam } from '../types/tool.types';
55
54
  import type { ComposioConfig } from '../composio';
56
55
  import type { BaseComposioProvider } from '../provider/BaseProvider';
57
- import { hmacSha256Base64, timingSafeEqual } from '../utils/crypto';
56
+ import {
57
+ WEBHOOK_HEADERS,
58
+ getHeader,
59
+ assertWebhookBodySize,
60
+ readWebhookRequest,
61
+ validateWebhookTimestamp,
62
+ verifyWebhookSignature,
63
+ } from '../utils/webhookVerification';
58
64
  import { CONFIG_DEFAULTS } from '../utils/config-defaults';
59
65
  import { ComposioRequestOptions } from '../types/requestOptions.types';
60
66
  import { withCancellation } from '../utils/cancellation';
61
67
  import { invokeUserCallback } from '../utils/userCallback';
62
68
 
63
69
  /**
64
- * Safely converts a value to a string, returning the default if the value is null, undefined, or empty.
65
- * This prevents runtime crashes when calling string methods like `.toLowerCase()` on non-string values.
70
+ * Normalizes string and numeric identifiers, falling back for empty or malformed values.
66
71
  * @private
67
72
  */
68
73
  const toStringOrDefault = (value: unknown, defaultValue: string): string => {
69
- if (value === null || value === undefined) {
70
- return defaultValue;
71
- }
72
- const str = String(value);
74
+ const str = typeof value === 'string' || typeof value === 'number' ? String(value) : '';
73
75
  return str.length > 0 ? str : defaultValue;
74
76
  };
75
77
 
76
- /**
77
- * The signature header names Composio sends with every webhook delivery.
78
- * @private
79
- */
80
- const WEBHOOK_HEADERS = {
81
- id: 'webhook-id',
82
- timestamp: 'webhook-timestamp',
83
- signature: 'webhook-signature',
84
- } as const;
85
-
86
- /**
87
- * Returns true if the value is a Fetch API `Request`.
88
- * @private
89
- */
90
- const isFetchRequest = (request: WebhookRequestLike): request is Request =>
91
- typeof Request !== 'undefined' && request instanceof Request;
92
-
93
- /**
94
- * Reads a single header value case-insensitively from either a `Headers`
95
- * instance or a plain record (where values may be `string | string[]`).
96
- * Returns `undefined` when the header is missing.
97
- * @private
98
- */
99
- const getHeader = (headers: unknown, name: string): string | undefined => {
100
- if (typeof Headers !== 'undefined' && headers instanceof Headers) {
101
- return headers.get(name) ?? undefined;
102
- }
103
-
104
- if (headers === null || typeof headers !== 'object') {
105
- return undefined;
106
- }
107
-
108
- // Plain record: match the header name case-insensitively.
109
- const target = name.toLowerCase();
110
- for (const [key, value] of Object.entries(headers as Record<string, unknown>)) {
111
- if (key.toLowerCase() !== target) {
112
- continue;
113
- }
114
- if (Array.isArray(value)) {
115
- const first = value.find((item): item is string => typeof item === 'string');
116
- return first;
117
- }
118
- return typeof value === 'string' ? value : undefined;
119
- }
120
- return undefined;
121
- };
122
-
123
- /**
124
- * Coerces an object request body (string, Buffer/Uint8Array, or already-parsed
125
- * value) into the raw string form expected by signature verification.
126
- * @private
127
- */
128
- const bodyToString = (body: unknown): string => {
129
- if (typeof body === 'string') {
130
- return body;
131
- }
132
- if (body instanceof Uint8Array) {
133
- return new TextDecoder().decode(body);
134
- }
135
- if (body === null || body === undefined) {
136
- return '';
137
- }
138
- // Already-parsed object (e.g. Next.js Pages Router with the JSON body parser).
139
- // Note: re-stringifying cannot reproduce the exact bytes Composio signed, so
140
- // signature verification on a pre-parsed body is best-effort only.
141
- if (typeof body === 'object') {
142
- return JSON.stringify(body);
143
- }
144
- return String(body);
145
- };
146
-
147
78
  /**
148
79
  * Trigger (Instance) class
149
80
  * /api/v3/trigger_instances
@@ -174,6 +105,8 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
174
105
  *
175
106
  * @example
176
107
  * ```ts
108
+ * const APP_URL = 'https://your-app.com';
109
+ *
177
110
  * await composio.triggers.setWebhookSubscription({
178
111
  * webhookUrl: `${APP_URL}/webhooks/composio`,
179
112
  * });
@@ -194,7 +127,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
194
127
  *
195
128
  * @example
196
129
  * ```ts
197
- * const triggers = await triggers.listActive({
130
+ * const activeTriggers = await composio.triggers.listActive({
198
131
  * authConfigIds: ['123'],
199
132
  * connectedAccountIds: ['456'],
200
133
  * });
@@ -554,10 +487,9 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
554
487
  *
555
488
  * @example
556
489
  * ```ts
557
- *
558
- * triggers.subscribe((data) => {
490
+ * await composio.triggers.subscribe((data) => {
559
491
  * console.log(data);
560
- * }, );
492
+ * });
561
493
  * ```
562
494
  */
563
495
  async subscribe(
@@ -724,11 +656,11 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
724
656
  *
725
657
  * @example
726
658
  * ```ts
727
- * composio.trigger.subscribe((data) => {
659
+ * await composio.triggers.subscribe((data) => {
728
660
  * console.log(data);
729
661
  * });
730
662
  *
731
- * await triggers.unsubscribe();
663
+ * await composio.triggers.unsubscribe();
732
664
  * ```
733
665
  */
734
666
  async unsubscribe() {
@@ -748,18 +680,22 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
748
680
  * Next.js Pages Router `req`). The signature headers (`webhook-id`,
749
681
  * `webhook-timestamp`, `webhook-signature`) are read case-insensitively.
750
682
  *
683
+ * Configure a request body limit in your server or framework as well,
684
+ * especially if it buffers the body before calling this method.
685
+ *
751
686
  * @param {WebhookRequestLike} request - The incoming webhook HTTP request
752
687
  * @param {ParseWebhookOptions} [options] - Parse options
753
688
  * @param {string} [options.verifySecret] - Webhook secret; when set, the signature is verified
754
689
  * @param {number} [options.tolerance=300] - Max webhook age in seconds (only used when verifying)
690
+ * @param {number} [options.maxBodyBytes=10485760] - Max request body size in bytes (10 MiB)
755
691
  * @returns {Promise<VerifyWebhookResult>} The parsed (and optionally verified) webhook payload
756
692
  *
757
693
  * @throws {ValidationError} If `verifySecret` is set but the signature headers are missing
758
694
  * @throws {ComposioWebhookSignatureVerificationError} If signature verification fails
759
- * @throws {ComposioWebhookPayloadError} If the payload cannot be parsed
695
+ * @throws {ComposioWebhookPayloadError} If the payload exceeds the limit or cannot be parsed
760
696
  *
761
697
  * @example
762
- * ```ts
698
+ * ```ts nocheck="Express route handler; the checker has no express types"
763
699
  * // Express with express.raw (verify the signature)
764
700
  * app.post('/webhooks/composio', express.raw({ type: 'application/json' }), async (req, res) => {
765
701
  * try {
@@ -797,7 +733,10 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
797
733
  * return new Response('Unauthorized', { status: 401 });
798
734
  * }
799
735
  * }
736
+ * ```
800
737
  *
738
+ * @example
739
+ * ```ts
801
740
  * // Next.js App Router — parse only (no verification)
802
741
  * export async function POST(request: Request) {
803
742
  * const result = await composio.triggers.parse(request);
@@ -811,15 +750,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
811
750
  options?: ParseWebhookOptions
812
751
  ): Promise<VerifyWebhookResult> {
813
752
  // Extract the raw body and signature headers from either request shape.
814
- let body: string;
815
- let headers: unknown;
816
- if (isFetchRequest(request)) {
817
- body = await request.text();
818
- headers = request.headers;
819
- } else {
820
- body = bodyToString(request.body);
821
- headers = request.headers;
822
- }
753
+ const { body, headers } = await readWebhookRequest(request, options?.maxBodyBytes);
823
754
 
824
755
  const verifySecret = options?.verifySecret;
825
756
 
@@ -887,6 +818,9 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
887
818
  * The signature is computed as: `HMAC-SHA256(${webhookId}.${webhookTimestamp}.${payload}, secret)`
888
819
  * and is expected in the format: `v1,base64EncodedSignature`
889
820
  *
821
+ * For a Fetch API `Request`, use {@link parse} to enforce a limit while reading
822
+ * the body. Set a server request limit if you buffer the payload yourself.
823
+ *
890
824
  * @param {VerifyWebhookParams} params - The verification parameters
891
825
  * @param {string} params.payload - The raw webhook payload as a string (request body)
892
826
  * @param {string} params.signature - The signature from the 'webhook-signature' header
@@ -894,6 +828,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
894
828
  * @param {string} params.webhookId - The webhook ID from the 'webhook-id' header
895
829
  * @param {string} params.webhookTimestamp - The timestamp from the 'webhook-timestamp' header (Unix seconds)
896
830
  * @param {number} [params.tolerance=300] - Maximum allowed age of the webhook in seconds (default: 5 minutes). Set to 0 to disable timestamp validation.
831
+ * @param {number} [params.maxBodyBytes] - Max UTF-8 size of the supplied payload
897
832
  * @returns {VerifyWebhookResult} The verified and parsed webhook payload with version information
898
833
  *
899
834
  * @throws {ValidationError} If the parameters are invalid
@@ -902,26 +837,26 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
902
837
  *
903
838
  * @example
904
839
  * ```ts
905
- * // In an Express.js webhook handler
906
- * app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
840
+ * // In a webhook route that receives a Fetch API Request (Next.js App Router, Hono, Remix)
841
+ * export async function POST(request: Request) {
907
842
  * try {
908
843
  * const result = await composio.triggers.verifyWebhook({
909
- * payload: req.body.toString(),
910
- * signature: req.headers['webhook-signature'] as string,
911
- * webhookId: req.headers['webhook-id'] as string,
912
- * webhookTimestamp: req.headers['webhook-timestamp'] as string,
844
+ * payload: await request.text(),
845
+ * signature: request.headers.get('webhook-signature') ?? '',
846
+ * id: request.headers.get('webhook-id') ?? '',
847
+ * timestamp: request.headers.get('webhook-timestamp') ?? '',
913
848
  * secret: process.env.COMPOSIO_WEBHOOK_SECRET!,
914
849
  * });
915
850
  *
916
851
  * // Process the verified payload
917
852
  * console.log('Webhook version:', result.version);
918
853
  * console.log('Received trigger:', result.payload.triggerSlug);
919
- * res.status(200).send('OK');
854
+ * return new Response('OK', { status: 200 });
920
855
  * } catch (error) {
921
856
  * console.error('Webhook verification failed:', error);
922
- * res.status(401).send('Unauthorized');
857
+ * return new Response('Unauthorized', { status: 401 });
923
858
  * }
924
- * });
859
+ * }
925
860
  * ```
926
861
  */
927
862
  async verifyWebhook(params: VerifyWebhookParams): Promise<VerifyWebhookResult> {
@@ -962,15 +897,20 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
962
897
  id: webhookId,
963
898
  timestamp: webhookTimestamp,
964
899
  tolerance,
900
+ maxBodyBytes,
965
901
  } = parsedParams.data;
966
902
 
903
+ if (maxBodyBytes !== undefined) {
904
+ assertWebhookBodySize(payload, maxBodyBytes);
905
+ }
906
+
967
907
  // Validate timestamp if tolerance is set
968
908
  if (tolerance > 0) {
969
- this.validateWebhookTimestamp(webhookTimestamp, tolerance);
909
+ validateWebhookTimestamp(webhookTimestamp, tolerance);
970
910
  }
971
911
 
972
912
  // Verify signature using the correct format: msgId.timestamp.payload
973
- await this.verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret);
913
+ await verifyWebhookSignature(webhookId, webhookTimestamp, payload, signature, secret);
974
914
 
975
915
  // Parse the payload and detect version
976
916
  const { version, rawPayload, normalizedPayload } = this.parseWebhookPayload(payload);
@@ -1003,7 +943,7 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
1003
943
  // Try V1/V2/V3 formats using shared parsing logic
1004
944
  const result = this.tryParseVersionedPayload(jsonPayload);
1005
945
  if (result.ok) {
1006
- const { ok, ...rest } = result;
946
+ const { ok: _ok, ...rest } = result;
1007
947
  return rest;
1008
948
  }
1009
949
 
@@ -1168,109 +1108,4 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
1168
1108
  },
1169
1109
  };
1170
1110
  }
1171
-
1172
- /**
1173
- * Verifies the HMAC-SHA256 signature of a webhook payload.
1174
- * The signature format used by Composio is: `v1,base64EncodedSignature`
1175
- * The signing input is: `${msgId}.${timestamp}.${payload}`
1176
- * @private
1177
- */
1178
- private async verifyWebhookSignature(
1179
- webhookId: string,
1180
- webhookTimestamp: string,
1181
- payload: string,
1182
- signature: string,
1183
- secret: string
1184
- ): Promise<void> {
1185
- if (payload.length === 0) {
1186
- throw new ComposioWebhookSignatureVerificationError('No webhook payload was provided.');
1187
- }
1188
-
1189
- if (signature.length === 0) {
1190
- throw new ComposioWebhookSignatureVerificationError(
1191
- "No signature header value was provided. Please pass the value of the 'webhook-signature' header."
1192
- );
1193
- }
1194
-
1195
- if (secret.length === 0) {
1196
- throw new ComposioWebhookSignatureVerificationError(
1197
- 'No webhook secret was provided. You can find your webhook secret in your Composio dashboard.'
1198
- );
1199
- }
1200
-
1201
- if (webhookId.length === 0) {
1202
- throw new ComposioWebhookSignatureVerificationError(
1203
- "No webhook ID was provided. Please pass the value of the 'webhook-id' header."
1204
- );
1205
- }
1206
-
1207
- if (webhookTimestamp.length === 0) {
1208
- throw new ComposioWebhookSignatureVerificationError(
1209
- "No webhook timestamp was provided. Please pass the value of the 'webhook-timestamp' header."
1210
- );
1211
- }
1212
-
1213
- // Parse signature - may have multiple signatures prefixed with version (e.g., "v1,base64sig")
1214
- const signatures = signature.split(' ');
1215
- const v1Signatures: string[] = [];
1216
-
1217
- for (const sig of signatures) {
1218
- const [version, value] = sig.split(',');
1219
- if (version === 'v1' && value) {
1220
- v1Signatures.push(value);
1221
- }
1222
- }
1223
-
1224
- if (v1Signatures.length === 0) {
1225
- throw new ComposioWebhookSignatureVerificationError(
1226
- 'No valid v1 signature found in the webhook-signature header. ' +
1227
- "Expected format: 'v1,base64EncodedSignature'"
1228
- );
1229
- }
1230
-
1231
- // Compute expected signature: HMAC-SHA256(msgId.timestamp.payload, secret) -> base64
1232
- const toSign = `${webhookId}.${webhookTimestamp}.${payload}`;
1233
- const expectedSignature = await hmacSha256Base64(secret, toSign);
1234
-
1235
- // Check if any of the provided signatures match
1236
- let isValid = false;
1237
- for (const providedSignature of v1Signatures) {
1238
- if (timingSafeEqual(providedSignature, expectedSignature)) {
1239
- isValid = true;
1240
- break;
1241
- }
1242
- }
1243
-
1244
- if (!isValid) {
1245
- throw new ComposioWebhookSignatureVerificationError(
1246
- 'The signature provided is invalid. Please ensure you are using the correct webhook secret.'
1247
- );
1248
- }
1249
- }
1250
-
1251
- /**
1252
- * Validates that the webhook timestamp is within the allowed tolerance
1253
- * @private
1254
- */
1255
- private validateWebhookTimestamp(webhookTimestamp: string, tolerance: number): void {
1256
- const timestampSeconds = parseInt(webhookTimestamp, 10);
1257
-
1258
- if (Number.isNaN(timestampSeconds)) {
1259
- throw new ComposioWebhookPayloadError(
1260
- `Invalid webhook timestamp: ${webhookTimestamp}. Expected Unix timestamp in seconds.`
1261
- );
1262
- }
1263
-
1264
- const webhookTimeMs = timestampSeconds * 1000;
1265
- const currentTime = Date.now();
1266
- const timeDifference = Math.abs(currentTime - webhookTimeMs);
1267
-
1268
- if (timeDifference > tolerance * 1000) {
1269
- throw new ComposioWebhookSignatureVerificationError(
1270
- `The webhook timestamp is outside the allowed tolerance. ` +
1271
- `The webhook was sent ${Math.round(timeDifference / 1000)} seconds ago, ` +
1272
- `but the maximum allowed age is ${tolerance} seconds.`
1273
- );
1274
- }
1275
- }
1276
1111
  }
@@ -193,6 +193,8 @@ export class WebhookSubscriptions {
193
193
  *
194
194
  * @example
195
195
  * ```typescript
196
+ * const APP_URL = 'https://your-app.com';
197
+ *
196
198
  * const subscription = await composio.webhooks.subscriptions.set({
197
199
  * webhookUrl: `${APP_URL}/webhooks/composio`,
198
200
  * enabledEvents: ['composio.trigger.message', 'composio.connected_account.expired'],
@@ -1,4 +1,3 @@
1
- import { McpServerGetResponse } from '../types/mcp.types';
2
1
  import { Tool } from '../types/tool.types';
3
2
  import { BaseNonAgenticProvider } from './BaseProvider';
4
3
 
@@ -54,7 +54,7 @@ export class BatchProcessor {
54
54
  });
55
55
 
56
56
  this.pendingBatches.add(pending);
57
- pending.finally(() => {
57
+ void pending.finally(() => {
58
58
  this.pendingBatches.delete(pending);
59
59
  });
60
60
  }
@@ -259,7 +259,7 @@ export class TelemetryTransport {
259
259
  });
260
260
 
261
261
  this.pendingImmediateTelemetry.add(pending);
262
- pending.finally(() => {
262
+ void pending.finally(() => {
263
263
  this.pendingImmediateTelemetry.delete(pending);
264
264
  });
265
265
  }
@@ -624,7 +624,6 @@ const SamlConnectionDataSchema = z.discriminatedUnion('status', [
624
624
  expired_at: z.string().optional(),
625
625
  }).catchall(z.unknown()),
626
626
  ]);
627
- const CustomSamlConnectionDataSchema = BaseSchemeRaw.catchall(z.unknown());
628
627
 
629
628
  // DCR_OAUTH
630
629
  const DcrOauthInitiatingSchema = BaseSchemeRaw.extend({
@@ -364,13 +364,71 @@ export const ConnectedAccountRefreshOptionsSchema = z.object({
364
364
  });
365
365
  export type ConnectedAccountRefreshOptions = z.infer<typeof ConnectedAccountRefreshOptionsSchema>;
366
366
 
367
- // Use the Stainless-generated type as the source of truth for update params.
368
367
  export type { ConnectedAccountUpdateStatusParams as UpdateConnectedAccountParams } from '@composio/client/resources/connected-accounts';
369
368
 
370
369
  export const UpdateConnectedAccountParamsSchema = z.object({
371
370
  enabled: z.boolean(),
372
371
  });
373
372
 
373
+ /**
374
+ * Params for `composio.connectedAccounts.update()`: a new `alias` (an empty
375
+ * string clears it), new credential fields in `connection`, or both. At
376
+ * least one of the two is required.
377
+ *
378
+ * Use `enable()` or `disable()` to change whether the account is active.
379
+ */
380
+ export type PatchConnectedAccountParams = z.infer<typeof PatchConnectedAccountParamsSchema> & {
381
+ enabled?: never;
382
+ };
383
+
384
+ const credentialField = z.string().nullable().optional();
385
+
386
+ export const PatchConnectedAccountParamsSchema = z
387
+ .object({
388
+ alias: z.string().optional(),
389
+ connection: z
390
+ .object({
391
+ state: z
392
+ .object({
393
+ authScheme: z.enum([
394
+ 'BEARER_TOKEN',
395
+ 'API_KEY',
396
+ 'BASIC',
397
+ 'BASIC_WITH_JWT',
398
+ 'GOOGLE_SERVICE_ACCOUNT',
399
+ 'SERVICE_ACCOUNT',
400
+ ]),
401
+ val: z
402
+ .object({
403
+ token: credentialField,
404
+ generic_api_key: credentialField,
405
+ api_key: credentialField,
406
+ bearer_token: credentialField,
407
+ basic_encoded: credentialField,
408
+ generic_token: credentialField,
409
+ api_key_prefix: credentialField,
410
+ generic_secret: credentialField,
411
+ generic_id: credentialField,
412
+ user_agent: credentialField,
413
+ username: credentialField,
414
+ password: credentialField,
415
+ credentials_json: credentialField,
416
+ application_id: credentialField,
417
+ installation_id: credentialField,
418
+ private_key: credentialField,
419
+ })
420
+ .strict(),
421
+ })
422
+ .strict(),
423
+ })
424
+ .strict()
425
+ .optional(),
426
+ })
427
+ .strict()
428
+ .refine(params => params.alias !== undefined || params.connection !== undefined, {
429
+ message: 'At least one of alias or connection must be provided',
430
+ });
431
+
374
432
  /**
375
433
  * Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
376
434
  * shape of the wire's `acl_config_for_shared` block — the SDK adds the
@@ -4,7 +4,6 @@ import {
4
4
  Tool,
5
5
  ToolExecuteParams,
6
6
  ToolExecuteResponse,
7
- ToolkitVersion,
8
7
  ToolListParams,
9
8
  } from './tool.types';
10
9
  import { CustomConnectionData } from './connectedAccountAuthStates.types';