# filestack-policy

> 📂🥞 Filestack policy generator for authenticated Filestack requests (filestack.com)

Latest version **0.2.1** (published 2018-03-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install filestack-policy
pnpm add filestack-policy
yarn add filestack-policy
bun add filestack-policy
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2018-03-02 |
| First published | 2018-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Daniel Gormly |
| Maintainers | danielgormly |

## Links

- npm: https://www.npmjs.com/package/filestack-policy
- Repository: https://github.com/danielgormly/filestack-policy
- Homepage: https://github.com/danielgormly/filestack-policy#readme
- Issues: https://github.com/danielgormly/filestack-policy/issues
- npm.io page: https://npm.io/package/filestack-policy

## Recent versions

- 0.2.1 (latest) — 2018-03-02
- 0.2.0 — 2018-02-24
- 0.1.6 — 2018-02-24
- 0.1.5 — 2018-02-24
- 0.1.4 — 2018-02-24
- 0.1.3 — 2018-02-24
- 0.1.2 — 2018-02-24
- 0.1.1 — 2018-02-24
- 0.1.0 — 2018-02-24
- 0.0.2 — 2018-02-24
- 0.0.1 — 2018-02-24

## README

# filestack-policy

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][npm-url]
![lmao](https://img.shields.io/badge/pls%20download-lmao-ff69b4.svg)


Filestack policy generator for [Filestack.com](https://filestack.com). As described in the [creating policies](https://www.filestack.com/docs/security/creating-policies) document.

## Requirements
 - Tested on Node v6+

## Install

`npm i filestack-policy`

## Example

```javascript
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).

[npm-image]: https://img.shields.io/npm/v/filestack-policy.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/filestack-policy
[travis-url]: https://travis-ci.org/danielgormly/filestack-policy
[travis-image]: https://travis-ci.org/danielgormly/filestack-policy.svg?branch=master
[david-image]: https://david-dm.org/danielgormly/filestack-policy.svg
[david-url]: https://david-dm.org/danielgormly/filestack-policy
[downloads-image]: https://img.shields.io/npm/dw/filestack-policy.svg
[license-url]: https://opensource.org/licenses/MIT
[license-image]: https://img.shields.io/npm/l/filestack-policy.svg

---
_Source: https://npm.io/package/filestack-policy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
