@artifactshare/cli 0.10.1 → 0.10.2
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/CHANGELOG.md +6 -0
- package/README.md +3 -3
- package/dist/index.js +40 -9
- package/package.json +6 -1
- package/skills/artifactshare/SKILL.md +5 -4
- package/skills/artifactshare/artifactshare.mdc +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to `@artifactshare/cli` are documented here.
|
|
4
4
|
For user-facing announcements, see https://artifactshare.com/updates?product=cli.
|
|
5
5
|
|
|
6
|
+
## Unreleased
|
|
7
|
+
|
|
8
|
+
## 0.10.2 - 2026-08-09
|
|
9
|
+
|
|
10
|
+
- Rotate device-login refresh credentials after use and revoke their credential family during `logout`; a failed remote revoke now leaves the local credential intact.
|
|
11
|
+
|
|
6
12
|
## 0.10.1 - 2026-08-09
|
|
7
13
|
|
|
8
14
|
- Publish the first npm release covered by the Artifact Share source-available license.
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ runs add versions to the same file.
|
|
|
45
45
|
|
|
46
46
|
- **Interactive**: run `npx --yes @artifactshare/cli login`, or run `share`, `update`, or `download` directly — those commands start sign-in for you when unauthenticated (the CLI prints a link and code to open in your browser). Profiles created by `login` renew expired CLI sessions automatically during normal use.
|
|
47
47
|
- **CI / non-interactive**: issue a token at `https://artifactshare.com/settings/tokens`, then set `ARTIFACTSHARE_TOKEN` (or pass `--token`). Without a token, non-interactive runs fail with `error.code: "auth_required"` instead of hanging.
|
|
48
|
-
- Multiple accounts: keep one local profile per account (`profiles list` / `profiles use <name>`). In non-interactive agents, pipe an issued token into `profiles import-token --profile <name> --json` to create a saved API-token profile without browser login; API-token profiles are not renewed by the CLI. Use `logout --profile <name>` to
|
|
48
|
+
- Multiple accounts: keep one local profile per account (`profiles list` / `profiles use <name>`). In non-interactive agents, pipe an issued token into `profiles import-token --profile <name> --json` to create a saved API-token profile without browser login; API-token profiles are not renewed by the CLI. Use `logout --profile <name>` to revoke a device-login credential before removing it locally while keeping profile metadata, or `profiles delete <name>` to remove the profile entry too. API-token profiles are only removed locally.
|
|
49
49
|
|
|
50
50
|
## Commands
|
|
51
51
|
|
|
@@ -63,7 +63,7 @@ runs add versions to the same file.
|
|
|
63
63
|
| `comments list / post / edit / resolve / reopen / delete <target>` | Read, write, edit, resolve, reopen, and permanently delete comments |
|
|
64
64
|
| `projects list / create / edit` | List, create, and edit project destinations and audience |
|
|
65
65
|
| `move <target>` | Move an existing file into a project or back home; `edit` is preferred for new automation |
|
|
66
|
-
| `login` / `logout` / `whoami` | Sign in,
|
|
66
|
+
| `login` / `logout` / `whoami` | Sign in, revoke a device-login credential before removing it locally, and check who you are |
|
|
67
67
|
| `doctor` | Diagnose auth, destination, network, and upload readiness — tells you the next command to run |
|
|
68
68
|
| `changelog` | Show the installed version, this release's notes, and the public updates page |
|
|
69
69
|
| `profiles list / use / import-token / delete` | Switch between local account profiles, import an issued token from stdin, and delete profile entries |
|
|
@@ -129,4 +129,4 @@ Quote paths and free-form text before passing them through a shell. Artifact Sha
|
|
|
129
129
|
|
|
130
130
|
## License
|
|
131
131
|
|
|
132
|
-
The npm package through version 0.9.0 is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). From
|
|
132
|
+
The npm package through version 0.9.0 is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). From version 0.10.0 onward, `@artifactshare/cli` is covered by the [source-available license](LICENSE). Version 0.10.0 was intentionally not published; version 0.10.1 is the first npm release under the new license.
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { cli, define, lazy } from "gunshi";
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { appendFile, chmod, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
6
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
6
7
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
7
8
|
import { homedir } from "node:os";
|
|
8
9
|
import { createReadStream } from "node:fs";
|
|
9
10
|
import { Blob } from "node:buffer";
|
|
10
|
-
import { createHash } from "node:crypto";
|
|
11
11
|
//#region src/constants.ts
|
|
12
12
|
const DEFAULT_BASE_URL = "https://artifactshare.com";
|
|
13
13
|
const DEVICE_CLIENT_ID = "artifactshare-cli";
|
|
@@ -1790,7 +1790,8 @@ function parseStoredProfileCredential(raw) {
|
|
|
1790
1790
|
kind: "session",
|
|
1791
1791
|
session_token: parsed.session_token,
|
|
1792
1792
|
refresh_token: parsed.refresh_token,
|
|
1793
|
-
...parsed.expires_at !== void 0 ? { expires_at: parsed.expires_at } : {}
|
|
1793
|
+
...parsed.expires_at !== void 0 ? { expires_at: parsed.expires_at } : {},
|
|
1794
|
+
...typeof parsed.pending_rotation_id === "string" && parsed.pending_rotation_id ? { pending_rotation_id: parsed.pending_rotation_id } : {}
|
|
1794
1795
|
};
|
|
1795
1796
|
return {
|
|
1796
1797
|
ok: true,
|
|
@@ -2599,12 +2600,27 @@ async function runAuthenticatedApi(credential, options, request) {
|
|
|
2599
2600
|
return await request(refreshed.credential);
|
|
2600
2601
|
}
|
|
2601
2602
|
async function refreshStoredProfileSession(profile, refreshToken, options) {
|
|
2603
|
+
const stored = await readProfileToken(profile, options);
|
|
2604
|
+
if (!stored.ok || stored.credential.kind !== "session") return { ok: false };
|
|
2605
|
+
const rotationRequestId = stored.credential.pending_rotation_id ?? randomUUID();
|
|
2606
|
+
if (!stored.credential.pending_rotation_id) {
|
|
2607
|
+
if (!(await saveProfileSessionCredential(profile, {
|
|
2608
|
+
...stored.credential,
|
|
2609
|
+
pending_rotation_id: rotationRequestId
|
|
2610
|
+
}, options)).ok) return {
|
|
2611
|
+
ok: false,
|
|
2612
|
+
error: tokenStoreUnavailableError(profile)
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2602
2615
|
const request = await requestConfig(options);
|
|
2603
2616
|
if (request.error) return {
|
|
2604
2617
|
ok: false,
|
|
2605
2618
|
error: request.error
|
|
2606
2619
|
};
|
|
2607
|
-
const result = await apiPostPublic("/api/cli/auth/refresh", {
|
|
2620
|
+
const result = await apiPostPublic("/api/cli/auth/refresh", {
|
|
2621
|
+
refresh_token: refreshToken,
|
|
2622
|
+
rotation_request_id: rotationRequestId
|
|
2623
|
+
}, options, request.init);
|
|
2608
2624
|
if (result.error) return {
|
|
2609
2625
|
ok: false,
|
|
2610
2626
|
error: result.error
|
|
@@ -2617,14 +2633,14 @@ async function refreshStoredProfileSession(profile, refreshToken, options) {
|
|
|
2617
2633
|
error: mapApiError(response.status, body, { baseUrl: baseUrlOf(options) })
|
|
2618
2634
|
};
|
|
2619
2635
|
}
|
|
2620
|
-
if (typeof body?.access_token !== "string" || body.access_token.length === 0 || body.token_type?.toLowerCase() !== "bearer" || typeof body.expires_at !== "string") return {
|
|
2636
|
+
if (typeof body?.access_token !== "string" || body.access_token.length === 0 || body.token_type?.toLowerCase() !== "bearer" || typeof body.expires_at !== "string" || typeof body.refresh_token !== "string" || !body.refresh_token || typeof body.refresh_token_expires_at !== "string") return {
|
|
2621
2637
|
ok: false,
|
|
2622
2638
|
error: validationError("Refresh response was invalid.", "Run login again. If this repeats, report the response shape.", "service_error")
|
|
2623
2639
|
};
|
|
2624
2640
|
if (!(await saveProfileSessionCredential(profile, {
|
|
2625
2641
|
kind: "session",
|
|
2626
2642
|
session_token: body.access_token,
|
|
2627
|
-
refresh_token:
|
|
2643
|
+
refresh_token: body.refresh_token,
|
|
2628
2644
|
expires_at: body.expires_at
|
|
2629
2645
|
}, options)).ok) return {
|
|
2630
2646
|
ok: false,
|
|
@@ -4435,11 +4451,17 @@ function configData(config, resolved) {
|
|
|
4435
4451
|
//#endregion
|
|
4436
4452
|
//#region src/command-runners/profile-credentials.ts
|
|
4437
4453
|
async function deleteCredentialForProfileEntry(profile, rawEntry, options) {
|
|
4454
|
+
return await deleteProfileCredential(profile, optionsForProfileEntry(rawEntry, options));
|
|
4455
|
+
}
|
|
4456
|
+
async function readCredentialForProfileEntry(profile, rawEntry, options) {
|
|
4457
|
+
return await readProfileToken(profile, optionsForProfileEntry(rawEntry, options));
|
|
4458
|
+
}
|
|
4459
|
+
function optionsForProfileEntry(rawEntry, options) {
|
|
4438
4460
|
const entry = isRecord(rawEntry) ? rawEntry : {};
|
|
4439
|
-
return
|
|
4461
|
+
return {
|
|
4440
4462
|
...options,
|
|
4441
4463
|
baseUrl: nonEmpty(entry.base_url) ?? "https://artifactshare.com"
|
|
4442
|
-
}
|
|
4464
|
+
};
|
|
4443
4465
|
}
|
|
4444
4466
|
//#endregion
|
|
4445
4467
|
//#region src/command-runners/logout.ts
|
|
@@ -4463,6 +4485,15 @@ async function runLogout(parsed, mode) {
|
|
|
4463
4485
|
profile = defaultProfile;
|
|
4464
4486
|
}
|
|
4465
4487
|
const rawEntry = config.profiles?.[profile];
|
|
4488
|
+
const profileOptions = optionsForProfileEntry(rawEntry, parsed.options);
|
|
4489
|
+
const stored = await readCredentialForProfileEntry(profile, rawEntry, parsed.options);
|
|
4490
|
+
if (stored.ok && stored.credential.kind === "session") {
|
|
4491
|
+
const request = await requestConfig(profileOptions);
|
|
4492
|
+
if (request.error) return writeFailure(command, request.error, mode, 1);
|
|
4493
|
+
const revoked = await apiPostPublic("/api/cli/auth/revoke", { refresh_token: stored.credential.refresh_token }, profileOptions, request.init);
|
|
4494
|
+
if (revoked.error) return writeFailure(command, revoked.error, mode, 1);
|
|
4495
|
+
if (!revoked.response.ok && revoked.response.status !== 401) return writeFailure(command, mapApiError(revoked.response.status, revoked.body, { baseUrl: baseUrlOf(profileOptions) }), mode, 1);
|
|
4496
|
+
}
|
|
4466
4497
|
const deleted = await deleteCredentialForProfileEntry(profile, rawEntry, parsed.options);
|
|
4467
4498
|
if (!deleted.ok) return writeFailure(command, tokenStoreUnavailableError(profile), mode, 1);
|
|
4468
4499
|
return writeSuccess(command, {
|
|
@@ -5670,13 +5701,13 @@ Common failures:
|
|
|
5670
5701
|
});
|
|
5671
5702
|
const logoutDefinition = define({
|
|
5672
5703
|
name: "logout",
|
|
5673
|
-
description: "
|
|
5704
|
+
description: "Revoke and remove the saved credential for a CLI profile.",
|
|
5674
5705
|
toKebab: true,
|
|
5675
5706
|
args: commonArgs,
|
|
5676
5707
|
examples: `npx --yes @artifactshare/cli logout --profile client-a --json
|
|
5677
5708
|
npx --yes @artifactshare/cli logout --json
|
|
5678
5709
|
|
|
5679
|
-
logout
|
|
5710
|
+
logout revokes a device-login refresh credential before removing it locally. API-token profiles are removed locally only. Profile metadata stays in config.json for re-login hints.
|
|
5680
5711
|
When no --profile is passed, the global default profile is used.
|
|
5681
5712
|
|
|
5682
5713
|
Common failures:
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artifactshare/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Upload and share HTML, Markdown, folders, and static sites from terminals, AI agents, automation, and CI.",
|
|
5
5
|
"homepage": "https://artifactshare.com/connect",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/artifactshare/artifactshare.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
6
11
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
12
|
"keywords": [
|
|
8
13
|
"artifact-share",
|
|
@@ -61,7 +61,7 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
|
|
|
61
61
|
| Create a project | `projects create 'Name' --json` |
|
|
62
62
|
| Find an ID from a title | `resolve <value> --json` |
|
|
63
63
|
| Open a share URL | `open <url> --json` |
|
|
64
|
-
| Log out
|
|
64
|
+
| Log out | `logout --profile <name> --json` |
|
|
65
65
|
|
|
66
66
|
## Authentication
|
|
67
67
|
|
|
@@ -72,9 +72,10 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
|
|
|
72
72
|
browser for approval. Use it when a user is present; the pending event on
|
|
73
73
|
stderr includes `browser_open`. Do not pass API tokens to `login`.
|
|
74
74
|
Profiles created by `login` renew expired CLI sessions automatically.
|
|
75
|
-
- `logout --profile <name> --json`
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
- `logout --profile <name> --json` revokes a device-login refresh credential
|
|
76
|
+
before removing it locally and leaves profile metadata in `config.json`.
|
|
77
|
+
If remote revoke fails, the local credential is kept and logout fails.
|
|
78
|
+
API-token profiles are removed locally only and are not revoked on the server.
|
|
78
79
|
- To keep using an issued token as a named profile without TTY or browser
|
|
79
80
|
login, pipe it on standard input:
|
|
80
81
|
`printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`.
|
|
@@ -52,7 +52,7 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
|
|
|
52
52
|
- In agents, CI, or scripts, ask the user to issue an API token at `https://artifactshare.com/settings/tokens`, then run normal commands with `ARTIFACTSHARE_TOKEN` or `--token`; do not pass API tokens to `login`.
|
|
53
53
|
- To save that token as a named profile without TTY or browser login, pipe it on standard input: `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`. Imported API-token profiles are not renewed by the CLI. Add `--allow-plaintext-token-store` only on a trusted machine without a native token store.
|
|
54
54
|
- Use `login --profile <name> --json` when a user is present for browser approval. The pending event on stderr includes `browser_open`. Profiles created by `login` renew expired CLI sessions automatically.
|
|
55
|
-
-
|
|
55
|
+
- Use `logout --profile <name> --json` to revoke a device-login credential before removing it locally; this keeps profile metadata. API-token profiles are removed locally only and their server token is not revoked.
|
|
56
56
|
- Switch profiles with `profiles use <name> --json`; list with `profiles list --json`; remove a profile entry and its credential with `profiles delete <name> --json`.
|
|
57
57
|
- When the user gives an Artifact Share URL, start with `open <artifact-id-or-url> --json`. It ensures this rule is installed or updated, then reads single-file artifacts or returns a `download` next command for static sites and multi-file artifacts.
|
|
58
58
|
- Share with `share <path> --json`. In JSON output, give the user `data.artifact.url`; the artifact ID is `data.artifact.id`. Do not rerun `share` just to inspect the JSON shape: without `--key`, each successful run creates a new artifact. Posting to a project delivers to the audience defined by that project. Pick it with `--project-id <id>` or `--project <name>` (by exact name), or use the saved default. With no destination, share posts to home. Choose `home_audience` by purpose: use `config set home_audience private --scope user --json` for a personal safe default in this CLI environment, use `--scope repository` only for a policy agreed by all participants, and use `--visibility private|workspace|link` for one home post. For link sharing, pass exactly one of `--link-expires-at <RFC3339 UTC>` or `--no-link-expiry`; omit both to use the workspace default. Confirm the resolved audience with `config get home_audience --scope effective --json`; `--grant-email` does not change the resolved default.
|