@clipit-ai/cli 0.2.1 → 0.2.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/bin/clipit.mjs +28 -9
- package/package.json +1 -1
package/bin/clipit.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import process from 'node:process';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
|
|
12
|
-
const VERSION = '0.2.
|
|
12
|
+
const VERSION = '0.2.2';
|
|
13
13
|
const DEFAULT_BASE_URL = 'https://clipit.dev';
|
|
14
14
|
const DEFAULT_SCOPES = [
|
|
15
15
|
'clippy_agent',
|
|
@@ -724,14 +724,33 @@ async function enforceRunMaxCredits(config, options, functionName) {
|
|
|
724
724
|
async function login(config, options) {
|
|
725
725
|
const { verifier, challenge } = pkcePair();
|
|
726
726
|
const baseUrl = getBaseUrl(config, options);
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
727
|
+
let started;
|
|
728
|
+
try {
|
|
729
|
+
started = await apiFetch(config, options, 'POST', '/api/v1/cli-auth/start', {
|
|
730
|
+
codeChallenge: challenge,
|
|
731
|
+
codeChallengeMethod: 'S256',
|
|
732
|
+
requestedScopes: DEFAULT_SCOPES,
|
|
733
|
+
deviceName: os.hostname(),
|
|
734
|
+
cliVersion: VERSION,
|
|
735
|
+
platform: `${process.platform}/${process.arch}`,
|
|
736
|
+
}, { noAuth: true });
|
|
737
|
+
} catch (error) {
|
|
738
|
+
// A login start should never need credentials — a 401/404 here means the
|
|
739
|
+
// server predates the CLI auth API entirely.
|
|
740
|
+
if (error.status === 401 || error.status === 404) {
|
|
741
|
+
throw Object.assign(
|
|
742
|
+
new Error([
|
|
743
|
+
`${baseUrl} does not support browser login yet (its API layer predates this CLI).`,
|
|
744
|
+
'Use an API key instead:',
|
|
745
|
+
` 1. Create one at ${baseUrl} -> Settings -> API Keys -> Connect an Agent`,
|
|
746
|
+
" 2. Store it: printf '%s' \"$CLIPPER_API_KEY\" | clipit auth set-key --stdin",
|
|
747
|
+
' 3. Verify: clipit videos list',
|
|
748
|
+
].join('\n')),
|
|
749
|
+
{ exitCode: EXIT.AUTH, status: error.status, requestId: error.requestId },
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
throw error;
|
|
753
|
+
}
|
|
735
754
|
|
|
736
755
|
if (!options['no-browser']) {
|
|
737
756
|
try {
|