From 515b0b3a794120df428309509cd593967e32e536 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 3 Nov 2026 15:54:24 +0000 Subject: [PATCH] feat(pipes): Return state from authorizeDataIntegration Regenerated from the spec's new required DataIntegrationAuthorizeUrlResponse.state field. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../fixtures/data-integration-authorize-url-response.json | 1 + .../data-integration-authorize-url-response.interface.ts | 3 +++ src/pipes/pipes.spec.ts | 1 + src/pipes/serializers.spec.ts | 6 +++++- .../data-integration-authorize-url-response.serializer.ts | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pipes/fixtures/data-integration-authorize-url-response.json b/src/pipes/fixtures/data-integration-authorize-url-response.json index 5b80b9c0b..ad473b9b2 100644 --- a/src/pipes/fixtures/data-integration-authorize-url-response.json +++ b/src/pipes/fixtures/data-integration-authorize-url-response.json @@ -1,4 +1,5 @@ { "url": "https://api.workos.com/data-integrations/q2czJKmVAraSBg8xFpT7M9uR/authorize-redirect", + "state": "01K8ZQ6Y3J4N5P7R9T2V4W6X8Z", "completion": "finish_required" } diff --git a/src/pipes/interfaces/data-integration-authorize-url-response.interface.ts b/src/pipes/interfaces/data-integration-authorize-url-response.interface.ts index 2e5a620d3..fad2c2495 100644 --- a/src/pipes/interfaces/data-integration-authorize-url-response.interface.ts +++ b/src/pipes/interfaces/data-integration-authorize-url-response.interface.ts @@ -3,11 +3,14 @@ export interface DataIntegrationAuthorizeUrlResponse { /** The OAuth authorization URL to redirect the user to. */ url: string; + /** Identifies this authorization. WorkOS adds it to `return_to` alongside `connect_code` or `error`. Store it in the user's session with the `code_verifier` and compare it when the user returns. */ + state?: string; /** `finish_required` when the request included `code_challenge`: the connection will be held until your app finishes it. Omitted otherwise. If you sent `code_challenge` and this is missing, don't redirect the user. */ completion?: 'finish_required'; } export interface DataIntegrationAuthorizeUrlResponseWire { url: string; + state?: string; completion?: 'finish_required'; } diff --git a/src/pipes/pipes.spec.ts b/src/pipes/pipes.spec.ts index 47e638c31..ad69148b7 100644 --- a/src/pipes/pipes.spec.ts +++ b/src/pipes/pipes.spec.ts @@ -237,6 +237,7 @@ describe('Pipes', () => { expect(result.url).toBe( 'https://api.workos.com/data-integrations/q2czJKmVAraSBg8xFpT7M9uR/authorize-redirect', ); + expect(result.state).toBe('01K8ZQ6Y3J4N5P7R9T2V4W6X8Z'); }); it('sends the code challenge and returns the completion mode', async () => { diff --git a/src/pipes/serializers.spec.ts b/src/pipes/serializers.spec.ts index eb76dcd69..929a88a71 100644 --- a/src/pipes/serializers.spec.ts +++ b/src/pipes/serializers.spec.ts @@ -131,7 +131,11 @@ describe('DataIntegrationAuthorizeUrlResponseSerializer', () => { dataIntegrationAuthorizeUrlResponseFixture as DataIntegrationAuthorizeUrlResponseWire; const deserialized = deserializeDataIntegrationAuthorizeUrlResponse(fixture); - expect(deserialized).toBeDefined(); + expect(deserialized).toEqual({ + url: fixture.url, + state: fixture.state, + completion: fixture.completion, + }); }); }); diff --git a/src/pipes/serializers/data-integration-authorize-url-response.serializer.ts b/src/pipes/serializers/data-integration-authorize-url-response.serializer.ts index dd641838e..c4aa22595 100644 --- a/src/pipes/serializers/data-integration-authorize-url-response.serializer.ts +++ b/src/pipes/serializers/data-integration-authorize-url-response.serializer.ts @@ -9,5 +9,6 @@ export const deserializeDataIntegrationAuthorizeUrlResponse = ( response: DataIntegrationAuthorizeUrlResponseWire, ): DataIntegrationAuthorizeUrlResponse => ({ url: response.url, + state: response.state ?? '', completion: response.completion, });