@blotout/qinto-cli 0.1.3 → 0.1.4
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/index.js +52 -55
- package/dist/index.js.map +1 -1
- package/dist/worker-artifact/app-runtime/index.js +21 -6
- package/dist/worker-artifact/main/index.js +1 -1
- package/dist/worker-artifact/version.json +4 -4
- package/package.json +1 -1
- package/templates/app/full/ui/src/pages/index.astro +1 -1
package/dist/index.js
CHANGED
|
@@ -1240,7 +1240,7 @@ var Kn = Nn((e, t) => {
|
|
|
1240
1240
|
].filter(Boolean).join("\n").trimEnd()}${yn}`;
|
|
1241
1241
|
}), qn = {
|
|
1242
1242
|
name: "@blotout/qinto-cli",
|
|
1243
|
-
version: "0.1.
|
|
1243
|
+
version: "0.1.4",
|
|
1244
1244
|
type: "module",
|
|
1245
1245
|
description: "Qinto CLI: authenticate against the Qinto platform and operate it from the terminal or from an agent.",
|
|
1246
1246
|
repository: {
|
|
@@ -8211,62 +8211,62 @@ ${Ag()}
|
|
|
8211
8211
|
<p class="lede">Settings the platform stores against the domain. They ride the site worker's bindings, so saving one recomposes the
|
|
8212
8212
|
local workerd stack the same way a redeploy carries them to the edge.</p>
|
|
8213
8213
|
${Mg(e)}
|
|
8214
|
-
</div>`, Pg = (e, t) => e.enabled && t.enabled, Fg = (e, t
|
|
8215
|
-
title="${Q(
|
|
8216
|
-
let n = Q(e.manifest.name), r = `${$}/${Q(e.manifest.slug)}`, i =
|
|
8217
|
-
${Fg(t, n, `${e.manifest.name} — ${n.label}`)}
|
|
8218
|
-
</section>`).join("");
|
|
8214
|
+
</div>`, Pg = (e, t) => e.enabled && t.enabled, Fg = (e, t) => `<iframe class="panel" src="${Q(e.iframeUrl)}"
|
|
8215
|
+
title="${Q(t)}" sandbox="allow-scripts allow-same-origin allow-forms"></iframe>`, Ig = (e) => e.installs.find((t) => Pg(e, t)), Lg = (e, t) => {
|
|
8216
|
+
let n = Q(e.manifest.name), r = `${$}/${Q(e.manifest.slug)}`, i = Ig(e.state) === void 0 ? `<div class="card"><p class="hint">${e.state.enabled ? `Every install of ${n} is disabled, so there is no panel to open.` : `${n} is disabled on this site, so there is no panel to open.`} Enable one on the <a class="link" href="${r}">app's own page</a>.</p></div>` : Fg(t, e.manifest.name);
|
|
8219
8217
|
return `<div class="stack">
|
|
8220
8218
|
<p class="lede">Served from <code>${Q(t.origin)}</code> — a different origin to this console, so the panel's
|
|
8221
8219
|
<code>postMessage</code> checks are the ones a deployed panel makes.</p>
|
|
8222
|
-
${
|
|
8220
|
+
${i}
|
|
8223
8221
|
</div>`;
|
|
8224
|
-
},
|
|
8222
|
+
}, Rg = (e) => `
|
|
8225
8223
|
const ORIGIN = ${JSON.stringify(e.iframeOrigin)}
|
|
8226
8224
|
const TOKEN_PATH = ${JSON.stringify(e.tokenPath)}
|
|
8227
|
-
const
|
|
8225
|
+
const frame = document.querySelector('iframe.panel')
|
|
8226
|
+
|
|
8227
|
+
const send = async () => {
|
|
8228
|
+
const response = await fetch(TOKEN_PATH, { headers: { accept: 'application/json' } }).catch(() => null)
|
|
8229
|
+
// Answer the refusal: the panel waits on this token, and silence leaves that wait pending forever.
|
|
8230
|
+
if (response === null || !response.ok) {
|
|
8231
|
+
frame.contentWindow.postMessage({ type: 'qinto:token-error' }, ORIGIN)
|
|
8232
|
+
return
|
|
8233
|
+
}
|
|
8228
8234
|
|
|
8229
|
-
const send = async (frame) => {
|
|
8230
|
-
const response = await fetch(TOKEN_PATH + '?appInstallId=' + encodeURIComponent(frame.dataset.install), {
|
|
8231
|
-
headers: { accept: 'application/json' }
|
|
8232
|
-
})
|
|
8233
|
-
if (!response.ok) { return }
|
|
8234
8235
|
const { context, token } = await response.json()
|
|
8235
8236
|
frame.contentWindow.postMessage({ type: 'qinto:init', context, token }, ORIGIN)
|
|
8236
8237
|
}
|
|
8237
8238
|
|
|
8238
8239
|
window.addEventListener('message', (event) => {
|
|
8239
8240
|
if (event.origin !== ORIGIN) { return }
|
|
8240
|
-
|
|
8241
|
-
if (frame === undefined) { return }
|
|
8241
|
+
if (frame === null || frame.contentWindow === null || frame.contentWindow !== event.source) { return }
|
|
8242
8242
|
|
|
8243
8243
|
const message = event.data
|
|
8244
8244
|
if (message === null || typeof message !== 'object') { return }
|
|
8245
8245
|
|
|
8246
|
-
if (message.type === 'qinto:ready' || message.type === 'qinto:token') { void send(
|
|
8246
|
+
if (message.type === 'qinto:ready' || message.type === 'qinto:token') { void send(); return }
|
|
8247
8247
|
if (message.type === 'qinto:resize' && typeof message.height === 'number') {
|
|
8248
8248
|
frame.style.height = Math.max(120, Math.min(4000, Math.round(message.height))) + 'px'
|
|
8249
8249
|
}
|
|
8250
8250
|
})
|
|
8251
|
-
`,
|
|
8251
|
+
`, zg = "dev-user", Bg = 64 * 1024, Vg = (e, t, n) => new Promise((r, i) => {
|
|
8252
8252
|
e.once("error", i), e.listen(n, t, () => {
|
|
8253
8253
|
e.off("error", i), r();
|
|
8254
8254
|
});
|
|
8255
|
-
}),
|
|
8255
|
+
}), Hg = async (e) => {
|
|
8256
8256
|
let t = [], n = 0;
|
|
8257
8257
|
for await (let r of e) {
|
|
8258
|
-
if (n += r.length, n >
|
|
8258
|
+
if (n += r.length, n > Bg) throw Error("The submitted form is too large.");
|
|
8259
8259
|
t.push(r);
|
|
8260
8260
|
}
|
|
8261
8261
|
return Buffer.concat(t).toString("utf8");
|
|
8262
|
-
},
|
|
8262
|
+
}, Ug = async (e) => Object.fromEntries(new URLSearchParams(await Hg(e))), Wg = /* @__PURE__ */ new Set([
|
|
8263
8263
|
"127.0.0.1",
|
|
8264
8264
|
"localhost",
|
|
8265
8265
|
"[::1]"
|
|
8266
|
-
]),
|
|
8266
|
+
]), Gg = (e, t) => {
|
|
8267
8267
|
let n = e === void 0 ? null : URL.parse(e.includes("//") ? e : `http://${e}`);
|
|
8268
|
-
return n !== null &&
|
|
8269
|
-
},
|
|
8268
|
+
return n !== null && Wg.has(n.hostname) && n.port === String(t);
|
|
8269
|
+
}, Kg = {
|
|
8270
8270
|
[$h]: {
|
|
8271
8271
|
title: "Apps",
|
|
8272
8272
|
width: "full",
|
|
@@ -8288,26 +8288,23 @@ window.addEventListener('message', (event) => {
|
|
|
8288
8288
|
width: "form",
|
|
8289
8289
|
body: Ng
|
|
8290
8290
|
}
|
|
8291
|
-
}, Kg = (e, t) => {
|
|
8292
|
-
let n = e.state.installs.find((e) => e.appInstallId === t);
|
|
8293
|
-
return n === void 0 || !Pg(e.state, n) ? null : n;
|
|
8294
8291
|
}, qg = (e) => e.state.installs.map((e) => ({
|
|
8295
8292
|
id: e.appInstallId,
|
|
8296
8293
|
label: e.label,
|
|
8297
8294
|
enabled: e.enabled,
|
|
8298
8295
|
variables: e.variables
|
|
8299
|
-
})), Jg = async (e, t
|
|
8300
|
-
let
|
|
8301
|
-
return !t.state.installed ||
|
|
8296
|
+
})), Jg = async (e, t) => {
|
|
8297
|
+
let n = Ig(t.state);
|
|
8298
|
+
return !t.state.installed || n === void 0 || e.appUi === null ? null : {
|
|
8302
8299
|
token: await Mp({
|
|
8303
8300
|
kid: e.keys.appUiKeyId,
|
|
8304
8301
|
key: e.keys.appUiKey,
|
|
8305
8302
|
now: /* @__PURE__ */ new Date(),
|
|
8306
8303
|
slug: t.manifest.slug,
|
|
8307
|
-
userId:
|
|
8304
|
+
userId: zg,
|
|
8308
8305
|
domainId: t.state.domainId,
|
|
8309
8306
|
appId: t.state.appId,
|
|
8310
|
-
appInstallId:
|
|
8307
|
+
appInstallId: n.appInstallId,
|
|
8311
8308
|
appVersionId: yh,
|
|
8312
8309
|
access: "write"
|
|
8313
8310
|
}),
|
|
@@ -8317,7 +8314,7 @@ window.addEventListener('message', (event) => {
|
|
|
8317
8314
|
siteOrigin: e.origin,
|
|
8318
8315
|
appSlug: t.manifest.slug,
|
|
8319
8316
|
appVersion: yh,
|
|
8320
|
-
appInstallId:
|
|
8317
|
+
appInstallId: n.appInstallId,
|
|
8321
8318
|
installs: qg(t),
|
|
8322
8319
|
theme: "light"
|
|
8323
8320
|
}
|
|
@@ -8337,12 +8334,12 @@ window.addEventListener('message', (event) => {
|
|
|
8337
8334
|
return e === `${t}/ui` && n.state.installed && i !== null ? {
|
|
8338
8335
|
title: n.manifest.name,
|
|
8339
8336
|
width: "full",
|
|
8340
|
-
body: (e) =>
|
|
8341
|
-
script:
|
|
8337
|
+
body: (e) => Lg(e, i),
|
|
8338
|
+
script: Rg({
|
|
8342
8339
|
iframeOrigin: i.origin,
|
|
8343
8340
|
tokenPath: r
|
|
8344
8341
|
})
|
|
8345
|
-
} :
|
|
8342
|
+
} : Kg[e];
|
|
8346
8343
|
}, Xg = async (e) => {
|
|
8347
8344
|
let t = e.port, n = () => `http://${e.host}:${t}`, r = () => ({
|
|
8348
8345
|
manifest: e.stack.manifest(),
|
|
@@ -8378,46 +8375,46 @@ window.addEventListener('message', (event) => {
|
|
|
8378
8375
|
e.on("close", () => {
|
|
8379
8376
|
o.delete(e), n();
|
|
8380
8377
|
});
|
|
8381
|
-
}, c = /* @__PURE__ */ new Set(), l = async (t, n
|
|
8378
|
+
}, c = /* @__PURE__ */ new Set(), l = async (t, n) => {
|
|
8382
8379
|
if (t === "/") {
|
|
8383
|
-
|
|
8380
|
+
n.writeHead(303, { location: $ }).end();
|
|
8384
8381
|
return;
|
|
8385
8382
|
}
|
|
8386
8383
|
if (t === "/site/logs/stream") {
|
|
8387
|
-
s(
|
|
8384
|
+
s(n, (t) => e.stack.logs.subscribe((e) => {
|
|
8388
8385
|
e.spans !== void 0 && t.write(`event: spans\ndata: ${JSON.stringify(e.spans)}\n\n`);
|
|
8389
8386
|
}));
|
|
8390
8387
|
return;
|
|
8391
8388
|
}
|
|
8392
8389
|
if (t === "/reload") {
|
|
8393
|
-
s(
|
|
8390
|
+
s(n, (e) => (c.add(e), () => {
|
|
8394
8391
|
c.delete(e);
|
|
8395
8392
|
}));
|
|
8396
8393
|
return;
|
|
8397
8394
|
}
|
|
8398
8395
|
if (t === `${i()}/token`) {
|
|
8399
|
-
let t = await Jg(e.stack, r()
|
|
8396
|
+
let t = await Jg(e.stack, r());
|
|
8400
8397
|
if (t === null) {
|
|
8401
|
-
|
|
8398
|
+
n.writeHead(409, { "content-type": "text/plain" }).end("no active install to open the panel for");
|
|
8402
8399
|
return;
|
|
8403
8400
|
}
|
|
8404
|
-
|
|
8401
|
+
n.writeHead(200, {
|
|
8405
8402
|
"content-type": "application/json",
|
|
8406
8403
|
"cache-control": "no-store"
|
|
8407
8404
|
}).end(JSON.stringify(t));
|
|
8408
8405
|
return;
|
|
8409
8406
|
}
|
|
8410
|
-
let
|
|
8411
|
-
if (
|
|
8412
|
-
|
|
8407
|
+
let o = a(t);
|
|
8408
|
+
if (o === null) {
|
|
8409
|
+
n.writeHead(404, { "content-type": "text/plain" }).end("not found");
|
|
8413
8410
|
return;
|
|
8414
8411
|
}
|
|
8415
|
-
|
|
8412
|
+
n.writeHead(200, {
|
|
8416
8413
|
"content-type": "text/html; charset=utf-8",
|
|
8417
8414
|
"cache-control": "no-store"
|
|
8418
|
-
}),
|
|
8415
|
+
}), n.end(o);
|
|
8419
8416
|
}, u = async (t) => {
|
|
8420
|
-
let n = await
|
|
8417
|
+
let n = await Ug(t), r = t.url.slice(1);
|
|
8421
8418
|
if (r === "schedule-run") return await e.stack.runSchedule(n.scheduleId ?? ""), r;
|
|
8422
8419
|
let i = Mh({
|
|
8423
8420
|
action: r,
|
|
@@ -8429,7 +8426,7 @@ window.addEventListener('message', (event) => {
|
|
|
8429
8426
|
});
|
|
8430
8427
|
return await e.stack.apply(i), r;
|
|
8431
8428
|
}, d = (t) => t === "consent" ? tg : t === "app-variables" ? `${$h}/${e.stack.manifest().slug}` : e.stack.state().installed ? i() : $, f = async (t, n) => {
|
|
8432
|
-
let r = t.headers.authorization, i = await
|
|
8429
|
+
let r = t.headers.authorization, i = await Hg(t), a;
|
|
8433
8430
|
try {
|
|
8434
8431
|
a = JSON.parse(i);
|
|
8435
8432
|
} catch {
|
|
@@ -8456,13 +8453,13 @@ window.addEventListener('message', (event) => {
|
|
|
8456
8453
|
appValues: e.stack.appValues()
|
|
8457
8454
|
}), n.writeHead(202, { "content-type": "application/json" }).end(JSON.stringify({ accepted: !0 }));
|
|
8458
8455
|
}, p = async (r, i) => {
|
|
8459
|
-
if (!
|
|
8456
|
+
if (!Gg(r.headers.host, t)) {
|
|
8460
8457
|
i.writeHead(403, { "content-type": "text/plain" }).end("this console answers loopback only");
|
|
8461
8458
|
return;
|
|
8462
8459
|
}
|
|
8463
8460
|
let a = new URL(r.url, n());
|
|
8464
8461
|
if (r.method === "GET") {
|
|
8465
|
-
await l(a.pathname,
|
|
8462
|
+
await l(a.pathname, i);
|
|
8466
8463
|
return;
|
|
8467
8464
|
}
|
|
8468
8465
|
if (r.method !== "POST") {
|
|
@@ -8473,7 +8470,7 @@ window.addEventListener('message', (event) => {
|
|
|
8473
8470
|
await f(r, i);
|
|
8474
8471
|
return;
|
|
8475
8472
|
}
|
|
8476
|
-
if (!
|
|
8473
|
+
if (!Gg(r.headers.origin, t)) {
|
|
8477
8474
|
i.writeHead(403, { "content-type": "text/plain" }).end("cross-origin form posts are refused");
|
|
8478
8475
|
return;
|
|
8479
8476
|
}
|
|
@@ -8483,7 +8480,7 @@ window.addEventListener('message', (event) => {
|
|
|
8483
8480
|
t.writeHead(500, { "content-type": "text/plain" }).end(e instanceof Error ? e.message : String(e));
|
|
8484
8481
|
});
|
|
8485
8482
|
});
|
|
8486
|
-
return await
|
|
8483
|
+
return await Vg(m, e.host, e.port), t = m.address().port, {
|
|
8487
8484
|
origin: n,
|
|
8488
8485
|
reload: () => {
|
|
8489
8486
|
for (let e of c) e.write("event: reload\ndata: {}\n\n");
|
|
@@ -9013,7 +9010,7 @@ ${Object.keys(e_).map((e) => ` <button class="outline" data-std="${e}">${
|
|
|
9013
9010
|
],
|
|
9014
9011
|
result: { type: "app-dev" },
|
|
9015
9012
|
run: async (e, t) => {
|
|
9016
|
-
let n = e.positionals.at(0) ?? ".", r = e.options, i = {
|
|
9013
|
+
let n = u(e.positionals.at(0) ?? "."), r = e.options, i = {
|
|
9017
9014
|
worker: g_("--worker-port", r.workerPort),
|
|
9018
9015
|
demo: g_("--demo-port", r.demoPort),
|
|
9019
9016
|
console: g_("--console-port", r.consolePort),
|