@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.
- package/dist/actions/signIn.d.ts +40 -0
- package/dist/actions/signIn.js +47 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +24 -0
- package/dist/internal/types.d.ts +7 -0
- package/dist/internal/types.js +2 -0
- package/dist/schemas/events.d.ts +10 -10
- package/dist/schemas/events.js +10 -10
- package/dist/types.d.ts +41 -2
- package/esm/actions/signIn.d.ts +40 -0
- package/esm/actions/signIn.js +10 -0
- package/esm/errors.d.ts +10 -0
- package/esm/errors.js +8 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/internal/types.d.ts +7 -0
- package/esm/internal/types.js +1 -0
- package/esm/schemas/events.d.ts +10 -10
- package/esm/schemas/events.js +9 -9
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +41 -2
- package/package.json +1 -1
- package/src/actions/signIn.ts +50 -0
- package/src/errors.ts +17 -0
- package/src/index.ts +1 -0
- package/src/internal/types.ts +21 -0
- package/src/schemas/events.ts +16 -20
- package/src/types.ts +70 -3
package/src/schemas/events.ts
CHANGED
|
@@ -1,45 +1,41 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { notificationDetailsSchema } from "./notifications";
|
|
3
3
|
|
|
4
|
-
export const
|
|
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
|
|
10
|
-
typeof eventFrameAddedPayloadSchema
|
|
11
|
-
>;
|
|
9
|
+
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>;
|
|
12
10
|
|
|
13
|
-
export const
|
|
11
|
+
export const eventFrameRemovedSchema = z.object({
|
|
14
12
|
event: z.literal("frame_removed"),
|
|
15
13
|
});
|
|
16
14
|
|
|
17
|
-
export type
|
|
18
|
-
typeof eventFrameRemovedPayloadSchema
|
|
19
|
-
>;
|
|
15
|
+
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>;
|
|
20
16
|
|
|
21
|
-
export const
|
|
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
|
|
27
|
-
typeof
|
|
22
|
+
export type EventNotificationsEnabled = z.infer<
|
|
23
|
+
typeof eventNotificationsEnabledSchema
|
|
28
24
|
>;
|
|
29
25
|
|
|
30
|
-
export const
|
|
26
|
+
export const notificationsDisabledSchema = z.object({
|
|
31
27
|
event: z.literal("notifications_disabled"),
|
|
32
28
|
});
|
|
33
29
|
|
|
34
|
-
export type
|
|
35
|
-
typeof
|
|
30
|
+
export type EventNotificationsDisabled = z.infer<
|
|
31
|
+
typeof notificationsDisabledSchema
|
|
36
32
|
>;
|
|
37
33
|
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
export const serverEventSchema = z.discriminatedUnion("event", [
|
|
35
|
+
eventFrameAddedSchema,
|
|
36
|
+
eventFrameRemovedSchema,
|
|
37
|
+
eventNotificationsEnabledSchema,
|
|
38
|
+
notificationsDisabledSchema,
|
|
43
39
|
]);
|
|
44
40
|
|
|
45
|
-
export type
|
|
41
|
+
export type FrameServerEvent = z.infer<typeof serverEventSchema>;
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
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:
|
|
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;
|