Skip to content

Commit 688d7a6

Browse files
chore: add alert on unsupported signer state
1 parent cdbed94 commit 688d7a6

3 files changed

Lines changed: 52 additions & 9 deletions

File tree

packages/debugger/app/components/frame-app-notifications-control-panel.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
InfoIcon,
99
Loader2Icon,
1010
RefreshCwIcon,
11+
ShieldAlertIcon,
1112
} from "lucide-react";
1213
import { useFrameAppNotificationsManagerContext } from "../providers/FrameAppNotificationsManagerProvider";
1314
import { useCallback, useState } from "react";
@@ -94,7 +95,7 @@ export function FrameAppNotificationsControlPanel({
9495
);
9596

9697
return (
97-
<div className="flex flex-col gap-2 w-full border rounded-lg p-2">
98+
<div className="flex flex-col gap-4 w-full border rounded-lg p-2">
9899
<h3 className="font-semibold">
99100
Client settings
100101
<WithTooltip tooltip="Reload settings">
@@ -114,6 +115,17 @@ export function FrameAppNotificationsControlPanel({
114115
</Button>
115116
</WithTooltip>
116117
</h3>
118+
{!window.location.origin.match(/^https?:\/\/(localhost|127.0.0.1)/) && (
119+
<Alert variant="destructive">
120+
<ShieldAlertIcon className="h-[1em] w-[1em]"></ShieldAlertIcon>
121+
<AlertTitle>Be careful!</AlertTitle>
122+
<AlertDescription>
123+
At the moment we&apos;re sending your signer private key to the
124+
backend to sign event payload sent to webhook. We aren&apos;t
125+
storing your private key.
126+
</AlertDescription>
127+
</Alert>
128+
)}
117129
{isAddedToClient ? (
118130
<>
119131
<div className="flex gap-2 items-center">

packages/debugger/app/components/frame-debugger-diagnostics.tsx

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@ import {
44
getFrameV2Flattened,
55
type ParsingReport,
66
} from "frames.js";
7-
import {
8-
AlertTriangleIcon,
9-
CheckCircle2Icon,
10-
XCircleIcon,
11-
AlertTriangle,
12-
} from "lucide-react";
7+
import { AlertTriangleIcon, CheckCircle2Icon, XCircleIcon } from "lucide-react";
138
import { useMemo } from "react";
149
import { ShortenedText } from "./shortened-text";
1510
import type { DebuggerFrameStackItem } from "../hooks/useDebuggerFrameState";
1611
import { cn } from "@/lib/utils";
1712
import type { ProtocolConfiguration } from "./protocol-config-button";
1813
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
14+
import type { FarcasterSigner } from "@frames.js/render/identity/farcaster";
1915

2016
type FrameDebuggerDiagnosticsProps = {
2117
stackItem: DebuggerFrameStackItem;
2218
protocol: ProtocolConfiguration;
19+
farcasterSigner: FarcasterSigner | null;
2320
};
2421

2522
function isPropertyExperimental([key, value]: [string, string]) {
@@ -30,6 +27,7 @@ function isPropertyExperimental([key, value]: [string, string]) {
3027
export function FrameDebuggerDiagnostics({
3128
stackItem,
3229
protocol,
30+
farcasterSigner,
3331
}: FrameDebuggerDiagnosticsProps) {
3432
const properties = useMemo(() => {
3533
/** tuple of key and value */
@@ -121,6 +119,10 @@ export function FrameDebuggerDiagnostics({
121119
stackItem={stackItem}
122120
protocol={protocol}
123121
/>
122+
<FarcasterV2DoesNotSupportImpersonatedSignersAlert
123+
protocol={protocol}
124+
farcasterSigner={farcasterSigner}
125+
/>
124126
<Table>
125127
<TableBody>
126128
<TableRow>
@@ -237,7 +239,7 @@ function TryDifferentFarcasterSpecificationAlert({
237239
) {
238240
return (
239241
<Alert className="mb-4" variant="destructive">
240-
<AlertTriangle className="h-4 w-4" />
242+
<AlertTriangleIcon className="h-4 w-4" />
241243
<AlertTitle>Warning!</AlertTitle>
242244
<AlertDescription>
243245
This frame appears to be Farcaster v1 compatible only. Try parsing
@@ -257,7 +259,7 @@ function TryDifferentFarcasterSpecificationAlert({
257259
) {
258260
return (
259261
<Alert className="mb-4" variant="destructive">
260-
<AlertTriangle className="h-4 w-4" />
262+
<AlertTriangleIcon className="h-4 w-4" />
261263
<AlertTitle>Warning!</AlertTitle>
262264
<AlertDescription>
263265
This frame appears to be Farcaster v2 compatible only. Try parsing it
@@ -269,3 +271,31 @@ function TryDifferentFarcasterSpecificationAlert({
269271

270272
return null;
271273
}
274+
275+
type FarcasterV2DoesNotSupportImpersonatedSignersAlertProps = {
276+
farcasterSigner: FarcasterSigner | null;
277+
protocol: ProtocolConfiguration;
278+
};
279+
280+
function FarcasterV2DoesNotSupportImpersonatedSignersAlert({
281+
protocol,
282+
farcasterSigner: signer,
283+
}: FarcasterV2DoesNotSupportImpersonatedSignersAlertProps) {
284+
if (protocol.protocol !== "farcaster_v2") {
285+
return null;
286+
}
287+
288+
if (signer?.status !== "impersonating") {
289+
return;
290+
}
291+
292+
return (
293+
<Alert className="mb-4" variant="destructive">
294+
<AlertTriangleIcon className="h-4 w-4" />
295+
<AlertTitle>Unsupported farcaster signer</AlertTitle>
296+
<AlertDescription>
297+
Please use approved signer because impersonated signer is not supported.
298+
</AlertDescription>
299+
</Alert>
300+
);
301+
}

packages/debugger/app/components/frame-debugger.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export const FrameDebugger = React.forwardRef<
470470
</TabsList>
471471
<TabsContent className="overflow-y-auto" value="diagnostics">
472472
<FrameDebuggerDiagnostics
473+
farcasterSigner={farcasterSignerState.signer}
473474
stackItem={currentFrameStackItem}
474475
protocol={protocol}
475476
/>

0 commit comments

Comments
 (0)