@farcaster/snap 1.17.1 → 1.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/catalog.d.ts +5 -1
- package/dist/ui/schema.d.ts +5 -1
- package/dist/ui/schema.js +1 -1
- package/dist/validator.js +5 -0
- package/package.json +1 -1
- package/src/ui/schema.ts +1 -1
- package/src/validator.ts +6 -0
package/dist/ui/catalog.d.ts
CHANGED
|
@@ -10,7 +10,11 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
10
10
|
root: import("@json-render/core").SchemaType<"string", unknown>;
|
|
11
11
|
elements: import("@json-render/core").SchemaType<"record", import("@json-render/core").SchemaType<"object", {
|
|
12
12
|
type: import("@json-render/core").SchemaType<"ref", string>;
|
|
13
|
-
props:
|
|
13
|
+
props: {
|
|
14
|
+
optional: true;
|
|
15
|
+
kind: "propsOf";
|
|
16
|
+
inner?: string;
|
|
17
|
+
};
|
|
14
18
|
children: {
|
|
15
19
|
optional: true;
|
|
16
20
|
kind: "array";
|
package/dist/ui/schema.d.ts
CHANGED
|
@@ -7,7 +7,11 @@ export declare const snapJsonRenderSchema: import("@json-render/core").Schema<{
|
|
|
7
7
|
root: import("@json-render/core").SchemaType<"string", unknown>;
|
|
8
8
|
elements: import("@json-render/core").SchemaType<"record", import("@json-render/core").SchemaType<"object", {
|
|
9
9
|
type: import("@json-render/core").SchemaType<"ref", string>;
|
|
10
|
-
props:
|
|
10
|
+
props: {
|
|
11
|
+
optional: true;
|
|
12
|
+
kind: "propsOf";
|
|
13
|
+
inner?: string;
|
|
14
|
+
};
|
|
11
15
|
children: {
|
|
12
16
|
optional: true;
|
|
13
17
|
kind: "array";
|
package/dist/ui/schema.js
CHANGED
|
@@ -8,7 +8,7 @@ export const snapJsonRenderSchema = defineSchema((s) => ({
|
|
|
8
8
|
root: s.string(),
|
|
9
9
|
elements: s.record(s.object({
|
|
10
10
|
type: s.ref("catalog.components"),
|
|
11
|
-
props: s.propsOf("catalog.components"),
|
|
11
|
+
props: { ...s.propsOf("catalog.components"), optional: true },
|
|
12
12
|
children: { ...s.array(s.string()), optional: true },
|
|
13
13
|
})),
|
|
14
14
|
}),
|
package/dist/validator.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { snapResponseSchema } from "./schemas.js";
|
|
2
2
|
import { MAX_CHILDREN, MAX_DEPTH, MAX_ELEMENTS, MAX_ROOT_CHILDREN, SPEC_VERSION_1 } from "./constants.js";
|
|
3
|
+
import { snapJsonRenderCatalog } from "./ui/catalog.js";
|
|
3
4
|
// ─── Helpers ──────────────────────────────────────────
|
|
4
5
|
/** Actions whose `params.target` must be a valid URL. */
|
|
5
6
|
const URL_TARGET_ACTIONS = new Set(["submit", "open_url", "open_mini_app"]);
|
|
@@ -202,6 +203,10 @@ export function validateSnapResponse(json) {
|
|
|
202
203
|
if (urlIssues.length > 0) {
|
|
203
204
|
return { valid: false, issues: urlIssues };
|
|
204
205
|
}
|
|
206
|
+
const catalogResult = snapJsonRenderCatalog.validate(ui);
|
|
207
|
+
if (!catalogResult.success) {
|
|
208
|
+
return { valid: false, issues: catalogResult.error?.issues ?? [] };
|
|
209
|
+
}
|
|
205
210
|
}
|
|
206
211
|
return { valid: true, issues: [] };
|
|
207
212
|
}
|
package/package.json
CHANGED
package/src/ui/schema.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const snapJsonRenderSchema = defineSchema(
|
|
|
11
11
|
elements: s.record(
|
|
12
12
|
s.object({
|
|
13
13
|
type: s.ref("catalog.components"),
|
|
14
|
-
props: s.propsOf("catalog.components"),
|
|
14
|
+
props: { ...s.propsOf("catalog.components"), optional: true },
|
|
15
15
|
children: { ...s.array(s.string()), optional: true },
|
|
16
16
|
}),
|
|
17
17
|
),
|
package/src/validator.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { snapResponseSchema } from "./schemas";
|
|
3
3
|
import { MAX_CHILDREN, MAX_DEPTH, MAX_ELEMENTS, MAX_ROOT_CHILDREN, SPEC_VERSION_1 } from "./constants";
|
|
4
|
+
import { snapJsonRenderCatalog } from "./ui/catalog.js";
|
|
4
5
|
|
|
5
6
|
export type ValidationResult = {
|
|
6
7
|
valid: boolean;
|
|
@@ -255,6 +256,11 @@ export function validateSnapResponse(json: unknown): ValidationResult {
|
|
|
255
256
|
if (urlIssues.length > 0) {
|
|
256
257
|
return { valid: false, issues: urlIssues };
|
|
257
258
|
}
|
|
259
|
+
|
|
260
|
+
const catalogResult = snapJsonRenderCatalog.validate(ui);
|
|
261
|
+
if (!catalogResult.success) {
|
|
262
|
+
return { valid: false, issues: catalogResult.error?.issues ?? [] };
|
|
263
|
+
}
|
|
258
264
|
}
|
|
259
265
|
|
|
260
266
|
return { valid: true, issues: [] };
|