Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @digitalbazaar/http-digest-header Changelog

## 2.2.0 - 2025-10-dd

### Changed
- Eliminate dependencies in favor of native platform support for simple
(and rarely used) polyfill fallbacks which may be removed in future
versions. Dependencies removed:
- `base64url-universal`
- `js-base64`.

## 2.1.0 - 2025-10-07

### Added
Expand Down
3 changes: 1 addition & 2 deletions lib/httpDigest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*!
* Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved.
*/
import {fromUint8Array as base64Encode} from 'js-base64';
import {encode as base64urlEncode} from 'base64url-universal';
import {base64Encode, base64urlEncode} from './util.js';

const {crypto} = globalThis;

Expand Down
19 changes: 19 additions & 0 deletions lib/util-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* Copyright (c) 2021-2025 Digital Bazaar, Inc. All rights reserved.
*/
export function base64Encode(bytes) {
if(bytes.toBase64) {
return bytes.toBase64();
}
return btoa(Array.from(bytes, b => String.fromCodePoint(b)).join(''));
}

export function base64urlEncode(bytes) {
if(bytes.toBase64) {
return bytes.toBase64({alphabet: 'base64url', omitPadding: true});
}
return base64Encode(bytes)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replaceAll('=', '');
}
10 changes: 10 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*!
* Copyright (c) 2021-2025 Digital Bazaar, Inc. All rights reserved.
*/
export function base64Encode(bytes) {
return Buffer.from(bytes).toString('base64');
}

export function base64urlEncode(bytes) {
return Buffer.from(bytes).toString('base64url');
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
},
"type": "module",
"exports": "./lib/index.js",
"browser": {
"./lib/util.js": "./lib/util-browser.js"
},
"files": [
"lib/**/*.js"
],
"dependencies": {
"base64url-universal": "^2.0.0",
"js-base64": "^3.7.2"
},
"devDependencies": {
"c8": "^10.1.3",
"chai": "^4.3.6",
Expand Down