@farcaster/frame-core 0.0.29 → 0.0.32

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.
Files changed (74) hide show
  1. package/README.md +13 -0
  2. package/dist/actions/ComposeCast.d.ts +32 -0
  3. package/dist/actions/ComposeCast.js +2 -0
  4. package/dist/actions/index.d.ts +1 -0
  5. package/dist/actions/index.js +2 -1
  6. package/dist/errors.d.ts +3 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +3 -1
  9. package/dist/manifest.d.ts +101 -0
  10. package/dist/manifest.js +2 -0
  11. package/dist/schemas/embeds.d.ts +20 -20
  12. package/dist/schemas/embeds.js +1 -1
  13. package/dist/schemas/manifest.d.ts +92 -6
  14. package/dist/schemas/manifest.js +31 -0
  15. package/dist/schemas/shared.d.ts +4 -0
  16. package/dist/schemas/shared.js +29 -2
  17. package/dist/types.d.ts +3 -1
  18. package/dist/wallet/ethereum.d.ts +5 -1
  19. package/esm/actions/AddFrame.d.ts +23 -27
  20. package/esm/actions/AddFrame.js +9 -9
  21. package/esm/actions/ComposeCast.d.ts +32 -0
  22. package/esm/actions/ComposeCast.js +1 -0
  23. package/esm/actions/Ready.d.ts +11 -11
  24. package/esm/actions/Ready.js +2 -2
  25. package/esm/actions/SignIn.d.ts +33 -35
  26. package/esm/actions/SignIn.js +5 -5
  27. package/esm/actions/Swap.d.ts +43 -44
  28. package/esm/actions/Swap.js +1 -1
  29. package/esm/actions/ViewProfile.d.ts +3 -3
  30. package/esm/actions/ViewProfile.js +1 -1
  31. package/esm/actions/ViewToken.d.ts +3 -3
  32. package/esm/actions/ViewToken.js +1 -1
  33. package/esm/actions/index.d.ts +7 -6
  34. package/esm/actions/index.js +7 -6
  35. package/esm/context.d.ts +61 -65
  36. package/esm/context.js +1 -1
  37. package/esm/errors.d.ts +10 -9
  38. package/esm/errors.js +6 -6
  39. package/esm/index.d.ts +7 -5
  40. package/esm/index.js +7 -5
  41. package/esm/internal/types.d.ts +7 -18
  42. package/esm/internal/types.js +1 -1
  43. package/esm/manifest.d.ts +101 -0
  44. package/esm/manifest.js +1 -0
  45. package/esm/schemas/embeds.d.ts +239 -346
  46. package/esm/schemas/embeds.js +23 -31
  47. package/esm/schemas/events.d.ts +129 -225
  48. package/esm/schemas/events.js +17 -17
  49. package/esm/schemas/index.d.ts +5 -5
  50. package/esm/schemas/index.js +5 -5
  51. package/esm/schemas/manifest.d.ts +196 -154
  52. package/esm/schemas/manifest.js +54 -29
  53. package/esm/schemas/notifications.d.ts +58 -86
  54. package/esm/schemas/notifications.js +17 -17
  55. package/esm/schemas/shared.d.ts +39 -53
  56. package/esm/schemas/shared.js +49 -25
  57. package/esm/tsconfig.tsbuildinfo +1 -1
  58. package/esm/types.d.ts +53 -70
  59. package/esm/types.js +2 -2
  60. package/esm/wallet/ethereum.d.ts +39 -50
  61. package/esm/wallet/ethereum.js +1 -1
  62. package/esm/wallet/index.d.ts +1 -1
  63. package/esm/wallet/index.js +1 -1
  64. package/package.json +1 -1
  65. package/src/actions/ComposeCast.ts +36 -0
  66. package/src/actions/index.ts +1 -0
  67. package/src/errors.ts +4 -0
  68. package/src/index.ts +2 -0
  69. package/src/manifest.ts +113 -0
  70. package/src/schemas/embeds.ts +1 -1
  71. package/src/schemas/manifest.ts +33 -0
  72. package/src/schemas/shared.ts +36 -1
  73. package/src/types.ts +7 -0
  74. package/src/wallet/ethereum.ts +5 -1
@@ -1,53 +1,39 @@
1
- import type { z } from 'zod'
2
- export declare const secureUrlSchema: z.ZodString
3
- export declare const frameNameSchema: z.ZodString
4
- export declare const buttonTitleSchema: z.ZodString
5
- export declare const caip19TokenSchema: z.ZodString
6
- export declare const hexColorSchema: z.ZodString
7
- export declare const aspectRatioSchema: z.ZodUnion<
8
- [z.ZodLiteral<'1:1'>, z.ZodLiteral<'3:2'>]
9
- >
10
- export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject<
11
- {
12
- header: z.ZodString
13
- payload: z.ZodString
14
- signature: z.ZodString
15
- },
16
- 'strip',
17
- z.ZodTypeAny,
18
- {
19
- header: string
20
- payload: string
21
- signature: string
22
- },
23
- {
24
- header: string
25
- payload: string
26
- signature: string
27
- }
28
- >
29
- export type EncodedJsonFarcasterSignatureSchema = z.infer<
30
- typeof encodedJsonFarcasterSignatureSchema
31
- >
32
- export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject<
33
- {
34
- fid: z.ZodNumber
35
- type: z.ZodLiteral<'app_key'>
36
- key: z.ZodString
37
- },
38
- 'strip',
39
- z.ZodTypeAny,
40
- {
41
- type: 'app_key'
42
- fid: number
43
- key: string
44
- },
45
- {
46
- type: 'app_key'
47
- fid: number
48
- key: string
49
- }
50
- >
51
- export type JsonFarcasterSignatureHeaderSchema = z.infer<
52
- typeof jsonFarcasterSignatureHeaderSchema
53
- >
1
+ import { z } from 'zod';
2
+ export declare const createSimpleStringSchema: ({ max, noSpaces, }?: {
3
+ max?: number;
4
+ noSpaces?: boolean;
5
+ }) => z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
6
+ export declare const secureUrlSchema: z.ZodString;
7
+ export declare const frameNameSchema: z.ZodString;
8
+ export declare const buttonTitleSchema: z.ZodString;
9
+ export declare const caip19TokenSchema: z.ZodString;
10
+ export declare const hexColorSchema: z.ZodString;
11
+ export declare const aspectRatioSchema: z.ZodUnion<[z.ZodLiteral<"1:1">, z.ZodLiteral<"3:2">]>;
12
+ export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject<{
13
+ header: z.ZodString;
14
+ payload: z.ZodString;
15
+ signature: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ header: string;
18
+ payload: string;
19
+ signature: string;
20
+ }, {
21
+ header: string;
22
+ payload: string;
23
+ signature: string;
24
+ }>;
25
+ export type EncodedJsonFarcasterSignatureSchema = z.infer<typeof encodedJsonFarcasterSignatureSchema>;
26
+ export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject<{
27
+ fid: z.ZodNumber;
28
+ type: z.ZodLiteral<"app_key">;
29
+ key: z.ZodString;
30
+ }, "strip", z.ZodTypeAny, {
31
+ type: "app_key";
32
+ fid: number;
33
+ key: string;
34
+ }, {
35
+ type: "app_key";
36
+ fid: number;
37
+ key: string;
38
+ }>;
39
+ export type JsonFarcasterSignatureHeaderSchema = z.infer<typeof jsonFarcasterSignatureHeaderSchema>;
@@ -1,30 +1,54 @@
1
- import { z } from 'zod'
1
+ import { z } from 'zod';
2
+ const SPECIAL_CHARS_PATTERN = /[@#$%^&*+=\/\\|~«»]/;
3
+ const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/;
4
+ // Unicode ranges for emoji detection:
5
+ // \u{1F300}-\u{1F9FF} - Miscellaneous Symbols, Pictographs, Emoticons, Transport, Map, and Supplemental
6
+ // \u{2702}-\u{27B0} - Dingbats
7
+ // \u{2600}-\u{26FF} - Miscellaneous Symbols
8
+ // \u{2B00}-\u{2BFF} - Miscellaneous Symbols and Arrows
9
+ const EMOJI_PATTERN = /[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u;
10
+ export const createSimpleStringSchema = ({ max, noSpaces, } = {}) => {
11
+ const stringValidations = noSpaces
12
+ ? z
13
+ .string()
14
+ .max(max ?? Number.POSITIVE_INFINITY)
15
+ .regex(/^\S*$/, 'Spaces are not allowed')
16
+ : z.string().max(max ?? Number.POSITIVE_INFINITY);
17
+ return stringValidations
18
+ .refine((value) => !EMOJI_PATTERN.test(value), {
19
+ message: 'Emojis and symbols are not allowed',
20
+ })
21
+ .refine((value) => !SPECIAL_CHARS_PATTERN.test(value), {
22
+ message: 'Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed',
23
+ })
24
+ .refine((value) => !REPEATED_PUNCTUATION_PATTERN.test(value), {
25
+ message: 'Repeated punctuations (!!, ??, --) are not allowed',
26
+ });
27
+ };
2
28
  export const secureUrlSchema = z
3
- .string()
4
- .url()
5
- .startsWith('https://', { message: 'Must be an https url' })
6
- .max(512)
7
- export const frameNameSchema = z.string().max(32)
8
- export const buttonTitleSchema = z.string().max(32)
9
- const CAIP_19_REGEX =
10
- /^[-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)$/
29
+ .string()
30
+ .url()
31
+ .startsWith('https://', { message: 'Must be an https url' })
32
+ .max(1024);
33
+ export const frameNameSchema = z.string().max(32);
34
+ export const buttonTitleSchema = z.string().max(32);
35
+ const CAIP_19_REGEX = /^[-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)$/;
11
36
  export const caip19TokenSchema = z
12
- .string()
13
- .regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' })
37
+ .string()
38
+ .regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' });
14
39
  export const hexColorSchema = z
15
- .string()
16
- .regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
17
- message:
18
- 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
19
- })
20
- export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')])
40
+ .string()
41
+ .regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
42
+ message: 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
43
+ });
44
+ export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')]);
21
45
  export const encodedJsonFarcasterSignatureSchema = z.object({
22
- header: z.string(),
23
- payload: z.string(),
24
- signature: z.string(),
25
- })
46
+ header: z.string(),
47
+ payload: z.string(),
48
+ signature: z.string(),
49
+ });
26
50
  export const jsonFarcasterSignatureHeaderSchema = z.object({
27
- fid: z.number(),
28
- type: z.literal('app_key'),
29
- key: z.string().startsWith('0x'),
30
- })
51
+ fid: z.number(),
52
+ type: z.literal('app_key'),
53
+ key: z.string().startsWith('0x'),
54
+ });