@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 CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./types";
2
+ export * from "./schemas";
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./types";
2
+ export * from "./schemas";
@@ -0,0 +1,178 @@
1
+ import { z } from 'zod';
2
+ export declare const actionLaunchFrameSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"launch_frame">;
4
+ name: z.ZodString;
5
+ url: z.ZodString;
6
+ splashImageUrl: z.ZodOptional<z.ZodString>;
7
+ splashBackgroundColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ type: "launch_frame";
10
+ name: string;
11
+ url: string;
12
+ splashImageUrl?: string | undefined;
13
+ splashBackgroundColor?: string | undefined;
14
+ }, {
15
+ type: "launch_frame";
16
+ name: string;
17
+ url: string;
18
+ splashImageUrl?: string | undefined;
19
+ splashBackgroundColor?: string | undefined;
20
+ }>;
21
+ export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
22
+ type: z.ZodLiteral<"launch_frame">;
23
+ name: z.ZodString;
24
+ url: z.ZodString;
25
+ splashImageUrl: z.ZodOptional<z.ZodString>;
26
+ splashBackgroundColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ type: "launch_frame";
29
+ name: string;
30
+ url: string;
31
+ splashImageUrl?: string | undefined;
32
+ splashBackgroundColor?: string | undefined;
33
+ }, {
34
+ type: "launch_frame";
35
+ name: string;
36
+ url: string;
37
+ splashImageUrl?: string | undefined;
38
+ splashBackgroundColor?: string | undefined;
39
+ }>]>;
40
+ export declare const buttonTitleSchema: z.ZodString;
41
+ export declare const buttonSchema: z.ZodObject<{
42
+ title: z.ZodString;
43
+ action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
44
+ type: z.ZodLiteral<"launch_frame">;
45
+ name: z.ZodString;
46
+ url: z.ZodString;
47
+ splashImageUrl: z.ZodOptional<z.ZodString>;
48
+ splashBackgroundColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
49
+ }, "strip", z.ZodTypeAny, {
50
+ type: "launch_frame";
51
+ name: string;
52
+ url: string;
53
+ splashImageUrl?: string | undefined;
54
+ splashBackgroundColor?: string | undefined;
55
+ }, {
56
+ type: "launch_frame";
57
+ name: string;
58
+ url: string;
59
+ splashImageUrl?: string | undefined;
60
+ splashBackgroundColor?: string | undefined;
61
+ }>]>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ title: string;
64
+ action: {
65
+ type: "launch_frame";
66
+ name: string;
67
+ url: string;
68
+ splashImageUrl?: string | undefined;
69
+ splashBackgroundColor?: string | undefined;
70
+ };
71
+ }, {
72
+ title: string;
73
+ action: {
74
+ type: "launch_frame";
75
+ name: string;
76
+ url: string;
77
+ splashImageUrl?: string | undefined;
78
+ splashBackgroundColor?: string | undefined;
79
+ };
80
+ }>;
81
+ export declare const frameEmbedNextSchema: z.ZodObject<{
82
+ version: z.ZodLiteral<"next">;
83
+ imageUrl: z.ZodString;
84
+ button: z.ZodObject<{
85
+ title: z.ZodString;
86
+ action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
87
+ type: z.ZodLiteral<"launch_frame">;
88
+ name: z.ZodString;
89
+ url: z.ZodString;
90
+ splashImageUrl: z.ZodOptional<z.ZodString>;
91
+ splashBackgroundColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ type: "launch_frame";
94
+ name: string;
95
+ url: string;
96
+ splashImageUrl?: string | undefined;
97
+ splashBackgroundColor?: string | undefined;
98
+ }, {
99
+ type: "launch_frame";
100
+ name: string;
101
+ url: string;
102
+ splashImageUrl?: string | undefined;
103
+ splashBackgroundColor?: string | undefined;
104
+ }>]>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ title: string;
107
+ action: {
108
+ type: "launch_frame";
109
+ name: string;
110
+ url: string;
111
+ splashImageUrl?: string | undefined;
112
+ splashBackgroundColor?: string | undefined;
113
+ };
114
+ }, {
115
+ title: string;
116
+ action: {
117
+ type: "launch_frame";
118
+ name: string;
119
+ url: string;
120
+ splashImageUrl?: string | undefined;
121
+ splashBackgroundColor?: string | undefined;
122
+ };
123
+ }>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ version: "next";
126
+ imageUrl: string;
127
+ button: {
128
+ title: string;
129
+ action: {
130
+ type: "launch_frame";
131
+ name: string;
132
+ url: string;
133
+ splashImageUrl?: string | undefined;
134
+ splashBackgroundColor?: string | undefined;
135
+ };
136
+ };
137
+ }, {
138
+ version: "next";
139
+ imageUrl: string;
140
+ button: {
141
+ title: string;
142
+ action: {
143
+ type: "launch_frame";
144
+ name: string;
145
+ url: string;
146
+ splashImageUrl?: string | undefined;
147
+ splashBackgroundColor?: string | undefined;
148
+ };
149
+ };
150
+ }>;
151
+ export declare const safeParseFrameEmbed: (rawResponse: unknown) => z.SafeParseReturnType<{
152
+ version: "next";
153
+ imageUrl: string;
154
+ button: {
155
+ title: string;
156
+ action: {
157
+ type: "launch_frame";
158
+ name: string;
159
+ url: string;
160
+ splashImageUrl?: string | undefined;
161
+ splashBackgroundColor?: string | undefined;
162
+ };
163
+ };
164
+ }, {
165
+ version: "next";
166
+ imageUrl: string;
167
+ button: {
168
+ title: string;
169
+ action: {
170
+ type: "launch_frame";
171
+ name: string;
172
+ url: string;
173
+ splashImageUrl?: string | undefined;
174
+ splashBackgroundColor?: string | undefined;
175
+ };
176
+ };
177
+ }>;
178
+ export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { colorValueSchema, frameNameSchema, secureUrlSchema } from './shared';
3
+ export const actionLaunchFrameSchema = z.object({
4
+ type: z.literal('launch_frame'),
5
+ name: frameNameSchema,
6
+ url: secureUrlSchema,
7
+ splashImageUrl: secureUrlSchema.optional(),
8
+ splashBackgroundColor: colorValueSchema.optional(),
9
+ });
10
+ export const actionSchema = z.discriminatedUnion('type', [actionLaunchFrameSchema]);
11
+ export const buttonTitleSchema = z.string().max(32);
12
+ export const buttonSchema = z.object({
13
+ title: buttonTitleSchema,
14
+ action: actionSchema,
15
+ });
16
+ export const frameEmbedNextSchema = z.object({
17
+ version: z.literal('next'),
18
+ imageUrl: secureUrlSchema,
19
+ button: buttonSchema,
20
+ });
21
+ export const safeParseFrameEmbed = (rawResponse) => frameEmbedNextSchema.safeParse(rawResponse);
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ export declare const eventFrameAddedPayloadSchema: z.ZodObject<{
3
+ event: z.ZodLiteral<"frame_added">;
4
+ notificationDetails: z.ZodOptional<z.ZodObject<{
5
+ url: z.ZodString;
6
+ token: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ url: string;
9
+ token: string;
10
+ }, {
11
+ url: string;
12
+ token: string;
13
+ }>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ event: "frame_added";
16
+ notificationDetails?: {
17
+ url: string;
18
+ token: string;
19
+ } | undefined;
20
+ }, {
21
+ event: "frame_added";
22
+ notificationDetails?: {
23
+ url: string;
24
+ token: string;
25
+ } | undefined;
26
+ }>;
27
+ export type EventFrameAddedPayload = z.infer<typeof eventFrameAddedPayloadSchema>;
28
+ export declare const eventFrameRemovedPayloadSchema: z.ZodObject<{
29
+ event: z.ZodLiteral<"frame_removed">;
30
+ }, "strip", z.ZodTypeAny, {
31
+ event: "frame_removed";
32
+ }, {
33
+ event: "frame_removed";
34
+ }>;
35
+ export type EventFrameRemovedPayload = z.infer<typeof eventFrameRemovedPayloadSchema>;
36
+ export declare const eventNotificationsEnabledPayloadSchema: z.ZodObject<{
37
+ event: z.ZodLiteral<"notifications_enabled">;
38
+ notificationDetails: 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
+ }, "strip", z.ZodTypeAny, {
49
+ event: "notifications_enabled";
50
+ notificationDetails: {
51
+ url: string;
52
+ token: string;
53
+ };
54
+ }, {
55
+ event: "notifications_enabled";
56
+ notificationDetails: {
57
+ url: string;
58
+ token: string;
59
+ };
60
+ }>;
61
+ export type EventNotificationsEnabledPayload = z.infer<typeof eventNotificationsEnabledPayloadSchema>;
62
+ export declare const notificationsDisabledPayloadSchema: z.ZodObject<{
63
+ event: z.ZodLiteral<"notifications_disabled">;
64
+ }, "strip", z.ZodTypeAny, {
65
+ event: "notifications_disabled";
66
+ }, {
67
+ event: "notifications_disabled";
68
+ }>;
69
+ export type EventNotificationsDisabledPayload = z.infer<typeof notificationsDisabledPayloadSchema>;
70
+ export declare const eventPayloadSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
71
+ event: z.ZodLiteral<"frame_added">;
72
+ notificationDetails: z.ZodOptional<z.ZodObject<{
73
+ url: z.ZodString;
74
+ token: z.ZodString;
75
+ }, "strip", z.ZodTypeAny, {
76
+ url: string;
77
+ token: string;
78
+ }, {
79
+ url: string;
80
+ token: string;
81
+ }>>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ event: "frame_added";
84
+ notificationDetails?: {
85
+ url: string;
86
+ token: string;
87
+ } | undefined;
88
+ }, {
89
+ event: "frame_added";
90
+ notificationDetails?: {
91
+ url: string;
92
+ token: string;
93
+ } | undefined;
94
+ }>, z.ZodObject<{
95
+ event: z.ZodLiteral<"frame_removed">;
96
+ }, "strip", z.ZodTypeAny, {
97
+ event: "frame_removed";
98
+ }, {
99
+ event: "frame_removed";
100
+ }>, z.ZodObject<{
101
+ event: z.ZodLiteral<"notifications_enabled">;
102
+ notificationDetails: z.ZodObject<{
103
+ url: z.ZodString;
104
+ token: z.ZodString;
105
+ }, "strip", z.ZodTypeAny, {
106
+ url: string;
107
+ token: string;
108
+ }, {
109
+ url: string;
110
+ token: string;
111
+ }>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ event: "notifications_enabled";
114
+ notificationDetails: {
115
+ url: string;
116
+ token: string;
117
+ };
118
+ }, {
119
+ event: "notifications_enabled";
120
+ notificationDetails: {
121
+ url: string;
122
+ token: string;
123
+ };
124
+ }>, z.ZodObject<{
125
+ event: z.ZodLiteral<"notifications_disabled">;
126
+ }, "strip", z.ZodTypeAny, {
127
+ event: "notifications_disabled";
128
+ }, {
129
+ event: "notifications_disabled";
130
+ }>]>;
131
+ export type FrameEvent = z.infer<typeof eventPayloadSchema>;
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ import { notificationDetailsSchema } from './notifications';
3
+ export const eventFrameAddedPayloadSchema = z.object({
4
+ event: z.literal("frame_added"),
5
+ notificationDetails: notificationDetailsSchema.optional(),
6
+ });
7
+ export const eventFrameRemovedPayloadSchema = z.object({
8
+ event: z.literal("frame_removed"),
9
+ });
10
+ export const eventNotificationsEnabledPayloadSchema = z.object({
11
+ event: z.literal("notifications_enabled"),
12
+ notificationDetails: notificationDetailsSchema.required(),
13
+ });
14
+ export const notificationsDisabledPayloadSchema = z.object({
15
+ event: z.literal("notifications_disabled"),
16
+ });
17
+ export const eventPayloadSchema = z.discriminatedUnion("event", [
18
+ eventFrameAddedPayloadSchema,
19
+ eventFrameRemovedPayloadSchema,
20
+ eventNotificationsEnabledPayloadSchema,
21
+ notificationsDisabledPayloadSchema,
22
+ ]);
@@ -0,0 +1,5 @@
1
+ export * from "./embeds";
2
+ export * from "./events";
3
+ export * from "./shared";
4
+ export * from "./manifest";
5
+ export * from "./notifications";
@@ -0,0 +1,5 @@
1
+ export * from "./embeds";
2
+ export * from "./events";
3
+ export * from "./shared";
4
+ export * from "./manifest";
5
+ export * from "./notifications";
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ export declare const domainFrameConfig: z.ZodObject<{
3
+ version: z.ZodString;
4
+ name: z.ZodString;
5
+ iconUrl: z.ZodString;
6
+ homeUrl: z.ZodString;
7
+ splashImageUrl: z.ZodOptional<z.ZodString>;
8
+ splashBackgroundColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
9
+ webhookUrl: z.ZodOptional<z.ZodString>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ name: string;
12
+ version: string;
13
+ iconUrl: string;
14
+ homeUrl: string;
15
+ splashImageUrl?: string | undefined;
16
+ splashBackgroundColor?: string | undefined;
17
+ webhookUrl?: string | undefined;
18
+ }, {
19
+ name: string;
20
+ version: string;
21
+ iconUrl: string;
22
+ homeUrl: string;
23
+ splashImageUrl?: string | undefined;
24
+ splashBackgroundColor?: string | undefined;
25
+ webhookUrl?: string | undefined;
26
+ }>;
27
+ export declare const domainManifest: z.ZodObject<{
28
+ accountAssociation: z.ZodObject<{
29
+ header: z.ZodString;
30
+ payload: z.ZodString;
31
+ signature: z.ZodString;
32
+ }, "strip", z.ZodTypeAny, {
33
+ header: string;
34
+ payload: string;
35
+ signature: string;
36
+ }, {
37
+ header: string;
38
+ payload: string;
39
+ signature: string;
40
+ }>;
41
+ frame: z.ZodOptional<z.ZodObject<{
42
+ version: z.ZodString;
43
+ name: z.ZodString;
44
+ iconUrl: z.ZodString;
45
+ homeUrl: z.ZodString;
46
+ splashImageUrl: z.ZodOptional<z.ZodString>;
47
+ splashBackgroundColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
48
+ webhookUrl: z.ZodOptional<z.ZodString>;
49
+ }, "strip", z.ZodTypeAny, {
50
+ name: string;
51
+ version: string;
52
+ iconUrl: string;
53
+ homeUrl: string;
54
+ splashImageUrl?: string | undefined;
55
+ splashBackgroundColor?: string | undefined;
56
+ webhookUrl?: string | undefined;
57
+ }, {
58
+ name: string;
59
+ version: string;
60
+ iconUrl: string;
61
+ homeUrl: string;
62
+ splashImageUrl?: string | undefined;
63
+ splashBackgroundColor?: string | undefined;
64
+ webhookUrl?: string | undefined;
65
+ }>>;
66
+ }, "strip", z.ZodTypeAny, {
67
+ accountAssociation: {
68
+ header: string;
69
+ payload: string;
70
+ signature: string;
71
+ };
72
+ frame?: {
73
+ name: string;
74
+ version: string;
75
+ iconUrl: string;
76
+ homeUrl: string;
77
+ splashImageUrl?: string | undefined;
78
+ splashBackgroundColor?: string | undefined;
79
+ webhookUrl?: string | undefined;
80
+ } | undefined;
81
+ }, {
82
+ accountAssociation: {
83
+ header: string;
84
+ payload: string;
85
+ signature: string;
86
+ };
87
+ frame?: {
88
+ name: string;
89
+ version: string;
90
+ iconUrl: string;
91
+ homeUrl: string;
92
+ splashImageUrl?: string | undefined;
93
+ splashBackgroundColor?: string | undefined;
94
+ webhookUrl?: string | undefined;
95
+ } | undefined;
96
+ }>;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { secureUrlSchema, frameNameSchema, colorValueSchema, encodedJsonFarcasterSignatureSchema } from './shared';
3
+ export const domainFrameConfig = z.object({
4
+ version: z.string(),
5
+ name: frameNameSchema,
6
+ iconUrl: secureUrlSchema,
7
+ homeUrl: secureUrlSchema,
8
+ splashImageUrl: secureUrlSchema.optional(),
9
+ splashBackgroundColor: colorValueSchema.optional(),
10
+ webhookUrl: secureUrlSchema.optional()
11
+ });
12
+ export const domainManifest = z.object({
13
+ accountAssociation: encodedJsonFarcasterSignatureSchema,
14
+ frame: domainFrameConfig.optional(),
15
+ });
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ export declare const notificationDetailsSchema: z.ZodObject<{
3
+ url: z.ZodString;
4
+ token: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ url: string;
7
+ token: string;
8
+ }, {
9
+ url: string;
10
+ token: string;
11
+ }>;
12
+ export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>;
13
+ export declare const sendNotificationRequestSchema: z.ZodObject<{
14
+ notificationId: z.ZodString;
15
+ title: z.ZodString;
16
+ body: z.ZodString;
17
+ targetUrl: z.ZodString;
18
+ tokens: z.ZodArray<z.ZodString, "many">;
19
+ }, "strip", z.ZodTypeAny, {
20
+ title: string;
21
+ notificationId: string;
22
+ body: string;
23
+ targetUrl: string;
24
+ tokens: string[];
25
+ }, {
26
+ title: string;
27
+ notificationId: string;
28
+ body: string;
29
+ targetUrl: string;
30
+ tokens: string[];
31
+ }>;
32
+ export type SendNotificationRequest = z.infer<typeof sendNotificationRequestSchema>;
33
+ export declare const sendNotificationResponseSchema: z.ZodObject<{
34
+ result: z.ZodObject<{
35
+ successfulTokens: z.ZodArray<z.ZodString, "many">;
36
+ invalidTokens: z.ZodArray<z.ZodString, "many">;
37
+ rateLimitedTokens: z.ZodArray<z.ZodString, "many">;
38
+ }, "strip", z.ZodTypeAny, {
39
+ successfulTokens: string[];
40
+ invalidTokens: string[];
41
+ rateLimitedTokens: string[];
42
+ }, {
43
+ successfulTokens: string[];
44
+ invalidTokens: string[];
45
+ rateLimitedTokens: string[];
46
+ }>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ result: {
49
+ successfulTokens: string[];
50
+ invalidTokens: string[];
51
+ rateLimitedTokens: string[];
52
+ };
53
+ }, {
54
+ result: {
55
+ successfulTokens: string[];
56
+ invalidTokens: string[];
57
+ rateLimitedTokens: string[];
58
+ };
59
+ }>;
60
+ export type SendNotificationResponse = z.infer<typeof sendNotificationResponseSchema>;
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { secureUrlSchema } from './shared';
3
+ export const notificationDetailsSchema = z.object({
4
+ url: z.string(),
5
+ token: z.string(),
6
+ });
7
+ export const sendNotificationRequestSchema = z.object({
8
+ notificationId: z.string().max(128),
9
+ title: z.string().max(32),
10
+ body: z.string().max(128),
11
+ targetUrl: secureUrlSchema,
12
+ tokens: z.string().array().max(100),
13
+ });
14
+ export const sendNotificationResponseSchema = z.object({
15
+ result: z.object({
16
+ successfulTokens: z.array(z.string()),
17
+ invalidTokens: z.array(z.string()),
18
+ rateLimitedTokens: z.array(z.string()),
19
+ }),
20
+ });
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ export declare const secureUrlSchema: z.ZodString;
3
+ export declare const frameNameSchema: z.ZodString;
4
+ export declare const colorValueSchema: z.ZodOptional<z.ZodString>;
5
+ export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject<{
6
+ header: z.ZodString;
7
+ payload: z.ZodString;
8
+ signature: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ header: string;
11
+ payload: string;
12
+ signature: string;
13
+ }, {
14
+ header: string;
15
+ payload: string;
16
+ signature: string;
17
+ }>;
18
+ export type EncodedJsonFarcasterSignatureSchema = z.infer<typeof encodedJsonFarcasterSignatureSchema>;
19
+ export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject<{
20
+ fid: z.ZodNumber;
21
+ type: z.ZodLiteral<"app_key">;
22
+ key: z.ZodString;
23
+ }, "strip", z.ZodTypeAny, {
24
+ type: "app_key";
25
+ fid: number;
26
+ key: string;
27
+ }, {
28
+ type: "app_key";
29
+ fid: number;
30
+ key: string;
31
+ }>;
32
+ export type JsonFarcasterSignatureHeaderSchema = z.infer<typeof jsonFarcasterSignatureHeaderSchema>;
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export const secureUrlSchema = z.string().url().startsWith('https://', { message: 'Must be an https url' }).max(512);
3
+ export const frameNameSchema = z.string().max(32);
4
+ export const colorValueSchema = z.string().max(9).optional();
5
+ export const encodedJsonFarcasterSignatureSchema = z.object({
6
+ header: z.string(),
7
+ payload: z.string(),
8
+ signature: z.string(),
9
+ });
10
+ export const jsonFarcasterSignatureHeaderSchema = z.object({
11
+ fid: z.number(),
12
+ type: z.literal("app_key"),
13
+ key: z.string().startsWith("0x"),
14
+ });