@hive3/cli 0.1.0 → 0.1.1-beta.0

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.
Files changed (3) hide show
  1. package/README.md +21 -0
  2. package/package.json +1 -1
  3. package/src/login.js +22 -4
package/README.md CHANGED
@@ -11,6 +11,20 @@ hive whoami
11
11
  hive capabilities
12
12
  ```
13
13
 
14
+ The package installs both command names. Use `hive` or `hive3` interchangeably:
15
+
16
+ ```bash
17
+ hive3 login
18
+ hive3 whoami
19
+ ```
20
+
21
+ By default, `hive login` opens an approval page where the signed-in user chooses either Read Only or Full Access. Scripted logins can preselect a bundle:
22
+
23
+ ```bash
24
+ hive login --access read
25
+ hive login --access full
26
+ ```
27
+
14
28
  The CLI stores credentials in the OS config directory, or `HIVE_CONFIG_HOME` when set. It prints approval URLs, codes, key prefixes, and config paths, but never prints the API key secret after login completion.
15
29
 
16
30
  Useful environment overrides:
@@ -21,6 +35,13 @@ Useful environment overrides:
21
35
 
22
36
  ## Scopes
23
37
 
38
+ Most users should use the login approval page's Read Only or Full Access choice:
39
+
40
+ - Read Only: read account, community capability, post, and resource data.
41
+ - Full Access: read/write API capabilities, including community admin actions where the person already has the live role. Account deletion requests still require an explicit confirmation command.
42
+
43
+ Advanced users can request exact scopes with repeated `--scope` flags.
44
+
24
45
  - `account:read` and `account:write`: profile, account preferences, wallets visibility, NFT exposure, export/deletion requests, uploads, and builder config.
25
46
  - `posts:read` and `posts:write`: posts and comments.
26
47
  - `resources:read` and `resources:write`: events, courses, content, quests, jobs, participant workflows, evidence, attendance, progress, and applications.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hive3/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-beta.0",
4
4
  "description": "Command-line client for Hive's public API.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/login.js CHANGED
@@ -8,6 +8,7 @@ import { saveCredential } from "./config.js";
8
8
  export const DEFAULT_API_BASE_URL = "https://app.hive3.tech/api/v1";
9
9
  export const DEFAULT_APP_URL = "https://app.hive3.tech";
10
10
  export const DEFAULT_LABEL = "Hive CLI";
11
+ export const DEFAULT_PERMISSION_MODE = "select";
11
12
  export const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
12
13
 
13
14
  export function loginUsage() {
@@ -15,10 +16,11 @@ export function loginUsage() {
15
16
  "Usage: hive login [options]",
16
17
  "",
17
18
  "Options:",
19
+ " --access <read|full> Permission bundle to approve; omit to choose in browser",
18
20
  " --api-url <url> Public API base URL",
19
21
  " --app-url <url> Browser app URL for approval",
20
22
  " --label <label> Local credential label",
21
- " --scope <scope> Requested API scope, repeatable",
23
+ " --scope <scope> Advanced: request an exact API scope, repeatable",
22
24
  " --timeout-ms <ms> Login polling timeout",
23
25
  " --no-open Print the URL without opening a browser",
24
26
  " -h, --help Show help",
@@ -36,6 +38,8 @@ export function parseLoginArgs(args, env = process.env) {
36
38
  appUrl: env.HIVE_APP_URL || DEFAULT_APP_URL,
37
39
  label: DEFAULT_LABEL,
38
40
  noOpen: false,
41
+ permissionMode: DEFAULT_PERMISSION_MODE,
42
+ permissionModeExplicit: false,
39
43
  scopes: [],
40
44
  timeoutMs: DEFAULT_TIMEOUT_MS,
41
45
  };
@@ -44,6 +48,12 @@ export function parseLoginArgs(args, env = process.env) {
44
48
  const flag = args[index];
45
49
  if (flag === "--no-open") {
46
50
  options.noOpen = true;
51
+ } else if (flag === "--access" || flag === "--permission") {
52
+ index += 1;
53
+ const value = requiredFlagValue(flag, args[index]);
54
+ if (value !== "read" && value !== "full") throw new Error(`${flag} must be read or full`);
55
+ options.permissionMode = value;
56
+ options.permissionModeExplicit = true;
47
57
  } else if (flag === "--api-url") {
48
58
  index += 1;
49
59
  options.apiBaseUrl = requiredFlagValue(flag, args[index]);
@@ -69,6 +79,9 @@ export function parseLoginArgs(args, env = process.env) {
69
79
  if (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0) {
70
80
  throw new Error("--timeout-ms must be a positive number");
71
81
  }
82
+ if (options.permissionModeExplicit && options.scopes.length > 0) {
83
+ throw new Error("--access cannot be combined with --scope. Use one permission bundle or exact scopes.");
84
+ }
72
85
  return { help: false, options };
73
86
  }
74
87
 
@@ -123,11 +136,16 @@ function writeLine(stream, message = "") {
123
136
  export async function login(options, overrides = {}) {
124
137
  const deps = { ...defaultDeps(), ...overrides };
125
138
  const apiBaseUrl = normalizeBaseUrl(options.apiBaseUrl);
126
- const start = await postJson(deps.fetch, `${apiBaseUrl}/cli/auth/start`, {
139
+ const payload = {
127
140
  appUrl: options.appUrl,
128
141
  label: options.label,
129
- scopes: options.scopes.length > 0 ? options.scopes : undefined,
130
- });
142
+ };
143
+ if (options.scopes.length > 0) {
144
+ payload.scopes = options.scopes;
145
+ } else {
146
+ payload.permissionMode = options.permissionMode || DEFAULT_PERMISSION_MODE;
147
+ }
148
+ const start = await postJson(deps.fetch, `${apiBaseUrl}/cli/auth/start`, payload);
131
149
  const data = start.data;
132
150
  // A malformed server response must not turn the poll loop into a busy loop
133
151
  // (NaN/0 sleeps) or a hammering one: fall back to a sane 2s interval.