From 330a22a4b27f0377aaf90dce273a35f328ebb7c7 Mon Sep 17 00:00:00 2001
From: Jaume Alavedra
Date: Tue, 26 Nov 2024 10:58:54 +0100
Subject: [PATCH] fix: session key
---
.../AccountRecovery.tsx | 10 ++--
.../auth-sample/src/components/Logout.tsx | 7 ++-
.../SessionKey/BackendMintButton.tsx | 2 +
.../SessionKey/EIP1193CreateSessionButton.tsx | 7 ++-
.../auth-sample/src/pages/forgot-password.tsx | 4 +-
examples/apps/auth-sample/src/pages/index.tsx | 1 -
examples/apps/auth-sample/src/pages/login.tsx | 55 +++++++++++--------
.../apps/auth-sample/src/pages/register.tsx | 37 +++++++------
sdk/src/evm/evmProvider.ts | 2 +-
sdk/src/evm/registerSession.ts | 47 ++++++++++++++--
10 files changed, 115 insertions(+), 57 deletions(-)
diff --git a/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx b/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx
index 790f9cf7..d6e99297 100644
--- a/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx
+++ b/examples/apps/auth-sample/src/components/EmbeddedSignerRecovery/AccountRecovery.tsx
@@ -1,6 +1,7 @@
import {useState} from 'react';
import {useOpenfort} from '../../hooks/useOpenfort';
import Loading from '../Loading';
+import { Button } from '../ui/button';
const AccountRecovery: React.FC = () => {
const {handleRecovery} = useOpenfort();
@@ -21,7 +22,7 @@ const AccountRecovery: React.FC = () => {
-
+
@@ -48,7 +49,8 @@ const AccountRecovery: React.FC = () => {
-
+
diff --git a/examples/apps/auth-sample/src/components/Logout.tsx b/examples/apps/auth-sample/src/components/Logout.tsx
index 1325dac2..04d5e913 100644
--- a/examples/apps/auth-sample/src/components/Logout.tsx
+++ b/examples/apps/auth-sample/src/components/Logout.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import {useOpenfort} from '../hooks/useOpenfort';
import {useRouter} from 'next/router';
+import { Button } from './ui/button';
const LogoutButton: React.FC = () => {
const {logout} = useOpenfort();
@@ -16,12 +17,12 @@ const LogoutButton: React.FC = () => {
};
return (
-
+
);
};
diff --git a/examples/apps/auth-sample/src/components/SessionKey/BackendMintButton.tsx b/examples/apps/auth-sample/src/components/SessionKey/BackendMintButton.tsx
index 67f60e47..1097dcb2 100644
--- a/examples/apps/auth-sample/src/components/SessionKey/BackendMintButton.tsx
+++ b/examples/apps/auth-sample/src/components/SessionKey/BackendMintButton.tsx
@@ -4,6 +4,7 @@ import openfort from '../../utils/openfortConfig';
import { Button } from '../ui/button';
import { privateKeyToAccount } from 'viem/accounts';
import { createWalletClient, http } from 'viem';
+import { polygonAmoy } from 'viem/chains';
const BackendMintButton: React.FC<{
handleSetMessage: (message: string) => void;
@@ -30,6 +31,7 @@ const BackendMintButton: React.FC<{
const collectResponseJSON = await collectResponse.json();
const walletClient = createWalletClient({
account: privateKeyToAccount(sessionKey),
+ chain: polygonAmoy,
transport: http()
})
const signature = await walletClient.signMessage({message: {raw: collectResponseJSON.userOperationHash}});
diff --git a/examples/apps/auth-sample/src/components/SessionKey/EIP1193CreateSessionButton.tsx b/examples/apps/auth-sample/src/components/SessionKey/EIP1193CreateSessionButton.tsx
index f186816e..5d66f854 100644
--- a/examples/apps/auth-sample/src/components/SessionKey/EIP1193CreateSessionButton.tsx
+++ b/examples/apps/auth-sample/src/components/SessionKey/EIP1193CreateSessionButton.tsx
@@ -34,7 +34,12 @@ const EIP1193CreateSessionButton: React.FC<{
}).extend(erc7715Actions())
const [account] = await walletClient.getAddresses()
await walletClient.grantPermissions({
- account: accountSession,
+ signer:{
+ type: "account",
+ data:{
+ id: accountSession
+ }
+ },
expiry: 60 * 60 * 24,
permissions: [
{
diff --git a/examples/apps/auth-sample/src/pages/forgot-password.tsx b/examples/apps/auth-sample/src/pages/forgot-password.tsx
index 10c43504..bda26266 100644
--- a/examples/apps/auth-sample/src/pages/forgot-password.tsx
+++ b/examples/apps/auth-sample/src/pages/forgot-password.tsx
@@ -5,7 +5,6 @@ import Link from 'next/link';
import {useRouter} from 'next/router';
import {AuthLayout} from '../components/Layouts/AuthLayout';
-import {Button} from '../components/Button';
import {TextField} from '../components/Fields';
import {StatusType, Toast} from '../components/Toasts';
@@ -13,6 +12,7 @@ import {StatusType, Toast} from '../components/Toasts';
import openfort from '../utils/openfortConfig';
import {getURL} from '../utils/getUrl';
import {AuthPlayerResponse} from '@openfort/openfort-js';
+import { Button } from '@/components/ui/button';
function ForgotPasswordPage() {
const router = useRouter();
@@ -99,7 +99,7 @@ function ForgotPasswordPage() {
required
/>
-
- {' '}
diff --git a/examples/apps/auth-sample/src/pages/login.tsx b/examples/apps/auth-sample/src/pages/login.tsx
index 11567c7a..75d4bdec 100644
--- a/examples/apps/auth-sample/src/pages/login.tsx
+++ b/examples/apps/auth-sample/src/pages/login.tsx
@@ -3,7 +3,6 @@ import Head from 'next/head';
import Link from 'next/link';
import {useRouter} from 'next/router';
import {AuthLayout} from '../components/Layouts/AuthLayout';
-import {Button, LinkButton} from '../components/Button';
import {TextField} from '../components/Fields';
import {StatusType, Toast} from '../components/Toasts';
import openfort from '../utils/openfortConfig';
@@ -11,8 +10,8 @@ import {getURL} from '../utils/getUrl';
import {
AuthPlayerResponse,
OAuthProvider,
- ThirdPartyOAuthProvider,
} from '@openfort/openfort-js';
+import { Button } from '@/components/ui/button';
function LoginPage() {
const router = useRouter();
@@ -115,7 +114,7 @@ function LoginPage() {
}
>
) : (