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

Commit 54a3a11

Browse files
committed
upgrade secman v2 to secman core (sc) to use it with secman
1 parent dc6410c commit 54a3a11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3292
-3664
lines changed

api/categories.go

-16
This file was deleted.

api/latest.ts

-16
This file was deleted.

app/config/index.ts

-163
This file was deleted.

app/refresher/index.ts

-75
This file was deleted.

contents/data/config.json

-4
This file was deleted.

contents/data/data.json

-7
This file was deleted.

contents/data/settings.json

-6
This file was deleted.

contents/examples/generate.ts

-13
This file was deleted.
File renamed without changes.

bin/run renamed to core/bin/run

File renamed without changes.
File renamed without changes.

core/config/index.ts

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { DOT_SECMAN_PATH, SECMAN_CONFIG_PATH } from "../constants";
2+
import { writeJsonFile as writeJSON } from "../tools/json/write";
3+
import fs from "fs";
4+
import path from "path";
5+
6+
export default async function writeConfigFile(
7+
username: any,
8+
user_email: any,
9+
access_token: any,
10+
refresh_token: any,
11+
transmission_key: any,
12+
master_password_hash: any,
13+
secret: any
14+
) {
15+
if (!fs.existsSync(DOT_SECMAN_PATH)) {
16+
fileIsNotFound();
17+
}
18+
19+
// write config file
20+
await writeJSON(
21+
SECMAN_CONFIG_PATH,
22+
{
23+
config: {
24+
name: username,
25+
secret: secret,
26+
user: user_email,
27+
},
28+
data: {
29+
access_token: access_token,
30+
master_password_hash: master_password_hash,
31+
refresh_token: refresh_token,
32+
transmission_key: transmission_key,
33+
},
34+
},
35+
{}
36+
);
37+
}
38+
39+
export function readConfig(obj: any) {
40+
if (!fs.existsSync(SECMAN_CONFIG_PATH)) {
41+
fileIsNotFound();
42+
} else {
43+
let rawData: any = fs.readFileSync(path.resolve(SECMAN_CONFIG_PATH));
44+
45+
let data: any = JSON.parse(rawData)["config"][obj];
46+
47+
return data;
48+
}
49+
}
50+
51+
export function readData(obj: any) {
52+
if (!fs.existsSync(SECMAN_CONFIG_PATH)) {
53+
fileIsNotFound();
54+
} else {
55+
let rawData: any = fs.readFileSync(path.resolve(SECMAN_CONFIG_PATH));
56+
57+
let data: any = JSON.parse(rawData)["data"][obj];
58+
59+
return data;
60+
}
61+
}
62+
63+
const fileIsNotFound = () => {
64+
console.log("~/.secman/secman.json does not exist, run `secman init`");
65+
66+
process.exit(0);
67+
};

0 commit comments

Comments
 (0)