Skip to content

Commit 675a210

Browse files
fix(sdk): added debug on mobile for mm login
1 parent f85b580 commit 675a210

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React, { useState, useEffect } from "react";
2+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
3+
import { authenticateAndAuthorize } from "@site/src/lib/siwsrp/auth";
4+
import { REQUEST_PARAMS } from "@site/src/lib/constants";
5+
6+
const DebugAuth = () => {
7+
const [ userData, setUserData ] = useState({
8+
accessToken: null,
9+
userProfile: null,
10+
data: null,
11+
session: null,
12+
token: null
13+
});
14+
const { siteConfig } = useDocusaurusContext();
15+
const { DASHBOARD_URL, VERCEL_ENV } = siteConfig?.customFields || {};
16+
const fetchLoginData = async () => {
17+
const { accessToken, userProfile } = await authenticateAndAuthorize(
18+
VERCEL_ENV as string,
19+
);
20+
setUserData(prev => ({...prev, accessToken, userProfile}));
21+
const loginResponse = await (
22+
await fetch(
23+
`${DASHBOARD_URL}/api/wallet/login`,
24+
{
25+
...REQUEST_PARAMS("POST", {
26+
hydra_token: accessToken,
27+
token: "true",
28+
}),
29+
body: JSON.stringify({
30+
profileId: userProfile.profileId,
31+
redirect_to: window.location.href,
32+
}),
33+
},
34+
)
35+
).json();
36+
const { data, session, token } = loginResponse;
37+
setUserData(prev => ({...prev, data, session, token}));
38+
};
39+
40+
return (
41+
<div>
42+
<button onClick={fetchLoginData}>user</button>
43+
<div>
44+
{JSON.stringify(userData, null, 2)}
45+
</div>
46+
</div>
47+
)
48+
};
49+
50+
export default DebugAuth;

src/lib/siwsrp/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export const authenticateAndAuthorize = async (env: string) => {
7272
await auth(env).connectSnap();
7373
accessToken = await auth(env).getAccessToken();
7474
userProfile = await auth(env).getUserProfile();
75+
console.log("data__", accessToken)
7576
} catch (e: any) {
77+
console.log("error__", e)
7678
throw new Error(e.message);
7779
}
7880

wallet/reference/new-reference.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ sidebar_class_name: "hidden"
77

88
import ParserOpenRPC from "@site/src/components/ParserOpenRPC"
99
import { NETWORK_NAMES } from "@site/src/plugins/plugin-json-rpc"
10+
import DebugAuth from "@site/src/components/AuthLogin/DebugAuth"
1011

12+
<DebugAuth />
1113
<ParserOpenRPC
1214
network={NETWORK_NAMES.linea}
1315
method="eth_sendRawTransaction"

0 commit comments

Comments
 (0)