@farcaster/frame-core
Advanced tools
Comparing version
@@ -1,22 +0,27 @@ | ||
import * as Errors from '../errors'; | ||
import type { OneOf } from '../internal/types'; | ||
import type { FrameNotificationDetails } from '../schemas'; | ||
import * as Errors from '../errors' | ||
import type { OneOf } from '../internal/types' | ||
import type { FrameNotificationDetails } from '../schemas' | ||
export type AddFrameResult = { | ||
notificationDetails?: FrameNotificationDetails; | ||
}; | ||
export type AddFrame = () => Promise<AddFrameResult>; | ||
notificationDetails?: FrameNotificationDetails | ||
} | ||
export type AddFrame = () => Promise<AddFrameResult> | ||
type InvalidDomainManifestJsonError = { | ||
type: 'invalid_domain_manifest'; | ||
}; | ||
type: 'invalid_domain_manifest' | ||
} | ||
type RejectedByUserJsonError = { | ||
type: 'rejected_by_user'; | ||
}; | ||
export type AddFrameJsonError = InvalidDomainManifestJsonError | RejectedByUserJsonError; | ||
export type AddFrameRejectedReason = AddFrameJsonError['type']; | ||
export type AddFrameJsonResult = OneOf<{ | ||
result: AddFrameResult; | ||
} | { | ||
error: AddFrameJsonError; | ||
}>; | ||
export type WireAddFrame = () => Promise<AddFrameJsonResult>; | ||
type: 'rejected_by_user' | ||
} | ||
export type AddFrameJsonError = | ||
| InvalidDomainManifestJsonError | ||
| RejectedByUserJsonError | ||
export type AddFrameRejectedReason = AddFrameJsonError['type'] | ||
export type AddFrameJsonResult = OneOf< | ||
| { | ||
result: AddFrameResult | ||
} | ||
| { | ||
error: AddFrameJsonError | ||
} | ||
> | ||
export type WireAddFrame = () => Promise<AddFrameJsonResult> | ||
/** | ||
@@ -26,4 +31,4 @@ * Thrown when the frame does not have a valid domain manifest. | ||
export declare class InvalidDomainManifest extends Errors.BaseError { | ||
readonly name = "AddFrame.InvalidDomainManifest"; | ||
constructor(); | ||
readonly name = 'AddFrame.InvalidDomainManifest' | ||
constructor() | ||
} | ||
@@ -34,5 +39,4 @@ /** | ||
export declare class RejectedByUser extends Errors.BaseError { | ||
readonly name = "AddFrame.RejectedByUser"; | ||
constructor(); | ||
readonly name = 'AddFrame.RejectedByUser' | ||
constructor() | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import * as Errors from '../errors'; | ||
import * as Errors from '../errors' | ||
/** | ||
@@ -6,6 +6,6 @@ * Thrown when the frame does not have a valid domain manifest. | ||
export class InvalidDomainManifest extends Errors.BaseError { | ||
name = 'AddFrame.InvalidDomainManifest'; | ||
constructor() { | ||
super('Invalid domain manifest'); | ||
} | ||
name = 'AddFrame.InvalidDomainManifest' | ||
constructor() { | ||
super('Invalid domain manifest') | ||
} | ||
} | ||
@@ -16,6 +16,6 @@ /** | ||
export class RejectedByUser extends Errors.BaseError { | ||
name = 'AddFrame.RejectedByUser'; | ||
constructor() { | ||
super('Add frame rejected by user'); | ||
} | ||
name = 'AddFrame.RejectedByUser' | ||
constructor() { | ||
super('Add frame rejected by user') | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
export * as AddFrame from './AddFrame'; | ||
export * as Ready from './Ready'; | ||
export * as SignIn from './SignIn'; | ||
export * as Swap from './Swap'; | ||
export * as ViewProfile from './ViewProfile'; | ||
export * as ViewToken from './ViewToken'; | ||
export * as AddFrame from './AddFrame' | ||
export * as Ready from './Ready' | ||
export * as SignIn from './SignIn' | ||
export * as Swap from './Swap' | ||
export * as ViewProfile from './ViewProfile' | ||
export * as ViewToken from './ViewToken' |
@@ -1,6 +0,6 @@ | ||
export * as AddFrame from './AddFrame'; | ||
export * as Ready from './Ready'; | ||
export * as SignIn from './SignIn'; | ||
export * as Swap from './Swap'; | ||
export * as ViewProfile from './ViewProfile'; | ||
export * as ViewToken from './ViewToken'; | ||
export * as AddFrame from './AddFrame' | ||
export * as Ready from './Ready' | ||
export * as SignIn from './SignIn' | ||
export * as Swap from './Swap' | ||
export * as ViewProfile from './ViewProfile' | ||
export * as ViewToken from './ViewToken' |
export type ReadyOptions = { | ||
/** | ||
* Disable native gestures. Use this option if your frame uses gestures | ||
* that conflict with native gestures. | ||
* | ||
* @defaultValue false | ||
*/ | ||
disableNativeGestures: boolean; | ||
}; | ||
/** | ||
* Disable native gestures. Use this option if your frame uses gestures | ||
* that conflict with native gestures. | ||
* | ||
* @defaultValue false | ||
*/ | ||
disableNativeGestures: boolean | ||
} | ||
export declare const DEFAULT_READY_OPTIONS: { | ||
disableNativeGestures: false; | ||
}; | ||
export type Ready = (options?: Partial<ReadyOptions>) => void; | ||
disableNativeGestures: false | ||
} | ||
export type Ready = (options?: Partial<ReadyOptions>) => void |
export const DEFAULT_READY_OPTIONS = { | ||
disableNativeGestures: false, | ||
}; | ||
disableNativeGestures: false, | ||
} |
@@ -1,34 +0,37 @@ | ||
import * as Errors from '../errors'; | ||
import type { OneOf } from '../internal/types'; | ||
import * as Errors from '../errors' | ||
import type { OneOf } from '../internal/types' | ||
export type SignInOptions = { | ||
/** | ||
* A random string used to prevent replay attacks. | ||
*/ | ||
nonce: string; | ||
/** | ||
* Start time at which the signature becomes valid. | ||
* ISO 8601 datetime. | ||
*/ | ||
notBefore?: string; | ||
/** | ||
* Expiration time at which the signature is no longer valid. | ||
* ISO 8601 datetime. | ||
*/ | ||
expirationTime?: string; | ||
}; | ||
/** | ||
* A random string used to prevent replay attacks. | ||
*/ | ||
nonce: string | ||
/** | ||
* Start time at which the signature becomes valid. | ||
* ISO 8601 datetime. | ||
*/ | ||
notBefore?: string | ||
/** | ||
* Expiration time at which the signature is no longer valid. | ||
* ISO 8601 datetime. | ||
*/ | ||
expirationTime?: string | ||
} | ||
export type SignInResult = { | ||
signature: string; | ||
message: string; | ||
}; | ||
export type SignIn = (options: SignInOptions) => Promise<SignInResult>; | ||
signature: string | ||
message: string | ||
} | ||
export type SignIn = (options: SignInOptions) => Promise<SignInResult> | ||
type RejectedByUserJsonError = { | ||
type: 'rejected_by_user'; | ||
}; | ||
export type SignInJsonError = RejectedByUserJsonError; | ||
export type SignInJsonResult = OneOf<{ | ||
result: SignInResult; | ||
} | { | ||
error: SignInJsonError; | ||
}>; | ||
export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>; | ||
type: 'rejected_by_user' | ||
} | ||
export type SignInJsonError = RejectedByUserJsonError | ||
export type SignInJsonResult = OneOf< | ||
| { | ||
result: SignInResult | ||
} | ||
| { | ||
error: SignInJsonError | ||
} | ||
> | ||
export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult> | ||
/** | ||
@@ -38,5 +41,4 @@ * Thrown when a sign in action was rejected. | ||
export declare class RejectedByUser extends Errors.BaseError { | ||
readonly name = "SignIn.RejectedByUser"; | ||
constructor(); | ||
readonly name = 'SignIn.RejectedByUser' | ||
constructor() | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import * as Errors from '../errors'; | ||
import * as Errors from '../errors' | ||
/** | ||
@@ -6,6 +6,6 @@ * Thrown when a sign in action was rejected. | ||
export class RejectedByUser extends Errors.BaseError { | ||
name = 'SignIn.RejectedByUser'; | ||
constructor() { | ||
super('Sign in rejected by user'); | ||
} | ||
name = 'SignIn.RejectedByUser' | ||
constructor() { | ||
super('Sign in rejected by user') | ||
} | ||
} |
export type SwapOptions = { | ||
/** | ||
* CAIP-19 asset ID | ||
* For example, Base USDC: | ||
* eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | ||
*/ | ||
sellToken?: string; | ||
/** | ||
* CAIP-19 token ID. For example, OP ETH: | ||
* eip155:10/native | ||
*/ | ||
buyToken?: string; | ||
/** | ||
* Sell token amount, as numeric string. | ||
* For example, 10 USDC: 1000000 | ||
*/ | ||
sellAmount?: string; | ||
}; | ||
/** | ||
* CAIP-19 asset ID | ||
* For example, Base USDC: | ||
* eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | ||
*/ | ||
sellToken?: string | ||
/** | ||
* CAIP-19 token ID. For example, OP ETH: | ||
* eip155:10/native | ||
*/ | ||
buyToken?: string | ||
/** | ||
* Sell token amount, as numeric string. | ||
* For example, 10 USDC: 1000000 | ||
*/ | ||
sellAmount?: string | ||
} | ||
type SwapDetails = { | ||
/** | ||
* Array of tx identifiers in order of execution. | ||
* Some swaps will have both an approval and swap tx. | ||
*/ | ||
transactions: `0x${string}`[]; | ||
}; | ||
/** | ||
* Array of tx identifiers in order of execution. | ||
* Some swaps will have both an approval and swap tx. | ||
*/ | ||
transactions: `0x${string}`[] | ||
} | ||
type SwapErrorDetails = { | ||
/** | ||
* Error code. | ||
*/ | ||
error: string; | ||
/** | ||
* Error message. | ||
*/ | ||
message?: string; | ||
}; | ||
export type SwapErrorReason = 'rejected_by_user' | 'swap_failed'; | ||
export type SwapResult = { | ||
success: true; | ||
swap: SwapDetails; | ||
} | { | ||
success: false; | ||
reason: SwapErrorReason; | ||
error?: SwapErrorDetails; | ||
}; | ||
export type Swap = (options: SwapOptions) => Promise<SwapResult>; | ||
export {}; | ||
/** | ||
* Error code. | ||
*/ | ||
error: string | ||
/** | ||
* Error message. | ||
*/ | ||
message?: string | ||
} | ||
export type SwapErrorReason = 'rejected_by_user' | 'swap_failed' | ||
export type SwapResult = | ||
| { | ||
success: true | ||
swap: SwapDetails | ||
} | ||
| { | ||
success: false | ||
reason: SwapErrorReason | ||
error?: SwapErrorDetails | ||
} | ||
export type Swap = (options: SwapOptions) => Promise<SwapResult> |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
export {} |
export type ViewProfileOptions = { | ||
fid: number; | ||
}; | ||
export type ViewProfile = (options: ViewProfileOptions) => Promise<void>; | ||
fid: number | ||
} | ||
export type ViewProfile = (options: ViewProfileOptions) => Promise<void> |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
export {} |
export type ViewTokenOptions = { | ||
token: string; | ||
}; | ||
export type ViewToken = (options: ViewTokenOptions) => Promise<void>; | ||
token: string | ||
} | ||
export type ViewToken = (options: ViewTokenOptions) => Promise<void> |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
export {} |
@@ -1,72 +0,76 @@ | ||
import type { FrameNotificationDetails } from './schemas'; | ||
import type { FrameNotificationDetails } from './schemas' | ||
export type CastEmbedLocationContext = { | ||
type: 'cast_embed'; | ||
embed: string; | ||
cast: { | ||
fid: number; | ||
hash: string; | ||
}; | ||
}; | ||
type: 'cast_embed' | ||
embed: string | ||
cast: { | ||
fid: number | ||
hash: string | ||
} | ||
} | ||
export type NotificationLocationContext = { | ||
type: 'notification'; | ||
notification: { | ||
notificationId: string; | ||
title: string; | ||
body: string; | ||
}; | ||
}; | ||
type: 'notification' | ||
notification: { | ||
notificationId: string | ||
title: string | ||
body: string | ||
} | ||
} | ||
export type LauncherLocationContext = { | ||
type: 'launcher'; | ||
}; | ||
type: 'launcher' | ||
} | ||
export type ChannelLocationContext = { | ||
type: 'channel'; | ||
channel: { | ||
/** | ||
* Channel key identifier | ||
*/ | ||
key: string; | ||
/** | ||
* Channel name | ||
*/ | ||
name: string; | ||
/** | ||
* Channel profile image URL | ||
*/ | ||
imageUrl?: string; | ||
}; | ||
}; | ||
export type LocationContext = CastEmbedLocationContext | NotificationLocationContext | LauncherLocationContext | ChannelLocationContext; | ||
export type AccountLocation = { | ||
placeId: string; | ||
type: 'channel' | ||
channel: { | ||
/** | ||
* Human-readable string describing the location | ||
* Channel key identifier | ||
*/ | ||
description: string; | ||
}; | ||
export type UserContext = { | ||
fid: number; | ||
username?: string; | ||
displayName?: string; | ||
key: string | ||
/** | ||
* Profile image URL | ||
* Channel name | ||
*/ | ||
pfpUrl?: string; | ||
location?: AccountLocation; | ||
}; | ||
name: string | ||
/** | ||
* Channel profile image URL | ||
*/ | ||
imageUrl?: string | ||
} | ||
} | ||
export type LocationContext = | ||
| CastEmbedLocationContext | ||
| NotificationLocationContext | ||
| LauncherLocationContext | ||
| ChannelLocationContext | ||
export type AccountLocation = { | ||
placeId: string | ||
/** | ||
* Human-readable string describing the location | ||
*/ | ||
description: string | ||
} | ||
export type UserContext = { | ||
fid: number | ||
username?: string | ||
displayName?: string | ||
/** | ||
* Profile image URL | ||
*/ | ||
pfpUrl?: string | ||
location?: AccountLocation | ||
} | ||
export type SafeAreaInsets = { | ||
top: number; | ||
bottom: number; | ||
left: number; | ||
right: number; | ||
}; | ||
top: number | ||
bottom: number | ||
left: number | ||
right: number | ||
} | ||
export type ClientContext = { | ||
clientFid: number; | ||
added: boolean; | ||
notificationDetails?: FrameNotificationDetails; | ||
safeAreaInsets?: SafeAreaInsets; | ||
}; | ||
clientFid: number | ||
added: boolean | ||
notificationDetails?: FrameNotificationDetails | ||
safeAreaInsets?: SafeAreaInsets | ||
} | ||
export type FrameContext = { | ||
client: ClientContext; | ||
user: UserContext; | ||
location?: LocationContext; | ||
}; | ||
client: ClientContext | ||
user: UserContext | ||
location?: LocationContext | ||
} |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
export {} |
@@ -1,10 +0,12 @@ | ||
export declare class BaseError<cause extends Error | undefined = undefined> extends Error { | ||
name: string; | ||
cause: cause; | ||
constructor(message: string, options?: BaseError.Options<cause>); | ||
export declare class BaseError< | ||
cause extends Error | undefined = undefined, | ||
> extends Error { | ||
name: string | ||
cause: cause | ||
constructor(message: string, options?: BaseError.Options<cause>) | ||
} | ||
export declare namespace BaseError { | ||
type Options<cause extends Error | undefined = Error | undefined> = { | ||
cause?: cause | undefined; | ||
}; | ||
type Options<cause extends Error | undefined = Error | undefined> = { | ||
cause?: cause | undefined | ||
} | ||
} |
export class BaseError extends Error { | ||
name = 'BaseError'; | ||
cause; | ||
constructor(message, options = {}) { | ||
super(message, options.cause ? { cause: options.cause } : undefined); | ||
this.cause = options.cause; | ||
} | ||
name = 'BaseError' | ||
cause | ||
constructor(message, options = {}) { | ||
super(message, options.cause ? { cause: options.cause } : undefined) | ||
this.cause = options.cause | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
export * from './actions'; | ||
export * from './wallet'; | ||
export * as Context from './context'; | ||
export * from './types'; | ||
export * from './schemas'; | ||
export * from './actions' | ||
export * from './wallet' | ||
export * as Context from './context' | ||
export * from './types' | ||
export * from './schemas' |
@@ -1,5 +0,5 @@ | ||
export * from './actions'; | ||
export * from './wallet'; | ||
export * as Context from './context'; | ||
export * from './types'; | ||
export * from './schemas'; | ||
export * from './actions' | ||
export * from './wallet' | ||
export * as Context from './context' | ||
export * from './types' | ||
export * from './schemas' |
type Compute<type> = { | ||
[key in keyof type]: type[key]; | ||
} & unknown; | ||
type KeyofUnion<type> = type extends type ? keyof type : never; | ||
export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Compute<item & { | ||
[key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined; | ||
}> : never; | ||
export {}; | ||
[key in keyof type]: type[key] | ||
} & unknown | ||
type KeyofUnion<type> = type extends type ? keyof type : never | ||
export type OneOf< | ||
union extends object, | ||
fallback extends object | undefined = undefined, | ||
keys extends KeyofUnion<union> = KeyofUnion<union>, | ||
> = union extends infer item | ||
? Compute< | ||
item & { | ||
[key in Exclude<keys, keyof item>]?: fallback extends object | ||
? key extends keyof fallback | ||
? fallback[key] | ||
: undefined | ||
: undefined | ||
} | ||
> | ||
: never |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
export {} |
@@ -1,243 +0,350 @@ | ||
import { z } from 'zod'; | ||
export declare const actionLaunchFrameSchema: z.ZodObject<{ | ||
type: z.ZodLiteral<"launch_frame">; | ||
name: z.ZodString; | ||
url: z.ZodString; | ||
splashImageUrl: z.ZodOptional<z.ZodString>; | ||
splashBackgroundColor: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}>; | ||
export declare const actionViewTokenSchema: z.ZodObject<{ | ||
type: z.ZodLiteral<"view_token">; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "view_token"; | ||
token: string; | ||
}, { | ||
type: "view_token"; | ||
token: string; | ||
}>; | ||
export declare const actionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ | ||
type: z.ZodLiteral<"launch_frame">; | ||
name: z.ZodString; | ||
url: z.ZodString; | ||
splashImageUrl: z.ZodOptional<z.ZodString>; | ||
splashBackgroundColor: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"view_token">; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "view_token"; | ||
token: string; | ||
}, { | ||
type: "view_token"; | ||
token: string; | ||
}>]>; | ||
export declare const buttonSchema: z.ZodObject<{ | ||
title: z.ZodString; | ||
action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ | ||
type: z.ZodLiteral<"launch_frame">; | ||
name: z.ZodString; | ||
url: z.ZodString; | ||
splashImageUrl: z.ZodOptional<z.ZodString>; | ||
splashBackgroundColor: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"view_token">; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "view_token"; | ||
token: string; | ||
}, { | ||
type: "view_token"; | ||
token: string; | ||
}>]>; | ||
}, "strip", z.ZodTypeAny, { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}, { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}>; | ||
export declare const frameEmbedNextSchema: z.ZodObject<{ | ||
version: z.ZodLiteral<"next">; | ||
imageUrl: z.ZodString; | ||
aspectRatio: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"1:1">, z.ZodLiteral<"3:2">]>>; | ||
button: z.ZodObject<{ | ||
title: z.ZodString; | ||
action: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ | ||
type: z.ZodLiteral<"launch_frame">; | ||
name: z.ZodString; | ||
url: z.ZodString; | ||
splashImageUrl: z.ZodOptional<z.ZodString>; | ||
splashBackgroundColor: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}, { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"view_token">; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "view_token"; | ||
token: string; | ||
}, { | ||
type: "view_token"; | ||
token: string; | ||
}>]>; | ||
}, "strip", z.ZodTypeAny, { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}, { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
version: "next"; | ||
imageUrl: string; | ||
import type { z } from 'zod' | ||
export declare const actionLaunchFrameSchema: z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'launch_frame'> | ||
name: z.ZodString | ||
url: z.ZodString | ||
splashImageUrl: z.ZodOptional<z.ZodString> | ||
splashBackgroundColor: z.ZodOptional<z.ZodString> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
}, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
> | ||
export declare const actionViewTokenSchema: z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'view_token'> | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
}, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
} | ||
> | ||
export declare const actionSchema: z.ZodDiscriminatedUnion< | ||
'type', | ||
[ | ||
z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'launch_frame'> | ||
name: z.ZodString | ||
url: z.ZodString | ||
splashImageUrl: z.ZodOptional<z.ZodString> | ||
splashBackgroundColor: z.ZodOptional<z.ZodString> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
}, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
>, | ||
z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'view_token'> | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
}, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
} | ||
>, | ||
] | ||
> | ||
export declare const buttonSchema: z.ZodObject< | ||
{ | ||
title: z.ZodString | ||
action: z.ZodDiscriminatedUnion< | ||
'type', | ||
[ | ||
z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'launch_frame'> | ||
name: z.ZodString | ||
url: z.ZodString | ||
splashImageUrl: z.ZodOptional<z.ZodString> | ||
splashBackgroundColor: z.ZodOptional<z.ZodString> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
}, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
>, | ||
z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'view_token'> | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
}, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
} | ||
>, | ||
] | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
}, | ||
{ | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
} | ||
> | ||
export declare const frameEmbedNextSchema: z.ZodObject< | ||
{ | ||
version: z.ZodLiteral<'next'> | ||
imageUrl: z.ZodString | ||
aspectRatio: z.ZodOptional< | ||
z.ZodUnion<[z.ZodLiteral<'1:1'>, z.ZodLiteral<'3:2'>]> | ||
> | ||
button: z.ZodObject< | ||
{ | ||
title: z.ZodString | ||
action: z.ZodDiscriminatedUnion< | ||
'type', | ||
[ | ||
z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'launch_frame'> | ||
name: z.ZodString | ||
url: z.ZodString | ||
splashImageUrl: z.ZodOptional<z.ZodString> | ||
splashBackgroundColor: z.ZodOptional<z.ZodString> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
}, | ||
{ | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
>, | ||
z.ZodObject< | ||
{ | ||
type: z.ZodLiteral<'view_token'> | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
}, | ||
{ | ||
type: 'view_token' | ||
token: string | ||
} | ||
>, | ||
] | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
}, | ||
{ | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
} | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
version: 'next' | ||
imageUrl: string | ||
button: { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}; | ||
aspectRatio?: "1:1" | "3:2" | undefined; | ||
}, { | ||
version: "next"; | ||
imageUrl: string; | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
} | ||
aspectRatio?: '1:1' | '3:2' | undefined | ||
}, | ||
{ | ||
version: 'next' | ||
imageUrl: string | ||
button: { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}; | ||
aspectRatio?: "1:1" | "3:2" | undefined; | ||
}>; | ||
export declare const safeParseFrameEmbed: (rawResponse: unknown) => z.SafeParseReturnType<{ | ||
version: "next"; | ||
imageUrl: string; | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
} | ||
aspectRatio?: '1:1' | '3:2' | undefined | ||
} | ||
> | ||
export declare const safeParseFrameEmbed: ( | ||
rawResponse: unknown, | ||
) => z.SafeParseReturnType< | ||
{ | ||
version: 'next' | ||
imageUrl: string | ||
button: { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}; | ||
aspectRatio?: "1:1" | "3:2" | undefined; | ||
}, { | ||
version: "next"; | ||
imageUrl: string; | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
} | ||
aspectRatio?: '1:1' | '3:2' | undefined | ||
}, | ||
{ | ||
version: 'next' | ||
imageUrl: string | ||
button: { | ||
title: string; | ||
action: { | ||
type: "launch_frame"; | ||
name: string; | ||
url: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
} | { | ||
type: "view_token"; | ||
token: string; | ||
}; | ||
}; | ||
aspectRatio?: "1:1" | "3:2" | undefined; | ||
}>; | ||
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema>; | ||
title: string | ||
action: | ||
| { | ||
type: 'launch_frame' | ||
name: string | ||
url: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
} | ||
| { | ||
type: 'view_token' | ||
token: string | ||
} | ||
} | ||
aspectRatio?: '1:1' | '3:2' | undefined | ||
} | ||
> | ||
export type FrameEmbedNext = z.infer<typeof frameEmbedNextSchema> |
@@ -1,28 +0,36 @@ | ||
import { z } from 'zod'; | ||
import { aspectRatioSchema, buttonTitleSchema, caip19TokenSchema, frameNameSchema, hexColorSchema, secureUrlSchema, } from './shared'; | ||
import { z } from 'zod' | ||
import { | ||
aspectRatioSchema, | ||
buttonTitleSchema, | ||
caip19TokenSchema, | ||
frameNameSchema, | ||
hexColorSchema, | ||
secureUrlSchema, | ||
} from './shared' | ||
export const actionLaunchFrameSchema = z.object({ | ||
type: z.literal('launch_frame'), | ||
name: frameNameSchema, | ||
url: secureUrlSchema, | ||
splashImageUrl: secureUrlSchema.optional(), | ||
splashBackgroundColor: hexColorSchema.optional(), | ||
}); | ||
type: z.literal('launch_frame'), | ||
name: frameNameSchema, | ||
url: secureUrlSchema, | ||
splashImageUrl: secureUrlSchema.optional(), | ||
splashBackgroundColor: hexColorSchema.optional(), | ||
}) | ||
export const actionViewTokenSchema = z.object({ | ||
type: z.literal('view_token'), | ||
token: caip19TokenSchema, | ||
}); | ||
type: z.literal('view_token'), | ||
token: caip19TokenSchema, | ||
}) | ||
export const actionSchema = z.discriminatedUnion('type', [ | ||
actionLaunchFrameSchema, | ||
actionViewTokenSchema, | ||
]); | ||
actionLaunchFrameSchema, | ||
actionViewTokenSchema, | ||
]) | ||
export const buttonSchema = z.object({ | ||
title: buttonTitleSchema, | ||
action: actionSchema, | ||
}); | ||
title: buttonTitleSchema, | ||
action: actionSchema, | ||
}) | ||
export const frameEmbedNextSchema = z.object({ | ||
version: z.literal('next'), | ||
imageUrl: secureUrlSchema, | ||
aspectRatio: aspectRatioSchema.optional(), | ||
button: buttonSchema, | ||
}); | ||
export const safeParseFrameEmbed = (rawResponse) => frameEmbedNextSchema.safeParse(rawResponse); | ||
version: z.literal('next'), | ||
imageUrl: secureUrlSchema, | ||
aspectRatio: aspectRatioSchema.optional(), | ||
button: buttonSchema, | ||
}) | ||
export const safeParseFrameEmbed = (rawResponse) => | ||
frameEmbedNextSchema.safeParse(rawResponse) |
@@ -1,131 +0,227 @@ | ||
import { z } from 'zod'; | ||
export declare const eventFrameAddedSchema: z.ZodObject<{ | ||
event: z.ZodLiteral<"frame_added">; | ||
notificationDetails: z.ZodOptional<z.ZodObject<{ | ||
url: z.ZodString; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
url: string; | ||
token: string; | ||
}, { | ||
url: string; | ||
token: string; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "frame_added"; | ||
notificationDetails?: { | ||
url: string; | ||
token: string; | ||
} | undefined; | ||
}, { | ||
event: "frame_added"; | ||
notificationDetails?: { | ||
url: string; | ||
token: string; | ||
} | undefined; | ||
}>; | ||
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>; | ||
export declare const eventFrameRemovedSchema: z.ZodObject<{ | ||
event: z.ZodLiteral<"frame_removed">; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "frame_removed"; | ||
}, { | ||
event: "frame_removed"; | ||
}>; | ||
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>; | ||
export declare const eventNotificationsEnabledSchema: z.ZodObject<{ | ||
event: z.ZodLiteral<"notifications_enabled">; | ||
notificationDetails: z.ZodObject<{ | ||
url: z.ZodString; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
url: string; | ||
token: string; | ||
}, { | ||
url: string; | ||
token: string; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "notifications_enabled"; | ||
import type { z } from 'zod' | ||
export declare const eventFrameAddedSchema: z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'frame_added'> | ||
notificationDetails: z.ZodOptional< | ||
z.ZodObject< | ||
{ | ||
url: z.ZodString | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
url: string | ||
token: string | ||
}, | ||
{ | ||
url: string | ||
token: string | ||
} | ||
> | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'frame_added' | ||
notificationDetails?: | ||
| { | ||
url: string | ||
token: string | ||
} | ||
| undefined | ||
}, | ||
{ | ||
event: 'frame_added' | ||
notificationDetails?: | ||
| { | ||
url: string | ||
token: string | ||
} | ||
| undefined | ||
} | ||
> | ||
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema> | ||
export declare const eventFrameRemovedSchema: z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'frame_removed'> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'frame_removed' | ||
}, | ||
{ | ||
event: 'frame_removed' | ||
} | ||
> | ||
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema> | ||
export declare const eventNotificationsEnabledSchema: z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'notifications_enabled'> | ||
notificationDetails: z.ZodObject< | ||
{ | ||
url: z.ZodString | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
url: string | ||
token: string | ||
}, | ||
{ | ||
url: string | ||
token: string | ||
} | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'notifications_enabled' | ||
notificationDetails: { | ||
url: string; | ||
token: string; | ||
}; | ||
}, { | ||
event: "notifications_enabled"; | ||
url: string | ||
token: string | ||
} | ||
}, | ||
{ | ||
event: 'notifications_enabled' | ||
notificationDetails: { | ||
url: string; | ||
token: string; | ||
}; | ||
}>; | ||
export type EventNotificationsEnabled = z.infer<typeof eventNotificationsEnabledSchema>; | ||
export declare const notificationsDisabledSchema: z.ZodObject<{ | ||
event: z.ZodLiteral<"notifications_disabled">; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "notifications_disabled"; | ||
}, { | ||
event: "notifications_disabled"; | ||
}>; | ||
export type EventNotificationsDisabled = z.infer<typeof notificationsDisabledSchema>; | ||
export declare const serverEventSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{ | ||
event: z.ZodLiteral<"frame_added">; | ||
notificationDetails: z.ZodOptional<z.ZodObject<{ | ||
url: z.ZodString; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
url: string; | ||
token: string; | ||
}, { | ||
url: string; | ||
token: string; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "frame_added"; | ||
notificationDetails?: { | ||
url: string; | ||
token: string; | ||
} | undefined; | ||
}, { | ||
event: "frame_added"; | ||
notificationDetails?: { | ||
url: string; | ||
token: string; | ||
} | undefined; | ||
}>, z.ZodObject<{ | ||
event: z.ZodLiteral<"frame_removed">; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "frame_removed"; | ||
}, { | ||
event: "frame_removed"; | ||
}>, z.ZodObject<{ | ||
event: z.ZodLiteral<"notifications_enabled">; | ||
notificationDetails: z.ZodObject<{ | ||
url: z.ZodString; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
url: string; | ||
token: string; | ||
}, { | ||
url: string; | ||
token: string; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "notifications_enabled"; | ||
notificationDetails: { | ||
url: string; | ||
token: string; | ||
}; | ||
}, { | ||
event: "notifications_enabled"; | ||
notificationDetails: { | ||
url: string; | ||
token: string; | ||
}; | ||
}>, z.ZodObject<{ | ||
event: z.ZodLiteral<"notifications_disabled">; | ||
}, "strip", z.ZodTypeAny, { | ||
event: "notifications_disabled"; | ||
}, { | ||
event: "notifications_disabled"; | ||
}>]>; | ||
export type FrameServerEvent = z.infer<typeof serverEventSchema>; | ||
url: string | ||
token: string | ||
} | ||
} | ||
> | ||
export type EventNotificationsEnabled = z.infer< | ||
typeof eventNotificationsEnabledSchema | ||
> | ||
export declare const notificationsDisabledSchema: z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'notifications_disabled'> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'notifications_disabled' | ||
}, | ||
{ | ||
event: 'notifications_disabled' | ||
} | ||
> | ||
export type EventNotificationsDisabled = z.infer< | ||
typeof notificationsDisabledSchema | ||
> | ||
export declare const serverEventSchema: z.ZodDiscriminatedUnion< | ||
'event', | ||
[ | ||
z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'frame_added'> | ||
notificationDetails: z.ZodOptional< | ||
z.ZodObject< | ||
{ | ||
url: z.ZodString | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
url: string | ||
token: string | ||
}, | ||
{ | ||
url: string | ||
token: string | ||
} | ||
> | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'frame_added' | ||
notificationDetails?: | ||
| { | ||
url: string | ||
token: string | ||
} | ||
| undefined | ||
}, | ||
{ | ||
event: 'frame_added' | ||
notificationDetails?: | ||
| { | ||
url: string | ||
token: string | ||
} | ||
| undefined | ||
} | ||
>, | ||
z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'frame_removed'> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'frame_removed' | ||
}, | ||
{ | ||
event: 'frame_removed' | ||
} | ||
>, | ||
z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'notifications_enabled'> | ||
notificationDetails: z.ZodObject< | ||
{ | ||
url: z.ZodString | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
url: string | ||
token: string | ||
}, | ||
{ | ||
url: string | ||
token: string | ||
} | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'notifications_enabled' | ||
notificationDetails: { | ||
url: string | ||
token: string | ||
} | ||
}, | ||
{ | ||
event: 'notifications_enabled' | ||
notificationDetails: { | ||
url: string | ||
token: string | ||
} | ||
} | ||
>, | ||
z.ZodObject< | ||
{ | ||
event: z.ZodLiteral<'notifications_disabled'> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
event: 'notifications_disabled' | ||
}, | ||
{ | ||
event: 'notifications_disabled' | ||
} | ||
>, | ||
] | ||
> | ||
export type FrameServerEvent = z.infer<typeof serverEventSchema> |
@@ -1,22 +0,22 @@ | ||
import { z } from 'zod'; | ||
import { notificationDetailsSchema } from './notifications'; | ||
import { z } from 'zod' | ||
import { notificationDetailsSchema } from './notifications' | ||
export const eventFrameAddedSchema = z.object({ | ||
event: z.literal('frame_added'), | ||
notificationDetails: notificationDetailsSchema.optional(), | ||
}); | ||
event: z.literal('frame_added'), | ||
notificationDetails: notificationDetailsSchema.optional(), | ||
}) | ||
export const eventFrameRemovedSchema = z.object({ | ||
event: z.literal('frame_removed'), | ||
}); | ||
event: z.literal('frame_removed'), | ||
}) | ||
export const eventNotificationsEnabledSchema = z.object({ | ||
event: z.literal('notifications_enabled'), | ||
notificationDetails: notificationDetailsSchema.required(), | ||
}); | ||
event: z.literal('notifications_enabled'), | ||
notificationDetails: notificationDetailsSchema.required(), | ||
}) | ||
export const notificationsDisabledSchema = z.object({ | ||
event: z.literal('notifications_disabled'), | ||
}); | ||
event: z.literal('notifications_disabled'), | ||
}) | ||
export const serverEventSchema = z.discriminatedUnion('event', [ | ||
eventFrameAddedSchema, | ||
eventFrameRemovedSchema, | ||
eventNotificationsEnabledSchema, | ||
notificationsDisabledSchema, | ||
]); | ||
eventFrameAddedSchema, | ||
eventFrameRemovedSchema, | ||
eventNotificationsEnabledSchema, | ||
notificationsDisabledSchema, | ||
]) |
@@ -1,5 +0,5 @@ | ||
export * from './embeds'; | ||
export * from './events'; | ||
export * from './shared'; | ||
export * from './manifest'; | ||
export * from './notifications'; | ||
export * from './embeds' | ||
export * from './events' | ||
export * from './shared' | ||
export * from './manifest' | ||
export * from './notifications' |
@@ -1,5 +0,5 @@ | ||
export * from './embeds'; | ||
export * from './events'; | ||
export * from './shared'; | ||
export * from './manifest'; | ||
export * from './notifications'; | ||
export * from './embeds' | ||
export * from './events' | ||
export * from './shared' | ||
export * from './manifest' | ||
export * from './notifications' |
@@ -1,112 +0,156 @@ | ||
import { z } from 'zod'; | ||
export declare const domainFrameConfigSchema: z.ZodObject<{ | ||
version: z.ZodUnion<[z.ZodLiteral<"0.0.0">, z.ZodLiteral<"0.0.1">, z.ZodLiteral<"1">, z.ZodLiteral<"next">]>; | ||
name: z.ZodString; | ||
iconUrl: z.ZodString; | ||
homeUrl: z.ZodString; | ||
imageUrl: z.ZodOptional<z.ZodString>; | ||
buttonTitle: z.ZodOptional<z.ZodString>; | ||
splashImageUrl: z.ZodOptional<z.ZodString>; | ||
splashBackgroundColor: z.ZodOptional<z.ZodString>; | ||
webhookUrl: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
version: "next" | "0.0.0" | "0.0.1" | "1"; | ||
iconUrl: string; | ||
homeUrl: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
imageUrl?: string | undefined; | ||
buttonTitle?: string | undefined; | ||
webhookUrl?: string | undefined; | ||
}, { | ||
name: string; | ||
version: "next" | "0.0.0" | "0.0.1" | "1"; | ||
iconUrl: string; | ||
homeUrl: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
imageUrl?: string | undefined; | ||
buttonTitle?: string | undefined; | ||
webhookUrl?: string | undefined; | ||
}>; | ||
export declare const domainManifestSchema: z.ZodObject<{ | ||
accountAssociation: z.ZodObject<{ | ||
header: z.ZodString; | ||
payload: z.ZodString; | ||
signature: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
header: string; | ||
payload: string; | ||
signature: string; | ||
}, { | ||
header: string; | ||
payload: string; | ||
signature: string; | ||
}>; | ||
frame: z.ZodOptional<z.ZodObject<{ | ||
version: z.ZodUnion<[z.ZodLiteral<"0.0.0">, z.ZodLiteral<"0.0.1">, z.ZodLiteral<"1">, z.ZodLiteral<"next">]>; | ||
name: z.ZodString; | ||
iconUrl: z.ZodString; | ||
homeUrl: z.ZodString; | ||
imageUrl: z.ZodOptional<z.ZodString>; | ||
buttonTitle: z.ZodOptional<z.ZodString>; | ||
splashImageUrl: z.ZodOptional<z.ZodString>; | ||
splashBackgroundColor: z.ZodOptional<z.ZodString>; | ||
webhookUrl: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
version: "next" | "0.0.0" | "0.0.1" | "1"; | ||
iconUrl: string; | ||
homeUrl: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
imageUrl?: string | undefined; | ||
buttonTitle?: string | undefined; | ||
webhookUrl?: string | undefined; | ||
}, { | ||
name: string; | ||
version: "next" | "0.0.0" | "0.0.1" | "1"; | ||
iconUrl: string; | ||
homeUrl: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
imageUrl?: string | undefined; | ||
buttonTitle?: string | undefined; | ||
webhookUrl?: string | undefined; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
import type { z } from 'zod' | ||
export declare const domainFrameConfigSchema: z.ZodObject< | ||
{ | ||
version: z.ZodUnion< | ||
[ | ||
z.ZodLiteral<'0.0.0'>, | ||
z.ZodLiteral<'0.0.1'>, | ||
z.ZodLiteral<'1'>, | ||
z.ZodLiteral<'next'>, | ||
] | ||
> | ||
name: z.ZodString | ||
iconUrl: z.ZodString | ||
homeUrl: z.ZodString | ||
imageUrl: z.ZodOptional<z.ZodString> | ||
buttonTitle: z.ZodOptional<z.ZodString> | ||
splashImageUrl: z.ZodOptional<z.ZodString> | ||
splashBackgroundColor: z.ZodOptional<z.ZodString> | ||
webhookUrl: z.ZodOptional<z.ZodString> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
name: string | ||
version: 'next' | '0.0.0' | '0.0.1' | '1' | ||
iconUrl: string | ||
homeUrl: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
imageUrl?: string | undefined | ||
buttonTitle?: string | undefined | ||
webhookUrl?: string | undefined | ||
}, | ||
{ | ||
name: string | ||
version: 'next' | '0.0.0' | '0.0.1' | '1' | ||
iconUrl: string | ||
homeUrl: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
imageUrl?: string | undefined | ||
buttonTitle?: string | undefined | ||
webhookUrl?: string | undefined | ||
} | ||
> | ||
export declare const domainManifestSchema: z.ZodObject< | ||
{ | ||
accountAssociation: z.ZodObject< | ||
{ | ||
header: z.ZodString | ||
payload: z.ZodString | ||
signature: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
header: string | ||
payload: string | ||
signature: string | ||
}, | ||
{ | ||
header: string | ||
payload: string | ||
signature: string | ||
} | ||
> | ||
frame: z.ZodOptional< | ||
z.ZodObject< | ||
{ | ||
version: z.ZodUnion< | ||
[ | ||
z.ZodLiteral<'0.0.0'>, | ||
z.ZodLiteral<'0.0.1'>, | ||
z.ZodLiteral<'1'>, | ||
z.ZodLiteral<'next'>, | ||
] | ||
> | ||
name: z.ZodString | ||
iconUrl: z.ZodString | ||
homeUrl: z.ZodString | ||
imageUrl: z.ZodOptional<z.ZodString> | ||
buttonTitle: z.ZodOptional<z.ZodString> | ||
splashImageUrl: z.ZodOptional<z.ZodString> | ||
splashBackgroundColor: z.ZodOptional<z.ZodString> | ||
webhookUrl: z.ZodOptional<z.ZodString> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
name: string | ||
version: 'next' | '0.0.0' | '0.0.1' | '1' | ||
iconUrl: string | ||
homeUrl: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
imageUrl?: string | undefined | ||
buttonTitle?: string | undefined | ||
webhookUrl?: string | undefined | ||
}, | ||
{ | ||
name: string | ||
version: 'next' | '0.0.0' | '0.0.1' | '1' | ||
iconUrl: string | ||
homeUrl: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
imageUrl?: string | undefined | ||
buttonTitle?: string | undefined | ||
webhookUrl?: string | undefined | ||
} | ||
> | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
accountAssociation: { | ||
header: string; | ||
payload: string; | ||
signature: string; | ||
}; | ||
frame?: { | ||
name: string; | ||
version: "next" | "0.0.0" | "0.0.1" | "1"; | ||
iconUrl: string; | ||
homeUrl: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
imageUrl?: string | undefined; | ||
buttonTitle?: string | undefined; | ||
webhookUrl?: string | undefined; | ||
} | undefined; | ||
}, { | ||
header: string | ||
payload: string | ||
signature: string | ||
} | ||
frame?: | ||
| { | ||
name: string | ||
version: 'next' | '0.0.0' | '0.0.1' | '1' | ||
iconUrl: string | ||
homeUrl: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
imageUrl?: string | undefined | ||
buttonTitle?: string | undefined | ||
webhookUrl?: string | undefined | ||
} | ||
| undefined | ||
}, | ||
{ | ||
accountAssociation: { | ||
header: string; | ||
payload: string; | ||
signature: string; | ||
}; | ||
frame?: { | ||
name: string; | ||
version: "next" | "0.0.0" | "0.0.1" | "1"; | ||
iconUrl: string; | ||
homeUrl: string; | ||
splashImageUrl?: string | undefined; | ||
splashBackgroundColor?: string | undefined; | ||
imageUrl?: string | undefined; | ||
buttonTitle?: string | undefined; | ||
webhookUrl?: string | undefined; | ||
} | undefined; | ||
}>; | ||
header: string | ||
payload: string | ||
signature: string | ||
} | ||
frame?: | ||
| { | ||
name: string | ||
version: 'next' | '0.0.0' | '0.0.1' | '1' | ||
iconUrl: string | ||
homeUrl: string | ||
splashImageUrl?: string | undefined | ||
splashBackgroundColor?: string | undefined | ||
imageUrl?: string | undefined | ||
buttonTitle?: string | undefined | ||
webhookUrl?: string | undefined | ||
} | ||
| undefined | ||
} | ||
> |
@@ -1,25 +0,31 @@ | ||
import { z } from 'zod'; | ||
import { buttonTitleSchema, encodedJsonFarcasterSignatureSchema, frameNameSchema, hexColorSchema, secureUrlSchema, } from './shared'; | ||
import { z } from 'zod' | ||
import { | ||
buttonTitleSchema, | ||
encodedJsonFarcasterSignatureSchema, | ||
frameNameSchema, | ||
hexColorSchema, | ||
secureUrlSchema, | ||
} from './shared' | ||
export const domainFrameConfigSchema = z.object({ | ||
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for | ||
// backwards compatibilty. next should always resolve to the most recent | ||
// schema version. | ||
version: z.union([ | ||
z.literal('0.0.0'), | ||
z.literal('0.0.1'), | ||
z.literal('1'), | ||
z.literal('next'), | ||
]), | ||
name: frameNameSchema, | ||
iconUrl: secureUrlSchema, | ||
homeUrl: secureUrlSchema, | ||
imageUrl: secureUrlSchema.optional(), | ||
buttonTitle: buttonTitleSchema.optional(), | ||
splashImageUrl: secureUrlSchema.optional(), | ||
splashBackgroundColor: hexColorSchema.optional(), | ||
webhookUrl: secureUrlSchema.optional(), | ||
}); | ||
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for | ||
// backwards compatibilty. next should always resolve to the most recent | ||
// schema version. | ||
version: z.union([ | ||
z.literal('0.0.0'), | ||
z.literal('0.0.1'), | ||
z.literal('1'), | ||
z.literal('next'), | ||
]), | ||
name: frameNameSchema, | ||
iconUrl: secureUrlSchema, | ||
homeUrl: secureUrlSchema, | ||
imageUrl: secureUrlSchema.optional(), | ||
buttonTitle: buttonTitleSchema.optional(), | ||
splashImageUrl: secureUrlSchema.optional(), | ||
splashBackgroundColor: hexColorSchema.optional(), | ||
webhookUrl: secureUrlSchema.optional(), | ||
}) | ||
export const domainManifestSchema = z.object({ | ||
accountAssociation: encodedJsonFarcasterSignatureSchema, | ||
frame: domainFrameConfigSchema.optional(), | ||
}); | ||
accountAssociation: encodedJsonFarcasterSignatureSchema, | ||
frame: domainFrameConfigSchema.optional(), | ||
}) |
@@ -1,60 +0,88 @@ | ||
import { z } from 'zod'; | ||
export declare const notificationDetailsSchema: z.ZodObject<{ | ||
url: z.ZodString; | ||
token: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
url: string; | ||
token: string; | ||
}, { | ||
url: string; | ||
token: string; | ||
}>; | ||
export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>; | ||
export declare const sendNotificationRequestSchema: z.ZodObject<{ | ||
notificationId: z.ZodString; | ||
title: z.ZodString; | ||
body: z.ZodString; | ||
targetUrl: z.ZodString; | ||
tokens: z.ZodArray<z.ZodString, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
title: string; | ||
notificationId: string; | ||
body: string; | ||
targetUrl: string; | ||
tokens: string[]; | ||
}, { | ||
title: string; | ||
notificationId: string; | ||
body: string; | ||
targetUrl: string; | ||
tokens: string[]; | ||
}>; | ||
export type SendNotificationRequest = z.infer<typeof sendNotificationRequestSchema>; | ||
export declare const sendNotificationResponseSchema: z.ZodObject<{ | ||
result: z.ZodObject<{ | ||
successfulTokens: z.ZodArray<z.ZodString, "many">; | ||
invalidTokens: z.ZodArray<z.ZodString, "many">; | ||
rateLimitedTokens: z.ZodArray<z.ZodString, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
successfulTokens: string[]; | ||
invalidTokens: string[]; | ||
rateLimitedTokens: string[]; | ||
}, { | ||
successfulTokens: string[]; | ||
invalidTokens: string[]; | ||
rateLimitedTokens: string[]; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
import type { z } from 'zod' | ||
export declare const notificationDetailsSchema: z.ZodObject< | ||
{ | ||
url: z.ZodString | ||
token: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
url: string | ||
token: string | ||
}, | ||
{ | ||
url: string | ||
token: string | ||
} | ||
> | ||
export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema> | ||
export declare const sendNotificationRequestSchema: z.ZodObject< | ||
{ | ||
notificationId: z.ZodString | ||
title: z.ZodString | ||
body: z.ZodString | ||
targetUrl: z.ZodString | ||
tokens: z.ZodArray<z.ZodString, 'many'> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
title: string | ||
notificationId: string | ||
body: string | ||
targetUrl: string | ||
tokens: string[] | ||
}, | ||
{ | ||
title: string | ||
notificationId: string | ||
body: string | ||
targetUrl: string | ||
tokens: string[] | ||
} | ||
> | ||
export type SendNotificationRequest = z.infer< | ||
typeof sendNotificationRequestSchema | ||
> | ||
export declare const sendNotificationResponseSchema: z.ZodObject< | ||
{ | ||
result: z.ZodObject< | ||
{ | ||
successfulTokens: z.ZodArray<z.ZodString, 'many'> | ||
invalidTokens: z.ZodArray<z.ZodString, 'many'> | ||
rateLimitedTokens: z.ZodArray<z.ZodString, 'many'> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
successfulTokens: string[] | ||
invalidTokens: string[] | ||
rateLimitedTokens: string[] | ||
}, | ||
{ | ||
successfulTokens: string[] | ||
invalidTokens: string[] | ||
rateLimitedTokens: string[] | ||
} | ||
> | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
result: { | ||
successfulTokens: string[]; | ||
invalidTokens: string[]; | ||
rateLimitedTokens: string[]; | ||
}; | ||
}, { | ||
successfulTokens: string[] | ||
invalidTokens: string[] | ||
rateLimitedTokens: string[] | ||
} | ||
}, | ||
{ | ||
result: { | ||
successfulTokens: string[]; | ||
invalidTokens: string[]; | ||
rateLimitedTokens: string[]; | ||
}; | ||
}>; | ||
export type SendNotificationResponse = z.infer<typeof sendNotificationResponseSchema>; | ||
successfulTokens: string[] | ||
invalidTokens: string[] | ||
rateLimitedTokens: string[] | ||
} | ||
} | ||
> | ||
export type SendNotificationResponse = z.infer< | ||
typeof sendNotificationResponseSchema | ||
> |
@@ -1,20 +0,20 @@ | ||
import { z } from 'zod'; | ||
import { secureUrlSchema } from './shared'; | ||
import { z } from 'zod' | ||
import { secureUrlSchema } from './shared' | ||
export const notificationDetailsSchema = z.object({ | ||
url: z.string(), | ||
token: z.string(), | ||
}); | ||
url: z.string(), | ||
token: z.string(), | ||
}) | ||
export const sendNotificationRequestSchema = z.object({ | ||
notificationId: z.string().max(128), | ||
title: z.string().max(32), | ||
body: z.string().max(128), | ||
targetUrl: secureUrlSchema, | ||
tokens: z.string().array().max(100), | ||
}); | ||
notificationId: z.string().max(128), | ||
title: z.string().max(32), | ||
body: z.string().max(128), | ||
targetUrl: secureUrlSchema, | ||
tokens: z.string().array().max(100), | ||
}) | ||
export const sendNotificationResponseSchema = z.object({ | ||
result: z.object({ | ||
successfulTokens: z.array(z.string()), | ||
invalidTokens: z.array(z.string()), | ||
rateLimitedTokens: z.array(z.string()), | ||
}), | ||
}); | ||
result: z.object({ | ||
successfulTokens: z.array(z.string()), | ||
invalidTokens: z.array(z.string()), | ||
rateLimitedTokens: z.array(z.string()), | ||
}), | ||
}) |
@@ -1,35 +0,53 @@ | ||
import { z } from 'zod'; | ||
export declare const secureUrlSchema: z.ZodString; | ||
export declare const frameNameSchema: z.ZodString; | ||
export declare const buttonTitleSchema: z.ZodString; | ||
export declare const caip19TokenSchema: z.ZodString; | ||
export declare const hexColorSchema: z.ZodString; | ||
export declare const aspectRatioSchema: z.ZodUnion<[z.ZodLiteral<"1:1">, z.ZodLiteral<"3:2">]>; | ||
export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject<{ | ||
header: z.ZodString; | ||
payload: z.ZodString; | ||
signature: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
header: string; | ||
payload: string; | ||
signature: string; | ||
}, { | ||
header: string; | ||
payload: string; | ||
signature: string; | ||
}>; | ||
export type EncodedJsonFarcasterSignatureSchema = z.infer<typeof encodedJsonFarcasterSignatureSchema>; | ||
export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject<{ | ||
fid: z.ZodNumber; | ||
type: z.ZodLiteral<"app_key">; | ||
key: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "app_key"; | ||
fid: number; | ||
key: string; | ||
}, { | ||
type: "app_key"; | ||
fid: number; | ||
key: string; | ||
}>; | ||
export type JsonFarcasterSignatureHeaderSchema = z.infer<typeof jsonFarcasterSignatureHeaderSchema>; | ||
import type { z } from 'zod' | ||
export declare const secureUrlSchema: z.ZodString | ||
export declare const frameNameSchema: z.ZodString | ||
export declare const buttonTitleSchema: z.ZodString | ||
export declare const caip19TokenSchema: z.ZodString | ||
export declare const hexColorSchema: z.ZodString | ||
export declare const aspectRatioSchema: z.ZodUnion< | ||
[z.ZodLiteral<'1:1'>, z.ZodLiteral<'3:2'>] | ||
> | ||
export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject< | ||
{ | ||
header: z.ZodString | ||
payload: z.ZodString | ||
signature: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
header: string | ||
payload: string | ||
signature: string | ||
}, | ||
{ | ||
header: string | ||
payload: string | ||
signature: string | ||
} | ||
> | ||
export type EncodedJsonFarcasterSignatureSchema = z.infer< | ||
typeof encodedJsonFarcasterSignatureSchema | ||
> | ||
export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject< | ||
{ | ||
fid: z.ZodNumber | ||
type: z.ZodLiteral<'app_key'> | ||
key: z.ZodString | ||
}, | ||
'strip', | ||
z.ZodTypeAny, | ||
{ | ||
type: 'app_key' | ||
fid: number | ||
key: string | ||
}, | ||
{ | ||
type: 'app_key' | ||
fid: number | ||
key: string | ||
} | ||
> | ||
export type JsonFarcasterSignatureHeaderSchema = z.infer< | ||
typeof jsonFarcasterSignatureHeaderSchema | ||
> |
@@ -1,28 +0,30 @@ | ||
import { z } from 'zod'; | ||
import { z } from 'zod' | ||
export const secureUrlSchema = z | ||
.string() | ||
.url() | ||
.startsWith('https://', { message: 'Must be an https url' }) | ||
.max(512); | ||
export const frameNameSchema = z.string().max(32); | ||
export const buttonTitleSchema = z.string().max(32); | ||
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)$/; | ||
.string() | ||
.url() | ||
.startsWith('https://', { message: 'Must be an https url' }) | ||
.max(512) | ||
export const frameNameSchema = z.string().max(32) | ||
export const buttonTitleSchema = z.string().max(32) | ||
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)$/ | ||
export const caip19TokenSchema = z | ||
.string() | ||
.regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' }); | ||
.string() | ||
.regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' }) | ||
export const hexColorSchema = z | ||
.string() | ||
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, { | ||
message: 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.', | ||
}); | ||
export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')]); | ||
.string() | ||
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, { | ||
message: | ||
'Invalid hex color code. It should be in the format #RRGGBB or #RGB.', | ||
}) | ||
export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')]) | ||
export const encodedJsonFarcasterSignatureSchema = z.object({ | ||
header: z.string(), | ||
payload: z.string(), | ||
signature: z.string(), | ||
}); | ||
header: z.string(), | ||
payload: z.string(), | ||
signature: z.string(), | ||
}) | ||
export const jsonFarcasterSignatureHeaderSchema = z.object({ | ||
fid: z.number(), | ||
type: z.literal('app_key'), | ||
key: z.string().startsWith('0x'), | ||
}); | ||
fid: z.number(), | ||
type: z.literal('app_key'), | ||
key: z.string().startsWith('0x'), | ||
}) |
@@ -1,56 +0,75 @@ | ||
import type { AddFrame, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions'; | ||
import type { FrameContext } from './context'; | ||
import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas'; | ||
import type { Ethereum } from './wallet'; | ||
import type { | ||
AddFrame, | ||
Ready, | ||
SignIn, | ||
Swap, | ||
ViewProfile, | ||
ViewToken, | ||
} from './actions' | ||
import type { FrameContext } from './context' | ||
import type { | ||
EventFrameAdded, | ||
EventFrameRemoved, | ||
EventNotificationsDisabled, | ||
EventNotificationsEnabled, | ||
} from './schemas' | ||
import type { Ethereum } from './wallet' | ||
export type SetPrimaryButtonOptions = { | ||
text: string; | ||
loading?: boolean; | ||
disabled?: boolean; | ||
hidden?: boolean; | ||
}; | ||
export * from './wallet/ethereum'; | ||
export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready'; | ||
export type SignInOptions = SignIn.SignInOptions; | ||
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void; | ||
text: string | ||
loading?: boolean | ||
disabled?: boolean | ||
hidden?: boolean | ||
} | ||
export * from './wallet/ethereum' | ||
export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready' | ||
export type SignInOptions = SignIn.SignInOptions | ||
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void | ||
export type WireFrameHost = { | ||
context: FrameContext; | ||
close: () => void; | ||
ready: Ready.Ready; | ||
openUrl: (url: string) => void; | ||
signIn: SignIn.WireSignIn; | ||
setPrimaryButton: SetPrimaryButton; | ||
ethProviderRequest: Ethereum.EthProvideRequest; | ||
ethProviderRequestV2: Ethereum.RpcTransport; | ||
eip6963RequestProvider: () => void; | ||
addFrame: AddFrame.WireAddFrame; | ||
viewProfile: ViewProfile.ViewProfile; | ||
viewToken: ViewToken.ViewToken; | ||
swap: Swap.Swap; | ||
}; | ||
context: FrameContext | ||
close: () => void | ||
ready: Ready.Ready | ||
openUrl: (url: string) => void | ||
signIn: SignIn.WireSignIn | ||
setPrimaryButton: SetPrimaryButton | ||
ethProviderRequest: Ethereum.EthProvideRequest | ||
ethProviderRequestV2: Ethereum.RpcTransport | ||
eip6963RequestProvider: () => void | ||
addFrame: AddFrame.WireAddFrame | ||
viewProfile: ViewProfile.ViewProfile | ||
viewToken: ViewToken.ViewToken | ||
swap: Swap.Swap | ||
} | ||
export type FrameHost = { | ||
context: FrameContext; | ||
close: () => void; | ||
ready: Ready.Ready; | ||
openUrl: (url: string) => void; | ||
signIn: SignIn.SignIn; | ||
setPrimaryButton: SetPrimaryButton; | ||
ethProviderRequest: Ethereum.EthProvideRequest; | ||
ethProviderRequestV2: Ethereum.RpcTransport; | ||
/** | ||
* Receive forwarded eip6963:requestProvider events from the frame document. | ||
* Hosts must emit an EventEip6963AnnounceProvider in response. | ||
*/ | ||
eip6963RequestProvider: () => void; | ||
addFrame: AddFrame.AddFrame; | ||
viewProfile: ViewProfile.ViewProfile; | ||
viewToken: ViewToken.ViewToken; | ||
swap: Swap.Swap; | ||
}; | ||
context: FrameContext | ||
close: () => void | ||
ready: Ready.Ready | ||
openUrl: (url: string) => void | ||
signIn: SignIn.SignIn | ||
setPrimaryButton: SetPrimaryButton | ||
ethProviderRequest: Ethereum.EthProvideRequest | ||
ethProviderRequestV2: Ethereum.RpcTransport | ||
/** | ||
* Receive forwarded eip6963:requestProvider events from the frame document. | ||
* Hosts must emit an EventEip6963AnnounceProvider in response. | ||
*/ | ||
eip6963RequestProvider: () => void | ||
addFrame: AddFrame.AddFrame | ||
viewProfile: ViewProfile.ViewProfile | ||
viewToken: ViewToken.ViewToken | ||
swap: Swap.Swap | ||
} | ||
export type EventFrameAddRejected = { | ||
event: 'frame_add_rejected'; | ||
reason: AddFrame.AddFrameRejectedReason; | ||
}; | ||
event: 'frame_add_rejected' | ||
reason: AddFrame.AddFrameRejectedReason | ||
} | ||
export type EventPrimaryButtonClicked = { | ||
event: 'primary_button_clicked'; | ||
}; | ||
export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | Ethereum.EventEip6963AnnounceProvider; | ||
event: 'primary_button_clicked' | ||
} | ||
export type FrameClientEvent = | ||
| EventFrameAdded | ||
| EventFrameAddRejected | ||
| EventFrameRemoved | ||
| EventNotificationsEnabled | ||
| EventNotificationsDisabled | ||
| EventPrimaryButtonClicked | ||
| Ethereum.EventEip6963AnnounceProvider |
// start backwards compat, remove in 1.0 | ||
export * from './wallet/ethereum'; | ||
export { DEFAULT_READY_OPTIONS } from './actions/Ready'; | ||
export * from './wallet/ethereum' | ||
export { DEFAULT_READY_OPTIONS } from './actions/Ready' |
@@ -1,31 +0,46 @@ | ||
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'; | ||
export type EthProvideRequest<schema extends RpcSchema.Generic = RpcSchema.Default> = Provider.RequestFn<schema>; | ||
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox' | ||
export type EthProvideRequest< | ||
schema extends RpcSchema.Generic = RpcSchema.Default, | ||
> = Provider.RequestFn<schema> | ||
export type FrameEthProviderEventData = { | ||
type: 'frame_eth_provider_event'; | ||
} & EthProviderWireEvent; | ||
export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>; | ||
type: 'frame_eth_provider_event' | ||
} & EthProviderWireEvent | ||
export type RpcTransport = ( | ||
request: RpcRequest.RpcRequest, | ||
) => Promise<RpcResponse.RpcResponse> | ||
export type ProviderRpcError = { | ||
code: number; | ||
details?: string; | ||
message?: string; | ||
}; | ||
export type EthProviderWireEvent = { | ||
event: 'accountsChanged'; | ||
params: [readonly Address.Address[]]; | ||
} | { | ||
event: 'chainChanged'; | ||
params: [string]; | ||
} | { | ||
event: 'connect'; | ||
params: [Provider.ConnectInfo]; | ||
} | { | ||
event: 'disconnect'; | ||
params: [ProviderRpcError]; | ||
} | { | ||
event: 'message'; | ||
params: [Provider.Message]; | ||
}; | ||
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, { | ||
event: event; | ||
}>['params']) => void; | ||
code: number | ||
details?: string | ||
message?: string | ||
} | ||
export type EthProviderWireEvent = | ||
| { | ||
event: 'accountsChanged' | ||
params: [readonly Address.Address[]] | ||
} | ||
| { | ||
event: 'chainChanged' | ||
params: [string] | ||
} | ||
| { | ||
event: 'connect' | ||
params: [Provider.ConnectInfo] | ||
} | ||
| { | ||
event: 'disconnect' | ||
params: [ProviderRpcError] | ||
} | ||
| { | ||
event: 'message' | ||
params: [Provider.Message] | ||
} | ||
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>( | ||
event: event, | ||
params: Extract< | ||
EthProviderWireEvent, | ||
{ | ||
event: event | ||
} | ||
>['params'], | ||
) => void | ||
/** | ||
@@ -35,10 +50,10 @@ * Metadata of the EIP-1193 Provider. | ||
export interface EIP6963ProviderInfo { | ||
icon: `data:image/${string}`; | ||
name: string; | ||
rdns: string; | ||
uuid: string; | ||
icon: `data:image/${string}` | ||
name: string | ||
rdns: string | ||
uuid: string | ||
} | ||
export type EventEip6963AnnounceProvider = { | ||
event: 'eip6963:announceProvider'; | ||
info: EIP6963ProviderInfo; | ||
}; | ||
event: 'eip6963:announceProvider' | ||
info: EIP6963ProviderInfo | ||
} |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
export {} |
@@ -1,1 +0,1 @@ | ||
export * as Ethereum from './ethereum'; | ||
export * as Ethereum from './ethereum' |
@@ -1,1 +0,1 @@ | ||
export * as Ethereum from './ethereum'; | ||
export * as Ethereum from './ethereum' |
{ | ||
"name": "@farcaster/frame-core", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/farcasterxyz/frames.git", | ||
"directory": "packages/frame-core" | ||
}, | ||
"main": "dist/index.js", | ||
@@ -5,0 +11,0 @@ "module": "esm/index.js", |
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
188266
1.58%103
0.98%0
-100%3421
12.02%0
-100%