@the-vibe-company/armada 0.1.15 → 0.1.16
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 +18 -3
- package/dist/armada.js +143 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,7 +160,7 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
|
|
|
160
160
|
**Deploy on Vercel.** Create a project from this repository and set these options:
|
|
161
161
|
|
|
162
162
|
- Root Directory: `packages/dashboard`, with files outside the root directory included (the default). The framework preset is Next.js, and Bun installs the workspace from `bun.lock`.
|
|
163
|
-
- Environment variables: the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), `LINEAR_API_KEY`, `GITHUB_TOKEN`, `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN`. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while Turso is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (Linear and GitHub read period, default 60) and `ARMADA_DASHBOARD_AUTHOR` (the name requests are signed with until a viewer gives theirs). Never add a runtime token (Conductor or other): the coordinator carries out every request.
|
|
163
|
+
- Environment variables: the accounts variables below (or, until they are set, `ARMADA_DASHBOARD_PASSWORD`), `LINEAR_API_KEY`, `GITHUB_TOKEN`, `ARMADA_TURSO_URL` and `ARMADA_TURSO_TOKEN`. With accounts and the vault (`ARMADA_SECRETS_KEY`, see [Keys kept in Armada](#keys-kept-in-armada)), the last four move to the Keys page and are only a fallback here. Optional: `ARMADA_REPOSITORIES` (the `owner/name` list shown while Turso is unreachable on a fresh server), `ARMADA_DASHBOARD_LANGUAGE` (`en` or `fr`), `ARMADA_DASHBOARD_SNAPSHOT_SECONDS` (Linear and GitHub read period, default 60) and `ARMADA_DASHBOARD_AUTHOR` (the name requests are signed with until a viewer gives theirs). Never add a runtime token (Conductor or other): the coordinator carries out every request.
|
|
164
164
|
- The keys stay on the server; the browser only receives the fleet reading.
|
|
165
165
|
|
|
166
166
|
**Accounts.** People sign in with GitHub (or email and password where enabled) and belong to organizations, with the roles owner, admin and member. Accounts, sessions, organizations and invitations live in a libSQL database of their own, separate from the fleet's Turso database; its schema is applied on first use. Accounts turn on only when every required variable below is set. With none of them set, the shared password applies, unchanged; with some but not all, the dashboard fails closed (503, naming the missing ones) rather than fall back to a password that shows every organization's projects.
|
|
@@ -180,6 +180,19 @@ ARMADA_AUTH_URL=http://localhost:4822 ARMADA_AUTH_OWNER_EMAILS=you@example.com b
|
|
|
180
180
|
- Sessions are HttpOnly, SameSite=Lax cookies (Secure over https) valid 30 days; a revoked session can last up to five minutes (signed cookie cache). Without its accounts database the dashboard fails closed (503).
|
|
181
181
|
- Terminals sign in too (see [Sign in from a terminal](#sign-in-from-a-terminal)): `armada login` shows a code that the person confirms on the dashboard's `/device` page, and owners create API keys for headless coordinators on the Organization page. A key is shown once, belongs to the organization, and revoking it signs out whatever uses it. The CLI calls only `/api/cli/*`; without accounts those routes refuse with the next step.
|
|
182
182
|
|
|
183
|
+
**Keys kept in Armada.** With accounts, the organization's keys can live in Armada instead of on every machine: an owner or admin enters them once on the Keys page (Organization > Keys), and every signed-in terminal receives what it needs (see [Keys](#keys)). It turns on with one more variable:
|
|
184
|
+
|
|
185
|
+
| Variable | What |
|
|
186
|
+
| --- | --- |
|
|
187
|
+
| `ARMADA_SECRETS_KEY` | The vault's master key: 32 random bytes in base64 or hex, `openssl rand -base64 32`. It stays in the deployment's environment, never in a database. Changing it makes every stored key unreadable (the Keys page asks to enter them again) |
|
|
188
|
+
|
|
189
|
+
- The Keys page holds the Linear API key; the Turso access: a Platform API token (`turso auth api-tokens mint armada`) with the Turso organization and database names, or, without one, the database URL and a database token; and a GitHub token for the dashboard's own reads. Each member may add their own Linear key: their terminals use it, so the comments they post carry their name.
|
|
190
|
+
- Values are write-only: once saved, a secret is never shown again, only who set it and when. Each value is sealed with AES-256-GCM under its own data key, itself sealed by the master key, and bound to its organization, person and name.
|
|
191
|
+
- A signed-in terminal (a session of `armada login` or an organization API key) calls `POST /api/cli/credentials`. It receives the Linear key (the person's own first) and a Turso database token made for it through the Turso Platform API, which expires after 4 hours and is renewed without asking. Without a Platform token, the stored database token is handed out as is, and the audit list says so. Answers are never cached; a terminal asking more than 30 times a minute is refused for a minute.
|
|
192
|
+
- Every change and every key handed out is in the audit list at the bottom of the Keys page (owners and admins): who, which key, when; never a value.
|
|
193
|
+
- The dashboard reads each organization's fleet with that organization's keys from the vault, each missing one from its environment variables; once they are all on the Keys page, its environment shrinks to the accounts variables and `ARMADA_SECRETS_KEY`. A Turso database given on the Keys page is the organization's own: the projects registered in it belong to that organization, and, unless it is the deployment's first organization, it is read with none of the environment's keys (nor `ARMADA_REPOSITORIES`), since its registry could name any repository.
|
|
194
|
+
- Without `ARMADA_SECRETS_KEY` (or under the shared password), nothing changes: the Keys page says how to turn the vault on, the CLI's call answers 503 with that next step, and terminals keep their own keys.
|
|
195
|
+
|
|
183
196
|
**Switch from the shared password to accounts** (a deployment that runs on `ARMADA_DASHBOARD_PASSWORD` keeps working until the redeploy of step 4; set every variable before it, since a partial set locks the dashboard):
|
|
184
197
|
|
|
185
198
|
1. Create the accounts database (`turso db create armada-accounts`, then `turso db show armada-accounts --url` and `turso db tokens create armada-accounts`) and set `ARMADA_AUTH_DATABASE_URL` and `ARMADA_AUTH_DATABASE_TOKEN`.
|
|
@@ -216,7 +229,9 @@ armada logout # revokes this terminal's session and removes it from the machi
|
|
|
216
229
|
|
|
217
230
|
## Keys
|
|
218
231
|
|
|
219
|
-
Armada needs a few keys.
|
|
232
|
+
Armada needs a few keys. A terminal signed in to an Armada that keeps its organization's keys ([Keys kept in Armada](#keys-kept-in-armada)) needs none on the machine: `armada login`, then `armada status`. Otherwise set them up once per machine with `armada auth login`, or pass them as environment variables (the way to go in CI and cloud sandboxes).
|
|
233
|
+
|
|
234
|
+
Each key comes from the environment first, then from Armada when signed in, then from the credentials file. Armada is asked only for what the environment does not set, on each command that needs keys, so a key replaced on the Keys page takes effect on the next command. The Linear key it gives stays in memory; the Turso token it makes for the terminal is kept in the credentials file (`ARMADA_TURSO_LEASE`, with its expiry) and renewed when less than an hour is left. When Armada cannot be reached, the command warns and goes on with the machine's keys (and the Turso token kept earlier, until it expires). `armada logout` and `armada auth logout` remove the kept token.
|
|
220
235
|
|
|
221
236
|
| Variable | What | Needed by |
|
|
222
237
|
| --- | --- | --- |
|
|
@@ -226,7 +241,7 @@ Armada needs a few keys. Set them up once per machine with `armada auth login`,
|
|
|
226
241
|
| `GITHUB_TOKEN` or `GH_TOKEN` | GitHub token; otherwise `gh auth token` is used | pull requests and CI |
|
|
227
242
|
|
|
228
243
|
- `armada auth login` asks only for the keys that are missing, with hidden input for tokens, and stores them in `~/.config/armada/credentials` (or `$XDG_CONFIG_HOME/armada/credentials`), mode 0600 in a 0700 directory. Without a terminal it asks nothing and lists the variables to set instead.
|
|
229
|
-
- `armada auth status [--json]` shows which keys are set and where each comes from. It never prints a value.
|
|
244
|
+
- `armada auth status [--json]` shows which keys are set and where each comes from (for example `Armada: your own key`). It never prints a value.
|
|
230
245
|
- `armada auth logout` removes Armada's keys from the file.
|
|
231
246
|
|
|
232
247
|
The credentials file is a plain dotenv file (`KEY=value` lines, `#` comments) that a shell can also `source`. You may edit it by hand; Armada keeps your other lines and comments when it updates it. GitHub tokens are not stored there: use the environment or `gh auth login`.
|
package/dist/armada.js
CHANGED
|
@@ -310,10 +310,12 @@ var displayCode = (code) => code.length === 8 ? `${code.slice(0, 4)}-${code.slic
|
|
|
310
310
|
class ArmadaApiError extends Error {
|
|
311
311
|
next;
|
|
312
312
|
signedOut;
|
|
313
|
-
|
|
313
|
+
status;
|
|
314
|
+
constructor(message, next = null, signedOut = false, status = null) {
|
|
314
315
|
super(message);
|
|
315
316
|
this.next = next;
|
|
316
317
|
this.signedOut = signedOut;
|
|
318
|
+
this.status = status;
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
var LOGIN_NEXT = "armada login";
|
|
@@ -364,7 +366,7 @@ function armadaApi(opts) {
|
|
|
364
366
|
const refusal = (status, body, what) => {
|
|
365
367
|
const error = typeof body.error === "string" ? body.error : `HTTP ${status}`;
|
|
366
368
|
const next = typeof body.next === "string" ? body.next : status === 401 ? LOGIN_NEXT : null;
|
|
367
|
-
return new ArmadaApiError(what ? `${what}: ${error}` : error, next, status === 401);
|
|
369
|
+
return new ArmadaApiError(what ? `${what}: ${error}` : error, next, status === 401, status);
|
|
368
370
|
};
|
|
369
371
|
return {
|
|
370
372
|
async startDeviceLogin() {
|
|
@@ -407,6 +409,20 @@ function armadaApi(opts) {
|
|
|
407
409
|
throw refusal(status, body, status === 401 ? null : "Armada could not say who is signed in");
|
|
408
410
|
return body;
|
|
409
411
|
},
|
|
412
|
+
async credentials(signIn, held) {
|
|
413
|
+
const { status, body } = await call("POST", "credentials", { signIn, body: { turso: held } });
|
|
414
|
+
if (status !== 200)
|
|
415
|
+
throw refusal(status, body, status === 401 ? null : "Armada gave no keys");
|
|
416
|
+
const str = (v) => typeof v === "string" && v.length > 0;
|
|
417
|
+
const org = body.organization;
|
|
418
|
+
const linear = body.linear;
|
|
419
|
+
const turso = body.turso;
|
|
420
|
+
const shaped = body.schemaVersion === 1 && str(org?.id) && (linear === null || str(linear?.apiKey)) && (turso === null || turso?.kind === "kept" && str(turso.revision) && str(turso.expiresAt) || (turso?.kind === "minted" || turso?.kind === "stored") && str(turso.url) && str(turso.token));
|
|
421
|
+
if (!shaped)
|
|
422
|
+
throw new ArmadaApiError(`Armada (${host}) answered the keys in a shape this CLI does not know`);
|
|
423
|
+
const warnings = Array.isArray(body.warnings) ? body.warnings.filter((w) => typeof w === "string") : [];
|
|
424
|
+
return { ...body, warnings };
|
|
425
|
+
},
|
|
410
426
|
async signOut(signIn) {
|
|
411
427
|
const { status, body } = await call("DELETE", "session", { signIn });
|
|
412
428
|
if (status !== 200)
|
|
@@ -3243,6 +3259,23 @@ var SESSION_TOKEN_VARIABLE = "ARMADA_SESSION_TOKEN";
|
|
|
3243
3259
|
var API_KEY_VARIABLE = "ARMADA_API_KEY";
|
|
3244
3260
|
var API_URL_VARIABLE = "ARMADA_API_URL";
|
|
3245
3261
|
var SIGNED_IN_TO_VARIABLE = "ARMADA_SIGNED_IN_TO";
|
|
3262
|
+
var TURSO_LEASE_VARIABLE = "ARMADA_TURSO_LEASE";
|
|
3263
|
+
var formatLease = (lease) => Buffer.from(JSON.stringify(lease), "utf8").toString("base64url");
|
|
3264
|
+
function parseLease(value) {
|
|
3265
|
+
if (!value?.trim())
|
|
3266
|
+
return null;
|
|
3267
|
+
try {
|
|
3268
|
+
const l = JSON.parse(Buffer.from(value.trim(), "base64url").toString("utf8"));
|
|
3269
|
+
const keys = ["api", "organization", "url", "token", "expiresAt", "revision"];
|
|
3270
|
+
if (!keys.every((k) => typeof l[k] === "string" && l[k]))
|
|
3271
|
+
return null;
|
|
3272
|
+
if (Number.isNaN(Date.parse(String(l.expiresAt))))
|
|
3273
|
+
return null;
|
|
3274
|
+
return Object.fromEntries(keys.map((k) => [k, String(l[k])]));
|
|
3275
|
+
} catch {
|
|
3276
|
+
return null;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3246
3279
|
function armadaAddress(url) {
|
|
3247
3280
|
try {
|
|
3248
3281
|
const u = new URL(url.trim());
|
|
@@ -3280,7 +3313,7 @@ var fromEnv = (env, variable) => {
|
|
|
3280
3313
|
const value = clean(env[variable]);
|
|
3281
3314
|
return value ? { value, source: { kind: "env", variable } } : null;
|
|
3282
3315
|
};
|
|
3283
|
-
function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
3316
|
+
function resolveCredentials({ env, store = {}, personal, ghToken, armada }) {
|
|
3284
3317
|
const fromStore = (variable) => {
|
|
3285
3318
|
const value = clean(store[variable]);
|
|
3286
3319
|
return value ? { value, source: { kind: "store" } } : null;
|
|
@@ -3301,10 +3334,12 @@ function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
|
3301
3334
|
const storedKey = fromStore(API_KEY_VARIABLE);
|
|
3302
3335
|
const armadaSignInElsewhere = !here && (session || storedKey) ? signedInTo : null;
|
|
3303
3336
|
const armadaSignIn = envKey ? { kind: "api-key", key: envKey.value, source: envKey.source } : session && here ? { kind: "session", token: session.value, source: session.source } : storedKey && here ? { kind: "api-key", key: storedKey.value, source: storedKey.source } : null;
|
|
3337
|
+
const fromArmada = (value, detail) => value && detail ? { value, source: { kind: "armada", detail } } : null;
|
|
3338
|
+
const tursoPair = armada?.turso && !fromEnv(env, "ARMADA_TURSO_URL") && !fromEnv(env, "ARMADA_TURSO_TOKEN") ? armada.turso : null;
|
|
3304
3339
|
const found = {
|
|
3305
|
-
linearApiKey:
|
|
3306
|
-
tursoUrl: stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
|
|
3307
|
-
tursoToken: stored("ARMADA_TURSO_TOKEN"),
|
|
3340
|
+
linearApiKey: fromEnv(env, "LINEAR_API_KEY") ?? fromArmada(armada?.linearApiKey?.value, armada?.linearApiKey?.detail) ?? fromStore("LINEAR_API_KEY"),
|
|
3341
|
+
tursoUrl: fromArmada(tursoPair?.url, tursoPair?.detail) ?? stored("ARMADA_TURSO_URL") ?? (tursoUrlConfig ? { value: tursoUrlConfig, source: { kind: "config", key: "turso.url" } } : null),
|
|
3342
|
+
tursoToken: fromArmada(tursoPair?.token, tursoPair?.detail) ?? stored("ARMADA_TURSO_TOKEN"),
|
|
3308
3343
|
githubToken: fromEnv(env, "GITHUB_TOKEN") ?? fromEnv(env, "GH_TOKEN") ?? fromGh()
|
|
3309
3344
|
};
|
|
3310
3345
|
return {
|
|
@@ -3325,7 +3360,7 @@ function resolveCredentials({ env, store = {}, personal, ghToken }) {
|
|
|
3325
3360
|
}
|
|
3326
3361
|
var missingKeys = (credentials) => STORED_KEYS.filter((k) => credentials[k.name] === null);
|
|
3327
3362
|
function missingKeyMessage(key) {
|
|
3328
|
-
return `${key.variable} is not set. Set it in the environment,
|
|
3363
|
+
return `${key.variable} is not set. Set it in the environment, run \`armada auth login\` to store it on this machine (${key.hint}), or sign in with \`armada login\` to an Armada that keeps your organization's keys.`;
|
|
3329
3364
|
}
|
|
3330
3365
|
// ../core/src/dotenv.ts
|
|
3331
3366
|
var ASSIGNMENT = /^\s*(export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
@@ -5235,7 +5270,7 @@ async function loadStatus(config, opts) {
|
|
|
5235
5270
|
});
|
|
5236
5271
|
}
|
|
5237
5272
|
// package.json
|
|
5238
|
-
var version = "0.1.
|
|
5273
|
+
var version = "0.1.16";
|
|
5239
5274
|
|
|
5240
5275
|
// src/io.ts
|
|
5241
5276
|
class UsageError extends Error {
|
|
@@ -5258,15 +5293,91 @@ async function loadMachine(io) {
|
|
|
5258
5293
|
]);
|
|
5259
5294
|
return { paths, store, personal };
|
|
5260
5295
|
}
|
|
5261
|
-
|
|
5296
|
+
var hhmm = (iso) => `${iso.slice(0, 16).replace("T", " ")} UTC`;
|
|
5297
|
+
var wantsArmada = (env) => !env.LINEAR_API_KEY?.trim() || !env.ARMADA_TURSO_URL?.trim() && !env.ARMADA_TURSO_TOKEN?.trim();
|
|
5298
|
+
var fromLease = (lease) => ({
|
|
5299
|
+
url: lease.url,
|
|
5300
|
+
token: lease.token,
|
|
5301
|
+
detail: `a token made for this terminal, expires ${hhmm(lease.expiresAt)}`
|
|
5302
|
+
});
|
|
5303
|
+
async function fromArmada(io, machine, credentials) {
|
|
5304
|
+
const signIn = credentials.armadaSignIn;
|
|
5305
|
+
if (!signIn)
|
|
5306
|
+
return null;
|
|
5307
|
+
const now = (io.now ?? (() => new Date))();
|
|
5308
|
+
const address = armadaAddress(credentials.armadaApi.url);
|
|
5309
|
+
const stored = parseLease(machine.store?.values[TURSO_LEASE_VARIABLE]);
|
|
5310
|
+
const lease = stored && stored.api === address && Date.parse(stored.expiresAt) > now.getTime() ? stored : null;
|
|
5311
|
+
const keep = async (next) => {
|
|
5312
|
+
if (!machine.paths || next === null && !machine.store?.assigned.includes(TURSO_LEASE_VARIABLE))
|
|
5313
|
+
return;
|
|
5314
|
+
await updateCredentialStore(machine.paths, { [TURSO_LEASE_VARIABLE]: next ? formatLease(next) : null }).catch((err) => io.stderr(`! the Turso token from Armada could not be kept in ${machine.paths?.credentials} (${err.code ?? "error"}); it is asked again next time
|
|
5315
|
+
`));
|
|
5316
|
+
};
|
|
5317
|
+
let answer;
|
|
5318
|
+
try {
|
|
5319
|
+
answer = await armadaApi({ url: credentials.armadaApi.url, ...io.fetch ? { fetch: io.fetch } : {} }).credentials(signIn, lease ? { revision: lease.revision, expiresAt: lease.expiresAt } : null);
|
|
5320
|
+
} catch (err) {
|
|
5321
|
+
if (!(err instanceof ArmadaApiError))
|
|
5322
|
+
throw err;
|
|
5323
|
+
if (err.signedOut || err.status === 403) {
|
|
5324
|
+
await keep(null);
|
|
5325
|
+
io.stderr(`! Armada gave no keys (${err.message}); using this machine's${err.next ? `. Next: ${err.next}` : ""}
|
|
5326
|
+
`);
|
|
5327
|
+
return null;
|
|
5328
|
+
}
|
|
5329
|
+
if (err.status === 503 && !lease)
|
|
5330
|
+
return null;
|
|
5331
|
+
io.stderr(`! Armada gave no keys (${err.message}); using this machine's${lease ? " and the Turso token it made earlier" : ""}${err.next ? `. Next: ${err.next}` : ""}
|
|
5332
|
+
`);
|
|
5333
|
+
return lease ? { linearApiKey: null, turso: fromLease(lease) } : null;
|
|
5334
|
+
}
|
|
5335
|
+
for (const w of answer.warnings)
|
|
5336
|
+
io.stderr(`! Armada: ${w}
|
|
5337
|
+
`);
|
|
5338
|
+
const linearApiKey = answer.linear ? {
|
|
5339
|
+
value: answer.linear.apiKey,
|
|
5340
|
+
detail: answer.linear.scope === "own" ? "your own key" : `the key of ${answer.organization.name}`
|
|
5341
|
+
} : null;
|
|
5342
|
+
const t = answer.turso;
|
|
5343
|
+
if (t?.kind === "minted") {
|
|
5344
|
+
const next = {
|
|
5345
|
+
api: address,
|
|
5346
|
+
organization: answer.organization.id,
|
|
5347
|
+
url: t.url,
|
|
5348
|
+
token: t.token,
|
|
5349
|
+
expiresAt: t.expiresAt,
|
|
5350
|
+
revision: t.revision
|
|
5351
|
+
};
|
|
5352
|
+
await keep(next);
|
|
5353
|
+
return { linearApiKey, turso: fromLease(next) };
|
|
5354
|
+
}
|
|
5355
|
+
if (t?.kind === "kept" && lease)
|
|
5356
|
+
return { linearApiKey, turso: fromLease(lease) };
|
|
5357
|
+
await keep(null);
|
|
5358
|
+
return {
|
|
5359
|
+
linearApiKey,
|
|
5360
|
+
turso: t?.kind === "stored" ? { url: t.url, token: t.token, detail: `the stored Turso access of ${answer.organization.name}` } : null
|
|
5361
|
+
};
|
|
5362
|
+
}
|
|
5363
|
+
async function loadCredentials(io, { armada = true } = {}) {
|
|
5262
5364
|
const machine = await loadMachine(io);
|
|
5263
|
-
|
|
5365
|
+
let gh;
|
|
5366
|
+
const sources = {
|
|
5264
5367
|
env: io.env,
|
|
5265
|
-
ghToken:
|
|
5368
|
+
ghToken: () => {
|
|
5369
|
+
if (gh === undefined)
|
|
5370
|
+
gh = io.ghToken();
|
|
5371
|
+
return gh;
|
|
5372
|
+
},
|
|
5266
5373
|
...machine.store ? { store: machine.store.values } : {},
|
|
5267
5374
|
...machine.personal ? { personal: machine.personal.config } : {}
|
|
5268
|
-
}
|
|
5269
|
-
|
|
5375
|
+
};
|
|
5376
|
+
const local = resolveCredentials(sources);
|
|
5377
|
+
if (!armada || !local.armadaSignIn || !wantsArmada(io.env))
|
|
5378
|
+
return { machine, credentials: local };
|
|
5379
|
+
const keys = await fromArmada(io, machine, local);
|
|
5380
|
+
return { machine, credentials: keys ? resolveCredentials({ ...sources, armada: keys }) : local };
|
|
5270
5381
|
}
|
|
5271
5382
|
var describeSource = (s) => {
|
|
5272
5383
|
switch (s.kind) {
|
|
@@ -5274,6 +5385,8 @@ var describeSource = (s) => {
|
|
|
5274
5385
|
return `environment (${s.variable})`;
|
|
5275
5386
|
case "store":
|
|
5276
5387
|
return "credentials file";
|
|
5388
|
+
case "armada":
|
|
5389
|
+
return `Armada: ${s.detail}`;
|
|
5277
5390
|
case "config":
|
|
5278
5391
|
return `personal config (${s.key})`;
|
|
5279
5392
|
case "gh":
|
|
@@ -5405,13 +5518,14 @@ async function authStatus(io, json) {
|
|
|
5405
5518
|
async function authLogout(io) {
|
|
5406
5519
|
const paths = requirePaths(machinePaths(io.env));
|
|
5407
5520
|
const store = await readCredentialStore(paths.credentials);
|
|
5408
|
-
const
|
|
5521
|
+
const variables = [...STORED_KEYS.map((k) => k.variable), TURSO_LEASE_VARIABLE];
|
|
5522
|
+
const stored = variables.filter((v) => store.assigned.includes(v));
|
|
5409
5523
|
if (!stored.length) {
|
|
5410
5524
|
io.stdout(`No Armada key is stored in ${paths.credentials}.
|
|
5411
5525
|
`);
|
|
5412
5526
|
} else {
|
|
5413
|
-
await updateCredentialStore(paths, Object.fromEntries(
|
|
5414
|
-
io.stdout(`Removed ${stored.
|
|
5527
|
+
await updateCredentialStore(paths, Object.fromEntries(variables.map((v) => [v, null])));
|
|
5528
|
+
io.stdout(`Removed ${stored.join(", ")} from ${paths.credentials}.
|
|
5415
5529
|
`);
|
|
5416
5530
|
}
|
|
5417
5531
|
const fromEnv = STORED_KEYS.filter((k) => io.env[k.variable]?.trim()).map((k) => k.variable);
|
|
@@ -6214,7 +6328,8 @@ async function loginWithApiKey(io, credentials) {
|
|
|
6214
6328
|
await updateCredentialStore(p, {
|
|
6215
6329
|
[API_KEY_VARIABLE]: key,
|
|
6216
6330
|
[SESSION_TOKEN_VARIABLE]: null,
|
|
6217
|
-
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url)
|
|
6331
|
+
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
|
|
6332
|
+
[TURSO_LEASE_VARIABLE]: null
|
|
6218
6333
|
});
|
|
6219
6334
|
io.stdout(`Signed in to ${hostOf(credentials.armadaApi.url)} as ${describeIdentity(identity)}.
|
|
6220
6335
|
The key is stored in ${p.credentials}.
|
|
@@ -6222,7 +6337,7 @@ The key is stored in ${p.credentials}.
|
|
|
6222
6337
|
return 0;
|
|
6223
6338
|
}
|
|
6224
6339
|
async function login(io, apiKey) {
|
|
6225
|
-
const { machine, credentials } = await loadCredentials(io);
|
|
6340
|
+
const { machine, credentials } = await loadCredentials(io, { armada: false });
|
|
6226
6341
|
const host = hostOf(credentials.armadaApi.url);
|
|
6227
6342
|
if (credentials.armadaSignIn?.source.kind === "env")
|
|
6228
6343
|
io.stderr(`! ${API_KEY_VARIABLE} is set in the environment: it wins over what \`armada login\` stores.
|
|
@@ -6247,7 +6362,8 @@ Then confirm it at ${code.verificationUriComplete}
|
|
|
6247
6362
|
await updateCredentialStore(p, {
|
|
6248
6363
|
[SESSION_TOKEN_VARIABLE]: token,
|
|
6249
6364
|
[API_KEY_VARIABLE]: null,
|
|
6250
|
-
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url)
|
|
6365
|
+
[SIGNED_IN_TO_VARIABLE]: armadaAddress(url),
|
|
6366
|
+
[TURSO_LEASE_VARIABLE]: null
|
|
6251
6367
|
});
|
|
6252
6368
|
if (previous && previous !== token)
|
|
6253
6369
|
await apiOf(io, storedAt(machine)).signOut({ kind: "session", token: previous }).catch(() => {});
|
|
@@ -6259,7 +6375,7 @@ Then confirm it at ${code.verificationUriComplete}
|
|
|
6259
6375
|
return 0;
|
|
6260
6376
|
}
|
|
6261
6377
|
async function whoami(io, json) {
|
|
6262
|
-
const { credentials } = await loadCredentials(io);
|
|
6378
|
+
const { credentials } = await loadCredentials(io, { armada: false });
|
|
6263
6379
|
const signIn = requireSignIn(credentials);
|
|
6264
6380
|
const identity = await apiOf(io, credentials.armadaApi.url).whoami(signIn);
|
|
6265
6381
|
if (json) {
|
|
@@ -6273,10 +6389,10 @@ async function whoami(io, json) {
|
|
|
6273
6389
|
return 0;
|
|
6274
6390
|
}
|
|
6275
6391
|
async function logout(io) {
|
|
6276
|
-
const { machine } = await loadCredentials(io);
|
|
6392
|
+
const { machine } = await loadCredentials(io, { armada: false });
|
|
6277
6393
|
const p = paths(io);
|
|
6278
6394
|
const at = storedAt(machine);
|
|
6279
|
-
const stored = [SESSION_TOKEN_VARIABLE, API_KEY_VARIABLE].filter((k) => machine.store?.assigned.includes(k));
|
|
6395
|
+
const stored = [SESSION_TOKEN_VARIABLE, API_KEY_VARIABLE, TURSO_LEASE_VARIABLE].filter((k) => machine.store?.assigned.includes(k));
|
|
6280
6396
|
const session = machine.store?.values[SESSION_TOKEN_VARIABLE]?.trim();
|
|
6281
6397
|
if (session) {
|
|
6282
6398
|
await apiOf(io, at).signOut({ kind: "session", token: session }).catch((err) => io.stderr(`! the session could not be revoked on Armada (${err instanceof Error ? err.message : String(err)}); it expires on its own
|
|
@@ -6286,7 +6402,8 @@ async function logout(io) {
|
|
|
6286
6402
|
await updateCredentialStore(p, {
|
|
6287
6403
|
[SESSION_TOKEN_VARIABLE]: null,
|
|
6288
6404
|
[API_KEY_VARIABLE]: null,
|
|
6289
|
-
[SIGNED_IN_TO_VARIABLE]: null
|
|
6405
|
+
[SIGNED_IN_TO_VARIABLE]: null,
|
|
6406
|
+
[TURSO_LEASE_VARIABLE]: null
|
|
6290
6407
|
});
|
|
6291
6408
|
io.stdout(`Signed out of ${hostOf(at)}: removed the sign-in from ${p.credentials}.
|
|
6292
6409
|
`);
|
|
@@ -6749,7 +6866,7 @@ Options:
|
|
|
6749
6866
|
${TICKET_HELP} -h, --help Show this help; \`armada <command> --help\` shows one command
|
|
6750
6867
|
-v, --version Print the version
|
|
6751
6868
|
|
|
6752
|
-
Keys (the environment
|
|
6869
|
+
Keys (the environment first, then Armada when signed in, then the file):
|
|
6753
6870
|
LINEAR_API_KEY Linear API key (required by status, init, brief, claim, report,
|
|
6754
6871
|
release, ask and answer)
|
|
6755
6872
|
ARMADA_TURSO_URL Turso database URL (required by init, inbox and status --all;
|
|
@@ -6763,7 +6880,8 @@ Keys (the environment always wins over the file):
|
|
|
6763
6880
|
Files:
|
|
6764
6881
|
$XDG_CONFIG_HOME/armada (default ~/.config/armada)
|
|
6765
6882
|
credentials KEY=value lines, mode 0600, written by \`armada auth login\` and
|
|
6766
|
-
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY
|
|
6883
|
+
\`armada login\` (the sign-in: ARMADA_SESSION_TOKEN or ARMADA_API_KEY; the
|
|
6884
|
+
Turso token Armada made for this terminal: ARMADA_TURSO_LEASE)
|
|
6767
6885
|
config.toml personal defaults: language, [turso] url, [dashboard] url, [api] url
|
|
6768
6886
|
`;
|
|
6769
6887
|
function commandHelp(command) {
|