turnzero 0.40.0-next.1 → 0.41.0-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.
@@ -840,9 +840,9 @@ var updateCredentialFile = (io2, place, tag, change) => {
840
840
  return "written" in written ? { written: true, before: read2.state } : written;
841
841
  };
842
842
  var dropCredentialWriting = (io2, place, tag) => dropWritingFile(io2, place.path, tag);
843
- var withAuthorized = (origin, entry) => (state) => ({
843
+ var withAuthorized = (origin, entry, from = origin) => (state) => ({
844
844
  origins: new Map([...state.origins, [origin, entry]]),
845
- pending: new Map([...state.pending].filter(([key]) => key !== origin))
845
+ pending: new Map([...state.pending].filter(([key]) => key !== origin && key !== from))
846
846
  });
847
847
  var withPending = (origin, entry) => (state) => ({
848
848
  origins: state.origins,
@@ -1362,7 +1362,7 @@ var otherLivingRequestOf = (pending, origin, now) => {
1362
1362
  }
1363
1363
  return found?.origin ?? null;
1364
1364
  };
1365
- var elsewhereRequestSentence = (origin, other) => `A request is pending on this computer for ${other} instead, so the first act ran against ${other}. Where the mint was made at ${origin}, run the first act above. Where it was made at ${other}, run the line its ${MINT_TOKEN_ACTION} call answered exactly as given.`;
1365
+ var otherRequestPresentedSentence = (origin, other) => `No request is pending for ${origin} on this computer, so the one its first act made for ${other} is presented at ${origin} instead.`;
1366
1366
  var markerDisagreesSentence = (kind, origin = DEFAULT_COMMAND_ORIGIN) => kind === "authorized computer" ? `The exchange minted a token that is not an authorized computer's, and ${AUTHORIZE_SUBCOMMAND} keeps only an authorized computer's, so nothing of its value was printed or kept. Call ${MINT_TOKEN_ACTION} from your tool again naming ${AUTHORIZED_COMPUTER_MEMBER}: true, as ${AUTHORIZE_SUBCOMMAND} prints it, and run the line it answers.` : `The exchange minted an authorized computer's token, and ${TOKEN_SUBCOMMAND} ${TOKEN_CLAIM_ACT} prints only a token that is not one, so nothing of its value was printed or kept. Call ${MINT_TOKEN_ACTION} from your tool again without ${AUTHORIZED_COMPUTER_MEMBER}, as ${TOKEN_SUBCOMMAND} ${TOKEN_REQUEST_ACT} prints it, and run the line it answers; to authorize this computer, run ${AUTHORIZE_SUBCOMMAND}${originWordsOf(origin)}.`;
1367
1367
  var unclaimableFormSentence = (origin = DEFAULT_COMMAND_ORIGIN) => `The exchange minted a token whose value is of no form ${TOKEN_SUBCOMMAND} ${TOKEN_CLAIM_ACT} prints, so nothing of its value was printed or kept. ${mintAgainSentence("general", origin)}`;
1368
1368
  var mintedRevocationLines = (revocation, minted) => "lines" in revocation ? [...revocation.lines, standsSentence(`The token it minted, ${minted.id},`, minted.id, minted.expiresAt)] : [`The token it minted, ${minted.id}, is revoked.`];
@@ -1405,13 +1405,17 @@ async function completeAct(io2, origin, kind, presentation, userAgent, say, deli
1405
1405
  return COMMAND_STATUS.nothing_started;
1406
1406
  }
1407
1407
  hideStandingTokens(io2, read2.state);
1408
- const pending = read2.state.pending.get(origin);
1409
- if (pending === void 0) {
1408
+ const now = io2.clock();
1409
+ const own = read2.state.pending.get(origin);
1410
+ const firstParty = (key) => FIRST_PARTY_COMMAND_ORIGINS.includes(key);
1411
+ const crossing = (own === void 0 || !pendingLives(own, now)) && firstParty(origin) ? otherLivingRequestOf(new Map([...read2.state.pending].filter(([key]) => firstParty(key))), origin, now) : null;
1412
+ const from = crossing ?? (own !== void 0 ? origin : null);
1413
+ const pending = from === null ? void 0 : read2.state.pending.get(from);
1414
+ if (from === null || pending === void 0) {
1410
1415
  say(noPendingSentence(origin, kind, held ? "mint" : "code"));
1411
- const other = otherLivingRequestOf(read2.state.pending, origin, io2.clock());
1412
- if (other !== null) say(elsewhereRequestSentence(origin, other));
1413
1416
  return COMMAND_STATUS.nothing_started;
1414
1417
  }
1418
+ if (from !== origin) say(otherRequestPresentedSentence(origin, from));
1415
1419
  io2.hide(pending.verifier, REDACTED_VERIFIER);
1416
1420
  io2.hide(pending.challenge, REDACTED_CHALLENGE);
1417
1421
  const tag = runTagOf();
@@ -1519,9 +1523,9 @@ async function completeAct(io2, origin, kind, presentation, userAgent, say, deli
1519
1523
  stage.now = "minted";
1520
1524
  io2.hide(minted.value, REDACTED_TOKEN);
1521
1525
  if (kind === "tzmesh" && carried !== null) {
1522
- const ended = updateCredentialFile(io2, place, tag, withoutPending(origin));
1526
+ const ended = updateCredentialFile(io2, place, tag, withoutPending(from));
1523
1527
  if (stage.ended) return COMMAND_STATUS.unknown;
1524
- if (!("written" in ended)) say(`The request pending for ${origin} stands in the credential file, which could not be written now: it ends at its expiry, or when ${firstActNamed(kind, origin)} replaces it.`);
1528
+ if (!("written" in ended)) say(`The request pending for ${from} stands in the credential file, which could not be written now: it ends at its expiry, or when ${firstActNamed(kind, from)} replaces it.`);
1525
1529
  return isTzmeshSignedToken(minted.value) && !minted.authorizedComputer ? await carried.deliver(minted) : await carried.refuse(minted);
1526
1530
  }
1527
1531
  if (kind === "general" && !isClaimableToken(minted.value)) {
@@ -1534,27 +1538,27 @@ async function completeAct(io2, origin, kind, presentation, userAgent, say, deli
1534
1538
  for (const line of mintedRevocationLines(await revokeUnder(io2, origin, minted.value, minted.id, userAgent), minted)) say(line);
1535
1539
  return COMMAND_STATUS.failed;
1536
1540
  }
1537
- if (kind === "general") return claimed(io2, place, tag, origin, minted, say, deliver);
1538
- return await kept(io2, place, tag, origin, minted, userAgent, say, login2 !== null);
1541
+ if (kind === "general") return claimed(io2, place, tag, origin, minted, say, deliver, from);
1542
+ return await kept(io2, place, tag, origin, minted, userAgent, say, login2 !== null, from);
1539
1543
  } finally {
1540
1544
  release();
1541
1545
  dropCredentialWriting(io2, place, tag);
1542
1546
  carried?.drop();
1543
1547
  }
1544
1548
  }
1545
- function claimed(io2, place, tag, origin, minted, say, deliver) {
1546
- const ended = updateCredentialFile(io2, place, tag, withoutPending(origin));
1549
+ function claimed(io2, place, tag, origin, minted, say, deliver, from = origin) {
1550
+ const ended = updateCredentialFile(io2, place, tag, withoutPending(from));
1547
1551
  deliver(minted);
1548
1552
  say(
1549
1553
  `${CLAIMED_LINE_HEAD}token ${minted.id} at ${origin}, label ${minted.label !== null ? JSON.stringify(minted.label) : "none"}, expiring ${minted.expiresAt !== null ? `at ${minted.expiresAt}` : "never"}; its value is printed once, on standard output, and kept nowhere.`
1550
1554
  );
1551
- if (!("written" in ended)) say(`The request pending for ${origin} stands in the credential file, which could not be written now: it ends at its expiry, or when ${firstActNamed("general", origin)} replaces it.`);
1555
+ if (!("written" in ended)) say(`The request pending for ${from} stands in the credential file, which could not be written now: it ends at its expiry, or when ${firstActNamed("general", from)} replaces it.`);
1552
1556
  return COMMAND_STATUS.done;
1553
1557
  }
1554
- async function kept(io2, place, tag, origin, minted, userAgent, say, named = false) {
1558
+ async function kept(io2, place, tag, origin, minted, userAgent, say, named = false, from = origin) {
1555
1559
  const now = io2.clock();
1556
1560
  const entry = { token: minted.value, token_id: minted.id, label: minted.label, expires_at: minted.expiresAt, authorized_at: now.toISOString() };
1557
- const written = updateCredentialFile(io2, place, tag, withAuthorized(origin, entry));
1561
+ const written = updateCredentialFile(io2, place, tag, withAuthorized(origin, entry, from));
1558
1562
  if (!("written" in written)) {
1559
1563
  say(
1560
1564
  "unwritten" in written ? `${unwritableFileSentence(place.path, written.unwritten)} So the token the exchange minted was not kept.` : `${readRefusalOf(written, place.path)} So the token the exchange minted was not kept.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turnzero",
3
- "version": "0.40.0-next.1",
3
+ "version": "0.41.0-next.1",
4
4
  "type": "module",
5
5
  "description": "Deploy and run AI-built apps with Turn Zero Cloud hosting and backend services.",
6
6
  "license": "Apache-2.0",