@positronic/cloudflare 0.0.63 → 0.0.64
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/src/api/index.js +7 -0
- package/dist/src/api/webhooks/coordination.js +26 -97
- package/dist/src/api/webhooks/index.js +43 -7
- package/dist/src/api/webhooks/system.js +22 -3
- package/dist/src/monitor-do.js +17 -5
- package/dist/src/webhook-adapter.js +1 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/webhooks/coordination.d.ts +2 -8
- package/dist/types/api/webhooks/coordination.d.ts.map +1 -1
- package/dist/types/api/webhooks/index.d.ts.map +1 -1
- package/dist/types/api/webhooks/system.d.ts.map +1 -1
- package/dist/types/monitor-do.d.ts +6 -3
- package/dist/types/monitor-do.d.ts.map +1 -1
- package/dist/types/webhook-adapter.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/src/api/index.js
CHANGED
|
@@ -169,6 +169,13 @@ app.use('*', function(c, next) {
|
|
|
169
169
|
next()
|
|
170
170
|
];
|
|
171
171
|
}
|
|
172
|
+
// Ignore favicon requests (browsers auto-request this when loading pages)
|
|
173
|
+
if (c.req.path === '/favicon.ico') {
|
|
174
|
+
return [
|
|
175
|
+
2,
|
|
176
|
+
c.body(null, 204)
|
|
177
|
+
];
|
|
178
|
+
}
|
|
172
179
|
// Skip auth for viewing pages (GET /pages/:slug but not GET /pages/ or /pages/:slug/meta)
|
|
173
180
|
if (c.req.method === 'GET' && c.req.path.startsWith('/pages/') && !c.req.path.endsWith('/meta')) {
|
|
174
181
|
return [
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
1
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
2
|
try {
|
|
11
3
|
var info = gen[key](arg);
|
|
@@ -35,44 +27,6 @@ function _async_to_generator(fn) {
|
|
|
35
27
|
});
|
|
36
28
|
};
|
|
37
29
|
}
|
|
38
|
-
function _iterable_to_array_limit(arr, i) {
|
|
39
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
-
if (_i == null) return;
|
|
41
|
-
var _arr = [];
|
|
42
|
-
var _n = true;
|
|
43
|
-
var _d = false;
|
|
44
|
-
var _s, _e;
|
|
45
|
-
try {
|
|
46
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
47
|
-
_arr.push(_s.value);
|
|
48
|
-
if (i && _arr.length === i) break;
|
|
49
|
-
}
|
|
50
|
-
} catch (err) {
|
|
51
|
-
_d = true;
|
|
52
|
-
_e = err;
|
|
53
|
-
} finally{
|
|
54
|
-
try {
|
|
55
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
56
|
-
} finally{
|
|
57
|
-
if (_d) throw _e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return _arr;
|
|
61
|
-
}
|
|
62
|
-
function _non_iterable_rest() {
|
|
63
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
-
}
|
|
65
|
-
function _sliced_to_array(arr, i) {
|
|
66
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
67
|
-
}
|
|
68
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
|
-
if (!o) return;
|
|
70
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
71
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
72
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
73
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
74
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
75
|
-
}
|
|
76
30
|
function _ts_generator(thisArg, body) {
|
|
77
31
|
var f, y, t, _ = {
|
|
78
32
|
label: 0,
|
|
@@ -164,16 +118,16 @@ function _ts_generator(thisArg, body) {
|
|
|
164
118
|
};
|
|
165
119
|
}
|
|
166
120
|
}
|
|
167
|
-
import { isSignalValid, brainMachineDefinition } from '@positronic/core';
|
|
121
|
+
import { isSignalValid, brainMachineDefinition, validateWebhookToken } from '@positronic/core';
|
|
168
122
|
/**
|
|
169
123
|
* Find a brain waiting for a webhook, queue the WEBHOOK_RESPONSE signal, and wake it up.
|
|
170
124
|
* Returns a JSON response object suitable for returning from a webhook endpoint.
|
|
171
125
|
*
|
|
172
126
|
* This is the signal-based approach: webhook response data flows through the signal queue
|
|
173
127
|
* rather than being passed directly to the resume method.
|
|
174
|
-
*/ export function queueWebhookAndWakeUp(context, slug, identifier, response) {
|
|
128
|
+
*/ export function queueWebhookAndWakeUp(context, slug, identifier, response, submittedToken) {
|
|
175
129
|
return _async_to_generator(function() {
|
|
176
|
-
var monitorId, monitorStub, brainRunId, run, validation, namespace, doId, stub;
|
|
130
|
+
var monitorId, monitorStub, result, brainRunId, expectedToken, tokenValidation, run, validation, namespace, doId, stub;
|
|
177
131
|
return _ts_generator(this, function(_state) {
|
|
178
132
|
switch(_state.label){
|
|
179
133
|
case 0:
|
|
@@ -184,11 +138,30 @@ import { isSignalValid, brainMachineDefinition } from '@positronic/core';
|
|
|
184
138
|
monitorStub.findWaitingBrain(slug, identifier)
|
|
185
139
|
];
|
|
186
140
|
case 1:
|
|
187
|
-
|
|
188
|
-
if (!
|
|
141
|
+
result = _state.sent();
|
|
142
|
+
if (!result) return [
|
|
189
143
|
3,
|
|
190
144
|
5
|
|
191
145
|
];
|
|
146
|
+
brainRunId = result.brainRunId, expectedToken = result.token;
|
|
147
|
+
// Validate CSRF token
|
|
148
|
+
tokenValidation = validateWebhookToken(expectedToken, submittedToken);
|
|
149
|
+
if (!tokenValidation.valid) {
|
|
150
|
+
return [
|
|
151
|
+
2,
|
|
152
|
+
{
|
|
153
|
+
received: true,
|
|
154
|
+
action: 'ignored',
|
|
155
|
+
identifier: identifier,
|
|
156
|
+
brainRunId: brainRunId,
|
|
157
|
+
reason: tokenValidation.reason
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
// Warn in dev mode when no token is present — may indicate an unprotected form
|
|
162
|
+
if (!expectedToken && !submittedToken && context.env.NODE_ENV === 'development') {
|
|
163
|
+
console.warn('[positronic] Webhook "'.concat(slug, '" received without a CSRF token. ') + "This is fine if you validate the request in your webhook handler, " + "but if this webhook receives form submissions from a page, consider " + "adding a token with generateFormToken(). See the docs for details.");
|
|
164
|
+
}
|
|
192
165
|
return [
|
|
193
166
|
4,
|
|
194
167
|
monitorStub.getRun(brainRunId)
|
|
@@ -254,49 +227,5 @@ import { isSignalValid, brainMachineDefinition } from '@positronic/core';
|
|
|
254
227
|
});
|
|
255
228
|
})();
|
|
256
229
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
* Supports:
|
|
260
|
-
* - name[] syntax for explicit arrays
|
|
261
|
-
* - Multiple values with same key (converted to array)
|
|
262
|
-
*/ export function parseFormData(formData) {
|
|
263
|
-
var result = {};
|
|
264
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
265
|
-
try {
|
|
266
|
-
for(var _iterator = formData.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
267
|
-
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
268
|
-
// Handle array fields (e.g., name[] for multi-select)
|
|
269
|
-
if (key.endsWith('[]')) {
|
|
270
|
-
var baseKey = key.slice(0, -2);
|
|
271
|
-
if (!result[baseKey]) {
|
|
272
|
-
result[baseKey] = [];
|
|
273
|
-
}
|
|
274
|
-
result[baseKey].push(value);
|
|
275
|
-
} else if (result[key] !== undefined) {
|
|
276
|
-
// Convert to array if same key appears multiple times
|
|
277
|
-
if (!Array.isArray(result[key])) {
|
|
278
|
-
result[key] = [
|
|
279
|
-
result[key]
|
|
280
|
-
];
|
|
281
|
-
}
|
|
282
|
-
result[key].push(value);
|
|
283
|
-
} else {
|
|
284
|
-
result[key] = value;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
} catch (err) {
|
|
288
|
-
_didIteratorError = true;
|
|
289
|
-
_iteratorError = err;
|
|
290
|
-
} finally{
|
|
291
|
-
try {
|
|
292
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
293
|
-
_iterator.return();
|
|
294
|
-
}
|
|
295
|
-
} finally{
|
|
296
|
-
if (_didIteratorError) {
|
|
297
|
-
throw _iteratorError;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return result;
|
|
302
|
-
}
|
|
230
|
+
// Re-export parseFormData from core for backwards compatibility
|
|
231
|
+
export { parseFormData } from '@positronic/core';
|
|
@@ -197,7 +197,7 @@ webhooks.get('/', function(context) {
|
|
|
197
197
|
// Receive incoming webhook from external service (user-defined webhooks)
|
|
198
198
|
webhooks.post('/:slug', function(context) {
|
|
199
199
|
return _async_to_generator(function() {
|
|
200
|
-
var slug, webhookManifest, webhook, handlerResult, result, error;
|
|
200
|
+
var slug, webhookManifest, webhook, clonedReq, handlerResult, submittedToken, contentType, formData, e, result, error;
|
|
201
201
|
return _ts_generator(this, function(_state) {
|
|
202
202
|
switch(_state.label){
|
|
203
203
|
case 0:
|
|
@@ -216,10 +216,13 @@ webhooks.post('/:slug', function(context) {
|
|
|
216
216
|
case 1:
|
|
217
217
|
_state.trys.push([
|
|
218
218
|
1,
|
|
219
|
-
|
|
219
|
+
8,
|
|
220
220
|
,
|
|
221
|
-
|
|
221
|
+
9
|
|
222
222
|
]);
|
|
223
|
+
// Clone the request so we can extract the CSRF token separately
|
|
224
|
+
// without consuming the body that the user's handler needs
|
|
225
|
+
clonedReq = context.req.raw.clone();
|
|
223
226
|
return [
|
|
224
227
|
4,
|
|
225
228
|
webhook.handler(context.req.raw)
|
|
@@ -235,11 +238,44 @@ webhooks.post('/:slug', function(context) {
|
|
|
235
238
|
})
|
|
236
239
|
];
|
|
237
240
|
}
|
|
241
|
+
// Extract CSRF token from form submissions
|
|
242
|
+
submittedToken = null;
|
|
243
|
+
contentType = clonedReq.headers.get('content-type') || '';
|
|
244
|
+
if (!(contentType.includes('form-urlencoded') || contentType.includes('form-data'))) return [
|
|
245
|
+
3,
|
|
246
|
+
6
|
|
247
|
+
];
|
|
248
|
+
_state.label = 3;
|
|
249
|
+
case 3:
|
|
250
|
+
_state.trys.push([
|
|
251
|
+
3,
|
|
252
|
+
5,
|
|
253
|
+
,
|
|
254
|
+
6
|
|
255
|
+
]);
|
|
238
256
|
return [
|
|
239
257
|
4,
|
|
240
|
-
|
|
258
|
+
clonedReq.formData()
|
|
241
259
|
];
|
|
242
|
-
case
|
|
260
|
+
case 4:
|
|
261
|
+
formData = _state.sent();
|
|
262
|
+
submittedToken = formData.get('__positronic_token');
|
|
263
|
+
return [
|
|
264
|
+
3,
|
|
265
|
+
6
|
|
266
|
+
];
|
|
267
|
+
case 5:
|
|
268
|
+
e = _state.sent();
|
|
269
|
+
return [
|
|
270
|
+
3,
|
|
271
|
+
6
|
|
272
|
+
];
|
|
273
|
+
case 6:
|
|
274
|
+
return [
|
|
275
|
+
4,
|
|
276
|
+
queueWebhookAndWakeUp(context, slug, handlerResult.identifier, handlerResult.response, submittedToken)
|
|
277
|
+
];
|
|
278
|
+
case 7:
|
|
243
279
|
result = _state.sent();
|
|
244
280
|
// For user webhooks, return 'queued' instead of 'not_found' when no brain is waiting
|
|
245
281
|
// This allows webhooks to be received even when no brain is actively waiting
|
|
@@ -257,7 +293,7 @@ webhooks.post('/:slug', function(context) {
|
|
|
257
293
|
2,
|
|
258
294
|
context.json(result)
|
|
259
295
|
];
|
|
260
|
-
case
|
|
296
|
+
case 8:
|
|
261
297
|
error = _state.sent();
|
|
262
298
|
console.error("Error receiving webhook ".concat(slug, ":"), error);
|
|
263
299
|
return [
|
|
@@ -266,7 +302,7 @@ webhooks.post('/:slug', function(context) {
|
|
|
266
302
|
error: 'Failed to process webhook'
|
|
267
303
|
}, 500)
|
|
268
304
|
];
|
|
269
|
-
case
|
|
305
|
+
case 9:
|
|
270
306
|
return [
|
|
271
307
|
2
|
|
272
308
|
];
|
|
@@ -181,7 +181,7 @@ var system = new Hono();
|
|
|
181
181
|
* Content-Type: application/x-www-form-urlencoded or multipart/form-data
|
|
182
182
|
*/ system.post('/ui-form', function(context) {
|
|
183
183
|
return _async_to_generator(function() {
|
|
184
|
-
var identifier, formData, response, result, error;
|
|
184
|
+
var identifier, formData, _parseFormData, response, token, result, error;
|
|
185
185
|
return _ts_generator(this, function(_state) {
|
|
186
186
|
switch(_state.label){
|
|
187
187
|
case 0:
|
|
@@ -208,13 +208,32 @@ var system = new Hono();
|
|
|
208
208
|
];
|
|
209
209
|
case 2:
|
|
210
210
|
formData = _state.sent();
|
|
211
|
-
|
|
211
|
+
_parseFormData = parseFormData(formData), response = _parseFormData.data, token = _parseFormData.token;
|
|
212
|
+
// System ui-form endpoint always requires a CSRF token
|
|
213
|
+
if (!token) {
|
|
214
|
+
return [
|
|
215
|
+
2,
|
|
216
|
+
context.json({
|
|
217
|
+
received: false,
|
|
218
|
+
action: 'ignored',
|
|
219
|
+
identifier: identifier,
|
|
220
|
+
reason: 'Missing form token'
|
|
221
|
+
}, 403)
|
|
222
|
+
];
|
|
223
|
+
}
|
|
212
224
|
return [
|
|
213
225
|
4,
|
|
214
|
-
queueWebhookAndWakeUp(context, 'ui-form', identifier, response)
|
|
226
|
+
queueWebhookAndWakeUp(context, 'ui-form', identifier, response, token)
|
|
215
227
|
];
|
|
216
228
|
case 3:
|
|
217
229
|
result = _state.sent();
|
|
230
|
+
// Return 403 if token mismatch
|
|
231
|
+
if (result.action === 'ignored' && result.reason === 'Invalid form token') {
|
|
232
|
+
return [
|
|
233
|
+
2,
|
|
234
|
+
context.json(result, 403)
|
|
235
|
+
];
|
|
236
|
+
}
|
|
218
237
|
// Return 404 if no brain was waiting
|
|
219
238
|
if (result.action === 'not_found') {
|
|
220
239
|
return [
|
package/dist/src/monitor-do.js
CHANGED
|
@@ -259,6 +259,12 @@ export var MonitorDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
259
259
|
_this.storage = state.storage.sql;
|
|
260
260
|
// Update table schema and indexes
|
|
261
261
|
_this.storage.exec("\n CREATE TABLE IF NOT EXISTS brain_runs (\n run_id TEXT PRIMARY KEY,\n brain_title TEXT NOT NULL,\n brain_description TEXT,\n type TEXT NOT NULL,\n status TEXT NOT NULL,\n options TEXT,\n error TEXT,\n created_at INTEGER NOT NULL,\n started_at INTEGER,\n completed_at INTEGER\n );\n\n CREATE TABLE IF NOT EXISTS brain_events (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n run_id TEXT NOT NULL,\n event_type TEXT NOT NULL,\n event_data TEXT NOT NULL,\n created_at INTEGER NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_brain_events_run\n ON brain_events(run_id, id);\n\n CREATE INDEX IF NOT EXISTS idx_brain_status -- Renamed index\n ON brain_runs(brain_title, status);\n\n CREATE INDEX IF NOT EXISTS idx_brain_time -- Renamed index\n ON brain_runs(created_at DESC);\n\n CREATE TABLE IF NOT EXISTS webhook_registrations (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n slug TEXT NOT NULL,\n identifier TEXT NOT NULL,\n brain_run_id TEXT NOT NULL,\n created_at INTEGER NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_webhook_lookup\n ON webhook_registrations(slug, identifier);\n\n CREATE INDEX IF NOT EXISTS idx_webhook_brain_run\n ON webhook_registrations(brain_run_id);\n\n CREATE TABLE IF NOT EXISTS page_registrations (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n slug TEXT NOT NULL UNIQUE,\n brain_run_id TEXT NOT NULL,\n persist INTEGER NOT NULL DEFAULT 0,\n created_at INTEGER NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_page_brain_run\n ON page_registrations(brain_run_id);\n\n CREATE INDEX IF NOT EXISTS idx_page_persist\n ON page_registrations(persist);\n ");
|
|
262
|
+
// Migration: add token column to webhook_registrations
|
|
263
|
+
try {
|
|
264
|
+
_this.storage.exec("ALTER TABLE webhook_registrations ADD COLUMN token TEXT");
|
|
265
|
+
} catch (e) {
|
|
266
|
+
// Column already exists
|
|
267
|
+
}
|
|
262
268
|
return _this;
|
|
263
269
|
}
|
|
264
270
|
_create_class(MonitorDO, [
|
|
@@ -476,18 +482,24 @@ export var MonitorDO = /*#__PURE__*/ function(DurableObject) {
|
|
|
476
482
|
* Register a webhook to wait for
|
|
477
483
|
* Called when a brain emits a WEBHOOK event
|
|
478
484
|
*/ key: "registerWebhook",
|
|
479
|
-
value: function registerWebhook(slug, identifier, brainRunId) {
|
|
480
|
-
this.storage.exec("\n INSERT INTO webhook_registrations (slug, identifier, brain_run_id, created_at)\n VALUES (?, ?, ?, ?)\n ", slug, identifier, brainRunId, Date.now());
|
|
485
|
+
value: function registerWebhook(slug, identifier, brainRunId, token) {
|
|
486
|
+
this.storage.exec("\n INSERT INTO webhook_registrations (slug, identifier, brain_run_id, token, created_at)\n VALUES (?, ?, ?, ?, ?)\n ", slug, identifier, brainRunId, token !== null && token !== void 0 ? token : null, Date.now());
|
|
481
487
|
}
|
|
482
488
|
},
|
|
483
489
|
{
|
|
484
490
|
/**
|
|
485
491
|
* Find a brain waiting for this webhook
|
|
486
|
-
* Returns the brain_run_id if found, null otherwise
|
|
492
|
+
* Returns the brain_run_id and token if found, null otherwise
|
|
487
493
|
*/ key: "findWaitingBrain",
|
|
488
494
|
value: function findWaitingBrain(slug, identifier) {
|
|
489
|
-
var results = this.storage.exec("\n SELECT brain_run_id as brainRunId\n FROM webhook_registrations\n WHERE slug = ? AND identifier = ?\n LIMIT 1\n ", slug, identifier).toArray();
|
|
490
|
-
|
|
495
|
+
var results = this.storage.exec("\n SELECT brain_run_id as brainRunId, token\n FROM webhook_registrations\n WHERE slug = ? AND identifier = ?\n LIMIT 1\n ", slug, identifier).toArray();
|
|
496
|
+
if (results.length === 0) return null;
|
|
497
|
+
var row = results[0];
|
|
498
|
+
var _row_token;
|
|
499
|
+
return {
|
|
500
|
+
brainRunId: row.brainRunId,
|
|
501
|
+
token: (_row_token = row.token) !== null && _row_token !== void 0 ? _row_token : null
|
|
502
|
+
};
|
|
491
503
|
}
|
|
492
504
|
},
|
|
493
505
|
{
|
|
@@ -195,7 +195,7 @@ import { BRAIN_EVENTS } from '@positronic/core';
|
|
|
195
195
|
registration = _step.value;
|
|
196
196
|
return [
|
|
197
197
|
4,
|
|
198
|
-
this.monitorStub.registerWebhook(registration.slug, registration.identifier, event.brainRunId)
|
|
198
|
+
this.monitorStub.registerWebhook(registration.slug, registration.identifier, event.brainRunId, registration.token)
|
|
199
199
|
];
|
|
200
200
|
case 3:
|
|
201
201
|
_state.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAU3C,QAAA,MAAM,GAAG;cAAwB,QAAQ;yCAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAU3C,QAAA,MAAM,GAAG;cAAwB,QAAQ;yCAAK,CAAC;AAiE/C,eAAe,GAAG,CAAC;AAGnB,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -18,7 +18,7 @@ export type WebhookHandlerResult = {
|
|
|
18
18
|
* This is the signal-based approach: webhook response data flows through the signal queue
|
|
19
19
|
* rather than being passed directly to the resume method.
|
|
20
20
|
*/
|
|
21
|
-
export declare function queueWebhookAndWakeUp(context: Context, slug: string, identifier: string, response: Record<string, unknown
|
|
21
|
+
export declare function queueWebhookAndWakeUp(context: Context, slug: string, identifier: string, response: Record<string, unknown>, submittedToken?: string | null): Promise<{
|
|
22
22
|
received: boolean;
|
|
23
23
|
action: 'resumed' | 'not_found' | 'queued' | 'ignored';
|
|
24
24
|
identifier: string;
|
|
@@ -26,11 +26,5 @@ export declare function queueWebhookAndWakeUp(context: Context, slug: string, id
|
|
|
26
26
|
message?: string;
|
|
27
27
|
reason?: string;
|
|
28
28
|
}>;
|
|
29
|
-
|
|
30
|
-
* Parse form data into a plain object, handling array fields.
|
|
31
|
-
* Supports:
|
|
32
|
-
* - name[] syntax for explicit arrays
|
|
33
|
-
* - Multiple values with same key (converted to array)
|
|
34
|
-
*/
|
|
35
|
-
export declare function parseFormData(formData: FormData): Record<string, unknown>;
|
|
29
|
+
export { parseFormData } from '@positronic/core';
|
|
36
30
|
//# sourceMappingURL=coordination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordination.d.ts","sourceRoot":"","sources":["../../../../src/api/webhooks/coordination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,CA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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/webhooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,QAAA,MAAM,QAAQ;cAAwB,QAAQ;yCAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/webhooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,QAAA,MAAM,QAAQ;cAAwB,QAAQ;yCAAK,CAAC;AAiFpD,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../../src/api/webhooks/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,MAAM;cAAwB,QAAQ;yCAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../../src/api/webhooks/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,MAAM;cAAwB,QAAQ;yCAAK,CAAC;AAoDlD,eAAe,MAAM,CAAC"}
|
|
@@ -22,12 +22,15 @@ export declare class MonitorDO extends DurableObject<Env> {
|
|
|
22
22
|
* Register a webhook to wait for
|
|
23
23
|
* Called when a brain emits a WEBHOOK event
|
|
24
24
|
*/
|
|
25
|
-
registerWebhook(slug: string, identifier: string, brainRunId: string): void;
|
|
25
|
+
registerWebhook(slug: string, identifier: string, brainRunId: string, token?: string): void;
|
|
26
26
|
/**
|
|
27
27
|
* Find a brain waiting for this webhook
|
|
28
|
-
* Returns the brain_run_id if found, null otherwise
|
|
28
|
+
* Returns the brain_run_id and token if found, null otherwise
|
|
29
29
|
*/
|
|
30
|
-
findWaitingBrain(slug: string, identifier: string):
|
|
30
|
+
findWaitingBrain(slug: string, identifier: string): {
|
|
31
|
+
brainRunId: string;
|
|
32
|
+
token: string | null;
|
|
33
|
+
} | null;
|
|
31
34
|
/**
|
|
32
35
|
* Clear all webhook registrations for a brain run
|
|
33
36
|
* Called when brain completes, errors, or is cancelled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor-do.d.ts","sourceRoot":"","sources":["../../src/monitor-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,GAAG;CAEnB;AAED,qBAAa,SAAU,SAAQ,aAAa,CAAC,GAAG,CAAC;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,kBAAkB,CAA4B;IAEtD,OAAO,CAAC,QAAQ,CAAwC;gBAE5C,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"monitor-do.d.ts","sourceRoot":"","sources":["../../src/monitor-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,GAAG;CAEnB;AAED,qBAAa,SAAU,SAAQ,aAAa,CAAC,GAAG,CAAC;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAA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,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,cAAe,YAAW,OAAO;IAChC,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE;QAAE,eAAe,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAA;KAAE;IAE5E,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook-adapter.d.ts","sourceRoot":"","sources":["../../src/webhook-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,cAAe,YAAW,OAAO;IAChC,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE;QAAE,eAAe,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAA;KAAE;IAE5E,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBjD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positronic/cloudflare",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"clean": "rm -rf tsconfig.tsbuildinfo dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@positronic/core": "^0.0.
|
|
35
|
-
"@positronic/spec": "^0.0.
|
|
36
|
-
"@positronic/template-new-project": "^0.0.
|
|
34
|
+
"@positronic/core": "^0.0.64",
|
|
35
|
+
"@positronic/spec": "^0.0.64",
|
|
36
|
+
"@positronic/template-new-project": "^0.0.64",
|
|
37
37
|
"aws4fetch": "^1.0.18",
|
|
38
38
|
"caz": "^2.0.0",
|
|
39
39
|
"cron-schedule": "^5.0.4",
|