@farcaster/miniapp-core 0.3.0 → 0.3.1
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/schemas/embeds.d.ts +324 -40
- package/dist/schemas/embeds.js +11 -11
- package/dist/schemas/events.d.ts +156 -24
- package/dist/schemas/events.js +14 -14
- package/dist/schemas/manifest.d.ts +634 -220
- package/dist/schemas/manifest.js +16 -16
- package/dist/schemas/notifications.d.ts +48 -10
- package/dist/schemas/notifications.js +14 -14
- package/dist/schemas/shared.d.ts +23 -7
- package/dist/schemas/shared.js +18 -18
- package/esm/schemas/embeds.d.ts +324 -40
- package/esm/schemas/embeds.js +1 -1
- package/esm/schemas/events.d.ts +156 -24
- package/esm/schemas/events.js +1 -1
- package/esm/schemas/manifest.d.ts +634 -220
- package/esm/schemas/manifest.js +1 -1
- package/esm/schemas/notifications.d.ts +48 -10
- package/esm/schemas/notifications.js +1 -1
- package/esm/schemas/shared.d.ts +23 -7
- package/esm/schemas/shared.js +1 -1
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/schemas/embeds.ts +1 -1
- package/src/schemas/events.ts +1 -1
- package/src/schemas/manifest.ts +1 -1
- package/src/schemas/notifications.ts +1 -1
- package/src/schemas/shared.ts +1 -1
package/dist/schemas/manifest.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.domainManifestSchema = exports.domainMiniAppConfigSchema = void 0;
|
|
4
|
-
const
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
5
|
const types_ts_1 = require("../types.js");
|
|
6
6
|
const shared_ts_1 = require("./shared.js");
|
|
7
|
-
const primaryCategorySchema =
|
|
7
|
+
const primaryCategorySchema = zod_1.z.enum([
|
|
8
8
|
'games',
|
|
9
9
|
'social',
|
|
10
10
|
'finance',
|
|
@@ -41,16 +41,16 @@ function removeArrayDuplicates(arr) {
|
|
|
41
41
|
const set = new Set(arr);
|
|
42
42
|
return Array.from(set);
|
|
43
43
|
}
|
|
44
|
-
exports.domainMiniAppConfigSchema =
|
|
44
|
+
exports.domainMiniAppConfigSchema = zod_1.z
|
|
45
45
|
.object({
|
|
46
46
|
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for
|
|
47
47
|
// backwards compatibility. next should always resolve to the most recent
|
|
48
48
|
// schema version.
|
|
49
|
-
version:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
version: zod_1.z.union([
|
|
50
|
+
zod_1.z.literal('0.0.0'),
|
|
51
|
+
zod_1.z.literal('0.0.1'),
|
|
52
|
+
zod_1.z.literal('1'),
|
|
53
|
+
zod_1.z.literal('next'),
|
|
54
54
|
]),
|
|
55
55
|
name: shared_ts_1.miniAppNameSchema,
|
|
56
56
|
iconUrl: shared_ts_1.secureUrlSchema,
|
|
@@ -65,9 +65,9 @@ exports.domainMiniAppConfigSchema = v4_1.z
|
|
|
65
65
|
/** see: https://github.com/farcasterxyz/miniapps/discussions/191 */
|
|
66
66
|
subtitle: (0, shared_ts_1.createSimpleStringSchema)({ max: 30 }).optional(),
|
|
67
67
|
description: (0, shared_ts_1.createSimpleStringSchema)({ max: 170 }).optional(),
|
|
68
|
-
screenshotUrls:
|
|
68
|
+
screenshotUrls: zod_1.z.array(shared_ts_1.secureUrlSchema).max(3).optional(),
|
|
69
69
|
primaryCategory: primaryCategorySchema.optional(),
|
|
70
|
-
tags:
|
|
70
|
+
tags: zod_1.z
|
|
71
71
|
.array((0, shared_ts_1.createSimpleStringSchema)({ max: 20, noSpaces: true }))
|
|
72
72
|
.max(5)
|
|
73
73
|
.optional(),
|
|
@@ -77,14 +77,14 @@ exports.domainMiniAppConfigSchema = v4_1.z
|
|
|
77
77
|
ogDescription: (0, shared_ts_1.createSimpleStringSchema)({ max: 100 }).optional(),
|
|
78
78
|
ogImageUrl: shared_ts_1.secureUrlSchema.optional(),
|
|
79
79
|
/** see: https://github.com/farcasterxyz/miniapps/discussions/204 */
|
|
80
|
-
noindex:
|
|
80
|
+
noindex: zod_1.z.boolean().optional(),
|
|
81
81
|
/** see https://github.com/farcasterxyz/miniapps/discussions/256 */
|
|
82
|
-
requiredChains:
|
|
83
|
-
.array(
|
|
82
|
+
requiredChains: zod_1.z
|
|
83
|
+
.array(zod_1.z.enum(chainList))
|
|
84
84
|
.transform(removeArrayDuplicates)
|
|
85
85
|
.optional(),
|
|
86
|
-
requiredCapabilities:
|
|
87
|
-
.array(
|
|
86
|
+
requiredCapabilities: zod_1.z
|
|
87
|
+
.array(zod_1.z.enum(types_ts_1.miniAppHostCapabilityList))
|
|
88
88
|
.transform(removeArrayDuplicates)
|
|
89
89
|
.optional(),
|
|
90
90
|
/** see https://github.com/farcasterxyz/miniapps/discussions/158 */
|
|
@@ -108,7 +108,7 @@ exports.domainMiniAppConfigSchema = v4_1.z
|
|
|
108
108
|
message: 'castShareUrl must have the same domain as homeUrl',
|
|
109
109
|
path: ['castShareUrl'],
|
|
110
110
|
});
|
|
111
|
-
exports.domainManifestSchema =
|
|
111
|
+
exports.domainManifestSchema = zod_1.z
|
|
112
112
|
.object({
|
|
113
113
|
accountAssociation: shared_ts_1.encodedJsonFarcasterSignatureSchema,
|
|
114
114
|
miniapp: exports.domainMiniAppConfigSchema.optional(),
|
|
@@ -1,22 +1,60 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
export declare const notificationDetailsSchema: z.ZodObject<{
|
|
3
3
|
url: z.ZodString;
|
|
4
4
|
token: z.ZodString;
|
|
5
|
-
}, z.
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
url: string;
|
|
7
|
+
token: string;
|
|
8
|
+
}, {
|
|
9
|
+
url: string;
|
|
10
|
+
token: string;
|
|
11
|
+
}>;
|
|
6
12
|
export type MiniAppNotificationDetails = z.infer<typeof notificationDetailsSchema>;
|
|
7
13
|
export declare const sendNotificationRequestSchema: z.ZodObject<{
|
|
8
14
|
notificationId: z.ZodString;
|
|
9
15
|
title: z.ZodString;
|
|
10
16
|
body: z.ZodString;
|
|
11
|
-
targetUrl: z.ZodString
|
|
12
|
-
tokens: z.ZodArray<z.ZodString>;
|
|
13
|
-
}, z.
|
|
17
|
+
targetUrl: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
18
|
+
tokens: z.ZodArray<z.ZodString, "many">;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
title: string;
|
|
21
|
+
notificationId: string;
|
|
22
|
+
body: string;
|
|
23
|
+
targetUrl: string;
|
|
24
|
+
tokens: string[];
|
|
25
|
+
}, {
|
|
26
|
+
title: string;
|
|
27
|
+
notificationId: string;
|
|
28
|
+
body: string;
|
|
29
|
+
targetUrl: string;
|
|
30
|
+
tokens: string[];
|
|
31
|
+
}>;
|
|
14
32
|
export type SendNotificationRequest = z.infer<typeof sendNotificationRequestSchema>;
|
|
15
33
|
export declare const sendNotificationResponseSchema: z.ZodObject<{
|
|
16
34
|
result: z.ZodObject<{
|
|
17
|
-
successfulTokens: z.ZodArray<z.ZodString>;
|
|
18
|
-
invalidTokens: z.ZodArray<z.ZodString>;
|
|
19
|
-
rateLimitedTokens: z.ZodArray<z.ZodString>;
|
|
20
|
-
}, z.
|
|
21
|
-
|
|
35
|
+
successfulTokens: z.ZodArray<z.ZodString, "many">;
|
|
36
|
+
invalidTokens: z.ZodArray<z.ZodString, "many">;
|
|
37
|
+
rateLimitedTokens: z.ZodArray<z.ZodString, "many">;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
successfulTokens: string[];
|
|
40
|
+
invalidTokens: string[];
|
|
41
|
+
rateLimitedTokens: string[];
|
|
42
|
+
}, {
|
|
43
|
+
successfulTokens: string[];
|
|
44
|
+
invalidTokens: string[];
|
|
45
|
+
rateLimitedTokens: string[];
|
|
46
|
+
}>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
result: {
|
|
49
|
+
successfulTokens: string[];
|
|
50
|
+
invalidTokens: string[];
|
|
51
|
+
rateLimitedTokens: string[];
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
result: {
|
|
55
|
+
successfulTokens: string[];
|
|
56
|
+
invalidTokens: string[];
|
|
57
|
+
rateLimitedTokens: string[];
|
|
58
|
+
};
|
|
59
|
+
}>;
|
|
22
60
|
export type SendNotificationResponse = z.infer<typeof sendNotificationResponseSchema>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendNotificationResponseSchema = exports.sendNotificationRequestSchema = exports.notificationDetailsSchema = void 0;
|
|
4
|
-
const
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
5
|
const shared_ts_1 = require("./shared.js");
|
|
6
|
-
exports.notificationDetailsSchema =
|
|
7
|
-
url:
|
|
8
|
-
token:
|
|
6
|
+
exports.notificationDetailsSchema = zod_1.z.object({
|
|
7
|
+
url: zod_1.z.string(),
|
|
8
|
+
token: zod_1.z.string(),
|
|
9
9
|
});
|
|
10
|
-
exports.sendNotificationRequestSchema =
|
|
11
|
-
notificationId:
|
|
12
|
-
title:
|
|
13
|
-
body:
|
|
10
|
+
exports.sendNotificationRequestSchema = zod_1.z.object({
|
|
11
|
+
notificationId: zod_1.z.string().max(128),
|
|
12
|
+
title: zod_1.z.string().max(32),
|
|
13
|
+
body: zod_1.z.string().max(128),
|
|
14
14
|
targetUrl: shared_ts_1.secureUrlSchema,
|
|
15
|
-
tokens:
|
|
15
|
+
tokens: zod_1.z.string().array().max(100),
|
|
16
16
|
});
|
|
17
|
-
exports.sendNotificationResponseSchema =
|
|
18
|
-
result:
|
|
19
|
-
successfulTokens:
|
|
20
|
-
invalidTokens:
|
|
21
|
-
rateLimitedTokens:
|
|
17
|
+
exports.sendNotificationResponseSchema = zod_1.z.object({
|
|
18
|
+
result: zod_1.z.object({
|
|
19
|
+
successfulTokens: zod_1.z.array(zod_1.z.string()),
|
|
20
|
+
invalidTokens: zod_1.z.array(zod_1.z.string()),
|
|
21
|
+
rateLimitedTokens: zod_1.z.array(zod_1.z.string()),
|
|
22
22
|
}),
|
|
23
23
|
});
|
package/dist/schemas/shared.d.ts
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
export declare const createSimpleStringSchema: ({ max, noSpaces, }?: {
|
|
3
3
|
max?: number;
|
|
4
4
|
noSpaces?: boolean;
|
|
5
|
-
}) => z.ZodString
|
|
6
|
-
export declare const secureUrlSchema: z.ZodString
|
|
5
|
+
}) => z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
6
|
+
export declare const secureUrlSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
7
7
|
export declare const miniAppNameSchema: z.ZodString;
|
|
8
8
|
export declare const buttonTitleSchema: z.ZodString;
|
|
9
9
|
export declare const caip19TokenSchema: z.ZodString;
|
|
10
10
|
export declare const hexColorSchema: z.ZodString;
|
|
11
|
-
export declare const domainSchema: z.ZodString
|
|
12
|
-
export declare const aspectRatioSchema: z.ZodUnion<
|
|
11
|
+
export declare const domainSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>, string, string>;
|
|
12
|
+
export declare const aspectRatioSchema: z.ZodUnion<[z.ZodLiteral<"1:1">, z.ZodLiteral<"3:2">]>;
|
|
13
13
|
export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject<{
|
|
14
14
|
header: z.ZodString;
|
|
15
15
|
payload: z.ZodString;
|
|
16
16
|
signature: z.ZodString;
|
|
17
|
-
}, z.
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
header: string;
|
|
19
|
+
payload: string;
|
|
20
|
+
signature: string;
|
|
21
|
+
}, {
|
|
22
|
+
header: string;
|
|
23
|
+
payload: string;
|
|
24
|
+
signature: string;
|
|
25
|
+
}>;
|
|
18
26
|
export type EncodedJsonFarcasterSignatureSchema = z.infer<typeof encodedJsonFarcasterSignatureSchema>;
|
|
19
27
|
export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject<{
|
|
20
28
|
fid: z.ZodNumber;
|
|
21
29
|
type: z.ZodLiteral<"app_key">;
|
|
22
30
|
key: z.ZodString;
|
|
23
|
-
}, z.
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
type: "app_key";
|
|
33
|
+
fid: number;
|
|
34
|
+
key: string;
|
|
35
|
+
}, {
|
|
36
|
+
type: "app_key";
|
|
37
|
+
fid: number;
|
|
38
|
+
key: string;
|
|
39
|
+
}>;
|
|
24
40
|
export type JsonFarcasterSignatureHeaderSchema = z.infer<typeof jsonFarcasterSignatureHeaderSchema>;
|
package/dist/schemas/shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jsonFarcasterSignatureHeaderSchema = exports.encodedJsonFarcasterSignatureSchema = exports.aspectRatioSchema = exports.domainSchema = exports.hexColorSchema = exports.caip19TokenSchema = exports.buttonTitleSchema = exports.miniAppNameSchema = exports.secureUrlSchema = exports.createSimpleStringSchema = void 0;
|
|
4
|
-
const
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
5
|
const SPECIAL_CHARS_PATTERN = /[@#$%^&*+=\/\\|~«»]/;
|
|
6
6
|
const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/;
|
|
7
7
|
// Unicode ranges for emoji detection:
|
|
@@ -12,11 +12,11 @@ const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/;
|
|
|
12
12
|
const EMOJI_PATTERN = /[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u;
|
|
13
13
|
const createSimpleStringSchema = ({ max, noSpaces, } = {}) => {
|
|
14
14
|
const stringValidations = noSpaces
|
|
15
|
-
?
|
|
15
|
+
? zod_1.z
|
|
16
16
|
.string()
|
|
17
17
|
.max(max ?? Number.POSITIVE_INFINITY)
|
|
18
18
|
.regex(/^\S*$/, 'Spaces are not allowed')
|
|
19
|
-
:
|
|
19
|
+
: zod_1.z.string().max(max ?? Number.POSITIVE_INFINITY);
|
|
20
20
|
return stringValidations
|
|
21
21
|
.refine((value) => !EMOJI_PATTERN.test(value), {
|
|
22
22
|
message: 'Emojis and symbols are not allowed',
|
|
@@ -29,7 +29,7 @@ const createSimpleStringSchema = ({ max, noSpaces, } = {}) => {
|
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
exports.createSimpleStringSchema = createSimpleStringSchema;
|
|
32
|
-
exports.secureUrlSchema =
|
|
32
|
+
exports.secureUrlSchema = zod_1.z
|
|
33
33
|
.string()
|
|
34
34
|
.url()
|
|
35
35
|
.startsWith('https://', { message: 'Must be an https url' })
|
|
@@ -61,13 +61,13 @@ exports.secureUrlSchema = v4_1.z
|
|
|
61
61
|
}, {
|
|
62
62
|
message: 'URL must not use IP addresses or localhost',
|
|
63
63
|
});
|
|
64
|
-
exports.miniAppNameSchema =
|
|
65
|
-
exports.buttonTitleSchema =
|
|
64
|
+
exports.miniAppNameSchema = zod_1.z.string().max(32);
|
|
65
|
+
exports.buttonTitleSchema = zod_1.z.string().max(32);
|
|
66
66
|
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)$/;
|
|
67
|
-
exports.caip19TokenSchema =
|
|
67
|
+
exports.caip19TokenSchema = zod_1.z
|
|
68
68
|
.string()
|
|
69
69
|
.regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' });
|
|
70
|
-
exports.hexColorSchema =
|
|
70
|
+
exports.hexColorSchema = zod_1.z
|
|
71
71
|
.string()
|
|
72
72
|
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
|
|
73
73
|
message: 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
|
|
@@ -79,7 +79,7 @@ exports.hexColorSchema = v4_1.z
|
|
|
79
79
|
// - Must have at least one dot (TLD required)
|
|
80
80
|
// - TLD must be at least 2 characters and only letters
|
|
81
81
|
const DOMAIN_REGEX = /^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
82
|
-
exports.domainSchema =
|
|
82
|
+
exports.domainSchema = zod_1.z
|
|
83
83
|
.string()
|
|
84
84
|
.max(1024)
|
|
85
85
|
.regex(DOMAIN_REGEX, {
|
|
@@ -97,14 +97,14 @@ exports.domainSchema = v4_1.z
|
|
|
97
97
|
.refine((value) => !value.includes(':'), {
|
|
98
98
|
message: 'Domain must not include port numbers',
|
|
99
99
|
});
|
|
100
|
-
exports.aspectRatioSchema =
|
|
101
|
-
exports.encodedJsonFarcasterSignatureSchema =
|
|
102
|
-
header:
|
|
103
|
-
payload:
|
|
104
|
-
signature:
|
|
100
|
+
exports.aspectRatioSchema = zod_1.z.union([zod_1.z.literal('1:1'), zod_1.z.literal('3:2')]);
|
|
101
|
+
exports.encodedJsonFarcasterSignatureSchema = zod_1.z.object({
|
|
102
|
+
header: zod_1.z.string(),
|
|
103
|
+
payload: zod_1.z.string(),
|
|
104
|
+
signature: zod_1.z.string(),
|
|
105
105
|
});
|
|
106
|
-
exports.jsonFarcasterSignatureHeaderSchema =
|
|
107
|
-
fid:
|
|
108
|
-
type:
|
|
109
|
-
key:
|
|
106
|
+
exports.jsonFarcasterSignatureHeaderSchema = zod_1.z.object({
|
|
107
|
+
fid: zod_1.z.number(),
|
|
108
|
+
type: zod_1.z.literal('app_key'),
|
|
109
|
+
key: zod_1.z.string().startsWith('0x'),
|
|
110
110
|
});
|