This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade
secman v2
to secman core (sc)
to use it with secman
- Loading branch information
Showing
75 changed files
with
3,292 additions
and
3,664 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { DOT_SECMAN_PATH, SECMAN_CONFIG_PATH } from "../constants"; | ||
import { writeJsonFile as writeJSON } from "../tools/json/write"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export default async function writeConfigFile( | ||
username: any, | ||
user_email: any, | ||
access_token: any, | ||
refresh_token: any, | ||
transmission_key: any, | ||
master_password_hash: any, | ||
secret: any | ||
) { | ||
if (!fs.existsSync(DOT_SECMAN_PATH)) { | ||
fileIsNotFound(); | ||
} | ||
|
||
// write config file | ||
await writeJSON( | ||
SECMAN_CONFIG_PATH, | ||
{ | ||
config: { | ||
name: username, | ||
secret: secret, | ||
user: user_email, | ||
}, | ||
data: { | ||
access_token: access_token, | ||
master_password_hash: master_password_hash, | ||
refresh_token: refresh_token, | ||
transmission_key: transmission_key, | ||
}, | ||
}, | ||
{} | ||
); | ||
} | ||
|
||
export function readConfig(obj: any) { | ||
if (!fs.existsSync(SECMAN_CONFIG_PATH)) { | ||
fileIsNotFound(); | ||
} else { | ||
let rawData: any = fs.readFileSync(path.resolve(SECMAN_CONFIG_PATH)); | ||
|
||
let data: any = JSON.parse(rawData)["config"][obj]; | ||
|
||
return data; | ||
} | ||
} | ||
|
||
export function readData(obj: any) { | ||
if (!fs.existsSync(SECMAN_CONFIG_PATH)) { | ||
fileIsNotFound(); | ||
} else { | ||
let rawData: any = fs.readFileSync(path.resolve(SECMAN_CONFIG_PATH)); | ||
|
||
let data: any = JSON.parse(rawData)["data"][obj]; | ||
|
||
return data; | ||
} | ||
} | ||
|
||
const fileIsNotFound = () => { | ||
console.log("~/.secman/secman.json does not exist, run `secman init`"); | ||
|
||
process.exit(0); | ||
}; |
Oops, something went wrong.