Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tmountjr committed May 28, 2024
1 parent 7e35303 commit 22ca5f4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ JavaScript implementation of the "Edgio Token" (`ectoken`) - see main repo [ecto

## Install

1. Clone this repo.
2. `cd` into the repo directory
3. Run `npm install`
```
$ npm install js-ectoken
```

## Usage

This library is provided in CommonJS (CJS) format. To include the library in a script, `require` it:
```js
const { ECToken, encrypt, decrypt } = require('./ECToken.js')
const { ECToken, encrypt, decrypt } = require('js-ectoken')

const ec_token = new ECToken()
ec_token.addValue('ec_country_allow', 'US')
Expand All @@ -33,6 +32,17 @@ const token = await encrypt('my-secret-key', ec_token)
const plaintext = await decrypt('my-secret-key', token)
```

If installing this library as a replacement for [`ectoken-nodejs`](https://github.com/hattan/ectoken-nodejs), import the `V3` namespace instead:

```js
const { V3 } = require('js-ectoken')

const token = await encrypt('my-secret-key', 'some_param=valueA&some_other_param=valueB')
const plaintext = await 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.**

## Contribute

We welcome issues, questions, and pull requests.
Expand Down

0 comments on commit 22ca5f4

Please sign in to comment.