@tinycloud/operations 0.7.0-beta.31 → 0.7.0-beta.33

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.
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/revoked-grant.ts
21
+ var revoked_grant_exports = {};
22
+ __export(revoked_grant_exports, {
23
+ REVOKED_GRANT_MESSAGE: () => REVOKED_GRANT_MESSAGE,
24
+ isRevokedGrantRefusal: () => isRevokedGrantRefusal
25
+ });
26
+ module.exports = __toCommonJS(revoked_grant_exports);
27
+ var import_sdk_services = require("@tinycloud/sdk-services");
28
+
29
+ // src/cli-name.ts
30
+ var import_node_path = require("path");
31
+ var CLI_NAME = (0, import_node_path.basename)(process.argv[1] ?? "") === "tinycloud" ? "tinycloud" : "tc";
32
+
33
+ // src/revoked-grant.ts
34
+ var MAX_CAUSE_DEPTH = 8;
35
+ var REVOKED_GRANT_BODY = /\b401 - (?:Invalid invocation: )?delegation-(?:revoked: [A-Za-z0-9]+|ancestor-revoked: ancestor=[A-Za-z0-9]+ invoked=[A-Za-z0-9]+)\s*$/;
36
+ var REVOKED_GRANT_CODES = /* @__PURE__ */ new Set(["AUTH_DELEGATION_REVOKED", "AUTH_DELEGATION_ANCESTOR_REVOKED"]);
37
+ var REVOKED_GRANT_MESSAGE = `This grant was revoked. Ask the owner for a new grant (\`${CLI_NAME} auth request ...\`).`;
38
+ function isRevokedGrantRefusal(error) {
39
+ if ((0, import_sdk_services.authorizationVerdictOf)(error) !== "unauthenticated") return false;
40
+ const seen = /* @__PURE__ */ new Set();
41
+ let node = error;
42
+ for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof node === "object" && node !== null && !seen.has(node); depth += 1) {
43
+ seen.add(node);
44
+ const { code, message, cause } = node;
45
+ if (REVOKED_GRANT_CODES.has(code)) return true;
46
+ if (typeof message === "string" && REVOKED_GRANT_BODY.test(message)) return true;
47
+ node = cause;
48
+ }
49
+ return false;
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ REVOKED_GRANT_MESSAGE,
54
+ isRevokedGrantRefusal
55
+ });
56
+ //# sourceMappingURL=revoked-grant.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/revoked-grant.ts","../src/cli-name.ts"],"sourcesContent":["import { authorizationVerdictOf } from \"@tinycloud/sdk-services\";\nimport { CLI_NAME } from \"./cli-name.js\";\n\n/** Cause links read for the node's refusal; the SDK wraps it, so it is rarely the outermost error. */\nconst MAX_CAUSE_DEPTH = 8;\n/**\n * The node's whole 401 body for a revoked chain (`delegation-revoked: <cid>`, or\n * `delegation-ancestor-revoked: ancestor=<cid> invoked=<cid>`; older nodes prefix `Invalid invocation: `),\n * as it ends an SDK error message (`<what failed>: 401 - <body>`). The match starts at the `401 - ` separator\n * and runs to the end of the message, and only letters and digits may follow the error kind (the CIDs are not\n * checked beyond that), so a key or path in another 401 body (`Unauthorized Action: <space>/kv/…/delegation-revoked/ / …`)\n * or any other text that mentions \"revoked\" does not match.\n */\nconst REVOKED_GRANT_BODY =\n /\\b401 - (?:Invalid invocation: )?delegation-(?:revoked: [A-Za-z0-9]+|ancestor-revoked: ancestor=[A-Za-z0-9]+ invoked=[A-Za-z0-9]+)\\s*$/;\n/** The KV service's own typed codes for the same two bodies. */\nconst REVOKED_GRANT_CODES: ReadonlySet<unknown> = new Set([\"AUTH_DELEGATION_REVOKED\", \"AUTH_DELEGATION_ANCESTOR_REVOKED\"]);\n\nexport const REVOKED_GRANT_MESSAGE =\n `This grant was revoked. Ask the owner for a new grant (\\`${CLI_NAME} auth request ...\\`).`;\n\n/**\n * Whether a node refusal says the presented grant (or one it was derived from) was revoked.\n * Status alone cannot tell this from a stale session, so it also needs the typed code or the node's own\n * `delegation-revoked` / `delegation-ancestor-revoked` 401 body; any other 401 keeps its meaning.\n */\nexport function isRevokedGrantRefusal(error: unknown): boolean {\n if (authorizationVerdictOf(error) !== \"unauthenticated\") return false;\n const seen = new Set<unknown>();\n let node: unknown = error;\n for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof node === \"object\" && node !== null && !seen.has(node); depth += 1) {\n seen.add(node);\n const { code, message, cause } = node as { code?: unknown; message?: unknown; cause?: unknown };\n if (REVOKED_GRANT_CODES.has(code)) return true;\n if (typeof message === \"string\" && REVOKED_GRANT_BODY.test(message)) return true;\n node = cause;\n }\n return false;\n}\n","import { basename } from \"node:path\";\n\n/**\n * The command name hints and messages tell users to run. The CLI installs as\n * both `tc` and `tinycloud` (Ubuntu's iproute2 ships `/usr/sbin/tc`), so the\n * name follows the invoked bin. Any other host process, such as the MCP server,\n * gets `tc`.\n */\nexport const CLI_NAME = basename(process.argv[1] ?? \"\") === \"tinycloud\" ? \"tinycloud\" : \"tc\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuC;;;ACAvC,uBAAyB;AAQlB,IAAM,eAAW,2BAAS,QAAQ,KAAK,CAAC,KAAK,EAAE,MAAM,cAAc,cAAc;;;ADJxF,IAAM,kBAAkB;AASxB,IAAM,qBACJ;AAEF,IAAM,sBAA4C,oBAAI,IAAI,CAAC,2BAA2B,kCAAkC,CAAC;AAElH,IAAM,wBACX,4DAA4D,QAAQ;AAO/D,SAAS,sBAAsB,OAAyB;AAC7D,UAAI,4CAAuB,KAAK,MAAM,kBAAmB,QAAO;AAChE,QAAM,OAAO,oBAAI,IAAa;AAC9B,MAAI,OAAgB;AACpB,WAAS,QAAQ,GAAG,QAAQ,mBAAmB,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,KAAK,IAAI,IAAI,GAAG,SAAS,GAAG;AACvH,SAAK,IAAI,IAAI;AACb,UAAM,EAAE,MAAM,SAAS,MAAM,IAAI;AACjC,QAAI,oBAAoB,IAAI,IAAI,EAAG,QAAO;AAC1C,QAAI,OAAO,YAAY,YAAY,mBAAmB,KAAK,OAAO,EAAG,QAAO;AAC5E,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,9 @@
1
+ declare const REVOKED_GRANT_MESSAGE: string;
2
+ /**
3
+ * Whether a node refusal says the presented grant (or one it was derived from) was revoked.
4
+ * Status alone cannot tell this from a stale session, so it also needs the typed code or the node's own
5
+ * `delegation-revoked` / `delegation-ancestor-revoked` 401 body; any other 401 keeps its meaning.
6
+ */
7
+ declare function isRevokedGrantRefusal(error: unknown): boolean;
8
+
9
+ export { REVOKED_GRANT_MESSAGE, isRevokedGrantRefusal };
@@ -0,0 +1,9 @@
1
+ declare const REVOKED_GRANT_MESSAGE: string;
2
+ /**
3
+ * Whether a node refusal says the presented grant (or one it was derived from) was revoked.
4
+ * Status alone cannot tell this from a stale session, so it also needs the typed code or the node's own
5
+ * `delegation-revoked` / `delegation-ancestor-revoked` 401 body; any other 401 keeps its meaning.
6
+ */
7
+ declare function isRevokedGrantRefusal(error: unknown): boolean;
8
+
9
+ export { REVOKED_GRANT_MESSAGE, isRevokedGrantRefusal };
@@ -0,0 +1,30 @@
1
+ // src/revoked-grant.ts
2
+ import { authorizationVerdictOf } from "@tinycloud/sdk-services";
3
+
4
+ // src/cli-name.ts
5
+ import { basename } from "path";
6
+ var CLI_NAME = basename(process.argv[1] ?? "") === "tinycloud" ? "tinycloud" : "tc";
7
+
8
+ // src/revoked-grant.ts
9
+ var MAX_CAUSE_DEPTH = 8;
10
+ var REVOKED_GRANT_BODY = /\b401 - (?:Invalid invocation: )?delegation-(?:revoked: [A-Za-z0-9]+|ancestor-revoked: ancestor=[A-Za-z0-9]+ invoked=[A-Za-z0-9]+)\s*$/;
11
+ var REVOKED_GRANT_CODES = /* @__PURE__ */ new Set(["AUTH_DELEGATION_REVOKED", "AUTH_DELEGATION_ANCESTOR_REVOKED"]);
12
+ var REVOKED_GRANT_MESSAGE = `This grant was revoked. Ask the owner for a new grant (\`${CLI_NAME} auth request ...\`).`;
13
+ function isRevokedGrantRefusal(error) {
14
+ if (authorizationVerdictOf(error) !== "unauthenticated") return false;
15
+ const seen = /* @__PURE__ */ new Set();
16
+ let node = error;
17
+ for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof node === "object" && node !== null && !seen.has(node); depth += 1) {
18
+ seen.add(node);
19
+ const { code, message, cause } = node;
20
+ if (REVOKED_GRANT_CODES.has(code)) return true;
21
+ if (typeof message === "string" && REVOKED_GRANT_BODY.test(message)) return true;
22
+ node = cause;
23
+ }
24
+ return false;
25
+ }
26
+ export {
27
+ REVOKED_GRANT_MESSAGE,
28
+ isRevokedGrantRefusal
29
+ };
30
+ //# sourceMappingURL=revoked-grant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/revoked-grant.ts","../src/cli-name.ts"],"sourcesContent":["import { authorizationVerdictOf } from \"@tinycloud/sdk-services\";\nimport { CLI_NAME } from \"./cli-name.js\";\n\n/** Cause links read for the node's refusal; the SDK wraps it, so it is rarely the outermost error. */\nconst MAX_CAUSE_DEPTH = 8;\n/**\n * The node's whole 401 body for a revoked chain (`delegation-revoked: <cid>`, or\n * `delegation-ancestor-revoked: ancestor=<cid> invoked=<cid>`; older nodes prefix `Invalid invocation: `),\n * as it ends an SDK error message (`<what failed>: 401 - <body>`). The match starts at the `401 - ` separator\n * and runs to the end of the message, and only letters and digits may follow the error kind (the CIDs are not\n * checked beyond that), so a key or path in another 401 body (`Unauthorized Action: <space>/kv/…/delegation-revoked/ / …`)\n * or any other text that mentions \"revoked\" does not match.\n */\nconst REVOKED_GRANT_BODY =\n /\\b401 - (?:Invalid invocation: )?delegation-(?:revoked: [A-Za-z0-9]+|ancestor-revoked: ancestor=[A-Za-z0-9]+ invoked=[A-Za-z0-9]+)\\s*$/;\n/** The KV service's own typed codes for the same two bodies. */\nconst REVOKED_GRANT_CODES: ReadonlySet<unknown> = new Set([\"AUTH_DELEGATION_REVOKED\", \"AUTH_DELEGATION_ANCESTOR_REVOKED\"]);\n\nexport const REVOKED_GRANT_MESSAGE =\n `This grant was revoked. Ask the owner for a new grant (\\`${CLI_NAME} auth request ...\\`).`;\n\n/**\n * Whether a node refusal says the presented grant (or one it was derived from) was revoked.\n * Status alone cannot tell this from a stale session, so it also needs the typed code or the node's own\n * `delegation-revoked` / `delegation-ancestor-revoked` 401 body; any other 401 keeps its meaning.\n */\nexport function isRevokedGrantRefusal(error: unknown): boolean {\n if (authorizationVerdictOf(error) !== \"unauthenticated\") return false;\n const seen = new Set<unknown>();\n let node: unknown = error;\n for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof node === \"object\" && node !== null && !seen.has(node); depth += 1) {\n seen.add(node);\n const { code, message, cause } = node as { code?: unknown; message?: unknown; cause?: unknown };\n if (REVOKED_GRANT_CODES.has(code)) return true;\n if (typeof message === \"string\" && REVOKED_GRANT_BODY.test(message)) return true;\n node = cause;\n }\n return false;\n}\n","import { basename } from \"node:path\";\n\n/**\n * The command name hints and messages tell users to run. The CLI installs as\n * both `tc` and `tinycloud` (Ubuntu's iproute2 ships `/usr/sbin/tc`), so the\n * name follows the invoked bin. Any other host process, such as the MCP server,\n * gets `tc`.\n */\nexport const CLI_NAME = basename(process.argv[1] ?? \"\") === \"tinycloud\" ? \"tinycloud\" : \"tc\";\n"],"mappings":";AAAA,SAAS,8BAA8B;;;ACAvC,SAAS,gBAAgB;AAQlB,IAAM,WAAW,SAAS,QAAQ,KAAK,CAAC,KAAK,EAAE,MAAM,cAAc,cAAc;;;ADJxF,IAAM,kBAAkB;AASxB,IAAM,qBACJ;AAEF,IAAM,sBAA4C,oBAAI,IAAI,CAAC,2BAA2B,kCAAkC,CAAC;AAElH,IAAM,wBACX,4DAA4D,QAAQ;AAO/D,SAAS,sBAAsB,OAAyB;AAC7D,MAAI,uBAAuB,KAAK,MAAM,kBAAmB,QAAO;AAChE,QAAM,OAAO,oBAAI,IAAa;AAC9B,MAAI,OAAgB;AACpB,WAAS,QAAQ,GAAG,QAAQ,mBAAmB,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,KAAK,IAAI,IAAI,GAAG,SAAS,GAAG;AACvH,SAAK,IAAI,IAAI;AACb,UAAM,EAAE,MAAM,SAAS,MAAM,IAAI;AACjC,QAAI,oBAAoB,IAAI,IAAI,EAAG,QAAO;AAC1C,QAAI,OAAO,YAAY,YAAY,mBAAmB,KAAK,OAAO,EAAG,QAAO;AAC5E,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/operations",
3
- "version": "0.7.0-beta.31",
3
+ "version": "0.7.0-beta.33",
4
4
  "description": "TinyCloud shared operations contracts and runtime",
5
5
  "author": "TinyCloud, Inc.",
6
6
  "license": "EGPL",
@@ -54,6 +54,11 @@
54
54
  "import": "./dist/recovery.js",
55
55
  "require": "./dist/recovery.cjs"
56
56
  },
57
+ "./revoked-grant": {
58
+ "types": "./dist/revoked-grant.d.ts",
59
+ "import": "./dist/revoked-grant.js",
60
+ "require": "./dist/revoked-grant.cjs"
61
+ },
57
62
  "./cli-name": {
58
63
  "types": "./dist/cli-name.d.ts",
59
64
  "import": "./dist/cli-name.js",
@@ -75,7 +80,7 @@
75
80
  "coverage.json"
76
81
  ],
77
82
  "scripts": {
78
- "build": "tsup --entry src/index.ts --entry src/state.ts --entry src/artifacts.ts --entry src/cli-runtime.ts --entry src/profile.ts --entry src/secret-capabilities.ts --entry src/delegation-binding.ts --entry src/secret-request.ts --entry src/recovery.ts --entry src/cli-name.ts --entry src/tc-apps.ts",
83
+ "build": "tsup --entry src/index.ts --entry src/state.ts --entry src/artifacts.ts --entry src/cli-runtime.ts --entry src/profile.ts --entry src/secret-capabilities.ts --entry src/delegation-binding.ts --entry src/secret-request.ts --entry src/recovery.ts --entry src/cli-name.ts --entry src/revoked-grant.ts --entry src/tc-apps.ts",
79
84
  "clean": "rm -rf dist",
80
85
  "test": "bun scripts/test.ts",
81
86
  "typecheck": "tsc -p tsconfig.typecheck.json",
@@ -84,7 +89,7 @@
84
89
  "check:generated": "bun scripts/generate.ts --check"
85
90
  },
86
91
  "dependencies": {
87
- "@tinycloud/node-sdk": "3.3.0-beta.34",
92
+ "@tinycloud/node-sdk": "3.3.0-beta.35",
88
93
  "@tinycloud/sdk-core": "3.3.0-beta.31",
89
94
  "@tinycloud/sdk-services": "3.3.0-beta.25",
90
95
  "node-sql-parser": "5.4.0",