-
Notifications
You must be signed in to change notification settings - Fork 2
feat(web): add-siwe-authentication-for-file-uploads-and-notification-… #34
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
feat(web): add-siwe-authentication-for-file-uploads-and-notification-… #34
Conversation
✅ Deploy Preview for curate-v2 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Important Review skippedAuto reviews are limited to the following labels: dependencies. Please add one of these labels to enable auto reviews. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce significant enhancements to the web application, including new authentication features, database integration, and improved user interface components. Key additions involve implementing authentication middleware, handling user settings, and integrating with Netlify for deployment. Several React components and hooks were updated to ensure authenticated access and better state management. Additionally, new scripts and configurations were added to streamline the build and deployment processes. Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant Browser
participant Netlify
participant Function
participant Database
User->>Browser: Request access
Browser->>Netlify: Send request with JWT
Netlify->>Function: Call authMiddleware
Function->>Database: Verify JWT token
Database-->>Function: Return user details
Function-->>Netlify: Return response
Netlify-->>Browser: Send response
Browser-->>User: Display content
Poem
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 (
|
|
@coderabbitai full review |
Actions performedFull review triggered. |
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: 16
Outside diff range and nitpick comments (8)
web/src/types/supabase-notification.ts (3)
60-77: Thehermes-tg-counterstable is well-defined. Consider adding a unique index onbot_nameif it is expected to be unique to improve query performance.
141-155: Thetg-juror-subscriptionstable is straightforward. Ensure thatjuror_addressandtg_user_idare indexed for faster lookups.
186-206: Theuser-settingstable structure is appropriate for storing user preferences. Consider implementing caching strategies for frequently accessed settings to enhance performance.web/src/types/supabase-datalake.ts (5)
51-65: Thederived-accountstable is straightforward. Ensure thataccountandderivedare indexed for faster lookups.
90-128: Thehistoricaltable is well-structured for logging historical data. Consider implementing data retention policies to manage the growth of this table effectively.
177-203: Thepoh-vouchdbtable is correctly defined for handling Proof of Humanity vouches. Ensure thatchainId,claimer,pohId, andvoucherare indexed for efficient querying.
204-221: Thepohv2-eventstable is well-defined for event logging. Consider adding error handling strategies for transaction logging to ensure data integrity.
244-257: Thesce-heightstable is straightforward and well-defined. Ensure thatheightandnetworkare indexed for efficient queries.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
yarn.lockis excluded by!**/*.lock
Files selected for processing (26)
- web/.gitignore (1 hunks)
- web/netlify.toml (1 hunks)
- web/netlify/functions/authUser.ts (1 hunks)
- web/netlify/functions/fetch-settings.ts (1 hunks)
- web/netlify/functions/getNonce.ts (1 hunks)
- web/netlify/functions/update-settings.ts (1 hunks)
- web/netlify/functions/uploadToIPFS.ts (4 hunks)
- web/netlify/middleware/authMiddleware.ts (1 hunks)
- web/package.json (4 hunks)
- web/scripts/generateBuildInfo.sh (1 hunks)
- web/scripts/runEnv.sh (1 hunks)
- web/src/components/ActionButton/Modal/ChallengeItemModal.tsx (2 hunks)
- web/src/components/ActionButton/Modal/RemoveModal.tsx (2 hunks)
- web/src/components/EnsureAuth.tsx (1 hunks)
- web/src/hooks/queries/useUserSettings.tsx (1 hunks)
- web/src/hooks/useSessionStorage.ts (1 hunks)
- web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/FormContact.tsx (3 hunks)
- web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx (4 hunks)
- web/src/layout/Header/navbar/Menu/Settings/Notifications/index.tsx (2 hunks)
- web/src/pages/SubmitItem/index.tsx (3 hunks)
- web/src/pages/SubmitList/index.tsx (3 hunks)
- web/src/types/supabase-datalake.ts (1 hunks)
- web/src/types/supabase-notification.ts (1 hunks)
- web/src/utils/authoriseUser.ts (1 hunks)
- web/src/utils/uploadFileToIPFS.ts (2 hunks)
- web/src/utils/uploadSettingsToSupabase.ts (1 hunks)
Additional context used
Shellcheck
web/scripts/generateBuildInfo.sh
[info] 6-6: Double quote to prevent globbing and word splitting.
web/scripts/runEnv.sh
[warning] 7-7: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
[info] 10-10: Double quote to prevent globbing and word splitting.
[error] 15-15: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).
[warning] 15-15: Remove quotes from right-hand side of =~ to match as a regex rather than literally.
[error] 16-16: Argument mixes string and array. Use * or separate argument.
[warning] 22-22: ShellCheck can't follow non-constant source. Use a directive to specify location.
[info] 22-22: Double quote to prevent globbing and word splitting.
[warning] 23-23: ShellCheck can't follow non-constant source. Use a directive to specify location.
[info] 23-23: Double quote to prevent globbing and word splitting.
[info] 25-25: Double quote to prevent globbing and word splitting.
Biome
web/src/hooks/queries/useUserSettings.tsx
[error] 10-10: Do not use template literals if interpolation and special-character handling are not needed.
[error] 16-16: Do not use template literals if interpolation and special-character handling are not needed.
[error] 12-12: Use Number.Infinity instead of the equivalent global.
web/netlify/functions/fetch-settings.ts
[error] 12-12: Forbidden non-null assertion.
[error] 12-12: Forbidden non-null assertion.
[error] 21-21: Do not use template literals if interpolation and special-character handling are not needed.
[error] 3-4: All these imports are only used as types.
web/netlify/middleware/authMiddleware.ts
[error] 12-12: Do not use template literals if interpolation and special-character handling are not needed.
web/src/layout/Header/navbar/Menu/Settings/Notifications/index.tsx
[error] 1-1: All these imports are only used as types.
[error] 2-3: All these imports are only used as types.
web/netlify/functions/getNonce.ts
[error] 28-28: Forbidden non-null assertion.
[error] 28-28: Forbidden non-null assertion.
[error] 6-7: All these imports are only used as types.
web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/FormContact.tsx
[error] 1-1: The default import and some named imports are only used as types.
[error] 49-49: This hook does not specify all of its dependencies: isEditing
web/src/utils/authoriseUser.ts
[error] 12-12: Do not use template literals if interpolation and special-character handling are not needed.
[error] 26-26: Do not use template literals if interpolation and special-character handling are not needed.
web/src/pages/SubmitItem/index.tsx
[error] 49-49: Unsafe usage of optional chaining.
[error] 55-55: Change to an optional chain.
[error] 1-1: The default import is only used as a type.
web/src/components/EnsureAuth.tsx
[error] 57-57: The computed expression can be simplified without the use of a string literal.
[error] 1-1: The default import is only used as a type.
web/netlify/functions/uploadToIPFS.ts
[error] 97-97: Unexpected any. Specify a different type.
[error] 1-2: Some named imports are only used as types.
web/netlify/functions/update-settings.ts
[error] 15-15: Unexpected any. Specify a different type.
[error] 67-67: Forbidden non-null assertion.
[error] 67-67: Forbidden non-null assertion.
[error] 5-6: All these imports are only used as types.
web/src/pages/SubmitList/index.tsx
[error] 1-1: All these imports are only used as types.
web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx
[error] 1-1: The default import is only used as a type.
[error] 10-11: All these imports are only used as types.
[error] 52-52: This hook does not specify all of its dependencies: refetchUserSettings
[error] 52-52: This hook specifies more dependencies than necessary: address
web/netlify/functions/authUser.ts
[error] 50-50: Do not use template literals if interpolation and special-character handling are not needed.
[error] 55-55: Do not use template literals if interpolation and special-character handling are not needed.
[error] 63-63: Forbidden non-null assertion.
[error] 63-63: Forbidden non-null assertion.
[error] 10-11: All these imports are only used as types.
web/src/components/ActionButton/Modal/RemoveModal.tsx
[error] 28-31: Template literals are preferred over string concatenation.
[error] 31-31: Do not use template literals if interpolation and special-character handling are not needed.
[error] 109-109: The computed expression can be simplified without the use of a string literal.
[error] 1-1: The default import is only used as a type.
[error] 6-7: All these imports are only used as types.
[error] 15-16: Some named imports are only used as types.
[error] 63-63: This hook specifies more dependencies than necessary: isLoadingExtradata
web/src/components/ActionButton/Modal/ChallengeItemModal.tsx
[error] 26-26: This enum declaration contains members that are implicitly initialized.
[error] 133-133: The computed expression can be simplified without the use of a string literal.
[error] 1-1: The default import is only used as a type.
[error] 15-16: All these imports are only used as types.
[error] 16-17: Some named imports are only used as types.
[error] 75-75: This hook does not specify all of its dependencies: challengeType
[error] 85-85: This hook does not specify all of its dependencies: isLoadingExtradata
Additional comments not posted (29)
web/netlify.toml (1)
1-14: Configuration settings innetlify.tomllook good and align with the PR objectives.web/.gitignore (1)
33-33: The addition ofgeneratedNetlifyInfo.jsonto.gitignoreis appropriate to avoid tracking generated files in version control.web/src/hooks/useSessionStorage.ts (1)
1-22: The implementation ofuseSessionStoragehook looks good and follows best practices for managing session storage in React.web/src/utils/uploadFileToIPFS.ts (1)
Line range hint
5-18: The implementation ofuploadFileToIPFSfunction looks good and correctly handles authentication tokens for secure file uploads.web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/FormContact.tsx (1)
27-27: Add optionalisEditingprop toIForminterface.This addition allows conditional validation and UI changes based on whether the form is in editing mode.
web/src/pages/SubmitItem/index.tsx (2)
36-38: Define a styled version ofEnsureAuth.This styled component centralizes the authentication logic while allowing for specific styling, which enhances modularity and maintainability.
70-80: Wrap sensitive routes inEnsureAuthto secure them.This change ensures that only authenticated users can access certain routes, enhancing the security of the application.
web/src/components/EnsureAuth.tsx (1)
74-94: ImplementcreateSiweMessageto generate SIWE messages.This function is crucial for generating standardized messages for Ethereum-based authentication, aligning with best practices for decentralized applications.
web/netlify/functions/uploadToIPFS.ts (1)
Line range hint
69-104: RefactoruploadToIpfsto handle file uploads with authentication.This function now properly checks for required query parameters and handles errors, ensuring robustness and security in file uploads.
web/netlify/functions/update-settings.ts (1)
15-88: Enhance input validation and error handling inupdateSettings.The function now includes comprehensive checks for required and unexpected keys, proper formatting validation, and secure database interactions, significantly improving the robustness and security of the settings update process.
web/src/pages/SubmitList/index.tsx (2)
20-20: LGTM! The addition ofEnsureAuthandStyledEnsureAuthaligns with the PR's objective to enhance authentication for sensitive operations.Also applies to: 42-44
81-98: LGTM! The use ofStyledEnsureAuthto wrap the form routes ensures that these operations are secured and accessible only to authenticated users.web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx (2)
40-61: LGTM! The use ofuseUserSettingsto fetch and manage user settings dynamically enhances the component's functionality and user experience.
68-82: LGTM! The form submission logic is well-implemented, correctly handling the update of user settings and providing appropriate feedback to the user.web/package.json (1)
Line range hint
76-109: LGTM! The addition of new dependencies such as@middy/core,@middy/http-json-body-parser,jose, andsiweare essential for the middleware and authentication functionalities introduced in this PR.web/netlify/functions/authUser.ts (1)
13-112: LGTM! TheauthUserfunction is well-implemented with robust error handling, security checks, and middleware usage, enhancing the authentication process.web/src/components/ActionButton/Modal/RemoveModal.tsx (1)
92-131: LGTM! The use ofEnsureAuthto secure the removal process is a crucial security enhancement, ensuring that only authenticated users can perform this operation.web/src/components/ActionButton/Modal/ChallengeItemModal.tsx (1)
116-155: LGTM! The use ofEnsureAuthto secure the challenge process is a crucial security enhancement, ensuring that only authenticated users can perform this operation.web/src/types/supabase-notification.ts (4)
1-1: Type definition for JSON is comprehensive and correctly handles nested structures.
3-242: TheDatabaseinterface structure is well-organized, covering various tables with appropriate types for rows, inserts, and updates.
156-185: Theuser-public-messagestable correctly uses nullable types for optional fields. Review the use ofidto ensure it is appropriately set as a primary key or unique identifier.
27-59: Thediscord-broadcasttable includes nullable types where appropriate, reflecting optional data. Ensure that the use of nullables aligns with business logic.web/src/types/supabase-datalake.ts (7)
1-1: Type definition for JSON is comprehensive and correctly handles nested structures.
3-296: TheDatabaseinterface structure is well-organized, covering various tables with appropriate types for rows, inserts, and updates.
222-242: Thesce-contractstable includes aJsontype forcontract, which is appropriate for storing structured data. Validate the JSON structure before insertion to prevent schema violations.
6-28: TheCIDstable structure is correctly defined. Ensure that the use of nullable types forestuary,file_headers,threat_detected, andverifiedis justified by business requirements.
129-152: Thelogbooktable is defined to track process logs. Ensure thatlastSeenBlock,network, andunixare appropriately used and indexed if they serve as common query parameters.
154-176: Themainnet-justificationstable uses nullable types extensively. Review the business logic to ensure that this flexibility is required and does not compromise data quality.
258-281: Thesepolia-justificationstable uses nullable types extensively. Review the business logic to ensure that this flexibility is required and does not compromise data quality.
web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/FormContact.tsx
Show resolved
Hide resolved
…and-notifications
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
LGTM |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
PR-Codex overview
This PR enhances Netlify deployment setup, adds user authentication features, and improves Supabase integration.
Detailed summary
generatedNetlifyInfo.jsonnetlify.tomlSummary by CodeRabbit
New Features
Bug Fixes
Improvements
Chores
.gitignorefor better development workflow management.