@devries-cameron20 / composio Mirror · read-only / commits / 0827ec095
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 22:15 UTC

fix(connected-accounts): add REVOKED arm to S2SOauth2ConnectionDataSchema

The top-level ConnectedAccountStatusSchema accepts REVOKED for any auth scheme, but only Oauth2ConnectionDataSchema had a matching arm. For the 12 other unions, a REVOKED payload would fail discriminated-union parsing and `transformConnectedAccountResponse` would silently drop the entire `state` object — refresh tokens / api keys / oauth tokens would vanish without surfacing an error. Today this can't fire (per Apollo, REVOKED is OAuth2-only) but `S2S_OAUTH2` is on the near-term roadmap. Add the REVOKED arm preemptively and an inline invariant comment so the next reviewer doesn't have to re-derive the OAuth2-only scope. Addresses PR #3344 review comment P1#1.

jkomyno committed May 7, 2026 at 10:15 UTC 0827ec09553ffa788791d7f9fddf91355664fd0d
1 file changed +14
ts/packages/core/src/types/connectedAccountAuthStates.types.ts
+14
@@ -149,6 +149,11 @@ export const Oauth2InactiveConnectionDataSchema = Oauth2InitiatingConnectionData
149 // (`apps/apollo/src/lib/connected_accounts/schemes/connectionDataScheme.ts`):
150 // shape matches the INITIATING schema with a status literal, plus an
151 // optional `revoked_at` timestamp.
152 +//
153 +// Invariant (2026-05, Apollo PR #9550): REVOKED is emitted only for OAUTH2
154 +// today. S2S_OAUTH2 revocation is on Apollo's near-term roadmap — a matching
155 +// REVOKED arm exists in `S2SOauth2ConnectionDataSchema` below for when that
156 +// lands. Other auth schemes (api_key, basic, etc.) are not in scope.
157 export const Oauth2RevokedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
158 status: z.literal(ConnectionStatuses.REVOKED),
159 revoked_at: z.string().optional(),
@@ -179,6 +184,11 @@ export type Oauth2ConnectionData = z.infer<typeof Oauth2ConnectionDataSchema>;
184 export type CustomOauth2ConnectionData = z.infer<typeof CustomOauth2ConnectionDataSchema>;
185
186 // S2S_OAUTH2
187 +// Invariant: REVOKED is OAuth2-only as of Apollo PR #9550 (2026-05). S2S_OAUTH2
188 +// revocation is on Apollo's near-term roadmap; the REVOKED arm below is added
189 +// preemptively so that when the server starts emitting it, the per-scheme
190 +// schema accepts it instead of `transformConnectedAccountResponse` silently
191 +// dropping the entire `state` payload (refresh tokens, etc.).
192 const S2SOauth2BaseSchema = BaseSchemeRaw.extend({
193 status: z.literal(ConnectionStatuses.INITIALIZING),
194 }).catchall(z.unknown());
@@ -214,6 +224,10 @@ const S2SOauth2ConnectionDataSchema = z.discriminatedUnion('status', [
224 status: z.literal(ConnectionStatuses.EXPIRED),
225 expired_at: z.string().optional(),
226 }).catchall(z.unknown()),
227 + S2SOauth2BaseSchema.extend({
228 + status: z.literal(ConnectionStatuses.REVOKED),
229 + revoked_at: z.string().optional(),
230 + }).catchall(z.unknown()),
231 ]);
232 const CustomS2SOauth2ConnectionDataSchema = BaseSchemeRaw.extend({
233 access_token: z.string().optional(),