Skip to content

Repository files navigation

@edgio/ectoken

JavaScript implementation of Edgio token (ectoken)

Table of Contents

Background

JavaScript implementation of the "Edgio Token" (ectoken) - see main repo ectoken for more details.

Install

$ npm install @edgio/ectoken

Usage

const{ ECToken, encrypt, decrypt }=require('@edgio/ectoken')constec_token=newECToken()ec_token.addValue('ec_country_allow','US')// Add additional directives in the same way.consttoken=awaitencrypt('my-secret-key',ec_token)constplaintext=awaitdecrypt('my-secret-key',token)

If installing this library as a replacement for ectoken-nodejs, import the V3 namespace instead:

const{V3}=require('@edgio/ectoken')consttoken=awaitV3.encrypt('my-secret-key','some_param=valueA&some_other_param=valueB')constplaintext=awaitV3.decrypt('my-secret-key',token)

Please Note: because this version of the token generator uses crypto.subtle, the encrypt and decrypt functions are now asynchronous.

The ECToken helper class is optional for both the namespaced and non-namespaced import variations. The encrypt function will accept either an ECToken object or a plain string.

Contribute

We welcome issues, questions, and pull requests.

License

This project is licensed under the terms of the Apache 2.0 open source license. Please refer to the License-2.0.txt file for the full terms.

About

JavaScript implementation of ectoken

Resources

Stars

2 stars

Watchers

8 watching

Forks

Releases

Packages

Contributors

Languages