url-encrypt
URL encrypting and verifying
Used to encrypt and verify URLs using OAuth signature encryption standards, for authentication purposes between services.
Install
$ npm install url-encrypt --save
Initialize
Creation of encryptor with secret Key
const urlEncrypt = ; const encryptor = ;
Encryption
const url = encryptor; // The above result will be something like this// https://example.com/posts?postId=15&prfx_nonce=...// &prfx_timestamp=15..&prfx_method=sha256&prfx_signature=...
As a result, security settings, such as an encrypted signature, will be added to the URL.
Verification
Then verifying an URL using the same configuration and the secret key
encryptor// returns true or false
Expiration
Each encryption has its own expiration date after an outflow of expiration date - URL verification will turn into failure. The default expired date is 15 minutes, but it's configurable.
// Setting up expired time 1 hour;
Config
There is a way to change the configuration after initialization:
const encryptor = ; encryptor;
Parameters
All encryption options are described below.
encryptor;