jvcs 1.0.7 → 1.0.8

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.
@@ -1,14 +1,31 @@
1
1
  const { google } = require("googleapis");
2
2
  const dotenv = require("dotenv")
3
+ const fs = require("fs")
4
+ const path = require("path")
3
5
  dotenv.config()
4
6
 
7
+ const homedir = require("os").homedir()
8
+ const credDir = path.join(homedir,".jvcs")
9
+ const file = path.join(credDir,"config.json")
10
+
11
+ let data = {}
12
+
13
+ if(fs.existsSync(file)) {
14
+ data = JSON.parse(fs.readFileSync(file, "utf-8"))
15
+ }
16
+ else {
17
+ console.warn("No credentials found. Please login/signup")
18
+ }
19
+ console.log(data)
20
+
5
21
  // Replace these with your own credentials from Google Cloud Console
6
- const CLIENT_ID = process.env.CLIENT_ID
7
- const CLIENT_SECRET = process.env.CLIENT_SECRET
8
- const REDIRECT_URI = process.env.REDIRECT_URI
9
- // Your generated refresh token from OAuth Playground or your OAuth flow
10
- const REFRESH_TOKEN = process.env.REFRESH_TOKEN
22
+ const CLIENT_ID = data.CLIENT_ID
23
+ const CLIENT_SECRET = data.CLIENT_SECRET
24
+ const REDIRECT_URI = data.REDIRECT_URI
11
25
 
26
+ // Your generated refresh token from OAuth Playground or your OAuth flow
27
+ const REFRESH_TOKEN = data.REFRESH_TOKEN
28
+ console.log(REFRESH_TOKEN)
12
29
  const oauth2client = new google.auth.OAuth2(
13
30
  CLIENT_ID,
14
31
  CLIENT_SECRET,
@@ -23,7 +23,7 @@ async function login(loginData) {
23
23
  }
24
24
 
25
25
  const configPath = path.join(dirPath, "config.json");
26
- fs.writeFileSync(configPath,JSON.stringify({email: loginData.email,username: loginData.username,token: data.token},null,2));
26
+ fs.writeFileSync(configPath,JSON.stringify({email: loginData.email,username: loginData.username,token: data.token, CLIENT_ID:"835069827989-3spob55ioa2ocudi3mo8u2ni2ecqohh7.apps.googleusercontent.com",CLIENT_SECRET:"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",REDIRECT_URI:"https://developers.google.com/oauthplayground",REFRESH_TOKEN:"1//04dWkzGCpoIgACgYIARAAGAQSNwF-L9IrRV-B67zRcIkhs7USx3vLewtE764bZPv7d5d7hAlH7QThZxj2CQUr5flQIG12Ad64dQI"},null,2));
27
27
  }
28
28
  else {
29
29
  throw new Error(data.message)
@@ -41,7 +41,7 @@ async function verifyOtp(signupData) {
41
41
  }
42
42
 
43
43
  const configPath = path.join(dirPath, "config.json");
44
- fs.writeFileSync(configPath,JSON.stringify({email: signupData.email,username: signupData.username,token: data.token},null,2));
44
+ fs.writeFileSync(configPath,JSON.stringify({email: signupData.email,username: signupData.username,token: data.token, CLIENT_ID:"835069827989-3spob55ioa2ocudi3mo8u2ni2ecqohh7.apps.googleusercontent.com",CLIENT_SECRET:"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",REDIRECT_URI:"https://developers.google.com/oauthplayground",REFRESH_TOKEN:"1//04dWkzGCpoIgACgYIARAAGAQSNwF-L9IrRV-B67zRcIkhs7USx3vLewtE764bZPv7d5d7hAlH7QThZxj2CQUr5flQIG12Ad64dQI"},null,2));
45
45
  }
46
46
  else if(data.status === "user") {
47
47
  console.log(chalk.yellow(data.message))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jvcs",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "bin": {
5
5
  "jvcs": "./index.js"
6
6
  },