@dupecom/botcha-cloudflare 0.18.0 → 0.19.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/README.md +1 -1
- package/dist/auth.d.ts +48 -3
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +89 -21
- package/dist/dashboard/docs.d.ts +15 -0
- package/dist/dashboard/docs.d.ts.map +1 -0
- package/dist/dashboard/docs.js +556 -0
- package/dist/dashboard/layout.d.ts.map +1 -1
- package/dist/dashboard/layout.js +1 -1
- package/dist/dashboard/whitepaper.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -13
- package/dist/static.d.ts +52 -2
- package/dist/static.d.ts.map +1 -1
- package/dist/static.js +69 -6
- package/dist/tap-jwks.d.ts +2 -1
- package/dist/tap-jwks.d.ts.map +1 -1
- package/dist/tap-jwks.js +31 -7
- package/package.json +1 -1
package/dist/tap-jwks.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Implements .well-known/jwks for TAP agent public key discovery
|
|
4
4
|
* Per Visa TAP spec: https://developer.visa.com/capabilities/trusted-agent-protocol
|
|
5
5
|
*/
|
|
6
|
+
import { getSigningPublicKeyJWK } from './auth.js';
|
|
6
7
|
// ============ PEM <-> JWK CONVERSION ============
|
|
7
8
|
/**
|
|
8
9
|
* Convert PEM public key to JWK format
|
|
@@ -122,27 +123,49 @@ function arrayBufferToPem(buffer) {
|
|
|
122
123
|
// ============ JWKS ENDPOINT HANDLERS ============
|
|
123
124
|
/**
|
|
124
125
|
* GET /.well-known/jwks
|
|
125
|
-
* Returns JWK Set for app's TAP-enabled agents
|
|
126
|
+
* Returns JWK Set for app's TAP-enabled agents.
|
|
127
|
+
* Also includes BOTCHA's own signing public key when JWT_SIGNING_KEY is configured.
|
|
126
128
|
*/
|
|
127
129
|
export async function jwksRoute(c) {
|
|
128
130
|
try {
|
|
131
|
+
const allKeys = [];
|
|
132
|
+
// Always include BOTCHA's own signing public key if configured
|
|
133
|
+
const jwtSigningKeyEnv = c.env.JWT_SIGNING_KEY;
|
|
134
|
+
if (jwtSigningKeyEnv) {
|
|
135
|
+
try {
|
|
136
|
+
const privateKeyJwk = JSON.parse(jwtSigningKeyEnv);
|
|
137
|
+
const publicKeyJwk = getSigningPublicKeyJWK(privateKeyJwk);
|
|
138
|
+
allKeys.push({
|
|
139
|
+
kty: publicKeyJwk.kty,
|
|
140
|
+
crv: publicKeyJwk.crv,
|
|
141
|
+
x: publicKeyJwk.x,
|
|
142
|
+
y: publicKeyJwk.y,
|
|
143
|
+
kid: 'botcha-signing-1',
|
|
144
|
+
use: 'sig',
|
|
145
|
+
alg: 'ES256',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
console.error('Failed to derive BOTCHA signing public key for JWKS:', error);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
129
152
|
const appId = c.req.query('app_id');
|
|
130
|
-
//
|
|
153
|
+
// If no app_id, return just the BOTCHA signing key (if any)
|
|
131
154
|
if (!appId) {
|
|
132
|
-
return c.json({ keys:
|
|
155
|
+
return c.json({ keys: allKeys }, 200, {
|
|
133
156
|
'Cache-Control': 'public, max-age=3600',
|
|
134
157
|
});
|
|
135
158
|
}
|
|
136
159
|
const agents = c.env.AGENTS;
|
|
137
160
|
if (!agents) {
|
|
138
161
|
console.error('AGENTS KV namespace not available');
|
|
139
|
-
return c.json({ keys:
|
|
162
|
+
return c.json({ keys: allKeys }, 200);
|
|
140
163
|
}
|
|
141
164
|
// Get agent list for this app
|
|
142
165
|
const agentIndexKey = `app_agents:${appId}`;
|
|
143
166
|
const agentIdsData = await agents.get(agentIndexKey, 'text');
|
|
144
167
|
if (!agentIdsData) {
|
|
145
|
-
return c.json({ keys:
|
|
168
|
+
return c.json({ keys: allKeys }, 200, {
|
|
146
169
|
'Cache-Control': 'public, max-age=3600',
|
|
147
170
|
});
|
|
148
171
|
}
|
|
@@ -174,8 +197,9 @@ export async function jwksRoute(c) {
|
|
|
174
197
|
return null;
|
|
175
198
|
}
|
|
176
199
|
});
|
|
177
|
-
const
|
|
178
|
-
|
|
200
|
+
const agentJwks = (await Promise.all(jwkPromises)).filter((jwk) => jwk !== null);
|
|
201
|
+
allKeys.push(...agentJwks);
|
|
202
|
+
return c.json({ keys: allKeys }, 200, {
|
|
179
203
|
'Cache-Control': 'public, max-age=3600',
|
|
180
204
|
});
|
|
181
205
|
}
|