Skip to content

Add remaining optional authorization request parameters - #62

Open
scweber-cisco wants to merge 1 commit into
duosecurity:mainfrom
scweber-cisco:add-authorize-request-params
Open

scweber-cisco wants to merge 1 commit into
duosecurity:mainfrom
scweber-cisco:add-authorize-request-params

Conversation

@scweber-cisco

@scweber-cisco scweber-cisco commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The OIDC Auth API documents five optional parameters for the authorization request JWT that createAuthUrl had no way to send. This adds them to AuthUrlOptions, alongside the nonce option added in #60.

Option Type Validation
dest_app_name string none documented
dest_app_id string none documented
display_username string none documented
max_age number non-negative integer, else DuoException
prompt 'login' literal type, no runtime check

Each option follows the same omit-when-undefined pattern as nonce, so the request payload is byte-for-byte unchanged for callers who don't use them.

const authUrl = await client.createAuthUrl('username', state, {
  dest_app_name: 'Production Console',
  dest_app_id: 'console-prod',
  display_username: 'Sam Weber',
  max_age: 300,
  prompt: 'login',
});

Notes on two judgment calls

max_age: 0 is tested explicitly. Zero is the documented way to force interactive authentication, and it's falsy — a if (max_age) guard would silently drop it. The validation is !Number.isInteger(max_age) || max_age < 0.

prompt is typed as the literal 'login' rather than string. That is the only value Duo currently supports, so the type documents the real contract; it will need widening if Duo adds others. No runtime check was added, so a plain-JS caller passing something else still reaches Duo rather than being gated by the SDK.

Test plan

  • 9 new tests in test/client/auth-url.test.ts, written test-first: one per option asserting the claim lands in the verified request JWT, max_age: 0, negative and non-integer max_age rejection, and one test asserting all five claims are absent when no options are passed.
  • Full suite: 67 passing, up from 58.
  • Separately typechecked a scratch consumer project against the built .d.ts to confirm the new options are visible to package consumers and that prompt: 'consent', max_age: '300' and a misspelled key are all rejected.

🤖 Generated with Claude Code

The OIDC Auth API documents five optional parameters for the authorization
request JWT that createAuthUrl had no way to send: dest_app_name, dest_app_id,
display_username, max_age and prompt. Add them to AuthUrlOptions alongside
nonce, following the same omit-when-undefined pattern so the request payload is
unchanged for callers who don't use them.

max_age is validated as a non-negative integer, since 0 is meaningful (it
forces interactive authentication) and would be dropped by a truthiness check.
prompt is typed as the literal 'login', which is the only value Duo currently
supports.

https://duo.com/docs/oauthapi

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@e9fff97). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##             main       #62   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         5           
  Lines           ?       163           
  Branches        ?        43           
========================================
  Hits            ?       163           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@scweber-cisco
scweber-cisco marked this pull request as ready for review September 22, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants