Skip to content

Commit 1fccc06

Browse files
chore: do not store signer key
1 parent 10cf966 commit 1fccc06

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useFrameAppNotificationsManagerContext } from "../providers/FrameAppNot
99
import type { GETEventsResponseBody } from "../notifications/[namespaceId]/events/route";
1010
import { Button } from "@/components/ui/button";
1111
import { WithTooltip } from "./with-tooltip";
12-
import { UseFrameAppInIframeReturn } from "@frames.js/render/src/frame-app/iframe";
12+
import type { UseFrameAppInIframeReturn } from "@frames.js/render/frame-app/iframe";
1313

1414
type FrameAppDebuggerNotificationsProps = {
1515
frameApp: Extract<UseFrameAppInIframeReturn, { status: "success" }>;

packages/debugger/app/notifications/[namespaceId]/route.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,32 @@ export type NotificationUrl = {
1919

2020
export type Notification = Omit<SendNotificationRequest, "tokens">;
2121

22+
const privateKeyParser = z
23+
.string()
24+
.min(1)
25+
.startsWith("0x")
26+
.transform((val) => hexToBytes(val as Hex));
27+
2228
const postRequestBodySchema = z.discriminatedUnion("action", [
2329
z.object({
2430
action: z.literal("add_frame"),
31+
privateKey: privateKeyParser,
2532
}),
2633
z.object({
2734
action: z.literal("remove_frame"),
35+
privateKey: privateKeyParser,
2836
}),
2937
z.object({
3038
action: z.literal("enable_notifications"),
39+
privateKey: privateKeyParser,
3140
}),
3241
z.object({
3342
action: z.literal("disable_notifications"),
43+
privateKey: privateKeyParser,
3444
}),
3545
]);
3646

37-
export type POSTNotificationsDetailRequestBody = z.infer<
47+
export type POSTNotificationsDetailRequestBody = z.input<
3848
typeof postRequestBodySchema
3949
>;
4050

@@ -80,8 +90,6 @@ export async function POST(
8090
return Response.json({ message: "Not found" }, { status: 404 });
8191
}
8292

83-
const privateKey = hexToBytes(namespace.signerPrivateKey as Hex);
84-
8593
switch (requestBody.data.action) {
8694
case "add_frame": {
8795
const notificationDetails = await storage.addFrame(namespace);
@@ -102,7 +110,7 @@ export async function POST(
102110
};
103111

104112
sendEvent(event, {
105-
privateKey,
113+
privateKey: requestBody.data.privateKey,
106114
fid: namespace.fid,
107115
webhookUrl: namespace.webhookUrl,
108116
})
@@ -156,7 +164,7 @@ export async function POST(
156164

157165
sendEvent(event, {
158166
fid: namespace.fid,
159-
privateKey,
167+
privateKey: requestBody.data.privateKey,
160168
webhookUrl: namespace.webhookUrl,
161169
})
162170
.then(() => {
@@ -212,7 +220,7 @@ export async function POST(
212220

213221
sendEvent(event, {
214222
fid: namespace.fid,
215-
privateKey,
223+
privateKey: requestBody.data.privateKey,
216224
webhookUrl: namespace.webhookUrl,
217225
})
218226
.then(() => {
@@ -267,7 +275,7 @@ export async function POST(
267275

268276
sendEvent(event, {
269277
fid: namespace.fid,
270-
privateKey,
278+
privateKey: requestBody.data.privateKey,
271279
webhookUrl: namespace.webhookUrl,
272280
})
273281
.then(() => {

packages/debugger/app/notifications/route.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
const postRequestBodySchema = z.object({
1111
fid: z.coerce.number().int().positive(),
1212
frameAppUrl: z.string().url(),
13-
signerPrivateKey: z.string().min(1),
1413
webhookUrl: z.string().url(),
1514
});
1615

@@ -35,7 +34,7 @@ export async function POST(req: NextRequest) {
3534
}
3635

3736
const redis = createRedis();
38-
const { fid, frameAppUrl, signerPrivateKey, webhookUrl } = body.data;
37+
const { fid, frameAppUrl, webhookUrl } = body.data;
3938
const storage = new RedisNotificationsStorage(redis, req.nextUrl.href);
4039

4140
// Create new namespace
@@ -44,7 +43,6 @@ export async function POST(req: NextRequest) {
4443
const namespace = await storage.registerNamespace(namespaceId, {
4544
fid,
4645
frameAppUrl,
47-
signerPrivateKey,
4846
webhookUrl,
4947
});
5048

packages/debugger/app/notifications/storage.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ type NotificationsNamespace = {
88
id: string;
99
fid: number;
1010
frameAppUrl: string;
11-
signerPrivateKey: string;
1211
namespaceUrl: string;
1312
webhookUrl: string;
1413
frame:
@@ -32,15 +31,13 @@ export class RedisNotificationsStorage {
3231
params: {
3332
fid: number;
3433
frameAppUrl: string;
35-
signerPrivateKey: string;
3634
webhookUrl: string;
3735
}
3836
) {
3937
const namespace: NotificationsNamespace = {
4038
id,
4139
fid: params.fid,
4240
frameAppUrl: params.frameAppUrl,
43-
signerPrivateKey: params.signerPrivateKey,
4441
namespaceUrl: new URL(`/notifications/${id}`, this.serverUrl).toString(),
4542
webhookUrl: params.webhookUrl,
4643
frame: {

packages/debugger/app/providers/FrameAppNotificationsManagerProvider.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export function useFrameAppNotificationsManager({
127127
body: JSON.stringify({
128128
fid: signer.fid,
129129
frameAppUrl: frameUrl,
130-
signerPrivateKey: signer.privateKey,
131130
webhookUrl,
132131
} satisfies POSTNotificationsRequestBody),
133132
});
@@ -162,6 +161,7 @@ export function useFrameAppNotificationsManager({
162161
async addFrame() {
163162
const result = await sendEvent.mutateAsync({
164163
action: "add_frame",
164+
privateKey: signer.privateKey,
165165
});
166166

167167
if (result.type !== "frame_added") {
@@ -178,6 +178,7 @@ export function useFrameAppNotificationsManager({
178178
async removeFrame() {
179179
await sendEvent.mutateAsync({
180180
action: "remove_frame",
181+
privateKey: signer.privateKey,
181182
});
182183

183184
// refetch notification settings
@@ -188,6 +189,7 @@ export function useFrameAppNotificationsManager({
188189
async enableNotifications() {
189190
const result = await sendEvent.mutateAsync({
190191
action: "enable_notifications",
192+
privateKey: signer.privateKey,
191193
});
192194

193195
// refetch notification settings
@@ -204,6 +206,7 @@ export function useFrameAppNotificationsManager({
204206
async disableNotifications() {
205207
await sendEvent.mutateAsync({
206208
action: "disable_notifications",
209+
privateKey: signer.privateKey,
207210
});
208211

209212
// refetch notification settings

0 commit comments

Comments
 (0)