0.2.1 • Published 8 years ago
filestack-policy v0.2.1
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 signatureAPI
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).