🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

cddl

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cddl

Concise data definition language (RFC 8610) implementation and JSON validator in Node.js

Source
npmnpm
Version
0.8.1
Version published
Weekly downloads
793
-18.92%
Maintainers
1
Weekly downloads
 
Created
Source

CDDL Test

Concise data definition language (RFC 8610) implementation and JSON validator in Node.js.

CDDL expresses Concise Binary Object Representation (CBOR) data structures (RFC 7049). Its main goal is to provide an easy and unambiguous way to express structures for protocol messages and data formats that use CBOR or JSON.

There are also CDDL parsers for other languages:

  • Rust: anweiss/cddl

Note: this is work in progress, feel free to have a look at the code or contribute but don't use this for anything yet!

Install

To install this package run:

$ npm install cddl

Using this package

This package exposes a CLI as well as a programmatic interface for parsing and transforming CDDL.

CLI

The cddl CLI offers a validate command that helps identify invalid CDDL formats, e.g.:

npx cddl validate ./path/to/interface.cddl
âś… Valid CDDL file!

Programmatic Interface

You can also use this package to parse a CDDL file into an abstract syntax tree (AST). For example, given the following CDDL file:

person = {
    identity,       ; an identity
    employer: tstr, ; some employer
}

It parses the content into an AST:

import { parse } from 'cddl'

const ast = parse('./spec.cddl')
console.log(ast)
/**
 * outputs:
 * [
 *   {
 *     Type: 'group',
 *     Name: 'person',
 *     Properties: [ [Object], [Object] ],
 *     IsChoiceAddition: false
 *   }
 * ]
 */

The CDDL AST is defined in source files. The parse method returns Assignment[].

If you are interested in this project, please feel free to contribute ideas or code patches. Have a look at our contributing guidelines](https://github.com/christian-bromann/cddl/blob/master/LICENSE) to get started.

Keywords

cddl

FAQs

Package last updated on 22 May 2023

Did you know?

Socket

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.

Install

Related posts