@farcaster/frame-core 0.0.0-canary-20250630194123 → 0.0.0-canary-20250630212526
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 +153 -10
- package/dist/index.js +18 -33
- package/esm/index.d.ts +153 -10
- package/esm/index.js +17 -10
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -7
- package/src/index.ts +50 -10
- package/dist/actions/AddMiniApp.d.ts +0 -36
- package/dist/actions/AddMiniApp.js +0 -57
- package/dist/actions/ComposeCast.d.ts +0 -37
- package/dist/actions/ComposeCast.js +0 -2
- package/dist/actions/Haptics.d.ts +0 -5
- package/dist/actions/Haptics.js +0 -2
- package/dist/actions/Ready.d.ts +0 -13
- package/dist/actions/Ready.js +0 -6
- package/dist/actions/SendToken.d.ts +0 -48
- package/dist/actions/SendToken.js +0 -2
- package/dist/actions/SignIn.d.ts +0 -55
- package/dist/actions/SignIn.js +0 -47
- package/dist/actions/SwapToken.d.ts +0 -46
- package/dist/actions/SwapToken.js +0 -2
- package/dist/actions/ViewCast.d.ts +0 -25
- package/dist/actions/ViewCast.js +0 -2
- package/dist/actions/ViewProfile.d.ts +0 -4
- package/dist/actions/ViewProfile.js +0 -2
- package/dist/actions/ViewToken.d.ts +0 -4
- package/dist/actions/ViewToken.js +0 -2
- package/dist/actions/index.d.ts +0 -10
- package/dist/actions/index.js +0 -46
- package/dist/back.d.ts +0 -13
- package/dist/back.js +0 -6
- package/dist/context.d.ts +0 -94
- package/dist/context.js +0 -2
- package/dist/errors.d.ts +0 -13
- package/dist/errors.js +0 -12
- package/dist/internal/types.d.ts +0 -8
- package/dist/internal/types.js +0 -2
- package/dist/manifest.d.ts +0 -107
- package/dist/manifest.js +0 -2
- package/dist/schemas/embeds.d.ts +0 -72
- package/dist/schemas/embeds.js +0 -32
- package/dist/schemas/events.d.ts +0 -43
- package/dist/schemas/events.js +0 -25
- package/dist/schemas/index.d.ts +0 -5
- package/dist/schemas/index.js +0 -21
- package/dist/schemas/manifest.d.ts +0 -160
- package/dist/schemas/manifest.js +0 -114
- package/dist/schemas/notifications.d.ts +0 -22
- package/dist/schemas/notifications.js +0 -23
- package/dist/schemas/shared.d.ts +0 -24
- package/dist/schemas/shared.js +0 -110
- package/dist/solana.d.ts +0 -72
- package/dist/solana.js +0 -15
- package/dist/solanaWire.d.ts +0 -3
- package/dist/solanaWire.js +0 -84
- package/dist/types.d.ts +0 -87
- package/dist/types.js +0 -41
- package/dist/wallet/ethereum.d.ts +0 -47
- package/dist/wallet/ethereum.js +0 -2
- package/dist/wallet/index.d.ts +0 -1
- package/dist/wallet/index.js +0 -37
- package/esm/actions/AddMiniApp.d.ts +0 -36
- package/esm/actions/AddMiniApp.js +0 -19
- package/esm/actions/ComposeCast.d.ts +0 -37
- package/esm/actions/ComposeCast.js +0 -1
- package/esm/actions/Haptics.d.ts +0 -5
- package/esm/actions/Haptics.js +0 -1
- package/esm/actions/Ready.d.ts +0 -13
- package/esm/actions/Ready.js +0 -3
- package/esm/actions/SendToken.d.ts +0 -48
- package/esm/actions/SendToken.js +0 -1
- package/esm/actions/SignIn.d.ts +0 -55
- package/esm/actions/SignIn.js +0 -10
- package/esm/actions/SwapToken.d.ts +0 -46
- package/esm/actions/SwapToken.js +0 -1
- package/esm/actions/ViewCast.d.ts +0 -25
- package/esm/actions/ViewCast.js +0 -1
- package/esm/actions/ViewProfile.d.ts +0 -4
- package/esm/actions/ViewProfile.js +0 -1
- package/esm/actions/ViewToken.d.ts +0 -4
- package/esm/actions/ViewToken.js +0 -1
- package/esm/actions/index.d.ts +0 -10
- package/esm/actions/index.js +0 -10
- package/esm/back.d.ts +0 -13
- package/esm/back.js +0 -3
- package/esm/context.d.ts +0 -94
- package/esm/context.js +0 -1
- package/esm/errors.d.ts +0 -13
- package/esm/errors.js +0 -8
- package/esm/internal/types.d.ts +0 -8
- package/esm/internal/types.js +0 -1
- package/esm/manifest.d.ts +0 -107
- package/esm/manifest.js +0 -1
- package/esm/schemas/embeds.d.ts +0 -72
- package/esm/schemas/embeds.js +0 -28
- package/esm/schemas/events.d.ts +0 -43
- package/esm/schemas/events.js +0 -22
- package/esm/schemas/index.d.ts +0 -5
- package/esm/schemas/index.js +0 -5
- package/esm/schemas/manifest.d.ts +0 -160
- package/esm/schemas/manifest.js +0 -111
- package/esm/schemas/notifications.d.ts +0 -22
- package/esm/schemas/notifications.js +0 -20
- package/esm/schemas/shared.d.ts +0 -24
- package/esm/schemas/shared.js +0 -106
- package/esm/solana.d.ts +0 -72
- package/esm/solana.js +0 -11
- package/esm/solanaWire.d.ts +0 -3
- package/esm/solanaWire.js +0 -80
- package/esm/types.d.ts +0 -87
- package/esm/types.js +0 -23
- package/esm/wallet/ethereum.d.ts +0 -47
- package/esm/wallet/ethereum.js +0 -1
- package/esm/wallet/index.d.ts +0 -1
- package/esm/wallet/index.js +0 -1
- package/src/actions/AddMiniApp.ts +0 -51
- package/src/actions/ComposeCast.ts +0 -44
- package/src/actions/Haptics.ts +0 -9
- package/src/actions/Ready.ts +0 -15
- package/src/actions/SendToken.ts +0 -57
- package/src/actions/SignIn.ts +0 -67
- package/src/actions/SwapToken.ts +0 -54
- package/src/actions/ViewCast.ts +0 -27
- package/src/actions/ViewProfile.ts +0 -5
- package/src/actions/ViewToken.ts +0 -5
- package/src/actions/index.ts +0 -10
- package/src/back.ts +0 -15
- package/src/context.ts +0 -117
- package/src/errors.ts +0 -21
- package/src/internal/types.ts +0 -20
- package/src/manifest.ts +0 -120
- package/src/schemas/embeds.ts +0 -44
- package/src/schemas/events.ts +0 -41
- package/src/schemas/index.ts +0 -5
- package/src/schemas/manifest.ts +0 -125
- package/src/schemas/notifications.ts +0 -33
- package/src/schemas/shared.ts +0 -138
- package/src/solana.ts +0 -108
- package/src/solanaWire.ts +0 -120
- package/src/types.ts +0 -155
- package/src/wallet/ethereum.ts +0 -65
- package/src/wallet/index.ts +0 -1
package/src/actions/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * as AddMiniApp from './AddMiniApp.ts'
|
|
2
|
-
export * as ComposeCast from './ComposeCast.ts'
|
|
3
|
-
export * as Haptics from './Haptics.ts'
|
|
4
|
-
export * as Ready from './Ready.ts'
|
|
5
|
-
export * as SignIn from './SignIn.ts'
|
|
6
|
-
export * as SendToken from './SendToken.ts'
|
|
7
|
-
export * as SwapToken from './SwapToken.ts'
|
|
8
|
-
export * as ViewCast from './ViewCast.ts'
|
|
9
|
-
export * as ViewProfile from './ViewProfile.ts'
|
|
10
|
-
export * as ViewToken from './ViewToken.ts'
|
package/src/back.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type BackState = {
|
|
2
|
-
/**
|
|
3
|
-
* Is the back control visible. Note that on mobile devices Farcaster clients
|
|
4
|
-
* may support a gesture based control rather than button control.
|
|
5
|
-
*
|
|
6
|
-
* @default false
|
|
7
|
-
*/
|
|
8
|
-
visible: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const DEFAULT_BACK_STATE = {
|
|
12
|
-
visible: false,
|
|
13
|
-
} satisfies BackState
|
|
14
|
-
|
|
15
|
-
export type UpdateBackState = (state: BackState) => Promise<void>
|
package/src/context.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { FrameNotificationDetails } from './schemas/index.ts'
|
|
2
|
-
|
|
3
|
-
export type MiniappUser = {
|
|
4
|
-
fid: number
|
|
5
|
-
username?: string
|
|
6
|
-
displayName?: string
|
|
7
|
-
pfpUrl?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface MiniappCast {
|
|
11
|
-
author: MiniappUser
|
|
12
|
-
hash: string
|
|
13
|
-
parentHash?: string
|
|
14
|
-
parentFid?: number
|
|
15
|
-
timestamp?: number
|
|
16
|
-
mentions?: MiniappUser[]
|
|
17
|
-
text: string
|
|
18
|
-
embeds?: string[]
|
|
19
|
-
channelKey?: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type CastEmbedLocationContext = {
|
|
23
|
-
type: 'cast_embed'
|
|
24
|
-
embed: string
|
|
25
|
-
cast: MiniappCast
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type CastShareLocationContext = {
|
|
29
|
-
type: 'cast_share'
|
|
30
|
-
cast: MiniappCast
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type NotificationLocationContext = {
|
|
34
|
-
type: 'notification'
|
|
35
|
-
notification: {
|
|
36
|
-
notificationId: string
|
|
37
|
-
title: string
|
|
38
|
-
body: string
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type LauncherLocationContext = {
|
|
43
|
-
type: 'launcher'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type ChannelLocationContext = {
|
|
47
|
-
type: 'channel'
|
|
48
|
-
channel: {
|
|
49
|
-
/**
|
|
50
|
-
* Channel key identifier
|
|
51
|
-
*/
|
|
52
|
-
key: string
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Channel name
|
|
56
|
-
*/
|
|
57
|
-
name: string
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Channel profile image URL
|
|
61
|
-
*/
|
|
62
|
-
imageUrl?: string
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type LocationContext =
|
|
67
|
-
| CastEmbedLocationContext
|
|
68
|
-
| CastShareLocationContext
|
|
69
|
-
| NotificationLocationContext
|
|
70
|
-
| LauncherLocationContext
|
|
71
|
-
| ChannelLocationContext
|
|
72
|
-
|
|
73
|
-
export type AccountLocation = {
|
|
74
|
-
placeId: string
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Human-readable string describing the location
|
|
78
|
-
*/
|
|
79
|
-
description: string
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export type UserContext = {
|
|
83
|
-
fid: number
|
|
84
|
-
username?: string
|
|
85
|
-
displayName?: string
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Profile image URL
|
|
89
|
-
*/
|
|
90
|
-
pfpUrl?: string
|
|
91
|
-
location?: AccountLocation
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type SafeAreaInsets = {
|
|
95
|
-
top: number
|
|
96
|
-
bottom: number
|
|
97
|
-
left: number
|
|
98
|
-
right: number
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export type ClientContext = {
|
|
102
|
-
clientFid: number
|
|
103
|
-
added: boolean
|
|
104
|
-
notificationDetails?: FrameNotificationDetails
|
|
105
|
-
safeAreaInsets?: SafeAreaInsets
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export type ClientFeatures = {
|
|
109
|
-
haptics: boolean
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type FrameContext = {
|
|
113
|
-
client: ClientContext
|
|
114
|
-
user: UserContext
|
|
115
|
-
location?: LocationContext
|
|
116
|
-
features?: ClientFeatures
|
|
117
|
-
}
|
package/src/errors.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type GlobalErrorType<name extends string = 'Error'> = Error & {
|
|
2
|
-
name: name
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export class BaseError<
|
|
6
|
-
cause extends Error | undefined = undefined,
|
|
7
|
-
> extends Error {
|
|
8
|
-
override name = 'BaseError'
|
|
9
|
-
cause: cause
|
|
10
|
-
|
|
11
|
-
constructor(message: string, options: BaseError.Options<cause> = {}) {
|
|
12
|
-
super(message, options.cause ? { cause: options.cause } : undefined)
|
|
13
|
-
this.cause = options.cause as any
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export declare namespace BaseError {
|
|
18
|
-
type Options<cause extends Error | undefined = Error | undefined> = {
|
|
19
|
-
cause?: cause | undefined
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/internal/types.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type Compute<type> = { [key in keyof type]: type[key] } & unknown
|
|
2
|
-
|
|
3
|
-
type KeyofUnion<type> = type extends type ? keyof type : never
|
|
4
|
-
|
|
5
|
-
export type OneOf<
|
|
6
|
-
union extends object,
|
|
7
|
-
fallback extends object | undefined = undefined,
|
|
8
|
-
///
|
|
9
|
-
keys extends KeyofUnion<union> = KeyofUnion<union>,
|
|
10
|
-
> = union extends infer item
|
|
11
|
-
? Compute<
|
|
12
|
-
item & {
|
|
13
|
-
[key in Exclude<keys, keyof item>]?: fallback extends object
|
|
14
|
-
? key extends keyof fallback
|
|
15
|
-
? fallback[key]
|
|
16
|
-
: undefined
|
|
17
|
-
: undefined
|
|
18
|
-
}
|
|
19
|
-
>
|
|
20
|
-
: never
|
package/src/manifest.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Farcaster manifest for a domain hosted at `/.well-known/farcaster.json`
|
|
3
|
-
*/
|
|
4
|
-
export type Manifest = {
|
|
5
|
-
accountAssociation: AccountAssociation
|
|
6
|
-
frame: FrameConfig
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Signed domain association linking this frame to a Farcaster account
|
|
11
|
-
*
|
|
12
|
-
* A DomainAssociation can be generated using the {@link https://farcaster.xyz/~/developers/domains | Warpcast
|
|
13
|
-
* Domains Developer} tool.
|
|
14
|
-
*/
|
|
15
|
-
export type AccountAssociation = {
|
|
16
|
-
/**
|
|
17
|
-
* Base64URL encoded JFS signature
|
|
18
|
-
*/
|
|
19
|
-
header: string
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Base64URL encoded payload signature
|
|
23
|
-
*/
|
|
24
|
-
payload: string
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Base64URL encoded signature
|
|
28
|
-
*/
|
|
29
|
-
signature: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Frame configuration
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ``ts
|
|
37
|
-
* const frame: FrameConfig = {
|
|
38
|
-
* version: '1',
|
|
39
|
-
* name: 'Yoink!',
|
|
40
|
-
* homeUrl: 'https://yoink.party',
|
|
41
|
-
* iconUrl: 'https://yoink.party/img/icon.png',
|
|
42
|
-
* imageUrl: 'https://yoink.party/framesV2/opengraph-image',
|
|
43
|
-
* buttonTitle: '🚩 Start',
|
|
44
|
-
* splashImageUrl: 'https://yoink.party/img/splash.png',
|
|
45
|
-
* splashImageBackgroundColor: '#eeeee4',
|
|
46
|
-
* webhookUrl: 'https://yoink.party/webhook'
|
|
47
|
-
* };
|
|
48
|
-
* ``
|
|
49
|
-
*/
|
|
50
|
-
export type FrameConfig = {
|
|
51
|
-
/**
|
|
52
|
-
* Manifest version
|
|
53
|
-
*
|
|
54
|
-
* Must be the literal '1'.
|
|
55
|
-
*/
|
|
56
|
-
version: '1'
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* App name that will be displayed to users
|
|
60
|
-
*
|
|
61
|
-
* Max length of 32 characters.
|
|
62
|
-
*/
|
|
63
|
-
name: string
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Default launch URL
|
|
67
|
-
*
|
|
68
|
-
* Max length of 1024 characters.
|
|
69
|
-
*/
|
|
70
|
-
homeUrl: string
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Icon URL
|
|
74
|
-
*
|
|
75
|
-
* Max length of 1024 characters. Image must be 200x200px and less than 1MB.
|
|
76
|
-
*/
|
|
77
|
-
iconUrl: string
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Image URL
|
|
81
|
-
*
|
|
82
|
-
* Max length of 1024 characters. Image must have a 3:2 ratio.
|
|
83
|
-
*/
|
|
84
|
-
imageUrl: string
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Default button title to use when frame is rendered.
|
|
88
|
-
*
|
|
89
|
-
* Max length of 32 characters.
|
|
90
|
-
*/
|
|
91
|
-
buttonTitle: string
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Splash image URL
|
|
95
|
-
*
|
|
96
|
-
* Max length of 1024 characters. Image must be 200x200px and less than 1MB.
|
|
97
|
-
*/
|
|
98
|
-
splashImageUrl?: string
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Splash background color
|
|
102
|
-
*
|
|
103
|
-
* Must be a hex color code.
|
|
104
|
-
*/
|
|
105
|
-
splashBackgroundColor?: string
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* URL to which clients will POST server events.
|
|
109
|
-
* Max length of 1024 characters.
|
|
110
|
-
* Required if the frame application uses notifications.
|
|
111
|
-
*/
|
|
112
|
-
webhookUrl?: string
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Canonical domain for the frame application.
|
|
116
|
-
* If specified, this domain will be treated as the primary domain for the frame.
|
|
117
|
-
* Max length of 1024 characters.
|
|
118
|
-
*/
|
|
119
|
-
canonicalDomain?: string
|
|
120
|
-
}
|
package/src/schemas/embeds.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4'
|
|
2
|
-
import {
|
|
3
|
-
aspectRatioSchema,
|
|
4
|
-
buttonTitleSchema,
|
|
5
|
-
caip19TokenSchema,
|
|
6
|
-
frameNameSchema,
|
|
7
|
-
hexColorSchema,
|
|
8
|
-
secureUrlSchema,
|
|
9
|
-
} from './shared.ts'
|
|
10
|
-
|
|
11
|
-
export const actionLaunchFrameSchema = z.object({
|
|
12
|
-
type: z.literal('launch_frame'),
|
|
13
|
-
name: frameNameSchema,
|
|
14
|
-
url: secureUrlSchema.optional(),
|
|
15
|
-
splashImageUrl: secureUrlSchema.optional(),
|
|
16
|
-
splashBackgroundColor: hexColorSchema.optional(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
export const actionViewTokenSchema = z.object({
|
|
20
|
-
type: z.literal('view_token'),
|
|
21
|
-
token: caip19TokenSchema,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
export const actionSchema = z.discriminatedUnion('type', [
|
|
25
|
-
actionLaunchFrameSchema,
|
|
26
|
-
actionViewTokenSchema,
|
|
27
|
-
])
|
|
28
|
-
|
|
29
|
-
export const buttonSchema = z.object({
|
|
30
|
-
title: buttonTitleSchema,
|
|
31
|
-
action: actionSchema,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export const frameEmbedNextSchema = z.object({
|
|
35
|
-
version: z.literal('next'),
|
|
36
|
-
imageUrl: secureUrlSchema,
|
|
37
|
-
aspectRatio: aspectRatioSchema.optional(),
|
|
38
|
-
button: buttonSchema,
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
export const safeParseFrameEmbed = (rawResponse: unknown) =>
|
|
42
|
-
frameEmbedNextSchema.safeParse(rawResponse)
|
|
43
|
-
|
|
44
|
-
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema>
|
package/src/schemas/events.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4'
|
|
2
|
-
import { notificationDetailsSchema } from './notifications.ts'
|
|
3
|
-
|
|
4
|
-
export const eventFrameAddedSchema = z.object({
|
|
5
|
-
event: z.literal('frame_added'),
|
|
6
|
-
notificationDetails: notificationDetailsSchema.optional(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>
|
|
10
|
-
|
|
11
|
-
export const eventFrameRemovedSchema = z.object({
|
|
12
|
-
event: z.literal('frame_removed'),
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>
|
|
16
|
-
|
|
17
|
-
export const eventNotificationsEnabledSchema = z.object({
|
|
18
|
-
event: z.literal('notifications_enabled'),
|
|
19
|
-
notificationDetails: notificationDetailsSchema.required(),
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export type EventNotificationsEnabled = z.infer<
|
|
23
|
-
typeof eventNotificationsEnabledSchema
|
|
24
|
-
>
|
|
25
|
-
|
|
26
|
-
export const notificationsDisabledSchema = z.object({
|
|
27
|
-
event: z.literal('notifications_disabled'),
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
export type EventNotificationsDisabled = z.infer<
|
|
31
|
-
typeof notificationsDisabledSchema
|
|
32
|
-
>
|
|
33
|
-
|
|
34
|
-
export const serverEventSchema = z.discriminatedUnion('event', [
|
|
35
|
-
eventFrameAddedSchema,
|
|
36
|
-
eventFrameRemovedSchema,
|
|
37
|
-
eventNotificationsEnabledSchema,
|
|
38
|
-
notificationsDisabledSchema,
|
|
39
|
-
])
|
|
40
|
-
|
|
41
|
-
export type FrameServerEvent = z.infer<typeof serverEventSchema>
|
package/src/schemas/index.ts
DELETED
package/src/schemas/manifest.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4'
|
|
2
|
-
import { miniAppHostCapabilityList } from '../types.ts'
|
|
3
|
-
import {
|
|
4
|
-
buttonTitleSchema,
|
|
5
|
-
createSimpleStringSchema,
|
|
6
|
-
domainSchema,
|
|
7
|
-
encodedJsonFarcasterSignatureSchema,
|
|
8
|
-
frameNameSchema,
|
|
9
|
-
hexColorSchema,
|
|
10
|
-
secureUrlSchema,
|
|
11
|
-
} from './shared.ts'
|
|
12
|
-
|
|
13
|
-
const primaryCategorySchema = z.enum([
|
|
14
|
-
'games',
|
|
15
|
-
'social',
|
|
16
|
-
'finance',
|
|
17
|
-
'utility',
|
|
18
|
-
'productivity',
|
|
19
|
-
'health-fitness',
|
|
20
|
-
'news-media',
|
|
21
|
-
'music',
|
|
22
|
-
'shopping',
|
|
23
|
-
'education',
|
|
24
|
-
'developer-tools',
|
|
25
|
-
'entertainment',
|
|
26
|
-
'art-creativity',
|
|
27
|
-
])
|
|
28
|
-
|
|
29
|
-
const chainList = [
|
|
30
|
-
'eip155:1', // Ethereum mainnet
|
|
31
|
-
'eip155:8453', // Base mainnet
|
|
32
|
-
'eip155:42161', // Arbitrum One
|
|
33
|
-
'eip155:421614', // Arbitrum Sepolia
|
|
34
|
-
'eip155:84532', // Base Sepolia
|
|
35
|
-
'eip155:666666666', // Degen
|
|
36
|
-
'eip155:100', // Gnosis
|
|
37
|
-
'eip155:10', // Optimism
|
|
38
|
-
'eip155:11155420', // Optimism Sepolia
|
|
39
|
-
'eip155:137', // Polygon
|
|
40
|
-
'eip155:11155111', // Ethereum Sepolia
|
|
41
|
-
'eip155:7777777', // Zora
|
|
42
|
-
'eip155:130', // Unichain
|
|
43
|
-
'eip155:10143', // Monad testnet
|
|
44
|
-
'eip155:42220', // Celo
|
|
45
|
-
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', // Solana
|
|
46
|
-
] as const
|
|
47
|
-
|
|
48
|
-
function removeArrayDuplicates<T>(arr: T[]) {
|
|
49
|
-
const set = new Set(arr)
|
|
50
|
-
return Array.from(set)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const domainFrameConfigSchema = z
|
|
54
|
-
.object({
|
|
55
|
-
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for
|
|
56
|
-
// backwards compatibility. next should always resolve to the most recent
|
|
57
|
-
// schema version.
|
|
58
|
-
version: z.union([
|
|
59
|
-
z.literal('0.0.0'),
|
|
60
|
-
z.literal('0.0.1'),
|
|
61
|
-
z.literal('1'),
|
|
62
|
-
z.literal('next'),
|
|
63
|
-
]),
|
|
64
|
-
name: frameNameSchema,
|
|
65
|
-
iconUrl: secureUrlSchema,
|
|
66
|
-
homeUrl: secureUrlSchema,
|
|
67
|
-
/** deprecated, set ogImageUrl instead */
|
|
68
|
-
imageUrl: secureUrlSchema.optional(),
|
|
69
|
-
/** deprecated, will rely on fc:frame meta tag */
|
|
70
|
-
buttonTitle: buttonTitleSchema.optional(),
|
|
71
|
-
splashImageUrl: secureUrlSchema.optional(),
|
|
72
|
-
splashBackgroundColor: hexColorSchema.optional(),
|
|
73
|
-
webhookUrl: secureUrlSchema.optional(),
|
|
74
|
-
/** see: https://github.com/farcasterxyz/miniapps/discussions/191 */
|
|
75
|
-
subtitle: createSimpleStringSchema({ max: 30 }).optional(),
|
|
76
|
-
description: createSimpleStringSchema({ max: 170 }).optional(),
|
|
77
|
-
screenshotUrls: z.array(secureUrlSchema).max(3).optional(),
|
|
78
|
-
primaryCategory: primaryCategorySchema.optional(),
|
|
79
|
-
tags: z
|
|
80
|
-
.array(createSimpleStringSchema({ max: 20, noSpaces: true }))
|
|
81
|
-
.max(5)
|
|
82
|
-
.optional(),
|
|
83
|
-
heroImageUrl: secureUrlSchema.optional(),
|
|
84
|
-
tagline: createSimpleStringSchema({ max: 30 }).optional(),
|
|
85
|
-
ogTitle: createSimpleStringSchema({ max: 30 }).optional(),
|
|
86
|
-
ogDescription: createSimpleStringSchema({ max: 100 }).optional(),
|
|
87
|
-
ogImageUrl: secureUrlSchema.optional(),
|
|
88
|
-
/** see: https://github.com/farcasterxyz/miniapps/discussions/204 */
|
|
89
|
-
noindex: z.boolean().optional(),
|
|
90
|
-
/** see https://github.com/farcasterxyz/miniapps/discussions/256 */
|
|
91
|
-
requiredChains: z
|
|
92
|
-
.array(z.enum(chainList))
|
|
93
|
-
.transform(removeArrayDuplicates)
|
|
94
|
-
.optional(),
|
|
95
|
-
requiredCapabilities: z
|
|
96
|
-
.array(z.enum(miniAppHostCapabilityList))
|
|
97
|
-
.transform(removeArrayDuplicates)
|
|
98
|
-
.optional(),
|
|
99
|
-
/** see https://github.com/farcasterxyz/miniapps/discussions/158 */
|
|
100
|
-
/** Documentation will be added once this feature is finalized. */
|
|
101
|
-
castShareUrl: secureUrlSchema.optional(),
|
|
102
|
-
/** Canonical domain for the frame application */
|
|
103
|
-
canonicalDomain: domainSchema.optional(),
|
|
104
|
-
})
|
|
105
|
-
.refine(
|
|
106
|
-
(data) => {
|
|
107
|
-
if (data.castShareUrl === undefined) return true
|
|
108
|
-
try {
|
|
109
|
-
const homeUrlDomain = new URL(data.homeUrl).hostname
|
|
110
|
-
const castShareUrlDomain = new URL(data.castShareUrl).hostname
|
|
111
|
-
return homeUrlDomain === castShareUrlDomain
|
|
112
|
-
} catch {
|
|
113
|
-
return false
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
message: 'castShareUrl must have the same domain as homeUrl',
|
|
118
|
-
path: ['castShareUrl'],
|
|
119
|
-
},
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
export const domainManifestSchema = z.object({
|
|
123
|
-
accountAssociation: encodedJsonFarcasterSignatureSchema,
|
|
124
|
-
frame: domainFrameConfigSchema.optional(),
|
|
125
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4'
|
|
2
|
-
import { secureUrlSchema } from './shared.ts'
|
|
3
|
-
|
|
4
|
-
export const notificationDetailsSchema = z.object({
|
|
5
|
-
url: z.string(),
|
|
6
|
-
token: z.string(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>
|
|
10
|
-
|
|
11
|
-
export const sendNotificationRequestSchema = z.object({
|
|
12
|
-
notificationId: z.string().max(128),
|
|
13
|
-
title: z.string().max(32),
|
|
14
|
-
body: z.string().max(128),
|
|
15
|
-
targetUrl: secureUrlSchema,
|
|
16
|
-
tokens: z.string().array().max(100),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
export type SendNotificationRequest = z.infer<
|
|
20
|
-
typeof sendNotificationRequestSchema
|
|
21
|
-
>
|
|
22
|
-
|
|
23
|
-
export const sendNotificationResponseSchema = z.object({
|
|
24
|
-
result: z.object({
|
|
25
|
-
successfulTokens: z.array(z.string()),
|
|
26
|
-
invalidTokens: z.array(z.string()),
|
|
27
|
-
rateLimitedTokens: z.array(z.string()),
|
|
28
|
-
}),
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
export type SendNotificationResponse = z.infer<
|
|
32
|
-
typeof sendNotificationResponseSchema
|
|
33
|
-
>
|
package/src/schemas/shared.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4'
|
|
2
|
-
|
|
3
|
-
const SPECIAL_CHARS_PATTERN = /[@#$%^&*+=\/\\|~«»]/
|
|
4
|
-
const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/
|
|
5
|
-
|
|
6
|
-
// Unicode ranges for emoji detection:
|
|
7
|
-
// \u{1F300}-\u{1F9FF} - Miscellaneous Symbols, Pictographs, Emoticons, Transport, Map, and Supplemental
|
|
8
|
-
// \u{2702}-\u{27B0} - Dingbats
|
|
9
|
-
// \u{2600}-\u{26FF} - Miscellaneous Symbols
|
|
10
|
-
// \u{2B00}-\u{2BFF} - Miscellaneous Symbols and Arrows
|
|
11
|
-
const EMOJI_PATTERN =
|
|
12
|
-
/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u
|
|
13
|
-
|
|
14
|
-
export const createSimpleStringSchema = ({
|
|
15
|
-
max,
|
|
16
|
-
noSpaces,
|
|
17
|
-
}: { max?: number; noSpaces?: boolean } = {}) => {
|
|
18
|
-
const stringValidations = noSpaces
|
|
19
|
-
? z
|
|
20
|
-
.string()
|
|
21
|
-
.max(max ?? Number.POSITIVE_INFINITY)
|
|
22
|
-
.regex(/^\S*$/, 'Spaces are not allowed')
|
|
23
|
-
: z.string().max(max ?? Number.POSITIVE_INFINITY)
|
|
24
|
-
|
|
25
|
-
return stringValidations
|
|
26
|
-
.refine((value) => !EMOJI_PATTERN.test(value), {
|
|
27
|
-
message: 'Emojis and symbols are not allowed',
|
|
28
|
-
})
|
|
29
|
-
.refine((value) => !SPECIAL_CHARS_PATTERN.test(value), {
|
|
30
|
-
message:
|
|
31
|
-
'Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed',
|
|
32
|
-
})
|
|
33
|
-
.refine((value) => !REPEATED_PUNCTUATION_PATTERN.test(value), {
|
|
34
|
-
message: 'Repeated punctuations (!!, ??, --) are not allowed',
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const secureUrlSchema = z
|
|
39
|
-
.string()
|
|
40
|
-
.url()
|
|
41
|
-
.startsWith('https://', { message: 'Must be an https url' })
|
|
42
|
-
.max(1024)
|
|
43
|
-
.refine((url) => !url.includes(' '), {
|
|
44
|
-
message: 'URL must not contain spaces',
|
|
45
|
-
})
|
|
46
|
-
.refine(
|
|
47
|
-
(url) => {
|
|
48
|
-
try {
|
|
49
|
-
const hostname = new URL(url).hostname
|
|
50
|
-
// Check for localhost
|
|
51
|
-
if (hostname === 'localhost' || hostname.endsWith('.localhost')) {
|
|
52
|
-
return false
|
|
53
|
-
}
|
|
54
|
-
// Check for IPv4 addresses
|
|
55
|
-
const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/
|
|
56
|
-
if (ipv4Regex.test(hostname)) {
|
|
57
|
-
return false
|
|
58
|
-
}
|
|
59
|
-
// Check for IPv6 addresses (including brackets)
|
|
60
|
-
if (hostname.startsWith('[') && hostname.endsWith(']')) {
|
|
61
|
-
return false
|
|
62
|
-
}
|
|
63
|
-
return true
|
|
64
|
-
} catch {
|
|
65
|
-
return false
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
message: 'URL must not use IP addresses or localhost',
|
|
70
|
-
},
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
export const frameNameSchema = z.string().max(32)
|
|
74
|
-
export const buttonTitleSchema = z.string().max(32)
|
|
75
|
-
|
|
76
|
-
const CAIP_19_REGEX =
|
|
77
|
-
/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/
|
|
78
|
-
|
|
79
|
-
export const caip19TokenSchema = z
|
|
80
|
-
.string()
|
|
81
|
-
.regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' })
|
|
82
|
-
|
|
83
|
-
export const hexColorSchema = z
|
|
84
|
-
.string()
|
|
85
|
-
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
|
|
86
|
-
message:
|
|
87
|
-
'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
// Domain validation regex:
|
|
91
|
-
// - Each label (part between dots) must start and end with alphanumeric
|
|
92
|
-
// - Labels can contain hyphens in the middle
|
|
93
|
-
// - Cannot have consecutive dots
|
|
94
|
-
// - Must have at least one dot (TLD required)
|
|
95
|
-
// - TLD must be at least 2 characters and only letters
|
|
96
|
-
const DOMAIN_REGEX =
|
|
97
|
-
/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/
|
|
98
|
-
|
|
99
|
-
export const domainSchema = z
|
|
100
|
-
.string()
|
|
101
|
-
.max(1024)
|
|
102
|
-
.regex(DOMAIN_REGEX, {
|
|
103
|
-
message: 'Must be a valid domain name (e.g., example.com, sub.example.com)',
|
|
104
|
-
})
|
|
105
|
-
.refine((value) => !value.includes('://'), {
|
|
106
|
-
message: 'Domain must not include protocol (http://, https://, etc.)',
|
|
107
|
-
})
|
|
108
|
-
.refine((value) => !value.includes('/'), {
|
|
109
|
-
message: 'Domain must not include path separators',
|
|
110
|
-
})
|
|
111
|
-
.refine((value) => !value.includes('@'), {
|
|
112
|
-
message: 'Domain must not include @ symbol',
|
|
113
|
-
})
|
|
114
|
-
.refine((value) => !value.includes(':'), {
|
|
115
|
-
message: 'Domain must not include port numbers',
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')])
|
|
119
|
-
|
|
120
|
-
export const encodedJsonFarcasterSignatureSchema = z.object({
|
|
121
|
-
header: z.string(),
|
|
122
|
-
payload: z.string(),
|
|
123
|
-
signature: z.string(),
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
export type EncodedJsonFarcasterSignatureSchema = z.infer<
|
|
127
|
-
typeof encodedJsonFarcasterSignatureSchema
|
|
128
|
-
>
|
|
129
|
-
|
|
130
|
-
export const jsonFarcasterSignatureHeaderSchema = z.object({
|
|
131
|
-
fid: z.number(),
|
|
132
|
-
type: z.literal('app_key'),
|
|
133
|
-
key: z.string().startsWith('0x'),
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
export type JsonFarcasterSignatureHeaderSchema = z.infer<
|
|
137
|
-
typeof jsonFarcasterSignatureHeaderSchema
|
|
138
|
-
>
|