Skip to content

Commit 72bc7f0

Browse files
authored
Merge pull request #5 from GustavoOS/feature/issue-3-with-tests
Remove base64url package in favor of Node's built-in `Buffer` api.
2 parents a745ff5 + b339185 commit 72bc7f0

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

lib/crypto.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const crypto = require('crypto')
2-
const base64url = require('base64url')
32

43
const iv_size_bytes = 12
54

@@ -45,7 +44,7 @@ async function encrypt(key, token, verbose = false) {
4544
console.log('+---------------------------------------------------------------------------------------------------')
4645
}
4746

48-
return base64url.encode(iv_ciphertext)
47+
return Buffer.from(iv_ciphertext).toString('base64url')
4948
}
5049

5150
/**
@@ -59,7 +58,7 @@ async function decrypt(key, token, verbose = false) {
5958
const key_encoded = new TextEncoder().encode(key)
6059
const key_digest = await crypto.subtle.digest('SHA-256', key_encoded)
6160

62-
const decoded_token = base64url.toBuffer(token)
61+
const decoded_token = Buffer.from(token, 'base64url')
6362

6463
// First n bytes (iv_size_bytes) is the iv.
6564
const iv = decoded_token.subarray(0, iv_size_bytes)

package-lock.json

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@edgio/ectoken",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "JS implementation of Edgio token (ectoken)",
55
"main": "index.js",
66
"repository": {
@@ -25,9 +25,6 @@
2525
"node": ">= 15.0.0"
2626
},
2727
"homepage": "https://github.com/Edgio/js-ectoken#readme",
28-
"dependencies": {
29-
"base64url": "^3.0.1"
30-
},
3128
"publishConfig": {
3229
"access": "public"
3330
},

0 commit comments

Comments
 (0)