@farcaster/frame-core 0.0.31 → 0.0.33

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.
@@ -1,5 +1,40 @@
1
1
  import { z } from 'zod'
2
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
+
3
38
  export const secureUrlSchema = z
4
39
  .string()
5
40
  .url()
@@ -1,4 +1,8 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
1
+ import type * as Address from 'ox/Address'
2
+ import type * as Provider from 'ox/Provider'
3
+ import type * as RpcRequest from 'ox/RpcRequest'
4
+ import type * as RpcResponse from 'ox/RpcResponse'
5
+ import type * as RpcSchema from 'ox/RpcSchema'
2
6
 
3
7
  export type EthProvideRequest<
4
8
  schema extends RpcSchema.Generic = RpcSchema.Default,