@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/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;
|
|
@@ -18,7 +18,15 @@ export type AccountLocation = {
|
|
|
18
18
|
description: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export type
|
|
21
|
+
export type FrameLocationContextCastEmbed = {
|
|
22
|
+
type: "cast_embed";
|
|
23
|
+
cast: {
|
|
24
|
+
fid: number;
|
|
25
|
+
hash: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type FrameLocationContextNotification = {
|
|
22
30
|
type: "notification";
|
|
23
31
|
notification: {
|
|
24
32
|
notificationId: string;
|
|
@@ -27,7 +35,14 @@ export type FrameLocationNotificationContext = {
|
|
|
27
35
|
};
|
|
28
36
|
};
|
|
29
37
|
|
|
30
|
-
export type
|
|
38
|
+
export type FrameLocationContextLauncher = {
|
|
39
|
+
type: "launcher";
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type FrameLocationContext =
|
|
43
|
+
| FrameLocationContextCastEmbed
|
|
44
|
+
| FrameLocationContextNotification
|
|
45
|
+
| FrameLocationContextLauncher;
|
|
31
46
|
|
|
32
47
|
export type FrameContext = {
|
|
33
48
|
user: {
|
|
@@ -40,16 +55,13 @@ export type FrameContext = {
|
|
|
40
55
|
pfpUrl?: string;
|
|
41
56
|
};
|
|
42
57
|
location?: FrameLocationContext;
|
|
58
|
+
client: {
|
|
59
|
+
clientFid: number;
|
|
60
|
+
added: boolean;
|
|
61
|
+
notificationDetails?: FrameNotificationDetails;
|
|
62
|
+
};
|
|
43
63
|
};
|
|
44
64
|
|
|
45
|
-
export const notificationDetailsSchema = z.object({
|
|
46
|
-
url: z.string(),
|
|
47
|
-
token: z.string(),
|
|
48
|
-
});
|
|
49
|
-
export type FrameNotificationDetails = z.infer<
|
|
50
|
-
typeof notificationDetailsSchema
|
|
51
|
-
>;
|
|
52
|
-
|
|
53
65
|
export type AddFrameResult =
|
|
54
66
|
| {
|
|
55
67
|
added: true;
|
|
@@ -57,21 +69,29 @@ export type AddFrameResult =
|
|
|
57
69
|
}
|
|
58
70
|
| {
|
|
59
71
|
added: false;
|
|
60
|
-
reason: "
|
|
72
|
+
reason: "invalid_domain_manifest" | "rejected_by_user";
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
export type AddFrame = () => Promise<AddFrameResult>;
|
|
64
76
|
|
|
77
|
+
export type ReadyOptions = {
|
|
78
|
+
/**
|
|
79
|
+
* Disable native gestures. Use this option if your frame uses gestures
|
|
80
|
+
* that conflict with native gestures.
|
|
81
|
+
*
|
|
82
|
+
* @defaultValue false
|
|
83
|
+
*/
|
|
84
|
+
disableNativeGestures: boolean;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const DEFAULT_READY_OPTIONS: ReadyOptions = {
|
|
88
|
+
disableNativeGestures: false,
|
|
89
|
+
}
|
|
90
|
+
|
|
65
91
|
export type FrameHost = {
|
|
66
92
|
context: FrameContext;
|
|
67
93
|
close: () => void;
|
|
68
|
-
ready: (options
|
|
69
|
-
/**
|
|
70
|
-
* Disable native gestures. Use this option if your frame uses gestures
|
|
71
|
-
* that conflict with native gestures.
|
|
72
|
-
*/
|
|
73
|
-
disableNativeGestures: boolean;
|
|
74
|
-
}>) => void;
|
|
94
|
+
ready: (options?: Partial<ReadyOptions>) => void;
|
|
75
95
|
openUrl: (url: string) => void;
|
|
76
96
|
setPrimaryButton: SetPrimaryButton;
|
|
77
97
|
ethProviderRequest: EthProviderRequest;
|
|
@@ -79,88 +99,8 @@ export type FrameHost = {
|
|
|
79
99
|
addFrame: AddFrame;
|
|
80
100
|
};
|
|
81
101
|
|
|
82
|
-
export const eventSchema = z.object({
|
|
83
|
-
header: z.string(),
|
|
84
|
-
payload: z.string(),
|
|
85
|
-
signature: z.string(),
|
|
86
|
-
});
|
|
87
|
-
export type EventSchema = z.infer<typeof eventSchema>;
|
|
88
|
-
|
|
89
|
-
// JSON Farcaster Signature header after decoding
|
|
90
|
-
|
|
91
|
-
export const eventHeaderSchema = z.object({
|
|
92
|
-
fid: z.number(),
|
|
93
|
-
type: z.literal("app_key"),
|
|
94
|
-
key: z.string().startsWith("0x"),
|
|
95
|
-
});
|
|
96
|
-
export type EventHeader = z.infer<typeof eventHeaderSchema>;
|
|
97
|
-
|
|
98
|
-
// Webhook event payload after decoding
|
|
99
|
-
|
|
100
|
-
export const eventFrameAddedPayloadSchema = z.object({
|
|
101
|
-
event: z.literal("frame-added"),
|
|
102
|
-
notificationDetails: notificationDetailsSchema.optional(),
|
|
103
|
-
});
|
|
104
|
-
export type EventFrameAddedPayload = z.infer<
|
|
105
|
-
typeof eventFrameAddedPayloadSchema
|
|
106
|
-
>;
|
|
107
|
-
|
|
108
|
-
export const eventFrameRemovedPayloadSchema = z.object({
|
|
109
|
-
event: z.literal("frame-removed"),
|
|
110
|
-
});
|
|
111
|
-
export type EventFrameRemovedPayload = z.infer<
|
|
112
|
-
typeof eventFrameRemovedPayloadSchema
|
|
113
|
-
>;
|
|
114
|
-
|
|
115
|
-
export const eventNotificationsEnabledPayloadSchema = z.object({
|
|
116
|
-
event: z.literal("notifications-enabled"),
|
|
117
|
-
notificationDetails: notificationDetailsSchema.required(),
|
|
118
|
-
});
|
|
119
|
-
export type EventNotificationsEnabledPayload = z.infer<
|
|
120
|
-
typeof eventNotificationsEnabledPayloadSchema
|
|
121
|
-
>;
|
|
122
|
-
|
|
123
|
-
export const notificationsDisabledPayloadSchema = z.object({
|
|
124
|
-
event: z.literal("notifications-disabled"),
|
|
125
|
-
});
|
|
126
|
-
export type EventNotificationsDisabledPayload = z.infer<
|
|
127
|
-
typeof notificationsDisabledPayloadSchema
|
|
128
|
-
>;
|
|
129
|
-
|
|
130
|
-
export const eventPayloadSchema = z.discriminatedUnion("event", [
|
|
131
|
-
eventFrameAddedPayloadSchema,
|
|
132
|
-
eventFrameRemovedPayloadSchema,
|
|
133
|
-
eventNotificationsEnabledPayloadSchema,
|
|
134
|
-
notificationsDisabledPayloadSchema,
|
|
135
|
-
]);
|
|
136
|
-
export type FrameEvent = z.infer<typeof eventPayloadSchema>;
|
|
137
|
-
|
|
138
|
-
// Notifications API request and response formats
|
|
139
|
-
|
|
140
|
-
export const sendNotificationRequestSchema = z.object({
|
|
141
|
-
notificationId: z.string().uuid(),
|
|
142
|
-
title: z.string().max(32),
|
|
143
|
-
body: z.string().max(128),
|
|
144
|
-
targetUrl: z.string().max(256),
|
|
145
|
-
tokens: z.string().array().max(100),
|
|
146
|
-
});
|
|
147
|
-
export type SendNotificationRequest = z.infer<
|
|
148
|
-
typeof sendNotificationRequestSchema
|
|
149
|
-
>;
|
|
150
|
-
|
|
151
|
-
export const sendNotificationResponseSchema = z.object({
|
|
152
|
-
result: z.object({
|
|
153
|
-
successfulTokens: z.array(z.string()),
|
|
154
|
-
invalidTokens: z.array(z.string()),
|
|
155
|
-
rateLimitedTokens: z.array(z.string()),
|
|
156
|
-
}),
|
|
157
|
-
});
|
|
158
|
-
export type SendNotificationResponse = z.infer<
|
|
159
|
-
typeof sendNotificationResponseSchema
|
|
160
|
-
>;
|
|
161
|
-
|
|
162
102
|
export type FrameEthProviderEventData = {
|
|
163
|
-
type:
|
|
103
|
+
type: "frame_eth_provider_event";
|
|
164
104
|
} & EthProviderWireEvent;
|
|
165
105
|
|
|
166
106
|
export type RpcTransport = (
|
|
@@ -171,28 +111,31 @@ export type ProviderRpcError = {
|
|
|
171
111
|
code: number;
|
|
172
112
|
details?: string;
|
|
173
113
|
message?: string;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export type EthProviderWireEvent = {
|
|
177
|
-
event: "accountsChanged",
|
|
178
|
-
params: [readonly Address.Address[]]
|
|
179
|
-
} | {
|
|
180
|
-
event: "chainChanged",
|
|
181
|
-
params: [string]
|
|
182
|
-
} | {
|
|
183
|
-
event: "connect",
|
|
184
|
-
params: [Provider.ConnectInfo]
|
|
185
|
-
} | {
|
|
186
|
-
event: "disconnect",
|
|
187
|
-
params: [ProviderRpcError]
|
|
188
|
-
} | {
|
|
189
|
-
event: "message",
|
|
190
|
-
params: [Provider.Message]
|
|
191
114
|
};
|
|
192
115
|
|
|
193
|
-
export type
|
|
194
|
-
|
|
195
|
-
|
|
116
|
+
export type EthProviderWireEvent =
|
|
117
|
+
| {
|
|
118
|
+
event: "accountsChanged";
|
|
119
|
+
params: [readonly Address.Address[]];
|
|
120
|
+
}
|
|
121
|
+
| {
|
|
122
|
+
event: "chainChanged";
|
|
123
|
+
params: [string];
|
|
124
|
+
}
|
|
125
|
+
| {
|
|
126
|
+
event: "connect";
|
|
127
|
+
params: [Provider.ConnectInfo];
|
|
128
|
+
}
|
|
129
|
+
| {
|
|
130
|
+
event: "disconnect";
|
|
131
|
+
params: [ProviderRpcError];
|
|
132
|
+
}
|
|
133
|
+
| {
|
|
134
|
+
event: "message";
|
|
135
|
+
params: [Provider.Message];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent["event"]>(
|
|
196
139
|
event: event,
|
|
197
|
-
params: Extract<EthProviderWireEvent, { event: event }>[
|
|
140
|
+
params: Extract<EthProviderWireEvent, { event: event }>["params"]
|
|
198
141
|
) => void;
|