@bcts/dcbor 1.0.0-alpha.20 → 1.0.0-alpha.22
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/LICENSE +2 -1
- package/dist/index.cjs +80 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +80 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +80 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -21
- package/src/bignum.ts +4 -0
- package/src/byte-string.ts +4 -0
- package/src/cbor-codable.ts +4 -0
- package/src/cbor-tagged-codable.ts +4 -0
- package/src/cbor-tagged-decodable.ts +4 -0
- package/src/cbor-tagged-encodable.ts +4 -0
- package/src/cbor-tagged.ts +4 -0
- package/src/cbor.ts +6 -0
- package/src/conveniences.ts +4 -0
- package/src/date.ts +4 -0
- package/src/decode.ts +6 -0
- package/src/diag.ts +4 -0
- package/src/dump.ts +4 -0
- package/src/error.ts +4 -0
- package/src/exact.ts +4 -0
- package/src/float.ts +4 -0
- package/src/global.d.ts +4 -0
- package/src/globals.d.ts +5 -0
- package/src/index.ts +4 -0
- package/src/map.ts +4 -0
- package/src/prelude.ts +4 -0
- package/src/set.ts +4 -0
- package/src/simple.ts +4 -0
- package/src/stdlib.ts +4 -0
- package/src/string-util.ts +4 -0
- package/src/tag.ts +4 -0
- package/src/tags-store.ts +4 -0
- package/src/tags.ts +4 -0
- package/src/varint.ts +6 -0
- package/src/walk.ts +5 -3
package/LICENSE
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Copyright © 2023-2026 Blockchain Commons, LLC
|
|
2
|
-
Copyright © 2025-2026
|
|
2
|
+
Copyright © 2025-2026 Parity Technologies
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
Redistribution and use in source and binary forms, with or without modification,
|
|
5
6
|
are permitted provided that the following conditions are met:
|
package/dist/index.cjs
CHANGED
|
@@ -4282,6 +4282,10 @@ var CborError = class CborError extends Error {
|
|
|
4282
4282
|
//#endregion
|
|
4283
4283
|
//#region src/stdlib.ts
|
|
4284
4284
|
/**
|
|
4285
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4286
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
4287
|
+
*
|
|
4288
|
+
*
|
|
4285
4289
|
* Standard library re-exports and compatibility layer.
|
|
4286
4290
|
*
|
|
4287
4291
|
* In Rust, this handles std/no_std feature flags.
|
|
@@ -4806,6 +4810,10 @@ var ExactU128 = class {
|
|
|
4806
4810
|
//#endregion
|
|
4807
4811
|
//#region src/float.ts
|
|
4808
4812
|
/**
|
|
4813
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4814
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
4815
|
+
*
|
|
4816
|
+
*
|
|
4809
4817
|
* Float encoding and conversion utilities for dCBOR.
|
|
4810
4818
|
*
|
|
4811
4819
|
* # Floating Point Number Support in dCBOR
|
|
@@ -4959,6 +4967,11 @@ const f16CborData = (value) => {
|
|
|
4959
4967
|
|
|
4960
4968
|
//#endregion
|
|
4961
4969
|
//#region src/varint.ts
|
|
4970
|
+
/**
|
|
4971
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4972
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
4973
|
+
*
|
|
4974
|
+
*/
|
|
4962
4975
|
const typeBits = (t) => {
|
|
4963
4976
|
return t << 5;
|
|
4964
4977
|
};
|
|
@@ -5052,6 +5065,10 @@ function getUint64(view, byteOffset, littleEndian) {
|
|
|
5052
5065
|
//#endregion
|
|
5053
5066
|
//#region src/string-util.ts
|
|
5054
5067
|
/**
|
|
5068
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5069
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
5070
|
+
*
|
|
5071
|
+
*
|
|
5055
5072
|
* String utilities for dCBOR, including Unicode normalization.
|
|
5056
5073
|
*
|
|
5057
5074
|
* @module string-util
|
|
@@ -5225,6 +5242,10 @@ const getGlobalTagsStore = () => {
|
|
|
5225
5242
|
//#endregion
|
|
5226
5243
|
//#region src/dump.ts
|
|
5227
5244
|
/**
|
|
5245
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5246
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
5247
|
+
*
|
|
5248
|
+
*
|
|
5228
5249
|
* Hex dump utilities for CBOR data.
|
|
5229
5250
|
*
|
|
5230
5251
|
* Affordances for viewing the encoded binary representation of CBOR as hexadecimal.
|
|
@@ -5409,6 +5430,10 @@ function dumpItems(cbor, level, opts) {
|
|
|
5409
5430
|
//#endregion
|
|
5410
5431
|
//#region src/diag.ts
|
|
5411
5432
|
/**
|
|
5433
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5434
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
5435
|
+
*
|
|
5436
|
+
*
|
|
5412
5437
|
* Enhanced diagnostic formatting for CBOR values.
|
|
5413
5438
|
*
|
|
5414
5439
|
* Provides multiple formatting options including
|
|
@@ -5640,6 +5665,10 @@ function resolveTagsStore(tags) {
|
|
|
5640
5665
|
//#endregion
|
|
5641
5666
|
//#region src/simple.ts
|
|
5642
5667
|
/**
|
|
5668
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5669
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
5670
|
+
*
|
|
5671
|
+
*
|
|
5643
5672
|
* CBOR Simple Values (Major Type 7).
|
|
5644
5673
|
*
|
|
5645
5674
|
* @module simple
|
|
@@ -5693,6 +5722,11 @@ const simpleCborData = (simple) => {
|
|
|
5693
5722
|
|
|
5694
5723
|
//#endregion
|
|
5695
5724
|
//#region src/decode.ts
|
|
5725
|
+
/**
|
|
5726
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5727
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
5728
|
+
*
|
|
5729
|
+
*/
|
|
5696
5730
|
function decodeCbor(data) {
|
|
5697
5731
|
const { cbor, len } = decodeCborInternal(new DataView(data.buffer, data.byteOffset, data.byteLength));
|
|
5698
5732
|
const remaining = data.length - len;
|
|
@@ -5958,6 +5992,10 @@ function checkCanonicalEncoding(cbor, buf) {
|
|
|
5958
5992
|
//#endregion
|
|
5959
5993
|
//#region src/conveniences.ts
|
|
5960
5994
|
/**
|
|
5995
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5996
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
5997
|
+
*
|
|
5998
|
+
*
|
|
5961
5999
|
* Convenience utilities for working with CBOR values.
|
|
5962
6000
|
*
|
|
5963
6001
|
* Provides type-safe helpers for checking types, extracting values,
|
|
@@ -6544,6 +6582,10 @@ const isNumber = (cbor) => {
|
|
|
6544
6582
|
//#endregion
|
|
6545
6583
|
//#region src/map.ts
|
|
6546
6584
|
/**
|
|
6585
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
6586
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
6587
|
+
*
|
|
6588
|
+
*
|
|
6547
6589
|
* Map Support in dCBOR
|
|
6548
6590
|
*
|
|
6549
6591
|
* A deterministic CBOR map implementation that ensures maps with the same
|
|
@@ -6776,6 +6818,10 @@ var CborMap = class CborMap {
|
|
|
6776
6818
|
//#endregion
|
|
6777
6819
|
//#region src/walk.ts
|
|
6778
6820
|
/**
|
|
6821
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
6822
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
6823
|
+
*
|
|
6824
|
+
*
|
|
6779
6825
|
* Tree traversal system for CBOR data structures.
|
|
6780
6826
|
*
|
|
6781
6827
|
* This module provides a visitor pattern implementation for traversing
|
|
@@ -6920,15 +6966,13 @@ const walk = (cbor, initialState, visitor) => {
|
|
|
6920
6966
|
*/
|
|
6921
6967
|
function walkInternal(cbor, level, edge, state, visitor, skipVisit = false) {
|
|
6922
6968
|
let currentState = state;
|
|
6923
|
-
let stopDescent = false;
|
|
6924
6969
|
if (!skipVisit) {
|
|
6925
6970
|
const [newState, stop] = visitor({
|
|
6926
6971
|
type: "single",
|
|
6927
6972
|
cbor
|
|
6928
6973
|
}, level, edge, currentState);
|
|
6929
6974
|
currentState = newState;
|
|
6930
|
-
|
|
6931
|
-
if (stopDescent) return currentState;
|
|
6975
|
+
if (stop) return currentState;
|
|
6932
6976
|
}
|
|
6933
6977
|
switch (cbor.type) {
|
|
6934
6978
|
case MajorType.Array:
|
|
@@ -7002,6 +7046,11 @@ function walkTagged(cbor, level, state, visitor) {
|
|
|
7002
7046
|
|
|
7003
7047
|
//#endregion
|
|
7004
7048
|
//#region src/cbor.ts
|
|
7049
|
+
/**
|
|
7050
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7051
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
7052
|
+
*
|
|
7053
|
+
*/
|
|
7005
7054
|
const MajorType = {
|
|
7006
7055
|
Unsigned: 0,
|
|
7007
7056
|
Negative: 1,
|
|
@@ -7477,6 +7526,10 @@ const Cbor = {
|
|
|
7477
7526
|
//#endregion
|
|
7478
7527
|
//#region src/cbor-tagged-encodable.ts
|
|
7479
7528
|
/**
|
|
7529
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7530
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
7531
|
+
*
|
|
7532
|
+
*
|
|
7480
7533
|
* Tagged CBOR encoding support.
|
|
7481
7534
|
*
|
|
7482
7535
|
* This module provides the `CborTaggedEncodable` interface, which enables types to
|
|
@@ -7523,6 +7576,10 @@ const createTaggedCbor = (encodable) => {
|
|
|
7523
7576
|
//#endregion
|
|
7524
7577
|
//#region src/cbor-tagged-decodable.ts
|
|
7525
7578
|
/**
|
|
7579
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7580
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
7581
|
+
*
|
|
7582
|
+
*
|
|
7526
7583
|
* Tagged CBOR decoding support.
|
|
7527
7584
|
*
|
|
7528
7585
|
* This module provides the `CborTaggedDecodable` interface, which enables types to
|
|
@@ -7568,6 +7625,10 @@ const extractTaggedContent = (cbor) => {
|
|
|
7568
7625
|
//#endregion
|
|
7569
7626
|
//#region src/date.ts
|
|
7570
7627
|
/**
|
|
7628
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7629
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
7630
|
+
*
|
|
7631
|
+
*
|
|
7571
7632
|
* Date/time support for CBOR with tag(1) encoding.
|
|
7572
7633
|
*
|
|
7573
7634
|
* A CBOR-friendly representation of a date and time.
|
|
@@ -8049,6 +8110,10 @@ var CborDate = class CborDate {
|
|
|
8049
8110
|
//#endregion
|
|
8050
8111
|
//#region src/bignum.ts
|
|
8051
8112
|
/**
|
|
8113
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
8114
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
8115
|
+
*
|
|
8116
|
+
*
|
|
8052
8117
|
* CBOR bignum (tags 2 and 3) support.
|
|
8053
8118
|
*
|
|
8054
8119
|
* This module provides conversion between CBOR and JavaScript BigInt types,
|
|
@@ -8311,6 +8376,10 @@ function cborToBigint(cbor) {
|
|
|
8311
8376
|
//#endregion
|
|
8312
8377
|
//#region src/tags.ts
|
|
8313
8378
|
/**
|
|
8379
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
8380
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
8381
|
+
*
|
|
8382
|
+
*
|
|
8314
8383
|
* Standard CBOR tag definitions from the IANA registry.
|
|
8315
8384
|
*
|
|
8316
8385
|
* @module tags
|
|
@@ -8523,6 +8592,10 @@ const tagsForValues = (values) => {
|
|
|
8523
8592
|
//#endregion
|
|
8524
8593
|
//#region src/set.ts
|
|
8525
8594
|
/**
|
|
8595
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
8596
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
8597
|
+
*
|
|
8598
|
+
*
|
|
8526
8599
|
* Set data structure for CBOR with tag(258) encoding.
|
|
8527
8600
|
*
|
|
8528
8601
|
* A Set is encoded as an array with no duplicate elements,
|
|
@@ -8924,6 +8997,10 @@ function encodeCborValue(value) {
|
|
|
8924
8997
|
//#endregion
|
|
8925
8998
|
//#region src/byte-string.ts
|
|
8926
8999
|
/**
|
|
9000
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
9001
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
9002
|
+
*
|
|
9003
|
+
*
|
|
8927
9004
|
* Byte string utilities for dCBOR.
|
|
8928
9005
|
*
|
|
8929
9006
|
* Represents a CBOR byte string (major type 2).
|