@seneca/apikey
v0.1.0
Published
Apikey management plugin for Seneca
Downloads
3
Readme
A Seneca.js plugin for providing API keys.
@seneca/apikey
| | This open source module is sponsored and supported by Voxgig. | |---|---|
Description
This module is a plugin for the Seneca framework. It provides common actions for supplying API keys to external clients.
API keys are generated and hashed to the same level as passwords.
Install
npm install seneca
npm install seneca-promisify // dependency
npm install seneca-entity // dependency
npm install @seneca/user // dependency
npm install @seneca/apikey
Quick example
Register a apikey and then create an automatic login for testing.
const Seneca = require('seneca')
var seneca = Seneca()
.use('promisify')
.use('entity')
.use('apikey')
// TODO: complete quick example
Detailed Examples
Because Seneca treats messages as first-class citizens, 90% of unit testing can be implemented with message scenarios that also provide detailed usage examples:
Options
test
: boolean falsekeysize
: number 32tagsize
: number 8rounds
: number 11salt.bytelen
: number 16salt.format
: string "hex"pepper
: string ""generate_salt
: function generate_salt
Set plugin options when loading with:
seneca.use('apikey', { name: value, ... })
Note: foo.bar in the list above means { foo: { bar: ... } }
Action Patterns
Action Descriptions
« sys:apikey,generate:key
»
Generate a new API key.
Parameters
- owner : string " "
- scope : string "default"
Replies With
{
ok: '`true` if successful',
key: 'key string'
}
« sys:apikey,verify:key
»
Verify an API key.
Parameters
- owner : string " "
- scope : string "default"
- key : string " "
Replies With
{
ok: '`true` if verified',
why: 'explanation code'
}
License
Copyright (c) 2010-2020, Richard Rodger and other contributors. Licensed under MIT.