1.0.3 • Published 4 years ago

owncloud-sign-url v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

owncloud-sign-url

Build Status npm version Coverage Status

owncloud-sign-url is a little node.js library for signing urls and validating them based on secret key.

NOTE You need a Node 10.17.0 and higher.

Init

npm install owncloud-sign-url

or

yarn add owncloud-sign-url

Create signature object based on secret.

Secret string should not be known for anyone else, except your servers

const SignUrl = require('owncloud-sign-url');

const signUrl = new SignUrl({
  secretKey: 'your secret key string',
  ttl: 60, // optional (in seconds)
  algorithm: 'sha256' // optional
});

Generate signed url

const url = 'http://example.com/resource';
const httpMethod = 'get';

const signedUrl = signUrl.generateSignedUrl(url, httpMethod);

Verify url on resource side

const errorCode = this.verifySignedUrl(req);

License

MIT