Comparing version 0.0.1-main.20240220T200704 to 0.0.1-main.20240220T205912
@@ -202,2 +202,3 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "../jsx/jsx-runtime"; | ||
postUrl: target ?? frame.postUrl, | ||
state: frame.state, | ||
} | ||
@@ -217,2 +218,3 @@ postFrameRedirect(body) | ||
postUrl: target ?? frame.postUrl, | ||
state: frame.state, | ||
} | ||
@@ -233,3 +235,3 @@ postFrameAction(body) | ||
function Data() { | ||
return (_jsx("div", { class: "bg-background-100 border rounded-md overflow-hidden divide-y", style: { height: 'min-content' }, "x-data": "{\n get rows() {\n return [\n { property: 'fc:frame', value: frame.version, status: 'valid' },\n { property: 'fc:frame:image', value: frame.imageUrl, status: 'valid' },\n { property: 'fc:frame:aspect_ratio', value: frame.imageAspectRatio, status: 'valid' },\n { property: 'fc:frame:post_url', value: frame.postUrl, status: frame.debug.postUrlTooLong ? 'error' : 'valid' },\n { property: 'og:image', value: frame.image || 'Not Provided', status: frame.image ? 'valid' : 'error' },\n { property: 'og:title', value: frame.title || 'Not Provided', status: frame.title ? 'valid' : 'error' },\n ...(frame.input?.text ? [{ property: 'fc:frame:input:text', value: frame.input.text, status: frame.debug.inputTextTooLong ? 'error' : 'valid' }] : []),\n ...(frame.buttons.map(button => ({\n property: `fc:frame:button:${button.index}`,\n value: `\n <span>${button.title}</span>${button.type ? `, <span>${button.type}</span>` : ''}${button.target ? `, <span>${button.target}</span>` : ''}\n `,\n status: 'valid',\n }))),\n ]\n },\n }", children: _jsx("template", { "x-for": "(row, index) in rows", children: _jsxs("div", { class: "items-center flex flex-row", style: { fontSize: '0.8125rem' }, children: [_jsx("div", { class: "text-gray-700 p-3 font-medium", "x-text": "row.property", style: { minWidth: '10rem' } }), _jsx("div", { class: "text-gray-1000 p-3 text-ellipsis overflow-hidden whitespace-nowrap", "x-html": "row.value" }), _jsxs("div", { class: "flex p-3", style: { justifyContent: 'flex-end', flex: '1' }, children: [_jsx("template", { "x-if": "row.status === 'valid'", children: _jsx("span", { class: "text-green-600", children: checkCircledIcon }) }), _jsx("template", { "x-if": "row.status === 'error'", children: _jsx("span", { class: "text-red-600", children: crossCircledIcon }) })] })] }) }) })); | ||
return (_jsx("div", { class: "bg-background-100 border rounded-md overflow-hidden divide-y", style: { height: 'min-content' }, "x-data": "{\n get rows() {\n return [\n { property: 'fc:frame', value: frame.version, status: 'valid' },\n { property: 'fc:frame:image', value: frame.imageUrl, status: 'valid' },\n { property: 'fc:frame:aspect_ratio', value: frame.imageAspectRatio, status: 'valid' },\n { property: 'fc:frame:post_url', value: frame.postUrl, status: frame.debug.postUrlTooLong ? 'error' : 'valid' },\n { property: 'fc:frame:state', value: frame.state, status: frame.debug.stateTooLong ? 'error' : 'valid' },\n { property: 'og:image', value: frame.image || 'Not Provided', status: frame.image ? 'valid' : 'error' },\n { property: 'og:title', value: frame.title || 'Not Provided', status: frame.title ? 'valid' : 'error' },\n ...(frame.input?.text ? [{ property: 'fc:frame:input:text', value: frame.input.text, status: frame.debug.inputTextTooLong ? 'error' : 'valid' }] : []),\n ...(frame.buttons.map(button => ({\n property: `fc:frame:button:${button.index}`,\n value: `\n <span>${button.title}</span>${button.type ? `, <span>${button.type}</span>` : ''}${button.target ? `, <span>${button.target}</span>` : ''}\n `,\n status: 'valid',\n }))),\n ]\n },\n }", children: _jsx("template", { "x-for": "(row, index) in rows", children: _jsxs("div", { class: "items-center flex flex-row", style: { fontSize: '0.8125rem' }, children: [_jsx("div", { class: "text-gray-700 p-3 font-medium", "x-text": "row.property", style: { minWidth: '10rem' } }), _jsx("div", { class: "text-gray-1000 p-3 text-ellipsis overflow-hidden whitespace-nowrap", "x-html": "row.value" }), _jsxs("div", { class: "flex p-3", style: { justifyContent: 'flex-end', flex: '1' }, children: [_jsx("template", { "x-if": "row.status === 'valid'", children: _jsx("span", { class: "text-green-600", children: checkCircledIcon }) }), _jsx("template", { "x-if": "row.status === 'error'", children: _jsx("span", { class: "text-red-600", children: crossCircledIcon }) })] })] }) }) })); | ||
} | ||
@@ -236,0 +238,0 @@ function Metrics() { |
@@ -98,3 +98,3 @@ import { jsxs as _jsxs, jsx as _jsx } from "../jsx/jsx-runtime"; | ||
const json = c.req.valid('json'); | ||
const { buttonIndex, castId, fid, inputText, postUrl } = json; | ||
const { buttonIndex, castId, fid, inputText, postUrl, state } = json; | ||
const { response, speed } = await fetchFrame({ | ||
@@ -107,2 +107,3 @@ baseUrl, | ||
postUrl, | ||
state, | ||
}); | ||
@@ -113,4 +114,4 @@ const response2 = response.clone(); | ||
const frame = htmlToFrame(text); | ||
const state = htmlToState(text); | ||
const contextHtml = await getCodeHtml(JSON.stringify(state.context, null, 2), 'json'); | ||
const state_ = htmlToState(text); | ||
const contextHtml = await getCodeHtml(JSON.stringify(state_.context, null, 2), 'json'); | ||
const routes = getRoutes(baseUrl, inspectRoutes(app.hono)); | ||
@@ -143,3 +144,3 @@ const imageSize = await getImageSize(frame.imageUrl); | ||
routes, | ||
state, | ||
state: state_, | ||
}); | ||
@@ -150,3 +151,3 @@ }) | ||
const json = c.req.valid('json'); | ||
const { buttonIndex, castId, fid, inputText, postUrl } = json; | ||
const { buttonIndex, castId, fid, inputText, postUrl, state } = json; | ||
const { response, speed } = await fetchFrame({ | ||
@@ -159,2 +160,3 @@ baseUrl, | ||
postUrl, | ||
state, | ||
}); | ||
@@ -161,0 +163,0 @@ return c.json({ |
@@ -22,2 +22,3 @@ import { type FrameImageAspectRatio, type FrameVersion, type Pretty } from '../types.js'; | ||
postUrlTooLong: boolean; | ||
stateTooLong: boolean; | ||
valid: boolean; | ||
@@ -41,4 +42,4 @@ }>; | ||
}; | ||
export type FrameMetaTagPropertyName = 'fc:frame' | 'fc:frame:image' | 'fc:frame:image:aspect_ratio' | 'fc:frame:input:text' | 'fc:frame:post_url' | 'og:image' | 'og:title' | `fc:frame:button:${FrameButton['index']}:action` | `fc:frame:button:${FrameButton['index']}:target` | `fc:frame:button:${FrameButton['index']}`; | ||
export type FrameMetaTagPropertyName = 'fc:frame' | 'fc:frame:image' | 'fc:frame:image:aspect_ratio' | 'fc:frame:input:text' | 'fc:frame:post_url' | 'fc:frame:state' | 'og:image' | 'og:title' | `fc:frame:button:${FrameButton['index']}:action` | `fc:frame:button:${FrameButton['index']}:target` | `fc:frame:button:${FrameButton['index']}`; | ||
export type FarcMetaTagPropertyName = 'farc:context' | 'farc:prev_context'; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -14,2 +14,3 @@ import { type Context } from 'hono'; | ||
postUrl: string; | ||
state: string; | ||
title: string; | ||
@@ -38,2 +39,3 @@ version: "vNext"; | ||
postUrlTooLong: boolean; | ||
stateTooLong: boolean; | ||
valid: boolean; | ||
@@ -47,2 +49,3 @@ buttons: FrameButton[]; | ||
postUrl: string; | ||
state: string; | ||
version: "vNext"; | ||
@@ -58,2 +61,3 @@ }; | ||
postUrl: string; | ||
state: string; | ||
version: "vNext"; | ||
@@ -73,4 +77,5 @@ }; | ||
postUrl: string; | ||
state: string | undefined; | ||
}; | ||
export declare function fetchFrame({ baseUrl, buttonIndex, castId, fid, inputText, postUrl, }: { | ||
export declare function fetchFrame({ baseUrl, buttonIndex, castId, fid, inputText, postUrl, state, }: { | ||
baseUrl: string; | ||
@@ -85,2 +90,3 @@ buttonIndex: number; | ||
postUrl: string; | ||
state: string | undefined; | ||
}): Promise<{ | ||
@@ -87,0 +93,0 @@ response: Response; |
@@ -25,2 +25,3 @@ import { Message } from '@farcaster/core'; | ||
'fc:frame:post_url', | ||
'fc:frame:state', | ||
'og:image', | ||
@@ -46,2 +47,3 @@ 'og:title', | ||
const postUrl = properties['fc:frame:post_url'] ?? ''; | ||
const state = properties['fc:frame:state'] ?? ''; | ||
const title = properties['og:title'] ?? ''; | ||
@@ -55,2 +57,3 @@ const version = properties['fc:frame'] ?? 'vNext'; | ||
postUrl, | ||
state, | ||
title, | ||
@@ -150,2 +153,3 @@ version, | ||
: false; | ||
const stateTooLong = properties.state.length > 4096; | ||
const { buttonsAreOutOfOrder, invalidButtons } = validateButtons(buttons); | ||
@@ -156,2 +160,3 @@ // TODO: Figure out how this is determined | ||
inputTextTooLong || | ||
stateTooLong || | ||
Boolean(invalidButtons.length)); | ||
@@ -164,2 +169,3 @@ const frame = { | ||
postUrl: properties.postUrl, | ||
state: properties.state, | ||
version: properties.version, | ||
@@ -178,2 +184,3 @@ }; | ||
postUrlTooLong, | ||
stateTooLong, | ||
valid, | ||
@@ -246,2 +253,3 @@ }, | ||
const inputText = value.inputText; | ||
const state = value.state; | ||
// TODO: Make dynamic | ||
@@ -253,5 +261,5 @@ const fid = 2; | ||
}; | ||
return { buttonIndex, castId, fid, inputText, postUrl }; | ||
return { buttonIndex, castId, fid, inputText, postUrl, state }; | ||
} | ||
export async function fetchFrame({ baseUrl, buttonIndex, castId, fid, inputText, postUrl, }) { | ||
export async function fetchFrame({ baseUrl, buttonIndex, castId, fid, inputText, postUrl, state, }) { | ||
const privateKeyBytes = ed25519.utils.randomPrivateKey(); | ||
@@ -324,2 +332,3 @@ // const publicKeyBytes = await ed.getPublicKeyAsync(privateKeyBytes) | ||
network: 1, | ||
state, | ||
timestamp: message.data?.timestamp, | ||
@@ -326,0 +335,0 @@ url: baseUrl, |
@@ -169,3 +169,3 @@ import { jsx as _jsx, jsxs as _jsxs } from "./jsx/jsx-runtime"; | ||
// We need to pass some context to the next frame to derive button values, state, etc. | ||
const nextFrameParams = toSearchParams({ | ||
const nextFrameState = serializeJson({ | ||
initialUrl: context.initialUrl, | ||
@@ -175,7 +175,7 @@ previousIntentData: intentData, | ||
}); | ||
return c.render(_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { property: "fc:frame", content: "vNext" }), _jsx("meta", { property: "fc:frame:image", content: `${parsePath(context.url)}/image?${frameImageParams.toString()}` }), _jsx("meta", { property: "fc:frame:image:aspect_ratio", content: imageAspectRatio ?? '1.91:1' }), _jsx("meta", { property: "og:image", content: `${parsePath(context.url)}/image?${frameImageParams.toString()}` }), _jsx("meta", { property: "fc:frame:post_url", content: `${action | ||
return c.render(_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { property: "fc:frame", content: "vNext" }), _jsx("meta", { property: "fc:frame:image", content: `${parsePath(context.url)}/image?${frameImageParams.toString()}` }), _jsx("meta", { property: "fc:frame:image:aspect_ratio", content: imageAspectRatio ?? '1.91:1' }), _jsx("meta", { property: "og:image", content: `${parsePath(context.url)}/image?${frameImageParams.toString()}` }), _jsx("meta", { property: "fc:frame:post_url", content: action | ||
? url.origin + | ||
parsePath(this.basePath) + | ||
parsePath(action || '') | ||
: context.url}?${nextFrameParams}` }), parsedIntents, _jsx("meta", { property: "farc:context", content: serializeJson(context) })] }), _jsx("body", { style: { | ||
: context.url }), _jsx("meta", { property: "fc:frame:state", content: nextFrameState }), parsedIntents, _jsx("meta", { property: "farc:context", content: serializeJson(context) })] }), _jsx("body", { style: { | ||
alignItems: 'center', | ||
@@ -182,0 +182,0 @@ display: 'flex', |
@@ -64,2 +64,3 @@ import { type Context, type Env } from 'hono'; | ||
network: number; | ||
state?: string | undefined; | ||
timestamp: number; | ||
@@ -66,0 +67,0 @@ url: string; |
import {} from 'hono'; | ||
import {} from '../types.js'; | ||
import { fromQuery } from './fromQuery.js'; | ||
import { deserializeJson } from './deserializeJson.js'; | ||
import { parsePath } from './parsePath.js'; | ||
@@ -8,3 +8,5 @@ import { verifyFrame } from './verifyFrame.js'; | ||
const { trustedData, untrustedData } = (await request.json().catch(() => { })) || {}; | ||
const { initialUrl, previousState, previousIntentData } = fromQuery(request.query()); | ||
const { initialUrl, previousState, previousIntentData } = untrustedData?.state | ||
? deserializeJson(untrustedData.state) | ||
: {}; | ||
const message = await (() => { | ||
@@ -11,0 +13,0 @@ if (!verify) |
@@ -31,2 +31,3 @@ // TODO: TSDoc | ||
postUrlTooLong: boolean | ||
stateTooLong: boolean | ||
valid: boolean | ||
@@ -62,2 +63,3 @@ } | ||
| 'fc:frame:post_url' | ||
| 'fc:frame:state' | ||
| 'og:image' | ||
@@ -64,0 +66,0 @@ | 'og:title' |
@@ -43,2 +43,3 @@ import { Message } from '@farcaster/core' | ||
'fc:frame:post_url', | ||
'fc:frame:state', | ||
'og:image', | ||
@@ -69,2 +70,3 @@ 'og:title', | ||
const postUrl = properties['fc:frame:post_url'] ?? '' | ||
const state = properties['fc:frame:state'] ?? '' | ||
const title = properties['og:title'] ?? '' | ||
@@ -79,2 +81,3 @@ const version = (properties['fc:frame'] as FrameVersion) ?? 'vNext' | ||
postUrl, | ||
state, | ||
title, | ||
@@ -200,2 +203,3 @@ version, | ||
: false | ||
const stateTooLong = properties.state.length > 4096 | ||
@@ -209,2 +213,3 @@ const { buttonsAreOutOfOrder, invalidButtons } = validateButtons(buttons) | ||
inputTextTooLong || | ||
stateTooLong || | ||
Boolean(invalidButtons.length) | ||
@@ -219,2 +224,3 @@ ) | ||
postUrl: properties.postUrl, | ||
state: properties.state, | ||
version: properties.version, | ||
@@ -234,2 +240,3 @@ } | ||
postUrlTooLong, | ||
stateTooLong, | ||
valid, | ||
@@ -312,2 +319,4 @@ }, | ||
const state = value.state as string | undefined | ||
// TODO: Make dynamic | ||
@@ -322,3 +331,3 @@ const fid = 2 | ||
return { buttonIndex, castId, fid, inputText, postUrl } | ||
return { buttonIndex, castId, fid, inputText, postUrl, state } | ||
} | ||
@@ -333,2 +342,3 @@ | ||
postUrl, | ||
state, | ||
}: { | ||
@@ -344,2 +354,3 @@ baseUrl: string | ||
postUrl: string | ||
state: string | undefined | ||
}) { | ||
@@ -423,2 +434,3 @@ const privateKeyBytes = ed25519.utils.randomPrivateKey() | ||
network: 1, | ||
state, | ||
timestamp: message.data?.timestamp, | ||
@@ -425,0 +437,0 @@ url: baseUrl, |
{ | ||
"name": "farc", | ||
"version": "0.0.1-main.20240220T200704", | ||
"version": "0.0.1-main.20240220T205912", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "module": "_lib/index.js", |
@@ -63,2 +63,3 @@ import { type Context, type Env } from 'hono' | ||
network: number | ||
state?: string | undefined | ||
timestamp: number | ||
@@ -65,0 +66,0 @@ url: string |
import { type Context } from 'hono' | ||
import { type FrameContext } from '../types.js' | ||
import { fromQuery } from './fromQuery.js' | ||
import { deserializeJson } from './deserializeJson.js' | ||
import { parsePath } from './parsePath.js' | ||
@@ -29,5 +29,5 @@ import { verifyFrame } from './verifyFrame.js' | ||
(await request.json().catch(() => {})) || {} | ||
const { initialUrl, previousState, previousIntentData } = fromQuery< | ||
FrameContext<string, state> | ||
>(request.query()) | ||
const { initialUrl, previousState, previousIntentData } = untrustedData?.state | ||
? deserializeJson(untrustedData.state) | ||
: ({} as any) | ||
@@ -34,0 +34,0 @@ const message = await (() => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
568658
6752