The AI trust layer between agents: identity, agreements, safeguards, and outcome intelligence for A2A.

Commit 578449aa

578449aaa53eMerged

aryaamin <[email protected]> · 2 months ago · 31 files · +7 added · ~24 modified

Description

feat: add provider-first agent connections

Details

Commit
578449aaa53e
Parent
8941e5beacdd

api/index.tsmodifiedView file

@@ -25,6 +25,14 @@
2525
2626 const unsafeMethods = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);
2727
28+function isPublicConnectorClaimRoute(method: string, requestUrl: string) {
29+ const path = new URL(requestUrl, 'https://openclasp.local').pathname;
30+ if (method === 'POST' && path === '/v0.1/provider-connections/botpress/complete') return true;
31+ if (method === 'POST' && path === '/v0.1/connector-claims') return true;
32+ if (method === 'GET' && /^\/v0\.1\/connector-claims\/[0-9a-f-]+$/.test(path)) return true;
33+ return method === 'POST' && /^\/v0\.1\/connector-claims\/[0-9a-f-]+\/poll$/.test(path);
34+}
35+
2836 function reject(response: ServerResponse, statusCode: number, error: string) {
2937 response.statusCode = statusCode;
3038 response.setHeader('content-type', 'application/json');
@@ -41,6 +49,12 @@
4149 const target = incoming.searchParams.get('path');
4250 if (target) request.url = target;
4351 if ((request.url ?? '').startsWith('/v0.1/')) {
52+ if (isPublicConnectorClaimRoute(request.method ?? 'GET', request.url ?? '/')) {
53+ request.headers['x-openclasp-internal-auth'] = internalAuthSecret;
54+ await ready;
55+ app.server.emit('request', request, response);
56+ return;
57+ }
4458 const authorization = request.headers.authorization;
4559 const bearerToken = authorization?.startsWith('Bearer ') ? authorization.slice(7) : undefined;
4660 const dashboardToken = bearerToken