@farcaster/miniapp-core 0.0.0-canary-20250630212339
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/actions/AddMiniApp.d.ts +36 -0
- package/dist/actions/AddMiniApp.js +57 -0
- package/dist/actions/ComposeCast.d.ts +37 -0
- package/dist/actions/ComposeCast.js +2 -0
- package/dist/actions/Haptics.d.ts +5 -0
- package/dist/actions/Haptics.js +2 -0
- package/dist/actions/Ready.d.ts +13 -0
- package/dist/actions/Ready.js +6 -0
- package/dist/actions/SendToken.d.ts +48 -0
- package/dist/actions/SendToken.js +2 -0
- package/dist/actions/SignIn.d.ts +55 -0
- package/dist/actions/SignIn.js +47 -0
- package/dist/actions/SwapToken.d.ts +46 -0
- package/dist/actions/SwapToken.js +2 -0
- package/dist/actions/ViewCast.d.ts +25 -0
- package/dist/actions/ViewCast.js +2 -0
- package/dist/actions/ViewProfile.d.ts +4 -0
- package/dist/actions/ViewProfile.js +2 -0
- package/dist/actions/ViewToken.d.ts +4 -0
- package/dist/actions/ViewToken.js +2 -0
- package/dist/actions/index.d.ts +10 -0
- package/dist/actions/index.js +46 -0
- package/dist/back.d.ts +13 -0
- package/dist/back.js +6 -0
- package/dist/context.d.ts +94 -0
- package/dist/context.js +2 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +49 -0
- package/dist/internal/types.d.ts +8 -0
- package/dist/internal/types.js +2 -0
- package/dist/manifest.d.ts +113 -0
- package/dist/manifest.js +10 -0
- package/dist/schemas/embeds.d.ts +128 -0
- package/dist/schemas/embeds.js +43 -0
- package/dist/schemas/events.d.ts +63 -0
- package/dist/schemas/events.js +35 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +21 -0
- package/dist/schemas/manifest.d.ts +236 -0
- package/dist/schemas/manifest.js +127 -0
- package/dist/schemas/notifications.d.ts +22 -0
- package/dist/schemas/notifications.js +23 -0
- package/dist/schemas/shared.d.ts +24 -0
- package/dist/schemas/shared.js +110 -0
- package/dist/solana.d.ts +72 -0
- package/dist/solana.js +15 -0
- package/dist/solanaWire.d.ts +3 -0
- package/dist/solanaWire.js +84 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.js +41 -0
- package/dist/wallet/ethereum.d.ts +47 -0
- package/dist/wallet/ethereum.js +2 -0
- package/dist/wallet/index.d.ts +1 -0
- package/dist/wallet/index.js +37 -0
- package/esm/actions/AddMiniApp.d.ts +36 -0
- package/esm/actions/AddMiniApp.js +19 -0
- package/esm/actions/ComposeCast.d.ts +37 -0
- package/esm/actions/ComposeCast.js +1 -0
- package/esm/actions/Haptics.d.ts +5 -0
- package/esm/actions/Haptics.js +1 -0
- package/esm/actions/Ready.d.ts +13 -0
- package/esm/actions/Ready.js +3 -0
- package/esm/actions/SendToken.d.ts +48 -0
- package/esm/actions/SendToken.js +1 -0
- package/esm/actions/SignIn.d.ts +55 -0
- package/esm/actions/SignIn.js +10 -0
- package/esm/actions/SwapToken.d.ts +46 -0
- package/esm/actions/SwapToken.js +1 -0
- package/esm/actions/ViewCast.d.ts +25 -0
- package/esm/actions/ViewCast.js +1 -0
- package/esm/actions/ViewProfile.d.ts +4 -0
- package/esm/actions/ViewProfile.js +1 -0
- package/esm/actions/ViewToken.d.ts +4 -0
- package/esm/actions/ViewToken.js +1 -0
- package/esm/actions/index.d.ts +10 -0
- package/esm/actions/index.js +10 -0
- package/esm/back.d.ts +13 -0
- package/esm/back.js +3 -0
- package/esm/context.d.ts +94 -0
- package/esm/context.js +1 -0
- package/esm/errors.d.ts +13 -0
- package/esm/errors.js +8 -0
- package/esm/index.d.ts +10 -0
- package/esm/index.js +10 -0
- package/esm/internal/types.d.ts +8 -0
- package/esm/internal/types.js +1 -0
- package/esm/manifest.d.ts +113 -0
- package/esm/manifest.js +7 -0
- package/esm/schemas/embeds.d.ts +128 -0
- package/esm/schemas/embeds.js +39 -0
- package/esm/schemas/events.d.ts +63 -0
- package/esm/schemas/events.js +32 -0
- package/esm/schemas/index.d.ts +5 -0
- package/esm/schemas/index.js +5 -0
- package/esm/schemas/manifest.d.ts +236 -0
- package/esm/schemas/manifest.js +124 -0
- package/esm/schemas/notifications.d.ts +22 -0
- package/esm/schemas/notifications.js +20 -0
- package/esm/schemas/shared.d.ts +24 -0
- package/esm/schemas/shared.js +106 -0
- package/esm/solana.d.ts +72 -0
- package/esm/solana.js +11 -0
- package/esm/solanaWire.d.ts +3 -0
- package/esm/solanaWire.js +80 -0
- package/esm/tsconfig.tsbuildinfo +1 -0
- package/esm/types.d.ts +91 -0
- package/esm/types.js +23 -0
- package/esm/wallet/ethereum.d.ts +47 -0
- package/esm/wallet/ethereum.js +1 -0
- package/esm/wallet/index.d.ts +1 -0
- package/esm/wallet/index.js +1 -0
- package/package.json +42 -0
- package/src/actions/AddMiniApp.ts +51 -0
- package/src/actions/ComposeCast.ts +44 -0
- package/src/actions/Haptics.ts +9 -0
- package/src/actions/Ready.ts +15 -0
- package/src/actions/SendToken.ts +57 -0
- package/src/actions/SignIn.ts +67 -0
- package/src/actions/SwapToken.ts +54 -0
- package/src/actions/ViewCast.ts +27 -0
- package/src/actions/ViewProfile.ts +5 -0
- package/src/actions/ViewToken.ts +5 -0
- package/src/actions/index.ts +10 -0
- package/src/back.ts +15 -0
- package/src/context.ts +117 -0
- package/src/errors.ts +21 -0
- package/src/index.ts +10 -0
- package/src/internal/types.ts +20 -0
- package/src/manifest.ts +131 -0
- package/src/schemas/embeds.ts +58 -0
- package/src/schemas/events.ts +57 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/manifest.ts +142 -0
- package/src/schemas/notifications.ts +35 -0
- package/src/schemas/shared.ts +138 -0
- package/src/solana.ts +108 -0
- package/src/solanaWire.ts +120 -0
- package/src/types.ts +165 -0
- package/src/wallet/ethereum.ts +65 -0
- package/src/wallet/index.ts +1 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as AddMiniApp from "./AddMiniApp.js";
|
|
2
|
+
export * as ComposeCast from "./ComposeCast.js";
|
|
3
|
+
export * as Haptics from "./Haptics.js";
|
|
4
|
+
export * as Ready from "./Ready.js";
|
|
5
|
+
export * as SignIn from "./SignIn.js";
|
|
6
|
+
export * as SendToken from "./SendToken.js";
|
|
7
|
+
export * as SwapToken from "./SwapToken.js";
|
|
8
|
+
export * as ViewCast from "./ViewCast.js";
|
|
9
|
+
export * as ViewProfile from "./ViewProfile.js";
|
|
10
|
+
export * as ViewToken from "./ViewToken.js";
|
package/esm/back.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type BackState = {
|
|
2
|
+
/**
|
|
3
|
+
* Is the back control visible. Note that on mobile devices Farcaster clients
|
|
4
|
+
* may support a gesture based control rather than button control.
|
|
5
|
+
*
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
visible: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const DEFAULT_BACK_STATE: {
|
|
11
|
+
visible: false;
|
|
12
|
+
};
|
|
13
|
+
export type UpdateBackState = (state: BackState) => Promise<void>;
|
package/esm/back.js
ADDED
package/esm/context.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { MiniAppNotificationDetails } from './schemas/index.ts';
|
|
2
|
+
export type MiniAppUser = {
|
|
3
|
+
fid: number;
|
|
4
|
+
username?: string;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
pfpUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface MiniAppCast {
|
|
9
|
+
author: MiniAppUser;
|
|
10
|
+
hash: string;
|
|
11
|
+
parentHash?: string;
|
|
12
|
+
parentFid?: number;
|
|
13
|
+
timestamp?: number;
|
|
14
|
+
mentions?: MiniAppUser[];
|
|
15
|
+
text: string;
|
|
16
|
+
embeds?: string[];
|
|
17
|
+
channelKey?: string;
|
|
18
|
+
}
|
|
19
|
+
export type CastEmbedLocationContext = {
|
|
20
|
+
type: 'cast_embed';
|
|
21
|
+
embed: string;
|
|
22
|
+
cast: MiniAppCast;
|
|
23
|
+
};
|
|
24
|
+
export type CastShareLocationContext = {
|
|
25
|
+
type: 'cast_share';
|
|
26
|
+
cast: MiniAppCast;
|
|
27
|
+
};
|
|
28
|
+
export type NotificationLocationContext = {
|
|
29
|
+
type: 'notification';
|
|
30
|
+
notification: {
|
|
31
|
+
notificationId: string;
|
|
32
|
+
title: string;
|
|
33
|
+
body: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type LauncherLocationContext = {
|
|
37
|
+
type: 'launcher';
|
|
38
|
+
};
|
|
39
|
+
export type ChannelLocationContext = {
|
|
40
|
+
type: 'channel';
|
|
41
|
+
channel: {
|
|
42
|
+
/**
|
|
43
|
+
* Channel key identifier
|
|
44
|
+
*/
|
|
45
|
+
key: string;
|
|
46
|
+
/**
|
|
47
|
+
* Channel name
|
|
48
|
+
*/
|
|
49
|
+
name: string;
|
|
50
|
+
/**
|
|
51
|
+
* Channel profile image URL
|
|
52
|
+
*/
|
|
53
|
+
imageUrl?: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export type LocationContext = CastEmbedLocationContext | CastShareLocationContext | NotificationLocationContext | LauncherLocationContext | ChannelLocationContext;
|
|
57
|
+
export type AccountLocation = {
|
|
58
|
+
placeId: string;
|
|
59
|
+
/**
|
|
60
|
+
* Human-readable string describing the location
|
|
61
|
+
*/
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
export type UserContext = {
|
|
65
|
+
fid: number;
|
|
66
|
+
username?: string;
|
|
67
|
+
displayName?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Profile image URL
|
|
70
|
+
*/
|
|
71
|
+
pfpUrl?: string;
|
|
72
|
+
location?: AccountLocation;
|
|
73
|
+
};
|
|
74
|
+
export type SafeAreaInsets = {
|
|
75
|
+
top: number;
|
|
76
|
+
bottom: number;
|
|
77
|
+
left: number;
|
|
78
|
+
right: number;
|
|
79
|
+
};
|
|
80
|
+
export type ClientContext = {
|
|
81
|
+
clientFid: number;
|
|
82
|
+
added: boolean;
|
|
83
|
+
notificationDetails?: MiniAppNotificationDetails;
|
|
84
|
+
safeAreaInsets?: SafeAreaInsets;
|
|
85
|
+
};
|
|
86
|
+
export type ClientFeatures = {
|
|
87
|
+
haptics: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type MiniAppContext = {
|
|
90
|
+
client: ClientContext;
|
|
91
|
+
user: UserContext;
|
|
92
|
+
location?: LocationContext;
|
|
93
|
+
features?: ClientFeatures;
|
|
94
|
+
};
|
package/esm/context.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type GlobalErrorType<name extends string = 'Error'> = Error & {
|
|
2
|
+
name: name;
|
|
3
|
+
};
|
|
4
|
+
export declare class BaseError<cause extends Error | undefined = undefined> extends Error {
|
|
5
|
+
name: string;
|
|
6
|
+
cause: cause;
|
|
7
|
+
constructor(message: string, options?: BaseError.Options<cause>);
|
|
8
|
+
}
|
|
9
|
+
export declare namespace BaseError {
|
|
10
|
+
type Options<cause extends Error | undefined = Error | undefined> = {
|
|
11
|
+
cause?: cause | undefined;
|
|
12
|
+
};
|
|
13
|
+
}
|
package/esm/errors.js
ADDED
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './actions/index.ts';
|
|
2
|
+
export * from './wallet/index.ts';
|
|
3
|
+
export * as Back from './back.ts';
|
|
4
|
+
export * as Errors from './errors.ts';
|
|
5
|
+
export * as Context from './context.ts';
|
|
6
|
+
export * as Manifest from './manifest.ts';
|
|
7
|
+
export * from './types.ts';
|
|
8
|
+
export * from './schemas/index.ts';
|
|
9
|
+
export * from './solana.ts';
|
|
10
|
+
export * from './solanaWire.ts';
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./actions/index.js";
|
|
2
|
+
export * from "./wallet/index.js";
|
|
3
|
+
export * as Back from "./back.js";
|
|
4
|
+
export * as Errors from "./errors.js";
|
|
5
|
+
export * as Context from "./context.js";
|
|
6
|
+
export * as Manifest from "./manifest.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./schemas/index.js";
|
|
9
|
+
export * from "./solana.js";
|
|
10
|
+
export * from "./solanaWire.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Compute<type> = {
|
|
2
|
+
[key in keyof type]: type[key];
|
|
3
|
+
} & unknown;
|
|
4
|
+
type KeyofUnion<type> = type extends type ? keyof type : never;
|
|
5
|
+
export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Compute<item & {
|
|
6
|
+
[key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
|
|
7
|
+
}> : never;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Farcaster manifest for a domain hosted at `/.well-known/farcaster.json`
|
|
3
|
+
*/
|
|
4
|
+
export type Manifest = {
|
|
5
|
+
accountAssociation: AccountAssociation;
|
|
6
|
+
miniapp?: MiniAppConfig;
|
|
7
|
+
frame?: MiniAppConfig;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Signed domain association linking this miniapp to a Farcaster account
|
|
11
|
+
*
|
|
12
|
+
* A DomainAssociation can be generated using the {@link https://farcaster.xyz/~/developers/domains | Warpcast
|
|
13
|
+
* Domains Developer} tool.
|
|
14
|
+
*/
|
|
15
|
+
export type AccountAssociation = {
|
|
16
|
+
/**
|
|
17
|
+
* Base64URL encoded JFS signature
|
|
18
|
+
*/
|
|
19
|
+
header: string;
|
|
20
|
+
/**
|
|
21
|
+
* Base64URL encoded payload signature
|
|
22
|
+
*/
|
|
23
|
+
payload: string;
|
|
24
|
+
/**
|
|
25
|
+
* Base64URL encoded signature
|
|
26
|
+
*/
|
|
27
|
+
signature: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* MiniApp configuration
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ``ts
|
|
34
|
+
* const miniapp: MiniAppConfig = {
|
|
35
|
+
* version: '1',
|
|
36
|
+
* name: 'Yoink!',
|
|
37
|
+
* homeUrl: 'https://yoink.party',
|
|
38
|
+
* iconUrl: 'https://yoink.party/img/icon.png',
|
|
39
|
+
* imageUrl: 'https://yoink.party/framesV2/opengraph-image',
|
|
40
|
+
* buttonTitle: '🚩 Start',
|
|
41
|
+
* splashImageUrl: 'https://yoink.party/img/splash.png',
|
|
42
|
+
* splashImageBackgroundColor: '#eeeee4',
|
|
43
|
+
* webhookUrl: 'https://yoink.party/webhook'
|
|
44
|
+
* };
|
|
45
|
+
* ``
|
|
46
|
+
*/
|
|
47
|
+
export type MiniAppConfig = {
|
|
48
|
+
/**
|
|
49
|
+
* Manifest version
|
|
50
|
+
*
|
|
51
|
+
* Must be the literal '1'.
|
|
52
|
+
*/
|
|
53
|
+
version: '1';
|
|
54
|
+
/**
|
|
55
|
+
* App name that will be displayed to users
|
|
56
|
+
*
|
|
57
|
+
* Max length of 32 characters.
|
|
58
|
+
*/
|
|
59
|
+
name: string;
|
|
60
|
+
/**
|
|
61
|
+
* Default launch URL
|
|
62
|
+
*
|
|
63
|
+
* Max length of 1024 characters.
|
|
64
|
+
*/
|
|
65
|
+
homeUrl: string;
|
|
66
|
+
/**
|
|
67
|
+
* Icon URL
|
|
68
|
+
*
|
|
69
|
+
* Max length of 1024 characters. Image must be 200x200px and less than 1MB.
|
|
70
|
+
*/
|
|
71
|
+
iconUrl: string;
|
|
72
|
+
/**
|
|
73
|
+
* Image URL
|
|
74
|
+
*
|
|
75
|
+
* Max length of 1024 characters. Image must have a 3:2 ratio.
|
|
76
|
+
*/
|
|
77
|
+
imageUrl: string;
|
|
78
|
+
/**
|
|
79
|
+
* Default button title to use when miniapp is rendered.
|
|
80
|
+
*
|
|
81
|
+
* Max length of 32 characters.
|
|
82
|
+
*/
|
|
83
|
+
buttonTitle: string;
|
|
84
|
+
/**
|
|
85
|
+
* Splash image URL
|
|
86
|
+
*
|
|
87
|
+
* Max length of 1024 characters. Image must be 200x200px and less than 1MB.
|
|
88
|
+
*/
|
|
89
|
+
splashImageUrl?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Splash background color
|
|
92
|
+
*
|
|
93
|
+
* Must be a hex color code.
|
|
94
|
+
*/
|
|
95
|
+
splashBackgroundColor?: string;
|
|
96
|
+
/**
|
|
97
|
+
* URL to which clients will POST server events.
|
|
98
|
+
* Max length of 1024 characters.
|
|
99
|
+
* Required if the miniapp application uses notifications.
|
|
100
|
+
*/
|
|
101
|
+
webhookUrl?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Canonical domain for the miniapp application.
|
|
104
|
+
* If specified, this domain will be treated as the primary domain for the miniapp.
|
|
105
|
+
* Max length of 1024 characters.
|
|
106
|
+
*/
|
|
107
|
+
canonicalDomain?: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Helper function to get the MiniApp config from a manifest,
|
|
111
|
+
* supporting both 'miniapp' and 'frame' properties during the transition period
|
|
112
|
+
*/
|
|
113
|
+
export declare function getMiniAppConfig(manifest: Manifest): MiniAppConfig | undefined;
|
package/esm/manifest.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export declare const actionLaunchFrameSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
url: z.ZodOptional<z.ZodString>;
|
|
6
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
7
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const actionLaunchMiniAppSchema: z.ZodObject<{
|
|
10
|
+
type: z.ZodLiteral<"launch_miniapp">;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
url: z.ZodOptional<z.ZodString>;
|
|
13
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
14
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const actionViewTokenSchema: z.ZodObject<{
|
|
17
|
+
type: z.ZodLiteral<"view_token">;
|
|
18
|
+
token: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const actionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
21
|
+
type: z.ZodLiteral<"launch_miniapp">;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
url: z.ZodOptional<z.ZodString>;
|
|
24
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
25
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<"view_token">;
|
|
28
|
+
token: z.ZodString;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
31
|
+
name: z.ZodString;
|
|
32
|
+
url: z.ZodOptional<z.ZodString>;
|
|
33
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
34
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>]>;
|
|
36
|
+
export declare const buttonSchema: z.ZodObject<{
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
action: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
39
|
+
type: z.ZodLiteral<"launch_miniapp">;
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
url: z.ZodOptional<z.ZodString>;
|
|
42
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
43
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
45
|
+
type: z.ZodLiteral<"view_token">;
|
|
46
|
+
token: z.ZodString;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
49
|
+
name: z.ZodString;
|
|
50
|
+
url: z.ZodOptional<z.ZodString>;
|
|
51
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
52
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>]>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export declare const miniAppEmbedNextSchema: z.ZodObject<{
|
|
56
|
+
version: z.ZodLiteral<"next">;
|
|
57
|
+
imageUrl: z.ZodString;
|
|
58
|
+
aspectRatio: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"1:1">, z.ZodLiteral<"3:2">]>>;
|
|
59
|
+
button: z.ZodObject<{
|
|
60
|
+
title: z.ZodString;
|
|
61
|
+
action: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
62
|
+
type: z.ZodLiteral<"launch_miniapp">;
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
url: z.ZodOptional<z.ZodString>;
|
|
65
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
66
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
68
|
+
type: z.ZodLiteral<"view_token">;
|
|
69
|
+
token: z.ZodString;
|
|
70
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
+
type: z.ZodLiteral<"launch_frame">;
|
|
72
|
+
name: z.ZodString;
|
|
73
|
+
url: z.ZodOptional<z.ZodString>;
|
|
74
|
+
splashImageUrl: z.ZodOptional<z.ZodString>;
|
|
75
|
+
splashBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>]>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const safeParseMiniAppEmbed: (rawResponse: unknown) => z.ZodSafeParseResult<{
|
|
80
|
+
version: "next";
|
|
81
|
+
imageUrl: string;
|
|
82
|
+
button: {
|
|
83
|
+
title: string;
|
|
84
|
+
action: {
|
|
85
|
+
type: "launch_miniapp";
|
|
86
|
+
name: string;
|
|
87
|
+
url?: string | undefined;
|
|
88
|
+
splashImageUrl?: string | undefined;
|
|
89
|
+
splashBackgroundColor?: string | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
type: "view_token";
|
|
92
|
+
token: string;
|
|
93
|
+
} | {
|
|
94
|
+
type: "launch_frame";
|
|
95
|
+
name: string;
|
|
96
|
+
url?: string | undefined;
|
|
97
|
+
splashImageUrl?: string | undefined;
|
|
98
|
+
splashBackgroundColor?: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
aspectRatio?: "1:1" | "3:2" | undefined;
|
|
102
|
+
}>;
|
|
103
|
+
export declare const safeParseFrameEmbed: (rawResponse: unknown) => z.ZodSafeParseResult<{
|
|
104
|
+
version: "next";
|
|
105
|
+
imageUrl: string;
|
|
106
|
+
button: {
|
|
107
|
+
title: string;
|
|
108
|
+
action: {
|
|
109
|
+
type: "launch_miniapp";
|
|
110
|
+
name: string;
|
|
111
|
+
url?: string | undefined;
|
|
112
|
+
splashImageUrl?: string | undefined;
|
|
113
|
+
splashBackgroundColor?: string | undefined;
|
|
114
|
+
} | {
|
|
115
|
+
type: "view_token";
|
|
116
|
+
token: string;
|
|
117
|
+
} | {
|
|
118
|
+
type: "launch_frame";
|
|
119
|
+
name: string;
|
|
120
|
+
url?: string | undefined;
|
|
121
|
+
splashImageUrl?: string | undefined;
|
|
122
|
+
splashBackgroundColor?: string | undefined;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
aspectRatio?: "1:1" | "3:2" | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
export type MiniAppEmbedNext = z.infer<typeof miniAppEmbedNextSchema>;
|
|
128
|
+
export type FrameEmbedNext = MiniAppEmbedNext;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { aspectRatioSchema, buttonTitleSchema, caip19TokenSchema, hexColorSchema, miniAppNameSchema, secureUrlSchema, } from "./shared.js";
|
|
3
|
+
export const actionLaunchFrameSchema = z.object({
|
|
4
|
+
type: z.literal('launch_frame'),
|
|
5
|
+
name: miniAppNameSchema,
|
|
6
|
+
url: secureUrlSchema.optional(),
|
|
7
|
+
splashImageUrl: secureUrlSchema.optional(),
|
|
8
|
+
splashBackgroundColor: hexColorSchema.optional(),
|
|
9
|
+
});
|
|
10
|
+
export const actionLaunchMiniAppSchema = z.object({
|
|
11
|
+
type: z.literal('launch_miniapp'),
|
|
12
|
+
name: miniAppNameSchema,
|
|
13
|
+
url: secureUrlSchema.optional(),
|
|
14
|
+
splashImageUrl: secureUrlSchema.optional(),
|
|
15
|
+
splashBackgroundColor: hexColorSchema.optional(),
|
|
16
|
+
});
|
|
17
|
+
export const actionViewTokenSchema = z.object({
|
|
18
|
+
type: z.literal('view_token'),
|
|
19
|
+
token: caip19TokenSchema,
|
|
20
|
+
});
|
|
21
|
+
export const actionSchema = z.discriminatedUnion('type', [
|
|
22
|
+
actionLaunchMiniAppSchema,
|
|
23
|
+
actionViewTokenSchema,
|
|
24
|
+
// Remove after compatibility period
|
|
25
|
+
actionLaunchFrameSchema,
|
|
26
|
+
]);
|
|
27
|
+
export const buttonSchema = z.object({
|
|
28
|
+
title: buttonTitleSchema,
|
|
29
|
+
action: actionSchema,
|
|
30
|
+
});
|
|
31
|
+
export const miniAppEmbedNextSchema = z.object({
|
|
32
|
+
version: z.literal('next'),
|
|
33
|
+
imageUrl: secureUrlSchema,
|
|
34
|
+
aspectRatio: aspectRatioSchema.optional(),
|
|
35
|
+
button: buttonSchema,
|
|
36
|
+
});
|
|
37
|
+
export const safeParseMiniAppEmbed = (rawResponse) => miniAppEmbedNextSchema.safeParse(rawResponse);
|
|
38
|
+
// Backward compatibility - also parse fc:frame meta tags
|
|
39
|
+
export const safeParseFrameEmbed = safeParseMiniAppEmbed;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export declare const eventMiniAppAddedSchema: z.ZodObject<{
|
|
3
|
+
event: z.ZodLiteral<"miniapp_added">;
|
|
4
|
+
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
token: z.ZodString;
|
|
7
|
+
}, z.core.$strip>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type EventMiniAppAdded = z.infer<typeof eventMiniAppAddedSchema>;
|
|
10
|
+
export declare const eventFrameAddedSchema: z.ZodObject<{
|
|
11
|
+
event: z.ZodLiteral<"frame_added">;
|
|
12
|
+
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
url: z.ZodString;
|
|
14
|
+
token: z.ZodString;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>;
|
|
18
|
+
export declare const eventMiniAppRemovedSchema: z.ZodObject<{
|
|
19
|
+
event: z.ZodLiteral<"miniapp_removed">;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type EventMiniAppRemoved = z.infer<typeof eventMiniAppRemovedSchema>;
|
|
22
|
+
export declare const eventFrameRemovedSchema: z.ZodObject<{
|
|
23
|
+
event: z.ZodLiteral<"frame_removed">;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>;
|
|
26
|
+
export declare const eventNotificationsEnabledSchema: z.ZodObject<{
|
|
27
|
+
event: z.ZodLiteral<"notifications_enabled">;
|
|
28
|
+
notificationDetails: z.ZodObject<{
|
|
29
|
+
url: z.ZodNonOptional<z.ZodString>;
|
|
30
|
+
token: z.ZodNonOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type EventNotificationsEnabled = z.infer<typeof eventNotificationsEnabledSchema>;
|
|
34
|
+
export declare const notificationsDisabledSchema: z.ZodObject<{
|
|
35
|
+
event: z.ZodLiteral<"notifications_disabled">;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type EventNotificationsDisabled = z.infer<typeof notificationsDisabledSchema>;
|
|
38
|
+
export declare const serverEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
39
|
+
event: z.ZodLiteral<"miniapp_added">;
|
|
40
|
+
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
url: z.ZodString;
|
|
42
|
+
token: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
45
|
+
event: z.ZodLiteral<"miniapp_removed">;
|
|
46
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
47
|
+
event: z.ZodLiteral<"notifications_enabled">;
|
|
48
|
+
notificationDetails: z.ZodObject<{
|
|
49
|
+
url: z.ZodNonOptional<z.ZodString>;
|
|
50
|
+
token: z.ZodNonOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
event: z.ZodLiteral<"notifications_disabled">;
|
|
54
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
55
|
+
event: z.ZodLiteral<"frame_added">;
|
|
56
|
+
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
url: z.ZodString;
|
|
58
|
+
token: z.ZodString;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
event: z.ZodLiteral<"frame_removed">;
|
|
62
|
+
}, z.core.$strip>]>;
|
|
63
|
+
export type MiniAppServerEvent = z.infer<typeof serverEventSchema>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { notificationDetailsSchema } from "./notifications.js";
|
|
3
|
+
export const eventMiniAppAddedSchema = z.object({
|
|
4
|
+
event: z.literal('miniapp_added'),
|
|
5
|
+
notificationDetails: notificationDetailsSchema.optional(),
|
|
6
|
+
});
|
|
7
|
+
export const eventFrameAddedSchema = z.object({
|
|
8
|
+
event: z.literal('frame_added'),
|
|
9
|
+
notificationDetails: notificationDetailsSchema.optional(),
|
|
10
|
+
});
|
|
11
|
+
export const eventMiniAppRemovedSchema = z.object({
|
|
12
|
+
event: z.literal('miniapp_removed'),
|
|
13
|
+
});
|
|
14
|
+
export const eventFrameRemovedSchema = z.object({
|
|
15
|
+
event: z.literal('frame_removed'),
|
|
16
|
+
});
|
|
17
|
+
export const eventNotificationsEnabledSchema = z.object({
|
|
18
|
+
event: z.literal('notifications_enabled'),
|
|
19
|
+
notificationDetails: notificationDetailsSchema.required(),
|
|
20
|
+
});
|
|
21
|
+
export const notificationsDisabledSchema = z.object({
|
|
22
|
+
event: z.literal('notifications_disabled'),
|
|
23
|
+
});
|
|
24
|
+
export const serverEventSchema = z.discriminatedUnion('event', [
|
|
25
|
+
eventMiniAppAddedSchema,
|
|
26
|
+
eventMiniAppRemovedSchema,
|
|
27
|
+
eventNotificationsEnabledSchema,
|
|
28
|
+
notificationsDisabledSchema,
|
|
29
|
+
// Remove after compatibility period
|
|
30
|
+
eventFrameAddedSchema,
|
|
31
|
+
eventFrameRemovedSchema,
|
|
32
|
+
]);
|