sphereai-cli 1.0.3 → 1.0.4
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 +57 -400
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,219 +1,106 @@
|
|
|
1
1
|
# SphereAI CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Key-Based Authentication** - Authenticate using UserChannelKey (recommended)
|
|
8
|
-
- **OAuth2 Authentication** - Secure browser-based authentication flow with local callback server (legacy)
|
|
9
|
-
- **JWT Token Management** - Secure token storage with automatic user info extraction from token payload
|
|
10
|
-
- **File Tracking** - Git-like file tracking system with .sphereignore support
|
|
11
|
-
- **Multiple Output Formats** - JSON and table formats for all commands
|
|
12
|
-
- **Environment Override** - Support for environment variables and command-line options
|
|
13
|
-
- **Offline User Info** - User information extracted from JWT token (no API calls needed)
|
|
3
|
+
Official command-line interface for interacting with SphereAI services.
|
|
14
4
|
|
|
15
5
|
## Installation
|
|
16
6
|
|
|
17
|
-
### From npm (Global Installation)
|
|
18
|
-
|
|
19
7
|
```bash
|
|
20
8
|
npm install -g sphereai-cli
|
|
21
9
|
```
|
|
22
10
|
|
|
23
|
-
### From Source
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# Clone the repository
|
|
27
|
-
git clone <repository-url>
|
|
28
|
-
cd SphereAI.CLI
|
|
29
|
-
|
|
30
|
-
# Install dependencies
|
|
31
|
-
npm install
|
|
32
|
-
|
|
33
|
-
# Build the project
|
|
34
|
-
npm run build
|
|
35
|
-
|
|
36
|
-
# Link globally for local development
|
|
37
|
-
npm link
|
|
38
|
-
```
|
|
39
|
-
|
|
40
11
|
## Quick Start
|
|
41
12
|
|
|
42
|
-
### 1.
|
|
43
|
-
|
|
44
|
-
Set the required API URLs using environment variables:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
# Main API URL (for prompts and other resources)
|
|
48
|
-
export SPHEREAI_API_URL=https://api.develop.sphereai.nava.com.br
|
|
49
|
-
|
|
50
|
-
# CLI API URL (for key-based authentication)
|
|
51
|
-
export SPHEREAI_CLI_API_URL=https://cli.api.develop.sphereai.nava.com.br
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Or create a `.env` file in your project directory:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
# Main API URL (for prompts and other resources after authentication)
|
|
58
|
-
SPHEREAI_API_URL=https://api.develop.sphereai.nava.com.br
|
|
59
|
-
|
|
60
|
-
# CLI API URL (for key-based authentication)
|
|
61
|
-
SPHEREAI_CLI_API_URL=https://cli.api.develop.sphereai.nava.com.br
|
|
13
|
+
### 1. Authenticate
|
|
62
14
|
|
|
63
|
-
|
|
64
|
-
SPHEREAI_AUTH_URL=http://localhost:3000/login?callback=http://localhost:3001/callback
|
|
65
|
-
SPHEREAI_OAUTH_CALLBACK_PORT=3001
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 2. Authentication
|
|
69
|
-
|
|
70
|
-
#### Option A: UserChannelKey Authentication (Recommended)
|
|
71
|
-
|
|
72
|
-
Authenticate using your UserChannelKey:
|
|
15
|
+
Login using your UserChannelKey (provided by your administrator):
|
|
73
16
|
|
|
74
17
|
```bash
|
|
75
18
|
sphereai auth login YOUR_USER_CHANNEL_KEY
|
|
76
19
|
```
|
|
77
20
|
|
|
78
|
-
|
|
79
|
-
1. Send your key to the CLI API endpoint `https://cli.api.develop.sphereai.nava.com.br/api/v1/Auth`
|
|
80
|
-
2. Receive a JWT token and user information
|
|
81
|
-
3. Save the token securely to `~/.config/sphereai-cli/config.json`
|
|
82
|
-
4. Display user and channel information
|
|
83
|
-
|
|
84
|
-
Example response:
|
|
85
|
-
```
|
|
86
|
-
✔ Successfully authenticated!
|
|
87
|
-
✓ Logged in as: John Doe
|
|
88
|
-
ℹ Channel: Production Channel
|
|
89
|
-
ℹ Token expires in: 3600 seconds
|
|
90
|
-
ℹ Token expiration: 1/13/2025, 10:00:00 AM
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
#### Option B: OAuth2 Flow (Legacy)
|
|
94
|
-
|
|
95
|
-
For legacy OAuth2 authentication:
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
export SPHEREAI_AUTH_URL=https://your-auth-url.com/authorize
|
|
99
|
-
sphereai auth login-oauth
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
This will:
|
|
103
|
-
1. Open your browser to the authorization page
|
|
104
|
-
2. Start a local callback server on port 3001
|
|
105
|
-
3. Save the token securely to `~/.config/sphereai-cli/config.json`
|
|
106
|
-
|
|
107
|
-
#### Option C: Manual Token Setting
|
|
108
|
-
|
|
109
|
-
If you already have a JWT token:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
sphereai auth set-token YOUR_JWT_TOKEN
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### 3. Verify Authentication
|
|
21
|
+
### 2. Verify Authentication
|
|
116
22
|
|
|
117
23
|
```bash
|
|
118
24
|
sphereai auth whoami
|
|
119
25
|
```
|
|
120
26
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
- Name
|
|
125
|
-
- Channel Name
|
|
126
|
-
- Role
|
|
127
|
-
- Account creation date
|
|
27
|
+
### 3. Start Using
|
|
28
|
+
|
|
29
|
+
You're ready to use SphereAI CLI commands.
|
|
128
30
|
|
|
129
31
|
## Commands
|
|
130
32
|
|
|
131
|
-
### Authentication
|
|
33
|
+
### Authentication
|
|
132
34
|
|
|
133
35
|
| Command | Description |
|
|
134
36
|
|---------|-------------|
|
|
135
|
-
| `sphereai auth login <key>` | Authenticate
|
|
136
|
-
| `sphereai auth
|
|
137
|
-
| `sphereai auth
|
|
138
|
-
| `sphereai auth whoami` | Display current user information |
|
|
139
|
-
| `sphereai auth set-token <token>` | Manually set authentication token |
|
|
37
|
+
| `sphereai auth login <key>` | Authenticate with your UserChannelKey |
|
|
38
|
+
| `sphereai auth logout` | Sign out and clear stored credentials |
|
|
39
|
+
| `sphereai auth whoami` | Display your current user information |
|
|
140
40
|
| `sphereai auth config` | Display current configuration |
|
|
141
41
|
|
|
142
|
-
|
|
42
|
+
**Examples:**
|
|
143
43
|
|
|
144
44
|
```bash
|
|
145
|
-
#
|
|
45
|
+
# Login
|
|
146
46
|
sphereai auth login YOUR_USER_CHANNEL_KEY
|
|
147
47
|
|
|
148
|
-
#
|
|
149
|
-
sphereai auth login-oauth
|
|
150
|
-
|
|
151
|
-
# Set token manually
|
|
152
|
-
sphereai auth set-token YOUR_JWT_TOKEN
|
|
153
|
-
|
|
154
|
-
# Check current user
|
|
48
|
+
# Check who you are logged in as
|
|
155
49
|
sphereai auth whoami
|
|
156
50
|
|
|
157
|
-
#
|
|
51
|
+
# View as JSON
|
|
158
52
|
sphereai auth whoami --output json
|
|
159
53
|
|
|
160
|
-
#
|
|
161
|
-
sphereai auth config
|
|
162
|
-
|
|
163
|
-
# Logout (clear stored token)
|
|
54
|
+
# Logout
|
|
164
55
|
sphereai auth logout
|
|
165
56
|
```
|
|
166
57
|
|
|
167
|
-
### File Management
|
|
58
|
+
### File Management
|
|
59
|
+
|
|
60
|
+
Track files for use with SphereAI services. Works similar to git staging.
|
|
168
61
|
|
|
169
62
|
| Command | Description |
|
|
170
63
|
|---------|-------------|
|
|
171
|
-
| `sphereai files add [path]` | Add files to tracking
|
|
64
|
+
| `sphereai files add [path]` | Add files to tracking |
|
|
172
65
|
| `sphereai files list` | List all tracked files |
|
|
173
66
|
| `sphereai files remove <path>` | Remove a file from tracking |
|
|
174
|
-
| `sphereai files clear` | Clear all tracked files |
|
|
67
|
+
| `sphereai files clear --force` | Clear all tracked files |
|
|
175
68
|
| `sphereai files status` | Show status of tracked files |
|
|
176
|
-
| `sphereai files ignore` | Show
|
|
69
|
+
| `sphereai files ignore` | Show current ignore patterns |
|
|
177
70
|
|
|
178
|
-
|
|
71
|
+
**Examples:**
|
|
179
72
|
|
|
180
73
|
```bash
|
|
181
|
-
# Add all files from current directory
|
|
74
|
+
# Add all files from current directory
|
|
182
75
|
sphereai files add .
|
|
183
76
|
|
|
184
77
|
# Add a specific file
|
|
185
|
-
sphereai files add
|
|
78
|
+
sphereai files add myfile.txt
|
|
186
79
|
|
|
187
|
-
# Add files from a
|
|
80
|
+
# Add files from a directory
|
|
188
81
|
sphereai files add src/
|
|
189
82
|
|
|
190
83
|
# List tracked files
|
|
191
84
|
sphereai files list
|
|
192
85
|
|
|
193
|
-
# List
|
|
86
|
+
# List with details (size, date)
|
|
194
87
|
sphereai files list --verbose
|
|
195
88
|
|
|
196
|
-
#
|
|
89
|
+
# Check status
|
|
197
90
|
sphereai files status
|
|
198
91
|
|
|
199
92
|
# Remove a file from tracking
|
|
200
|
-
sphereai files remove
|
|
93
|
+
sphereai files remove myfile.txt
|
|
201
94
|
|
|
202
|
-
# Clear all tracked files
|
|
95
|
+
# Clear all tracked files
|
|
203
96
|
sphereai files clear --force
|
|
204
|
-
|
|
205
|
-
# Show .sphereignore patterns
|
|
206
|
-
sphereai files ignore
|
|
207
|
-
|
|
208
|
-
# Reload .sphereignore patterns
|
|
209
|
-
sphereai files ignore --reload
|
|
210
97
|
```
|
|
211
98
|
|
|
212
|
-
|
|
99
|
+
### .sphereignore File
|
|
213
100
|
|
|
214
|
-
|
|
101
|
+
Create a `.sphereignore` file in your project root to exclude files from tracking. It works like `.gitignore`.
|
|
215
102
|
|
|
216
|
-
**Example
|
|
103
|
+
**Example `.sphereignore`:**
|
|
217
104
|
|
|
218
105
|
```gitignore
|
|
219
106
|
# Dependencies
|
|
@@ -223,14 +110,14 @@ node_modules/
|
|
|
223
110
|
dist/
|
|
224
111
|
build/
|
|
225
112
|
|
|
226
|
-
# Environment
|
|
113
|
+
# Environment files
|
|
227
114
|
.env
|
|
228
115
|
.env.*
|
|
229
116
|
|
|
230
117
|
# Logs
|
|
231
118
|
*.log
|
|
232
119
|
|
|
233
|
-
# IDE
|
|
120
|
+
# IDE files
|
|
234
121
|
.vscode/
|
|
235
122
|
.idea/
|
|
236
123
|
|
|
@@ -238,292 +125,62 @@ build/
|
|
|
238
125
|
.DS_Store
|
|
239
126
|
```
|
|
240
127
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
- Use `#` for comments
|
|
244
|
-
- Directory patterns: `node_modules/`
|
|
245
|
-
- Wildcard patterns: `*.log`, `*.env.*`
|
|
246
|
-
- Exact matches: `.DS_Store`
|
|
247
|
-
|
|
248
|
-
If no `.sphereignore` file exists, the following default patterns are used:
|
|
249
|
-
|
|
250
|
-
- `node_modules`, `.git`, `dist`, `build`
|
|
251
|
-
- `.env`, `.env.*`, `*.log`
|
|
252
|
-
- `.DS_Store`, `coverage`, `.vscode`, `.idea`
|
|
253
|
-
|
|
254
|
-
## Global Options
|
|
255
|
-
|
|
256
|
-
All commands support these global options:
|
|
257
|
-
|
|
258
|
-
| Option | Description | Environment Variable |
|
|
259
|
-
|--------|-------------|---------------------|
|
|
260
|
-
| `--token <token>` | Override stored authentication token | `SPHEREAI_TOKEN` |
|
|
261
|
-
| `--output <format>` | Output format: `json` or `table` | - |
|
|
262
|
-
|
|
263
|
-
## Environment Variables
|
|
264
|
-
|
|
265
|
-
| Variable | Description | Required | Default |
|
|
266
|
-
|----------|-------------|----------|---------|
|
|
267
|
-
| `SPHEREAI_API_URL` | Main API URL for resources (prompts, etc.) | Yes | - |
|
|
268
|
-
| `SPHEREAI_CLI_API_URL` | CLI API URL for key-based authentication | Yes (for login) | - |
|
|
269
|
-
| `SPHEREAI_TOKEN` | Override stored authentication token | No | - |
|
|
270
|
-
| `SPHEREAI_AUTH_URL` | OAuth2 authorization URL (legacy) | No | - |
|
|
271
|
-
| `SPHEREAI_OAUTH_CALLBACK_PORT` | OAuth2 callback port (legacy) | No | 3001 |
|
|
272
|
-
|
|
273
|
-
### Examples
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
# Set required environment variables
|
|
277
|
-
export SPHEREAI_API_URL="https://api.develop.sphereai.nava.com.br"
|
|
278
|
-
export SPHEREAI_CLI_API_URL="https://cli.api.develop.sphereai.nava.com.br"
|
|
279
|
-
|
|
280
|
-
# Use custom token
|
|
281
|
-
sphereai --token YOUR_TOKEN auth whoami
|
|
282
|
-
|
|
283
|
-
# JSON output
|
|
284
|
-
sphereai auth whoami --output json
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
## Configuration
|
|
288
|
-
|
|
289
|
-
### Configuration File
|
|
290
|
-
|
|
291
|
-
The CLI stores configuration in: `~/.config/sphereai-cli/config.json`
|
|
292
|
-
|
|
293
|
-
This file contains:
|
|
294
|
-
- JWT authentication token
|
|
295
|
-
- API base URL
|
|
296
|
-
- OAuth2 authorization URL
|
|
297
|
-
- OAuth callback port (default: 3000)
|
|
298
|
-
|
|
299
|
-
**Note**: User information is extracted from the JWT token payload when needed, so it's always up-to-date with your current token.
|
|
300
|
-
|
|
301
|
-
### View Configuration
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
sphereai auth config
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### Clear Configuration
|
|
308
|
-
|
|
309
|
-
```bash
|
|
310
|
-
sphereai auth logout
|
|
311
|
-
```
|
|
128
|
+
If no `.sphereignore` file exists, common patterns are ignored by default (node_modules, .git, dist, build, .env, etc.).
|
|
312
129
|
|
|
313
130
|
## Output Formats
|
|
314
131
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
Human-readable formatted tables with colors.
|
|
318
|
-
|
|
319
|
-
```bash
|
|
320
|
-
sphereai auth whoami
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### JSON Format
|
|
324
|
-
|
|
325
|
-
Machine-readable JSON output for scripting and automation.
|
|
326
|
-
|
|
327
|
-
```bash
|
|
328
|
-
sphereai auth whoami --output json
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
## Error Handling
|
|
332
|
-
|
|
333
|
-
The CLI provides clear error messages for common issues:
|
|
334
|
-
|
|
335
|
-
- **401 Unauthorized**: Authentication required or token expired
|
|
336
|
-
- **403 Forbidden**: Insufficient permissions
|
|
337
|
-
- **404 Not Found**: Resource does not exist
|
|
338
|
-
- **400 Bad Request**: Validation errors with detailed field information
|
|
339
|
-
- **500 Internal Server Error**: Server-side issues
|
|
340
|
-
|
|
341
|
-
### Debug Mode
|
|
342
|
-
|
|
343
|
-
Enable debug output for troubleshooting:
|
|
132
|
+
All commands support two output formats:
|
|
344
133
|
|
|
345
134
|
```bash
|
|
346
|
-
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
## Examples
|
|
350
|
-
|
|
351
|
-
### Complete Authentication Workflow
|
|
352
|
-
|
|
353
|
-
```bash
|
|
354
|
-
# 1. Set API URLs (in .env file or environment variables)
|
|
355
|
-
export SPHEREAI_API_URL=https://api.develop.sphereai.nava.com.br
|
|
356
|
-
export SPHEREAI_CLI_API_URL=https://cli.api.develop.sphereai.nava.com.br
|
|
357
|
-
|
|
358
|
-
# 2. Authenticate using UserChannelKey
|
|
359
|
-
sphereai auth login YOUR_USER_CHANNEL_KEY
|
|
360
|
-
|
|
361
|
-
# 3. Check authentication
|
|
135
|
+
# Table format (default) - human readable
|
|
362
136
|
sphereai auth whoami
|
|
363
137
|
|
|
364
|
-
#
|
|
365
|
-
sphereai auth config
|
|
366
|
-
|
|
367
|
-
# 5. Use JSON output
|
|
138
|
+
# JSON format - for scripting
|
|
368
139
|
sphereai auth whoami --output json
|
|
369
|
-
|
|
370
|
-
# 6. Logout when done
|
|
371
|
-
sphereai auth logout
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### Scripting with JSON Output
|
|
375
|
-
|
|
376
|
-
```bash
|
|
377
|
-
#!/bin/bash
|
|
378
|
-
|
|
379
|
-
# Get current user info as JSON
|
|
380
|
-
user=$(sphereai auth whoami --output json)
|
|
381
|
-
|
|
382
|
-
# Parse with jq (requires jq to be installed)
|
|
383
|
-
user_id=$(echo "$user" | jq -r '.id')
|
|
384
|
-
user_email=$(echo "$user" | jq -r '.email')
|
|
385
|
-
user_role=$(echo "$user" | jq -r '.role')
|
|
386
|
-
|
|
387
|
-
echo "User ID: $user_id"
|
|
388
|
-
echo "Email: $user_email"
|
|
389
|
-
echo "Role: $user_role"
|
|
390
140
|
```
|
|
391
141
|
|
|
392
|
-
##
|
|
393
|
-
|
|
394
|
-
### Prerequisites
|
|
395
|
-
|
|
396
|
-
- Node.js >= 14.0.0
|
|
397
|
-
- npm or yarn
|
|
398
|
-
|
|
399
|
-
### Setup
|
|
400
|
-
|
|
401
|
-
```bash
|
|
402
|
-
# Install dependencies
|
|
403
|
-
npm install
|
|
404
|
-
|
|
405
|
-
# Build
|
|
406
|
-
npm run build
|
|
407
|
-
|
|
408
|
-
# Development mode (watch for changes)
|
|
409
|
-
npm run dev
|
|
410
|
-
|
|
411
|
-
# Link for local testing
|
|
412
|
-
npm link
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### Project Structure
|
|
416
|
-
|
|
417
|
-
```
|
|
418
|
-
src/
|
|
419
|
-
├── commands/ # CLI command implementations
|
|
420
|
-
│ ├── auth.ts # Authentication commands
|
|
421
|
-
│ ├── prompts.ts # Prompt management commands
|
|
422
|
-
│ └── files.ts # File tracking commands
|
|
423
|
-
├── services/ # Core services
|
|
424
|
-
│ ├── api-client.ts # HTTP client wrapper
|
|
425
|
-
│ ├── cli-api-client.ts # CLI auth API client
|
|
426
|
-
│ ├── auth-service.ts # OAuth2 flow handler
|
|
427
|
-
│ ├── config-service.ts # Configuration management
|
|
428
|
-
│ └── file-tracking-service.ts # File tracking management
|
|
429
|
-
├── types/ # TypeScript type definitions
|
|
430
|
-
│ └── api-types.ts # API type definitions
|
|
431
|
-
├── utils/ # Utility functions
|
|
432
|
-
│ ├── formatters.ts # Output formatting
|
|
433
|
-
│ ├── errors.ts # Error handling
|
|
434
|
-
│ └── sphereignore.ts # .sphereignore parser
|
|
435
|
-
└── index.ts # CLI entry point
|
|
436
|
-
```
|
|
142
|
+
## Global Options
|
|
437
143
|
|
|
438
|
-
|
|
144
|
+
| Option | Description |
|
|
145
|
+
|--------|-------------|
|
|
146
|
+
| `--output <format>` | Output format: `table` (default) or `json` |
|
|
147
|
+
| `--help` | Show help for any command |
|
|
148
|
+
| `--version` | Show CLI version |
|
|
439
149
|
|
|
440
|
-
|
|
441
|
-
# Clean build directory
|
|
442
|
-
npm run clean
|
|
443
|
-
|
|
444
|
-
# Compile TypeScript
|
|
445
|
-
npm run build
|
|
150
|
+
## Configuration
|
|
446
151
|
|
|
447
|
-
|
|
448
|
-
```
|
|
152
|
+
Your credentials are stored securely in your user configuration directory. Use `sphereai auth config` to view the current configuration.
|
|
449
153
|
|
|
450
154
|
## Troubleshooting
|
|
451
155
|
|
|
452
|
-
###
|
|
156
|
+
### Token Expired
|
|
453
157
|
|
|
454
|
-
|
|
158
|
+
Re-authenticate with your UserChannelKey:
|
|
455
159
|
|
|
456
160
|
```bash
|
|
457
|
-
|
|
458
|
-
# Or you can change the port in config (future enhancement)
|
|
161
|
+
sphereai auth login YOUR_USER_CHANNEL_KEY
|
|
459
162
|
```
|
|
460
163
|
|
|
461
|
-
###
|
|
164
|
+
### Clear All Data
|
|
462
165
|
|
|
463
166
|
```bash
|
|
464
|
-
|
|
465
|
-
sphereai auth login --email user@example.com --password secret
|
|
167
|
+
sphereai auth logout
|
|
466
168
|
```
|
|
467
169
|
|
|
468
|
-
###
|
|
170
|
+
### Check Your Configuration
|
|
469
171
|
|
|
470
172
|
```bash
|
|
471
|
-
# Check current configuration
|
|
472
173
|
sphereai auth config
|
|
473
|
-
|
|
474
|
-
# Clear all authentication data and reconfigure
|
|
475
|
-
sphereai auth logout
|
|
476
|
-
sphereai auth set-auth-url https://your-auth-url.com/authorize
|
|
477
|
-
sphereai auth login
|
|
478
174
|
```
|
|
479
175
|
|
|
480
|
-
|
|
176
|
+
## Requirements
|
|
481
177
|
|
|
482
|
-
|
|
483
|
-
# Logout to clear all stored data
|
|
484
|
-
sphereai auth logout
|
|
485
|
-
```
|
|
178
|
+
- Node.js 14.0.0 or higher
|
|
486
179
|
|
|
487
|
-
##
|
|
180
|
+
## Support
|
|
488
181
|
|
|
489
|
-
|
|
490
|
-
2. Create a feature branch
|
|
491
|
-
3. Make your changes
|
|
492
|
-
4. Run tests and build
|
|
493
|
-
5. Submit a pull request
|
|
182
|
+
For issues and questions, please contact your SphereAI administrator.
|
|
494
183
|
|
|
495
184
|
## License
|
|
496
185
|
|
|
497
186
|
ISC
|
|
498
|
-
|
|
499
|
-
## Support
|
|
500
|
-
|
|
501
|
-
For issues and questions, please refer to your SphereAI system administrator.
|
|
502
|
-
|
|
503
|
-
## Security
|
|
504
|
-
|
|
505
|
-
### JWT Token Storage
|
|
506
|
-
The CLI stores JWT tokens in your local configuration file (`~/.config/sphereai-cli/config.json`). The token contains encoded user information that is decoded locally when needed.
|
|
507
|
-
|
|
508
|
-
### Token Claims
|
|
509
|
-
The JWT token includes the following claims that are used by the CLI:
|
|
510
|
-
- `sub` - User ID
|
|
511
|
-
- `customer_id` - Customer ID
|
|
512
|
-
- `unique_name` - User name
|
|
513
|
-
- `email` - User email
|
|
514
|
-
- `role` - User role (Admin/User)
|
|
515
|
-
- `iat` - Issued at timestamp
|
|
516
|
-
- `exp` - Expiration timestamp
|
|
517
|
-
|
|
518
|
-
The `whoami` command decodes these claims locally without making API calls, providing instant user information display.
|
|
519
|
-
|
|
520
|
-
## Changelog
|
|
521
|
-
|
|
522
|
-
### Version 1.0.0
|
|
523
|
-
- Initial release
|
|
524
|
-
- OAuth2 authentication support with browser-based flow
|
|
525
|
-
- JWT token-based user information (decoded locally)
|
|
526
|
-
- Credential-based authentication
|
|
527
|
-
- Token management (set, view, clear)
|
|
528
|
-
- JSON and table output formats
|
|
529
|
-
- Comprehensive error handling with user-friendly messages
|
package/dist/index.js
CHANGED
|
@@ -86,13 +86,6 @@ Examples:
|
|
|
86
86
|
Configuration:
|
|
87
87
|
Config file location: ~/.config/sphereai-cli/config.json
|
|
88
88
|
View config: sphereai auth config
|
|
89
|
-
|
|
90
|
-
Environment Variables:
|
|
91
|
-
SPHEREAI_API_URL - Main API URL for resources (required)
|
|
92
|
-
SPHEREAI_CLI_API_URL - CLI API URL for key-based auth (required for login)
|
|
93
|
-
SPHEREAI_TOKEN - Override stored token
|
|
94
|
-
SPHEREAI_AUTH_URL - OAuth2 URL (for legacy login-oauth)
|
|
95
|
-
SPHEREAI_OAUTH_CALLBACK_PORT - OAuth2 callback port (default: 3001)
|
|
96
89
|
`);
|
|
97
90
|
// Parse command line arguments
|
|
98
91
|
program.parse(process.argv);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAE5B,4CAA4C;AAC5C,gBAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE/B,yCAAoC;AACpC,0CAAuD;AACvD,gDAA6D;AAC7D,4CAAyD;AACzD,8DAA0D;AAC1D,sDAAkD;AAGlD,8BAA8B;AAC9B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,gDAAgD,CAAC;KAC7D,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,iBAAiB,EAAE,sCAAsC,CAAC;KACjE,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;IACjC,gDAAgD;IAChD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;IAEhC,+BAA+B;IAC/B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,8BAAa,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,6BAA6B;IAC7B,IAAI,IAAI,CAAC,KAAK,EA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