turnzero 0.39.0 → 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.
- package/dist/turnzero-cloud.mjs +29 -25
- package/package.json +1 -1
package/dist/turnzero-cloud.mjs
CHANGED
|
@@ -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
|
|
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
|
|
1409
|
-
|
|
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(
|
|
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 ${
|
|
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(
|
|
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 ${
|
|
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.`
|
|
@@ -4009,7 +4013,7 @@ var DEPLOY_CREDENTIAL = Object.freeze({
|
|
|
4009
4013
|
piped: false,
|
|
4010
4014
|
places: NO_INPUT_PLACES
|
|
4011
4015
|
});
|
|
4012
|
-
var DEPLOY_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the
|
|
4016
|
+
var DEPLOY_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the sign-in route if the address is admitted`;
|
|
4013
4017
|
var DEPLOY_AFTER_LOGIN = `Once login has printed authorized:, run this deploy line again. ${NOTHING_SENT_OR_STARTED}`;
|
|
4014
4018
|
var PREPARE_ACT = "prepare";
|
|
4015
4019
|
var PREPARE_AGAIN = "Nothing was started. Run the line again: it prepares a fresh upload, which replaces any upload this run prepared.";
|
|
@@ -4461,7 +4465,7 @@ async function deployRun(named, io2, flags) {
|
|
|
4461
4465
|
var DEPLOY_AFTER_OWN_ERROR = "the deploy may or may not have started. Call tzcloud_read_status from your tool first, make the start-only retry a pending upload it answers carries, and run the line again only where it shows neither";
|
|
4462
4466
|
var DEPLOY_ROW = Object.freeze({
|
|
4463
4467
|
name: DEPLOY_SUBCOMMAND,
|
|
4464
|
-
summary: "Deploys the application folder, or a .zip file. It zips the folder, makes the preparing deploy call, uploads the zip under the upload grant that call returns, starts the deploy, and waits for it, printing each step and the outcome. It runs under this computer's token. A tool connected by a minted token, or a job with no tool, runs it under a minted token. With no credential, it sends nothing and prints the two routes to get one: the minted token's variables first, then the
|
|
4468
|
+
summary: "Deploys the application folder, or a .zip file. It zips the folder, makes the preparing deploy call, uploads the zip under the upload grant that call returns, starts the deploy, and waits for it, printing each step and the outcome. It runs under this computer's token. A tool connected by a minted token, or a job with no tool, runs it under a minted token. With no credential, it sends nothing and prints the two routes to get one: the minted token's variables first, then the sign-in route if the address is admitted.",
|
|
4465
4469
|
example: `${DEPLOY_SUBCOMMAND} ${DEPLOY_OPTION.application} <application id> ${DEPLOY_OPTION.path} <folder>`,
|
|
4466
4470
|
options: DEPLOY_OPTIONS,
|
|
4467
4471
|
credential: DEPLOY_CREDENTIAL,
|
|
@@ -4554,7 +4558,7 @@ var CHECK_CREDENTIAL = Object.freeze({
|
|
|
4554
4558
|
piped: false,
|
|
4555
4559
|
places: NO_INPUT_PLACES
|
|
4556
4560
|
});
|
|
4557
|
-
var CHECK_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the
|
|
4561
|
+
var CHECK_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the sign-in route if the address is admitted`;
|
|
4558
4562
|
var checkAnswerOf = (answer) => {
|
|
4559
4563
|
const { refusals, first_deploy: firstDeploy, recorded_health_path: recordedHealthPath } = answer;
|
|
4560
4564
|
if (!Array.isArray(refusals) || typeof firstDeploy !== "boolean" || typeof recordedHealthPath !== "string") return null;
|
|
@@ -5370,7 +5374,7 @@ var SESSION_CREDENTIAL = Object.freeze({
|
|
|
5370
5374
|
piped: false,
|
|
5371
5375
|
places: NO_INPUT_PLACES
|
|
5372
5376
|
});
|
|
5373
|
-
var SESSION_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the
|
|
5377
|
+
var SESSION_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the sign-in route if the address is admitted`;
|
|
5374
5378
|
var missingOptionSentence = (option) => `${SESSION_SUBCOMMAND} needs ${option.name} ${option.value}, as the line a ${toolNameOf(SIGN_IN_TEST_END_USER_ACTION)} call answers names it. ${NOTHING_SENT_OR_WRITTEN}`;
|
|
5375
5379
|
var ENVIRONMENT_REFUSAL = `${SESSION_OPTION.environment} names the environment the end user signs in to, ${COMMAND_ENVIRONMENTS.join(" or ")}. ${NOTHING_SENT_OR_WRITTEN}`;
|
|
5376
5380
|
var OUT_STANDS_REFUSAL = `A file stands where ${SESSION_OPTION.out} names the cookie jar, and ${SESSION_SUBCOMMAND} replaces one only where the line names ${SESSION_OPTION.force}. Name a new file, or add ${SESSION_OPTION.force} to replace it. ${NOTHING_SENT_OR_WRITTEN}`;
|
|
@@ -6258,7 +6262,7 @@ var LIBRARY_CREDENTIAL = Object.freeze({
|
|
|
6258
6262
|
piped: false,
|
|
6259
6263
|
places: NO_INPUT_PLACES
|
|
6260
6264
|
});
|
|
6261
|
-
var LIBRARY_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the
|
|
6265
|
+
var LIBRARY_READS = `no standard input. It reads a minted token from ${MINTED_TOKEN_VARIABLE} if that is set. Otherwise it reads this computer's token for the platform's address from its credential file, which ${LOGIN_SUBCOMMAND} and ${AUTHORIZE_SUBCOMMAND} write, and sends it only to that address. With neither, it prints the variable route first, then the sign-in route if the address is admitted`;
|
|
6262
6266
|
var TAKE_AFTER_LOGIN = `Once ${LOGIN_SUBCOMMAND} has printed authorized:, run this take line again. ${NOTHING_WRITTEN2}`;
|
|
6263
6267
|
var takeRedirectedLine = (status) => `${LIBRARY_READ_ACTION} was answered ${status >= 100 ? `${answeredHow(status)}, a redirect` : answeredHow(status)}, which the command never follows, so the credential was sent to no second address. ${NOTHING_WRITTEN2}`;
|
|
6264
6268
|
async function readTakeCredential(io2, named, afterLogin, why) {
|
|
@@ -7398,7 +7402,7 @@ async function whoami(call, io2) {
|
|
|
7398
7402
|
}
|
|
7399
7403
|
var WHOAMI_ROW = Object.freeze({
|
|
7400
7404
|
name: WHOAMI_SUBCOMMAND,
|
|
7401
|
-
summary: `Shows the account this computer's token acts as at the platform's address. It reads the token the credential file keeps for the address, and makes one ${READ_ACCOUNT_ACTION} call under it. It prints the address, the account's sign-in address and id, and the token's label and expiry. With no token for the address, it sends nothing. It lists the routes a tool takes itself (${AUTHORIZE_SUBCOMMAND}, tzcloud_deploy_files, the upload route, and ${PROVISION_SUBCOMMAND}), then the device line and the person's
|
|
7405
|
+
summary: `Shows the account this computer's token acts as at the platform's address. It reads the token the credential file keeps for the address, and makes one ${READ_ACCOUNT_ACTION} call under it. It prints the address, the account's sign-in address and id, and the token's label and expiry. With no token for the address, it sends nothing. It lists the routes a tool takes itself (${AUTHORIZE_SUBCOMMAND}, tzcloud_deploy_files, the upload route, and ${PROVISION_SUBCOMMAND}), then the device line and the person's sign-in route. It prints no token.`,
|
|
7402
7406
|
example: WHOAMI_SUBCOMMAND,
|
|
7403
7407
|
options: WHOAMI_OPTIONS,
|
|
7404
7408
|
credential: null,
|
|
@@ -7407,10 +7411,10 @@ var WHOAMI_ROW = Object.freeze({
|
|
|
7407
7411
|
done: "the account was read",
|
|
7408
7412
|
failed: "the platform refused the read, for example because it no longer accepts the token: the printed lines name login",
|
|
7409
7413
|
unknown: "the read got no response, or a response that is not a refusal",
|
|
7410
|
-
nothing_started: "nothing was read. An option or the credential file was refused, or the platform was too old. Or no live token exists for the address, and the printed lines give the next steps that need no
|
|
7414
|
+
nothing_started: "nothing was read. An option or the credential file was refused, or the platform was too old. Or no live token exists for the address, and the printed lines give the next steps that need no new sign-in, then the sign-in route"
|
|
7411
7415
|
},
|
|
7412
7416
|
variables: [[ORIGIN_VARIABLE, `the platform's address whose token is read if the command has no ${DEPLOY_OPTION.origin}.`]],
|
|
7413
|
-
note: [`${WHOAMI_SUBCOMMAND} reads which account
|
|
7417
|
+
note: [`${WHOAMI_SUBCOMMAND} reads which account the token kept by login or authorize on this computer belongs to, so you can tell it from your tool's own connection. The credential file is ${CREDENTIAL_FILE_WORDS}.`],
|
|
7414
7418
|
afterOwnError: "nothing was changed, since whoami only reads; run it again",
|
|
7415
7419
|
run: whoami
|
|
7416
7420
|
});
|
|
@@ -10410,7 +10414,7 @@ var SCAFFOLD_AFTER_LOGIN = `Once ${LOGIN_SUBCOMMAND} has printed authorized:, ru
|
|
|
10410
10414
|
var SCAFFOLD_SIGN_IN_WHY = `A template that takes library entries needs a sign-in, since the library's reads are under a credential. The ${SCAFFOLD_DEFAULT_TEMPLATE} template, which takes none, runs without one.`;
|
|
10411
10415
|
var SCAFFOLD_ROW = Object.freeze({
|
|
10412
10416
|
name: SCAFFOLD_SUBCOMMAND,
|
|
10413
|
-
summary: `Writes a new service from a template into a project, ${SCAFFOLD_DEFAULT_TEMPLATE} if the command has no ${SCAFFOLD_OPTION.template}. It writes the template's files under app/, runs npm install and npm test there, and prints the next steps. It starts a new application, and writes over no file. Some templates take library entries: database-service takes the Database entry, and web-app takes three. Such a template takes each entry as library take does, under the same credential and with the same checks, before it writes anything. It fills the manifest's packages member from the library folder's rows. With no credential, it writes nothing, and prints the
|
|
10417
|
+
summary: `Writes a new service from a template into a project, ${SCAFFOLD_DEFAULT_TEMPLATE} if the command has no ${SCAFFOLD_OPTION.template}. It writes the template's files under app/, runs npm install and npm test there, and prints the next steps. It starts a new application, and writes over no file. Some templates take library entries: database-service takes the Database entry, and web-app takes three. Such a template takes each entry as library take does, under the same credential and with the same checks, before it writes anything. It fills the manifest's packages member from the library folder's rows. With no credential, it writes nothing, and prints the sign-in route and this command to run again once you are signed in. A template that takes no entry reads no credential.`,
|
|
10414
10418
|
example: `${SCAFFOLD_SUBCOMMAND} ${SCAFFOLD_OPTION.template} database-service ${SCAFFOLD_OPTION.path} <project root>`,
|
|
10415
10419
|
options: SCAFFOLD_OPTIONS,
|
|
10416
10420
|
credential: SCAFFOLD_CREDENTIAL,
|