+51
-2
@@ -478,2 +478,46 @@ #!/usr/bin/env node | ||
| // src/commands/login.ts | ||
| var prompts = __toESM(require("@clack/prompts"), 1); | ||
| async function runLoginInteractive(deps) { | ||
| prompts.intro("dropthis login"); | ||
| const email = await prompts.text({ | ||
| message: "Email address", | ||
| validate: (v) => v?.includes("@") ? void 0 : "Enter a valid email" | ||
| }); | ||
| if (prompts.isCancel(email)) { | ||
| prompts.cancel("Login cancelled."); | ||
| return { exitCode: 0 }; | ||
| } | ||
| const requestResult = await deps.client.auth.requestEmailOtp({ email }); | ||
| if (requestResult.error) { | ||
| prompts.cancel(requestResult.error.message); | ||
| return { exitCode: exitCodeFor("api_error") }; | ||
| } | ||
| const otp = await prompts.text({ | ||
| message: "Paste the code from your email" | ||
| }); | ||
| if (prompts.isCancel(otp)) { | ||
| prompts.cancel("Login cancelled."); | ||
| return { exitCode: 0 }; | ||
| } | ||
| const session = await deps.client.auth.verifyEmailOtp({ email, code: otp }); | ||
| if (session.error) { | ||
| prompts.cancel(session.error.message); | ||
| return { exitCode: exitCodeFor("api_error") }; | ||
| } | ||
| const apiKey = await deps.client.apiKeys.create({ label: "CLI" }); | ||
| if (apiKey.error) { | ||
| prompts.cancel(apiKey.error.message); | ||
| return { exitCode: exitCodeFor("api_error") }; | ||
| } | ||
| await deps.store.save({ | ||
| apiKey: apiKey.data.key, | ||
| keyId: apiKey.data.id, | ||
| keyLast4: apiKey.data.keyLast4, | ||
| accountId: apiKey.data.accountId ?? session.data.accountId, | ||
| email, | ||
| storage: "secure" | ||
| }); | ||
| prompts.outro("Logged in successfully."); | ||
| return { exitCode: 0 }; | ||
| } | ||
| async function runLoginRequest(input, deps) { | ||
@@ -1057,3 +1101,3 @@ const result = await deps.client.auth.requestEmailOtp({ | ||
| const store = options.store ?? new MemoryCredentialStore(); | ||
| program.name("dropthis").description("Publish anything online and get a URL back.").version("0.1.1"); | ||
| program.name("dropthis").description("Publish anything online and get a URL back.").version("0.1.2"); | ||
| program.option("--api-key <key>", "Override API key for this invocation"); | ||
@@ -1065,3 +1109,8 @@ program.option("--api-url <url>", "Override API base URL"); | ||
| async (commandOptions) => { | ||
| if (!commandOptions.email || !commandOptions.otp) return; | ||
| if (!commandOptions.email || !commandOptions.otp) { | ||
| const deps2 = await commandDeps(program, options, store, commandOptions); | ||
| const result2 = await runLoginInteractive(deps2); | ||
| process.exitCode = result2.exitCode; | ||
| return; | ||
| } | ||
| const deps = await commandDeps(program, options, store, commandOptions); | ||
@@ -1068,0 +1117,0 @@ const result = await runLoginVerify( |
+1
-1
| { | ||
| "name": "dropthis", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "Official CLI for Dropthis.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
Potential vulnerability
Supply chain riskInitial human review suggests the presence of a vulnerability in this package. It is pending further analysis and confirmation.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 3 instances
Potential vulnerability
Supply chain riskInitial human review suggests the presence of a vulnerability in this package. It is pending further analysis and confirmation.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 3 instances
1236048
0.41%22923
0.21%