Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@digitalcredentials/cborld
Advanced tools
A JavaScript CBOR-LD Process for Web browsers and Node.js apps.
(Forked from digitalbazaar/cborld
v4
to provide TypeScript and ReactNative compatibility.)
This library provides a CBOR-LD Processor for Web browsers, React Native, and Node.js applications.
npm install @digitalcredentials/cborld
To install locally (for development):
git clone https://github.com/digitalcredentials/cborld.git
cd cborld
npm install
This library provides two primary functions for encoding and decoding CBOR-LD data.
To encode a JSON-LD document as CBOR-LD:
import {encode, documentLoader} from '@digitalcredentials/cborld';
const jsonldDocument = {
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'Note',
summary: 'CBOR-LD',
content: 'CBOR-LD is awesome!'
};
// encode a JSON-LD Javascript object into CBOR-LD bytes
const cborldBytes = await encode({jsonldDocument, documentLoader});
To decode a CBOR-LD document to JSON-LD:
import {decode, documentLoader} from '@digitalcredentials/cborld';
// get the CBOR-LD bytes
const cborldBytes = await fs.promises.readFile('out.cborld');
// decode the CBOR-LD bytes into a Javascript object
const jsonldDocument = await cborld.decode({cborldBytes, documentLoader});
Uint8Array
Encodes a given JSON-LD document into a CBOR-LD byte array.
object
Decodes a CBOR-LD byte array into a JSON-LD document.
function
A diagnostic function that is called with
diagnostic information. Typically set to console.log
when
debugging.
string
Fetches a resource given a URL and returns it as a string.
Promise<Uint8Array>
Encodes a given JSON-LD document into a CBOR-LD byte array.
Kind: global function
Returns: Uint8Array
- - The encoded CBOR-LD bytes.
Param | Type | Description |
---|---|---|
options | object |
The options to use when encoding to CBOR-LD. |
options.jsonldDocument | object |
The JSON-LD Document to convert to CBOR-LD bytes. |
options.documentLoader | documentLoaderFunction |
The document loader to use when resolving JSON-LD Context URLs. |
[options.appContextMap] | Map |
A map of JSON-LD Context URLs and their encoded CBOR-LD values (must be values greater than 32767 (0x7FFF)). |
[options.appTermMap] | Map |
A map of JSON-LD terms and their associated CBOR-LD term codecs. |
[options.diagnose] | diagnosticFunction |
A function that, if provided, is called with diagnostic information. |
Promise<object>
Decodes a CBOR-LD byte array into a JSON-LD document.
Kind: global function
Returns: object
- - The decoded JSON-LD Document.
Param | Type | Description |
---|---|---|
options | object |
The options to use when decoding CBOR-LD. |
options.cborldBytes | Uint8Array |
The encoded CBOR-LD bytes to decode. |
options.documentLoader | function |
The document loader to use when resolving JSON-LD Context URLs. |
[options.appContextMap] | Map |
A map of JSON-LD Context URLs and their associated CBOR-LD values. The values must be greater than 32767 (0x7FFF)). |
[options.appTermMap] | Map |
A map of JSON-LD terms and their associated CBOR-LD term codecs. |
[options.diagnose] | diagnosticFunction |
A function that, if provided, is called with diagnostic information. |
function
A diagnostic function that is called with diagnostic information. Typically
set to console.log
when debugging.
Kind: global typedef
Param | Type | Description |
---|---|---|
message | string | The diagnostic message. |
string
Fetches a resource given a URL and returns it as a string.
Kind: global typedef
Returns: string
- The resource associated with the URL as a string.
Param | Type | Description |
---|---|---|
url | string |
The URL to retrieve. |
Examples:
TBD
Please follow the existing code style.
PRs accepted.
If editing the README, please conform to the standard-readme specification.
FAQs
A CBOR-LD encoder/decoder for Javascript.
We found that @digitalcredentials/cborld demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.