Skip to content

Commit

Permalink
chore: ignore siwe types
Browse files Browse the repository at this point in the history
Co-authored-by: MK <mago.khamidov@gmail.com>
  • Loading branch information
DanielSinclair and magiziz committed May 28, 2024
1 parent 320403a commit d9bc805
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/with-next-siwe-iron-session/pages/api/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try {
const { message, signature } = req.body;
const siweMessage = createSiweMessage(message);
// TODO: remove @ts-ignore
// @ts-ignore
const { success, error, data } = await siweMessage.verify({
signature,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,27 @@ export function getAuthOptions(req: IncomingMessage): NextAuthOptions {
}

const nextAuthHost = new URL(nextAuthUrl).host;
// TODO: remove @ts-ignore
// @ts-ignore
if (siwe.domain !== nextAuthHost) {
return null;
}

if (
// TODO: remove @ts-ignore
// @ts-ignore
siwe.nonce !==
(await getCsrfToken({ req: { headers: req.headers } }))
) {
return null;
}

// TODO: remove @ts-ignore
// @ts-ignore
await siwe.verify({ signature: credentials?.signature || '' });
return {
// TODO: remove @ts-ignore
// @ts-ignore
id: siwe.address,
};
} catch (e) {
Expand Down
8 changes: 8 additions & 0 deletions packages/example/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,27 @@ export function getAuthOptions(req: IncomingMessage): NextAuthOptions {
}

const nextAuthHost = new URL(nextAuthUrl).host;
// TODO: remove @ts-ignore
// @ts-ignore
if (siwe.domain !== nextAuthHost) {
return null;
}

if (
// TODO: remove @ts-ignore
// @ts-ignore
siwe.nonce !==
(await getCsrfToken({ req: { headers: req.headers } }))
) {
return null;
}

// TODO: remove @ts-ignore
// @ts-ignore
await siwe.verify({ signature: credentials?.signature || '' });
return {
// TODO: remove @ts-ignore
// @ts-ignore
id: siwe.address,
};
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function RainbowKitSiweNextAuthProvider({

// Spread unconfigurable options last so they can't be overridden
...unconfigurableOptions,
});
} as CreateSiweMessageParameters);
},

getNonce: async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/rainbowkit/src/components/SignIn/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export function SignIn({
setState((x) => ({ ...x, status: 'verifying' }));

try {
// TODO: remove @ts-ignore
// @ts-ignore
const verified = await authAdapter.verify({ message, signature });

if (verified) {
Expand Down

0 comments on commit d9bc805

Please sign in to comment.