fix(token): align Token model with x_refresh_token_hard_expires_in response field#207
Open
noneal220 wants to merge 1 commit intointuit:masterfrom
Open
fix(token): align Token model with x_refresh_token_hard_expires_in response field#207noneal220 wants to merge 1 commit intointuit:masterfrom
noneal220 wants to merge 1 commit intointuit:masterfrom
Conversation
…sponse field The 4.2.4 release added the x-include-refresh-token-hard-expires-in header on createToken(), refresh(), and refreshUsingToken(), but the Token model stored the response field under x_refresh_token_lifetime_expires_in, which does not match the key the Intuit OAuth2 platform returns (x_refresh_token_hard_expires_in). Once the platform team enables the feature, the current code would silently drop the value. Changes: - Rename Token field from x_refresh_token_lifetime_expires_in to x_refresh_token_hard_expires_in in constructor, getToken, setToken, and clearToken. - Add x_refresh_token_hard_expires_in to TokenData and Token type definitions. - Update CHANGELOG 4.2.4 entry to reference the correct field name. - Add test/HardExpiresTest.js to verify the outbound header is sent on all three token endpoints and that x_refresh_token_hard_expires_in from the response body is parsed into the Token (defaults to 0 when absent).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The 4.2.4 release (PR #206) added the
x-include-refresh-token-hard-expires-in: truerequest header tocreateToken(),refresh(), andrefreshUsingToken(), but theTokenmodel stored the response field underx_refresh_token_lifetime_expires_in, which does not match the key the Intuit OAuth2 platform will actually return:x_refresh_token_hard_expires_in.Once the platform team enables the feature server-side, the existing code would silently drop the value. This PR aligns the client with the real response shape.
Expected platform response (confirmed sample)
{ "access_token": "eyJhbGciOiJkaXIi...", "token_type": "bearer", "expires_in": 3600, "refresh_token": "RT1-39-H3-1785429816rcysb9dns1ofreknypnm", "x_refresh_token_expires_in": 8726400, "x_refresh_token_hard_expires_in": 156032154 }Changes
src/access-token/Token.js— rename field tox_refresh_token_hard_expires_inin constructor,getToken(),setToken(), andclearToken().types/index.d.ts— addx_refresh_token_hard_expires_into bothTokenDataand theTokenclass declarations.CHANGELOG.md— correct the 4.2.4 entry to reference the right field name.test/HardExpiresTest.js(new) — 4 tests verifying:x-include-refresh-token-hard-expires-in: trueis sent oncreateToken().refresh().refreshUsingToken().x_refresh_token_hard_expires_inin the response body is parsed intotoken.x_refresh_token_hard_expires_in, and defaults to0when absent (back-compat for the pre-rollout state).Test results
No lint errors (
npx eslint test/HardExpiresTest.js src/access-token/Token.js).Backward compatibility
0— identical behavior to today.token.x_refresh_token_lifetime_expires_in, which was added in 4.2.4 and is unreleased field-wise (platform hasn't been returning it yet).Related