@didit-protocol/mcp-server 4.0.0 → 5.1.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.
Files changed (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +583 -227
  3. package/dist/audit-log.d.ts +22 -0
  4. package/dist/audit-log.d.ts.map +1 -0
  5. package/dist/audit-log.js +77 -0
  6. package/dist/audit-log.js.map +1 -0
  7. package/dist/auth/introspection-verifier.d.ts +16 -0
  8. package/dist/auth/introspection-verifier.d.ts.map +1 -0
  9. package/dist/auth/introspection-verifier.js +77 -0
  10. package/dist/auth/introspection-verifier.js.map +1 -0
  11. package/dist/auth/verifier.d.ts +19 -0
  12. package/dist/auth/verifier.d.ts.map +1 -0
  13. package/dist/auth/verifier.js +88 -0
  14. package/dist/auth/verifier.js.map +1 -0
  15. package/dist/blank-args.d.ts +10 -0
  16. package/dist/blank-args.d.ts.map +1 -0
  17. package/dist/blank-args.js +34 -0
  18. package/dist/blank-args.js.map +1 -0
  19. package/dist/chatgpt-app.d.ts +44 -0
  20. package/dist/chatgpt-app.d.ts.map +1 -0
  21. package/dist/chatgpt-app.js +52 -0
  22. package/dist/chatgpt-app.js.map +1 -0
  23. package/dist/config.d.ts +93 -5
  24. package/dist/config.d.ts.map +1 -1
  25. package/dist/config.js +198 -27
  26. package/dist/config.js.map +1 -1
  27. package/dist/dates.d.ts +2 -0
  28. package/dist/dates.d.ts.map +1 -0
  29. package/dist/dates.js +23 -0
  30. package/dist/dates.js.map +1 -0
  31. package/dist/feature-config-schema.d.ts +66 -0
  32. package/dist/feature-config-schema.d.ts.map +1 -0
  33. package/dist/feature-config-schema.js +192 -0
  34. package/dist/feature-config-schema.js.map +1 -0
  35. package/dist/http.d.ts +4 -0
  36. package/dist/http.d.ts.map +1 -0
  37. package/dist/http.js +230 -0
  38. package/dist/http.js.map +1 -0
  39. package/dist/index.d.ts +20 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +2383 -510
  42. package/dist/index.js.map +1 -1
  43. package/dist/internal-tools.d.ts +17 -0
  44. package/dist/internal-tools.d.ts.map +1 -0
  45. package/dist/internal-tools.js +26 -0
  46. package/dist/internal-tools.js.map +1 -0
  47. package/dist/mcp-modern.d.ts +36 -0
  48. package/dist/mcp-modern.d.ts.map +1 -0
  49. package/dist/mcp-modern.js +152 -0
  50. package/dist/mcp-modern.js.map +1 -0
  51. package/dist/orgapp.d.ts +34 -0
  52. package/dist/orgapp.d.ts.map +1 -0
  53. package/dist/orgapp.js +93 -0
  54. package/dist/orgapp.js.map +1 -0
  55. package/dist/permissions.d.ts +24 -0
  56. package/dist/permissions.d.ts.map +1 -0
  57. package/dist/permissions.js +210 -0
  58. package/dist/permissions.js.map +1 -0
  59. package/dist/privileged-tools.d.ts +14 -0
  60. package/dist/privileged-tools.d.ts.map +1 -0
  61. package/dist/privileged-tools.js +21 -0
  62. package/dist/privileged-tools.js.map +1 -0
  63. package/dist/schema/feature-config-schema.json +4446 -0
  64. package/dist/security.d.ts +168 -0
  65. package/dist/security.d.ts.map +1 -0
  66. package/dist/security.js +858 -0
  67. package/dist/security.js.map +1 -0
  68. package/dist/session-pdf-download.d.ts +8 -0
  69. package/dist/session-pdf-download.d.ts.map +1 -0
  70. package/dist/session-pdf-download.js +91 -0
  71. package/dist/session-pdf-download.js.map +1 -0
  72. package/dist/tools/analytics.d.ts +13 -0
  73. package/dist/tools/analytics.d.ts.map +1 -0
  74. package/dist/tools/analytics.js +171 -0
  75. package/dist/tools/analytics.js.map +1 -0
  76. package/dist/tools/auth.d.ts +10 -3
  77. package/dist/tools/auth.d.ts.map +1 -1
  78. package/dist/tools/auth.js +68 -11
  79. package/dist/tools/auth.js.map +1 -1
  80. package/dist/tools/billing.d.ts +2 -2
  81. package/dist/tools/billing.d.ts.map +1 -1
  82. package/dist/tools/billing.js +37 -4
  83. package/dist/tools/billing.js.map +1 -1
  84. package/dist/tools/blocklist.d.ts +5 -0
  85. package/dist/tools/blocklist.d.ts.map +1 -0
  86. package/dist/tools/blocklist.js +21 -0
  87. package/dist/tools/blocklist.js.map +1 -0
  88. package/dist/tools/businesses.d.ts +1 -1
  89. package/dist/tools/businesses.d.ts.map +1 -1
  90. package/dist/tools/businesses.js +31 -9
  91. package/dist/tools/businesses.js.map +1 -1
  92. package/dist/tools/cases.d.ts +6 -0
  93. package/dist/tools/cases.d.ts.map +1 -0
  94. package/dist/tools/cases.js +63 -0
  95. package/dist/tools/cases.js.map +1 -0
  96. package/dist/tools/compliance.d.ts +8 -0
  97. package/dist/tools/compliance.d.ts.map +1 -0
  98. package/dist/tools/compliance.js +95 -0
  99. package/dist/tools/compliance.js.map +1 -0
  100. package/dist/tools/context.d.ts +2 -0
  101. package/dist/tools/context.d.ts.map +1 -0
  102. package/dist/tools/context.js +37 -0
  103. package/dist/tools/context.js.map +1 -0
  104. package/dist/tools/customization.d.ts +10 -4
  105. package/dist/tools/customization.d.ts.map +1 -1
  106. package/dist/tools/customization.js +21 -11
  107. package/dist/tools/customization.js.map +1 -1
  108. package/dist/tools/feature-config.d.ts +53 -0
  109. package/dist/tools/feature-config.d.ts.map +1 -0
  110. package/dist/tools/feature-config.js +432 -0
  111. package/dist/tools/feature-config.js.map +1 -0
  112. package/dist/tools/lists.d.ts.map +1 -1
  113. package/dist/tools/lists.js +17 -16
  114. package/dist/tools/lists.js.map +1 -1
  115. package/dist/tools/members.d.ts +7 -0
  116. package/dist/tools/members.d.ts.map +1 -0
  117. package/dist/tools/members.js +60 -0
  118. package/dist/tools/members.js.map +1 -0
  119. package/dist/tools/observability.d.ts +4 -0
  120. package/dist/tools/observability.d.ts.map +1 -0
  121. package/dist/tools/observability.js +17 -0
  122. package/dist/tools/observability.js.map +1 -0
  123. package/dist/tools/questionnaires.d.ts +61 -3
  124. package/dist/tools/questionnaires.d.ts.map +1 -1
  125. package/dist/tools/questionnaires.js +130 -6
  126. package/dist/tools/questionnaires.js.map +1 -1
  127. package/dist/tools/reports.d.ts +5 -0
  128. package/dist/tools/reports.d.ts.map +1 -0
  129. package/dist/tools/reports.js +89 -0
  130. package/dist/tools/reports.js.map +1 -0
  131. package/dist/tools/search.d.ts +30 -0
  132. package/dist/tools/search.d.ts.map +1 -0
  133. package/dist/tools/search.js +317 -0
  134. package/dist/tools/search.js.map +1 -0
  135. package/dist/tools/session-explain-levers.d.ts +17 -0
  136. package/dist/tools/session-explain-levers.d.ts.map +1 -0
  137. package/dist/tools/session-explain-levers.js +139 -0
  138. package/dist/tools/session-explain-levers.js.map +1 -0
  139. package/dist/tools/session-explain.d.ts +3 -0
  140. package/dist/tools/session-explain.d.ts.map +1 -0
  141. package/dist/tools/session-explain.js +180 -0
  142. package/dist/tools/session-explain.js.map +1 -0
  143. package/dist/tools/sessions.d.ts +9 -2
  144. package/dist/tools/sessions.d.ts.map +1 -1
  145. package/dist/tools/sessions.js +131 -22
  146. package/dist/tools/sessions.js.map +1 -1
  147. package/dist/tools/settings.d.ts +15 -1
  148. package/dist/tools/settings.d.ts.map +1 -1
  149. package/dist/tools/settings.js +143 -6
  150. package/dist/tools/settings.js.map +1 -1
  151. package/dist/tools/standalone.d.ts +7 -6
  152. package/dist/tools/standalone.d.ts.map +1 -1
  153. package/dist/tools/standalone.js +41 -26
  154. package/dist/tools/standalone.js.map +1 -1
  155. package/dist/tools/transactions.d.ts +9 -0
  156. package/dist/tools/transactions.d.ts.map +1 -1
  157. package/dist/tools/transactions.js +77 -4
  158. package/dist/tools/transactions.js.map +1 -1
  159. package/dist/tools/users.d.ts +1 -1
  160. package/dist/tools/users.d.ts.map +1 -1
  161. package/dist/tools/users.js +30 -9
  162. package/dist/tools/users.js.map +1 -1
  163. package/dist/tools/webhooks.d.ts.map +1 -1
  164. package/dist/tools/webhooks.js +22 -5
  165. package/dist/tools/webhooks.js.map +1 -1
  166. package/dist/tools/workflow-graph.d.ts +65 -0
  167. package/dist/tools/workflow-graph.d.ts.map +1 -0
  168. package/dist/tools/workflow-graph.js +686 -0
  169. package/dist/tools/workflow-graph.js.map +1 -0
  170. package/package.json +23 -6
@@ -0,0 +1,34 @@
1
+ export interface AppRef {
2
+ appId: string;
3
+ appName: string;
4
+ /** "live" | "sandbox" — the application's mode, as the auth API reports it. Carried through
5
+ * because "am I about to bill this customer?" is unanswerable without it: sandbox sessions are
6
+ * never billed and mock every provider, and a copilot that cannot see this told a customer she
7
+ * was testing in sandbox while it drove her live application. Absent when the API omits it. */
8
+ mode?: string;
9
+ }
10
+ export interface OrgRef {
11
+ orgId: string;
12
+ orgName: string;
13
+ apps: AppRef[];
14
+ /** listApplications failed for this org — its apps are UNKNOWN, not empty. */
15
+ appsError?: boolean;
16
+ }
17
+ /** The caller's organizations with their applications nested, cached per token (60s TTL). */
18
+ export declare function getOrgAppMap(forceRefresh?: boolean): Promise<OrgRef[]>;
19
+ /** Run `fn` with the request context scoped to a specific (org, app) so the existing
20
+ * per-app tools resolve orgAppPath() and the X-Didit-Organization-Id header correctly. */
21
+ export declare function runForScope<R>(orgId: string, appId: string | undefined, fn: () => Promise<R>): Promise<R>;
22
+ /** Bounded-parallel map — caps concurrent fan-out so we don't hammer the API. */
23
+ export declare function mapWithConcurrency<T, R>(items: T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
24
+ export declare const ORG_APP_PROPS: {
25
+ readonly organization_id: {
26
+ readonly type: "string";
27
+ readonly description: "Organization UUID (from didit_org_list). Optional if your token has a single/default org.";
28
+ };
29
+ readonly application_id: {
30
+ readonly type: "string";
31
+ readonly description: "Application UUID (from didit_context_get). Optional when you own exactly one application - it is resolved automatically, even if you belong to several organizations.";
32
+ };
33
+ };
34
+ //# sourceMappingURL=orgapp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgapp.d.ts","sourceRoot":"","sources":["../src/orgapp.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB;;;oGAGgG;IAChG,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAkDD,6FAA6F;AAC7F,wBAAsB,YAAY,CAAC,YAAY,UAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ1E;AAED;2FAC2F;AAC3F,wBAAsB,WAAW,CAAC,CAAC,EACjC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED,iFAAiF;AACjF,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAC3C,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,EAAE,CAAC,CAYd;AAMD,eAAO,MAAM,aAAa;;;;;;;;;CAShB,CAAC"}
package/dist/orgapp.js ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ORG_APP_PROPS = void 0;
4
+ exports.getOrgAppMap = getOrgAppMap;
5
+ exports.runForScope = runForScope;
6
+ exports.mapWithConcurrency = mapWithConcurrency;
7
+ const config_1 = require("./config");
8
+ const auth_1 = require("./tools/auth");
9
+ // Keyed by the caller's access token; the MCP process is long-lived so module state
10
+ // persists across the per-request Server instances. Short TTL keeps it fresh.
11
+ const orgAppCache = new Map();
12
+ const TTL_MS = 60000;
13
+ function extractResults(payload) {
14
+ if (Array.isArray(payload))
15
+ return payload;
16
+ if (payload && Array.isArray(payload.results))
17
+ return payload.results;
18
+ if (payload && Array.isArray(payload.organizations))
19
+ return payload.organizations;
20
+ if (payload && Array.isArray(payload.applications))
21
+ return payload.applications;
22
+ return [];
23
+ }
24
+ const idOf = (o) => o?.uuid ?? o?.id ?? o?.organization_id ?? o?.application_id;
25
+ const nameOf = (o) => o?.name ?? o?.display_name ?? idOf(o) ?? "";
26
+ const modeOf = (o) => typeof o?.mode === "string" && o.mode ? { mode: o.mode } : {};
27
+ async function buildOrgAppMap() {
28
+ const orgs = extractResults(await (0, auth_1.listOrganizations)());
29
+ const refs = await Promise.all(orgs.map(async (o) => {
30
+ const orgId = idOf(o);
31
+ if (!orgId)
32
+ return null;
33
+ let apps = [];
34
+ let appsError = false;
35
+ try {
36
+ apps = extractResults(await (0, auth_1.listApplications)(orgId))
37
+ .map((a) => {
38
+ const appId = idOf(a);
39
+ return appId ? { appId, appName: nameOf(a), ...modeOf(a) } : null;
40
+ })
41
+ .filter((a) => a !== null);
42
+ }
43
+ catch {
44
+ appsError = true; // org whose apps the caller can't list — leave it appless but flagged
45
+ }
46
+ return { orgId, orgName: nameOf(o), apps, ...(appsError ? { appsError } : {}) };
47
+ }));
48
+ return refs.filter((r) => r !== null);
49
+ }
50
+ /** The caller's organizations with their applications nested, cached per token (60s TTL). */
51
+ async function getOrgAppMap(forceRefresh = false) {
52
+ const token = config_1.requestContext.getStore()?.accessToken ?? "__stdio__";
53
+ const now = Date.now();
54
+ const cached = orgAppCache.get(token);
55
+ if (!forceRefresh && cached && cached.expires > now)
56
+ return cached.map;
57
+ const map = await buildOrgAppMap();
58
+ orgAppCache.set(token, { map, expires: now + TTL_MS });
59
+ return map;
60
+ }
61
+ /** Run `fn` with the request context scoped to a specific (org, app) so the existing
62
+ * per-app tools resolve orgAppPath() and the X-Didit-Organization-Id header correctly. */
63
+ async function runForScope(orgId, appId, fn) {
64
+ const ctx = config_1.requestContext.getStore();
65
+ return config_1.requestContext.run({ accessToken: ctx?.accessToken, organizationId: orgId, applicationId: appId }, fn);
66
+ }
67
+ /** Bounded-parallel map — caps concurrent fan-out so we don't hammer the API. */
68
+ async function mapWithConcurrency(items, limit, fn) {
69
+ const results = new Array(items.length);
70
+ let next = 0;
71
+ async function worker() {
72
+ for (let i = next++; i < items.length; i = next++) {
73
+ results[i] = await fn(items[i], i);
74
+ }
75
+ }
76
+ await Promise.all(Array.from({ length: Math.max(1, Math.min(limit, items.length)) }, () => worker()));
77
+ return results;
78
+ }
79
+ // Org/app selectors shared by the console (management) tools, which target
80
+ // /organization/{org}/application/{app}/... endpoints. Spread into each such tool's
81
+ // `properties`. Resolved (arg → token context → env default) by orgAppPath in config.ts;
82
+ // discover ids via didit_org_list / didit_org_list_applications.
83
+ exports.ORG_APP_PROPS = {
84
+ organization_id: {
85
+ type: "string",
86
+ description: "Organization UUID (from didit_org_list). Optional if your token has a single/default org.",
87
+ },
88
+ application_id: {
89
+ type: "string",
90
+ description: "Application UUID (from didit_context_get). Optional when you own exactly one application - it is resolved automatically, even if you belong to several organizations.",
91
+ },
92
+ };
93
+ //# sourceMappingURL=orgapp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgapp.js","sourceRoot":"","sources":["../src/orgapp.ts"],"names":[],"mappings":";;;AA4EA,oCAQC;AAID,kCAUC;AAGD,gDAgBC;AArHD,qCAA0C;AAC1C,uCAAmE;AA+BnE,oFAAoF;AACpF,8EAA8E;AAC9E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;AAClD,MAAM,MAAM,GAAG,KAAM,CAAC;AAEtB,SAAS,cAAc,CAAC,OAAY;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC3C,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC;IACtE,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC;QAA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,EAAE,QAAQ;QACd,WAAW,EAAE,uKAAuK;KACrL;CACO,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { DiditError } from "./security";
2
+ export type PermissionMode = "shadow" | "enforce" | "off";
3
+ export declare const TOOL_PERMISSIONS: Record<string, string | null>;
4
+ export type PermissionDecision = "allow" | "would_deny" | "deny";
5
+ export interface PermissionQuery {
6
+ tool: string;
7
+ /** `AuthInfo.scopes`: the introspected `org_permissions` plus OAuth scopes and claims. */
8
+ scopes: readonly string[] | undefined;
9
+ mode: PermissionMode;
10
+ /** The organization the token's permissions describe (`AuthInfo.extra.organization_id`). */
11
+ tokenOrg: string | undefined;
12
+ /** The organization the call acts in (explicit `organization_id` argument, else the token's). */
13
+ targetOrg: string | undefined;
14
+ }
15
+ /**
16
+ * `allow` when the tool needs no pre-check, the call targets an organization other than
17
+ * the one the token's permissions describe (a multi-org user routing by `organization_id`
18
+ * — we cannot judge that org), the token carries no permission strings, or it carries the
19
+ * required one. Otherwise `deny` in enforce mode and `would_deny` in shadow mode (the call
20
+ * proceeds, the audit line records the verdict).
21
+ */
22
+ export declare function decidePermission({ tool, scopes, mode, tokenOrg, targetOrg }: PermissionQuery): PermissionDecision;
23
+ export declare function missingPermissionError(tool: string): DiditError;
24
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAC;AAM1D,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA8J1D,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,YAAY,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,0FAA0F;IAC1F,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,cAAc,CAAC;IACrB,4FAA4F;IAC5F,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,iGAAiG;IACjG,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,eAAe,GAAG,kBAAkB,CAUjH;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAS/D"}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOOL_PERMISSIONS = void 0;
4
+ exports.decidePermission = decidePermission;
5
+ exports.missingPermissionError = missingPermissionError;
6
+ // Per-tool permission pre-check.
7
+ //
8
+ // The backend is the authoritative enforcer: every console endpoint the tools call is
9
+ // decorated with `@has_privileges(["<action>:<resource>"])` and refuses with a 403 when
10
+ // the caller's organization role lacks it. The introspected token already carries the
11
+ // caller's `org_permissions` (they arrive in `AuthInfo.scopes`), so the same decision can
12
+ // be taken HERE, before the request leaves: the model gets a `missing_scope` error naming
13
+ // the permission instead of an opaque 403, and tools/list can hide what the caller could
14
+ // never run. Defense in depth, same pattern as `isPrivilegedCaller`.
15
+ //
16
+ // TOOL_PERMISSIONS mirrors the backend decorators tool by tool (the PR that introduced it
17
+ // lists the endpoint behind every entry) — including their quirks, because a permission the
18
+ // backend does not actually check would block legitimate users. `null` means "no
19
+ // pre-check": endpoints without a decorator, membership-scoped ones (`/organizations/me/`),
20
+ // and everything that is not org/app-scoped. Unknown tools are never checked either.
21
+ const security_1 = require("./security");
22
+ const internal_tools_1 = require("./internal-tools");
23
+ /** Only the backend's permission strings count; `scopes` also carries OAuth scopes and
24
+ * claims, and a token with none of the former (stdio env token) is not a role we can judge. */
25
+ const PERMISSION_RE = /^(read|write|delete|list|create|approve):[a-z-]+$/;
26
+ exports.TOOL_PERMISSIONS = {
27
+ // ── Auth service (apx.didit.me): membership-scoped or bootstrap, no @has_privileges ──
28
+ didit_account_login: null, // POST auth /programmatic/login/ — account bootstrap
29
+ didit_account_register: null, // POST auth /programmatic/register/ — account bootstrap
30
+ didit_account_resend_otp: null, // POST auth /programmatic/resend-otp/ — account bootstrap
31
+ didit_account_verify_2fa: null, // POST auth /2fa/verify/ — account bootstrap (login step-up)
32
+ didit_account_verify_email: null, // POST auth /programmatic/verify-email/ — account bootstrap
33
+ didit_context_get: null, // GET auth /organizations/me/ (+ applications) — membership-scoped
34
+ didit_org_get_application: null, // GET auth /organizations/me/{org}/applications/{app}/ — hardcoded owner/admin check, no decorator
35
+ didit_org_list: null, // GET auth /organizations/me/ — membership-scoped
36
+ didit_org_list_applications: null, // GET auth /organizations/me/{org}/applications/ — hardcoded owner/admin check, no decorator
37
+ didit_org_reveal_application_api_key: null, // same endpoint as didit_org_get_application
38
+ didit_org_invite_member: "write:members", // POST auth /organizations/{org}/members/invite/ → member.py:394
39
+ didit_org_list_api_keys: "read:applications", // GET auth /organizations/{org}/applications/{app}/api-keys/ → application_api_keys.py:24
40
+ didit_org_list_members: "list:members", // GET auth /organizations/{org}/members/ → member.py:141
41
+ didit_org_list_roles: "list:roles", // GET auth /organizations/{org}/roles/ → roles.py:55
42
+ didit_org_remove_member: "delete:members", // DELETE auth /organizations/{org}/members/{id}/ → member.py:109
43
+ didit_org_update_member: "write:members", // PATCH auth /organizations/{org}/members/{id}/ → member.py:76
44
+ // ── Billing ──
45
+ didit_org_get_balance: "read:subscription", // GET /organization/{org}/top-up/ → stripe.py:498
46
+ didit_org_top_up: null, // POST /organization/{org}/top-up/ — TopUpView has only GET/PUT as coded
47
+ // ── Alerts, analytics, audit ──
48
+ didit_alert_configure: "write:applications", // PATCH …/alerts/{type}/ → alerts.py:42
49
+ didit_alert_list: "read:applications", // GET …/alerts/ → alerts.py:62
50
+ didit_analytics: "read:analytics", // GET …/analytics/ → analytics.py:196
51
+ didit_audit_log_list: null, // GET …/audit-logs/ — app-scoped route does not exist as coded (real one: /audit/{org}/audit-logs/, read:audit-logs)
52
+ // ── Blocklist / allowlist ──
53
+ didit_allowlist_add: "write:blocklist", // POST …/allowlist/add/ → allowlist.py:33
54
+ didit_blocklist_add: "write:blocklist", // POST …/blocklist/add/ → blocklist.py:47
55
+ didit_blocklist_get: "read:blocklist", // GET …/blocklist/ → blocklist.py:178
56
+ didit_blocklist_remove: "write:blocklist", // POST …/blocklist/remove/ → blocklist.py:76
57
+ // ── Branding ──
58
+ didit_branding_get: "read:customization", // GET …/white-label-customization/ → white_label_customization.py:66
59
+ didit_branding_update: "write:customization", // PATCH …/white-label-customization/ → white_label_customization.py:73
60
+ // ── Cases ──
61
+ didit_case_create: "write:cases", // POST …/cases/ → case_management.py:292
62
+ didit_case_get: "read:cases", // GET …/cases/{id}/ → case_management.py:353
63
+ didit_case_list: "list:cases", // GET …/cases/ → case_management.py:264
64
+ didit_case_manage: "write:cases", // POST …/cases/{id}/{resolve|assign|reopen|escalate}/, PATCH …/cases/{id}/ → case_management.py
65
+ didit_case_search: "list:cases", // GET /organization/{org}/cases/ → case_management.py:264
66
+ didit_case_statistics: "list:cases", // GET …/cases/statistics/ → case_management.py:910
67
+ // ── Lists ──
68
+ didit_lists_create: "create:lists", // POST …/lists/ → lists.py:69
69
+ didit_lists_delete: "delete:lists", // DELETE …/lists/{uuid}/ → lists.py:122
70
+ didit_lists_entries_list: "read:lists", // GET …/lists/{uuid}/entries/ → lists.py:153
71
+ didit_lists_entry_create: "create:lists", // POST …/lists/{uuid}/entries/ → lists.py:197
72
+ didit_lists_entry_delete: "delete:lists", // DELETE …/lists/{uuid}/entries/{entry}/ → lists.py:233
73
+ didit_lists_entry_upload_face: "create:lists", // POST …/lists/{uuid}/entries/face-upload/ → list_face_upload.py:126
74
+ didit_lists_get: "read:lists", // GET …/lists/{uuid}/ → lists.py:110
75
+ didit_lists_list: "read:lists", // GET …/lists/ → lists.py:40
76
+ didit_lists_update: "write:lists", // PATCH …/lists/{uuid}/ → lists.py:114
77
+ // ── Questionnaires (delete reuses write) ──
78
+ didit_questionnaire_append_choices: "write:questionnaires", // PATCH …/questionnaires/{uuid}/ → questionnaire.py:208
79
+ didit_questionnaire_create: "write:questionnaires", // POST …/questionnaires/ → questionnaire.py:149
80
+ didit_questionnaire_delete: "write:questionnaires", // DELETE …/questionnaires/{uuid}/ → questionnaire.py:227
81
+ didit_questionnaire_get: "read:questionnaires", // GET …/questionnaires/{uuid}/ → questionnaire.py:204
82
+ didit_questionnaire_list: "read:questionnaires", // GET …/questionnaires/ → questionnaire.py:96
83
+ didit_questionnaire_update: "write:questionnaires", // PATCH …/questionnaires/{uuid}/ → questionnaire.py:208
84
+ // ── Reports (row-level access, @has_privileges([]) or per-kind) ──
85
+ didit_report_export: null, // POST …/reports/{kind}/ — permission varies by kind (read:sessions|transactions|businesses|users)
86
+ didit_report_get: null, // GET …/reports/{id}/ → reports.py:129, @has_privileges([]) + row-level check
87
+ didit_report_get_download_url: null, // GET …/reports/{id}/download-url/ → reports.py:153, same
88
+ didit_report_list: null, // GET …/reports/ → reports.py:100, same
89
+ // ── Sessions ──
90
+ didit_session_add_review: "write:sessions", // POST …/sessions/{id}/reviews/ → activity.py:97
91
+ didit_session_batch_delete: "delete:sessions", // DELETE …/sessions/delete/ → application.py:529
92
+ didit_session_create: null, // POST /session/ → session.py:152 — permission classes only, no decorator
93
+ didit_session_create_import: null, // POST /session/imports/ → imports.py:77 — no decorator
94
+ didit_session_delete: "delete:sessions", // DELETE /session/{id}/delete/ → session.py:1406
95
+ didit_session_generate_pdf: "read:sessions", // GET /session/{id}/generate-pdf/ → pdf.py:86
96
+ didit_session_get_decision: "read:sessions", // GET /session/{id}/decision/ → session.py:536
97
+ didit_session_get_import: null, // GET /session/imports/{id}/ → imports.py:170 — no decorator
98
+ didit_session_get_import_errors: null, // GET /session/imports/{id}/errors/ → imports.py:182 — no decorator
99
+ didit_session_get_import_template: null, // GET /session/imports/template/ → imports.py:197 — no decorator
100
+ didit_session_import_shared: null, // POST /session/import-shared/ → shared_session.py:78 — no decorator
101
+ didit_session_list: "list:sessions", // GET …/sessions/ → application.py:123
102
+ didit_session_list_reviews: "read:sessions", // GET …/sessions/{id}/reviews/ → activity.py:77
103
+ didit_session_search: "list:sessions", // GET /organization/{org}/sessions/ → application.py:448
104
+ didit_session_share: "write:sessions", // POST /session/{id}/share/ → shared_session.py:44
105
+ didit_session_update_data: "write:sessions", // PATCH /session/{id}/update-data/ → session.py:1238
106
+ didit_session_update_poa_data: "write:sessions", // PATCH /session/{id}/update-poa-data/ → session.py:1461
107
+ didit_session_update_status: "write:sessions", // PATCH /session/{id}/update-status/ → session.py:1033
108
+ didit_session_explain_decision: "read:sessions", // GET /session/{id}/decision/ folded into its trace
109
+ didit_session_webhooks: "read:sessions", // GET /session/{id}/webhooks/ → webhooks.py:38
110
+ didit_session_webhook_resend: "create:sessions", // POST /session/{id}/webhook/{uuid}/resend → webhooks.py:109
111
+ // ── Transactions (reads are gated by list:transactions) ──
112
+ didit_transaction_create: "create:transactions", // POST …/transactions/ → transactions.py:331
113
+ didit_transaction_get: "list:transactions", // GET …/transactions/{id}/ → transactions.py:479
114
+ didit_transaction_list: "list:transactions", // GET …/transactions/ → transactions.py:278
115
+ didit_transaction_rule_backtest: "list:transactions", // POST …/transactions/rules/backtest/ → transactions.py:816
116
+ didit_transaction_rule_create: "write:transactions", // POST …/transactions/rules/ → transactions.py:766
117
+ didit_transaction_rule_delete: "write:transactions", // DELETE …/transactions/rules/{uuid}/ → transactions.py:801
118
+ didit_transaction_rule_get: "list:transactions", // GET …/transactions/rules/{uuid}/ → transactions.py:785
119
+ didit_transaction_rule_install: "write:transactions", // POST …/transactions/rules/install/ → transactions.py:914
120
+ didit_transaction_rule_library_list: "list:transactions", // GET …/transactions/rules/library/ → transactions.py:895
121
+ didit_transaction_rule_list: "list:transactions", // GET …/transactions/rules/ → transactions.py:754
122
+ didit_transaction_rule_uninstall: "write:transactions", // DELETE …/transactions/rules/install/ → transactions.py:926
123
+ didit_transaction_rule_update: "write:transactions", // PATCH …/transactions/rules/{uuid}/ → transactions.py:790
124
+ didit_transaction_screen_wallet: "create:transactions", // POST …/transactions/screen-wallet/ → transactions.py:371
125
+ didit_transaction_search: "list:transactions", // GET /organization/{org}/transactions/ → transactions.py:278
126
+ // ── Vendor businesses (KYB) ──
127
+ didit_vendor_business_create: "create:businesses", // POST …/vendor-businesses/ → vendor_business.py:154
128
+ didit_vendor_business_delete: "delete:businesses", // DELETE …/vendor-businesses/delete/ → vendor_business.py:935
129
+ didit_vendor_business_get: "read:businesses", // GET …/vendor-businesses/{vendor_data}/ → vendor_business.py:197
130
+ didit_vendor_business_list: "list:businesses", // GET …/vendor-businesses/ → vendor_business.py:150
131
+ didit_vendor_business_search: "list:businesses", // per-app fan-out over the list endpoint
132
+ didit_vendor_business_update: null, // PATCH …/vendor-businesses/{vendor_data}/update/ — route does not exist as coded (only by-id/)
133
+ didit_vendor_business_update_status: "write:businesses", // POST …/vendor-businesses/bulk-status/ → vendor_business.py:965
134
+ // ── Vendor users ──
135
+ didit_vendor_user_create: "create:users", // POST …/vendor-users/ → vendor_user.py:330
136
+ didit_vendor_user_delete: "delete:users", // DELETE …/vendor-users/delete/ → vendor_user.py:1139
137
+ didit_vendor_user_get: "read:users", // GET …/vendor-users/{vendor_data}/ → vendor_user.py:763
138
+ didit_vendor_user_list: "list:users", // GET …/vendor-users/ → vendor_user.py:283
139
+ didit_vendor_user_search: "list:users", // per-app fan-out over the list endpoint
140
+ didit_vendor_user_update: "write:users", // PATCH …/vendor-users/{vendor_data}/update/ → vendor_user.py:1098
141
+ didit_vendor_user_update_status: "write:users", // POST …/vendor-users/bulk-status/ → vendor_user.py:1169
142
+ // ── Standalone verification APIs (proxy.py:36 gates every …/apis/* POST on create:sessions) ──
143
+ didit_verify_age: "create:sessions",
144
+ didit_verify_aml: "create:sessions",
145
+ didit_verify_database: "create:sessions",
146
+ didit_verify_email_check: null, // …/apis/email/check/ — route does not exist as coded (only /apis/email-risk/)
147
+ didit_verify_email_send: null, // …/apis/email/send/ — route does not exist as coded
148
+ didit_verify_face_match: "create:sessions",
149
+ didit_verify_face_search: "create:sessions",
150
+ didit_verify_id: "create:sessions",
151
+ didit_verify_kyb_search: "create:sessions",
152
+ didit_verify_kyb_select: "create:sessions",
153
+ didit_verify_passive_liveness: "create:sessions",
154
+ didit_verify_phone_check: null, // …/apis/phone/check/ — route does not exist as coded
155
+ didit_verify_phone_send: null, // …/apis/phone/send/ — route does not exist as coded
156
+ didit_verify_poa: "create:sessions",
157
+ // ── Webhooks (delete reuses write) ──
158
+ didit_webhook_create: "write:webhooks", // POST …/webhook/destinations/ → webhook_destinations.py:112
159
+ didit_webhook_delete: "write:webhooks", // DELETE …/webhook/destinations/{uuid}/ → webhook_destinations.py:181
160
+ didit_webhook_get: "read:webhooks", // GET …/webhook/destinations/{uuid}/ → webhook_destinations.py:151
161
+ didit_webhook_list: "read:webhooks", // GET …/webhook/destinations/ → webhook_destinations.py:106
162
+ didit_webhook_update: "write:webhooks", // PATCH …/webhook/destinations/{uuid}/ → webhook_destinations.py:160
163
+ // ── Workflows (delete reuses write; graph helpers are read-gated POSTs) ──
164
+ didit_workflow_build_graph: "read:workflows", // POST …/compliance/build-workflow/ → compliance.py:137
165
+ didit_workflow_create: "write:workflows", // POST …/verification-settings/ → verification_settings.py:146
166
+ didit_workflow_create_draft: "write:workflows", // POST …/verification-settings/{uuid}/create-draft/ → verification_settings.py:328
167
+ didit_workflow_delete: "write:workflows", // DELETE …/verification-settings/{uuid}/ → verification_settings.py:224
168
+ didit_workflow_edit_graph: "write:workflows", // PUT …/verification-settings/{uuid}/workflow-graph/ → workflow_graph.py:63
169
+ didit_workflow_get: "read:workflows", // GET …/verification-settings/{uuid}/ → verification_settings.py:214
170
+ didit_workflow_get_branch_fields: "read:workflows", // POST …/workflow-graph/branch-fields/ → workflow_graph.py:202
171
+ didit_workflow_get_feature_config_schema: null, // no backend call — bundled artifact
172
+ didit_workflow_get_field_definitions: "read:workflows", // GET …/workflow-graph/field-definitions/ → workflow_graph.py:451
173
+ didit_workflow_get_id_verification_methods_catalog: "read:workflows", // GET …/workflow-graph/id-verification-methods-catalog/ → workflow_graph.py
174
+ didit_workflow_get_kyb_registry_catalog: null, // GET /organization/kyb-registry-pricing/ → application.py KYBRegistryPricingView (anonymous, no privilege)
175
+ didit_workflow_get_graph: "read:workflows", // GET …/verification-settings/{uuid}/workflow-graph/ → workflow_graph.py:44
176
+ didit_workflow_list: "read:workflows", // GET …/verification-settings/ → verification_settings.py:74
177
+ didit_workflow_publish: "write:workflows", // PATCH …/verification-settings/{uuid}/ → verification_settings.py:219
178
+ didit_workflow_search: "read:workflows", // per-app fan-out over the list endpoint
179
+ didit_workflow_set_graph: "write:workflows", // PUT …/verification-settings/{uuid}/workflow-graph/ → workflow_graph.py:63
180
+ didit_workflow_update: "write:workflows", // PATCH …/verification-settings/{uuid}/ → verification_settings.py:219
181
+ didit_workflow_validate_graph: "read:workflows", // POST …/workflow-graph/validate/ → workflow_graph.py:142
182
+ // Internal-only families (compliance, travel rule, marketplace, networks, SDK token): empty in the public build.
183
+ ...internal_tools_1.INTERNAL_TOOL_PERMISSIONS,
184
+ };
185
+ /**
186
+ * `allow` when the tool needs no pre-check, the call targets an organization other than
187
+ * the one the token's permissions describe (a multi-org user routing by `organization_id`
188
+ * — we cannot judge that org), the token carries no permission strings, or it carries the
189
+ * required one. Otherwise `deny` in enforce mode and `would_deny` in shadow mode (the call
190
+ * proceeds, the audit line records the verdict).
191
+ */
192
+ function decidePermission({ tool, scopes, mode, tokenOrg, targetOrg }) {
193
+ const required = exports.TOOL_PERMISSIONS[tool];
194
+ const judgeable = Boolean(tokenOrg) && (!targetOrg || targetOrg === tokenOrg);
195
+ const permissions = (scopes ?? []).filter((scope) => PERMISSION_RE.test(scope));
196
+ if (mode === "off" || !required || !judgeable || permissions.length === 0 || permissions.includes(required)) {
197
+ return "allow";
198
+ }
199
+ return mode === "enforce" ? "deny" : "would_deny";
200
+ }
201
+ function missingPermissionError(tool) {
202
+ const required = exports.TOOL_PERMISSIONS[tool];
203
+ return new security_1.DiditError({
204
+ code: "missing_scope",
205
+ message: `Your role in this organization does not include the permission '${required}' that ${tool} requires.`,
206
+ field: "permission",
207
+ hint: `Ask an organization owner or admin to grant '${required}' to your role, then retry.`,
208
+ });
209
+ }
210
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":";;;AA4MA,4CAUC;AAED,wDASC;AAjOD,iCAAiC;AACjC,EAAE;AACF,sFAAsF;AACtF,wFAAwF;AACxF,sFAAsF;AACtF,0FAA0F;AAC1F,0FAA0F;AAC1F,yFAAyF;AACzF,qEAAqE;AACrE,EAAE;AACF,0FAA0F;AAC1F,4FAA4F;AAC5F,iFAAiF;AACjF,4FAA4F;AAC5F,qFAAqF;AACrF,yCAAwC;AACxC,qDAA6D;AAI7D;+FAC+F;AAC/F,MAAM,aAAa,GAAG,mDAAmD,CAAC;AAE7D,QAAA,gBAAgB,GAAkC;IAC7D,wFAAwF;IACxF,mBAAmB,EAAE,IAAI,EAAE,qDAAqD;IAChF,sBAAsB,EAAE,IAAI,EAAE,wDAAwD;IACtF,wBAAwB,EAAE,IAAI,EAAE,0DAA0D;IAC1F,wBAAwB,EAAE,IAAI,EAAE,6DAA6D;IAC7F,0BAA0B,EAAE,IAAI,EAAE,4DAA4D;IAC9F,iBAAiB,EAAE,IAAI,EAAE,mEAAmE;IAC5F,yBAAyB,EAAE,IAAI,EAAE,mGAAmG;IACpI,cAAc,EAAE,IAAI,EAAE,kDAAkD;IACxE,2BAA2B,EAAE,IAAI,EAAE,6FAA6F;IAChI,oCAAoC,EAAE,IAAI,EAAE,6CAA6C;IACzF,uBAA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AAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5G,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC;AACpD,CAAC;AAED,SAAgB,sBAAsB,CAAC,IAAY;IACjD,MAAM,QAAQ,GAAG,wBAAgB,CAAC,IAAI,CAAC,CAAC;IAExC,OAAO,IAAI,qBAAU,CAAC;QACpB,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,mEAAmE,QAAQ,UAAU,IAAI,YAAY;QAC9G,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,gDAAgD,QAAQ,6BAA6B;KAC5F,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,14 @@
1
+ type ToolDef = {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: any;
5
+ };
6
+ export declare const PRIVILEGED_GROUP_PREFIX: [string, string] | null;
7
+ export declare function isPrivilegedToolName(_name: string): boolean;
8
+ export declare function isPrivilegedCaller(_authInfo: any, _opts?: {
9
+ hosted?: boolean;
10
+ }): boolean;
11
+ export declare const PRIVILEGED_TOOL_DEFS: ToolDef[];
12
+ export declare function dispatchPrivilegedTool(name: string, _args: any): Promise<any>;
13
+ export {};
14
+ //# sourceMappingURL=privileged-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privileged-tools.d.ts","sourceRoot":"","sources":["../src/privileged-tools.ts"],"names":[],"mappings":"AAIA,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,GAAG,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAW,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAExF;AAED,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAAO,CAAC;AAElD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAEnF"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Public build: a small set of internal-only operational tools is not part of the open-source
3
+ // distribution, so this module is intentionally empty. It exposes the same surface the server
4
+ // expects (so index.ts compiles unchanged) with no tool definitions and no dispatch.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PRIVILEGED_TOOL_DEFS = exports.PRIVILEGED_GROUP_PREFIX = void 0;
7
+ exports.isPrivilegedToolName = isPrivilegedToolName;
8
+ exports.isPrivilegedCaller = isPrivilegedCaller;
9
+ exports.dispatchPrivilegedTool = dispatchPrivilegedTool;
10
+ exports.PRIVILEGED_GROUP_PREFIX = null;
11
+ function isPrivilegedToolName(_name) {
12
+ return false;
13
+ }
14
+ function isPrivilegedCaller(_authInfo, _opts) {
15
+ return false;
16
+ }
17
+ exports.PRIVILEGED_TOOL_DEFS = [];
18
+ async function dispatchPrivilegedTool(name, _args) {
19
+ throw new Error(`Unknown tool: ${name}`);
20
+ }
21
+ //# sourceMappingURL=privileged-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privileged-tools.js","sourceRoot":"","sources":["../src/privileged-tools.ts"],"names":[],"mappings":";AAAA,8FAA8F;AAC9F,8FAA8F;AAC9F,qFAAqF;;;AAMrF,oDAEC;AAED,gDAEC;AAID,wDAEC;AAdY,QAAA,uBAAuB,GAA4B,IAAI,CAAC;AAErE,SAAgB,oBAAoB,CAAC,KAAa;IAChD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAc,EAAE,KAA4B;IAC7E,OAAO,KAAK,CAAC;AACf,CAAC;AAEY,QAAA,oBAAoB,GAAc,EAAE,CAAC;AAE3C,KAAK,UAAU,sBAAsB,CAAC,IAAY,EAAE,KAAU;IACnE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC"}