Skip to content

Commit

Permalink
Bump v0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
NakajimaTakuya committed Feb 21, 2024
1 parent 970cefb commit a0c88dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ The following file is generated when this command is executed.

Be careful not to publish the generated config/master.key in git.

The key used for encryption/decryption is the `config/master.key` generated here, or if not available, the `$MASTER_KEY` environment variable.

## edit

```sh
Expand Down
18 changes: 16 additions & 2 deletions lib/credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ class Credential {
}

get masterKeyAndIv() {
return process.env.MASTER_KEY || fs.readFileSync(this.masterKeyFile, 'utf-8');
try {
return fs.readFileSync(this.masterKeyFile, 'utf-8')
} catch(err) {
if (process.env.MASTER_KEY) {
return process.env.MASTER_KEY;
}

log.error(`config/masterkey (or $MASTER_KEY) is not found`);
throw err;
}
}

get masterKeyFile() {
Expand Down Expand Up @@ -105,7 +114,12 @@ class Credential {
}

reset() {
let body = this.read();
try {
let body = this.read();
} catch(err) {
log.error('The current master.key is not present, so the contents cannot be retained. If you still wish, try the setup command.');
throw err;
}
this.constructor.createMasterKey(this.configDir);
this.write(body);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lifull/sesame-keeper",
"version": "0.0.3",
"version": "0.0.4",
"description": "rails-like credential management mechanism.",
"keywords": [
"credentials",
Expand Down

0 comments on commit a0c88dd

Please sign in to comment.