secret-stack-decorators
TypeScript or Babel decorators that make it possible to write secret-stack plugins in OOP style
Usage
npm install --save secret-stack-decorators
Only supports secret-stack >=6.2.0
In your TypeScript or Babel codebase, import plugin
and muxrpc
:
; module.exports = myplugin;
Example
Before:
var plugin = name: 'ebt' version: '1.0.0' manifest: replicate: 'duplex' request: 'sync' block: 'sync' peerStatus: 'sync' permissions: anonymous: allow: 'replicate' { // INITIALIZATION CODE return { /* ... */ } { /* ... */ } { /* ... */ } { /* ... */ } }
After:
API
@plugin(version: string)
This decorator should be placed on a class that is meant to be a secret-stack plugin. The version
argument should be a string expressing a SemVer version.
Important: the name of the class is used as a string to register the plugin. class foo
will be transformed to api.foo
. This is why the class's name is usually lowercase.
@muxrpc(manifestType: string, permission?: object)
The manifestType
argument is a string, should have the value 'sync'
or 'async'
or 'source'
or 'sink'
or 'duplex'
. The optional permission
object should have the shape {role: 'allow' | 'deny'}
, i.e., the object's keys are names of roles (such as anonymous
or master
, etc), and the value can be either the string 'allow'
or the string 'deny'
.
License
MIT