Socket
Socket
Sign inDemoInstall

cbor2

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.1

lib/box.js.map

15

lib/box.d.ts

@@ -25,13 +25,6 @@ import { SYMS } from './constants.js';

declare function saveEncoded(obj: OriginalEncoding, orig: Uint8Array): void;
declare function box(value: bigint, orig: Uint8Array): BigInt;
declare function box(value: string, orig: Uint8Array): String;
declare function box(value: number, orig: Uint8Array): Number;
/**
* Put an object wrapper around a primitive value, such as a number, boolean,
* or bigint, storing the original CBOR encoding of the value for later
* reconstitution.
*
* @param value Primitive value.
* @param orig Original encoding.
* @returns Object wrapper with original encoding attached.
*/
declare function box<T>(value: T, orig: Uint8Array): ValueOf<T>;
/**
* Remove all boxed types from an object.

@@ -44,2 +37,2 @@ *

export { OriginalEncoding, ValueOf, box, getEncoded, saveEncoded, unbox };
export { type OriginalEncoding, type ValueOf, box, getEncoded, saveEncoded, unbox };

@@ -59,1 +59,2 @@ import { SYMS } from "./constants.js";

};
//# sourceMappingURL=box.js.map

@@ -1,2 +0,2 @@

import { C as CommentOptions } from './options-38a74b48.js';
import { C as CommentOptions } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -3,0 +3,0 @@

@@ -163,3 +163,3 @@ import { MT, NUMBYTES, SYMS } from "./constants.js";

const CommentOptionsDefault = {
...CBORcontainer.defaultOptions,
...CBORcontainer.defaultDecodeOptions,
initialDepth: 0,

@@ -225,1 +225,2 @@ noPrefixHex: false,

};
//# sourceMappingURL=comment.js.map

@@ -67,1 +67,2 @@ const MT = {

};
//# sourceMappingURL=constants.js.map

@@ -1,2 +0,2 @@

import { e as RequiredDecodeOptions, P as Parent, M as MtAiValue } from './options-38a74b48.js';
import { R as RequiredDecodeOptions, D as DecodeOptions, P as Parent, M as MtAiValue } from './options-_aKvrAbt.js';
import { DecodeStream } from './decodeStream.js';

@@ -18,3 +18,24 @@ import { Tag } from './tag.js';

#private;
static defaultOptions: RequiredDecodeOptions;
static defaultDecodeOptions: RequiredDecodeOptions;
/**
* Throw errors when decoding for bytes that were not encoded with {@link
* https://www.ietf.org/archive/id/draft-ietf-cbor-cde-01.html CBOR Common
* Deterministic Encoding Profile}.
*
* CDE does not mandate this checking, so it is up to the application
* whether it wants to ensure that inputs were not encoded incompetetently
* or maliciously. To turn all of these on at once, set the cbor option to
* true.
*/
static cdeDecodeOptions: DecodeOptions;
/**
* Throw errors when decoding for bytes that were not encoded with {@link
* https://www.ietf.org/archive/id/draft-mcnally-deterministic-cbor-07.html
* dCBOR: A Deterministic CBOR Application Profile}.
*
* The dCBOR spec mandates that these errors be thrown when decoding dCBOR.
* Turn this on by setting the `dcbor` option to true, which also enables
* `cde` mode.
*/
static dcborDecodeOptions: DecodeOptions;
parent: Parent | undefined;

@@ -21,0 +42,0 @@ mt: number;

@@ -0,1 +1,2 @@

import { sortCoreDeterministic } from "./sorts.js";
import { MT, NUMBYTES } from "./constants.js";

@@ -7,2 +8,3 @@ import { box, getEncoded, saveEncoded } from "./box.js";

import { Tag } from "./tag.js";
import { checkSubnormal } from "./float.js";
import { encode } from "./encoder.js";

@@ -18,6 +20,8 @@ const LENGTH_FOR_AI = /* @__PURE__ */ new Map([

class CBORcontainer {
static defaultOptions = {
static defaultDecodeOptions = {
...DecodeStream.defaultOptions,
ParentType: CBORcontainer,
boxed: false,
cde: false,
dcbor: false,
rejectLargeNegatives: false,

@@ -29,6 +33,7 @@ rejectBigInts: false,

rejectLongLoundNaN: false,
rejectLongNumbers: false,
rejectLongFloats: false,
rejectNegativeZero: false,
rejectSimple: false,
rejectStreaming: false,
rejectSubnormals: false,
rejectUndefined: false,

@@ -38,2 +43,38 @@ saveOriginal: false,

};
/**
* Throw errors when decoding for bytes that were not encoded with {@link
* https://www.ietf.org/archive/id/draft-ietf-cbor-cde-01.html CBOR Common
* Deterministic Encoding Profile}.
*
* CDE does not mandate this checking, so it is up to the application
* whether it wants to ensure that inputs were not encoded incompetetently
* or maliciously. To turn all of these on at once, set the cbor option to
* true.
*/
static cdeDecodeOptions = {
cde: true,
rejectStreaming: true,
requirePreferred: true,
sortKeys: sortCoreDeterministic
};
/**
* Throw errors when decoding for bytes that were not encoded with {@link
* https://www.ietf.org/archive/id/draft-mcnally-deterministic-cbor-07.html
* dCBOR: A Deterministic CBOR Application Profile}.
*
* The dCBOR spec mandates that these errors be thrown when decoding dCBOR.
* Turn this on by setting the `dcbor` option to true, which also enables
* `cde` mode.
*/
static dcborDecodeOptions = {
...this.cdeDecodeOptions,
dcbor: true,
rejectDuplicateKeys: true,
rejectLargeNegatives: true,
rejectLongLoundNaN: true,
rejectLongFloats: true,
rejectNegativeZero: true,
rejectSimple: true,
rejectUndefined: true
};
parent;

@@ -89,8 +130,2 @@ mt;

}
if (opts.rejectLongNumbers && ai > NUMBYTES.ZERO) {
const buf = encode(value, { chunkSize: 9 });
if (buf.length < LENGTH_FOR_AI.get(ai)) {
throw new Error(`Int should have been encoded shorter: ${value}`);
}
}
if (opts.rejectLargeNegatives && value < -0x8000000000000000n) {

@@ -117,3 +152,6 @@ throw new Error(`Invalid 65bit negative number: ${value}`);

}
if (opts.rejectLongNumbers) {
if (opts.rejectSubnormals) {
checkSubnormal(stream.toHere(offset + 1));
}
if (opts.rejectLongFloats) {
const buf = encode(value, { chunkSize: 9 });

@@ -288,1 +326,2 @@ if (buf[0] >> 5 !== mt) {

};
//# sourceMappingURL=container.js.map

@@ -1,2 +0,2 @@

import { a as DecodeOptions } from './options-38a74b48.js';
import { D as DecodeOptions } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -3,0 +3,0 @@

import { CBORcontainer } from "./container.js";
import { DecodeStream } from "./decodeStream.js";
import { SYMS } from "./constants.js";
function decode(src, options) {
const opts = {
...CBORcontainer.defaultOptions,
...options
};
function decode(src, options = {}) {
const opts = { ...CBORcontainer.defaultDecodeOptions };
if (options.dcbor) {
Object.assign(opts, CBORcontainer.dcborDecodeOptions);
} else if (options.cde) {
Object.assign(opts, CBORcontainer.cdeDecodeOptions);
}
Object.assign(opts, options);
if (Object.hasOwn(opts, "rejectLongNumbers")) {
throw new TypeError("rejectLongNumbers has changed to requirePreferred");
}
if (opts.boxed) {

@@ -41,1 +47,2 @@ opts.saveOriginal = true;

};
//# sourceMappingURL=decoder.js.map

@@ -1,2 +0,2 @@

import { M as MtAiValue, S as Sliceable, b as DecodeStreamOptions } from './options-38a74b48.js';
import { M as MtAiValue, S as Sliceable, b as DecodeStreamOptions } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -19,2 +19,3 @@

* @throws On invalid input or extra data in input.
* @yields Value tuples.
* @example

@@ -31,2 +32,2 @@ * ```js

export { DecodeStream, ValueGenerator };
export { DecodeStream, type ValueGenerator };

@@ -14,3 +14,4 @@ import {

maxDepth: 1024,
encoding: "hex"
encoding: "hex",
requirePreferred: false
};

@@ -53,2 +54,3 @@ #src;

* @throws On invalid input or extra data in input.
* @yields Value tuples.
* @example

@@ -75,2 +77,3 @@ * ```js

* @throws Maximum depth exceeded, invalid input.
* @yields Value tuples.
*/

@@ -97,2 +100,4 @@ *#nextVal(depth) {

simple = true;
} else if (this.#opts.requirePreferred && val < 24) {
throw new Error(`Unexpectedly long integer encoding (1) for ${val}`);
}

@@ -106,2 +111,5 @@ break;

val = this.#view.getUint16(this.#offset, false);
if (this.#opts.requirePreferred && val <= 255) {
throw new Error(`Unexpectedly long integer encoding (2) for ${val}`);
}
}

@@ -115,2 +123,5 @@ break;

val = this.#view.getUint32(this.#offset, false);
if (this.#opts.requirePreferred && val <= 65535) {
throw new Error(`Unexpectedly long integer encoding (4) for ${val}`);
}
}

@@ -127,2 +138,5 @@ break;

}
if (this.#opts.requirePreferred && val <= 4294967295) {
throw new Error(`Unexpectedly long integer encoding (8) for ${val}`);
}
}

@@ -258,1 +272,2 @@ break;

};
//# sourceMappingURL=decodeStream.js.map

@@ -1,2 +0,2 @@

import { a as DecodeOptions } from './options-38a74b48.js';
import { D as DecodeOptions } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -3,0 +3,0 @@

@@ -29,3 +29,3 @@ import { MT, SYMS } from "./constants.js";

const opts = {
...CBORcontainer.defaultOptions,
...CBORcontainer.defaultDecodeOptions,
...options,

@@ -127,1 +127,2 @@ ParentType: DiagContainer

};
//# sourceMappingURL=diagnostic.js.map

@@ -1,26 +0,32 @@

import { f as RequiredEncodeOptions, j as Writer, h as TaggedValue, T as TagNumber, E as EncodeOptions } from './options-38a74b48.js';
import { f as RequiredEncodeOptions, E as EncodeOptions, j as Writer, h as TaggedValue, T as TagNumber } from './options-_aKvrAbt.js';
import './sorts.js';
declare const ENCODED: symbol;
declare const EncodeOptionsDefault: RequiredEncodeOptions;
declare const defaultEncodeOptions: RequiredEncodeOptions;
/**
* Any class. Ish.
* Encode with CDE ({@link
* https://www.ietf.org/archive/id/draft-ietf-cbor-cde-01.html CBOR Common
* Deterministic Encoding Profile}). Eable this set of options by setting
* `cde` to true.
*
* Since cbor2 always uses preferred encoding, this option only sets the
* sort algorithm for map/object keys, and ensures that any original
* encoding information (from decoding with saveOriginal) is ignored.
*/
type AbstractClassType<T extends abstract new (...args: any) => any> = abstract new (...args: any) => InstanceType<T>;
type TypeEncoder<T> = (obj: T, w: Writer, opts: RequiredEncodeOptions) => TaggedValue | undefined;
declare const cdeEncodeOptions: EncodeOptions;
/**
* Add a known converter for the given type to CBOR.
* Encode with CDE and dCBOR ({@link
* https://www.ietf.org/archive/id/draft-mcnally-deterministic-cbor-07.html
* dCBOR: A Deterministic CBOR Application Profile}). Enable this set of
* options by setting `dcbor` to true.
*
* @param typ Type constructor, e.g. "Array".
* @param encoder Converter function for that type.
* @returns Previous converter for that type, or unknown.
* Several of these options can cause errors to be thrown for inputs that
* would have otherwise generated valid CBOR (e.g. `undefined`).
*/
declare function registerEncoder<T extends AbstractClassType<T>>(typ: T, encoder: TypeEncoder<InstanceType<T>>): TypeEncoder<T> | undefined;
declare const dcborEncodeOptions: EncodeOptions;
/**
* Remove the given type from being converted to CBOR.
*
* @param typ Type constructor, e.e.g "Array".
* @returns Previous converter for that type, or unknown.
* Any class. Ish.
*/
declare function clearEncoder<T extends AbstractClassType<T>>(typ: T): TypeEncoder<T> | undefined;
type AbstractClassType<T extends abstract new (...args: any) => any> = abstract new (...args: any) => InstanceType<T>;
type TypeEncoder<T> = (obj: T, w: Writer, opts: RequiredEncodeOptions) => TaggedValue | undefined;
interface ToJSON {

@@ -59,2 +65,10 @@ /**

/**
* Write a tag number to the output stream. MUST be followed by writing
* the tag contents.
*
* @param tag Tag number.
* @param w Stream to write to.
*/
declare function writeTag(tag: TagNumber, w: Writer): void;
/**
* Intended for internal use.

@@ -78,10 +92,2 @@ *

/**
* Write a tag number to the output stream. MUST be followed by writing
* the tag contents.
*
* @param tag Tag number.
* @param w Stream to write to.
*/
declare function writeTag(tag: TagNumber, w: Writer): void;
/**
* Convert the string to UTF8. Write the length of the UTF8 version to the

@@ -112,2 +118,17 @@ * stream with major type UTF8_STRING, then the UTF8 bytes.

/**
* Add a known converter for the given type to CBOR.
*
* @param typ Type constructor, e.g. "Array".
* @param encoder Converter function for that type.
* @returns Previous converter for that type, or unknown.
*/
declare function registerEncoder<T extends AbstractClassType<T>>(typ: T, encoder: TypeEncoder<InstanceType<T>>): TypeEncoder<T> | undefined;
/**
* Remove the given type from being converted to CBOR.
*
* @param typ Type constructor, e.e.g "Array".
* @returns Previous converter for that type, or unknown.
*/
declare function clearEncoder<T extends AbstractClassType<T>>(typ: T): TypeEncoder<T> | undefined;
/**
* Write a single value of unknown type to the given writer.

@@ -130,2 +151,2 @@ *

export { AbstractClassType, ENCODED, EncodeOptionsDefault, ToJSON, TypeEncoder, clearEncoder, encode, registerEncoder, writeArray, writeBigInt, writeFloat, writeInt, writeNumber, writeString, writeTag, writeUint8Array, writeUnknown };
export { type AbstractClassType, ENCODED, type ToJSON, type TypeEncoder, cdeEncodeOptions, clearEncoder, dcborEncodeOptions, defaultEncodeOptions, encode, registerEncoder, writeArray, writeBigInt, writeFloat, writeInt, writeNumber, writeString, writeTag, writeUint8Array, writeUnknown };

@@ -0,4 +1,5 @@

import { sortCoreDeterministic } from "./sorts.js";
import { MT, NUMBYTES, SIMPLE, SYMS, TAG } from "./constants.js";
import { Writer } from "./writer.js";
import { halfToUint } from "./float.js";
import { flushToZero, halfToUint } from "./float.js";
import { hexToU8 } from "./utils.js";

@@ -16,7 +17,10 @@ const {

const TE = new TextEncoder();
const EncodeOptionsDefault = {
const defaultEncodeOptions = {
...Writer.defaultOptions,
avoidInts: false,
cde: false,
collapseBigInts: true,
dcbor: false,
float64: false,
flushToZero: false,
forceEndian: null,

@@ -33,16 +37,16 @@ ignoreOriginalEncoding: false,

};
const TYPES = /* @__PURE__ */ new Map([
[Array, writeArray],
[Uint8Array, writeUint8Array]
]);
function registerEncoder(typ, encoder) {
const old = TYPES.get(typ);
TYPES.set(typ, encoder);
return old;
}
function clearEncoder(typ) {
const old = TYPES.get(typ);
TYPES.delete(typ);
return old;
}
const cdeEncodeOptions = {
cde: true,
ignoreOriginalEncoding: true,
sortKeys: sortCoreDeterministic
};
const dcborEncodeOptions = {
...cdeEncodeOptions,
dcbor: true,
largeNegativeAsBigInt: true,
rejectCustomSimples: true,
rejectDuplicateKeys: true,
rejectUndefined: true,
simplifyNegativeZero: true
};
function writeFloat(val, w, opts) {

@@ -93,2 +97,12 @@ if (opts.rejectFloats) {

}
function writeTag(tag, w) {
if (typeof tag === "number") {
writeInt(tag, w, MT.TAG);
} else if (tag <= Number.MAX_SAFE_INTEGER) {
writeInt(Number(tag), w, MT.TAG);
} else {
w.writeUint8(MT.TAG << 5 | NUMBYTES.EIGHT);
w.writeBigUint64(tag);
}
}
function writeBigInt(val, w, opts) {

@@ -121,2 +135,5 @@ const neg = val < 0n;

function writeNumber(val, w, opts) {
if (opts.flushToZero) {
val = flushToZero(val);
}
if (Object.is(val, -0)) {

@@ -138,12 +155,2 @@ if (opts.simplifyNegativeZero) {

}
function writeTag(tag, w) {
if (typeof tag === "number") {
writeInt(tag, w, MT.TAG);
} else if (tag <= Number.MAX_SAFE_INTEGER) {
writeInt(Number(tag), w, MT.TAG);
} else {
w.writeUint8(MT.TAG << 5 | NUMBYTES.EIGHT);
w.writeBigUint64(tag);
}
}
function writeString(val, w) {

@@ -166,2 +173,16 @@ const utf8 = TE.encode(val);

}
const TYPES = /* @__PURE__ */ new Map([
[Array, writeArray],
[Uint8Array, writeUint8Array]
]);
function registerEncoder(typ, encoder) {
const old = TYPES.get(typ);
TYPES.set(typ, encoder);
return old;
}
function clearEncoder(typ) {
const old = TYPES.get(typ);
TYPES.delete(typ);
return old;
}
function writeObject(obj, w, opts) {

@@ -202,2 +223,4 @@ if (obj === null) {

const entries = Object.entries(obj).map(
// Circular
// eslint-disable-next-line no-use-before-define
(e) => [e[0], e[1], encode(e[0], opts)]

@@ -245,7 +268,10 @@ );

}
function encode(val, options) {
const opts = {
...EncodeOptionsDefault,
...options
};
function encode(val, options = {}) {
const opts = { ...defaultEncodeOptions };
if (options.dcbor) {
Object.assign(opts, dcborEncodeOptions);
} else if (options.cde) {
Object.assign(opts, cdeEncodeOptions);
}
Object.assign(opts, options);
const w = new Writer(opts);

@@ -257,4 +283,6 @@ writeUnknown(val, w, opts);

ENCODED,
EncodeOptionsDefault,
cdeEncodeOptions,
clearEncoder,
dcborEncodeOptions,
defaultEncodeOptions,
encode,

@@ -272,1 +300,2 @@ registerEncoder,

};
//# sourceMappingURL=encoder.js.map

@@ -6,5 +6,7 @@ /**

* @param offset Offset into buf to start reading 2 octets.
* @param rejectSubnormals Throw if the result is subnormal.
* @returns Parsed float.
* @throws Unwanted subnormal.
*/
declare function parseHalf(buf: Uint8Array, offset?: number): number;
declare function parseHalf(buf: Uint8Array, offset?: number, rejectSubnormals?: boolean): number;
/**

@@ -20,3 +22,18 @@ * Return a big-endian unsigned integer that has the same internal layout

declare function halfToUint(half: number): number | null;
/**
* Flush subnormal numbers to 0/-0.
*
* @param n Number.
* @returns Normalized number.
*/
declare function flushToZero(n: number): number;
/**
* Does the given buffer contain a bigEndian IEEE754 float that is subnormal?
* If so, throw an error.
*
* @param buf 2, 4, or 8 bytes for float16, float32, or float64.
* @throws Bad input or subnormal.
*/
declare function checkSubnormal(buf: Uint8Array): void;
export { halfToUint, parseHalf };
export { checkSubnormal, flushToZero, halfToUint, parseHalf };

@@ -1,6 +0,9 @@

function parseHalf(buf, offset = 0) {
function parseHalf(buf, offset = 0, rejectSubnormals = false) {
const sign = buf[offset] & 128 ? -1 : 1;
const exp = (buf[offset] & 124) >> 2;
const mant = (buf[offset] & 3) << 8 | buf[offset + 1];
if (!exp) {
if (exp === 0) {
if (rejectSubnormals && mant !== 0) {
throw new Error(`Unwanted subnormal: ${sign * 5960464477539063e-23 * mant}`);
}
return sign * 5960464477539063e-23 * mant;

@@ -41,5 +44,45 @@ } else if (exp === 31) {

}
function flushToZero(n) {
if (n !== 0) {
const a = new ArrayBuffer(8);
const dv = new DataView(a);
dv.setFloat64(0, n, false);
const b = dv.getBigUint64(0, false);
if ((b & 0x7ff0000000000000n) === 0n) {
return b & 0x8000000000000000n ? -0 : 0;
}
}
return n;
}
function checkSubnormal(buf) {
switch (buf.length) {
case 2:
parseHalf(buf, 0, true);
break;
case 4: {
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
const n = dv.getUint32(0, false);
if ((n & 2139095040) === 0 && n & 8388607) {
throw new Error(`Unwanted subnormal: ${dv.getFloat32(0, false)}`);
}
break;
}
case 8: {
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
const n = dv.getBigUint64(0, false);
if ((n & 0x7ff0000000000000n) === 0n && n & 0x000fffffffffffn) {
throw new Error(`Unwanted subnormal: ${dv.getFloat64(0, false)}`);
}
break;
}
default:
throw new TypeError(`Bad input to isSubnormal: ${buf}`);
}
}
export {
checkSubnormal,
flushToZero,
halfToUint,
parseHalf
};
//# sourceMappingURL=float.js.map

@@ -0,7 +1,8 @@

import { D as DecodeOptions } from './options-_aKvrAbt.js';
export { C as CommentOptions, b as DecodeStreamOptions, c as DecodeValue, a as Decodeable, E as EncodeOptions, M as MtAiValue, P as Parent, d as ParentConstructor, e as RequiredCommentOptions, R as RequiredDecodeOptions, f as RequiredEncodeOptions, g as Simple, S as Sliceable, T as TagNumber, h as TaggedValue, i as ToCBOR, j as Writer, W as WriterOptions } from './options-_aKvrAbt.js';
export { DecodeStream, ValueGenerator } from './decodeStream.js';
export { C as CommentOptions, a as DecodeOptions, b as DecodeStreamOptions, c as DecodeValue, D as Decodeable, E as EncodeOptions, M as MtAiValue, P as Parent, d as ParentConstructor, R as RequiredCommentOptions, e as RequiredDecodeOptions, f as RequiredEncodeOptions, g as Simple, S as Sliceable, T as TagNumber, h as TaggedValue, i as ToCBOR, j as Writer, W as WriterOptions } from './options-38a74b48.js';
export { decode } from './decoder.js';
export { diagnose } from './diagnostic.js';
export { comment } from './comment.js';
export { encode } from './encoder.js';
export { cdeEncodeOptions, dcborEncodeOptions, defaultEncodeOptions, encode } from './encoder.js';
export { Tag } from './tag.js';

@@ -11,1 +12,7 @@ export { getEncoded, unbox } from './box.js';

import './constants.js';
declare const cdeDecodeOptions: DecodeOptions;
declare const dcborDecodeOptions: DecodeOptions;
declare const defaultDecodeOptions: Required<DecodeOptions>;
export { DecodeOptions, cdeDecodeOptions, dcborDecodeOptions, defaultDecodeOptions };
import "./types.js";
import { CBORcontainer } from "./container.js";
import { decode } from "./decoder.js";
import { diagnose } from "./diagnostic.js";
import { comment } from "./comment.js";
import { encode } from "./encoder.js";
import {
cdeEncodeOptions,
defaultEncodeOptions,
dcborEncodeOptions,
encode
} from "./encoder.js";
import { Simple } from "./simple.js";
import { Tag } from "./tag.js";
import { unbox, getEncoded } from "./box.js";
const {
cdeDecodeOptions,
dcborDecodeOptions,
defaultDecodeOptions
} = CBORcontainer;
export {
Simple,
Tag,
cdeDecodeOptions,
cdeEncodeOptions,
comment,
dcborDecodeOptions,
dcborEncodeOptions,
decode,
defaultDecodeOptions,
defaultEncodeOptions,
diagnose,

@@ -19,1 +36,2 @@ encode,

};
//# sourceMappingURL=index.js.map
import './sorts.js';
export { C as CommentOptions, a as DecodeOptions, b as DecodeStreamOptions, c as DecodeValue, D as Decodeable, E as EncodeOptions, M as MtAiValue, P as Parent, d as ParentConstructor, R as RequiredCommentOptions, e as RequiredDecodeOptions, f as RequiredEncodeOptions, k as RequiredWriterOptions, S as Sliceable, W as WriterOptions } from './options-38a74b48.js';
export { C as CommentOptions, D as DecodeOptions, b as DecodeStreamOptions, c as DecodeValue, a as Decodeable, E as EncodeOptions, M as MtAiValue, P as Parent, d as ParentConstructor, e as RequiredCommentOptions, R as RequiredDecodeOptions, f as RequiredEncodeOptions, k as RequiredWriterOptions, S as Sliceable, W as WriterOptions } from './options-_aKvrAbt.js';

@@ -1,2 +0,2 @@

export { g as Simple } from './options-38a74b48.js';
export { g as Simple } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -24,1 +24,2 @@ import { MT } from "./constants.js";

};
//# sourceMappingURL=simple.js.map

@@ -35,2 +35,2 @@ /**

export { KeySorter, KeyValueEncoded, sortCoreDeterministic, sortLengthFirstDeterministic };
export { type KeySorter, type KeyValueEncoded, sortCoreDeterministic, sortLengthFirstDeterministic };

@@ -33,1 +33,2 @@ function sortCoreDeterministic(a, b) {

};
//# sourceMappingURL=sorts.js.map

@@ -1,2 +0,2 @@

import { R as RequiredCommentOptions, e as RequiredDecodeOptions, i as ToCBOR, D as Decodeable, T as TagNumber } from './options-38a74b48.js';
import { e as RequiredCommentOptions, R as RequiredDecodeOptions, i as ToCBOR, a as Decodeable, T as TagNumber } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -71,2 +71,3 @@

* array.
* @yields One time, the contained value.
*/

@@ -93,2 +94,2 @@ [Symbol.iterator](): Generator<unknown, void, undefined>;

export { BaseDecoder, Commenter, Tag, TagDecoder };
export { type BaseDecoder, type Commenter, Tag, type TagDecoder };

@@ -66,2 +66,3 @@ class Tag {

* array.
* @yields One time, the contained value.
*/

@@ -112,1 +113,2 @@ *[Symbol.iterator]() {

};
//# sourceMappingURL=tag.js.map
export { }
export { }

@@ -94,3 +94,3 @@ import { MT, TAG } from "./constants.js";

}
if (opts.rejectLongNumbers && tag.contents[0] === 0) {
if (opts.requirePreferred && tag.contents[0] === 0) {
throw new Error(`Decoding overly-large bigint: ${tag}(h'${u8toHex(tag.contents)}`);

@@ -102,3 +102,3 @@ }

}
if (opts.rejectLongNumbers && bi >= Number.MIN_SAFE_INTEGER && bi <= Number.MAX_SAFE_INTEGER) {
if (opts.requirePreferred && bi >= Number.MIN_SAFE_INTEGER && bi <= Number.MAX_SAFE_INTEGER) {
throw new Error(`Decoding bigint that could have been int: ${bi}n`);

@@ -371,1 +371,2 @@ }

registerEncoder(BigInt, writeBoxed);
//# sourceMappingURL=types.js.map

@@ -50,1 +50,2 @@ function hexToU8(str) {

};
//# sourceMappingURL=utils.js.map

@@ -1,2 +0,2 @@

export { T as TagNumber, h as TaggedValue, i as ToCBOR, j as Writer } from './options-38a74b48.js';
export { T as TagNumber, h as TaggedValue, i as ToCBOR, j as Writer } from './options-_aKvrAbt.js';
import './sorts.js';

@@ -138,1 +138,2 @@ class Writer {

};
//# sourceMappingURL=writer.js.map
{
"name": "cbor2",
"version": "1.1.0",
"version": "1.2.1",
"description": "Encode and parse data in the Concise Binary Object Representation (CBOR) data format (RFC8949).",

@@ -46,14 +46,14 @@ "exports": {

},
"packageManager": "pnpm@8.6.10",
"packageManager": "pnpm@8.14.3",
"devDependencies": {
"@cto.af/eslint-config": "3.0.1",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"c8": "8.0.1",
"eslint": "8.48.0",
"eslint-plugin-jsdoc": "46.5.1",
"@cto.af/eslint-config": "3.1.0",
"@typescript-eslint/eslint-plugin": "6.19.1",
"@typescript-eslint/parser": "6.19.1",
"c8": "9.1.0",
"eslint": "8.56.0",
"eslint-plugin-jsdoc": "48.0.2",
"eslint-plugin-markdown": "3.0.1",
"rimraf": "^5.0.1",
"tsup": "7.2.0",
"typedoc": "0.25.0"
"rimraf": "^5.0.5",
"tsup": "8.0.1",
"typedoc": "0.25.7"
},

@@ -60,0 +60,0 @@ "license": "MIT",

@@ -8,3 +8,3 @@ # cbor2

- Web-first. Usable in node.
- Web-first. Usable in Node and Deno.
- Simpler where possible. Remove non-core features in favor of extensibility.

@@ -17,8 +17,5 @@ - Synchronous decoding. Removes streaming capabilities that are rarely used.

This project now only supports versions of Node that the Node team is
This project now only supports versions of Node.js that the Node team is
[currently supporting](https://github.com/nodejs/Release#release-schedule).
Ava's [support
statement](https://github.com/avajs/ava/blob/main/docs/support-statement.md)
is what we will be using as well. Since the first release will not be soon,
that means Node `18`+ is required.
Currently, that means Node `18`+ is required.

@@ -25,0 +22,0 @@ ## Installation

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc