-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
typeTable
and registryEntryId
.
Adds support for newer `@digitalbazaar/cbrold` `encode()` and `decode()` API options.
- Loading branch information
Showing
3 changed files
with
27 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ const BASE_45_MULTIBASE_PREFIX = 'R'; | |
* @param {object} [options.jsonldDocument] - Document to encode. | ||
* @param {object} [options.cborldBytes] - CBOR-LD bytes to encode. | ||
* @param {object} [options.documentLoader] - Loader for jsonldDocument. | ||
* @param {Number} [options.registryEntryId] - CBOR-LD type table registry | ||
Check warning on line 29 in lib/util.js GitHub Actions / lint (20.x)
|
||
* entry id. | ||
* @param {Map} [options.typeTable] - CBOR-LD type table for associated | ||
* registryEntryId. | ||
* @param {object} [options.appContextMap] - CBOR-LD app context map. | ||
* @param {object} [options.moduleSize] - Output image QR Code module size. | ||
* @param {object} [options.margin] - Output image margin size. | ||
|
@@ -39,9 +43,10 @@ const BASE_45_MULTIBASE_PREFIX = 'R'; | |
* @returns {object} The QR code properties. | ||
*/ | ||
export async function toQrCode({ | ||
header, jsonldDocument, cborldBytes, documentLoader, appContextMap, | ||
moduleSize, margin, qrMultibaseEncoding = BASE_45_MULTIBASE_PREFIX, | ||
qrErrorCorrectionLevel = 'L', qrVersion = 0, diagnose | ||
header, jsonldDocument, cborldBytes, documentLoader, registryEntryId, | ||
typeTable, appContextMap, moduleSize, margin, | ||
qrMultibaseEncoding = BASE_45_MULTIBASE_PREFIX, qrErrorCorrectionLevel = 'L', | ||
qrVersion = 0, diagnose | ||
} = {}) { | ||
if(jsonldDocument && cborldBytes) { | ||
throw new Error( | ||
|
@@ -52,6 +57,8 @@ export async function toQrCode({ | |
cborldBytes = await cborld.encode({ | ||
jsonldDocument, | ||
documentLoader, | ||
registryEntryId, | ||
typeTable, | ||
appContextMap, | ||
// to debug, set diagnose: console.log | ||
diagnose | ||
|
@@ -79,7 +86,7 @@ export async function toQrCode({ | |
|
||
export async function fromQrCode({ | ||
expectedHeader = '', text, decodeCborld = true, documentLoader, | ||
appContextMap, diagnose | ||
typeTable, appContextMap, diagnose | ||
} = {}) { | ||
if(!(text && text.startsWith(expectedHeader))) { | ||
throw TypeError('Unsupported QR format.'); | ||
|
@@ -107,6 +114,7 @@ export async function fromQrCode({ | |
const jsonldDocument = await cborld.decode({ | ||
cborldBytes, | ||
documentLoader, | ||
typeTable, | ||
appContextMap, | ||
// to debug, set diagnose: console.log | ||
diagnose | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters