Skip to content

Commit

Permalink
⚡️ Validate user API keys in CLI (reworkd#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
MusabShakeel576 authored Jul 5, 2023
1 parent 4a48803 commit 38d7b39
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 46 deletions.
215 changes: 199 additions & 16 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"inquirer": "^9.2.7",
"lodash": "^4.17.21",
"minimist": "^1.2.8",
"node-fetch": "^3.3.1",
"simple-git": "^3.19.0",
"touch": "^3.1.0"
}
Expand Down
9 changes: 5 additions & 4 deletions cli/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export const printTitle = () => {
);
};

// Function to check if entered api key is in the correct format
export const isValidSkKey = (apikey) => {
const pattern = /^sk-[a-zA-Z0-9]{48}$/;
return pattern.test(apikey);
// Function to check if entered api key is in the correct format or empty
export const isValidKey = (apikey, pattern) => {
return (apikey === "" || pattern.test(apikey))
};

export const validKeyErrorMessage = "\nInvalid api key. Please try again."
Loading

0 comments on commit 38d7b39

Please sign in to comment.