-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enhancements #6
Enhancements #6
Conversation
Warning Rate limit exceeded@DanielRivers has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 6 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes introduce several enhancements across multiple files. A new asynchronous function, Changes
Possibly related PRs
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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 (5)
lib/utils/generateRandomString.ts (1)
20-30
: LGTM, but consider adding a comment.The
generateRandomStringNonCrypto
function is a useful addition for generating random strings in environments where thecrypto
API is not available.To improve the code clarity, consider adding a comment to clarify that the function is not suitable for cryptographic purposes:
+/** + * Generates a random string using a non-cryptographic method. + * Note: This function is not suitable for cryptographic purposes. + * @param {number} length + * @returns {string} random string + */ function generateRandomStringNonCrypto(length: number = 28) { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; const charactersLength = characters.length; for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; }lib/sessionManager/stores/expoSecureStore.ts (4)
7-14
: LGTM! Consider making the retry limit and delay configurable.The
waitForExpoSecureStore
function is correctly implemented and serves its purpose of ensuring thatexpoSecureStore
is initialized before executing related methods.The retry limit of 20 and the delay of 100 milliseconds are reasonable values for most use cases.
Consider making the retry limit and delay configurable by accepting them as optional parameters with default values:
async function waitForExpoSecureStore(maxRetries = 20, retryDelay = 100) { let tries = 0; while (!expoSecureStore && tries < maxRetries) { console.log('waiting'); await new Promise((resolve) => setTimeout(resolve, retryDelay)); tries++; } }
54-54
: LGTM! Consider handling the case whereexpoSecureStore
is not initialized.The
setSessionItem
method is correctly updated to ensure thatexpoSecureStore
is initialized before executing its core logic.Consider handling the case where
expoSecureStore
is not initialized even after the maximum number of retries:async setSessionItem( itemKey: V | StorageKeys, itemValue: unknown, ): Promise<void> { await waitForExpoSecureStore(); if (!expoSecureStore) { throw new Error("ExpoSecureStore is not initialized"); } // rest of the method }
Line range hint
79-97
: LGTM! Consider handling the case whereexpoSecureStore
is not initialized.The
getSessionItem
method is correctly updated to ensure thatexpoSecureStore
is initialized before executing its core logic.The change to return
null
if the joined string is empty is a good improvement for consistency.Consider handling the case where
expoSecureStore
is not initialized even after the maximum number of retries:async getSessionItem(itemKey: V | StorageKeys): Promise<unknown | null> { await waitForExpoSecureStore(); if (!expoSecureStore) { throw new Error("ExpoSecureStore is not initialized"); } // rest of the method }
106-107
: LGTM! Consider handling the case whereexpoSecureStore
is not initialized.The
removeSessionItem
method is correctly updated to ensure thatexpoSecureStore
is initialized before executing its core logic.Consider handling the case where
expoSecureStore
is not initialized even after the maximum number of retries:async removeSessionItem(itemKey: V | StorageKeys): Promise<void> { await waitForExpoSecureStore(); if (!expoSecureStore) { throw new Error("ExpoSecureStore is not initialized"); } // rest of the method }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- lib/sessionManager/stores/expoSecureStore.ts (5 hunks)
- lib/types.ts (2 hunks)
- lib/utils/generateAuthUrl.ts (1 hunks)
- lib/utils/generateRandomString.ts (1 hunks)
Additional comments not posted (4)
lib/utils/generateRandomString.ts (1)
7-13
: LGTM!The changes to the
generateRandomString
function are approved. The introduction of a fallback mechanism using thegenerateRandomStringNonCrypto
function enhances the function's robustness and usability across different environments.lib/utils/generateAuthUrl.ts (2)
25-27
: LGTM!The changes to conditionally handle the
state
parameter are approved. This allows the user to provide their ownstate
value while maintaining the fallback to a securely generated random string.
30-33
: LGTM!The changes to conditionally handle the
nonce
parameter are approved. This allows the user to provide their ownnonce
value while maintaining the fallback to a securely generated random string. Including thenonce
in thesearchParams
object is also correct.lib/types.ts (1)
108-111
: LGTM!The addition of the optional
nonce
property to theLoginOptions
type is a valuable security enhancement. The accompanying comment clearly explains its purpose as a single-use code to prevent replay attacks.The code changes are approved.
bdf06f4
to
3eb0cec
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
==========================================
- Coverage 62.17% 59.30% -2.88%
==========================================
Files 15 15
Lines 312 344 +32
Branches 36 37 +1
==========================================
+ Hits 194 204 +10
- Misses 118 140 +22
|
Explain your changes
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.