Skip to content

Commit

Permalink
CLI warnings (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marfuen authored Aug 3, 2023
1 parent df36e27 commit 7f54012
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/grumpy-pets-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"thirdweb": patch
---

- Warn users on windows to not use the powershell as there are some compatibility issues with it at the moment.
- Warn users if they are pasting a client id instead of a secret key.
19 changes: 19 additions & 0 deletions packages/cli/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import chalk from "chalk";
import prompts from "prompts";
import Cache, { CacheEntry } from "sync-disk-cache";
import { ApiResponse } from "../lib/types";
import os from "os";

export async function loginUser(
cache: Cache,
Expand Down Expand Up @@ -40,6 +41,10 @@ export function getSession(cache: Cache) {

export async function createSession(cache: Cache) {
try {
const isWindows = os.type() === "Windows_NT";
if (isWindows) {
console.log(chalk.yellow("Windows detected: if you are using powershell, there are some known issues with it that we are actively working on, please use git bash or the command prompt. Thank you for your understanding."));
}
const response = await prompts({
type: "invisible",
name: "apiSecretKey",
Expand All @@ -48,6 +53,20 @@ export async function createSession(cache: Cache) {
)}`,
});

const keyPassed = response.apiSecretKey;
if (!keyPassed) {
console.log(chalk.red("You need to pass an API secret key"));
process.exit(1);
}

if (keyPassed.length === 32) {
console.log(chalk.red(`This is not a valid secret key. To get your secret key
1. Create an API key at https://thirdweb.com/create-api-key
2. Store and copy your Secret Key. This will be shown only once.
3. Paste it in the CLI when prompted`));
process.exit(1);
}

try {
await validateKey(response.apiSecretKey);
} catch (error) {
Expand Down

0 comments on commit 7f54012

Please sign in to comment.