filestack-policy
v0.2.1
Published
ππ₯ Filestack policy generator for authenticated Filestack requests (filestack.com)
Downloads
6
Readme
filestack-policy
Filestack policy generator for Filestack.com. As described in the creating policies document.
Requirements
- Tested on Node v6+
Install
npm i filestack-policy
Example
const { FilestackPolicy } = require('filestack-policy');
const policy = new FilestackPolicy({
expiry: Date.now() + 3600 // default = 24hrs from present time
path: '/path/to', // default === undefined e.g. *
container: 's3bucket-name' // default === undefined e.g. *
call: ['store', 'pick']: // default === [''] (no permissions granted)
secret: 'YOUR_SECRET', // Required, no default. Alternatively import setDefaultSecret().
});
const json = policy.toJSON() // Returns URL Safe policy string
const signature = policy.sign() // Return URL safe policy signature
API
module.FilestackPolicy(options: obj)
: Constructor Creates new FilestackPolicy object with parameters in single object.
module.setDefaultSecret(secret: string)
: Function Applies default secret for FilestackPolicy constructor to use. Later I will make this setDefaultOpts.
FilestackPolicy.prototype.toURLEncoded()
Function Returns URL safe policy.
FilestackPolicy.prototype.toJSON()
Function Returns policy JSON.
FilestackPolicy.prototype.sign()
Function Returns URL-safe signature (hashed with secret).