cbor-web 9.0.2 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,42 +1,19 @@
1
1
  {
2
2
  "name": "cbor-web",
3
- "version": "9.0.2",
3
+ "version": "10.0.2",
4
4
  "description": "",
5
5
  "main": "dist/cbor.js",
6
6
  "types": "./types/lib/cbor.d.ts",
7
- "scripts": {
8
- "build": "webpack",
9
- "copy": "webpack"
10
- },
11
7
  "keywords": [],
12
8
  "author": "Joe Hildebrand <joe-github@cursive.net>",
13
9
  "license": "MIT",
14
10
  "homepage": "https://github.com/hildjj/node-cbor/tree/main/packages/cbor-web",
15
11
  "repository": {
16
12
  "type": "git",
17
- "url": "http://github.com/hildjj/node-cbor.git",
13
+ "url": "git+ssh://git@github.com/hildjj/node-cbor.git",
18
14
  "directory": "packages/cbor-web"
19
15
  },
20
- "devDependencies": {
21
- "abort-controller": "3.0.0",
22
- "base64-js": "^1.5.1",
23
- "buffer": "^6.0.3",
24
- "cbor": "^9.0.2",
25
- "events": "^3.3.0",
26
- "ieee754": "^1.2.1",
27
- "inherits": "^2.0.4",
28
- "nofilter": "^3.1.0",
29
- "process": "^0.11.10",
30
- "readable-stream": "^4.4.0",
31
- "safe-buffer": "^5.2.1",
32
- "stream-browserify": "^3.0.0",
33
- "string_decoder": "^1.3.0",
34
- "util-deprecate": "^1.0.2",
35
- "webpack": "^5.82.1",
36
- "webpack-cli": "^5.1.1"
37
- },
38
16
  "engines": {
39
- "node": ">=16"
40
- },
41
- "gitHead": "1967cd4540e9aab60093fcd711cd97edee542043"
17
+ "node": ">=18"
18
+ }
42
19
  }
@@ -1,34 +0,0 @@
1
- import Commented = require("./commented");
2
- import Diagnose = require("./diagnose");
3
- import Decoder = require("./decoder");
4
- import Encoder = require("./encoder");
5
- import Simple = require("./simple");
6
- import Tagged = require("./tagged");
7
- import Map = require("./map");
8
- import SharedValueEncoder = require("./sharedValueEncoder");
9
- export declare const comment: typeof import("./commented").comment;
10
- export declare const decodeAll: typeof import("./decoder").decodeAll;
11
- export declare const decodeFirst: typeof import("./decoder").decodeFirst;
12
- export declare const decodeAllSync: typeof import("./decoder").decodeAllSync;
13
- export declare const decodeFirstSync: any;
14
- export declare const diagnose: typeof import("./diagnose").diagnose;
15
- export declare const encode: typeof import("./encoder").encode;
16
- export declare const encodeCanonical: typeof import("./encoder").encodeCanonical;
17
- export declare const encodeOne: typeof import("./encoder").encodeOne;
18
- export declare const encodeAsync: typeof import("./encoder").encodeAsync;
19
- export declare const decode: typeof import("./decoder").decodeFirstSync;
20
- export declare namespace leveldb {
21
- const decode_1: typeof Decoder.decodeFirstSync;
22
- export { decode_1 as decode };
23
- const encode_1: typeof Encoder.encode;
24
- export { encode_1 as encode };
25
- export const buffer: boolean;
26
- export const name: string;
27
- }
28
- /**
29
- * Reset everything that we can predict a plugin might have altered in good
30
- * faith. For now that includes the default set of tags that decoding and
31
- * encoding will use.
32
- */
33
- export declare function reset(): void;
34
- export { Commented, Diagnose, Decoder, Encoder, Simple, Tagged, Map, SharedValueEncoder };
@@ -1,111 +0,0 @@
1
- /// <reference types="node" />
2
- export = Commented;
3
- /**
4
- * Generate the expanded format of RFC 8949, section 3.2.2.
5
- *
6
- * @extends stream.Transform
7
- */
8
- declare class Commented extends stream.Transform {
9
- /**
10
- * Comment on an input Buffer or string, creating a string passed to the
11
- * callback. If callback not specified, a promise is returned.
12
- *
13
- * @param {string|Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray
14
- * |DataView|stream.Readable} input Something to parse.
15
- * @param {CommentOptions|commentCallback|string|number} [options={}]
16
- * Encoding, max_depth, or callback.
17
- * @param {commentCallback} [cb] If specified, called on completion.
18
- * @returns {Promise} If cb not specified.
19
- * @throws {Error} Input required.
20
- * @static
21
- */
22
- static comment(input: string | Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray | DataView | stream.Readable, options?: CommentOptions | commentCallback | string | number, cb?: commentCallback): Promise<any>;
23
- /**
24
- * Create a CBOR commenter.
25
- *
26
- * @param {CommentOptions} [options={}] Stream options.
27
- */
28
- constructor(options?: CommentOptions);
29
- depth: number;
30
- max_depth: number;
31
- all: NoFilter;
32
- parser: Decoder;
33
- /**
34
- * @param {Buffer} v Descend into embedded CBOR.
35
- * @private
36
- */
37
- private _tag_24;
38
- /**
39
- * @ignore
40
- */
41
- _on_error(er: any): void;
42
- /**
43
- * @ignore
44
- */
45
- _on_read(buf: any): void;
46
- /**
47
- * @ignore
48
- */
49
- _on_more(mt: any, len: any, parent_mt: any, pos: any): void;
50
- /**
51
- * @ignore
52
- */
53
- _on_start_string(mt: any, len: any, parent_mt: any, pos: any): void;
54
- /**
55
- * @ignore
56
- */
57
- _on_start(mt: any, tag: any, parent_mt: any, pos: any): void;
58
- /**
59
- * @ignore
60
- */
61
- _on_stop(mt: any): void;
62
- /**
63
- * @private
64
- */
65
- private _on_value;
66
- /**
67
- * @ignore
68
- */
69
- _on_data(): void;
70
- }
71
- declare namespace Commented {
72
- export { CommentOptions, commentCallback };
73
- }
74
- import stream = require("stream");
75
- import NoFilter = require("nofilter");
76
- import Decoder = require("./decoder");
77
- import { Buffer } from "buffer";
78
- type CommentOptions = {
79
- /**
80
- * How many times to indent
81
- * the dashes.
82
- */
83
- max_depth?: number;
84
- /**
85
- * Initial indentation depth.
86
- */
87
- depth?: number;
88
- /**
89
- * If true, omit the summary
90
- * of the full bytes read at the end.
91
- */
92
- no_summary?: boolean;
93
- /**
94
- * Mapping from tag number to function(v),
95
- * where v is the decoded value that comes after the tag, and where the
96
- * function returns the correctly-created value for that tag.
97
- */
98
- tags?: object;
99
- /**
100
- * If true, prefer Uint8Arrays to
101
- * be generated instead of node Buffers. This might turn on some more
102
- * changes in the future, so forward-compatibility is not guaranteed yet.
103
- */
104
- preferWeb?: boolean;
105
- /**
106
- * Encoding to use for input, if it
107
- * is a string.
108
- */
109
- encoding?: BufferEncoding;
110
- };
111
- type commentCallback = (error?: Error, commented?: string) => void;
@@ -1,63 +0,0 @@
1
- export namespace MT {
2
- const POS_INT: number;
3
- const NEG_INT: number;
4
- const BYTE_STRING: number;
5
- const UTF8_STRING: number;
6
- const ARRAY: number;
7
- const MAP: number;
8
- const TAG: number;
9
- const SIMPLE_FLOAT: number;
10
- }
11
- export type MT = number;
12
- export namespace TAG {
13
- const DATE_STRING: number;
14
- const DATE_EPOCH: number;
15
- const POS_BIGINT: number;
16
- const NEG_BIGINT: number;
17
- const DECIMAL_FRAC: number;
18
- const BIGFLOAT: number;
19
- const BASE64URL_EXPECTED: number;
20
- const BASE64_EXPECTED: number;
21
- const BASE16_EXPECTED: number;
22
- const CBOR: number;
23
- const URI: number;
24
- const BASE64URL: number;
25
- const BASE64: number;
26
- const REGEXP: number;
27
- const MIME: number;
28
- const SET: number;
29
- }
30
- export type TAG = number;
31
- export namespace NUMBYTES {
32
- const ZERO: number;
33
- const ONE: number;
34
- const TWO: number;
35
- const FOUR: number;
36
- const EIGHT: number;
37
- const INDEFINITE: number;
38
- }
39
- export type NUMBYTES = number;
40
- export namespace SIMPLE {
41
- const FALSE: number;
42
- const TRUE: number;
43
- const NULL: number;
44
- const UNDEFINED: number;
45
- }
46
- export type SIMPLE = number;
47
- export namespace SYMS {
48
- const NULL_1: symbol;
49
- export { NULL_1 as NULL };
50
- const UNDEFINED_1: symbol;
51
- export { UNDEFINED_1 as UNDEFINED };
52
- export const PARENT: symbol;
53
- export const BREAK: symbol;
54
- export const STREAM: symbol;
55
- }
56
- export const SHIFT32: 4294967296;
57
- export namespace BI {
58
- const MINUS_ONE: bigint;
59
- const NEG_MAX: bigint;
60
- const MAXINT32: bigint;
61
- const MAXINT64: bigint;
62
- const SHIFT32: bigint;
63
- }
@@ -1,198 +0,0 @@
1
- /// <reference types="node" />
2
- export = Decoder;
3
- /**
4
- * Decode a stream of CBOR bytes by transforming them into equivalent
5
- * JavaScript data. Because of the limitations of Node object streams,
6
- * special symbols are emitted instead of NULL or UNDEFINED. Fix those
7
- * up by calling {@link Decoder.nullcheck}.
8
- *
9
- * @extends BinaryParseStream
10
- */
11
- declare class Decoder extends BinaryParseStream {
12
- /**
13
- * Check the given value for a symbol encoding a NULL or UNDEFINED value in
14
- * the CBOR stream.
15
- *
16
- * @param {any} val The value to check.
17
- * @returns {any} The corrected value.
18
- * @throws {Error} Nothing was found.
19
- * @static
20
- * @example
21
- * myDecoder.on('data', val => {
22
- * val = Decoder.nullcheck(val)
23
- * // ...
24
- * })
25
- */
26
- static nullcheck(val: any): any;
27
- /**
28
- * Decode the first CBOR item in the input, synchronously. This will throw
29
- * an exception if the input is not valid CBOR, or if there are more bytes
30
- * left over at the end (if options.extendedResults is not true).
31
- *
32
- * @param {BufferLike} input If a Readable stream, must have
33
- * received the `readable` event already, or you will get an error
34
- * claiming "Insufficient data".
35
- * @param {DecoderOptions|string} [options={}] Options or encoding for input.
36
- * @returns {ExtendedResults|any} The decoded value.
37
- * @throws {UnexpectedDataError} Data is left over after decoding.
38
- * @throws {Error} Insufficient data.
39
- * @static
40
- */
41
- static decodeFirstSync(input: BufferLike, options?: DecoderOptions | string): ExtendedResults | any;
42
- /**
43
- * Decode all of the CBOR items in the input into an array. This will throw
44
- * an exception if the input is not valid CBOR; a zero-length input will
45
- * return an empty array.
46
- *
47
- * @param {BufferLike} input What to parse?
48
- * @param {DecoderOptions|string} [options={}] Options or encoding
49
- * for input.
50
- * @returns {Array<ExtendedResults>|Array<any>} Array of all found items.
51
- * @throws {TypeError} No input provided.
52
- * @throws {Error} Insufficient data provided.
53
- * @static
54
- */
55
- static decodeAllSync(input: BufferLike, options?: DecoderOptions | string): Array<ExtendedResults> | Array<any>;
56
- /**
57
- * Decode the first CBOR item in the input. This will error if there are
58
- * more bytes left over at the end (if options.extendedResults is not true),
59
- * and optionally if there were no valid CBOR bytes in the input. Emits the
60
- * {Decoder.NOT_FOUND} Symbol in the callback if no data was found and the
61
- * `required` option is false.
62
- *
63
- * @param {BufferLike} input What to parse?
64
- * @param {DecoderOptions|decodeCallback|string} [options={}] Options, the
65
- * callback, or input encoding.
66
- * @param {decodeCallback} [cb] Callback.
67
- * @returns {Promise<ExtendedResults|any>} Returned even if callback is
68
- * specified.
69
- * @throws {TypeError} No input provided.
70
- * @static
71
- */
72
- static decodeFirst(input: BufferLike, options?: DecoderOptions | decodeCallback | string, cb?: decodeCallback): Promise<ExtendedResults | any>;
73
- /**
74
- * @callback decodeAllCallback
75
- * @param {Error} error If one was generated.
76
- * @param {Array<ExtendedResults>|Array<any>} value All of the decoded
77
- * values, wrapped in an Array.
78
- */
79
- /**
80
- * Decode all of the CBOR items in the input. This will error if there are
81
- * more bytes left over at the end.
82
- *
83
- * @param {BufferLike} input What to parse?
84
- * @param {DecoderOptions|decodeAllCallback|string} [options={}]
85
- * Decoding options, the callback, or the input encoding.
86
- * @param {decodeAllCallback} [cb] Callback.
87
- * @returns {Promise<Array<ExtendedResults>|Array<any>>} Even if callback
88
- * is specified.
89
- * @throws {TypeError} No input specified.
90
- * @static
91
- */
92
- static decodeAll(input: BufferLike, options?: string | DecoderOptions | ((error: Error, value: Array<ExtendedResults> | Array<any>) => any), cb?: (error: Error, value: Array<ExtendedResults> | Array<any>) => any): Promise<Array<ExtendedResults> | Array<any>>;
93
- /**
94
- * Create a parsing stream.
95
- *
96
- * @param {DecoderOptions} [options={}] Options.
97
- */
98
- constructor(options?: DecoderOptions);
99
- running: boolean;
100
- max_depth: number;
101
- tags: {
102
- [x: string]: Tagged.TagFunction;
103
- };
104
- preferWeb: boolean;
105
- extendedResults: boolean;
106
- required: boolean;
107
- preventDuplicateKeys: boolean;
108
- valueBytes: NoFilter;
109
- /**
110
- * Stop processing.
111
- */
112
- close(): void;
113
- /**
114
- * Only called if extendedResults is true.
115
- *
116
- * @ignore
117
- */
118
- _onRead(data: any): void;
119
- }
120
- declare namespace Decoder {
121
- export { NOT_FOUND, BufferLike, ExtendedResults, DecoderOptions, decodeCallback };
122
- }
123
- import BinaryParseStream = require("../vendor/binary-parse-stream");
124
- import Tagged = require("./tagged");
125
- import NoFilter = require("nofilter");
126
- /**
127
- * Things that can act as inputs, from which a NoFilter can be created.
128
- */
129
- type BufferLike = string | Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray | DataView | stream.Readable;
130
- type DecoderOptions = {
131
- /**
132
- * The maximum depth to parse.
133
- * Use -1 for "until you run out of memory". Set this to a finite
134
- * positive number for un-trusted inputs. Most standard inputs won't nest
135
- * more than 100 or so levels; I've tested into the millions before
136
- * running out of memory.
137
- */
138
- max_depth?: number;
139
- /**
140
- * Mapping from tag number to function(v),
141
- * where v is the decoded value that comes after the tag, and where the
142
- * function returns the correctly-created value for that tag.
143
- */
144
- tags?: Tagged.TagMap;
145
- /**
146
- * If true, prefer Uint8Arrays to
147
- * be generated instead of node Buffers. This might turn on some more
148
- * changes in the future, so forward-compatibility is not guaranteed yet.
149
- */
150
- preferWeb?: boolean;
151
- /**
152
- * The encoding of the input.
153
- * Ignored if input is a Buffer.
154
- */
155
- encoding?: BufferEncoding;
156
- /**
157
- * Should an error be thrown when no
158
- * data is in the input?
159
- */
160
- required?: boolean;
161
- /**
162
- * If true, emit extended
163
- * results, which will be an object with shape {@link ExtendedResults }.
164
- * The value will already have been null-checked.
165
- */
166
- extendedResults?: boolean;
167
- /**
168
- * If true, error is
169
- * thrown if a map has duplicate keys.
170
- */
171
- preventDuplicateKeys?: boolean;
172
- };
173
- type ExtendedResults = {
174
- /**
175
- * The value that was found.
176
- */
177
- value: any;
178
- /**
179
- * The number of bytes of the original input that
180
- * were read.
181
- */
182
- length: number;
183
- /**
184
- * The bytes of the original input that were used
185
- * to produce the value.
186
- */
187
- bytes: Buffer;
188
- /**
189
- * The bytes that were left over from the original
190
- * input. This property only exists if {@linkcode Decoder.decodeFirst } or
191
- * {@linkcode Decoder.decodeFirstSync } was called.
192
- */
193
- unused?: Buffer;
194
- };
195
- type decodeCallback = (error?: Error, value?: any) => void;
196
- declare const NOT_FOUND: unique symbol;
197
- import { Buffer } from "buffer";
198
- import stream = require("stream");
@@ -1,91 +0,0 @@
1
- export = Diagnose;
2
- /**
3
- * Output the diagnostic format from a stream of CBOR bytes.
4
- *
5
- * @extends stream.Transform
6
- */
7
- declare class Diagnose extends stream.Transform {
8
- /**
9
- * Convenience function to return a string in diagnostic format.
10
- *
11
- * @param {BufferLike} input The CBOR bytes to format.
12
- * @param {DiagnoseOptions |diagnoseCallback|string} [options={}]
13
- * Options, the callback, or the input encoding.
14
- * @param {diagnoseCallback} [cb] Callback.
15
- * @returns {Promise} If callback not specified.
16
- * @throws {TypeError} Input not provided.
17
- */
18
- static diagnose(input: BufferLike, options?: DiagnoseOptions | diagnoseCallback | string, cb?: diagnoseCallback): Promise<any>;
19
- /**
20
- * Creates an instance of Diagnose.
21
- *
22
- * @param {DiagnoseOptions} [options={}] Options for creation.
23
- */
24
- constructor(options?: DiagnoseOptions);
25
- float_bytes: number;
26
- separator: string;
27
- stream_errors: boolean;
28
- parser: Decoder;
29
- /**
30
- * @ignore
31
- */
32
- _on_error(er: any): void;
33
- /** @private */
34
- private _on_more;
35
- /** @private */
36
- private _fore;
37
- /** @private */
38
- private _on_value;
39
- /** @private */
40
- private _on_start;
41
- /** @private */
42
- private _on_stop;
43
- /** @private */
44
- private _on_data;
45
- }
46
- declare namespace Diagnose {
47
- export { BufferLike, DiagnoseOptions, diagnoseCallback };
48
- }
49
- import stream = require("stream");
50
- import Decoder = require("./decoder");
51
- /**
52
- * Things that can act as inputs, from which a NoFilter can be created.
53
- */
54
- type BufferLike = string | Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray | DataView | stream.Readable;
55
- type DiagnoseOptions = {
56
- /**
57
- * Output between detected objects.
58
- */
59
- separator?: string;
60
- /**
61
- * Put error info into the
62
- * output stream.
63
- */
64
- stream_errors?: boolean;
65
- /**
66
- * The maximum depth to parse.
67
- * Use -1 for "until you run out of memory". Set this to a finite
68
- * positive number for un-trusted inputs. Most standard inputs won't nest
69
- * more than 100 or so levels; I've tested into the millions before
70
- * running out of memory.
71
- */
72
- max_depth?: number;
73
- /**
74
- * Mapping from tag number to function(v),
75
- * where v is the decoded value that comes after the tag, and where the
76
- * function returns the correctly-created value for that tag.
77
- */
78
- tags?: object;
79
- /**
80
- * If true, prefer Uint8Arrays to
81
- * be generated instead of node Buffers. This might turn on some more
82
- * changes in the future, so forward-compatibility is not guaranteed yet.
83
- */
84
- preferWeb?: boolean;
85
- /**
86
- * The encoding of input, ignored if
87
- * input is not string.
88
- */
89
- encoding?: BufferEncoding;
90
- };
91
- type diagnoseCallback = (error?: Error, value?: string) => void;