@farcaster/frame-core 0.0.11 → 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 +1 -218
- package/dist/types.js +0 -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 +1 -89
package/dist/types.js
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const notificationDetailsSchema = z.object({
|
|
3
|
-
url: z.string(),
|
|
4
|
-
token: z.string(),
|
|
5
|
-
});
|
|
6
1
|
export const DEFAULT_READY_OPTIONS = {
|
|
7
2
|
disableNativeGestures: false,
|
|
8
3
|
};
|
|
9
|
-
export const eventSchema = z.object({
|
|
10
|
-
header: z.string(),
|
|
11
|
-
payload: z.string(),
|
|
12
|
-
signature: z.string(),
|
|
13
|
-
});
|
|
14
|
-
// JSON Farcaster Signature header after decoding
|
|
15
|
-
export const eventHeaderSchema = z.object({
|
|
16
|
-
fid: z.number(),
|
|
17
|
-
type: z.literal("app_key"),
|
|
18
|
-
key: z.string().startsWith("0x"),
|
|
19
|
-
});
|
|
20
|
-
// Webhook event payload after decoding
|
|
21
|
-
export const eventFrameAddedPayloadSchema = z.object({
|
|
22
|
-
event: z.literal("frame_added"),
|
|
23
|
-
notificationDetails: notificationDetailsSchema.optional(),
|
|
24
|
-
});
|
|
25
|
-
export const eventFrameRemovedPayloadSchema = z.object({
|
|
26
|
-
event: z.literal("frame_removed"),
|
|
27
|
-
});
|
|
28
|
-
export const eventNotificationsEnabledPayloadSchema = z.object({
|
|
29
|
-
event: z.literal("notifications_enabled"),
|
|
30
|
-
notificationDetails: notificationDetailsSchema.required(),
|
|
31
|
-
});
|
|
32
|
-
export const notificationsDisabledPayloadSchema = z.object({
|
|
33
|
-
event: z.literal("notifications_disabled"),
|
|
34
|
-
});
|
|
35
|
-
export const eventPayloadSchema = z.discriminatedUnion("event", [
|
|
36
|
-
eventFrameAddedPayloadSchema,
|
|
37
|
-
eventFrameRemovedPayloadSchema,
|
|
38
|
-
eventNotificationsEnabledPayloadSchema,
|
|
39
|
-
notificationsDisabledPayloadSchema,
|
|
40
|
-
]);
|
|
41
|
-
// Notifications API request and response formats
|
|
42
|
-
export const sendNotificationRequestSchema = z.object({
|
|
43
|
-
notificationId: z.string().max(128),
|
|
44
|
-
title: z.string().max(32),
|
|
45
|
-
body: z.string().max(128),
|
|
46
|
-
targetUrl: z.string().max(256),
|
|
47
|
-
tokens: z.string().array().max(100),
|
|
48
|
-
});
|
|
49
|
-
export const sendNotificationResponseSchema = z.object({
|
|
50
|
-
result: z.object({
|
|
51
|
-
successfulTokens: z.array(z.string()),
|
|
52
|
-
invalidTokens: z.array(z.string()),
|
|
53
|
-
rateLimitedTokens: z.array(z.string()),
|
|
54
|
-
}),
|
|
55
|
-
});
|
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>;
|
package/src/types.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
|
|
|
4
4
|
export type SetPrimaryButton = (options: {
|
|
5
5
|
text: string;
|
|
@@ -44,14 +44,6 @@ export type FrameLocationContext =
|
|
|
44
44
|
| FrameLocationContextNotification
|
|
45
45
|
| FrameLocationContextLauncher;
|
|
46
46
|
|
|
47
|
-
export const notificationDetailsSchema = z.object({
|
|
48
|
-
url: z.string(),
|
|
49
|
-
token: z.string(),
|
|
50
|
-
});
|
|
51
|
-
export type FrameNotificationDetails = z.infer<
|
|
52
|
-
typeof notificationDetailsSchema
|
|
53
|
-
>;
|
|
54
|
-
|
|
55
47
|
export type FrameContext = {
|
|
56
48
|
user: {
|
|
57
49
|
fid: number;
|
|
@@ -107,86 +99,6 @@ export type FrameHost = {
|
|
|
107
99
|
addFrame: AddFrame;
|
|
108
100
|
};
|
|
109
101
|
|
|
110
|
-
export const eventSchema = z.object({
|
|
111
|
-
header: z.string(),
|
|
112
|
-
payload: z.string(),
|
|
113
|
-
signature: z.string(),
|
|
114
|
-
});
|
|
115
|
-
export type EventSchema = z.infer<typeof eventSchema>;
|
|
116
|
-
|
|
117
|
-
// JSON Farcaster Signature header after decoding
|
|
118
|
-
|
|
119
|
-
export const eventHeaderSchema = z.object({
|
|
120
|
-
fid: z.number(),
|
|
121
|
-
type: z.literal("app_key"),
|
|
122
|
-
key: z.string().startsWith("0x"),
|
|
123
|
-
});
|
|
124
|
-
export type EventHeader = z.infer<typeof eventHeaderSchema>;
|
|
125
|
-
|
|
126
|
-
// Webhook event payload after decoding
|
|
127
|
-
|
|
128
|
-
export const eventFrameAddedPayloadSchema = z.object({
|
|
129
|
-
event: z.literal("frame_added"),
|
|
130
|
-
notificationDetails: notificationDetailsSchema.optional(),
|
|
131
|
-
});
|
|
132
|
-
export type EventFrameAddedPayload = z.infer<
|
|
133
|
-
typeof eventFrameAddedPayloadSchema
|
|
134
|
-
>;
|
|
135
|
-
|
|
136
|
-
export const eventFrameRemovedPayloadSchema = z.object({
|
|
137
|
-
event: z.literal("frame_removed"),
|
|
138
|
-
});
|
|
139
|
-
export type EventFrameRemovedPayload = z.infer<
|
|
140
|
-
typeof eventFrameRemovedPayloadSchema
|
|
141
|
-
>;
|
|
142
|
-
|
|
143
|
-
export const eventNotificationsEnabledPayloadSchema = z.object({
|
|
144
|
-
event: z.literal("notifications_enabled"),
|
|
145
|
-
notificationDetails: notificationDetailsSchema.required(),
|
|
146
|
-
});
|
|
147
|
-
export type EventNotificationsEnabledPayload = z.infer<
|
|
148
|
-
typeof eventNotificationsEnabledPayloadSchema
|
|
149
|
-
>;
|
|
150
|
-
|
|
151
|
-
export const notificationsDisabledPayloadSchema = z.object({
|
|
152
|
-
event: z.literal("notifications_disabled"),
|
|
153
|
-
});
|
|
154
|
-
export type EventNotificationsDisabledPayload = z.infer<
|
|
155
|
-
typeof notificationsDisabledPayloadSchema
|
|
156
|
-
>;
|
|
157
|
-
|
|
158
|
-
export const eventPayloadSchema = z.discriminatedUnion("event", [
|
|
159
|
-
eventFrameAddedPayloadSchema,
|
|
160
|
-
eventFrameRemovedPayloadSchema,
|
|
161
|
-
eventNotificationsEnabledPayloadSchema,
|
|
162
|
-
notificationsDisabledPayloadSchema,
|
|
163
|
-
]);
|
|
164
|
-
export type FrameEvent = z.infer<typeof eventPayloadSchema>;
|
|
165
|
-
|
|
166
|
-
// Notifications API request and response formats
|
|
167
|
-
|
|
168
|
-
export const sendNotificationRequestSchema = z.object({
|
|
169
|
-
notificationId: z.string().max(128),
|
|
170
|
-
title: z.string().max(32),
|
|
171
|
-
body: z.string().max(128),
|
|
172
|
-
targetUrl: z.string().max(256),
|
|
173
|
-
tokens: z.string().array().max(100),
|
|
174
|
-
});
|
|
175
|
-
export type SendNotificationRequest = z.infer<
|
|
176
|
-
typeof sendNotificationRequestSchema
|
|
177
|
-
>;
|
|
178
|
-
|
|
179
|
-
export const sendNotificationResponseSchema = z.object({
|
|
180
|
-
result: z.object({
|
|
181
|
-
successfulTokens: z.array(z.string()),
|
|
182
|
-
invalidTokens: z.array(z.string()),
|
|
183
|
-
rateLimitedTokens: z.array(z.string()),
|
|
184
|
-
}),
|
|
185
|
-
});
|
|
186
|
-
export type SendNotificationResponse = z.infer<
|
|
187
|
-
typeof sendNotificationResponseSchema
|
|
188
|
-
>;
|
|
189
|
-
|
|
190
102
|
export type FrameEthProviderEventData = {
|
|
191
103
|
type: "frame_eth_provider_event";
|
|
192
104
|
} & EthProviderWireEvent;
|