Skip to content
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

chore: version packages #2204

Merged
merged 3 commits into from
Oct 15, 2024
Merged

chore: version packages #2204

merged 3 commits into from
Oct 15, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 3, 2024

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or setup this action to publish automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@rainbow-me/[email protected]

Minor Changes

  • f02bced: The Authentication API now supports ERC-1271 and ERC-6492 for smart contract signature verification to enable Sign-in with Ethereum for Smart Contract Wallets, including Coinbase Smart Wallet and Argent.

    We have also deprecated the siwe and ethers peer dependencies in favor of viem/siwe to make RainbowKit even more seamless.

    No changes are necessary for dApps that don't rely on the Authentication API.

    Follow the appropriate steps below to migrate.

    ** NextAuth Authentication **

    1. Remove siwe and ethers
    npm uninstall siwe ethers
    1. Upgrade RainbowKit, rainbowkit-siwe-next-auth, and viem
    npm i @rainbow-me/rainbowkit@^2.2.0 rainbow-me/rainbowkit-siwe-next-auth@^0.5.0 viem@^2.12.0
    1. Create a Public Client

    This allows viem to verify smart contract signatures.

    const config = getDefaultConfig({
      /* your config */
    });
    + const publicClient = config.getClient().extend(publicActions);
    1. Adjust your authorize implementation in /api/auth/[...nextauth].ts
    - import { SiweMessage } from 'siwe';
    + import {
    +   type SiweMessage,
    +   parseSiweMessage,
    +   validateSiweMessage,
    + } from 'viem/siwe';
    
    export function getAuthOptions(req: IncomingMessage): NextAuthOptions {
      const providers = [
        CredentialsProvider({
          async authorize(credentials: any) {
    
    -       const siwe = new SiweMessage(
    -         JSON.parse(credentials?.message || '{}'),
    -       );
    +       const siweMessage = parseSiweMessage(
    +         credentials?.message,
    +       ) as SiweMessage;
    
    +       if (!validateSiweMessage({
    +         address: siweMessage?.address,
    +         message: siweMessage,
    +       })) {
    +         return null;
    +       }
    
            /* ... */
    
    -       await siwe.verify({ signature: credentials?.signature || '' });
    +       const valid = await publicClient.verifyMessage({
    +         address: siweMessage?.address,
    +         message: credentials?.message,
    +         signature: credentials?.signature,
    +       });
    
    +       if (!valid) {
    +         return null;
    +       }
          },
          /* ... */
        })
      ]
    }

    Reference the with-next-siwe-next-auth example for more guidance.

    ** Custom Authentication **

    1. Remove siwe and ethers
    npm uninstall siwe ethers
    1. Upgrade RainbowKit and viem
    npm i @rainbow-me/rainbowkit@^2.2.0 viem@^2.12.0
    1. Create a Public Client

    This allows viem to verify smart contract signatures.

    const config = getDefaultConfig({
      /* your config */
    });
    
    + const publicClient = config.getClient().extend(publicActions);
    1. Adjust your createAuthenticationAdapter implementation
    - import { SiweMessage } from 'siwe';
    + import { createSiweMessage } from 'viem/siwe';
    
    createAuthenticationAdapter({
      getNonce: async () => {
        const response = await fetch('/api/nonce');
        return await response.text();
      },
    
      createMessage: ({ nonce, address, chainId }) => {
    -   return new SiweMessage({
    +   return createSiweMessage({
          domain: window.location.host,
          address,
          statement: 'Sign in with Ethereum to the app.',
          uri: window.location.origin,
          version: '1',
          chainId,
          nonce,
        });
      },
    
    - getMessageBody: ({ message }) => {
    -   return message.prepareMessage();
    - },
    
      /* ... */
    })
    1. Adopt generateSiweNonce
    - import { generateNonce } from 'siwe';
    + import { generateSiweNonce } from 'viem/siwe';
    
    - req.session.nonce = generateNonce();
    + req.session.nonce = generateSiweNonce();
    1. Adopt parseSiweMessage and verifyMessage if your Verify handler
    - import { SiweMessage } from 'siwe';
    + import { parseSiweMessage, type SiweMessage } from 'viem/siwe';
    
    const { message, signature } = req.body;
    - const siweMessage = new SiweMessage(message);
    - const { success, error, data } = await siweMessage.verify({
    -  signature,
    - });
    + const siweMessage = parseSiweMessage(message) as SiweMessage;
    + const success = await publicClient.verifyMessage({
    +   address: siweMessage.address,
    +   message,
    +   signature,
    + });
    
    - if (!success) throw error;
    + if (!success) throw new Error('Invalid signature.');
    
    - if (data.nonce !== req.session.nonce)
    + if (siweMessage.nonce !== req.session.nonce)
    +   return res.status(422).json({ message: 'Invalid nonce.' });

    Reference the with-next-siwe-iron-session example for more guidance.

@rainbow-me/[email protected]

Minor Changes

  • f02bced: The Authentication API now supports ERC-1271 and ERC-6492 for smart contract signature verification to enable Sign-in with Ethereum for Smart Contract Wallets.

    We have also deprecated the siwe and ethers peer dependencies in favor of viem/siwe.

    Follow the appropriate steps below to migrate.

    1. Remove siwe and ethers
    npm uninstall siwe ethers
    1. Upgrade RainbowKit, rainbowkit-siwe-next-auth, and viem
    npm i @rainbow-me/rainbowkit@^2.2.0 rainbow-me/rainbowkit-siwe-next-auth@^0.5.0 viem@^2.12.0
    1. Create a Public Client

    This allows viem to verify smart contract signatures.

    const config = getDefaultConfig({
      /* your config */
    });
    + const publicClient = config.getClient().extend(publicActions);
    1. Adjust your authorize implementation in /api/auth/[...nextauth].ts
    - import { SiweMessage } from 'siwe';
    + import {
    +   type SiweMessage,
    +   parseSiweMessage,
    +   validateSiweMessage,
    + } from 'viem/siwe';
    
    export function getAuthOptions(req: IncomingMessage): NextAuthOptions {
      const providers = [
        CredentialsProvider({
          async authorize(credentials: any) {
    
    -       const siwe = new SiweMessage(
    -         JSON.parse(credentials?.message || '{}'),
    -       );
    +       const siweMessage = parseSiweMessage(
    +         credentials?.message,
    +       ) as SiweMessage;
    
    +       if (!validateSiweMessage({
    +         address: siweMessage?.address,
    +         message: siweMessage,
    +       })) {
    +         return null;
    +       }
    
            /* ... */
    
    -       await siwe.verify({ signature: credentials?.signature || '' });
    +       const valid = await publicClient.verifyMessage({
    +         address: siweMessage?.address,
    +         message: credentials?.message,
    +         signature: credentials?.signature,
    +       });
    
    +       if (!valid) {
    +         return null;
    +       }
          },
          /* ... */
        })
      ]
    }

    Reference the with-next-siwe-next-auth example for more guidance.

Patch Changes

@rainbow-me/[email protected]

Patch Changes

  • dc31926: Upgraded wagmi to ^2.12.17

@rainbow-me/[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

[email protected]

Patch Changes

@github-actions github-actions bot requested a review from a team as a code owner October 3, 2024 07:15
Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rainbowkit-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 9:02am
rainbowkit-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 9:02am

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

Successfully merging this pull request may close these issues.

1 participant