Skip to content

Commit 8656741

Browse files
committed
Update dependencies (use native base64url implementation).
1 parent 92c4f62 commit 8656741

File tree

9 files changed

+18
-25
lines changed

9 files changed

+18
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# bedrock-vc-issuer ChangeLog
22

3+
## 30.0.2 - 2025-04-dd
4+
5+
### Changed
6+
- Update dependencies (use native base64url implementation).
7+
38
## 30.0.1 - 2025-04-30
49

510
### Changed

lib/suites.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
createSignCryptosuite as createEddsaJcs2022CryptoSuite
2020
} from '@digitalbazaar/eddsa-jcs-2022-cryptosuite';
2121
import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
22-
import {decode} from 'base64url-universal';
2322
import {
2423
cryptosuite as ecdsa2019CryptoSuite
2524
} from '@digitalbazaar/ecdsa-2019-cryptosuite';
@@ -228,7 +227,7 @@ function _createEcdsaXi2023Suite({signer, options} = {}) {
228227
}
229228
});
230229
}
231-
const extraInformation = decode(options.extraInformation);
230+
const extraInformation = Buffer.from(options.extraInformation, 'base64url');
232231
const cryptosuite = createEcdsaXi2023SignCryptosuite({
233232
extraInformation
234233
});

lib/vcjwt.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*!
2-
* Copyright (c) 2020-2024 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import * as base64url from 'base64url-universal';
5-
64
const TEXT_ENCODER = new TextEncoder();
75
const ENCODED_PERIOD = TEXT_ENCODER.encode('.');
86

@@ -72,8 +70,9 @@ export async function envelopeCredential({
7270

7371
export async function signJWT({payload, protectedHeader, signer} = {}) {
7472
// encode payload and protected header
75-
const b64Payload = base64url.encode(JSON.stringify(payload));
76-
const b64ProtectedHeader = base64url.encode(JSON.stringify(protectedHeader));
73+
const b64Payload = Buffer.from(JSON.stringify(payload)).toString('base64url');
74+
const b64ProtectedHeader = Buffer.from(
75+
JSON.stringify(protectedHeader)).toString('base64url');
7776
payload = TEXT_ENCODER.encode(b64Payload);
7877
protectedHeader = TEXT_ENCODER.encode(b64ProtectedHeader);
7978

@@ -89,7 +88,7 @@ export async function signJWT({payload, protectedHeader, signer} = {}) {
8988

9089
// create JWS
9190
const jws = {
92-
signature: base64url.encode(signature),
91+
signature: Buffer.from(signature).toString('base64url'),
9392
payload: b64Payload,
9493
protected: b64ProtectedHeader
9594
};

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@digitalbazaar/vc": "^7.1.2",
4949
"@digitalbazaar/webkms-client": "^14.1.2",
5050
"assert-plus": "^1.0.0",
51-
"base64url-universal": "2.0.0",
5251
"bnid": "^3.0.0",
5352
"body-parser": "^1.20.3",
5453
"cors": "^2.8.5",

test/mocha/50-vc-jwt-issuer.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*!
22
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import * as base64url from 'base64url-universal';
54
import * as bedrock from '@bedrock/core';
65
import * as helpers from './helpers.js';
76
import {createRequire} from 'node:module';
@@ -115,10 +114,8 @@ describe('issue using VC-JWT format', () => {
115114
const jwt = verifiableCredential.id.slice('data:application/jwt,'.length);
116115
const split = jwt.split('.');
117116
split.length.should.equal(3);
118-
const header = JSON.parse(
119-
new TextDecoder().decode(base64url.decode(split[0])));
120-
const payload = JSON.parse(
121-
new TextDecoder().decode(base64url.decode(split[1])));
117+
const header = JSON.parse(Buffer.from(split[0], 'base64url').toString());
118+
const payload = JSON.parse(Buffer.from(split[1], 'base64url').toString());
122119
header.kid.should.equal(assertionMethodKeyId);
123120
header.alg.should.equal('ES256');
124121
payload.iss.should.equal(did);

test/mocha/60-vc-jwt-issuer-status.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*!
22
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import * as base64url from 'base64url-universal';
54
import * as bedrock from '@bedrock/core';
65
import * as helpers from './helpers.js';
76
import {createRequire} from 'node:module';
@@ -137,10 +136,8 @@ describe('issue using VC-JWT format w/status list support', () => {
137136
const jwt = verifiableCredential.id.slice('data:application/jwt,'.length);
138137
const split = jwt.split('.');
139138
split.length.should.equal(3);
140-
const header = JSON.parse(
141-
new TextDecoder().decode(base64url.decode(split[0])));
142-
const payload = JSON.parse(
143-
new TextDecoder().decode(base64url.decode(split[1])));
139+
const header = JSON.parse(Buffer.from(split[0], 'base64url').toString());
140+
const payload = JSON.parse(Buffer.from(split[1], 'base64url').toString());
144141
header.kid.should.equal(assertionMethodKeyId);
145142
header.alg.should.equal('ES256');
146143
payload.iss.should.equal(did);

test/mocha/assertions/testIssueXi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import * as assertions from './index.js';
55
import * as helpers from '../helpers.js';
66
import {createRequire} from 'node:module';
7-
import {encode} from 'base64url-universal';
87

98
const require = createRequire(import.meta.url);
109

@@ -48,7 +47,8 @@ export function testIssueXi({suiteName, algorithm, issueOptions}) {
4847
const extraInformationBytes = new Uint8Array([
4948
12, 52, 75, 63, 74, 85, 21, 5, 62, 10
5049
]);
51-
const extraInformationEncoded = encode(extraInformationBytes);
50+
const extraInformationEncoded = Buffer.from(
51+
extraInformationBytes).toString('base64url');
5252
const {verifiableCredential} = await assertions.issueAndAssert({
5353
configId: noStatusListIssuerId,
5454
credential,

test/mocha/helpers.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import * as base64url from 'base64url-universal';
54
import * as bedrock from '@bedrock/core';
65
import * as database from '@bedrock/mongodb';
76
import {importJWK, SignJWT} from 'jose';
@@ -764,8 +763,7 @@ export function parseEnvelope({verifiableCredential}) {
764763
const data = id.slice(commaIndex + 1);
765764
// FIXME: consider adding verification of `data` (JWT)
766765
const split = data.split('.');
767-
const claimSet = JSON.parse(
768-
new TextDecoder().decode(base64url.decode(split[1])));
766+
const claimSet = JSON.parse(Buffer.from(split[1], 'base64url').toString());
769767
return claimSet.vc;
770768
}
771769
throw new Error(`Unknown envelope format "${format}".`);

test/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"@digitalbazaar/vc-bitstring-status-list": "^2.0.1",
5050
"@digitalbazaar/vc-status-list": "^8.0.1",
5151
"@digitalbazaar/webkms-client": "^14.1.2",
52-
"base64url-universal": "^2.0.0",
5352
"c8": "^10.1.3",
5453
"cross-env": "^7.0.3",
5554
"jose": "^6.0.10",

0 commit comments

Comments
 (0)