https://github.com/binded/keyed-tus-store
Higher level tus store that encodes key in upload ID
https://github.com/binded/keyed-tus-store
Last synced: over 1 year ago
JSON representation
Higher level tus store that encodes key in upload ID
- Host: GitHub
- URL: https://github.com/binded/keyed-tus-store
- Owner: binded
- License: mit
- Created: 2016-09-23T03:14:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-27T05:20:45.000Z (over 9 years ago)
- Last Synced: 2025-03-01T05:06:37.077Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 9
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# keyed-tus-store
[](https://travis-ci.org/blockai/keyed-tus-store)
[](https://github.com/blockai/abstract-tus-store)
Higher level [tus store](https://github.com/blockai/abstract-tus-store).
Takes a tus store and returns a new tus store which behaves mostly the
except that it transforms upload IDs returned by `create(key)` so that
the transformed upload ID also encodes the `key` argument.
Other functions are wrapped so that the original upload ID is decoded
before being passed.
An additional `decodeKey(uploadId)` function is exposed which returns
the key associated with an upload ID.
The idea behind this store was to make it easier to retrieve a key given
an upload ID without requiring additional state.
## Install
```bash
npm install --save keyed-tus-store
```
Requires Node v6+
## Usage
See [./test](./test) directory for usage examples.
**keyedStore(storeToWrap, secret)**
Where `storeToWrap` is a tus store and `secret` is a secret passphrase
used to encrypt and decrypt the upload IDs.
Returns a tus store.
**decodeKey(uploadId)**
Returns the `key` encoded in `uploadId`.
```javascript
import keyedStore from 'keyed-tus-store'
import { memstore } from 'abstract-tus-store'
const store = keyedStore(memstore(), 'some secret')
store.create('some-key').then(({ uploadId }) => {
const key = store.decodeKey(uploadId)
key === 'some-key' // => true
})
```