@noodleseed/one 0.86.0 → 0.87.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.
Files changed (140) hide show
  1. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +3 -3
  2. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js.map +1 -1
  3. package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.d.ts.map +1 -1
  4. package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js +23 -0
  5. package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js.map +1 -1
  6. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.d.ts.map +1 -1
  7. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js +14 -3
  8. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js.map +1 -1
  9. package/node_modules/@noodle-borg/auth/dist/claims.d.ts +22 -0
  10. package/node_modules/@noodle-borg/auth/dist/claims.d.ts.map +1 -0
  11. package/node_modules/@noodle-borg/auth/dist/claims.js +70 -0
  12. package/node_modules/@noodle-borg/auth/dist/claims.js.map +1 -0
  13. package/node_modules/@noodle-borg/auth/dist/index.d.ts +1 -0
  14. package/node_modules/@noodle-borg/auth/dist/index.d.ts.map +1 -1
  15. package/node_modules/@noodle-borg/auth/dist/index.js +1 -0
  16. package/node_modules/@noodle-borg/auth/dist/index.js.map +1 -1
  17. package/node_modules/@noodle-borg/auth/dist/jwt-issuer.d.ts +2 -0
  18. package/node_modules/@noodle-borg/auth/dist/jwt-issuer.d.ts.map +1 -1
  19. package/node_modules/@noodle-borg/auth/dist/jwt-issuer.js +1 -0
  20. package/node_modules/@noodle-borg/auth/dist/jwt-issuer.js.map +1 -1
  21. package/node_modules/@noodle-borg/auth/dist/metadata.d.ts +3 -0
  22. package/node_modules/@noodle-borg/auth/dist/metadata.d.ts.map +1 -1
  23. package/node_modules/@noodle-borg/auth/dist/metadata.js +3 -0
  24. package/node_modules/@noodle-borg/auth/dist/metadata.js.map +1 -1
  25. package/node_modules/@noodle-borg/auth/dist/verify.d.ts +7 -0
  26. package/node_modules/@noodle-borg/auth/dist/verify.d.ts.map +1 -1
  27. package/node_modules/@noodle-borg/auth/dist/verify.js +11 -13
  28. package/node_modules/@noodle-borg/auth/dist/verify.js.map +1 -1
  29. package/node_modules/@noodle-borg/authoring/dist/annotations.d.ts +45 -0
  30. package/node_modules/@noodle-borg/authoring/dist/annotations.d.ts.map +1 -0
  31. package/node_modules/@noodle-borg/authoring/dist/annotations.js +40 -0
  32. package/node_modules/@noodle-borg/authoring/dist/annotations.js.map +1 -0
  33. package/node_modules/@noodle-borg/authoring/dist/index.d.ts +1 -1
  34. package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
  35. package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
  36. package/node_modules/@noodle-borg/authoring/dist/server.d.ts +9 -45
  37. package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
  38. package/node_modules/@noodle-borg/authoring/dist/server.js +13 -39
  39. package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
  40. package/node_modules/@noodle-borg/compiler/dist/artifact/types.d.ts +11 -1
  41. package/node_modules/@noodle-borg/compiler/dist/artifact/types.d.ts.map +1 -1
  42. package/node_modules/@noodle-borg/compiler/dist/artifact/types.js +4 -1
  43. package/node_modules/@noodle-borg/compiler/dist/artifact/types.js.map +1 -1
  44. package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
  45. package/node_modules/@noodle-borg/compiler/dist/compile.js +19 -0
  46. package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
  47. package/node_modules/@noodle-borg/compiler/dist/index.d.ts +1 -1
  48. package/node_modules/@noodle-borg/compiler/dist/index.d.ts.map +1 -1
  49. package/node_modules/@noodle-borg/compiler/dist/index.js.map +1 -1
  50. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +9 -0
  51. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
  52. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +31 -0
  53. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
  54. package/node_modules/@noodle-borg/module/dist/contract.d.ts +4 -0
  55. package/node_modules/@noodle-borg/module/dist/contract.d.ts.map +1 -1
  56. package/node_modules/@noodle-borg/module/dist/contract.js.map +1 -1
  57. package/node_modules/@noodle-borg/protocol/dist/index.d.ts +1 -0
  58. package/node_modules/@noodle-borg/protocol/dist/index.d.ts.map +1 -1
  59. package/node_modules/@noodle-borg/protocol/dist/index.js +1 -0
  60. package/node_modules/@noodle-borg/protocol/dist/index.js.map +1 -1
  61. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts +2 -1
  62. package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
  63. package/node_modules/@noodle-borg/protocol/dist/mapping.js +3 -2
  64. package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
  65. package/node_modules/@noodle-borg/protocol/dist/sdk-server.d.ts.map +1 -1
  66. package/node_modules/@noodle-borg/protocol/dist/sdk-server.js +14 -1
  67. package/node_modules/@noodle-borg/protocol/dist/sdk-server.js.map +1 -1
  68. package/node_modules/@noodle-borg/protocol/dist/tool-authorization.d.ts +25 -0
  69. package/node_modules/@noodle-borg/protocol/dist/tool-authorization.d.ts.map +1 -0
  70. package/node_modules/@noodle-borg/protocol/dist/tool-authorization.js +51 -0
  71. package/node_modules/@noodle-borg/protocol/dist/tool-authorization.js.map +1 -0
  72. package/node_modules/@noodle-borg/runtime/dist/connector/types.d.ts +2 -0
  73. package/node_modules/@noodle-borg/runtime/dist/connector/types.d.ts.map +1 -1
  74. package/node_modules/@noodle-borg/runtime/dist/connector/types.js.map +1 -1
  75. package/node_modules/@noodle-borg/service/dist/assistant-interactive.d.ts.map +1 -1
  76. package/node_modules/@noodle-borg/service/dist/assistant-interactive.js +8 -0
  77. package/node_modules/@noodle-borg/service/dist/assistant-interactive.js.map +1 -1
  78. package/node_modules/@noodle-borg/service/dist/customer-verifier.d.ts +2 -2
  79. package/node_modules/@noodle-borg/service/dist/customer-verifier.d.ts.map +1 -1
  80. package/node_modules/@noodle-borg/service/dist/customer-verifier.js +37 -7
  81. package/node_modules/@noodle-borg/service/dist/customer-verifier.js.map +1 -1
  82. package/node_modules/@noodle-borg/service/dist/oauth/microsoft.d.ts +1 -1
  83. package/node_modules/@noodle-borg/service/dist/oauth/microsoft.d.ts.map +1 -1
  84. package/node_modules/@noodle-borg/service/dist/oauth/microsoft.js +8 -1
  85. package/node_modules/@noodle-borg/service/dist/oauth/microsoft.js.map +1 -1
  86. package/node_modules/@noodle-borg/service/dist/oauth/provider.d.ts.map +1 -1
  87. package/node_modules/@noodle-borg/service/dist/oauth/provider.js +60 -7
  88. package/node_modules/@noodle-borg/service/dist/oauth/provider.js.map +1 -1
  89. package/node_modules/@noodle-borg/service/dist/oauth/service-bootstrap.d.ts.map +1 -1
  90. package/node_modules/@noodle-borg/service/dist/oauth/service-bootstrap.js +7 -1
  91. package/node_modules/@noodle-borg/service/dist/oauth/service-bootstrap.js.map +1 -1
  92. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.d.ts.map +1 -1
  93. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.js +8 -0
  94. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres-schema.js.map +1 -1
  95. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.d.ts.map +1 -1
  96. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.js +34 -11
  97. package/node_modules/@noodle-borg/service/dist/oauth/store-postgres.js.map +1 -1
  98. package/node_modules/@noodle-borg/service/dist/oauth/store.d.ts +8 -0
  99. package/node_modules/@noodle-borg/service/dist/oauth/store.d.ts.map +1 -1
  100. package/node_modules/@noodle-borg/service/dist/oauth/store.js +6 -0
  101. package/node_modules/@noodle-borg/service/dist/oauth/store.js.map +1 -1
  102. package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.d.ts +4 -0
  103. package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.d.ts.map +1 -1
  104. package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.js +30 -4
  105. package/node_modules/@noodle-borg/service/dist/oauth/token-issuer.js.map +1 -1
  106. package/node_modules/@noodle-borg/service/dist/platform-auth-migration-postgres.d.ts.map +1 -1
  107. package/node_modules/@noodle-borg/service/dist/platform-auth-migration-postgres.js +22 -5
  108. package/node_modules/@noodle-borg/service/dist/platform-auth-migration-postgres.js.map +1 -1
  109. package/node_modules/@noodle-borg/service/dist/platform-auth-migration-runs-postgres.d.ts.map +1 -1
  110. package/node_modules/@noodle-borg/service/dist/platform-auth-migration-runs-postgres.js +5 -2
  111. package/node_modules/@noodle-borg/service/dist/platform-auth-migration-runs-postgres.js.map +1 -1
  112. package/node_modules/@noodle-borg/service/dist/platform-auth-migration.d.ts +1 -0
  113. package/node_modules/@noodle-borg/service/dist/platform-auth-migration.d.ts.map +1 -1
  114. package/node_modules/@noodle-borg/service/dist/platform-auth-migration.js +7 -4
  115. package/node_modules/@noodle-borg/service/dist/platform-auth-migration.js.map +1 -1
  116. package/node_modules/@noodle-borg/service/dist/registry-targets.d.ts +4 -0
  117. package/node_modules/@noodle-borg/service/dist/registry-targets.d.ts.map +1 -1
  118. package/node_modules/@noodle-borg/service/dist/registry-targets.js +14 -3
  119. package/node_modules/@noodle-borg/service/dist/registry-targets.js.map +1 -1
  120. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.d.ts.map +1 -1
  121. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.js +11 -5
  122. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.js.map +1 -1
  123. package/node_modules/@noodle-borg/service/dist/routes/assistant.d.ts.map +1 -1
  124. package/node_modules/@noodle-borg/service/dist/routes/assistant.js +26 -16
  125. package/node_modules/@noodle-borg/service/dist/routes/assistant.js.map +1 -1
  126. package/node_modules/@noodle-borg/service/dist/routes/protected-resource-metadata.d.ts.map +1 -1
  127. package/node_modules/@noodle-borg/service/dist/routes/protected-resource-metadata.js +7 -5
  128. package/node_modules/@noodle-borg/service/dist/routes/protected-resource-metadata.js.map +1 -1
  129. package/node_modules/@noodle-borg/transport-http/dist/handler.d.ts.map +1 -1
  130. package/node_modules/@noodle-borg/transport-http/dist/handler.js +19 -120
  131. package/node_modules/@noodle-borg/transport-http/dist/handler.js.map +1 -1
  132. package/node_modules/@noodle-borg/transport-http/dist/identity-authorization.d.ts +33 -0
  133. package/node_modules/@noodle-borg/transport-http/dist/identity-authorization.d.ts.map +1 -0
  134. package/node_modules/@noodle-borg/transport-http/dist/identity-authorization.js +133 -0
  135. package/node_modules/@noodle-borg/transport-http/dist/identity-authorization.js.map +1 -0
  136. package/node_modules/@noodle-borg/transport-http/dist/tool-authorization.d.ts +25 -0
  137. package/node_modules/@noodle-borg/transport-http/dist/tool-authorization.d.ts.map +1 -0
  138. package/node_modules/@noodle-borg/transport-http/dist/tool-authorization.js +64 -0
  139. package/node_modules/@noodle-borg/transport-http/dist/tool-authorization.js.map +1 -0
  140. package/package.json +1 -1
@@ -0,0 +1,133 @@
1
+ import { JSON_RPC } from '@noodle-borg/protocol';
2
+ import { effectiveProto } from './front-door.js';
3
+ import { header } from './request-capture.js';
4
+ /**
5
+ * Identity gate (OA-1/OA-3): require a verified token and authorize it against the deployment access mode.
6
+ * `allow: true` means the request may proceed, with caller and subject fields when available. `allow: false`
7
+ * means this function already wrote the denial response. Missing tokens and absent verifiers fail closed.
8
+ */
9
+ export async function authorizeIdentityMode(req, res, auth) {
10
+ const challenge = protectedResourceMetadataUrl(req, auth);
11
+ const token = bearerToken(req);
12
+ if (token === null || auth.verifyOwnerToken === undefined) {
13
+ sendUnauthorized(res, challenge);
14
+ return { allow: false };
15
+ }
16
+ const identity = await auth.verifyOwnerToken(token, resourceUrl(req, auth));
17
+ if (identity === null) {
18
+ sendUnauthorized(res, challenge);
19
+ return { allow: false };
20
+ }
21
+ if (auth.accessMode === 'authenticated') {
22
+ return { allow: true, caller: identity };
23
+ }
24
+ if (auth.accessMode === 'customers') {
25
+ if (identity.identityKind !== 'customer') {
26
+ sendUnauthorized(res, challenge);
27
+ return { allow: false };
28
+ }
29
+ return { allow: true, caller: identity };
30
+ }
31
+ if (auth.accessMode === 'owner-only') {
32
+ if (auth.ownerSubject === undefined) {
33
+ sendUnauthorized(res, challenge);
34
+ return { allow: false };
35
+ }
36
+ if (identity.subject !== auth.ownerSubject) {
37
+ sendForbidden(res);
38
+ return { allow: false };
39
+ }
40
+ return { allow: true, caller: identity };
41
+ }
42
+ if (auth.accessMode === 'org-members') {
43
+ const membership = auth.org === undefined || auth.authorizeDataPlaneIdentity === undefined
44
+ ? undefined
45
+ : await auth.authorizeDataPlaneIdentity({
46
+ accessMode: auth.accessMode,
47
+ org: auth.org,
48
+ subject: identity.subject,
49
+ ...(identity.email !== undefined ? { email: identity.email } : {}),
50
+ ...(auth.orgMembershipSources !== undefined
51
+ ? { membershipSources: auth.orgMembershipSources }
52
+ : {}),
53
+ });
54
+ if (membership?.allowed !== true) {
55
+ sendForbidden(res);
56
+ return { allow: false };
57
+ }
58
+ }
59
+ return { allow: true, caller: identity };
60
+ }
61
+ export async function authorizeMixedMode(req, res, auth) {
62
+ const token = bearerToken(req);
63
+ if (token === null)
64
+ return { allow: true };
65
+ const challenge = protectedResourceMetadataUrl(req, auth);
66
+ if (auth.verifyOwnerToken === undefined) {
67
+ sendUnauthorized(res, challenge);
68
+ return { allow: false };
69
+ }
70
+ const identity = await auth.verifyOwnerToken(token, resourceUrl(req, auth));
71
+ if (identity === null) {
72
+ sendUnauthorized(res, challenge);
73
+ return { allow: false };
74
+ }
75
+ return { allow: true, caller: identity };
76
+ }
77
+ export function isIdentityMode(mode) {
78
+ return (mode === 'owner-only' ||
79
+ mode === 'org-members' ||
80
+ mode === 'authenticated' ||
81
+ mode === 'customers');
82
+ }
83
+ function bearerToken(req) {
84
+ const auth = header(req, 'authorization');
85
+ if (!auth)
86
+ return null;
87
+ const match = /^Bearer\s+(.+)$/i.exec(auth);
88
+ return match?.[1] ?? null;
89
+ }
90
+ /**
91
+ * A `401` with a bearer challenge and a transport-level JSON-RPC error body. For owner-only endpoints,
92
+ * `resourceMetadataUrl` is included so an MCP client can discover the authorization server (RFC 9728 /
93
+ * the MCP authorization spec).
94
+ */
95
+ function sendUnauthorized(res, resourceMetadataUrl) {
96
+ const challenge = resourceMetadataUrl !== undefined
97
+ ? `Bearer realm="noodle", resource_metadata="${resourceMetadataUrl}"`
98
+ : 'Bearer realm="noodle"';
99
+ res.writeHead(401, {
100
+ 'content-type': 'application/json; charset=utf-8',
101
+ 'www-authenticate': challenge,
102
+ });
103
+ res.end(JSON.stringify(rpcError(JSON_RPC.INVALID_REQUEST, 'unauthorized')));
104
+ }
105
+ /** A `403` with a transport-level JSON-RPC error body (authenticated, but not authorized). */
106
+ function sendForbidden(res) {
107
+ res.writeHead(403, { 'content-type': 'application/json; charset=utf-8' });
108
+ res.end(JSON.stringify(rpcError(JSON_RPC.INVALID_REQUEST, 'forbidden')));
109
+ }
110
+ /** The public origin + path for this request, honouring the trusted forwarded-proto when configured. */
111
+ function requestUrl(req, trustProxy) {
112
+ const proto = effectiveProto(req, trustProxy);
113
+ const host = header(req, 'host') ?? 'localhost';
114
+ const pathname = new URL(req.url ?? '/', `${proto}://${host}`).pathname;
115
+ return { origin: `${proto}://${host}`, pathname };
116
+ }
117
+ /** The canonical resource identifier (the tenant MCP URL) a token must be audience-bound to (RFC 8707). */
118
+ function resourceUrl(req, auth) {
119
+ if (auth.publicResourceUrl !== undefined)
120
+ return auth.publicResourceUrl;
121
+ const { origin, pathname } = requestUrl(req, auth.trustProxy);
122
+ return `${origin}${pathname}`;
123
+ }
124
+ /** The RFC 9728 protected-resource-metadata URL for this request (well-known prefix before the path). */
125
+ export function protectedResourceMetadataUrl(req, auth) {
126
+ const resource = new URL(resourceUrl(req, auth));
127
+ return `${resource.origin}/.well-known/oauth-protected-resource${resource.pathname}`;
128
+ }
129
+ /** A transport-level JSON-RPC error response with no id (per the Streamable HTTP spec). */
130
+ function rpcError(code, message) {
131
+ return { jsonrpc: '2.0', id: null, error: { code, message } };
132
+ }
133
+ //# sourceMappingURL=identity-authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-authorization.js","sourceRoot":"","sources":["../src/identity-authorization.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAA+B,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAuB9C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAoB,EACpB,GAAmB,EACnB,IAAkC;IAElC,MAAM,SAAS,GAAG,4BAA4B,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC1D,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5E,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,KAAK,eAAe,EAAE,CAAC;QACxC,OAAO,EAAE,KAAK,EAAE,IA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ProtocolRequestContext, type ServedArtifact, type ToolAuthorizationDecision, type ToolAuthorizationRuleClass } from '@noodle-borg/protocol';
3
+ import { type IdentityAuthorizationOptions } from './identity-authorization.js';
4
+ export interface ToolAuthorizationObservation {
5
+ readonly toolName: string;
6
+ readonly decision: 'allow' | 'deny';
7
+ readonly reason: 'allowed' | Exclude<ToolAuthorizationDecision, {
8
+ allow: true;
9
+ }>['reason'];
10
+ readonly ruleClass: ToolAuthorizationRuleClass;
11
+ readonly ruleFingerprint: string;
12
+ }
13
+ interface ToolAuthorizationDenial {
14
+ readonly requestId: string | number | null;
15
+ readonly decision: Exclude<ToolAuthorizationDecision, {
16
+ allow: true;
17
+ }>;
18
+ }
19
+ export declare function preflightToolAuthorization(parsed: unknown, target: ServedArtifact, caller: ProtocolRequestContext['caller']): {
20
+ readonly observations: readonly ToolAuthorizationObservation[];
21
+ readonly denial?: ToolAuthorizationDenial;
22
+ };
23
+ export declare function sendToolAuthorizationDenial(req: IncomingMessage, res: ServerResponse, auth: IdentityAuthorizationOptions, denial: ToolAuthorizationDenial): void;
24
+ export {};
25
+ //# sourceMappingURL=tool-authorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-authorization.d.ts","sourceRoot":"","sources":["../src/tool-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EAEnB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAGhC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,4BAA4B,EAElC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,yBAAyB,EAAE;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC3F,QAAQ,CAAC,SAAS,EAAE,0BAA0B,CAAC;IAC/C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,yBAAyB,EAAE;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;CACxE;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,sBAAsB,CAAC,QAAQ,CAAC,GACvC;IACD,QAAQ,CAAC,YAAY,EAAE,SAAS,4BAA4B,EAAE,CAAC;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAC3C,CA8BA;AAED,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,4BAA4B,EAClC,MAAM,EAAE,uBAAuB,GAC9B,IAAI,CAkBN"}
@@ -0,0 +1,64 @@
1
+ import { evaluateToolAuthorization, TOOL_AUTHORIZATION_DENIED, toolAuthorizationRuleClass, toolAuthorizationRuleFingerprint, } from '@noodle-borg/protocol';
2
+ import { protectedResourceMetadataUrl, } from './identity-authorization.js';
3
+ import { rpcMethod, rpcTargetName, safeRpcId } from './request-capture.js';
4
+ export function preflightToolAuthorization(parsed, target, caller) {
5
+ const items = Array.isArray(parsed) ? parsed : [parsed];
6
+ const observations = [];
7
+ let denial;
8
+ for (const item of items) {
9
+ const method = rpcMethod(item);
10
+ if (method !== 'tools/call')
11
+ continue;
12
+ const toolName = rpcTargetName(item, method);
13
+ if (toolName === undefined)
14
+ continue;
15
+ const tool = target.artifact.tools.find((candidate) => candidate.name === toolName);
16
+ if (tool === undefined)
17
+ continue;
18
+ const decision = evaluateToolAuthorization(tool.authorization, caller);
19
+ observations.push({
20
+ toolName,
21
+ decision: decision.allow ? 'allow' : 'deny',
22
+ reason: decision.allow ? 'allowed' : decision.reason,
23
+ ruleClass: toolAuthorizationRuleClass(tool.authorization),
24
+ ruleFingerprint: toolAuthorizationRuleFingerprint(tool.authorization),
25
+ });
26
+ if (!decision.allow && denial === undefined) {
27
+ denial = {
28
+ requestId: safeRpcId(item).requestId ?? null,
29
+ decision,
30
+ };
31
+ }
32
+ }
33
+ return {
34
+ observations,
35
+ ...(denial === undefined ? {} : { denial }),
36
+ };
37
+ }
38
+ export function sendToolAuthorizationDenial(req, res, auth, denial) {
39
+ const metadata = protectedResourceMetadataUrl(req, auth);
40
+ if (denial.decision.reason === 'authentication_required') {
41
+ res.setHeader('WWW-Authenticate', `Bearer realm="noodle", resource_metadata="${metadata}"`);
42
+ sendError(res, 401, denial.requestId, 'unauthorized', denial.decision.reason);
43
+ return;
44
+ }
45
+ if (denial.decision.reason === 'insufficient_scope') {
46
+ res.setHeader('WWW-Authenticate', `Bearer error="insufficient_scope", scope="${denial.decision.requiredScopes.join(' ')}", resource_metadata="${metadata}"`);
47
+ sendError(res, 403, denial.requestId, 'insufficient scope', denial.decision.reason);
48
+ return;
49
+ }
50
+ sendError(res, 403, denial.requestId, 'forbidden', denial.decision.reason);
51
+ }
52
+ function sendError(res, status, requestId, message, reason) {
53
+ res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
54
+ res.end(JSON.stringify({
55
+ jsonrpc: '2.0',
56
+ id: requestId,
57
+ error: {
58
+ code: TOOL_AUTHORIZATION_DENIED,
59
+ message,
60
+ data: { reason },
61
+ },
62
+ }));
63
+ }
64
+ //# sourceMappingURL=tool-authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-authorization.js","sourceRoot":"","sources":["../src/tool-authorization.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB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AAC,MAAM,CAAC,CAAC;QACpF,OAAO;IACT,CAAC;IACD,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,SAAS,CAChB,GAAmB,EACnB,MAAiB,EACjB,SAAiC,EACjC,OAAe,EACf,MAAqE;IAErE,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,iCAAiC,EAAE,CAAC,CAAC;IAC7E,GAAG,CAAC,GAAG,CACL,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,SAAS;QACb,KAAK,EAAE;YACL,IAAI,EAAE,yBAAyB;YAC/B,OAAO;YACP,IAAI,EAAE,EAAE,MAAM,EAAE;SACjB;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noodleseed/one",
3
- "version": "0.86.0",
3
+ "version": "0.87.0",
4
4
  "private": false,
5
5
  "description": "Noodle CLI by Noodle Seed — author, run, and deploy declarative MCP servers. Embedding the assistant in your own web app is @noodleseed/assistant.",
6
6
  "license": "Apache-2.0",