Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit fd11b42

Browse files
jainejaine
authored andcommitted
site: allow Signature field in handlers
1 parent 20e720a commit fd11b42

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

ao/site/process.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ local MAX_CONTENT_BYTES = tonumber(os.getenv("SITE_MAX_CONTENT_BYTES") or "") or
5151
function handlers.ResolveRoute(msg)
5252
local ok, missing = validation.require_fields(msg, { "Site-Id", "Path" })
5353
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
54-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Path", "Actor-Role", "Schema-Version" })
54+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Path", "Actor-Role", "Schema-Version", "Signature" })
5555
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
5656
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
5757
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -74,7 +74,7 @@ end
7474
function handlers.GetPage(msg)
7575
local ok, missing = validation.require_fields(msg, { "Site-Id", "Page-Id" })
7676
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
77-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Page-Id", "Version", "Actor-Role", "Schema-Version" })
77+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Page-Id", "Version", "Actor-Role", "Schema-Version", "Signature" })
7878
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
7979
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
8080
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -101,7 +101,7 @@ end
101101
function handlers.GetLayout(msg)
102102
local ok, missing = validation.require_fields(msg, { "Layout-Id" })
103103
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
104-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Layout-Id", "Version", "Actor-Role", "Schema-Version" })
104+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Layout-Id", "Version", "Actor-Role", "Schema-Version", "Signature" })
105105
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
106106
local ok_len_layout, err_layout = validation.check_length(msg["Layout-Id"], 128, "Layout-Id")
107107
if not ok_len_layout then return codec.error("INVALID_INPUT", err_layout, { field = "Layout-Id" }) end
@@ -125,7 +125,7 @@ end
125125
function handlers.GetNavigation(msg)
126126
local ok, missing = validation.require_fields(msg, { "Site-Id", "Menu-Id" })
127127
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
128-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Menu-Id", "Version", "Actor-Role", "Schema-Version" })
128+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Menu-Id", "Version", "Actor-Role", "Schema-Version", "Signature" })
129129
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
130130
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
131131
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -152,7 +152,7 @@ end
152152
function handlers.PutDraft(msg)
153153
local ok, missing = validation.require_fields(msg, { "Site-Id", "Page-Id", "Content" })
154154
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
155-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Page-Id", "Content", "Actor-Role", "Schema-Version", "ExpectedVersion" })
155+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Page-Id", "Content", "Actor-Role", "Schema-Version", "ExpectedVersion", "Signature" })
156156
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
157157
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
158158
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -176,7 +176,7 @@ end
176176
function handlers.UpsertRoute(msg)
177177
local ok, missing = validation.require_fields(msg, { "Site-Id", "Path", "Page-Id" })
178178
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
179-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Path", "Page-Id", "Layout-Id", "Type", "Actor-Role", "Schema-Version" })
179+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Path", "Page-Id", "Layout-Id", "Type", "Actor-Role", "Schema-Version", "Signature" })
180180
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
181181
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
182182
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -204,7 +204,7 @@ end
204204
function handlers.PublishVersion(msg)
205205
local ok, missing = validation.require_fields(msg, { "Site-Id", "Version" })
206206
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
207-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Version", "ExpectedVersion", "Actor-Role", "Schema-Version" })
207+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Version", "ExpectedVersion", "Actor-Role", "Schema-Version", "Signature" })
208208
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
209209
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
210210
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -251,7 +251,7 @@ end
251251
function handlers.ArchivePage(msg)
252252
local ok, missing = validation.require_fields(msg, { "Site-Id", "Page-Id" })
253253
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
254-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Page-Id", "Version", "Actor-Role", "Schema-Version" })
254+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Page-Id", "Version", "Actor-Role", "Schema-Version", "Signature" })
255255
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
256256
local ok_len_site, err_site = validation.check_length(msg["Site-Id"], 128, "Site-Id")
257257
if not ok_len_site then return codec.error("INVALID_INPUT", err_site, { field = "Site-Id" }) end
@@ -273,7 +273,7 @@ function handlers.RecordOrder(msg)
273273
local ok, missing = validation.require_fields(msg, { "Site-Id", "Order-Id", "Status" })
274274
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
275275
local ok_extra, extras = validation.require_no_extras(msg, {
276-
"Action", "Request-Id", "Site-Id", "Order-Id", "Status", "TotalAmount", "Currency", "VatRate", "Actor-Role", "Schema-Version"
276+
"Action", "Request-Id", "Site-Id", "Order-Id", "Status", "TotalAmount", "Currency", "VatRate", "Actor-Role", "Schema-Version", "Signature"
277277
})
278278
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
279279
state.orders[msg["Site-Id"]] = state.orders[msg["Site-Id"]] or {}
@@ -297,7 +297,7 @@ end
297297
function handlers.GetOrder(msg)
298298
local ok, missing = validation.require_fields(msg, { "Site-Id", "Order-Id" })
299299
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
300-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Order-Id", "Actor-Role", "Schema-Version" })
300+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Order-Id", "Actor-Role", "Schema-Version", "Signature" })
301301
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
302302
local site_orders = state.orders[msg["Site-Id"]] or {}
303303
local order = site_orders[msg["Order-Id"]]
@@ -319,7 +319,7 @@ end
319319
function handlers.ListOrders(msg)
320320
local ok, missing = validation.require_fields(msg, { "Site-Id" })
321321
if not ok then return codec.error("INVALID_INPUT", "Missing field", { missing = missing }) end
322-
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Status", "Page", "PageSize", "Actor-Role", "Schema-Version" })
322+
local ok_extra, extras = validation.require_no_extras(msg, { "Action", "Request-Id", "Site-Id", "Status", "Page", "PageSize", "Actor-Role", "Schema-Version", "Signature" })
323323
if not ok_extra then return codec.error("UNSUPPORTED_FIELD", "Unexpected fields", { unexpected = extras }) end
324324
local page = tonumber(msg.Page or 1) or 1
325325
local page_size = tonumber(msg.PageSize or 20) or 20

scripts/verify/contracts.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ do
186186
site.route(with_req({ Action = "PutDraft", ["Site-Id"] = "site-1", ["Page-Id"] = "home", Content = { title = "Hello", blocks = { { type = "paragraph", text = "Hello" } } }, ["Actor-Role"] = "editor" }))
187187
site.route(with_req({ Action = "UpsertRoute", ["Site-Id"] = "site-1", Path = "/", ["Page-Id"] = "home", ["Layout-Id"] = "layout-1", ["Actor-Role"] = "editor" }))
188188
local publish = site.route(with_req({ Action = "PublishVersion", ["Site-Id"] = "site-1", Version = "v2", ["Actor-Role"] = "publisher" }))
189-
assert_eq(publish.status, "OK", "publish status")
189+
assert_status(publish, "OK", "publish status")
190190
assert_truthy(publish.payload.manifestTx, "publish manifestTx")
191191
assert_truthy(publish.payload.manifestHash, "publish manifestHash")
192192
local ar = require("ao.shared.arweave")

0 commit comments

Comments
 (0)