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: Use Magic OAuth V2 to log in #121

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 21 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"@dcl/schemas": "^9.8.0",
"@dcl/single-sign-on-client": "^0.1.0",
"@dcl/ui-env": "^1.4.0",
"@magic-ext/oauth": "^15.1.1",
"@magic-ext/oauth": "^22.16.0",
"@magic-ext/oauth2": "^9.16.0",
"@well-known-components/fetch-component": "^2.0.2",
"ajv": "^8.12.0",
"classnames": "^2.3.2",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Pages/CallbackPage/CallbackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export const CallbackPage = () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/naming-convention
const { OAuthExtension } = await import('@magic-ext/oauth')
const { OAuthExtension } = await import('@magic-ext/oauth2')

const magic = new Magic(MAGIC_KEY, {
extensions: [new OAuthExtension()]
})

try {
setConnectionModalState(ConnectionModalState.VALIDATING_SIGN_IN)
await magic?.oauth.getRedirectResult()
await magic?.oauth2.getRedirectResult()
setConnectionModalState(ConnectionModalState.WAITING_FOR_CONFIRMATION)
} catch (error) {
console.log(error)
Expand Down
6 changes: 3 additions & 3 deletions src/components/Pages/LoginPage/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OAuthProvider } from '@magic-ext/oauth'
import type { OAuthProvider } from '@magic-ext/oauth2'
import { ethers } from 'ethers'
import { AuthIdentity, Authenticator } from '@dcl/crypto'
import { ProviderType } from '@dcl/schemas/dist/dapps/provider-type'
Expand Down Expand Up @@ -57,15 +57,15 @@ export async function connectToProvider(connectionOption: ConnectionOptionType):
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/naming-convention
const { OAuthExtension } = await import('@magic-ext/oauth')
const { OAuthExtension } = await import('@magic-ext/oauth2')
const magic = new Magic(MAGIC_KEY, {
extensions: [new OAuthExtension()]
})

const url = new URL(window.location.href)
url.pathname = '/auth/callback'

await magic.oauth.loginWithRedirect({
await magic?.oauth2.loginWithRedirect({
provider: connectionOption === ConnectionOptionType.X ? 'twitter' : (connectionOption as OAuthProvider),
redirectURI: url.href
})
Expand Down
Loading