diff --git a/.changeset/application-response-older-api.md b/.changeset/application-response-older-api.md new file mode 100644 index 0000000..cbb9ce8 --- /dev/null +++ b/.changeset/application-response-older-api.md @@ -0,0 +1,5 @@ +--- +'@seamless-auth/types': patch +--- + +`OidcApplicationSchema` reads a missing `sessionExchangeEnabled` as `false`. 0.36.0 made the field required, so a client on 0.36.0 refused the application list from any API older than v0.23, which does not send it. diff --git a/src/schemas/oidcApplication/schema.test.ts b/src/schemas/oidcApplication/schema.test.ts index 3532493..101671d 100644 --- a/src/schemas/oidcApplication/schema.test.ts +++ b/src/schemas/oidcApplication/schema.test.ts @@ -1,6 +1,7 @@ import { describe, it, expect } from 'vitest'; import { OidcApplicationCreateRequestSchema, + OidcApplicationSchema, OidcApplicationKeysRequestSchema, OidcApplicationResourcesRequestSchema, OidcApplicationUpdateRequestSchema, @@ -358,6 +359,12 @@ describe('HostedUiSchema', () => { }); describe('sessionExchangeEnabled', () => { + it('reads as off from an API older than the session exchange', () => { + const field = OidcApplicationSchema.shape.sessionExchangeEnabled; + expect(field.parse(undefined)).toBe(false); + expect(field.parse(true)).toBe(true); + }); + const nativeClient = { name: 'CLI', clientType: 'public', diff --git a/src/schemas/oidcApplication/schema.ts b/src/schemas/oidcApplication/schema.ts index bef30b3..51fdecb 100644 --- a/src/schemas/oidcApplication/schema.ts +++ b/src/schemas/oidcApplication/schema.ts @@ -347,7 +347,8 @@ export const OidcApplicationSchema = z.object({ grantTypes: z.array(OidcApplicationGrantTypeSchema), deviceFlowEnabled: z.boolean(), noticesEnabled: z.boolean(), - sessionExchangeEnabled: z.boolean(), + /** Absent from an API older than v0.23, which has no session exchange. */ + sessionExchangeEnabled: z.boolean().default(false), pkceRequired: z.boolean(), nonceRequired: z.boolean(), jwks: OidcApplicationJwksSchema.nullable(),