@niscorp/moss 0.9.3 → 0.10.0
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/CHANGELOG.md +110 -0
- package/DESIGN.md +58 -55
- package/DOCS.md +259 -168
- package/README.md +5 -5
- package/dist/{chunk-PVZMCEBX.cjs → chunk-3CKBKTXA.cjs} +2 -2
- package/dist/chunk-3CKBKTXA.cjs.map +1 -0
- package/dist/{chunk-TAAKHW3U.js → chunk-3PL4AH4I.js} +4 -4
- package/dist/{chunk-TAAKHW3U.js.map → chunk-3PL4AH4I.js.map} +1 -1
- package/dist/{chunk-QAHDSRPK.js → chunk-4URQHVYG.js} +2 -2
- package/dist/chunk-4URQHVYG.js.map +1 -0
- package/dist/{chunk-U43CBKKE.cjs → chunk-6ACVHHFK.cjs} +32 -30
- package/dist/chunk-6ACVHHFK.cjs.map +1 -0
- package/dist/{chunk-IUJ2TRNB.cjs → chunk-7MOEKAVC.cjs} +6 -6
- package/dist/{chunk-IUJ2TRNB.cjs.map → chunk-7MOEKAVC.cjs.map} +1 -1
- package/dist/{chunk-NCQBGK3E.cjs → chunk-BFA76AKR.cjs} +4 -4
- package/dist/chunk-BFA76AKR.cjs.map +1 -0
- package/dist/{chunk-T5BRTFKP.js → chunk-DSVRFAGX.js} +3 -3
- package/dist/{chunk-T5BRTFKP.js.map → chunk-DSVRFAGX.js.map} +1 -1
- package/dist/{chunk-IW3A2YIC.js → chunk-EYWD733E.js} +3 -3
- package/dist/{chunk-IW3A2YIC.js.map → chunk-EYWD733E.js.map} +1 -1
- package/dist/{chunk-IY5BOFLK.cjs → chunk-G4P3XEVM.cjs} +19 -19
- package/dist/chunk-G4P3XEVM.cjs.map +1 -0
- package/dist/{chunk-6QPTMKRE.cjs → chunk-HUP7CZ7X.cjs} +6 -6
- package/dist/{chunk-6QPTMKRE.cjs.map → chunk-HUP7CZ7X.cjs.map} +1 -1
- package/dist/{chunk-VKQPOZDJ.cjs → chunk-LTS4AM6T.cjs} +4 -4
- package/dist/chunk-LTS4AM6T.cjs.map +1 -0
- package/dist/{chunk-UTFOMFCH.js → chunk-MEHCZECW.js} +5 -5
- package/dist/chunk-MEHCZECW.js.map +1 -0
- package/dist/{chunk-6MZPY4X6.js → chunk-MYPK5YZR.js} +249 -199
- package/dist/chunk-MYPK5YZR.js.map +1 -0
- package/dist/{chunk-TKXYPO2Y.js → chunk-NUX5MH4I.js} +4 -4
- package/dist/chunk-NUX5MH4I.js.map +1 -0
- package/dist/{chunk-EXMOO7ZR.cjs → chunk-UVY5ZPWW.cjs} +326 -276
- package/dist/chunk-UVY5ZPWW.cjs.map +1 -0
- package/dist/{chunk-MVG333UF.js → chunk-VYYDLGQ2.js} +27 -25
- package/dist/chunk-VYYDLGQ2.js.map +1 -0
- package/dist/{chunk-NRZ3Z2FF.js → chunk-WKZWSWOJ.js} +4 -4
- package/dist/chunk-WKZWSWOJ.js.map +1 -0
- package/dist/{chunk-YGZS5B2U.cjs → chunk-XH6TSWG4.cjs} +7 -7
- package/dist/{chunk-YGZS5B2U.cjs.map → chunk-XH6TSWG4.cjs.map} +1 -1
- package/dist/client.cjs +5 -5
- package/dist/client.js +2 -2
- package/dist/{document-CuF4JqzJ.d.cts → document-DvhT_HaJ.d.cts} +1 -1
- package/dist/{document-BzXQvEc1.d.ts → document-iKaRinZE.d.ts} +1 -1
- package/dist/{index-CSEo7Tys.d.cts → index-DWj3_0Zg.d.cts} +3 -0
- package/dist/{index-CSEo7Tys.d.ts → index-DWj3_0Zg.d.ts} +3 -0
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/integrations.cjs +27 -18
- package/dist/integrations.cjs.map +1 -1
- package/dist/integrations.d.cts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.js +25 -16
- package/dist/integrations.js.map +1 -1
- package/dist/node.cjs +9 -9
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +5 -5
- package/dist/protocol.cjs +5 -5
- package/dist/protocol.js +1 -1
- package/dist/terminal/dom/index.cjs +3 -3
- package/dist/terminal/dom/index.js +1 -1
- package/dist/terminal/dom/server.cjs +2 -2
- package/dist/terminal/dom/server.js +1 -1
- package/dist/terminal/index.cjs +3 -3
- package/dist/terminal/index.js +2 -2
- package/dist/terminal/ink/index.js.map +1 -1
- package/dist/terminal/react/index.cjs +9 -9
- package/dist/terminal/react/index.cjs.map +1 -1
- package/dist/terminal/react/index.js +4 -4
- package/dist/terminal/react/index.js.map +1 -1
- package/dist/terminal/react/server.cjs +4 -4
- package/dist/terminal/react/server.js +2 -2
- package/dist/terminal/tty/index.cjs +12 -12
- package/dist/terminal/tty/index.cjs.map +1 -1
- package/dist/terminal/tty/index.js +6 -6
- package/dist/terminal/tty/index.js.map +1 -1
- package/dist/terminal/vue/index.cjs +9 -9
- package/dist/terminal/vue/index.cjs.map +1 -1
- package/dist/terminal/vue/index.js +4 -4
- package/dist/terminal/vue/index.js.map +1 -1
- package/dist/terminal/vue/server.cjs +4 -4
- package/dist/terminal/vue/server.js +2 -2
- package/dist/tide.d.cts +1 -1
- package/dist/tide.d.ts +1 -1
- package/dist/unverified.cjs +4 -4
- package/dist/unverified.js +3 -3
- package/dist/vite.cjs +36 -10
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +31 -5
- package/dist/vite.js.map +1 -1
- package/package.json +13 -13
- package/dist/chunk-6MZPY4X6.js.map +0 -1
- package/dist/chunk-EXMOO7ZR.cjs.map +0 -1
- package/dist/chunk-IY5BOFLK.cjs.map +0 -1
- package/dist/chunk-MVG333UF.js.map +0 -1
- package/dist/chunk-NCQBGK3E.cjs.map +0 -1
- package/dist/chunk-NRZ3Z2FF.js.map +0 -1
- package/dist/chunk-PVZMCEBX.cjs.map +0 -1
- package/dist/chunk-QAHDSRPK.js.map +0 -1
- package/dist/chunk-TKXYPO2Y.js.map +0 -1
- package/dist/chunk-U43CBKKE.cjs.map +0 -1
- package/dist/chunk-UTFOMFCH.js.map +0 -1
- package/dist/chunk-VKQPOZDJ.cjs.map +0 -1
package/dist/integrations.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { emitterOf, spanClock } from './chunk-
|
|
1
|
+
import { emitterOf, spanClock } from './chunk-4URQHVYG.js';
|
|
2
2
|
import { generateKeyPairSync, sign, createPrivateKey, createPublicKey, createHash, randomBytes } from 'crypto';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
|
+
import { normalizeRole } from '@niscorp/charter';
|
|
5
6
|
import { ActionDefinitionSchema, paletteEntryOf } from '@niscorp/nova';
|
|
6
7
|
import { isRecord } from '@niscorp/nova/reflect';
|
|
7
8
|
import { StrataError, exceedsDepth, depthRefusal } from '@niscorp/strata';
|
|
@@ -222,8 +223,8 @@ var reachOf = (bundle, integrationId) => {
|
|
|
222
223
|
const admit = (url, actionId) => {
|
|
223
224
|
if (!url.startsWith(own)) return;
|
|
224
225
|
const key = normalizePath(url);
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
226
|
+
const declaring = reach[key] ??= [];
|
|
227
|
+
if (!declaring.includes(actionId)) declaring.push(actionId);
|
|
227
228
|
};
|
|
228
229
|
for (const [actionId, action] of Object.entries(bundle.actions)) {
|
|
229
230
|
for (const endpoint of Object.values(action.endpoints ?? {})) {
|
|
@@ -232,7 +233,7 @@ var reachOf = (bundle, integrationId) => {
|
|
|
232
233
|
}
|
|
233
234
|
return Object.fromEntries(Object.entries(reach).sort(([a], [b]) => a.localeCompare(b)));
|
|
234
235
|
};
|
|
235
|
-
var reachAdmits = (reach, path,
|
|
236
|
+
var reachAdmits = (reach, path, granted) => (reach[normalizePath(path)] ?? []).some((actionId) => granted.has(actionId));
|
|
236
237
|
var reachDeclares = (reach, path) => reach[normalizePath(path)] !== void 0;
|
|
237
238
|
|
|
238
239
|
// src/integrations/forward.ts
|
|
@@ -263,7 +264,16 @@ var createForwarder = (deps) => {
|
|
|
263
264
|
return sent(url, () => call.request(assertion));
|
|
264
265
|
};
|
|
265
266
|
};
|
|
266
|
-
var
|
|
267
|
+
var SANDBOX = "sandbox allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals allow-downloads allow-top-navigation";
|
|
268
|
+
var relayed = (response, otherwise, more = {}) => new Response(response.body, {
|
|
269
|
+
status: response.status,
|
|
270
|
+
headers: {
|
|
271
|
+
"content-type": response.headers.get("content-type") ?? otherwise,
|
|
272
|
+
"content-security-policy": SANDBOX,
|
|
273
|
+
"x-content-type-options": "nosniff",
|
|
274
|
+
...more
|
|
275
|
+
}
|
|
276
|
+
});
|
|
267
277
|
var HOOK_LIMIT = 240;
|
|
268
278
|
var HOOK_WINDOW_MS = 6e4;
|
|
269
279
|
var createHookLimit = () => {
|
|
@@ -284,8 +294,9 @@ var webhook = (deps, routes) => {
|
|
|
284
294
|
const id = c.req.param("id");
|
|
285
295
|
const here = new URL(c.req.url);
|
|
286
296
|
const headers = new Headers(c.req.raw.headers);
|
|
287
|
-
|
|
297
|
+
for (const name of ["authorization", "cookie", "proxy-authorization", "x-operator-key"]) headers.delete(name);
|
|
288
298
|
headers.delete("host");
|
|
299
|
+
for (const name of ["transfer-encoding", "keep-alive", "expect", "upgrade"]) headers.delete(name);
|
|
289
300
|
const ended = await deps.forward({
|
|
290
301
|
integration: id,
|
|
291
302
|
admits: () => hookAllows(id, Date.now()),
|
|
@@ -314,7 +325,7 @@ var proxy = (deps, routes) => {
|
|
|
314
325
|
request: async (assertion) => ({
|
|
315
326
|
method: c.req.method,
|
|
316
327
|
headers: { "content-type": "application/json", authorization: `Bearer ${assertion}` },
|
|
317
|
-
...c.req.method === "GET" ? {} : { body: await c.req.text() }
|
|
328
|
+
...c.req.method === "GET" || c.req.method === "HEAD" ? {} : { body: await c.req.text() }
|
|
318
329
|
})
|
|
319
330
|
});
|
|
320
331
|
if (ended.kind === "refused") return c.json({ message: ended.why === "uninstalled" ? "Not installed here." : "No such integration." }, 404);
|
|
@@ -520,7 +531,7 @@ var RegistrationRowSchema = z.object({ status: z.string(), key_hash: z.string().
|
|
|
520
531
|
var WrittenRowSchema = z.looseObject({ key_hash: z.string().nullish() });
|
|
521
532
|
var WrittenSchema = z.union([z.array(WrittenRowSchema), WrittenRowSchema.transform((row) => [row]), z.undefined().transform(() => [])]);
|
|
522
533
|
var RequestedRowSchema = z.object({ requested_data: strings });
|
|
523
|
-
var
|
|
534
|
+
var KeyOwnerRowSchema = z.object({ id: z.string() });
|
|
524
535
|
var actionKey = { integration_id: z.string(), action_id: z.string() };
|
|
525
536
|
var afterAction2 = (last) => ({
|
|
526
537
|
after_integration: last?.integration_id ?? "",
|
|
@@ -556,7 +567,7 @@ var recordFailedImport2 = async (replay, id, url, error) => {
|
|
|
556
567
|
};
|
|
557
568
|
var registrationOf = async (replay, id) => {
|
|
558
569
|
const row = RegistrationRowSchema.optional().parse(rowsOf(await replay("integrations/registration", { id }))[0]);
|
|
559
|
-
return { approved: row?.status === "approved",
|
|
570
|
+
return { approved: row?.status === "approved", hasKey: typeof row?.key_hash === "string" && row.key_hash !== "" };
|
|
560
571
|
};
|
|
561
572
|
var importedRow = ({ id, url, bundle, extension }) => ({
|
|
562
573
|
id,
|
|
@@ -592,7 +603,7 @@ var setBackToPending2 = async (replay, id, why) => {
|
|
|
592
603
|
var removeIntegration = async (replay, id) => {
|
|
593
604
|
await replay("integrations/remove", { id });
|
|
594
605
|
};
|
|
595
|
-
var integrationByKey = async (replay, key) =>
|
|
606
|
+
var integrationByKey = async (replay, key) => KeyOwnerRowSchema.optional().parse(rowsOf(await replay("integrations/by-key", { key_hash: hashIntegrationKey(key) }))[0])?.id;
|
|
596
607
|
var listIntegrations = async (replay) => {
|
|
597
608
|
const listed = await everyRow(ListedRowSchema, (after) => replay("integrations/list", { after: after?.id ?? "" }));
|
|
598
609
|
const counted = await everyRow(ActionCountRowSchema, (after) => replay("integrations/action-counts", { after: after?.integration_id ?? "" }));
|
|
@@ -708,12 +719,12 @@ var register = (deps, routes) => {
|
|
|
708
719
|
await recordFailedImport2(deps.replay, id, url, taken.error);
|
|
709
720
|
return c.json(taken.answer, taken.status);
|
|
710
721
|
}
|
|
711
|
-
const { approved: wasApproved,
|
|
722
|
+
const { approved: wasApproved, hasKey } = await registrationOf(deps.replay, id);
|
|
712
723
|
if (wasApproved) {
|
|
713
724
|
const refusal = deps.refusalOf({ ...deps.actions(), ...taken.bundle.actions });
|
|
714
725
|
if (refusal !== void 0) return c.json({ message: "Refused \u2014 the app would not serve this.", reasons: [`Error: ${refusal}`] }, 422);
|
|
715
726
|
}
|
|
716
|
-
const key =
|
|
727
|
+
const key = hasKey ? void 0 : mintIntegrationKey();
|
|
717
728
|
const { keptKey } = await writeBundle2(deps.replay, {
|
|
718
729
|
id,
|
|
719
730
|
url,
|
|
@@ -798,10 +809,8 @@ var buildContract = (host, integrationId) => {
|
|
|
798
809
|
const components = Object.keys(registered).sort().map((name) => paletteEntryOf(name, componentMetaOf(registered[name]?.meta)));
|
|
799
810
|
const audiences = /* @__PURE__ */ new Set();
|
|
800
811
|
for (const def of Object.values(host.charter)) {
|
|
801
|
-
if (def === void 0
|
|
802
|
-
const
|
|
803
|
-
const list2 = Array.isArray(selection) ? selection : selection?.allow ?? [];
|
|
804
|
-
for (const entry of list2) {
|
|
812
|
+
if (Array.isArray(def) || def?.actions === void 0) continue;
|
|
813
|
+
for (const entry of normalizeRole(def, "actions").allow) {
|
|
805
814
|
const parts = entry.split(".");
|
|
806
815
|
if (parts[0] === "ext" && parts[1] !== void 0 && parts[1] !== "*") audiences.add(parts[1]);
|
|
807
816
|
}
|