create-heresay 0.2.23 → 0.2.24
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-heresay",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
4
4
|
"description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/release/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.24
|
|
@@ -270,13 +270,25 @@ const onTeam = (i, email) => !!i?.members.some((m) => m.email.toLowerCase() ===
|
|
|
270
270
|
* every call, so a revoked connection or a removed member stops at once, not in an hour.
|
|
271
271
|
*/
|
|
272
272
|
export async function chatCaller(req, deps) {
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
273
|
+
const auth = req.headers['authorization'] ?? '';
|
|
274
|
+
let grant = null;
|
|
275
|
+
const m = /^Bearer hat_([a-f0-9]{24})_([A-Za-z0-9_-]{20,80})$/.exec(auth);
|
|
276
|
+
// A chat token (hct_), for chat apps that can't sign in with OAuth: the grant itself checks it.
|
|
277
|
+
const t = /^Bearer hct_([a-f0-9]{24})_([A-Za-z0-9_-]{20,80})$/.exec(auth);
|
|
278
|
+
if (m) {
|
|
279
|
+
const a = await deps.store.getAuth('access', m[1]);
|
|
280
|
+
if (!a || !same(sha(m[2]), String(a.data.hash)) || Date.parse(a.expires_at ?? '') < deps.now())
|
|
281
|
+
return null;
|
|
282
|
+
grant = await deps.store.getAuth('grant', String(a.data.grant_id));
|
|
283
|
+
}
|
|
284
|
+
else if (t) {
|
|
285
|
+
grant = await deps.store.getAuth('grant', t[1]);
|
|
286
|
+
if (!grant || !grant.data.token_hash || !same(sha(t[2]), String(grant.data.token_hash)))
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
278
290
|
return null;
|
|
279
|
-
|
|
291
|
+
}
|
|
280
292
|
if (!grant || grant.data.revoked_at)
|
|
281
293
|
return null;
|
|
282
294
|
const instance = await deps.store.getInstance();
|
|
@@ -298,15 +310,36 @@ export const signInFirst = (req, deps) => json(401, {
|
|
|
298
310
|
'www-authenticate': `Bearer realm="heresay", resource_metadata="${baseUrl(req, deps)}/.well-known/oauth-protected-resource/v1/mcp", scope="${SCOPE}"`,
|
|
299
311
|
});
|
|
300
312
|
// ---- connections, from the dashboard -------------------------------------------------------
|
|
301
|
-
/**
|
|
313
|
+
/**
|
|
314
|
+
* GET /v1/chat-connections, DELETE /v1/chat-connections/:id: yours, or anyone's for an owner.
|
|
315
|
+
* POST /v1/chat-connections { name }: a chat token, for a chat app that can't sign in with
|
|
316
|
+
* OAuth (a ChatGPT Sites bridge, a script). Same three tools, as you; shown once, stored hashed,
|
|
317
|
+
* revoked like any connection.
|
|
318
|
+
*/
|
|
302
319
|
export async function connections(p, member, req, deps) {
|
|
303
320
|
const mine = (g) => String(g.data.email).toLowerCase() === member.email.toLowerCase();
|
|
321
|
+
if (p.length === 1 && req.method === 'POST') {
|
|
322
|
+
const name = str(fields(req.body).name, 80) ?? 'A chat app';
|
|
323
|
+
const mineNow = (await deps.store.listAuth('grant')).filter((g) => !g.data.revoked_at && mine(g) && g.data.token_hash);
|
|
324
|
+
if (mineNow.length >= 10)
|
|
325
|
+
return json(400, { error: 'You have 10 chat tokens. Disconnect one first.' });
|
|
326
|
+
const id = hexId(), tokenSecret = secret();
|
|
327
|
+
await deps.store.putAuth({
|
|
328
|
+
kind: 'grant', id, expires_at: null,
|
|
329
|
+
data: {
|
|
330
|
+
email: member.email, client_id: null, client_name: name, kind: 'token', token_hash: sha(tokenSecret),
|
|
331
|
+
created_at: new Date(deps.now()).toISOString(), last_used_at: null, revoked_at: null,
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
deps.log('oauth.token_created', { grant_id: id, by: member.email, name });
|
|
335
|
+
return json(201, { id, token: `hct_${id}_${tokenSecret}`, name, mcp_url: resourceUrl(baseUrl(req, deps)) });
|
|
336
|
+
}
|
|
304
337
|
if (p.length === 1 && req.method === 'GET') {
|
|
305
338
|
const all = (await deps.store.listAuth('grant')).filter((g) => !g.data.revoked_at && (member.role === 'owner' || mine(g)));
|
|
306
339
|
all.sort((a, b) => String(a.data.created_at).localeCompare(String(b.data.created_at)));
|
|
307
340
|
return json(200, {
|
|
308
341
|
connections: all.map((g) => ({
|
|
309
|
-
id: g.id, email: g.data.email, client_name: g.data.client_name,
|
|
342
|
+
id: g.id, email: g.data.email, client_name: g.data.client_name, kind: g.data.token_hash ? 'token' : 'oauth',
|
|
310
343
|
created_at: g.data.created_at, last_used_at: g.data.last_used_at ?? null,
|
|
311
344
|
})),
|
|
312
345
|
});
|
|
@@ -2006,6 +2006,27 @@
|
|
|
2006
2006
|
]),
|
|
2007
2007
|
el('p', { class: 'hint', text: 'Claude, Cursor and other apps that take a remote MCP server use the same address.' }),
|
|
2008
2008
|
]));
|
|
2009
|
+
// For chat apps that can't sign in with OAuth: a ChatGPT workspace that blocks MCP plugins
|
|
2010
|
+
// (use a ChatGPT Sites bridge), or a script. Shown once.
|
|
2011
|
+
var tokenName = el('input', { name: 'token-name', value: 'ChatGPT', 'aria-label': 'What it is for', maxlength: '80' });
|
|
2012
|
+
var tokenOut = el('div');
|
|
2013
|
+
var tokenErr = el('p', { class: 'err', role: 'alert' });
|
|
2014
|
+
var tokenForm = el('form', { class: 'invite' }, [tokenName, el('button', { class: 'btn', text: 'Create chat token' })]);
|
|
2015
|
+
tokenForm.onsubmit = function (e) {
|
|
2016
|
+
e.preventDefault();
|
|
2017
|
+
tokenErr.textContent = '';
|
|
2018
|
+
api('POST', '/chat-connections', { name: tokenName.value }).then(function (b) {
|
|
2019
|
+
tokenOut.textContent = '';
|
|
2020
|
+
tokenOut.appendChild(el('p', { class: 'hint', text: 'Shown once. Paste it where the chat app asks for a Heresay token, with the address above. It sends requests as you; disconnect it below to stop it.' }));
|
|
2021
|
+
tokenOut.appendChild(el('div', { class: 'copy-prompt' }, [el('code', { class: 'url token-out', text: b.token }), copyButton(function () { return b.token; }, 'Copy token')]));
|
|
2022
|
+
load();
|
|
2023
|
+
}).catch(function (x) { tokenErr.textContent = x.message; });
|
|
2024
|
+
};
|
|
2025
|
+
view.appendChild(el('section', { class: 'card' }, [
|
|
2026
|
+
el('h2', { text: 'Can’t add MCP servers? Use a token' }),
|
|
2027
|
+
el('p', { class: 'mute', text: 'Some ChatGPT workspaces don’t allow plugins with MCPs. A ChatGPT Sites app (a bridge) can call this Heresay with a chat token instead, and works in Chat on every device. Scripts can use one too.' }),
|
|
2028
|
+
tokenForm, tokenErr, tokenOut,
|
|
2029
|
+
]));
|
|
2009
2030
|
var list = el('ul', { class: 'members' }, [loading('li')]);
|
|
2010
2031
|
var err = el('p', { class: 'err', role: 'alert' });
|
|
2011
2032
|
view.appendChild(el('section', { class: 'card' }, [el('h2', { text: me.role === 'owner' ? 'Connected chat apps' : 'Your connected chat apps' }), list, err]));
|
|
@@ -2016,7 +2037,7 @@
|
|
|
2016
2037
|
list.appendChild(el('li', {}, [
|
|
2017
2038
|
el('span', { class: 'avatar', text: (c.client_name || '?').charAt(0).toUpperCase() }),
|
|
2018
2039
|
el('div', {}, [el('b', { text: c.client_name + (c.email === me.email ? '' : ' · ' + c.email) }),
|
|
2019
|
-
el('span', { class: 'mute', text: 'Connected ' + new Date(c.created_at).toLocaleDateString() + (c.last_used_at ? ' · last used ' + new Date(c.last_used_at).toLocaleString() : '') })]),
|
|
2040
|
+
el('span', { class: 'mute', text: (c.kind === 'token' ? 'Chat token · created ' : 'Connected ') + new Date(c.created_at).toLocaleDateString() + (c.last_used_at ? ' · last used ' + new Date(c.last_used_at).toLocaleString() : '') })]),
|
|
2020
2041
|
el('button', { class: 'btn ghost', type: 'button', text: 'Disconnect', onclick: function () {
|
|
2021
2042
|
err.textContent = '';
|
|
2022
2043
|
api('DELETE', '/chat-connections/' + c.id).then(load).catch(function (x) { err.textContent = x.message; });
|