@farcaster/frame-core 0.1.4 → 0.1.6

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.
@@ -44,49 +44,69 @@ const chainList: [string, ...string[]] = [
44
44
  'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', // Solana
45
45
  ]
46
46
 
47
- export const domainFrameConfigSchema = z.object({
48
- // 0.0.0 and 0.0.1 are not technically part of the spec but kept for
49
- // backwards compatibility. next should always resolve to the most recent
50
- // schema version.
51
- version: z.union([
52
- z.literal('0.0.0'),
53
- z.literal('0.0.1'),
54
- z.literal('1'),
55
- z.literal('next'),
56
- ]),
57
- name: frameNameSchema,
58
- iconUrl: secureUrlSchema,
59
- homeUrl: secureUrlSchema,
60
- /** deprecated, set ogImageUrl instead */
61
- imageUrl: secureUrlSchema.optional(),
62
- /** deprecated, will rely on fc:frame meta tag */
63
- buttonTitle: buttonTitleSchema.optional(),
64
- splashImageUrl: secureUrlSchema.optional(),
65
- splashBackgroundColor: hexColorSchema.optional(),
66
- webhookUrl: secureUrlSchema.optional(),
67
- /** see: https://github.com/farcasterxyz/miniapps/discussions/191 */
68
- subtitle: createSimpleStringSchema({ max: 30 }).optional(),
69
- description: createSimpleStringSchema({ max: 170 }).optional(),
70
- screenshotUrls: z.array(secureUrlSchema).max(3).optional(),
71
- primaryCategory: primaryCategorySchema.optional(),
72
- tags: z
73
- .array(createSimpleStringSchema({ max: 20, noSpaces: true }))
74
- .max(5)
75
- .optional(),
76
- heroImageUrl: secureUrlSchema.optional(),
77
- tagline: createSimpleStringSchema({ max: 30 }).optional(),
78
- ogTitle: createSimpleStringSchema({ max: 30 }).optional(),
79
- ogDescription: createSimpleStringSchema({ max: 100 }).optional(),
80
- ogImageUrl: secureUrlSchema.optional(),
81
- /** see: https://github.com/farcasterxyz/miniapps/discussions/204 */
82
- noindex: z.boolean().optional(),
83
- /** see https://github.com/farcasterxyz/miniapps/discussions/256 */
84
- requiredChains: z.array(z.enum(chainList)).max(chainList.length).optional(),
85
- requiredCapabilities: z
86
- .array(z.enum(miniAppHostCapabilityList))
87
- .max(miniAppHostCapabilityList.length)
88
- .optional(),
89
- })
47
+ export const domainFrameConfigSchema = z
48
+ .object({
49
+ // 0.0.0 and 0.0.1 are not technically part of the spec but kept for
50
+ // backwards compatibility. next should always resolve to the most recent
51
+ // schema version.
52
+ version: z.union([
53
+ z.literal('0.0.0'),
54
+ z.literal('0.0.1'),
55
+ z.literal('1'),
56
+ z.literal('next'),
57
+ ]),
58
+ name: frameNameSchema,
59
+ iconUrl: secureUrlSchema,
60
+ homeUrl: secureUrlSchema,
61
+ /** deprecated, set ogImageUrl instead */
62
+ imageUrl: secureUrlSchema.optional(),
63
+ /** deprecated, will rely on fc:frame meta tag */
64
+ buttonTitle: buttonTitleSchema.optional(),
65
+ splashImageUrl: secureUrlSchema.optional(),
66
+ splashBackgroundColor: hexColorSchema.optional(),
67
+ webhookUrl: secureUrlSchema.optional(),
68
+ /** see: https://github.com/farcasterxyz/miniapps/discussions/191 */
69
+ subtitle: createSimpleStringSchema({ max: 30 }).optional(),
70
+ description: createSimpleStringSchema({ max: 170 }).optional(),
71
+ screenshotUrls: z.array(secureUrlSchema).max(3).optional(),
72
+ primaryCategory: primaryCategorySchema.optional(),
73
+ tags: z
74
+ .array(createSimpleStringSchema({ max: 20, noSpaces: true }))
75
+ .max(5)
76
+ .optional(),
77
+ heroImageUrl: secureUrlSchema.optional(),
78
+ tagline: createSimpleStringSchema({ max: 30 }).optional(),
79
+ ogTitle: createSimpleStringSchema({ max: 30 }).optional(),
80
+ ogDescription: createSimpleStringSchema({ max: 100 }).optional(),
81
+ ogImageUrl: secureUrlSchema.optional(),
82
+ /** see: https://github.com/farcasterxyz/miniapps/discussions/204 */
83
+ noindex: z.boolean().optional(),
84
+ /** see https://github.com/farcasterxyz/miniapps/discussions/256 */
85
+ requiredChains: z.array(z.enum(chainList)).max(chainList.length).optional(),
86
+ requiredCapabilities: z
87
+ .array(z.enum(miniAppHostCapabilityList))
88
+ .max(miniAppHostCapabilityList.length)
89
+ .optional(),
90
+ /** see https://github.com/farcasterxyz/miniapps/discussions/158 */
91
+ /** Documentation will be added once this feature is finalized. */
92
+ castShareUrl: secureUrlSchema.optional(),
93
+ })
94
+ .refine(
95
+ (data) => {
96
+ if (data.castShareUrl === undefined) return true
97
+ try {
98
+ const homeUrlDomain = new URL(data.homeUrl).hostname
99
+ const castShareUrlDomain = new URL(data.castShareUrl).hostname
100
+ return homeUrlDomain === castShareUrlDomain
101
+ } catch {
102
+ return false
103
+ }
104
+ },
105
+ {
106
+ message: 'castShareUrl must have the same domain as homeUrl',
107
+ path: ['castShareUrl'],
108
+ },
109
+ )
90
110
 
91
111
  export const domainManifestSchema = z.object({
92
112
  accountAssociation: encodedJsonFarcasterSignatureSchema,
package/src/types.ts CHANGED
@@ -14,6 +14,7 @@ import type {
14
14
  ViewProfile,
15
15
  ViewToken,
16
16
  } from './actions/index.ts'
17
+ import type { UpdateBackState } from './back.ts'
17
18
  import type { FrameContext } from './context.ts'
18
19
  import type {
19
20
  EventFrameAdded,
@@ -60,6 +61,7 @@ export const miniAppHostCapabilityList: [string, ...string[]] = [
60
61
  'haptics.impactOccurred',
61
62
  'haptics.notificationOccurred',
62
63
  'haptics.selectionChanged',
64
+ 'back',
63
65
  ]
64
66
 
65
67
  export type MiniAppHostCapability =
@@ -80,6 +82,7 @@ export type MiniAppHostCapability =
80
82
  | 'haptics.impactOccurred'
81
83
  | 'haptics.notificationOccurred'
82
84
  | 'haptics.selectionChanged'
85
+ | 'back'
83
86
 
84
87
  export type GetCapabilities = () => Promise<MiniAppHostCapability[]>
85
88
 
@@ -111,6 +114,7 @@ export type WireFrameHost = {
111
114
  selectionChanged: SelectionChanged
112
115
  getCapabilities: GetCapabilities
113
116
  getChains: GetChains
117
+ updateBackState: UpdateBackState
114
118
  }
115
119
 
116
120
  export type FrameHost = {
@@ -142,6 +146,7 @@ export type FrameHost = {
142
146
  selectionChanged: SelectionChanged
143
147
  getCapabilities: GetCapabilities
144
148
  getChains: GetChains
149
+ updateBackState: UpdateBackState
145
150
  }
146
151
 
147
152
  export type EventFrameAddRejected = {
@@ -153,6 +158,10 @@ export type EventPrimaryButtonClicked = {
153
158
  event: 'primary_button_clicked'
154
159
  }
155
160
 
161
+ export type EventBackNavigationTriggered = {
162
+ event: 'back_navigation_triggered'
163
+ }
164
+
156
165
  export type FrameClientEvent =
157
166
  | EventFrameAdded
158
167
  | EventFrameAddRejected
@@ -160,4 +169,5 @@ export type FrameClientEvent =
160
169
  | EventNotificationsEnabled
161
170
  | EventNotificationsDisabled
162
171
  | EventPrimaryButtonClicked
172
+ | EventBackNavigationTriggered
163
173
  | Ethereum.EventEip6963AnnounceProvider