@viewdo/dxp-story-cli
Version:
README.md
37 lines (28 loc) • 595 B
JavaScript
const JSONFile = require('./json-file')
module.exports = class AuthConfig {
constructor(email, token, file_service) {
Object.assign(this, {
email,
token,
file: new JSONFile(`./.auth`, file_service)
})
let config = this.file.read()
if(config)
Object.assign(this, config)
}
save() {
// mapping from the domain-model
let {
email,
token
} = this
let config = {
kind: 'Credentials',
apiVersion: 'auth.view.do/v1',
email,
token,
updated: new Date()
}
this.file.write(config)
}
}