clavarium 0.2.523-next.1 → 0.2.524-next.1

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.523-next.1",
3
+ "version": "0.2.524-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.523-next.1",
9
+ "version": "0.2.524-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.523-next.1",
3
+ "version": "0.2.524-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
package/server/api.mjs CHANGED
@@ -890,6 +890,8 @@ export async function handleApi(request, response, conversations, headers, resou
890
890
  if (talking[2] === '/pin') return send(200, await talk.pin(conversation, body.to, body.on !== false)), true;
891
891
  if (talking[2] === '/split') return send(200, talk.setSplit(conversation, { messages: body.messages, days: body.days, off: body.off })), true;
892
892
  if (typeof body.on === 'boolean') { const now = await talk.set(conversation, body.on); retell(conversation); return send(200, now), true; }
893
+ /* A sign-in code pasted in the chat while its sign-in waits: typed into its tool, never in the thread (#405). */
894
+ if (conversations.signinHelp?.codeInChat(conversation, body.text, body.files)) return send(201, { ...(await conversations.signinHelp.enterCode(conversation, body.text)), told: 'signin' }), true;
893
895
  /* What the chat may add to an answer: the choices ticked, the answers of a group, the zone of a picture it is about (Parley checks each). */
894
896
  return send(201, await talk.say(conversation, body.text, body.answers, body.files, body.via, { picked: body.picked, replies: body.replies, about: body.about, quick: body.quick === true })), true;
895
897
  }
package/server/door.mjs CHANGED
@@ -189,7 +189,7 @@ export async function handleDoor(request, response, { devices, conversations, re
189
189
  if (request.headers['content-type'] !== 'application/octet-stream') return send(400, { error: 'An attachment is a file.' });
190
190
  return send(201, await talk.attach(name, url.searchParams.get('name') ?? '', request));
191
191
  }
192
- if (request.method === 'POST' && talking[1] === undefined) { const body = await readJson(request); return send(201, await talk.say(name, body.text, body.answers, body.files, body.via, { quick: body.quick === true })); }
192
+ if (request.method === 'POST' && talking[1] === undefined) { const body = await readJson(request); if (part.terminal && signinCode && conversations.signinHelp?.codeInChat(name, body.text, body.files)) return send(201, { ...(await signinCode(name, body.text)), told: 'signin' }); return send(201, await talk.say(name, body.text, body.answers, body.files, body.via, { quick: body.quick === true })); }
193
193
  }
194
194
  /* A sign-in code (#405): a device given its terminal could type it there; no other. Named twice, never guessed. */
195
195
  const codeFor = /^\/conversations\/([^/]+)\/signin-code$/.exec(route);
@@ -185,6 +185,15 @@ export class SigninHelp {
185
185
  const ask = this.#personsAsk(name);
186
186
  return ask !== null && ask.field !== true;
187
187
  }
188
+ /* PASTED IN THE CHAT ITSELF (23-11, its owner: « I just want to paste the code », no terminal, no other field): while
189
+ its sign-in waits, a message that is nothing but a code is that code. It goes to enterCode, never into the thread. */
190
+ codeInChat(name, text, files) {
191
+ if (Array.isArray(files) && files.length) return false;
192
+ const code = String(text ?? '').trim();
193
+ /* One long word is not a code: « Probablement » stays a message. Its two halves (#), or long with letters and digits. */
194
+ const shaped = code.includes('#') ? code.length >= 20 : code.length >= 32 && /[0-9]/.test(code) && /[A-Za-z]/.test(code);
195
+ return shaped && CODE.test(code) && this.#personsAsk(name) !== null;
196
+ }
188
197
  /* THE CODE PASTED IN ITS FIELD (#405). Typed once, only while its tool shows its prompt; the value is in no answer,
189
198
  no error, no log, no file. */
190
199
  async enterCode(name, value) {