Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
upgrade secman v2 to secman core (sc) to use it with secman
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Mar 9, 2022
1 parent dc6410c commit 54a3a11
Show file tree
Hide file tree
Showing 75 changed files with 3,292 additions and 3,664 deletions.
16 changes: 0 additions & 16 deletions api/categories.go

This file was deleted.

16 changes: 0 additions & 16 deletions api/latest.ts

This file was deleted.

163 changes: 0 additions & 163 deletions app/config/index.ts

This file was deleted.

75 changes: 0 additions & 75 deletions app/refresher/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions contents/data/config.json

This file was deleted.

7 changes: 0 additions & 7 deletions contents/data/data.json

This file was deleted.

6 changes: 0 additions & 6 deletions contents/data/settings.json

This file was deleted.

13 changes: 0 additions & 13 deletions contents/examples/generate.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions core/config/index.ts
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);
};
Loading

0 comments on commit 54a3a11

Please sign in to comment.