Skip to content

Atlas integration for authentication, user settings, email confirmation, uploads #1654

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

Merged
merged 35 commits into from
Oct 16, 2024

Conversation

tractorss
Copy link
Contributor

@tractorss tractorss commented Jul 18, 2024

  • inital effort to support siwe from atlas

Related to https://github.com/kleros/atlas/pull/57


PR-Codex overview

This PR primarily focuses on refactoring and restructuring the authentication and user management functionalities, with significant changes to various utility functions, environment variables, and component implementations for email confirmation and user settings.

Detailed summary

  • Deleted several utility and function files related to user authorization and Supabase types.
  • Added new utility functions for user operations (addUser, updateEmail, confirmEmail, fetchUser, getNonce, loginUser).
  • Updated environment variables to include REACT_APP_ATLAS_URI.
  • Changed sessionStorage to localStorage in useSessionStorage hook.
  • Refactored EnsureAuth component to use context for user state management.
  • Introduced AtlasProvider context for handling user authentication and data fetching.
  • Implemented EmailConfirmation component for handling email verification.
  • Enhanced form handling in FormContactDetails to manage user settings and email verification.
  • Updated SVG icons and styles for better UI consistency.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced user authentication management through a new context provider.
    • Implemented email confirmation functionality for streamlined user verification.
    • Added a dedicated component for email confirmation and status feedback.
    • Introduced functionality for fetching user data via GraphQL.
    • Added a component to display email verification status and resend verification emails.
    • Introduced functionality for uploading files to IPFS.
    • New route added for the Settings page.
  • Bug Fixes

    • Improved error handling during user data retrieval processes.
  • Refactor

    • Streamlined authentication component structure for better maintainability.
    • Updated components to leverage the new context provider for user management.
    • Simplified logic in user settings management for improved user experience.
  • Chores

    • Updated project dependencies and configuration settings.

Copy link
Contributor

coderabbitai bot commented Jul 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent updates introduce a comprehensive user authentication management system through the implementation of the AtlasProvider, which facilitates interactions with an Atlas API. A new EmailConfirmation component has been added to handle the email verification process. Additionally, utility functions for confirming emails and fetching user data have been introduced, enhancing state management and streamlining user interactions. Several files related to IPFS uploads and authentication middleware have been removed, reflecting a shift in the project's architecture.

Changes

File Change Summary
web/src/context/AtlasProvider.tsx Implemented AtlasProvider for user authentication and session management. Added IAtlasProvider interface and useAtlasProvider hook.
web/src/pages/Settings/EmailConfirmation/index.tsx Added EmailConfirmation component for handling email verification using query parameters.
web/src/utils/atlas/confirmEmail.ts Introduced confirmEmail function with GraphQL mutation for email confirmation. Added types ConfirmEmailData and ConfirmEmailResponse.
web/src/utils/atlas/fetchUser.ts Added fetchUser function to retrieve user data via GraphQL, including types GetUserResponse and User.
web/src/utils/atlas/index.ts Updated to re-export uploadToIpfs along with other user management functionalities.
web/src/utils/atlas/uploadToIpfs.ts Introduced functionality for uploading files to IPFS, including enumerations and structured payload types.
web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/EmailVerificationInfo.tsx Added EmailVerificationInfo component to display email verification status and resend verification email. Introduced IEmailInfo interface.
web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx Modified FormContactDetails component to use useAtlasProvider for user settings management, simplifying logic and integrating email update functionality.
web/package.json Updated project version to 0.2.0, removed generate:supabase script, and updated dependencies.
web/.env.* Added REACT_APP_ATLAS_URI environment variable to multiple .env files.
web/netlify/functions/uploadToIPFS.ts, web/netlify/middleware/authMiddleware.ts Deleted files related to IPFS upload functionality and authentication middleware.

Possibly related PRs

Suggested labels

Package: Backend Storage

Suggested reviewers

  • alcercu
  • kemuru

Poem

In the realm of code, a rabbit hops,
With emails confirmed and no more flops.
Tokens dance and sessions thrive,
In the Atlas, we come alive!
New hooks and states, a joyful cheer,
For every user, we hold dear. 🐇✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jul 18, 2024

Deploy Preview for kleros-v2-university failed. Why did it fail? →

Name Link
🔨 Latest commit e72bd47
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/670ffb9c46f8b900089d1d3d

Copy link

netlify bot commented Jul 18, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit e72bd47
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/670ffb9c2539af0008e607c2
😎 Deploy Preview https://deploy-preview-1654--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jul 18, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit e72bd47
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/670ffb9c4ebc9c00086506f2
😎 Deploy Preview https://deploy-preview-1654--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a1dff3b and c755571.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (3)
  • web/package.json (1 hunks)
  • web/src/components/EnsureAuth.tsx (5 hunks)
  • web/src/utils/authoriseUser.ts (3 hunks)
Additional comments not posted (5)
web/src/utils/authoriseUser.ts (2)

11-15: Verify the correctness of the GraphQL query construction.

The query construction looks correct, but ensure the authData.message and authData.signature are properly sanitized to prevent injection attacks.


44-48: Verify the correctness of the GraphQL query construction.

The query construction looks correct, but ensure the address is properly sanitized to prevent injection attacks.

web/src/components/EnsureAuth.tsx (2)

Line range hint 44-56:
Ensure proper handling of the sign-in process.

The sign-in process looks correct. Ensure the createMessage function is correctly implemented and the signMessageAsync function handles errors properly.


Line range hint 79-97:
Ensure proper construction of the SIWE message.

The message construction looks correct. Ensure the getNonce function is correctly implemented and the createSiweMessage function handles errors properly.

web/package.json (1)

120-120: Verify the package update.

The viem package version was updated from 2.1.0 to 2.17.3. Ensure there are no compatibility issues with this update.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c755571 and e985455.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (10)
  • web/.env.devnet-neo.public (1 hunks)
  • web/.env.devnet-university.public (1 hunks)
  • web/.env.devnet.public (1 hunks)
  • web/.env.local.public (1 hunks)
  • web/.env.mainnet-neo.public (1 hunks)
  • web/.env.testnet.public (1 hunks)
  • web/netlify/middleware/authMiddleware.ts (1 hunks)
  • web/package.json (1 hunks)
  • web/src/components/EnsureAuth.tsx (6 hunks)
  • web/src/utils/authoriseUser.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • web/.env.devnet-neo.public
Additional comments not posted (10)
web/.env.local.public (1)

5-5: Ensure consistency and security for environment variables.

The new environment variable REACT_APP_ATLAS_URI is added correctly. Ensure that this variable is documented and follows the project's naming conventions. Verify that it does not expose any sensitive information.

web/.env.testnet.public (1)

6-6: Ensure consistency and security for environment variables.

The new environment variable REACT_APP_ATLAS_URI is added correctly. Ensure that this variable is documented and follows the project's naming conventions. Verify that it does not expose any sensitive information.

web/.env.devnet.public (1)

7-7: Ensure consistency and security for environment variables.

The new environment variable REACT_APP_ATLAS_URI is added correctly. Ensure that this variable is documented and follows the project's naming conventions. Verify that it does not expose any sensitive information.

web/.env.mainnet-neo.public (1)

8-8: New environment variable added for local GraphQL endpoint.

The addition of REACT_APP_ATLAS_URI pointing to http://localhost:3000/graphql is noted. Ensure this variable is used appropriately in the codebase and does not conflict with existing configurations.

Verify the usage of this new environment variable in the codebase.

Verification successful

New environment variable REACT_APP_ATLAS_URI is used in the codebase.

The environment variable REACT_APP_ATLAS_URI is referenced in the following file:

  • web/src/utils/authoriseUser.ts

This confirms its usage and ensures there are no conflicts with existing configurations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new environment variable `REACT_APP_ATLAS_URI`.

# Test: Search for the usage of `REACT_APP_ATLAS_URI`. Expect: Occurrences of the new variable.
rg --type js --type ts --type tsx 'REACT_APP_ATLAS_URI'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the usage of the new environment variable `REACT_APP_ATLAS_URI`.

# Test: Search for the usage of `REACT_APP_ATLAS_URI` in JavaScript, JSX, and TypeScript files.
rg --type js --type jsx --type ts 'REACT_APP_ATLAS_URI'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the usage of the new environment variable `REACT_APP_ATLAS_URI`.

# Test: Search for the usage of `REACT_APP_ATLAS_URI` in JavaScript, JSX, and TypeScript files.
rg --glob '*.js' --glob '*.jsx' --glob '*.ts' 'REACT_APP_ATLAS_URI'

Length of output: 158

web/.env.devnet-university.public (1)

8-8: New environment variable added for local GraphQL endpoint.

The addition of REACT_APP_ATLAS_URI pointing to http://localhost:3000/graphql is noted. Ensure this variable is used appropriately in the codebase and does not conflict with existing configurations.

Verify the usage of this new environment variable in the codebase.

Verification successful

Environment variable REACT_APP_ATLAS_URI is used appropriately.

The variable REACT_APP_ATLAS_URI is utilized in the codebase within web/src/utils/authoriseUser.ts. Ensure this usage aligns with the intended configuration and does not conflict with other settings.

  • web/src/utils/authoriseUser.ts: const atlasUri = import.meta.env.REACT_APP_ATLAS_URI ?? "";
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new environment variable `REACT_APP_ATLAS_URI`.

# Test: Search for the usage of `REACT_APP_ATLAS_URI`. Expect: Occurrences of the new variable.
rg --type js --type ts --type tsx 'REACT_APP_ATLAS_URI'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the usage of the new environment variable `REACT_APP_ATLAS_URI`.

# Test: Search for the usage of `REACT_APP_ATLAS_URI`. Expect: Occurrences of the new variable.
rg --type js --type ts --type-add 'tsx:*.{ts,tsx}' 'REACT_APP_ATLAS_URI'

Length of output: 163

web/src/utils/authoriseUser.ts (2)

59-85: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to getNonce match the new return type.


12-44: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to authoriseUser match the new return type.

Verification successful

Verified: The function usage matches the new return type.

The authoriseUser function is correctly handled in EnsureAuth.tsx, with the returned token being used appropriately.

  • web/src/components/EnsureAuth.tsx: The authoriseUser function call correctly handles the Promise<string> return type.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `authoriseUser` match the new return type.

# Test: Search for the function usage. Expect: Only occurrences of the new return type.
rg --type js -A 5 $'authoriseUser'

Length of output: 33


Script:

#!/bin/bash
# Description: Verify all function calls to `authoriseUser` match the new return type.

# Search for the function usage in JavaScript and TypeScript files.
rg --type-add 'ts:*.{ts,tsx}' -A 5 'authoriseUser'

# Search for import statements of the function to trace its usage.
rg --type-add 'ts:*.{ts,tsx}' -A 5 'import { authoriseUser'

Length of output: 1322


Script:

#!/bin/bash
# Description: Extract more lines around the function call in EnsureAuth.tsx to verify the handling of the new return type.

rg --type-add 'ts:*.{ts,tsx}' -A 10 -B 5 'authoriseUser' web/src/components/EnsureAuth.tsx

Length of output: 968

web/src/components/EnsureAuth.tsx (2)

Line range hint 79-97:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to createMessage are correctly updated.

Verification successful

LGTM! The createMessage function usage is correctly updated and self-contained within the EnsureAuth.tsx file. No further action required.

  • web/src/components/EnsureAuth.tsx: Verified the function usage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createMessage` are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new function name.
rg --type js -A 5 $'createMessage'

Length of output: 33


Script:

#!/bin/bash
# Description: Verify all function calls to `createMessage` are correctly updated.

# Test: Search for the function usage in .ts, .tsx, and .js files. Expect: Only occurrences of the new function name.
rg --type-add 'ts:*.{ts,tsx}' --type-add 'js:*.{js,jsx}' -A 10 $'createMessage'

Length of output: 1502


Line range hint 4-56:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to createMessage and JWT payload handling are correctly updated.

Verification successful

Verify function usage in the codebase

The code changes are approved, but ensure that all function calls to createMessage and JWT payload handling are correctly updated. The search results confirm that createMessage and jwt.decodeJwt are used correctly in EnsureAuth.tsx. Additionally, payload is handled properly in both EnsureAuth.tsx and authMiddleware.ts.

  • createMessage is correctly used in web/src/components/EnsureAuth.tsx.
  • JWT payload handling with jwt.decodeJwt and payload is correctly implemented in web/src/components/EnsureAuth.tsx and web/netlify/middleware/authMiddleware.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createMessage` and JWT payload handling are correctly updated.

# Test: Search for the function usage. Expect: Only occurrences of the new function name and payload property.
rg --type js -A 5 $'createMessage'
rg --type js -A 5 $'payload.sub'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify all function calls to `createMessage` and JWT payload handling are correctly updated.

# Search for the function usage in all relevant file types
rg --type js,ts,tsx -A 5 'createMessage'
rg --type js,ts,tsx -A 5 'payload.sub'

Length of output: 147


Script:

#!/bin/bash
# Description: Verify all function calls to `createMessage` and JWT payload handling are correctly updated.

# Search for the function usage in JavaScript, TypeScript, and TSX files separately
rg --type js -A 5 'createMessage'
rg --type ts -A 5 'createMessage'
rg --type tsx -A 5 'createMessage'

rg --type js -A 5 'payload.sub'
rg --type ts -A 5 'payload.sub'
rg --type tsx -A 5 'payload.sub'

Length of output: 1127


Script:

#!/bin/bash
# Description: Verify JWT payload handling by searching for 'payload.sub' without restricting file types.

# Search for 'payload.sub' in all files
rg -A 5 'payload.sub'

Length of output: 21


Script:

#!/bin/bash
# Description: Verify JWT payload handling by searching for 'jwt.decodeJwt' and 'payload' in all files.

# Search for 'jwt.decodeJwt' in all files
rg -A 5 'jwt.decodeJwt'

# Search for 'payload' in all files
rg -A 5 'payload'

Length of output: 1757

web/package.json (1)

121-121: LGTM! But verify the package usage in the codebase.

The version update is approved.

However, ensure that all usages of the viem package are compatible with the new version.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e985455 and 53b7b2a.

Files selected for processing (3)
  • web/netlify/functions/fetch-settings.ts (1 hunks)
  • web/netlify/functions/update-settings.ts (1 hunks)
  • web/netlify/middleware/authMiddleware.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/netlify/middleware/authMiddleware.ts
Additional comments not posted (2)
web/netlify/functions/fetch-settings.ts (1)

9-9: LGTM! But verify the usage of event.auth.sub in the codebase.

The change from event.auth.id to event.auth.sub aligns with standard practices for using subject claims in authentication tokens.

However, ensure that all references to event.auth.sub are correctly used throughout the codebase.

Verification successful

Usage of event.auth.sub is correct and isolated.

The change from event.auth.id to event.auth.sub is consistent with standard practices. The usage is correctly handled in the web/netlify/functions/fetch-settings.ts file.

  • web/netlify/functions/fetch-settings.ts: Correct usage of event.auth.sub.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `event.auth.sub` in the codebase.

# Test: Search for the usage of `event.auth.sub`. Expect: Correct usage in all instances.
rg --type js --type ts -A 5 $'event.auth.sub'

Length of output: 544

web/netlify/functions/update-settings.ts (1)

66-66: LGTM! But verify the usage of event.auth.sub in the codebase.

The change from event?.auth?.id to event?.auth?.sub aligns with standard practices for using subject claims in authentication tokens.

However, ensure that all references to event.auth.sub are correctly used throughout the codebase.

Verification successful

The usage of event.auth.sub in fetch-settings.ts appears consistent with the change in update-settings.ts. However, to ensure comprehensive verification, we need to check the context of its usage in fetch-settings.ts and look for any other instances in the codebase.


LGTM! The usage of event.auth.sub is consistent and correctly handled in the codebase.

  • web/netlify/functions/fetch-settings.ts: The event.auth.sub is used to fetch user settings from the database, and its usage is correct.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `event.auth.sub` in the codebase.

# Test: Search for the usage of `event.auth.sub`. Expect: Correct usage in all instances.
rg --type js --type ts -A 5 $'event.auth.sub'

Length of output: 544


Script:

#!/bin/bash
# Description: Verify the context of `event.auth.sub` usage in `fetch-settings.ts` and search for any other instances in the codebase.

# Search for the usage of `event.auth.sub` in `fetch-settings.ts` with extended context.
rg --type ts -A 10 -B 10 $'event.auth.sub' web/netlify/functions/fetch-settings.ts

# Search for any other instances of `event.auth.sub` in the codebase.
rg --type js --type ts -A 5 $'event.auth.sub'

Length of output: 1281

@fcanela
Copy link

fcanela commented Jul 26, 2024

LGTM so far. Ping again when it is out of draft

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 53b7b2a and 33b818e.

Files selected for processing (4)
  • web/src/components/EnsureAuth.tsx (7 hunks)
  • web/src/layout/Header/navbar/Menu/Settings/Notifications/index.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx (1 hunks)
  • web/src/pages/Resolver/index.tsx (1 hunks)
Additional comments not posted (6)
web/src/layout/Header/navbar/Menu/Settings/Notifications/index.tsx (1)

8-8: Verify the default export of EnsureAuth.

The import statement has been changed to a default import. Ensure that the EnsureAuth component is exported as a default export from its module.

Verification successful

The EnsureAuth component is correctly exported as a default export.

  • The EnsureAuth component is exported as a default export from web/src/components/EnsureAuth.tsx.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `EnsureAuth` is exported as a default export.

# Test: Search for the export statement in the `EnsureAuth` component file.
rg --type js --type ts 'export default EnsureAuth' web/src/components/EnsureAuth.tsx

Length of output: 113

web/src/components/EnsureAuth.tsx (3)

33-33: Ensure the JWT payload structure is consistent.

The validation logic now uses payload.sub instead of payload.id. Ensure that the JWT payload structure consistently uses sub for the subject identifier.


44-44: Ensure the createMessage function is correctly implemented.

Verify that the createMessage function is correctly implemented and replaces the previous createSiweMessage function.

Verification successful

The createMessage function is correctly implemented and relies on the createSiweMessage function from the viem/siwe module.

  • The createMessage function is defined in web/src/components/EnsureAuth.tsx.
  • It correctly calls createSiweMessage, which is imported from the viem/siwe module.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `createMessage` function.

# Test: Search for the implementation of the `createMessage` function.
rg --type js --type ts 'async function createMessage'

Length of output: 196


Script:

#!/bin/bash
# Description: Extract the full implementation of the `createMessage` function and search for the `createSiweMessage` function for comparison.

# Extract the full implementation of the `createMessage` function.
ast-grep --lang tsx --pattern $'async function createMessage($_, $_, $_) {
  $$$
}'

# Search for the implementation of the `createSiweMessage` function.
rg --type js --type ts 'function createSiweMessage'

Length of output: 1436


Script:

#!/bin/bash
# Search for the definition or import of the `createSiweMessage` function in the codebase.

# Search for the definition of `createSiweMessage`.
rg --type js --type ts 'function createSiweMessage'

# Search for imports of `createSiweMessage`.
rg --type js --type ts 'import { createSiweMessage }'

Length of output: 229


Script:

#!/bin/bash
# Search for the definition or import of the `createSiweMessage` function in the codebase.

# Search for the definition of `createSiweMessage`.
rg --type js --type ts 'function createSiweMessage'

# Search for imports of `createSiweMessage`.
rg --type js --type ts 'import { createSiweMessage }' --fixed-strings

Length of output: 206


Line range hint 79-97:
Ensure the createMessage function handles all required fields.

The createMessage function should handle all required fields for the SIWE message. Verify that all necessary fields are included.

web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx (1)

14-14: Verify the default export of EnsureAuth.

The import statement has been changed to a default import. Ensure that the EnsureAuth component is exported as a default export from its module.

Verification successful

Verification successful.

The EnsureAuth component is correctly exported as a default export from its module.

  • web/src/components/EnsureAuth.tsx: export default EnsureAuth;
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `EnsureAuth` is exported as a default export.

# Test: Search for the export statement in the `EnsureAuth` component file.
rg --type js --type ts 'export default EnsureAuth' web/src/components/EnsureAuth.tsx

Length of output: 113

web/src/pages/Resolver/index.tsx (1)

12-12: Verify the export change in EnsureAuth module.

The import statement for EnsureAuth has been changed from a named import to a default import. Ensure that EnsureAuth is now being exported as a default export from its module.

Verification successful

Verified: The import statement for EnsureAuth has been correctly updated to a default import in web/src/pages/Resolver/index.tsx, consistent with its default export in web/src/components/EnsureAuth.tsx.

  • web/src/pages/Resolver/index.tsx
  • web/src/components/EnsureAuth.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that EnsureAuth is being exported as a default export from its module.

# Test: Search for the export statement of EnsureAuth. Expect: EnsureAuth should be exported as a default export.
rg --type js --type ts $'export default EnsureAuth'

Length of output: 113

@jaybuidl jaybuidl changed the title chore(web): initial-wrapper-update Atlas SIWE integration Aug 7, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 33b818e and ba2442a.

Files selected for processing (7)
  • web/src/app.tsx (2 hunks)
  • web/src/components/EnsureAuth.tsx (1 hunks)
  • web/src/context/AtlasProvider.tsx (1 hunks)
  • web/src/utils/atlas/createMessage.ts (1 hunks)
  • web/src/utils/atlas/getNonce.ts (1 hunks)
  • web/src/utils/atlas/index.ts (1 hunks)
  • web/src/utils/atlas/loginUser.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • web/src/utils/atlas/index.ts
Additional comments not posted (3)
web/src/utils/atlas/createMessage.ts (1)

6-7: Verify compatibility with server-side rendering.

The use of window.location may cause issues if this function is used in a server-side rendering context.

web/src/components/EnsureAuth.tsx (1)

14-30: Refactor improves maintainability and clarity.

The refactoring to use useAtlasProvider simplifies the component and enhances separation of concerns. The default export is a good practice for component exports.

web/src/app.tsx (1)

33-99: Verify the integration of AtlasProvider.

Ensure that the placement of AtlasProvider as the outermost provider is intentional and that all components requiring its context are correctly wrapped. Verify that there are no unintended side effects on other providers or components.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ba2442a and ddd06d1.

Files selected for processing (4)
  • web/src/context/AtlasProvider.tsx (1 hunks)
  • web/src/utils/atlas/createMessage.ts (1 hunks)
  • web/src/utils/atlas/getNonce.ts (1 hunks)
  • web/src/utils/atlas/loginUser.ts (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • web/src/context/AtlasProvider.tsx
  • web/src/utils/atlas/createMessage.ts
  • web/src/utils/atlas/getNonce.ts
  • web/src/utils/atlas/loginUser.ts

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 8, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 8, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ddd06d1 and 5b41eda.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (1)
  • web/src/context/AtlasProvider.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/context/AtlasProvider.tsx

alcercu
alcercu previously approved these changes Oct 16, 2024
Copy link
Contributor

@alcercu alcercu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

kemuru
kemuru previously approved these changes Oct 16, 2024
Copy link
Contributor

@kemuru kemuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upload to ipfs works, auth user (signing in) works, fetch settings works, update settings works

jaybuidl
jaybuidl previously approved these changes Oct 16, 2024
@jaybuidl jaybuidl dismissed stale reviews from kemuru, alcercu, and themself via e72bd47 October 16, 2024 17:44
Copy link

Copy link

Code Climate has analyzed commit e72bd47 and detected 28 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3
Duplication 6
Style 19

View more on Code Climate.

@jaybuidl jaybuidl merged commit e72bd47 into dev Oct 16, 2024
16 of 26 checks passed
@jaybuidl jaybuidl deleted the feat/atlas-siwe branch October 16, 2024 17:49
@MAMware
Copy link

MAMware commented Oct 21, 2024 via email

@tractorss
Copy link
Contributor Author

Hi! ty, should i clone the comment there?

Hey Marcos, yes you can comment there.

Would you be interested in addressing this issue? 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frontend integration with the new Atlas backend for notifications and user settings
7 participants