@farcaster/frame-core 0.0.13 → 0.0.15
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/index.js +18 -2
- package/dist/schemas/embeds.js +22 -18
- package/dist/schemas/events.js +20 -17
- package/dist/schemas/index.js +21 -5
- package/dist/schemas/manifest.js +19 -16
- package/dist/schemas/notifications.js +19 -16
- package/dist/schemas/shared.js +15 -12
- package/dist/types.js +4 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/schemas/embeds.d.ts +178 -0
- package/esm/schemas/embeds.js +21 -0
- package/esm/schemas/events.d.ts +131 -0
- package/esm/schemas/events.js +22 -0
- package/esm/schemas/index.d.ts +5 -0
- package/esm/schemas/index.js +5 -0
- package/esm/schemas/manifest.d.ts +96 -0
- package/esm/schemas/manifest.js +21 -0
- package/esm/schemas/notifications.d.ts +60 -0
- package/esm/schemas/notifications.js +20 -0
- package/esm/schemas/shared.d.ts +32 -0
- package/esm/schemas/shared.js +17 -0
- package/esm/tsconfig.tsbuildinfo +1 -0
- package/esm/types.d.ts +108 -0
- package/esm/types.js +3 -0
- package/package.json +8 -3
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./schemas"), exports);
|
package/dist/schemas/embeds.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeParseFrameEmbed = exports.frameEmbedNextSchema = exports.buttonSchema = exports.buttonTitleSchema = exports.actionSchema = exports.actionLaunchFrameSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
exports.actionLaunchFrameSchema = zod_1.z.object({
|
|
7
|
+
type: zod_1.z.literal('launch_frame'),
|
|
8
|
+
name: shared_1.frameNameSchema,
|
|
9
|
+
url: shared_1.secureUrlSchema,
|
|
10
|
+
splashImageUrl: shared_1.secureUrlSchema.optional(),
|
|
11
|
+
splashBackgroundColor: shared_1.hexColorSchema.optional(),
|
|
9
12
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
title: buttonTitleSchema,
|
|
14
|
-
action: actionSchema,
|
|
13
|
+
exports.actionSchema = zod_1.z.discriminatedUnion('type', [exports.actionLaunchFrameSchema]);
|
|
14
|
+
exports.buttonTitleSchema = zod_1.z.string().max(32);
|
|
15
|
+
exports.buttonSchema = zod_1.z.object({
|
|
16
|
+
title: exports.buttonTitleSchema,
|
|
17
|
+
action: exports.actionSchema,
|
|
15
18
|
});
|
|
16
|
-
|
|
17
|
-
version: z.literal('next'),
|
|
18
|
-
imageUrl: secureUrlSchema,
|
|
19
|
-
button: buttonSchema,
|
|
19
|
+
exports.frameEmbedNextSchema = zod_1.z.object({
|
|
20
|
+
version: zod_1.z.literal('next'),
|
|
21
|
+
imageUrl: shared_1.secureUrlSchema,
|
|
22
|
+
button: exports.buttonSchema,
|
|
20
23
|
});
|
|
21
|
-
|
|
24
|
+
const safeParseFrameEmbed = (rawResponse) => exports.frameEmbedNextSchema.safeParse(rawResponse);
|
|
25
|
+
exports.safeParseFrameEmbed = safeParseFrameEmbed;
|
package/dist/schemas/events.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventPayloadSchema = exports.notificationsDisabledPayloadSchema = exports.eventNotificationsEnabledPayloadSchema = exports.eventFrameRemovedPayloadSchema = exports.eventFrameAddedPayloadSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const notifications_1 = require("./notifications");
|
|
6
|
+
exports.eventFrameAddedPayloadSchema = zod_1.z.object({
|
|
7
|
+
event: zod_1.z.literal("frame_added"),
|
|
8
|
+
notificationDetails: notifications_1.notificationDetailsSchema.optional(),
|
|
6
9
|
});
|
|
7
|
-
|
|
8
|
-
event: z.literal("frame_removed"),
|
|
10
|
+
exports.eventFrameRemovedPayloadSchema = zod_1.z.object({
|
|
11
|
+
event: zod_1.z.literal("frame_removed"),
|
|
9
12
|
});
|
|
10
|
-
|
|
11
|
-
event: z.literal("notifications_enabled"),
|
|
12
|
-
notificationDetails: notificationDetailsSchema.required(),
|
|
13
|
+
exports.eventNotificationsEnabledPayloadSchema = zod_1.z.object({
|
|
14
|
+
event: zod_1.z.literal("notifications_enabled"),
|
|
15
|
+
notificationDetails: notifications_1.notificationDetailsSchema.required(),
|
|
13
16
|
});
|
|
14
|
-
|
|
15
|
-
event: z.literal("notifications_disabled"),
|
|
17
|
+
exports.notificationsDisabledPayloadSchema = zod_1.z.object({
|
|
18
|
+
event: zod_1.z.literal("notifications_disabled"),
|
|
16
19
|
});
|
|
17
|
-
|
|
18
|
-
eventFrameAddedPayloadSchema,
|
|
19
|
-
eventFrameRemovedPayloadSchema,
|
|
20
|
-
eventNotificationsEnabledPayloadSchema,
|
|
21
|
-
notificationsDisabledPayloadSchema,
|
|
20
|
+
exports.eventPayloadSchema = zod_1.z.discriminatedUnion("event", [
|
|
21
|
+
exports.eventFrameAddedPayloadSchema,
|
|
22
|
+
exports.eventFrameRemovedPayloadSchema,
|
|
23
|
+
exports.eventNotificationsEnabledPayloadSchema,
|
|
24
|
+
exports.notificationsDisabledPayloadSchema,
|
|
22
25
|
]);
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./embeds"), exports);
|
|
18
|
+
__exportStar(require("./events"), exports);
|
|
19
|
+
__exportStar(require("./shared"), exports);
|
|
20
|
+
__exportStar(require("./manifest"), exports);
|
|
21
|
+
__exportStar(require("./notifications"), exports);
|
package/dist/schemas/manifest.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.domainManifestSchema = exports.domainFrameConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
exports.domainFrameConfigSchema = zod_1.z.object({
|
|
4
7
|
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for
|
|
5
8
|
// backwards compatibilty
|
|
6
|
-
version: z.union([
|
|
7
|
-
z.literal('0.0.0'),
|
|
8
|
-
z.literal('0.0.1'),
|
|
9
|
-
z.literal('1')
|
|
9
|
+
version: zod_1.z.union([
|
|
10
|
+
zod_1.z.literal('0.0.0'),
|
|
11
|
+
zod_1.z.literal('0.0.1'),
|
|
12
|
+
zod_1.z.literal('1')
|
|
10
13
|
]),
|
|
11
|
-
name: frameNameSchema,
|
|
12
|
-
iconUrl: secureUrlSchema,
|
|
13
|
-
homeUrl: secureUrlSchema,
|
|
14
|
-
splashImageUrl: secureUrlSchema.optional(),
|
|
15
|
-
splashBackgroundColor: hexColorSchema.optional(),
|
|
16
|
-
webhookUrl: secureUrlSchema.optional()
|
|
14
|
+
name: shared_1.frameNameSchema,
|
|
15
|
+
iconUrl: shared_1.secureUrlSchema,
|
|
16
|
+
homeUrl: shared_1.secureUrlSchema,
|
|
17
|
+
splashImageUrl: shared_1.secureUrlSchema.optional(),
|
|
18
|
+
splashBackgroundColor: shared_1.hexColorSchema.optional(),
|
|
19
|
+
webhookUrl: shared_1.secureUrlSchema.optional()
|
|
17
20
|
});
|
|
18
|
-
|
|
19
|
-
accountAssociation: encodedJsonFarcasterSignatureSchema,
|
|
20
|
-
frame: domainFrameConfigSchema.optional(),
|
|
21
|
+
exports.domainManifestSchema = zod_1.z.object({
|
|
22
|
+
accountAssociation: shared_1.encodedJsonFarcasterSignatureSchema,
|
|
23
|
+
frame: exports.domainFrameConfigSchema.optional(),
|
|
21
24
|
});
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendNotificationResponseSchema = exports.sendNotificationRequestSchema = exports.notificationDetailsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
exports.notificationDetailsSchema = zod_1.z.object({
|
|
7
|
+
url: zod_1.z.string(),
|
|
8
|
+
token: zod_1.z.string(),
|
|
6
9
|
});
|
|
7
|
-
|
|
8
|
-
notificationId: z.string().max(128),
|
|
9
|
-
title: z.string().max(32),
|
|
10
|
-
body: z.string().max(128),
|
|
11
|
-
targetUrl: secureUrlSchema,
|
|
12
|
-
tokens: z.string().array().max(100),
|
|
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
|
+
targetUrl: shared_1.secureUrlSchema,
|
|
15
|
+
tokens: zod_1.z.string().array().max(100),
|
|
13
16
|
});
|
|
14
|
-
|
|
15
|
-
result: z.object({
|
|
16
|
-
successfulTokens: z.array(z.string()),
|
|
17
|
-
invalidTokens: z.array(z.string()),
|
|
18
|
-
rateLimitedTokens: z.array(z.string()),
|
|
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()),
|
|
19
22
|
}),
|
|
20
23
|
});
|
package/dist/schemas/shared.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsonFarcasterSignatureHeaderSchema = exports.encodedJsonFarcasterSignatureSchema = exports.hexColorSchema = exports.frameNameSchema = exports.secureUrlSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.secureUrlSchema = zod_1.z.string().url().startsWith('https://', { message: 'Must be an https url' }).max(512);
|
|
6
|
+
exports.frameNameSchema = zod_1.z.string().max(32);
|
|
7
|
+
exports.hexColorSchema = zod_1.z.string()
|
|
5
8
|
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
|
|
6
9
|
message: "Invalid hex color code. It should be in the format #RRGGBB or #RGB.",
|
|
7
10
|
});
|
|
8
|
-
|
|
9
|
-
header: z.string(),
|
|
10
|
-
payload: z.string(),
|
|
11
|
-
signature: z.string(),
|
|
11
|
+
exports.encodedJsonFarcasterSignatureSchema = zod_1.z.object({
|
|
12
|
+
header: zod_1.z.string(),
|
|
13
|
+
payload: zod_1.z.string(),
|
|
14
|
+
signature: zod_1.z.string(),
|
|
12
15
|
});
|
|
13
|
-
|
|
14
|
-
fid: z.number(),
|
|
15
|
-
type: z.literal("app_key"),
|
|
16
|
-
key: z.string().startsWith("0x"),
|
|
16
|
+
exports.jsonFarcasterSignatureHeaderSchema = zod_1.z.object({
|
|
17
|
+
fid: zod_1.z.number(),
|
|
18
|
+
type: zod_1.z.literal("app_key"),
|
|
19
|
+
key: zod_1.z.string().startsWith("0x"),
|
|
17
20
|
});
|
package/dist/types.js
CHANGED
package/esm/index.d.ts
ADDED
package/esm/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const actionLaunchFrameSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
7
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
type: "launch_frame";
|
|
10
|
+
name: string;
|
|
11
|
+
url: string;
|
|
12
|
+
splashImageUrl?: string | undefined;
|
|
13
|
+
splashBackgroundColor?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
type: "launch_frame";
|
|
16
|
+
name: string;
|
|
17
|
+
url: string;
|
|
18
|
+
splashImageUrl?: string | undefined;
|
|
19
|
+
splashBackgroundColor?: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
url: z.ZodString;
|
|
25
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
26
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
type: "launch_frame";
|
|
29
|
+
name: string;
|
|
30
|
+
url: string;
|
|
31
|
+
splashImageUrl?: string | undefined;
|
|
32
|
+
splashBackgroundColor?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
type: "launch_frame";
|
|
35
|
+
name: string;
|
|
36
|
+
url: string;
|
|
37
|
+
splashImageUrl?: string | undefined;
|
|
38
|
+
splashBackgroundColor?: string | undefined;
|
|
39
|
+
}>]>;
|
|
40
|
+
export declare const buttonTitleSchema: z.ZodString;
|
|
41
|
+
export declare const buttonSchema: z.ZodObject<{
|
|
42
|
+
title: z.ZodString;
|
|
43
|
+
action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
url: z.ZodString;
|
|
47
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
48
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
type: "launch_frame";
|
|
51
|
+
name: string;
|
|
52
|
+
url: string;
|
|
53
|
+
splashImageUrl?: string | undefined;
|
|
54
|
+
splashBackgroundColor?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
type: "launch_frame";
|
|
57
|
+
name: string;
|
|
58
|
+
url: string;
|
|
59
|
+
splashImageUrl?: string | undefined;
|
|
60
|
+
splashBackgroundColor?: string | undefined;
|
|
61
|
+
}>]>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
title: string;
|
|
64
|
+
action: {
|
|
65
|
+
type: "launch_frame";
|
|
66
|
+
name: string;
|
|
67
|
+
url: string;
|
|
68
|
+
splashImageUrl?: string | undefined;
|
|
69
|
+
splashBackgroundColor?: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
}, {
|
|
72
|
+
title: string;
|
|
73
|
+
action: {
|
|
74
|
+
type: "launch_frame";
|
|
75
|
+
name: string;
|
|
76
|
+
url: string;
|
|
77
|
+
splashImageUrl?: string | undefined;
|
|
78
|
+
splashBackgroundColor?: string | undefined;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
export declare const frameEmbedNextSchema: z.ZodObject<{
|
|
82
|
+
version: z.ZodLiteral<"next">;
|
|
83
|
+
imageUrl: z.ZodString;
|
|
84
|
+
button: z.ZodObject<{
|
|
85
|
+
title: z.ZodString;
|
|
86
|
+
action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
87
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
url: z.ZodString;
|
|
90
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
91
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
type: "launch_frame";
|
|
94
|
+
name: string;
|
|
95
|
+
url: string;
|
|
96
|
+
splashImageUrl?: string | undefined;
|
|
97
|
+
splashBackgroundColor?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
type: "launch_frame";
|
|
100
|
+
name: string;
|
|
101
|
+
url: string;
|
|
102
|
+
splashImageUrl?: string | undefined;
|
|
103
|
+
splashBackgroundColor?: string | undefined;
|
|
104
|
+
}>]>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
title: string;
|
|
107
|
+
action: {
|
|
108
|
+
type: "launch_frame";
|
|
109
|
+
name: string;
|
|
110
|
+
url: string;
|
|
111
|
+
splashImageUrl?: string | undefined;
|
|
112
|
+
splashBackgroundColor?: string | undefined;
|
|
113
|
+
};
|
|
114
|
+
}, {
|
|
115
|
+
title: string;
|
|
116
|
+
action: {
|
|
117
|
+
type: "launch_frame";
|
|
118
|
+
name: string;
|
|
119
|
+
url: string;
|
|
120
|
+
splashImageUrl?: string | undefined;
|
|
121
|
+
splashBackgroundColor?: string | undefined;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
version: "next";
|
|
126
|
+
imageUrl: string;
|
|
127
|
+
button: {
|
|
128
|
+
title: string;
|
|
129
|
+
action: {
|
|
130
|
+
type: "launch_frame";
|
|
131
|
+
name: string;
|
|
132
|
+
url: string;
|
|
133
|
+
splashImageUrl?: string | undefined;
|
|
134
|
+
splashBackgroundColor?: string | undefined;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
}, {
|
|
138
|
+
version: "next";
|
|
139
|
+
imageUrl: string;
|
|
140
|
+
button: {
|
|
141
|
+
title: string;
|
|
142
|
+
action: {
|
|
143
|
+
type: "launch_frame";
|
|
144
|
+
name: string;
|
|
145
|
+
url: string;
|
|
146
|
+
splashImageUrl?: string | undefined;
|
|
147
|
+
splashBackgroundColor?: string | undefined;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
export declare const safeParseFrameEmbed: (rawResponse: unknown) => z.SafeParseReturnType<{
|
|
152
|
+
version: "next";
|
|
153
|
+
imageUrl: string;
|
|
154
|
+
button: {
|
|
155
|
+
title: string;
|
|
156
|
+
action: {
|
|
157
|
+
type: "launch_frame";
|
|
158
|
+
name: string;
|
|
159
|
+
url: string;
|
|
160
|
+
splashImageUrl?: string | undefined;
|
|
161
|
+
splashBackgroundColor?: string | undefined;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
}, {
|
|
165
|
+
version: "next";
|
|
166
|
+
imageUrl: string;
|
|
167
|
+
button: {
|
|
168
|
+
title: string;
|
|
169
|
+
action: {
|
|
170
|
+
type: "launch_frame";
|
|
171
|
+
name: string;
|
|
172
|
+
url: string;
|
|
173
|
+
splashImageUrl?: string | undefined;
|
|
174
|
+
splashBackgroundColor?: string | undefined;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
}>;
|
|
178
|
+
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { hexColorSchema, frameNameSchema, secureUrlSchema } from './shared';
|
|
3
|
+
export const actionLaunchFrameSchema = z.object({
|
|
4
|
+
type: z.literal('launch_frame'),
|
|
5
|
+
name: frameNameSchema,
|
|
6
|
+
url: secureUrlSchema,
|
|
7
|
+
splashImageUrl: secureUrlSchema.optional(),
|
|
8
|
+
splashBackgroundColor: hexColorSchema.optional(),
|
|
9
|
+
});
|
|
10
|
+
export const actionSchema = z.discriminatedUnion('type', [actionLaunchFrameSchema]);
|
|
11
|
+
export const buttonTitleSchema = z.string().max(32);
|
|
12
|
+
export const buttonSchema = z.object({
|
|
13
|
+
title: buttonTitleSchema,
|
|
14
|
+
action: actionSchema,
|
|
15
|
+
});
|
|
16
|
+
export const frameEmbedNextSchema = z.object({
|
|
17
|
+
version: z.literal('next'),
|
|
18
|
+
imageUrl: secureUrlSchema,
|
|
19
|
+
button: buttonSchema,
|
|
20
|
+
});
|
|
21
|
+
export const safeParseFrameEmbed = (rawResponse) => frameEmbedNextSchema.safeParse(rawResponse);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const eventFrameAddedPayloadSchema: z.ZodObject<{
|
|
3
|
+
event: z.ZodLiteral<"frame_added">;
|
|
4
|
+
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
token: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
url: string;
|
|
9
|
+
token: string;
|
|
10
|
+
}, {
|
|
11
|
+
url: string;
|
|
12
|
+
token: string;
|
|
13
|
+
}>>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
event: "frame_added";
|
|
16
|
+
notificationDetails?: {
|
|
17
|
+
url: string;
|
|
18
|
+
token: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
event: "frame_added";
|
|
22
|
+
notificationDetails?: {
|
|
23
|
+
url: string;
|
|
24
|
+
token: string;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type EventFrameAddedPayload = z.infer<typeof eventFrameAddedPayloadSchema>;
|
|
28
|
+
export declare const eventFrameRemovedPayloadSchema: z.ZodObject<{
|
|
29
|
+
event: z.ZodLiteral<"frame_removed">;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
event: "frame_removed";
|
|
32
|
+
}, {
|
|
33
|
+
event: "frame_removed";
|
|
34
|
+
}>;
|
|
35
|
+
export type EventFrameRemovedPayload = z.infer<typeof eventFrameRemovedPayloadSchema>;
|
|
36
|
+
export declare const eventNotificationsEnabledPayloadSchema: z.ZodObject<{
|
|
37
|
+
event: z.ZodLiteral<"notifications_enabled">;
|
|
38
|
+
notificationDetails: z.ZodObject<{
|
|
39
|
+
url: z.ZodString;
|
|
40
|
+
token: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
url: string;
|
|
43
|
+
token: string;
|
|
44
|
+
}, {
|
|
45
|
+
url: string;
|
|
46
|
+
token: string;
|
|
47
|
+
}>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
event: "notifications_enabled";
|
|
50
|
+
notificationDetails: {
|
|
51
|
+
url: string;
|
|
52
|
+
token: string;
|
|
53
|
+
};
|
|
54
|
+
}, {
|
|
55
|
+
event: "notifications_enabled";
|
|
56
|
+
notificationDetails: {
|
|
57
|
+
url: string;
|
|
58
|
+
token: string;
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
export type EventNotificationsEnabledPayload = z.infer<typeof eventNotificationsEnabledPayloadSchema>;
|
|
62
|
+
export declare const notificationsDisabledPayloadSchema: z.ZodObject<{
|
|
63
|
+
event: z.ZodLiteral<"notifications_disabled">;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
event: "notifications_disabled";
|
|
66
|
+
}, {
|
|
67
|
+
event: "notifications_disabled";
|
|
68
|
+
}>;
|
|
69
|
+
export type EventNotificationsDisabledPayload = z.infer<typeof notificationsDisabledPayloadSchema>;
|
|
70
|
+
export declare const eventPayloadSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
71
|
+
event: z.ZodLiteral<"frame_added">;
|
|
72
|
+
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
url: z.ZodString;
|
|
74
|
+
token: z.ZodString;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
url: string;
|
|
77
|
+
token: string;
|
|
78
|
+
}, {
|
|
79
|
+
url: string;
|
|
80
|
+
token: string;
|
|
81
|
+
}>>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
event: "frame_added";
|
|
84
|
+
notificationDetails?: {
|
|
85
|
+
url: string;
|
|
86
|
+
token: string;
|
|
87
|
+
} | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
event: "frame_added";
|
|
90
|
+
notificationDetails?: {
|
|
91
|
+
url: string;
|
|
92
|
+
token: string;
|
|
93
|
+
} | undefined;
|
|
94
|
+
}>, z.ZodObject<{
|
|
95
|
+
event: z.ZodLiteral<"frame_removed">;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
event: "frame_removed";
|
|
98
|
+
}, {
|
|
99
|
+
event: "frame_removed";
|
|
100
|
+
}>, z.ZodObject<{
|
|
101
|
+
event: z.ZodLiteral<"notifications_enabled">;
|
|
102
|
+
notificationDetails: z.ZodObject<{
|
|
103
|
+
url: z.ZodString;
|
|
104
|
+
token: z.ZodString;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
url: string;
|
|
107
|
+
token: string;
|
|
108
|
+
}, {
|
|
109
|
+
url: string;
|
|
110
|
+
token: string;
|
|
111
|
+
}>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
event: "notifications_enabled";
|
|
114
|
+
notificationDetails: {
|
|
115
|
+
url: string;
|
|
116
|
+
token: string;
|
|
117
|
+
};
|
|
118
|
+
}, {
|
|
119
|
+
event: "notifications_enabled";
|
|
120
|
+
notificationDetails: {
|
|
121
|
+
url: string;
|
|
122
|
+
token: string;
|
|
123
|
+
};
|
|
124
|
+
}>, z.ZodObject<{
|
|
125
|
+
event: z.ZodLiteral<"notifications_disabled">;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
event: "notifications_disabled";
|
|
128
|
+
}, {
|
|
129
|
+
event: "notifications_disabled";
|
|
130
|
+
}>]>;
|
|
131
|
+
export type FrameEvent = z.infer<typeof eventPayloadSchema>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { notificationDetailsSchema } from './notifications';
|
|
3
|
+
export const eventFrameAddedPayloadSchema = z.object({
|
|
4
|
+
event: z.literal("frame_added"),
|
|
5
|
+
notificationDetails: notificationDetailsSchema.optional(),
|
|
6
|
+
});
|
|
7
|
+
export const eventFrameRemovedPayloadSchema = z.object({
|
|
8
|
+
event: z.literal("frame_removed"),
|
|
9
|
+
});
|
|
10
|
+
export const eventNotificationsEnabledPayloadSchema = z.object({
|
|
11
|
+
event: z.literal("notifications_enabled"),
|
|
12
|
+
notificationDetails: notificationDetailsSchema.required(),
|
|
13
|
+
});
|
|
14
|
+
export const notificationsDisabledPayloadSchema = z.object({
|
|
15
|
+
event: z.literal("notifications_disabled"),
|
|
16
|
+
});
|
|
17
|
+
export const eventPayloadSchema = z.discriminatedUnion("event", [
|
|
18
|
+
eventFrameAddedPayloadSchema,
|
|
19
|
+
eventFrameRemovedPayloadSchema,
|
|
20
|
+
eventNotificationsEnabledPayloadSchema,
|
|
21
|
+
notificationsDisabledPayloadSchema,
|
|
22
|
+
]);
|