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

feat(auth): AppKit Auth #2413

Closed
wants to merge 97 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
3a2531b
v5.0.1 (#2411)
tomiir Jun 12, 2024
637c31b
chore(config): expose default appKitAuthConfig
Cali93 Jun 13, 2024
f1261de
release: v5.0.2 (#2439)
tomiir Jun 18, 2024
3a1ca63
chore(default-appkit-config): inject default appKit config
Cali93 Jun 19, 2024
9ce372e
release: 5.0.3 (#2453)
tomiir Jun 20, 2024
ccb5067
chore(dynamic-import): keep dynamic import
Cali93 Jun 24, 2024
9d81fd9
fix(connect): fix connect with wagmi
Cali93 Jun 24, 2024
33de742
chore(logs): add debug logs
Cali93 Jun 25, 2024
acc2e5c
fix(conflicts): pull develop & fix conflicts
Cali93 Jun 25, 2024
ea55eda
chore(remove-logs): remove logs
Cali93 Jun 25, 2024
7afeee8
fix(chains): dynamically set chains for 1CA
Cali93 Jun 25, 2024
126817a
chore(remove-prefetch): remove prefetch config
Cali93 Jun 25, 2024
106a844
chore(enable-auth): enable auth config flag
Cali93 Jun 25, 2024
9c3e127
feat(update-user): expose method to update user metadata
Cali93 Jun 25, 2024
865e95c
chore(client-id): store client id
Cali93 Jun 26, 2024
93b0b42
fix(session): fix session and siwe client state
Cali93 Jun 27, 2024
34a839d
chore(hook): provide a siwe session hook
Cali93 Jun 28, 2024
8d034dc
release: v5.0.4 (#2487)
tomiir Jul 1, 2024
e9c1368
release: v5.0.5 (#2499)
tomiir Jul 3, 2024
f617303
release: 5.0.6 (#2505)
tomiir Jul 3, 2024
5414224
fix(session): fix useSession hook
Cali93 Jul 4, 2024
ca8dd99
fix(conflicts): pull V5 and fix conflicts
Cali93 Jul 4, 2024
ee918f9
chore(optim): remove uncessary API calls
Cali93 Jul 5, 2024
bb8b66b
chore(auth-pages): dedicated auth pages in labs
Cali93 Jul 8, 2024
1ce00d9
fix(undefined-chainId): fix undefined chainId when using 1CA
Cali93 Jul 8, 2024
080f6a2
chore(prod-api): use the prod API URL for AppKit Auth
Cali93 Jul 12, 2024
ce10c01
fix(1ca-state): optimistically set session when using 1CA
Cali93 Jul 15, 2024
2f08412
chore(profiles): profiles requests
Cali93 Jul 24, 2024
930fdde
chore(profiles): profiles basic flow
Cali93 Jul 26, 2024
2603126
chore(profile): set main account and delete profile
Cali93 Jul 30, 2024
f815822
fix(conflicts): pull main & fix conflicts
Cali93 Jul 31, 2024
57abd61
fix(missing-chains): fix wagmi missing chains
Cali93 Jul 31, 2024
4e505ef
chore(profiles): profiles improvements
Cali93 Aug 14, 2024
20a38fe
chore(canary): release a new canary version
Cali93 Aug 14, 2024
e1284bf
chore(auth-url): update Auth API url and add example OTP requests
Cali93 Aug 15, 2024
9aab375
chore(ignore-apps): ignore apps and examples from changeset
Cali93 Aug 15, 2024
6c4e6ef
chore(new-canary): release new canary with correct auth API url
Cali93 Aug 15, 2024
77595f7
fix(conflicts): pull main and fix conflicts
Cali93 Aug 30, 2024
90c89d3
chore(imports): update AppKit buttons imports
Cali93 Aug 30, 2024
78da61e
fix(1CA): fix 1CA flow
Cali93 Aug 30, 2024
8d342a5
chore(ethereum-provider): update ethereum provider
Cali93 Aug 30, 2024
ad6435d
chore(canary): publish canary
Cali93 Sep 2, 2024
2e78796
chore(1ca): improve 1CA auth and error states
Cali93 Sep 2, 2024
b7197ee
chore(disconnect): disconnect using ConnectionController
Cali93 Sep 2, 2024
6338a02
chore(pre-release): enter pre release and use new canary version
Cali93 Sep 4, 2024
c8462cf
chore(localhost): use localhost for profiles API
Cali93 Sep 5, 2024
bb7e41a
fix(conflicts): pull develop & fix conflicts
Cali93 Sep 10, 2024
b13f6b0
fix(signOutOnNetworkChange): fix flow for signOutOnNetworkChange duri…
Cali93 Sep 10, 2024
81f2bc2
chore(canary): release new canary
Cali93 Sep 10, 2024
e26f36a
fix(disconnect): fix 1CA disconnect on error
Cali93 Sep 11, 2024
94d5454
chore(latest-canary): release latest canary
Cali93 Sep 12, 2024
a1740ab
fix(1CA-wrong-state): fix wrong modal states
Cali93 Sep 12, 2024
03dcd09
chore(canary): release new canary
Cali93 Sep 12, 2024
a869e5c
chore(profiles-api-url): update profiles API url
Cali93 Sep 18, 2024
304c7a4
chore(canary): latest canary
Cali93 Sep 24, 2024
9fc6442
chore(nonce): always fetch nonce
Cali93 Sep 24, 2024
31016b7
chore(canary): release latest canary
Cali93 Sep 24, 2024
a957ac5
fix(conflicts): pull main and fix conflicts
Cali93 Oct 1, 2024
5eeab11
chore(changesets): remove changesets
Cali93 Oct 1, 2024
87aecc4
chore(project-config): refactor fetching project config
Cali93 Oct 1, 2024
3f60bcc
fix(tests): fix tests for fetch and prefetch
Cali93 Oct 1, 2024
f88ebce
chore(tests): fix controller tests
Cali93 Oct 2, 2024
74ec463
fix(conflicts): pull main & fix conflicts
Cali93 Oct 2, 2024
2c92179
test(project-config): fetch project config tests
Cali93 Oct 2, 2024
a87ea33
chore(canary): enter pre release mode
Cali93 Oct 2, 2024
80bdb3f
chore(canary): add canary GH action
Cali93 Oct 2, 2024
fb7e0b5
chore(pre-exit): exit pre release mode
Cali93 Oct 2, 2024
6594e10
chore(delete-canary-action): delete GH canary action
Cali93 Oct 2, 2024
0e6050d
fix(siwe-fixes): fix SIWE and revert to 1CA authenticating flow
Cali93 Oct 3, 2024
87183e1
chore(canary): released new canary and updated 1CA naming
Cali93 Oct 10, 2024
eeeace1
chore(w3m): remove staging API url
Cali93 Oct 10, 2024
fcdcfe3
chore(1.1.0): update package version
Cali93 Oct 10, 2024
c9a2251
chore(main): pull main and fix conflicts
Cali93 Oct 10, 2024
506184e
chore(main): pull main and fix conflicts
Cali93 Oct 10, 2024
40d0859
chore(1CA-naming): use consistent 1CA naming
Cali93 Oct 10, 2024
c6d9248
Merge branch 'main' into feat/appkit-auth
enesozturk Oct 14, 2024
ddc7ee9
chore: revert changeset, vscode settings
enesozturk Oct 14, 2024
ff46923
chore: add deprecated jsdoc to siwe chains type
enesozturk Oct 14, 2024
f37e111
refactor: separate react export for siwe hooks, update lab examples a…
enesozturk Oct 14, 2024
422a15f
Merge branch 'main' into feat/appkit-auth
enesozturk Oct 14, 2024
dade692
chore: changeset file
enesozturk Oct 14, 2024
bf2d666
chore: revert import changes
enesozturk Oct 14, 2024
d57d072
chore: life cycle methods for address change
enesozturk Oct 14, 2024
639755d
chore: revert import/export changes
enesozturk Oct 14, 2024
b3040a5
chore: build issues
enesozturk Oct 14, 2024
1446807
chore: disable ethers tests temporarily
enesozturk Oct 15, 2024
dae1020
fix: ethers infinite loop issue
enesozturk Oct 15, 2024
87a3190
Merge branch 'main' into feat/appkit-auth
enesozturk Oct 16, 2024
2dd816f
refactor: connecting wc logics and siwe redirections
enesozturk Oct 16, 2024
92b5796
Merge branch 'main' into feat/appkit-auth
enesozturk Oct 16, 2024
870de52
chore: snackbar default duration control
enesozturk Oct 16, 2024
0d4d438
chore: trigger git
enesozturk Oct 16, 2024
ef3277a
chore: remove log
enesozturk Oct 16, 2024
3202071
chore: lock file
enesozturk Oct 16, 2024
b8c5e7e
chore(enableAuth): remove enable auth option
Cali93 Oct 16, 2024
52ba000
chore(siweConfig): stop relying on siweConfig and expose wallet name
Cali93 Oct 17, 2024
772cacd
chore(wallet-info): connected wallet info
Cali93 Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["@examples/*"]
"ignore": ["@examples/*", "@services/*"]
}
23 changes: 23 additions & 0 deletions .changeset/slimy-rules-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-scaffold-ui': patch
'@apps/laboratory': patch
'@reown/appkit': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-siwe': patch
'@reown/appkit-ui': patch
'@apps/demo': patch
'@apps/gallery': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-polkadot': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-wallet': patch
---

Introduces Auth feature over SIWE
2 changes: 1 addition & 1 deletion apps/laboratory/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const cspHeader = `
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
img-src * 'self' data: blob: https://walletconnect.org https://walletconnect.com https://secure.walletconnect.com https://secure.walletconnect.org https://tokens-data.1inch.io https://tokens.1inch.io https://ipfs.io https://appkit-lab.reown.org;
font-src 'self' https://fonts.gstatic.com;
connect-src 'self' https://react-wallet.walletconnect.com https://rpc.walletconnect.com https://rpc.walletconnect.org https://relay.walletconnect.com https://relay.walletconnect.org wss://relay.walletconnect.com wss://relay.walletconnect.org https://pulse.walletconnect.com https://pulse.walletconnect.org https://api.web3modal.com https://api.web3modal.org wss://www.walletlink.org https://o1095249.ingest.sentry.io https://quote-api.jup.ag;
connect-src 'self' https://react-wallet.walletconnect.com https://rpc.walletconnect.com https://rpc.walletconnect.org https://relay.walletconnect.com https://relay.walletconnect.org wss://relay.walletconnect.com wss://relay.walletconnect.org https://pulse.walletconnect.com https://pulse.walletconnect.org https://api.web3modal.com https://api.web3modal.org wss://www.walletlink.org https://o1095249.ingest.sentry.io https://quote-api.jup.ag http://localhost:8787;
frame-src 'self' https://verify.walletconnect.com https://verify.walletconnect.org https://secure.walletconnect.com https://secure.walletconnect.org https://secure.reown.com https://widget.solflare.com/ ${secureSiteDomain}/;
object-src 'none';
base-uri 'self';
Expand Down
18 changes: 18 additions & 0 deletions apps/laboratory/src/components/AppKitAuthInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client'

import * as React from 'react'

import { AppKitInfo } from './AppKitInfo'
import { useSiweSession } from '@reown/appkit-siwe/react'

export function AppKitAuthInfo() {
const { session, status } = useSiweSession()

return (
<AppKitInfo
address={session?.address}
chainId={session?.chainId}
heading={`SIWE status: ${status}`}
/>
)
}
13 changes: 10 additions & 3 deletions apps/laboratory/src/components/AppKitInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ type AppKitInfoProps = {
caipAddress?: string
address?: string
chainId?: number | string
clientId?: string
clientId?: string | null
heading?: string
}

export function AppKitInfo({ caipAddress, address, chainId, clientId }: AppKitInfoProps) {
export function AppKitInfo({
caipAddress,
address,
chainId,
clientId,
heading = 'Account Information'
}: AppKitInfoProps) {
return (
<Card marginTop={10} marginBottom={10}>
<CardHeader>
<Heading size="md">Account Information</Heading>
<Heading size="md">{heading}</Heading>
</CardHeader>

<CardBody>
Expand Down
2 changes: 1 addition & 1 deletion apps/laboratory/src/components/Siwe/SiweData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Text
} from '@chakra-ui/react'
import { useSession } from 'next-auth/react'
import type { SIWESession } from '@reown/appkit-siwe'
import type { SIWESession } from '@reown/appkit-siwe/react'

export function SiweData() {
const { data, status } = useSession()
Expand Down
6 changes: 5 additions & 1 deletion apps/laboratory/src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import nextAuth from 'next-auth'
import credentialsProvider from 'next-auth/providers/credentials'
import { type SIWESession, getChainIdFromMessage, getAddressFromMessage } from '@reown/appkit-siwe'
import {
type SIWESession,
getChainIdFromMessage,
getAddressFromMessage
} from '@reown/appkit-siwe/react'
import { verifySignature } from '../../../utils/SignatureUtil'

declare module 'next-auth' {
Expand Down
39 changes: 39 additions & 0 deletions apps/laboratory/src/pages/library/ethers-auth.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { createAppKit } from '@reown/appkit/react'
import { ThemeStore } from '../../utils/StoreUtil'
import { ConstantsUtil } from '../../utils/ConstantsUtil'
import { EthersTests } from '../../components/Ethers/EthersTests'
import { AppKitButtons } from '../../components/AppKitButtons'
import { SiweData } from '../../components/Siwe/SiweData'
import { EthersModalInfo } from '../../components/Ethers/EthersModalInfo'
import { EthersAdapter } from '@reown/appkit-adapter-ethers'
import { mainnet } from '@reown/appkit/networks'

const networks = ConstantsUtil.EvmNetworks

const ethersAdapter = new EthersAdapter()

const modal = createAppKit({
adapters: [ethersAdapter],
networks,
defaultNetwork: mainnet,
projectId: ConstantsUtil.ProjectId,
features: {
analytics: true,
socials: ['google', 'x', 'discord', 'farcaster', 'github', 'apple', 'facebook']
},
termsConditionsUrl: 'https://reown.com/terms-of-service',
privacyPolicyUrl: 'https://reown.com/privacy-policy'
})

ThemeStore.setModal(modal)

export default function Ethers() {
return (
<>
<AppKitButtons />
<EthersModalInfo />
<SiweData />
<EthersTests />
</>
)
}
46 changes: 46 additions & 0 deletions apps/laboratory/src/pages/library/wagmi-auth.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { createAppKit } from '@reown/appkit/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { WagmiProvider } from 'wagmi'
import { AppKitButtons } from '../../components/AppKitButtons'
import { WagmiTests } from '../../components/Wagmi/WagmiTests'
import { ThemeStore } from '../../utils/StoreUtil'
import { ConstantsUtil } from '../../utils/ConstantsUtil'
import { SiweData } from '../../components/Siwe/SiweData'
import { WagmiModalInfo } from '../../components/Wagmi/WagmiModalInfo'
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'
import { mainnet } from '@reown/appkit/networks'

const queryClient = new QueryClient()

const networks = ConstantsUtil.EvmNetworks

const wagmiAdapter = new WagmiAdapter({
ssr: true,
networks,
projectId: ConstantsUtil.ProjectId
})

const modal = createAppKit({
adapters: [wagmiAdapter],
networks,
defaultNetwork: mainnet,
projectId: ConstantsUtil.ProjectId,
features: {
analytics: true
}
})

ThemeStore.setModal(modal)

export default function Wagmi() {
return (
<WagmiProvider config={wagmiAdapter.wagmiConfig}>
<QueryClientProvider client={queryClient}>
<AppKitButtons />
<WagmiModalInfo />
<SiweData />
<WagmiTests />
</QueryClientProvider>
</WagmiProvider>
)
}
12 changes: 12 additions & 0 deletions apps/laboratory/src/utils/DataUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export const wagmiSdkOptions: SdkOption[] = [
link: '/library/wagmi-siwe/',
description: 'Configuration using wagmi and implementing sign in with ethereum'
},
{
title: 'AppKit Auth - Hosted SIWE',
link: '/library/wagmi-auth/',
description:
'Configuration using wagmi and implementing sign in with ethereum with a hosted server'
},
{
title: 'Without Email',
link: '/library/wagmi-no-email/',
Expand Down Expand Up @@ -69,6 +75,12 @@ export const ethersSdkOptions: SdkOption[] = [
link: '/library/ethers-siwe/',
description: 'Configuration using ethers and implementing sign in with ethereum'
},
{
title: 'AppKit Auth - Hosted SIWE',
link: '/library/ethers-auth/',
description:
'Configuration using ethers and implementing sign in with ethereum with a hosted server'
},
{
title: 'Without Email',
link: '/library/ethers-no-email/',
Expand Down
16 changes: 8 additions & 8 deletions apps/laboratory/src/utils/SiweUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { getCsrfToken, signIn, signOut, getSession } from 'next-auth/react'
import type { SIWEVerifyMessageArgs, SIWECreateMessageArgs, SIWESession } from '@reown/appkit-siwe'
import { createSIWEConfig, formatMessage } from '@reown/appkit-siwe'
import { ConstantsUtil } from './ConstantsUtil'

const chains = ConstantsUtil.EvmNetworks
import type {
SIWECreateMessageArgs,
SIWESession,
SIWEVerifyMessageArgs
} from '@reown/appkit-siwe/react'
import { createSIWEConfig, formatMessage } from '@reown/appkit-siwe/react'
import { getCsrfToken, getSession, signIn, signOut } from 'next-auth/react'

export const siweConfig = createSIWEConfig({
signOutOnAccountChange: true,
Expand All @@ -13,7 +14,6 @@ export const siweConfig = createSIWEConfig({
getMessageParams: async () => ({
domain: window.location.host,
uri: window.location.origin,
chains: chains.map(chain => chain.id as number),
statement: 'Please sign with your account',
iat: new Date().toISOString()
}),
Expand All @@ -29,7 +29,7 @@ export const siweConfig = createSIWEConfig({
getSession: async () => {
const session = await getSession()
if (!session) {
throw new Error('Failed to get session!')
return null
}

const { address, chainId } = session as unknown as SIWESession
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ModalFixture } from './w3m-fixture'
import { ModalPage } from '../pages/ModalPage'
import { timingFixture } from './timing-fixture'
import type { ModalFixture } from './w3m-fixture'

export const testMExternal = timingFixture.extend<ModalFixture>({
library: ['wagmi', { option: true }],
Expand Down
9 changes: 2 additions & 7 deletions apps/laboratory/tests/shared/utils/project.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { devices } from '@playwright/test'
import { DESKTOP_DEVICES, MOBILE_DEVICES } from '../constants/devices'

const LIBRARIES = ['ethers', 'ethers5', 'wagmi', 'solana'] as const
const MULTICHAIN_LIBRARIES = [
'multichain-basic',
'multichain-ethers-solana',
'multichain-ethers5-solana',
'multichain-wagmi-solana'
] as const
const LIBRARIES = ['wagmi', 'solana'] as const
const MULTICHAIN_LIBRARIES = ['multichain-basic', 'multichain-wagmi-solana'] as const

const LIBRARY_PERMUTATIONS = DESKTOP_DEVICES.flatMap(device =>
LIBRARIES.map(library => ({ device, library }))
Expand Down
6 changes: 3 additions & 3 deletions apps/laboratory/tests/shared/validators/ModalValidator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from '@playwright/test'
import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'
import type { CaipNetworkId } from '@reown/appkit'
import { ConstantsUtil } from '../../../src/utils/ConstantsUtil'
import { getMaximumWaitConnections } from '../utils/timeouts'
import { verifySignature } from '../../../src/utils/SignatureUtil'
import type { CaipNetworkId } from '@reown/appkit'
import { getMaximumWaitConnections } from '../utils/timeouts'

const MAX_WAIT = getMaximumWaitConnections()

Expand Down
Loading