orangeslice 2.0.3 → 2.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.
Files changed (3) hide show
  1. package/README.md +16 -0
  2. package/dist/cli.js +81 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,6 +18,22 @@ The CLI copies docs to `./orangeslice-docs`, creates `./orangeslice-docs/AGENTS.
18
18
  2. `ORANGESLICE_API_KEY` env var
19
19
  3. `~/.config/orangeslice/config.json`
20
20
 
21
+ ### CLI auth commands
22
+
23
+ ```bash
24
+ # One-time setup (also runs on plain `npx orangeslice` when unauthenticated)
25
+ npx orangeslice login
26
+
27
+ # Force re-auth and replace local stored key
28
+ npx orangeslice login --force
29
+
30
+ # Remove locally stored key
31
+ npx orangeslice logout
32
+
33
+ # Show current auth source (env or config file)
34
+ npx orangeslice auth status
35
+ ```
36
+
21
37
  Install as a dependency when writing app code:
22
38
 
23
39
  ```bash
package/dist/cli.js CHANGED
@@ -133,6 +133,29 @@ function saveConfigFile(config) {
133
133
  }
134
134
  catch { }
135
135
  }
136
+ function clearConfigFile() {
137
+ try {
138
+ if (!fs.existsSync(CONFIG_PATH))
139
+ return false;
140
+ fs.unlinkSync(CONFIG_PATH);
141
+ return true;
142
+ }
143
+ catch {
144
+ return false;
145
+ }
146
+ }
147
+ function maskKey(value) {
148
+ if (value.length <= 12)
149
+ return value;
150
+ return `${value.slice(0, 8)}...${value.slice(-4)}`;
151
+ }
152
+ function getStoredApiKey() {
153
+ const envKey = process.env.ORANGESLICE_API_KEY;
154
+ if (envKey && envKey.trim())
155
+ return envKey.trim();
156
+ const fileKey = readConfigFile().apiKey;
157
+ return fileKey?.trim() || "";
158
+ }
136
159
  function openBrowser(url) {
137
160
  try {
138
161
  if (process.platform === "darwin") {
@@ -188,10 +211,10 @@ async function completeDeviceAuth(deviceCode, pollIntervalMs, expiresIn) {
188
211
  }
189
212
  throw new Error("Timed out waiting for browser authentication.");
190
213
  }
191
- async function setupApiKey() {
192
- const existing = process.env.ORANGESLICE_API_KEY || readConfigFile().apiKey;
193
- if (existing && existing.trim()) {
194
- console.log(` ✓ API key already configured (${existing.slice(0, 12)}...)\n`);
214
+ async function setupApiKey(force = false) {
215
+ const existing = getStoredApiKey();
216
+ if (!force && existing) {
217
+ console.log(` ✓ API key already configured (${maskKey(existing)})\n`);
195
218
  return;
196
219
  }
197
220
  console.log(" Authenticating with Orange Slice...\n");
@@ -202,7 +225,61 @@ async function setupApiKey() {
202
225
  saveConfigFile({ apiKey });
203
226
  console.log(` ✓ API key saved to ${CONFIG_PATH}\n`);
204
227
  }
228
+ function printHelp() {
229
+ console.log("Usage:");
230
+ console.log(" npx orangeslice");
231
+ console.log(" npx orangeslice login [--force]");
232
+ console.log(" npx orangeslice logout");
233
+ console.log(" npx orangeslice auth status\n");
234
+ }
235
+ async function runLogin(args) {
236
+ const force = args.includes("--force");
237
+ await setupApiKey(force);
238
+ }
239
+ function runLogout() {
240
+ const removed = clearConfigFile();
241
+ if (removed) {
242
+ console.log(` ✓ Removed local auth at ${CONFIG_PATH}`);
243
+ }
244
+ else {
245
+ console.log(" No local config found to remove.");
246
+ }
247
+ if (process.env.ORANGESLICE_API_KEY) {
248
+ console.log(" Note: ORANGESLICE_API_KEY env var is still set in this shell.");
249
+ }
250
+ }
251
+ function runAuthStatus() {
252
+ const envKey = process.env.ORANGESLICE_API_KEY?.trim() || "";
253
+ if (envKey) {
254
+ console.log(` Authenticated via env var: ${maskKey(envKey)}`);
255
+ return;
256
+ }
257
+ const fileKey = readConfigFile().apiKey?.trim() || "";
258
+ if (fileKey) {
259
+ console.log(` Authenticated via config file (${CONFIG_PATH}): ${maskKey(fileKey)}`);
260
+ return;
261
+ }
262
+ console.log(" Not authenticated. Run `npx orangeslice login`.");
263
+ }
205
264
  async function main() {
265
+ const args = process.argv.slice(2);
266
+ const command = args[0];
267
+ if (command === "login") {
268
+ await runLogin(args.slice(1));
269
+ return;
270
+ }
271
+ if (command === "logout") {
272
+ runLogout();
273
+ return;
274
+ }
275
+ if (command === "auth" && args[1] === "status") {
276
+ runAuthStatus();
277
+ return;
278
+ }
279
+ if (command && (command === "--help" || command === "-h" || command === "help")) {
280
+ printHelp();
281
+ return;
282
+ }
206
283
  console.log("\norangeslice\n");
207
284
  const docsDir = resolveDocsDir();
208
285
  // Copy docs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orangeslice",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "B2B LinkedIn database prospector - 1.15B profiles, 85M companies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",