-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to getToken always force refresh #66
Conversation
WalkthroughThe recent updates introduce a new Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant Client
participant KindeClient
participant AuthServer
Client->>KindeClient: getToken(options: GetTokenOptions)
alt isForceRefresh is true
KindeClient->>AuthServer: Request new token
AuthServer-->>KindeClient: Return new token
else isForceRefresh is false or undefined
KindeClient->>KindeClient: Retrieve cached token
end
KindeClient-->>Client: Return token
sequenceDiagram
participant Client
participant KindeClient
participant AuthServer
Client->>KindeClient: getIdToken(options: GetTokenOptions)
alt isForceRefresh is true
KindeClient->>AuthServer: Request new ID token
AuthServer-->>KindeClient: Return new ID token
else isForceRefresh is false or undefined
KindeClient->>KindeClient: Retrieve cached ID token
end
KindeClient-->>Client: Return ID token
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/createKindeClient.ts (1)
Line range hint
369-374
: Optimize array iteration method.The use of
forEach
for iterating over arrays can be less efficient than other methods likefor...of
, especially with large arrays or when combined with other array operations. Consider refactoring to usefor...of
for better performance.- audience.trim().split(/\s+/).forEach((aud) => { - urlSearchParams.append('audience', aud); - }); + for (const aud of audience.trim().split(/\s+/)) { + urlSearchParams.append('audience', aud); + }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/createKindeClient.ts (3 hunks)
- src/types.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- src/types.ts
Additional context used
Biome
src/createKindeClient.ts
[error] 369-374: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
Additional comments not posted (2)
src/createKindeClient.ts (2)
199-202
: Ensure correct handling ofisForceRefresh
option ingetTokenType
.The implementation of the
isForceRefresh
option in thegetTokenType
function correctly forces a token refresh when the option is set. This aligns with the PR's objective to allow forced token refreshes.Also applies to: 205-205
221-221
: Validate the integration ofGetTokenOptions
ingetToken
andgetIdToken
.The integration of the
GetTokenOptions
parameter in thegetToken
andgetIdToken
functions is correctly implemented. This allows these functions to utilize the newforceRefresh
functionality.Also applies to: 225-225
Explain your changes
The forceRefresh option will always call the Kinde token endpoint to get the latest version of the tokens
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.