JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 162571
  • Score
    100M100P100Q188470F
  • License Apache-2.0

Library to serialize/deserialize CycloneDX BOM with protocol buffers

Package Exports

  • @appthreat/cdx-proto

Readme

cdx-proto

Runtime library to serialize/deserialize CycloneDX BOM with protocol buffers. The project was generated using protoc-gen-es from the official proto specification.

Sample usage

import { cdx_16, cdx_17 } from "@appthreat/cdx-proto";
import {
  fromBinary,
  fromJsonString,
  toBinary,
  toJson,
} from "@bufbuild/protobuf";

// Create .proto files
let bomSchema =
  +bomJson.specVersion === 1.6 ? cdx_16.BomSchema : cdx_17.BomSchema;
writeFileSync(
  binFile,
  toBinary(
    bomSchema,
    fromJsonString(bomSchema, stringifyIfNeeded(bomJson), {
      ignoreUnknownFields: true,
    }),
  ),
  {
    writeUnknownFields: true,
  },
);

// Read .proto files
const bomObject = fromBinary(bomSchema, readFileSync(binFile), {
  readUnknownFields: true,
});
const jsonstr = toJson(bomSchema, bomObject, { emitDefaultValues: true });

License

Apache-2.0