@farcaster/frame-core 0.0.17 → 0.0.19

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.
@@ -1,45 +1,41 @@
1
1
  import { z } from "zod";
2
2
  import { notificationDetailsSchema } from "./notifications";
3
3
 
4
- export const eventFrameAddedPayloadSchema = z.object({
4
+ export const eventFrameAddedSchema = z.object({
5
5
  event: z.literal("frame_added"),
6
6
  notificationDetails: notificationDetailsSchema.optional(),
7
7
  });
8
8
 
9
- export type EventFrameAddedPayload = z.infer<
10
- typeof eventFrameAddedPayloadSchema
11
- >;
9
+ export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>;
12
10
 
13
- export const eventFrameRemovedPayloadSchema = z.object({
11
+ export const eventFrameRemovedSchema = z.object({
14
12
  event: z.literal("frame_removed"),
15
13
  });
16
14
 
17
- export type EventFrameRemovedPayload = z.infer<
18
- typeof eventFrameRemovedPayloadSchema
19
- >;
15
+ export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>;
20
16
 
21
- export const eventNotificationsEnabledPayloadSchema = z.object({
17
+ export const eventNotificationsEnabledSchema = z.object({
22
18
  event: z.literal("notifications_enabled"),
23
19
  notificationDetails: notificationDetailsSchema.required(),
24
20
  });
25
21
 
26
- export type EventNotificationsEnabledPayload = z.infer<
27
- typeof eventNotificationsEnabledPayloadSchema
22
+ export type EventNotificationsEnabled = z.infer<
23
+ typeof eventNotificationsEnabledSchema
28
24
  >;
29
25
 
30
- export const notificationsDisabledPayloadSchema = z.object({
26
+ export const notificationsDisabledSchema = z.object({
31
27
  event: z.literal("notifications_disabled"),
32
28
  });
33
29
 
34
- export type EventNotificationsDisabledPayload = z.infer<
35
- typeof notificationsDisabledPayloadSchema
30
+ export type EventNotificationsDisabled = z.infer<
31
+ typeof notificationsDisabledSchema
36
32
  >;
37
33
 
38
- export const eventPayloadSchema = z.discriminatedUnion("event", [
39
- eventFrameAddedPayloadSchema,
40
- eventFrameRemovedPayloadSchema,
41
- eventNotificationsEnabledPayloadSchema,
42
- notificationsDisabledPayloadSchema,
34
+ export const serverEventSchema = z.discriminatedUnion("event", [
35
+ eventFrameAddedSchema,
36
+ eventFrameRemovedSchema,
37
+ eventNotificationsEnabledSchema,
38
+ notificationsDisabledSchema,
43
39
  ]);
44
40
 
45
- export type FrameEvent = z.infer<typeof eventPayloadSchema>;
41
+ export type FrameServerEvent = z.infer<typeof serverEventSchema>;
package/src/types.ts CHANGED
@@ -1,5 +1,18 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from "ox";
2
- import { FrameNotificationDetails } from "./schemas";
1
+ import type {
2
+ Address,
3
+ Provider,
4
+ RpcRequest,
5
+ RpcResponse,
6
+ RpcSchema,
7
+ } from "ox";
8
+ import {
9
+ FrameNotificationDetails,
10
+ EventFrameAdded,
11
+ EventFrameRemoved,
12
+ EventNotificationsEnabled,
13
+ EventNotificationsDisabled,
14
+ } from "./schemas";
15
+ import * as SignIn from "./actions/signIn";
3
16
 
4
17
  export type SetPrimaryButton = (options: {
5
18
  text: string;
@@ -53,6 +66,7 @@ export type FrameContext = {
53
66
  * Profile image URL
54
67
  */
55
68
  pfpUrl?: string;
69
+ location?: AccountLocation;
56
70
  };
57
71
  location?: FrameLocationContext;
58
72
  client: {
@@ -62,6 +76,10 @@ export type FrameContext = {
62
76
  };
63
77
  };
64
78
 
79
+ export type AddFrameRejectedReason =
80
+ | "invalid_domain_manifest"
81
+ | "rejected_by_user";
82
+
65
83
  export type AddFrameResult =
66
84
  | {
67
85
  added: true;
@@ -69,7 +87,7 @@ export type AddFrameResult =
69
87
  }
70
88
  | {
71
89
  added: false;
72
- reason: "invalid_domain_manifest" | "rejected_by_user";
90
+ reason: AddFrameRejectedReason;
73
91
  };
74
92
 
75
93
  export type AddFrame = () => Promise<AddFrameResult>;
@@ -88,11 +106,43 @@ export const DEFAULT_READY_OPTIONS: ReadyOptions = {
88
106
  disableNativeGestures: false,
89
107
  };
90
108
 
109
+ export type SignInOptions = {
110
+ /**
111
+ * A random string used to prevent replay attacks.
112
+ */
113
+ nonce: string;
114
+
115
+ /**
116
+ * Start time at which the signature becomes valid.
117
+ * ISO 8601 datetime.
118
+ */
119
+ notBefore?: string;
120
+
121
+ /**
122
+ * Expiration time at which the signature is no longer valid.
123
+ * ISO 8601 datetime.
124
+ */
125
+ expirationTime?: string;
126
+ };
127
+
128
+ export type WireFrameHost = {
129
+ context: FrameContext;
130
+ close: () => void;
131
+ ready: (options?: Partial<ReadyOptions>) => void;
132
+ openUrl: (url: string) => void;
133
+ signIn: SignIn.WireSignIn;
134
+ setPrimaryButton: SetPrimaryButton;
135
+ ethProviderRequest: EthProviderRequest;
136
+ ethProviderRequestV2: RpcTransport;
137
+ addFrame: AddFrame;
138
+ };
139
+
91
140
  export type FrameHost = {
92
141
  context: FrameContext;
93
142
  close: () => void;
94
143
  ready: (options?: Partial<ReadyOptions>) => void;
95
144
  openUrl: (url: string) => void;
145
+ signIn: SignIn.SignIn;
96
146
  setPrimaryButton: SetPrimaryButton;
97
147
  ethProviderRequest: EthProviderRequest;
98
148
  ethProviderRequestV2: RpcTransport;
@@ -139,3 +189,20 @@ export type EmitEthProvider = <event extends EthProviderWireEvent["event"]>(
139
189
  event: event,
140
190
  params: Extract<EthProviderWireEvent, { event: event }>["params"],
141
191
  ) => void;
192
+
193
+ export type EventFrameAddRejected = {
194
+ event: "frame_add_rejected";
195
+ reason: AddFrameRejectedReason;
196
+ };
197
+
198
+ export type EventPrimaryButtonClicked = {
199
+ event: "primary_button_clicked";
200
+ };
201
+
202
+ export type FrameClientEvent =
203
+ | EventFrameAdded
204
+ | EventFrameAddRejected
205
+ | EventFrameRemoved
206
+ | EventNotificationsEnabled
207
+ | EventNotificationsDisabled
208
+ | EventPrimaryButtonClicked;