51
/**
52
* Per-user access control for a SHARED connected account. Inert for PRIVATE.
53
*
54
+ * On the wire this lives under `acl_config_for_shared` — a single JSONB
55
+ * column on `connected_accounts`. The SDK exposes the inner shape as
56
+ * `aclConfigForShared` on inputs and responses (omit the block to mean
57
+ * "don't touch ACL" on create / PATCH; absence on a response means the
58
+ * caller isn't allowed to see the ACL).
59
+ *
60
* Resolution rule (deny wins):
61
* 1. requesting userId in `notAllowedUserIds` → DENY
62
* 2. `allowAllUsers === true` → ALLOW
63
* 3. requesting userId in `allowedUserIds` → ALLOW
64
* 4. otherwise → DENY (deny-by-default)
65
*
60
- * Default state (`allowAllUsers=false`, both arrays empty) means only the
61
- * connection's creator can use it. The creator must grant access explicitly.
66
+ * Default state (block omitted or `{}`) means only the connection's creator
67
+ * can use it. The creator must grant access explicitly.
68
*
63
- * Lists are capped at 1000 entries each by the backend.
69
+ * Backend caps: each list ≤1000 entries; each user_id 1..256 chars.
70
*/
65
-const ACL_LIST_LIMIT = 1000;
66
-export const ConnectedAccountAclSchema = z.object({
71
+const ACL_LIST_MAX_LENGTH = 1000;
72
+const ACL_USER_ID_MAX_LENGTH = 256;
73
+const aclUserIdString = z.string().min(1).max(ACL_USER_ID_MAX_LENGTH);
74
+
75
+export const ConnectedAccountAclConfigSchema = z.object({
76
allowAllUsers: z
77
.boolean()
78
.optional()
79
.describe('Wildcard "any user_id in the project" allow toggle. Default false.'),
80
allowedUserIds: z
72
- .array(z.string())
73
- .max(ACL_LIST_LIMIT)
81
+ .array(aclUserIdString)
82
+ .max(ACL_LIST_MAX_LENGTH)
83
.optional()
84
.describe('Explicit allow list (developer-assigned user_id strings). Default [].'),
85
notAllowedUserIds: z
77
- .array(z.string())
78
- .max(ACL_LIST_LIMIT)
86
+ .array(aclUserIdString)
87
+ .max(ACL_LIST_MAX_LENGTH)
88
.optional()
89
.describe('Explicit deny list. Wins over allow on conflict. Default [].'),
90
});
82
-export type ConnectedAccountAcl = z.infer<typeof ConnectedAccountAclSchema>;
91
+export type ConnectedAccountAclConfig = z.infer<typeof ConnectedAccountAclConfigSchema>;
92
+
93
+/**
94
+ * Resolved ACL as it appears on responses (creator / API-key callers).
95
+ * All three fields are populated when the block is visible; the block
96
+ * itself is absent for non-creator cookie callers.
97
+ */
98
+export const ConnectedAccountAclConfigResponseSchema = z.object({
99
+ allowAllUsers: z.boolean(),
100
+ allowedUserIds: z.array(z.string()),
101
+ notAllowedUserIds: z.array(z.string()),
102
+});
103
+export type ConnectedAccountAclConfigResponse = z.infer<
104
+ typeof ConnectedAccountAclConfigResponseSchema
105
+>;
106
107
export const CreateConnectedAccountParamsSchema = z.object({
108
authConfig: z.object({
186
createdAt: string;
187
updatedAt: string;
188
accountType?: ConnectedAccountType;
166
- allowAllUsers?: boolean;
167
- allowedUserIds?: string[];
168
- notAllowedUserIds?: string[];
189
+ aclConfigForShared?: ConnectedAccountAclConfigResponse;
190
}> = z.object({
191
id: z.string(),
192
authConfig: ConnectedAccountAuthConfigSchema,
211
createdAt: z.string(),
212
updatedAt: z.string(),
213
accountType: ConnectedAccountTypeSchema.optional(),
193
- // ACL fields are only present on responses when the caller is the creator
194
- // or is using a project/org API key — cookie callers who can use the
195
- // connection but aren't its creator see the row without these fields.
196
- allowAllUsers: z.boolean().optional(),
197
- allowedUserIds: z.array(z.string()).optional(),
198
- notAllowedUserIds: z.array(z.string()).optional(),
214
+ // `acl_config_for_shared` is only present on responses when the caller is
215
+ // the connection's creator or is using a project/org API key. Non-creator
216
+ // cookie callers see the row without this block — left as `undefined`
217
+ // here so callers can distinguish "I can't see the ACL" from "ACL is the
218
+ // default deny-by-default state".
219
+ aclConfigForShared: ConnectedAccountAclConfigResponseSchema.optional(),
220
});
221
222
export type ConnectedAccountRetrieveResponse = z.infer<
300
*/
301
accountType: ConnectedAccountTypeSchema.optional(),
302
/**
282
- * ACL for SHARED connections. Ignored when `accountType !== 'SHARED'`; the
283
- * backend rejects ACL fields on a `PRIVATE` connection with `AclOnlyForShared`.
303
+ * Per-user ACL for SHARED connections. Only valid when
304
+ * `accountType === 'SHARED'` — the backend rejects ACL on a PRIVATE
305
+ * connection with `ComposioAclOnlyForSharedError` (400).
306
*
285
- * Default (deny-by-default): only the creator can use the connection. Grant
286
- * access by setting `allowAllUsers: true` or by listing user IDs in
287
- * `allowedUserIds`. `notAllowedUserIds` always wins over allow.
307
+ * Omit the block (or pass `{}`) to keep the deny-by-default state: only the
308
+ * creator can use the connection. Grant access by setting
309
+ * `allowAllUsers: true` or listing user IDs in `allowedUserIds`.
310
+ * `notAllowedUserIds` always wins over allow.
311
*/
289
- allowAllUsers: ConnectedAccountAclSchema.shape.allowAllUsers,
290
- allowedUserIds: ConnectedAccountAclSchema.shape.allowedUserIds,
291
- notAllowedUserIds: ConnectedAccountAclSchema.shape.notAllowedUserIds,
312
+ aclConfigForShared: ConnectedAccountAclConfigSchema.optional(),
313
});
314
export type CreateConnectedAccountLinkOptions = z.infer<
315
typeof CreateConnectedAccountLinkOptionsSchema
336
});
337
338
/**
318
- * Params for `composio.connectedAccounts.updateAcl()`.
339
+ * Params for `composio.connectedAccounts.updateAcl()`. Mirrors the inner
340
+ * shape of the wire's `acl_config_for_shared` block — the SDK adds the
341
+ * outer nesting at the boundary, so callers pass the three fields flat.
342
*
320
- * PATCH-style semantics — omit a field to leave it unchanged; pass an empty
321
- * array to clear an allow/deny list. Backend rejects ACL writes on a
322
- * `PRIVATE` connection with `AclOnlyForShared` (400).
343
+ * PATCH-style semantics — omit a field to leave it unchanged; pass an
344
+ * empty array to clear an allow/deny list. Backend rejects ACL writes on
345
+ * a PRIVATE connection with `ComposioAclOnlyForSharedError` (400).
346
*
347
* Each field is optional, but at least one must be provided — passing an
348
* empty object is rejected as a no-op.
349
*/
327
-export const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclSchema.refine(
350
+export const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclConfigSchema.refine(
351
acl =>
352
acl.allowAllUsers !== undefined ||
353
acl.allowedUserIds !== undefined ||