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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# bedrock-vcb-verifier ChangeLog

## 1.3.2 - 2025-04-dd

### Fixed
- Always base64-encode QR code VCBs to ensure proper data URL construction.

## 1.3.1 - 2025-04-17

### Fixed
Expand Down
5 changes: 2 additions & 3 deletions lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ export async function barcodeToEnvelopedCredential({text, barcode} = {}) {
barcode = {data: text, format: BARCODE_FORMATS.QR_CODE};
}
const mediaType = `data:application/vcb;barcode-format=${barcode.format}`;
if(barcode.format === BARCODE_FORMATS.PDF417) {
if(barcode.format === BARCODE_FORMATS.PDF417 ||
barcode.format === BARCODE_FORMATS.QR_CODE) {
credential.id = `${mediaType};base64,` +
Buffer.from(barcode.data, 'utf8').toString('base64');
} else if(barcode.format === BARCODE_FORMATS.QR_CODE) {
credential.id = `${mediaType},${barcode.data}`;
} else {
throw new BedrockError(
'Could not create enveloped verifiable credential; ' +
Expand Down
5 changes: 5 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {mockData} from './mocha/mock.data.js';
// in-memory exchanges only used during testing
const EXCHANGES = new Map();

const TEXT_DECODER = new TextDecoder();

bedrock.events.on('bedrock.init', async () => {
// setup mock VCB verifier app...

Expand Down Expand Up @@ -162,6 +164,9 @@ bedrock.events.on('bedrock-express.configure.routes', app => {
};
if(format.parameters.has('base64')) {
barcode.data = new Uint8Array(Buffer.from(contents, 'base64'));
if(barcode.format === 'qr_code') {
barcode.data = TEXT_DECODER.decode(barcode.data);
}
}
({credential: verifiableCredential} = await barcodeToCredential({
barcode, documentLoader
Expand Down