token-store
v1.0.0
Published
store access tokens for command-line authentication
Downloads
15
Maintainers
Readme
token-store
Manage tokens for authenticating to multiple servers.
About
This was built for staticland, a static site hosting API. It's possible to create a new staticland server that manages static sites, so it's useful to be able to log into multiple servers.
This module provides a way to store the token for each server and switch between them.
token-store is meant to be used as a dependency of command-line tools that handle authentication and need a way to store the auth tokens that are returned.
Install
npm install --save token-store
Usage
var tokenStore = require('token-store')
var tokens = tokenStore({ filename: 'tokenstoretest' })
/* add a token */
tokens.set({
server: 'http://127.0.0.1:3322',
token: 'some token here please'
})
var current = tokens.current()
console.log('current token:', current)
/* add another token */
tokens.set({
server: 'https://example.com',
token: 'another actual token'
})
var current = tokens.current()
console.log('\nnew current token:\n', current)
/* list all tokens */
console.log('\nall tokens:\n', tokens.get())
/* set current token from available tokens */
if (tokens.has('http://127.0.0.1:3322')) {
current = tokens.current('http://127.0.0.1:3322')
console.log('\nnew current token:\n', current)
}
/* delete a token */
tokens.delete('https://example.com')
/* list all tokens */
console.log('\nonly one token left:\n', tokens.get())
/* completely destroy token store file! */
tokens.destroy()
Documentation
Examples
Contributing
Contributions are welcome! Please read the contributing guidelines first.
Conduct
It's important that this project contributes to a friendly, safe, and welcoming environment for all, particularly for folks that are historically underrepresented in technology. Read this project's code of conduct
Change log
Read about the changes to this project in CHANGELOG.md. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Contact
- chat – You can chat about this project at http://gitter.im/sethvincent/ask
- issues – Please open issues in the issues queue
- twitter – @sethdvincent
- email – Need in-depth support via paid contract? Send an email to sethvincent@gmail.com