Skip to content

Commit 6c663f8

Browse files
committed
Eliminate dependencies.
1 parent dc337cf commit 6c663f8

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @digitalbazaar/http-digest-header Changelog
22

3+
## 2.2.0 - 2025-10-dd
4+
5+
### Changed
6+
- Eliminate dependencies in favor of native platform support for simple
7+
(and rarely used) polyfill fallbacks which may be removed in future
8+
versions. Dependencies removed:
9+
- `@digitalbazaar/base64url-universal`
10+
- `js-base64`.
11+
312
## 2.1.0 - 2025-10-07
413

514
### Added

lib/httpDigest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*!
22
* Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import {fromUint8Array as base64Encode} from 'js-base64';
5-
import {encode as base64urlEncode} from 'base64url-universal';
4+
import {base64Encode, base64urlEncode} from './util.js';
65

76
const {crypto} = globalThis;
87

lib/util-browser.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*!
2+
* Copyright (c) 2021-2025 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
export function base64Encode(bytes) {
5+
if(bytes.toBase64) {
6+
return bytes.toBase64();
7+
}
8+
return btoa(Array.from(bytes, b => String.fromCodePoint(b)).join(''));
9+
}
10+
11+
export function base64urlEncode(bytes) {
12+
if(bytes.toBase64) {
13+
return bytes.toBase64({alphabet: 'base64url', omitPadding: true});
14+
}
15+
return base64Encode(bytes)
16+
.replace(/\+/g, '-')
17+
.replace(/\//g, '_')
18+
.replaceAll('=', '');
19+
}

lib/util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*!
2+
* Copyright (c) 2021-2025 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
export function base64Encode(bytes) {
5+
return Buffer.from(bytes).toString('base64');
6+
}
7+
8+
export function base64urlEncode(bytes) {
9+
return Buffer.from(bytes).toString('base64url');
10+
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
},
1515
"type": "module",
1616
"exports": "./lib/index.js",
17+
"browser": {
18+
"./lib/util.js": "./lib/util-browser.js"
19+
},
1720
"files": [
1821
"lib/**/*.js"
1922
],
20-
"dependencies": {
21-
"base64url-universal": "^2.0.0",
22-
"js-base64": "^3.7.2"
23-
},
2423
"devDependencies": {
2524
"c8": "^10.1.3",
2625
"chai": "^4.3.6",

0 commit comments

Comments
 (0)