Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@types/node": "^20.17.0",
"@vitest/coverage-v8": "^4.0.17",
"@workos-inc/node": "^10.4.0",
"@workos-inc/node": "^10.6.0",
"oxfmt": "^0.42.0",
"oxlint": "^1.57.0",
"typescript": "^5.9.3",
Expand Down
36 changes: 5 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 0 additions & 82 deletions src/core/client/types.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/core/pkce/generateAuthorizationUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export async function generateAuthorizationUrl(params: {
state: sealedState,
codeChallenge: pkce.codeChallenge,
codeChallengeMethod: pkce.codeChallengeMethod,
// Version-gated passthrough: `maxAge` only exists on the SDK option type
// (and is only serialized) in @workos-inc/node >= 10.6. The conditional
// type on GetAuthorizationUrlOptions ensures callers can only set it when
// their installed peer supports it; forwarded only when provided.
...(options.maxAge !== undefined && { maxAge: options.maxAge }),
});

return {
Expand Down
37 changes: 37 additions & 0 deletions src/core/pkce/pkce.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,40 @@ describe('PKCE payload size guards', () => {
}
});
});

describe('version-gated WorkOS passthrough params', () => {
// Capture the exact options object handed to the SDK's getAuthorizationUrl.
function capturing() {
let captured: Record<string, unknown> | undefined;
const client = {
...mockClient,
userManagement: {
...mockClient.userManagement,
getAuthorizationUrl: (opts: Record<string, unknown>) => {
captured = opts;
return mockClient.userManagement.getAuthorizationUrl(opts);
},
},
};
const run = (options: Parameters<typeof generate>[0] = {}) =>
generateAuthorizationUrl({
client: client as any,
config: config as any,
encryption: sessionEncryption,
options,
});
return { run, opts: () => captured };
}

it('forwards maxAge to getAuthorizationUrl when provided', async () => {
const { run, opts } = capturing();
await run({ maxAge: 60 });
expect(opts()?.maxAge).toBe(60);
});

it('omits maxAge from the SDK call when not provided (no silent default)', async () => {
const { run, opts } = capturing();
await run({});
expect(opts() && 'maxAge' in opts()!).toBe(false);
});
});
Loading
Loading