@farcaster/frame-core 0.0.0-canary-20250611151843 → 0.0.0-canary-20250627213014

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.
@@ -3,6 +3,7 @@ import { miniAppHostCapabilityList } from '../types.ts'
3
3
  import {
4
4
  buttonTitleSchema,
5
5
  createSimpleStringSchema,
6
+ domainSchema,
6
7
  encodedJsonFarcasterSignatureSchema,
7
8
  frameNameSchema,
8
9
  hexColorSchema,
@@ -98,6 +99,8 @@ export const domainFrameConfigSchema = z
98
99
  /** see https://github.com/farcasterxyz/miniapps/discussions/158 */
99
100
  /** Documentation will be added once this feature is finalized. */
100
101
  castShareUrl: secureUrlSchema.optional(),
102
+ /** Canonical domain for the frame application */
103
+ canonicalDomain: domainSchema.optional(),
101
104
  })
102
105
  .refine(
103
106
  (data) => {
@@ -40,6 +40,9 @@ export const secureUrlSchema = z
40
40
  .url()
41
41
  .startsWith('https://', { message: 'Must be an https url' })
42
42
  .max(1024)
43
+ .refine((url) => !url.includes(' '), {
44
+ message: 'URL must not contain spaces',
45
+ })
43
46
 
44
47
  export const frameNameSchema = z.string().max(32)
45
48
  export const buttonTitleSchema = z.string().max(32)
@@ -58,6 +61,34 @@ export const hexColorSchema = z
58
61
  'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
59
62
  })
60
63
 
64
+ // Domain validation regex:
65
+ // - Each label (part between dots) must start and end with alphanumeric
66
+ // - Labels can contain hyphens in the middle
67
+ // - Cannot have consecutive dots
68
+ // - Must have at least one dot (TLD required)
69
+ // - TLD must be at least 2 characters and only letters
70
+ const DOMAIN_REGEX =
71
+ /^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/
72
+
73
+ export const domainSchema = z
74
+ .string()
75
+ .max(1024)
76
+ .regex(DOMAIN_REGEX, {
77
+ message: 'Must be a valid domain name (e.g., example.com, sub.example.com)',
78
+ })
79
+ .refine((value) => !value.includes('://'), {
80
+ message: 'Domain must not include protocol (http://, https://, etc.)',
81
+ })
82
+ .refine((value) => !value.includes('/'), {
83
+ message: 'Domain must not include path separators',
84
+ })
85
+ .refine((value) => !value.includes('@'), {
86
+ message: 'Domain must not include @ symbol',
87
+ })
88
+ .refine((value) => !value.includes(':'), {
89
+ message: 'Domain must not include port numbers',
90
+ })
91
+
61
92
  export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')])
62
93
 
63
94
  export const encodedJsonFarcasterSignatureSchema = z.object({