@farcaster/frame-core 0.0.21 → 0.0.22
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/AddFrame.d.ts +36 -0
- package/dist/actions/AddFrame.js +57 -0
- package/dist/actions/{signIn.d.ts → SignIn.d.ts} +7 -6
- package/dist/actions/{signIn.js → SignIn.js} +1 -1
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +38 -0
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -25
- package/dist/internal/types.d.ts +3 -2
- package/dist/schemas/embeds.d.ts +1 -1
- package/dist/schemas/embeds.js +3 -3
- package/dist/schemas/events.d.ts +1 -1
- package/dist/schemas/events.js +5 -5
- package/dist/schemas/index.d.ts +5 -5
- package/dist/schemas/manifest.d.ts +1 -1
- package/dist/schemas/manifest.js +4 -4
- package/dist/schemas/notifications.d.ts +1 -1
- package/dist/schemas/shared.d.ts +1 -1
- package/dist/schemas/shared.js +4 -4
- package/dist/types.d.ts +42 -31
- package/esm/actions/AddFrame.d.ts +40 -0
- package/esm/actions/AddFrame.js +19 -0
- package/esm/actions/SignIn.d.ts +43 -0
- package/esm/actions/SignIn.js +10 -0
- package/esm/actions/index.d.ts +2 -0
- package/esm/actions/index.js +2 -0
- package/esm/errors.d.ts +9 -7
- package/esm/errors.js +6 -6
- package/esm/index.d.ts +3 -3
- package/esm/index.js +3 -3
- package/esm/internal/types.d.ts +19 -7
- package/esm/internal/types.js +1 -1
- package/esm/schemas/embeds.d.ts +231 -169
- package/esm/schemas/embeds.js +25 -19
- package/esm/schemas/events.d.ts +225 -129
- package/esm/schemas/events.js +18 -18
- package/esm/schemas/index.d.ts +5 -5
- package/esm/schemas/index.js +5 -5
- package/esm/schemas/manifest.d.ts +154 -110
- package/esm/schemas/manifest.js +29 -23
- package/esm/schemas/notifications.d.ts +86 -58
- package/esm/schemas/notifications.js +17 -17
- package/esm/schemas/shared.d.ts +49 -33
- package/esm/schemas/shared.js +20 -19
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +180 -140
- package/esm/types.js +2 -2
- package/package.json +4 -5
- package/src/actions/AddFrame.ts +51 -0
- package/src/actions/SignIn.ts +51 -0
- package/src/actions/index.ts +2 -0
- package/src/errors.ts +4 -4
- package/src/index.ts +3 -3
- package/src/internal/types.ts +3 -4
- package/src/schemas/embeds.ts +13 -13
- package/src/schemas/events.ts +17 -17
- package/src/schemas/index.ts +5 -5
- package/src/schemas/manifest.ts +11 -11
- package/src/schemas/notifications.ts +8 -10
- package/src/schemas/shared.ts +13 -13
- package/src/types.ts +125 -124
- package/esm/actions/signIn.d.ts +0 -40
- package/esm/actions/signIn.js +0 -10
- package/src/actions/signIn.ts +0 -50
package/esm/types.d.ts
CHANGED
|
@@ -1,155 +1,195 @@
|
|
|
1
|
-
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export type
|
|
1
|
+
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
|
|
2
|
+
import type { AddFrame, SignIn } from './actions'
|
|
3
|
+
import type {
|
|
4
|
+
EventFrameAdded,
|
|
5
|
+
EventFrameRemoved,
|
|
6
|
+
EventNotificationsDisabled,
|
|
7
|
+
EventNotificationsEnabled,
|
|
8
|
+
FrameNotificationDetails,
|
|
9
|
+
} from './schemas'
|
|
10
|
+
export type SetPrimaryButtonOptions = {
|
|
11
|
+
text: string
|
|
12
|
+
loading?: boolean
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
hidden?: boolean
|
|
15
|
+
}
|
|
16
|
+
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
|
|
17
|
+
export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>
|
|
11
18
|
export type AccountLocation = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
19
|
+
placeId: string
|
|
20
|
+
/**
|
|
21
|
+
* Human-readable string describing the location
|
|
22
|
+
*/
|
|
23
|
+
description: string
|
|
24
|
+
}
|
|
18
25
|
export type FrameLocationContextCastEmbed = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
+
type: 'cast_embed'
|
|
27
|
+
embed: string
|
|
28
|
+
cast: {
|
|
29
|
+
fid: number
|
|
30
|
+
hash: string
|
|
31
|
+
}
|
|
32
|
+
}
|
|
26
33
|
export type FrameLocationContextNotification = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
+
type: 'notification'
|
|
35
|
+
notification: {
|
|
36
|
+
notificationId: string
|
|
37
|
+
title: string
|
|
38
|
+
body: string
|
|
39
|
+
}
|
|
40
|
+
}
|
|
34
41
|
export type FrameLocationContextLauncher = {
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
export type FrameLocationContext =
|
|
42
|
+
type: 'launcher'
|
|
43
|
+
}
|
|
44
|
+
export type FrameLocationContext =
|
|
45
|
+
| FrameLocationContextCastEmbed
|
|
46
|
+
| FrameLocationContextNotification
|
|
47
|
+
| FrameLocationContextLauncher
|
|
38
48
|
export type SafeAreaInsets = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
49
|
+
top: number
|
|
50
|
+
bottom: number
|
|
51
|
+
left: number
|
|
52
|
+
right: number
|
|
53
|
+
}
|
|
44
54
|
export type FrameContext = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Profile image URL
|
|
51
|
-
*/
|
|
52
|
-
pfpUrl?: string;
|
|
53
|
-
location?: AccountLocation;
|
|
54
|
-
};
|
|
55
|
-
location?: FrameLocationContext;
|
|
56
|
-
client: {
|
|
57
|
-
clientFid: number;
|
|
58
|
-
added: boolean;
|
|
59
|
-
notificationDetails?: FrameNotificationDetails;
|
|
60
|
-
safeAreaInsets?: SafeAreaInsets;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export type AddFrameRejectedReason = "invalid_domain_manifest" | "rejected_by_user";
|
|
64
|
-
export type AddFrameResult = {
|
|
65
|
-
added: true;
|
|
66
|
-
notificationDetails?: FrameNotificationDetails;
|
|
67
|
-
} | {
|
|
68
|
-
added: false;
|
|
69
|
-
reason: AddFrameRejectedReason;
|
|
70
|
-
};
|
|
71
|
-
export type AddFrame = () => Promise<AddFrameResult>;
|
|
72
|
-
export type ReadyOptions = {
|
|
55
|
+
user: {
|
|
56
|
+
fid: number
|
|
57
|
+
username?: string
|
|
58
|
+
displayName?: string
|
|
73
59
|
/**
|
|
74
|
-
*
|
|
75
|
-
* that conflict with native gestures.
|
|
76
|
-
*
|
|
77
|
-
* @defaultValue false
|
|
60
|
+
* Profile image URL
|
|
78
61
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
pfpUrl?: string
|
|
63
|
+
location?: AccountLocation
|
|
64
|
+
}
|
|
65
|
+
location?: FrameLocationContext
|
|
66
|
+
client: {
|
|
67
|
+
clientFid: number
|
|
68
|
+
added: boolean
|
|
69
|
+
notificationDetails?: FrameNotificationDetails
|
|
70
|
+
safeAreaInsets?: SafeAreaInsets
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export type ReadyOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* Disable native gestures. Use this option if your frame uses gestures
|
|
76
|
+
* that conflict with native gestures.
|
|
77
|
+
*
|
|
78
|
+
* @defaultValue false
|
|
79
|
+
*/
|
|
80
|
+
disableNativeGestures: boolean
|
|
81
|
+
}
|
|
82
|
+
export declare const DEFAULT_READY_OPTIONS: ReadyOptions
|
|
82
83
|
export type SignInOptions = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
84
|
+
/**
|
|
85
|
+
* A random string used to prevent replay attacks.
|
|
86
|
+
*/
|
|
87
|
+
nonce: string
|
|
88
|
+
/**
|
|
89
|
+
* Start time at which the signature becomes valid.
|
|
90
|
+
* ISO 8601 datetime.
|
|
91
|
+
*/
|
|
92
|
+
notBefore?: string
|
|
93
|
+
/**
|
|
94
|
+
* Expiration time at which the signature is no longer valid.
|
|
95
|
+
* ISO 8601 datetime.
|
|
96
|
+
*/
|
|
97
|
+
expirationTime?: string
|
|
98
|
+
}
|
|
98
99
|
export type WireFrameHost = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
context: FrameContext
|
|
101
|
+
close: () => void
|
|
102
|
+
ready: (options?: Partial<ReadyOptions>) => void
|
|
103
|
+
openUrl: (url: string) => void
|
|
104
|
+
signIn: SignIn.WireSignIn
|
|
105
|
+
setPrimaryButton: SetPrimaryButton
|
|
106
|
+
ethProviderRequest: EthProviderRequest
|
|
107
|
+
ethProviderRequestV2: RpcTransport
|
|
108
|
+
eip6963RequestProvider: () => void
|
|
109
|
+
addFrame: AddFrame.WireAddFrame
|
|
110
|
+
}
|
|
109
111
|
export type FrameHost = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
context: FrameContext
|
|
113
|
+
close: () => void
|
|
114
|
+
ready: (options?: Partial<ReadyOptions>) => void
|
|
115
|
+
openUrl: (url: string) => void
|
|
116
|
+
signIn: SignIn.SignIn
|
|
117
|
+
setPrimaryButton: SetPrimaryButton
|
|
118
|
+
ethProviderRequest: EthProviderRequest
|
|
119
|
+
ethProviderRequestV2: RpcTransport
|
|
120
|
+
/**
|
|
121
|
+
* Receive forwarded eip6963:requestProvider events from the frame document.
|
|
122
|
+
* Hosts must emit an EventEip6963AnnounceProvider in response.
|
|
123
|
+
*/
|
|
124
|
+
eip6963RequestProvider: () => void
|
|
125
|
+
addFrame: AddFrame.AddFrame
|
|
126
|
+
}
|
|
120
127
|
export type FrameEthProviderEventData = {
|
|
121
|
-
|
|
122
|
-
} & EthProviderWireEvent
|
|
123
|
-
export type RpcTransport = (
|
|
128
|
+
type: 'frame_eth_provider_event'
|
|
129
|
+
} & EthProviderWireEvent
|
|
130
|
+
export type RpcTransport = (
|
|
131
|
+
request: RpcRequest.RpcRequest,
|
|
132
|
+
) => Promise<RpcResponse.RpcResponse>
|
|
124
133
|
export type ProviderRpcError = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
export type EthProviderWireEvent =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
code: number
|
|
135
|
+
details?: string
|
|
136
|
+
message?: string
|
|
137
|
+
}
|
|
138
|
+
export type EthProviderWireEvent =
|
|
139
|
+
| {
|
|
140
|
+
event: 'accountsChanged'
|
|
141
|
+
params: [readonly Address.Address[]]
|
|
142
|
+
}
|
|
143
|
+
| {
|
|
144
|
+
event: 'chainChanged'
|
|
145
|
+
params: [string]
|
|
146
|
+
}
|
|
147
|
+
| {
|
|
148
|
+
event: 'connect'
|
|
149
|
+
params: [Provider.ConnectInfo]
|
|
150
|
+
}
|
|
151
|
+
| {
|
|
152
|
+
event: 'disconnect'
|
|
153
|
+
params: [ProviderRpcError]
|
|
154
|
+
}
|
|
155
|
+
| {
|
|
156
|
+
event: 'message'
|
|
157
|
+
params: [Provider.Message]
|
|
158
|
+
}
|
|
159
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
|
|
160
|
+
event: event,
|
|
161
|
+
params: Extract<
|
|
162
|
+
EthProviderWireEvent,
|
|
163
|
+
{
|
|
164
|
+
event: event
|
|
165
|
+
}
|
|
166
|
+
>['params'],
|
|
167
|
+
) => void
|
|
148
168
|
export type EventFrameAddRejected = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
169
|
+
event: 'frame_add_rejected'
|
|
170
|
+
reason: AddFrame.AddFrameRejectedReason
|
|
171
|
+
}
|
|
152
172
|
export type EventPrimaryButtonClicked = {
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
173
|
+
event: 'primary_button_clicked'
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Metadata of the EIP-1193 Provider.
|
|
177
|
+
*/
|
|
178
|
+
export interface EIP6963ProviderInfo {
|
|
179
|
+
icon: `data:image/${string}`
|
|
180
|
+
name: string
|
|
181
|
+
rdns: string
|
|
182
|
+
uuid: string
|
|
183
|
+
}
|
|
184
|
+
export type EventEip6963AnnounceProvider = {
|
|
185
|
+
event: 'eip6963:announceProvider'
|
|
186
|
+
info: EIP6963ProviderInfo
|
|
187
|
+
}
|
|
188
|
+
export type FrameClientEvent =
|
|
189
|
+
| EventFrameAdded
|
|
190
|
+
| EventFrameAddRejected
|
|
191
|
+
| EventFrameRemoved
|
|
192
|
+
| EventNotificationsEnabled
|
|
193
|
+
| EventNotificationsDisabled
|
|
194
|
+
| EventPrimaryButtonClicked
|
|
195
|
+
| EventEip6963AnnounceProvider
|
package/esm/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const DEFAULT_READY_OPTIONS = {
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
disableNativeGestures: false,
|
|
3
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farcaster/frame-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"
|
|
13
|
-
"typescript": "^5.6.3",
|
|
12
|
+
"typescript": "^5.7.2",
|
|
14
13
|
"@farcaster/tsconfig": "0.0.2"
|
|
15
14
|
},
|
|
16
15
|
"dependencies": {
|
|
17
|
-
"ox": "^0.4.
|
|
18
|
-
"zod": "^3.
|
|
16
|
+
"ox": "^0.4.4",
|
|
17
|
+
"zod": "^3.24.1"
|
|
19
18
|
},
|
|
20
19
|
"publishConfig": {
|
|
21
20
|
"access": "public"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as Errors from '../errors'
|
|
2
|
+
import type { OneOf } from '../internal/types'
|
|
3
|
+
import type { FrameNotificationDetails } from '../schemas'
|
|
4
|
+
|
|
5
|
+
export type AddFrameResult = {
|
|
6
|
+
notificationDetails?: FrameNotificationDetails
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AddFrame = () => Promise<AddFrameResult>
|
|
10
|
+
|
|
11
|
+
type InvalidDomainManifestJsonError = {
|
|
12
|
+
type: 'invalid_domain_manifest'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type RejectedByUserJsonError = {
|
|
16
|
+
type: 'rejected_by_user'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type AddFrameJsonError =
|
|
20
|
+
| InvalidDomainManifestJsonError
|
|
21
|
+
| RejectedByUserJsonError
|
|
22
|
+
|
|
23
|
+
export type AddFrameRejectedReason = AddFrameJsonError['type']
|
|
24
|
+
|
|
25
|
+
export type AddFrameJsonResult = OneOf<
|
|
26
|
+
{ result: AddFrameResult } | { error: AddFrameJsonError }
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
export type WireAddFrame = () => Promise<AddFrameJsonResult>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when the frame does not have a valid domain manifest.
|
|
33
|
+
*/
|
|
34
|
+
export class InvalidDomainManifest extends Errors.BaseError {
|
|
35
|
+
override readonly name = 'AddFrame.InvalidDomainManifest'
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super('Invalid domain manifest')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when add frame action was rejected by the user.
|
|
44
|
+
*/
|
|
45
|
+
export class RejectedByUser extends Errors.BaseError {
|
|
46
|
+
override readonly name = 'AddFrame.RejectedByUser'
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
super('Add frame rejected by user')
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as Errors from '../errors'
|
|
2
|
+
import type { OneOf } from '../internal/types'
|
|
3
|
+
|
|
4
|
+
export type SignInOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* A random string used to prevent replay attacks.
|
|
7
|
+
*/
|
|
8
|
+
nonce: string
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Start time at which the signature becomes valid.
|
|
12
|
+
* ISO 8601 datetime.
|
|
13
|
+
*/
|
|
14
|
+
notBefore?: string
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Expiration time at which the signature is no longer valid.
|
|
18
|
+
* ISO 8601 datetime.
|
|
19
|
+
*/
|
|
20
|
+
expirationTime?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type SignInResult = {
|
|
24
|
+
signature: string
|
|
25
|
+
message: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SignIn = (options: SignInOptions) => Promise<SignInResult>
|
|
29
|
+
|
|
30
|
+
type RejectedByUserJsonError = {
|
|
31
|
+
type: 'rejected_by_user'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type SignInJsonError = RejectedByUserJsonError
|
|
35
|
+
|
|
36
|
+
export type SignInJsonResult = OneOf<
|
|
37
|
+
{ result: SignInResult } | { error: SignInJsonError }
|
|
38
|
+
>
|
|
39
|
+
|
|
40
|
+
export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when a sign in action was rejected.
|
|
44
|
+
*/
|
|
45
|
+
export class RejectedByUser extends Errors.BaseError {
|
|
46
|
+
override readonly name = 'SignIn.RejectedByUser'
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
super('Sign in rejected by user')
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export class BaseError<
|
|
2
|
-
cause extends Error | undefined = undefined
|
|
2
|
+
cause extends Error | undefined = undefined,
|
|
3
3
|
> extends Error {
|
|
4
|
-
override name =
|
|
5
|
-
cause: cause
|
|
4
|
+
override name = 'BaseError'
|
|
5
|
+
cause: cause
|
|
6
6
|
|
|
7
7
|
constructor(message: string, options: BaseError.Options<cause> = {}) {
|
|
8
8
|
super(message, options.cause ? { cause: options.cause } : undefined)
|
|
9
|
-
this.cause = options.cause as any
|
|
9
|
+
this.cause = options.cause as any
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './actions'
|
|
2
|
+
export * from './schemas'
|
|
3
|
+
export * from './types'
|
package/src/internal/types.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type Compute<type> = { [key in keyof type]: type[key] } & unknown
|
|
2
|
+
|
|
3
|
+
type KeyofUnion<type> = type extends type ? keyof type : never
|
|
2
4
|
|
|
3
5
|
export type OneOf<
|
|
4
6
|
union extends object,
|
|
@@ -16,6 +18,3 @@ export type OneOf<
|
|
|
16
18
|
}
|
|
17
19
|
>
|
|
18
20
|
: never
|
|
19
|
-
|
|
20
|
-
export type KeyofUnion<type> = type extends type ? keyof type : never
|
|
21
|
-
|
package/src/schemas/embeds.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
buttonTitleSchema,
|
|
4
4
|
frameNameSchema,
|
|
5
|
+
hexColorSchema,
|
|
5
6
|
secureUrlSchema,
|
|
6
|
-
|
|
7
|
-
} from "./shared";
|
|
7
|
+
} from './shared'
|
|
8
8
|
|
|
9
9
|
export const actionLaunchFrameSchema = z.object({
|
|
10
|
-
type: z.literal(
|
|
10
|
+
type: z.literal('launch_frame'),
|
|
11
11
|
name: frameNameSchema,
|
|
12
12
|
url: secureUrlSchema,
|
|
13
13
|
splashImageUrl: secureUrlSchema.optional(),
|
|
14
14
|
splashBackgroundColor: hexColorSchema.optional(),
|
|
15
|
-
})
|
|
15
|
+
})
|
|
16
16
|
|
|
17
|
-
export const actionSchema = z.discriminatedUnion(
|
|
17
|
+
export const actionSchema = z.discriminatedUnion('type', [
|
|
18
18
|
actionLaunchFrameSchema,
|
|
19
|
-
])
|
|
19
|
+
])
|
|
20
20
|
|
|
21
21
|
export const buttonSchema = z.object({
|
|
22
22
|
title: buttonTitleSchema,
|
|
23
23
|
action: actionSchema,
|
|
24
|
-
})
|
|
24
|
+
})
|
|
25
25
|
|
|
26
26
|
export const frameEmbedNextSchema = z.object({
|
|
27
|
-
version: z.literal(
|
|
27
|
+
version: z.literal('next'),
|
|
28
28
|
imageUrl: secureUrlSchema,
|
|
29
29
|
button: buttonSchema,
|
|
30
|
-
})
|
|
30
|
+
})
|
|
31
31
|
|
|
32
32
|
export const safeParseFrameEmbed = (rawResponse: unknown) =>
|
|
33
|
-
frameEmbedNextSchema.safeParse(rawResponse)
|
|
33
|
+
frameEmbedNextSchema.safeParse(rawResponse)
|
|
34
34
|
|
|
35
|
-
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema
|
|
35
|
+
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema>
|
package/src/schemas/events.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { notificationDetailsSchema } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { notificationDetailsSchema } from './notifications'
|
|
3
3
|
|
|
4
4
|
export const eventFrameAddedSchema = z.object({
|
|
5
|
-
event: z.literal(
|
|
5
|
+
event: z.literal('frame_added'),
|
|
6
6
|
notificationDetails: notificationDetailsSchema.optional(),
|
|
7
|
-
})
|
|
7
|
+
})
|
|
8
8
|
|
|
9
|
-
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema
|
|
9
|
+
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>
|
|
10
10
|
|
|
11
11
|
export const eventFrameRemovedSchema = z.object({
|
|
12
|
-
event: z.literal(
|
|
13
|
-
})
|
|
12
|
+
event: z.literal('frame_removed'),
|
|
13
|
+
})
|
|
14
14
|
|
|
15
|
-
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema
|
|
15
|
+
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>
|
|
16
16
|
|
|
17
17
|
export const eventNotificationsEnabledSchema = z.object({
|
|
18
|
-
event: z.literal(
|
|
18
|
+
event: z.literal('notifications_enabled'),
|
|
19
19
|
notificationDetails: notificationDetailsSchema.required(),
|
|
20
|
-
})
|
|
20
|
+
})
|
|
21
21
|
|
|
22
22
|
export type EventNotificationsEnabled = z.infer<
|
|
23
23
|
typeof eventNotificationsEnabledSchema
|
|
24
|
-
|
|
24
|
+
>
|
|
25
25
|
|
|
26
26
|
export const notificationsDisabledSchema = z.object({
|
|
27
|
-
event: z.literal(
|
|
28
|
-
})
|
|
27
|
+
event: z.literal('notifications_disabled'),
|
|
28
|
+
})
|
|
29
29
|
|
|
30
30
|
export type EventNotificationsDisabled = z.infer<
|
|
31
31
|
typeof notificationsDisabledSchema
|
|
32
|
-
|
|
32
|
+
>
|
|
33
33
|
|
|
34
|
-
export const serverEventSchema = z.discriminatedUnion(
|
|
34
|
+
export const serverEventSchema = z.discriminatedUnion('event', [
|
|
35
35
|
eventFrameAddedSchema,
|
|
36
36
|
eventFrameRemovedSchema,
|
|
37
37
|
eventNotificationsEnabledSchema,
|
|
38
38
|
notificationsDisabledSchema,
|
|
39
|
-
])
|
|
39
|
+
])
|
|
40
40
|
|
|
41
|
-
export type FrameServerEvent = z.infer<typeof serverEventSchema
|
|
41
|
+
export type FrameServerEvent = z.infer<typeof serverEventSchema>
|
package/src/schemas/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './embeds'
|
|
2
|
+
export * from './events'
|
|
3
|
+
export * from './shared'
|
|
4
|
+
export * from './manifest'
|
|
5
|
+
export * from './notifications'
|