@farcaster/frame-core 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/schemas/embeds.d.ts +178 -0
- package/dist/schemas/embeds.js +21 -0
- package/dist/schemas/events.d.ts +131 -0
- package/dist/schemas/events.js +22 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/manifest.d.ts +96 -0
- package/dist/schemas/manifest.js +15 -0
- package/dist/schemas/notifications.d.ts +60 -0
- package/dist/schemas/notifications.js +20 -0
- package/dist/schemas/shared.d.ts +32 -0
- package/dist/schemas/shared.js +14 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +33 -231
- package/dist/types.js +3 -52
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/schemas/embeds.ts +29 -0
- package/src/schemas/events.ts +47 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/manifest.ts +17 -0
- package/src/schemas/notifications.ts +35 -0
- package/src/schemas/shared.ts +23 -0
- package/src/types.ts +64 -121
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from "ox";
|
|
2
|
-
import {
|
|
2
|
+
import { FrameNotificationDetails } from "./schemas";
|
|
3
3
|
export type SetPrimaryButton = (options: {
|
|
4
4
|
text: string;
|
|
5
5
|
loading?: boolean;
|
|
@@ -14,7 +14,14 @@ export type AccountLocation = {
|
|
|
14
14
|
*/
|
|
15
15
|
description: string;
|
|
16
16
|
};
|
|
17
|
-
export type
|
|
17
|
+
export type FrameLocationContextCastEmbed = {
|
|
18
|
+
type: "cast_embed";
|
|
19
|
+
cast: {
|
|
20
|
+
fid: number;
|
|
21
|
+
hash: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type FrameLocationContextNotification = {
|
|
18
25
|
type: "notification";
|
|
19
26
|
notification: {
|
|
20
27
|
notificationId: string;
|
|
@@ -22,7 +29,10 @@ export type FrameLocationNotificationContext = {
|
|
|
22
29
|
body: string;
|
|
23
30
|
};
|
|
24
31
|
};
|
|
25
|
-
export type
|
|
32
|
+
export type FrameLocationContextLauncher = {
|
|
33
|
+
type: "launcher";
|
|
34
|
+
};
|
|
35
|
+
export type FrameLocationContext = FrameLocationContextCastEmbed | FrameLocationContextNotification | FrameLocationContextLauncher;
|
|
26
36
|
export type FrameContext = {
|
|
27
37
|
user: {
|
|
28
38
|
fid: number;
|
|
@@ -34,250 +44,42 @@ export type FrameContext = {
|
|
|
34
44
|
pfpUrl?: string;
|
|
35
45
|
};
|
|
36
46
|
location?: FrameLocationContext;
|
|
47
|
+
client: {
|
|
48
|
+
clientFid: number;
|
|
49
|
+
added: boolean;
|
|
50
|
+
notificationDetails?: FrameNotificationDetails;
|
|
51
|
+
};
|
|
37
52
|
};
|
|
38
|
-
export declare const notificationDetailsSchema: z.ZodObject<{
|
|
39
|
-
url: z.ZodString;
|
|
40
|
-
token: z.ZodString;
|
|
41
|
-
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
url: string;
|
|
43
|
-
token: string;
|
|
44
|
-
}, {
|
|
45
|
-
url: string;
|
|
46
|
-
token: string;
|
|
47
|
-
}>;
|
|
48
|
-
export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>;
|
|
49
53
|
export type AddFrameResult = {
|
|
50
54
|
added: true;
|
|
51
55
|
notificationDetails?: FrameNotificationDetails;
|
|
52
56
|
} | {
|
|
53
57
|
added: false;
|
|
54
|
-
reason: "
|
|
58
|
+
reason: "invalid_domain_manifest" | "rejected_by_user";
|
|
55
59
|
};
|
|
56
60
|
export type AddFrame = () => Promise<AddFrameResult>;
|
|
61
|
+
export type ReadyOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* Disable native gestures. Use this option if your frame uses gestures
|
|
64
|
+
* that conflict with native gestures.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue false
|
|
67
|
+
*/
|
|
68
|
+
disableNativeGestures: boolean;
|
|
69
|
+
};
|
|
70
|
+
export declare const DEFAULT_READY_OPTIONS: ReadyOptions;
|
|
57
71
|
export type FrameHost = {
|
|
58
72
|
context: FrameContext;
|
|
59
73
|
close: () => void;
|
|
60
|
-
ready: (options
|
|
61
|
-
/**
|
|
62
|
-
* Disable native gestures. Use this option if your frame uses gestures
|
|
63
|
-
* that conflict with native gestures.
|
|
64
|
-
*/
|
|
65
|
-
disableNativeGestures: boolean;
|
|
66
|
-
}>) => void;
|
|
74
|
+
ready: (options?: Partial<ReadyOptions>) => void;
|
|
67
75
|
openUrl: (url: string) => void;
|
|
68
76
|
setPrimaryButton: SetPrimaryButton;
|
|
69
77
|
ethProviderRequest: EthProviderRequest;
|
|
70
78
|
ethProviderRequestV2: RpcTransport;
|
|
71
79
|
addFrame: AddFrame;
|
|
72
80
|
};
|
|
73
|
-
export declare const eventSchema: z.ZodObject<{
|
|
74
|
-
header: z.ZodString;
|
|
75
|
-
payload: z.ZodString;
|
|
76
|
-
signature: z.ZodString;
|
|
77
|
-
}, "strip", z.ZodTypeAny, {
|
|
78
|
-
header: string;
|
|
79
|
-
payload: string;
|
|
80
|
-
signature: string;
|
|
81
|
-
}, {
|
|
82
|
-
header: string;
|
|
83
|
-
payload: string;
|
|
84
|
-
signature: string;
|
|
85
|
-
}>;
|
|
86
|
-
export type EventSchema = z.infer<typeof eventSchema>;
|
|
87
|
-
export declare const eventHeaderSchema: z.ZodObject<{
|
|
88
|
-
fid: z.ZodNumber;
|
|
89
|
-
type: z.ZodLiteral<"app_key">;
|
|
90
|
-
key: z.ZodString;
|
|
91
|
-
}, "strip", z.ZodTypeAny, {
|
|
92
|
-
type: "app_key";
|
|
93
|
-
fid: number;
|
|
94
|
-
key: string;
|
|
95
|
-
}, {
|
|
96
|
-
type: "app_key";
|
|
97
|
-
fid: number;
|
|
98
|
-
key: string;
|
|
99
|
-
}>;
|
|
100
|
-
export type EventHeader = z.infer<typeof eventHeaderSchema>;
|
|
101
|
-
export declare const eventFrameAddedPayloadSchema: z.ZodObject<{
|
|
102
|
-
event: z.ZodLiteral<"frame-added">;
|
|
103
|
-
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
104
|
-
url: z.ZodString;
|
|
105
|
-
token: z.ZodString;
|
|
106
|
-
}, "strip", z.ZodTypeAny, {
|
|
107
|
-
url: string;
|
|
108
|
-
token: string;
|
|
109
|
-
}, {
|
|
110
|
-
url: string;
|
|
111
|
-
token: string;
|
|
112
|
-
}>>;
|
|
113
|
-
}, "strip", z.ZodTypeAny, {
|
|
114
|
-
event: "frame-added";
|
|
115
|
-
notificationDetails?: {
|
|
116
|
-
url: string;
|
|
117
|
-
token: string;
|
|
118
|
-
} | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
event: "frame-added";
|
|
121
|
-
notificationDetails?: {
|
|
122
|
-
url: string;
|
|
123
|
-
token: string;
|
|
124
|
-
} | undefined;
|
|
125
|
-
}>;
|
|
126
|
-
export type EventFrameAddedPayload = z.infer<typeof eventFrameAddedPayloadSchema>;
|
|
127
|
-
export declare const eventFrameRemovedPayloadSchema: z.ZodObject<{
|
|
128
|
-
event: z.ZodLiteral<"frame-removed">;
|
|
129
|
-
}, "strip", z.ZodTypeAny, {
|
|
130
|
-
event: "frame-removed";
|
|
131
|
-
}, {
|
|
132
|
-
event: "frame-removed";
|
|
133
|
-
}>;
|
|
134
|
-
export type EventFrameRemovedPayload = z.infer<typeof eventFrameRemovedPayloadSchema>;
|
|
135
|
-
export declare const eventNotificationsEnabledPayloadSchema: z.ZodObject<{
|
|
136
|
-
event: z.ZodLiteral<"notifications-enabled">;
|
|
137
|
-
notificationDetails: z.ZodObject<{
|
|
138
|
-
url: z.ZodString;
|
|
139
|
-
token: z.ZodString;
|
|
140
|
-
}, "strip", z.ZodTypeAny, {
|
|
141
|
-
url: string;
|
|
142
|
-
token: string;
|
|
143
|
-
}, {
|
|
144
|
-
url: string;
|
|
145
|
-
token: string;
|
|
146
|
-
}>;
|
|
147
|
-
}, "strip", z.ZodTypeAny, {
|
|
148
|
-
event: "notifications-enabled";
|
|
149
|
-
notificationDetails: {
|
|
150
|
-
url: string;
|
|
151
|
-
token: string;
|
|
152
|
-
};
|
|
153
|
-
}, {
|
|
154
|
-
event: "notifications-enabled";
|
|
155
|
-
notificationDetails: {
|
|
156
|
-
url: string;
|
|
157
|
-
token: string;
|
|
158
|
-
};
|
|
159
|
-
}>;
|
|
160
|
-
export type EventNotificationsEnabledPayload = z.infer<typeof eventNotificationsEnabledPayloadSchema>;
|
|
161
|
-
export declare const notificationsDisabledPayloadSchema: z.ZodObject<{
|
|
162
|
-
event: z.ZodLiteral<"notifications-disabled">;
|
|
163
|
-
}, "strip", z.ZodTypeAny, {
|
|
164
|
-
event: "notifications-disabled";
|
|
165
|
-
}, {
|
|
166
|
-
event: "notifications-disabled";
|
|
167
|
-
}>;
|
|
168
|
-
export type EventNotificationsDisabledPayload = z.infer<typeof notificationsDisabledPayloadSchema>;
|
|
169
|
-
export declare const eventPayloadSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
170
|
-
event: z.ZodLiteral<"frame-added">;
|
|
171
|
-
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
172
|
-
url: z.ZodString;
|
|
173
|
-
token: z.ZodString;
|
|
174
|
-
}, "strip", z.ZodTypeAny, {
|
|
175
|
-
url: string;
|
|
176
|
-
token: string;
|
|
177
|
-
}, {
|
|
178
|
-
url: string;
|
|
179
|
-
token: string;
|
|
180
|
-
}>>;
|
|
181
|
-
}, "strip", z.ZodTypeAny, {
|
|
182
|
-
event: "frame-added";
|
|
183
|
-
notificationDetails?: {
|
|
184
|
-
url: string;
|
|
185
|
-
token: string;
|
|
186
|
-
} | undefined;
|
|
187
|
-
}, {
|
|
188
|
-
event: "frame-added";
|
|
189
|
-
notificationDetails?: {
|
|
190
|
-
url: string;
|
|
191
|
-
token: string;
|
|
192
|
-
} | undefined;
|
|
193
|
-
}>, z.ZodObject<{
|
|
194
|
-
event: z.ZodLiteral<"frame-removed">;
|
|
195
|
-
}, "strip", z.ZodTypeAny, {
|
|
196
|
-
event: "frame-removed";
|
|
197
|
-
}, {
|
|
198
|
-
event: "frame-removed";
|
|
199
|
-
}>, z.ZodObject<{
|
|
200
|
-
event: z.ZodLiteral<"notifications-enabled">;
|
|
201
|
-
notificationDetails: z.ZodObject<{
|
|
202
|
-
url: z.ZodString;
|
|
203
|
-
token: z.ZodString;
|
|
204
|
-
}, "strip", z.ZodTypeAny, {
|
|
205
|
-
url: string;
|
|
206
|
-
token: string;
|
|
207
|
-
}, {
|
|
208
|
-
url: string;
|
|
209
|
-
token: string;
|
|
210
|
-
}>;
|
|
211
|
-
}, "strip", z.ZodTypeAny, {
|
|
212
|
-
event: "notifications-enabled";
|
|
213
|
-
notificationDetails: {
|
|
214
|
-
url: string;
|
|
215
|
-
token: string;
|
|
216
|
-
};
|
|
217
|
-
}, {
|
|
218
|
-
event: "notifications-enabled";
|
|
219
|
-
notificationDetails: {
|
|
220
|
-
url: string;
|
|
221
|
-
token: string;
|
|
222
|
-
};
|
|
223
|
-
}>, z.ZodObject<{
|
|
224
|
-
event: z.ZodLiteral<"notifications-disabled">;
|
|
225
|
-
}, "strip", z.ZodTypeAny, {
|
|
226
|
-
event: "notifications-disabled";
|
|
227
|
-
}, {
|
|
228
|
-
event: "notifications-disabled";
|
|
229
|
-
}>]>;
|
|
230
|
-
export type FrameEvent = z.infer<typeof eventPayloadSchema>;
|
|
231
|
-
export declare const sendNotificationRequestSchema: z.ZodObject<{
|
|
232
|
-
notificationId: z.ZodString;
|
|
233
|
-
title: z.ZodString;
|
|
234
|
-
body: z.ZodString;
|
|
235
|
-
targetUrl: z.ZodString;
|
|
236
|
-
tokens: z.ZodArray<z.ZodString, "many">;
|
|
237
|
-
}, "strip", z.ZodTypeAny, {
|
|
238
|
-
notificationId: string;
|
|
239
|
-
title: string;
|
|
240
|
-
body: string;
|
|
241
|
-
targetUrl: string;
|
|
242
|
-
tokens: string[];
|
|
243
|
-
}, {
|
|
244
|
-
notificationId: string;
|
|
245
|
-
title: string;
|
|
246
|
-
body: string;
|
|
247
|
-
targetUrl: string;
|
|
248
|
-
tokens: string[];
|
|
249
|
-
}>;
|
|
250
|
-
export type SendNotificationRequest = z.infer<typeof sendNotificationRequestSchema>;
|
|
251
|
-
export declare const sendNotificationResponseSchema: z.ZodObject<{
|
|
252
|
-
result: z.ZodObject<{
|
|
253
|
-
successfulTokens: z.ZodArray<z.ZodString, "many">;
|
|
254
|
-
invalidTokens: z.ZodArray<z.ZodString, "many">;
|
|
255
|
-
rateLimitedTokens: z.ZodArray<z.ZodString, "many">;
|
|
256
|
-
}, "strip", z.ZodTypeAny, {
|
|
257
|
-
successfulTokens: string[];
|
|
258
|
-
invalidTokens: string[];
|
|
259
|
-
rateLimitedTokens: string[];
|
|
260
|
-
}, {
|
|
261
|
-
successfulTokens: string[];
|
|
262
|
-
invalidTokens: string[];
|
|
263
|
-
rateLimitedTokens: string[];
|
|
264
|
-
}>;
|
|
265
|
-
}, "strip", z.ZodTypeAny, {
|
|
266
|
-
result: {
|
|
267
|
-
successfulTokens: string[];
|
|
268
|
-
invalidTokens: string[];
|
|
269
|
-
rateLimitedTokens: string[];
|
|
270
|
-
};
|
|
271
|
-
}, {
|
|
272
|
-
result: {
|
|
273
|
-
successfulTokens: string[];
|
|
274
|
-
invalidTokens: string[];
|
|
275
|
-
rateLimitedTokens: string[];
|
|
276
|
-
};
|
|
277
|
-
}>;
|
|
278
|
-
export type SendNotificationResponse = z.infer<typeof sendNotificationResponseSchema>;
|
|
279
81
|
export type FrameEthProviderEventData = {
|
|
280
|
-
type:
|
|
82
|
+
type: "frame_eth_provider_event";
|
|
281
83
|
} & EthProviderWireEvent;
|
|
282
84
|
export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
|
|
283
85
|
export type ProviderRpcError = {
|
|
@@ -301,6 +103,6 @@ export type EthProviderWireEvent = {
|
|
|
301
103
|
event: "message";
|
|
302
104
|
params: [Provider.Message];
|
|
303
105
|
};
|
|
304
|
-
export type EmitEthProvider = <event extends EthProviderWireEvent[
|
|
106
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent["event"]>(event: event, params: Extract<EthProviderWireEvent, {
|
|
305
107
|
event: event;
|
|
306
|
-
}>[
|
|
108
|
+
}>["params"]) => void;
|
package/dist/types.js
CHANGED
|
@@ -1,52 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
token: z.string(),
|
|
5
|
-
});
|
|
6
|
-
export const eventSchema = z.object({
|
|
7
|
-
header: z.string(),
|
|
8
|
-
payload: z.string(),
|
|
9
|
-
signature: z.string(),
|
|
10
|
-
});
|
|
11
|
-
// JSON Farcaster Signature header after decoding
|
|
12
|
-
export const eventHeaderSchema = z.object({
|
|
13
|
-
fid: z.number(),
|
|
14
|
-
type: z.literal("app_key"),
|
|
15
|
-
key: z.string().startsWith("0x"),
|
|
16
|
-
});
|
|
17
|
-
// Webhook event payload after decoding
|
|
18
|
-
export const eventFrameAddedPayloadSchema = z.object({
|
|
19
|
-
event: z.literal("frame-added"),
|
|
20
|
-
notificationDetails: notificationDetailsSchema.optional(),
|
|
21
|
-
});
|
|
22
|
-
export const eventFrameRemovedPayloadSchema = z.object({
|
|
23
|
-
event: z.literal("frame-removed"),
|
|
24
|
-
});
|
|
25
|
-
export const eventNotificationsEnabledPayloadSchema = z.object({
|
|
26
|
-
event: z.literal("notifications-enabled"),
|
|
27
|
-
notificationDetails: notificationDetailsSchema.required(),
|
|
28
|
-
});
|
|
29
|
-
export const notificationsDisabledPayloadSchema = z.object({
|
|
30
|
-
event: z.literal("notifications-disabled"),
|
|
31
|
-
});
|
|
32
|
-
export const eventPayloadSchema = z.discriminatedUnion("event", [
|
|
33
|
-
eventFrameAddedPayloadSchema,
|
|
34
|
-
eventFrameRemovedPayloadSchema,
|
|
35
|
-
eventNotificationsEnabledPayloadSchema,
|
|
36
|
-
notificationsDisabledPayloadSchema,
|
|
37
|
-
]);
|
|
38
|
-
// Notifications API request and response formats
|
|
39
|
-
export const sendNotificationRequestSchema = z.object({
|
|
40
|
-
notificationId: z.string().uuid(),
|
|
41
|
-
title: z.string().max(32),
|
|
42
|
-
body: z.string().max(128),
|
|
43
|
-
targetUrl: z.string().max(256),
|
|
44
|
-
tokens: z.string().array().max(100),
|
|
45
|
-
});
|
|
46
|
-
export const sendNotificationResponseSchema = z.object({
|
|
47
|
-
result: z.object({
|
|
48
|
-
successfulTokens: z.array(z.string()),
|
|
49
|
-
invalidTokens: z.array(z.string()),
|
|
50
|
-
rateLimitedTokens: z.array(z.string()),
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
1
|
+
export const DEFAULT_READY_OPTIONS = {
|
|
2
|
+
disableNativeGestures: false,
|
|
3
|
+
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { colorValueSchema, frameNameSchema, secureUrlSchema } from './shared';
|
|
3
|
+
|
|
4
|
+
export const actionLaunchFrameSchema = z.object({
|
|
5
|
+
type: z.literal('launch_frame'),
|
|
6
|
+
name: frameNameSchema,
|
|
7
|
+
url: secureUrlSchema,
|
|
8
|
+
splashImageUrl: secureUrlSchema.optional(),
|
|
9
|
+
splashBackgroundColor: colorValueSchema.optional(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const actionSchema = z.discriminatedUnion('type', [actionLaunchFrameSchema]);
|
|
13
|
+
|
|
14
|
+
export const buttonTitleSchema = z.string().max(32);
|
|
15
|
+
|
|
16
|
+
export const buttonSchema = z.object({
|
|
17
|
+
title: buttonTitleSchema,
|
|
18
|
+
action: actionSchema,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const frameEmbedNextSchema = z.object({
|
|
22
|
+
version: z.literal('next'),
|
|
23
|
+
imageUrl: secureUrlSchema,
|
|
24
|
+
button: buttonSchema,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const safeParseFrameEmbed = (rawResponse: unknown) => frameEmbedNextSchema.safeParse(rawResponse);
|
|
28
|
+
|
|
29
|
+
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { notificationDetailsSchema } from './notifications';
|
|
3
|
+
|
|
4
|
+
export const eventFrameAddedPayloadSchema = z.object({
|
|
5
|
+
event: z.literal("frame_added"),
|
|
6
|
+
notificationDetails: notificationDetailsSchema.optional(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type EventFrameAddedPayload = z.infer<
|
|
10
|
+
typeof eventFrameAddedPayloadSchema
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export const eventFrameRemovedPayloadSchema = z.object({
|
|
14
|
+
event: z.literal("frame_removed"),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type EventFrameRemovedPayload = z.infer<
|
|
18
|
+
typeof eventFrameRemovedPayloadSchema
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export const eventNotificationsEnabledPayloadSchema = z.object({
|
|
22
|
+
event: z.literal("notifications_enabled"),
|
|
23
|
+
notificationDetails: notificationDetailsSchema.required(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type EventNotificationsEnabledPayload = z.infer<
|
|
27
|
+
typeof eventNotificationsEnabledPayloadSchema
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
export const notificationsDisabledPayloadSchema = z.object({
|
|
31
|
+
event: z.literal("notifications_disabled"),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type EventNotificationsDisabledPayload = z.infer<
|
|
35
|
+
typeof notificationsDisabledPayloadSchema
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
export const eventPayloadSchema = z.discriminatedUnion("event", [
|
|
39
|
+
eventFrameAddedPayloadSchema,
|
|
40
|
+
eventFrameRemovedPayloadSchema,
|
|
41
|
+
eventNotificationsEnabledPayloadSchema,
|
|
42
|
+
notificationsDisabledPayloadSchema,
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
export type FrameEvent = z.infer<typeof eventPayloadSchema>;
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { secureUrlSchema, frameNameSchema, colorValueSchema, encodedJsonFarcasterSignatureSchema } from './shared';
|
|
3
|
+
|
|
4
|
+
export const domainFrameConfig = z.object({
|
|
5
|
+
version: z.string(),
|
|
6
|
+
name: frameNameSchema,
|
|
7
|
+
iconUrl: secureUrlSchema,
|
|
8
|
+
homeUrl: secureUrlSchema,
|
|
9
|
+
splashImageUrl: secureUrlSchema.optional(),
|
|
10
|
+
splashBackgroundColor: colorValueSchema.optional(),
|
|
11
|
+
webhookUrl: secureUrlSchema.optional()
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const domainManifest = z.object({
|
|
15
|
+
accountAssociation: encodedJsonFarcasterSignatureSchema,
|
|
16
|
+
frame: domainFrameConfig.optional(),
|
|
17
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { secureUrlSchema } from './shared';
|
|
3
|
+
|
|
4
|
+
export const notificationDetailsSchema = z.object({
|
|
5
|
+
url: z.string(),
|
|
6
|
+
token: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type FrameNotificationDetails = z.infer<
|
|
10
|
+
typeof notificationDetailsSchema
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export const sendNotificationRequestSchema = z.object({
|
|
14
|
+
notificationId: z.string().max(128),
|
|
15
|
+
title: z.string().max(32),
|
|
16
|
+
body: z.string().max(128),
|
|
17
|
+
targetUrl: secureUrlSchema,
|
|
18
|
+
tokens: z.string().array().max(100),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type SendNotificationRequest = z.infer<
|
|
22
|
+
typeof sendNotificationRequestSchema
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export const sendNotificationResponseSchema = z.object({
|
|
26
|
+
result: z.object({
|
|
27
|
+
successfulTokens: z.array(z.string()),
|
|
28
|
+
invalidTokens: z.array(z.string()),
|
|
29
|
+
rateLimitedTokens: z.array(z.string()),
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type SendNotificationResponse = z.infer<
|
|
34
|
+
typeof sendNotificationResponseSchema
|
|
35
|
+
>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const secureUrlSchema = z.string().url().startsWith('https://', { message: 'Must be an https url' }).max(512);
|
|
4
|
+
|
|
5
|
+
export const frameNameSchema = z.string().max(32);
|
|
6
|
+
|
|
7
|
+
export const colorValueSchema = z.string().max(9).optional();
|
|
8
|
+
|
|
9
|
+
export const encodedJsonFarcasterSignatureSchema = z.object({
|
|
10
|
+
header: z.string(),
|
|
11
|
+
payload: z.string(),
|
|
12
|
+
signature: z.string(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type EncodedJsonFarcasterSignatureSchema = z.infer<typeof encodedJsonFarcasterSignatureSchema>;
|
|
16
|
+
|
|
17
|
+
export const jsonFarcasterSignatureHeaderSchema = z.object({
|
|
18
|
+
fid: z.number(),
|
|
19
|
+
type: z.literal("app_key"),
|
|
20
|
+
key: z.string().startsWith("0x"),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type JsonFarcasterSignatureHeaderSchema = z.infer<typeof jsonFarcasterSignatureHeaderSchema>;
|