omnipin 2.0.4 → 2.1.0
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/dist/index.js +232 -156
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -818,14 +818,30 @@ function coerce(o) {
|
|
|
818
818
|
if (ArrayBuffer.isView(o)) return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
819
819
|
throw Error('Unknown type, must be binary type');
|
|
820
820
|
}
|
|
821
|
-
function
|
|
821
|
+
function is_is(value) {
|
|
822
|
+
if (null === value) return 'null';
|
|
823
|
+
if (void 0 === value) return 'undefined';
|
|
824
|
+
if (!0 === value || !1 === value) return 'boolean';
|
|
825
|
+
let typeOf = typeof value;
|
|
826
|
+
if ('string' === typeOf || 'number' === typeOf || 'bigint' === typeOf || 'symbol' === typeOf) return typeOf;
|
|
827
|
+
if ('function' === typeOf) return 'Function';
|
|
828
|
+
if (Array.isArray(value)) return 'Array';
|
|
829
|
+
if (value instanceof Uint8Array) return 'Uint8Array';
|
|
830
|
+
if (value.constructor === Object) return 'Object';
|
|
831
|
+
let objectType = function(value) {
|
|
832
|
+
let objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
|
|
833
|
+
if (objectTypeNames.includes(objectTypeName)) return objectTypeName;
|
|
834
|
+
}(value);
|
|
835
|
+
return objectType || 'Object';
|
|
836
|
+
}
|
|
837
|
+
function isBuffer(buf) {
|
|
822
838
|
return useBuffer && globalThis.Buffer.isBuffer(buf);
|
|
823
839
|
}
|
|
824
840
|
function asU8A(buf) {
|
|
825
|
-
return buf instanceof Uint8Array ?
|
|
841
|
+
return buf instanceof Uint8Array ? isBuffer(buf) ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf : Uint8Array.from(buf);
|
|
826
842
|
}
|
|
827
843
|
function compare(b1, b2) {
|
|
828
|
-
if (
|
|
844
|
+
if (isBuffer(b1) && isBuffer(b2)) return b1.compare(b2);
|
|
829
845
|
for(let i = 0; i < b1.length; i++)if (b1[i] !== b2[i]) return b1[i] < b2[i] ? -1 : 1;
|
|
830
846
|
return 0;
|
|
831
847
|
}
|
|
@@ -833,41 +849,10 @@ function byte_utils_utf8ToBytes(str) {
|
|
|
833
849
|
let out = [], p = 0;
|
|
834
850
|
for(let i = 0; i < str.length; i++){
|
|
835
851
|
let c = str.charCodeAt(i);
|
|
836
|
-
c < 128 ? out[p++] = c : (c < 2048 ? out[p++] = c >> 6 | 192 : ((0xFC00 & c) == 0xD800 && i + 1 < str.length && (0xFC00 & str.charCodeAt(i + 1)) == 0xDC00 ? (c = 0x10000 + ((0x03FF & c) << 10) + (0x03FF & str.charCodeAt(++i)), out[p++] = c >> 18 | 240, out[p++] = c >> 12 & 63 | 128) : out[p++] = c >> 12 | 224, out[p++] = c >> 6 & 63 | 128), out[p++] = 63 & c | 128);
|
|
852
|
+
c < 128 ? out[p++] = c : (c < 2048 ? out[p++] = c >> 6 | 192 : ((0xFC00 & c) == 0xD800 && i + 1 < str.length && (0xFC00 & str.charCodeAt(i + 1)) == 0xDC00 ? (c = 0x10000 + ((0x03FF & c) << 10) + (0x03FF & str.charCodeAt(++i)), out[p++] = c >> 18 | 240, out[p++] = c >> 12 & 63 | 128) : (c >= 0xD800 && c <= 0xDFFF && (c = 0xFFFD), out[p++] = c >> 12 | 224), out[p++] = c >> 6 & 63 | 128), out[p++] = 63 & c | 128);
|
|
837
853
|
}
|
|
838
854
|
return out;
|
|
839
855
|
}
|
|
840
|
-
function utf8Slice(buf, offset, end) {
|
|
841
|
-
let res = [];
|
|
842
|
-
for(; offset < end;){
|
|
843
|
-
let firstByte = buf[offset], codePoint = null, bytesPerSequence = firstByte > 0xef ? 4 : firstByte > 0xdf ? 3 : firstByte > 0xbf ? 2 : 1;
|
|
844
|
-
if (offset + bytesPerSequence <= end) {
|
|
845
|
-
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
846
|
-
switch(bytesPerSequence){
|
|
847
|
-
case 1:
|
|
848
|
-
firstByte < 0x80 && (codePoint = firstByte);
|
|
849
|
-
break;
|
|
850
|
-
case 2:
|
|
851
|
-
(0xc0 & (secondByte = buf[offset + 1])) == 0x80 && (tempCodePoint = (0x1f & firstByte) << 0x6 | 0x3f & secondByte) > 0x7f && (codePoint = tempCodePoint);
|
|
852
|
-
break;
|
|
853
|
-
case 3:
|
|
854
|
-
secondByte = buf[offset + 1], thirdByte = buf[offset + 2], (0xc0 & secondByte) == 0x80 && (0xc0 & thirdByte) == 0x80 && (tempCodePoint = (0xf & firstByte) << 0xc | (0x3f & secondByte) << 0x6 | 0x3f & thirdByte) > 0x7ff && (tempCodePoint < 0xd800 || tempCodePoint > 0xdfff) && (codePoint = tempCodePoint);
|
|
855
|
-
break;
|
|
856
|
-
case 4:
|
|
857
|
-
secondByte = buf[offset + 1], thirdByte = buf[offset + 2], fourthByte = buf[offset + 3], (0xc0 & secondByte) == 0x80 && (0xc0 & thirdByte) == 0x80 && (0xc0 & fourthByte) == 0x80 && (tempCodePoint = (0xf & firstByte) << 0x12 | (0x3f & secondByte) << 0xc | (0x3f & thirdByte) << 0x6 | 0x3f & fourthByte) > 0xffff && tempCodePoint < 0x110000 && (codePoint = tempCodePoint);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
null === codePoint ? (codePoint = 0xfffd, bytesPerSequence = 1) : codePoint > 0xffff && (codePoint -= 0x10000, res.push(codePoint >>> 10 & 0x3ff | 0xd800), codePoint = 0xdc00 | 0x3ff & codePoint), res.push(codePoint), offset += bytesPerSequence;
|
|
861
|
-
}
|
|
862
|
-
return decodeCodePointsArray(res);
|
|
863
|
-
}
|
|
864
|
-
function decodeCodePointsArray(codePoints) {
|
|
865
|
-
let len = codePoints.length;
|
|
866
|
-
if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
|
|
867
|
-
let res = '', i = 0;
|
|
868
|
-
for(; i < len;)res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
|
|
869
|
-
return res;
|
|
870
|
-
}
|
|
871
856
|
function assertEnoughData(data, pos, need) {
|
|
872
857
|
if (data.length - pos < need) throw Error(`${decodeErrPrefix} not enough data for type`);
|
|
873
858
|
}
|
|
@@ -897,31 +882,31 @@ function readUint64(data, offset, options) {
|
|
|
897
882
|
if (!0 === options.allowBigInt) return value;
|
|
898
883
|
throw Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`);
|
|
899
884
|
}
|
|
900
|
-
function encodeUint(
|
|
901
|
-
return encodeUintValue(
|
|
885
|
+
function encodeUint(writer, token) {
|
|
886
|
+
return encodeUintValue(writer, 0, token.value);
|
|
902
887
|
}
|
|
903
|
-
function encodeUintValue(
|
|
888
|
+
function encodeUintValue(writer, major, uint) {
|
|
904
889
|
if (uint < uintBoundaries[0]) {
|
|
905
890
|
let nuint = Number(uint);
|
|
906
|
-
|
|
891
|
+
writer.push([
|
|
907
892
|
major | nuint
|
|
908
893
|
]);
|
|
909
894
|
} else if (uint < uintBoundaries[1]) {
|
|
910
895
|
let nuint = Number(uint);
|
|
911
|
-
|
|
896
|
+
writer.push([
|
|
912
897
|
24 | major,
|
|
913
898
|
nuint
|
|
914
899
|
]);
|
|
915
900
|
} else if (uint < uintBoundaries[2]) {
|
|
916
901
|
let nuint = Number(uint);
|
|
917
|
-
|
|
902
|
+
writer.push([
|
|
918
903
|
25 | major,
|
|
919
904
|
nuint >>> 8,
|
|
920
905
|
0xff & nuint
|
|
921
906
|
]);
|
|
922
907
|
} else if (uint < uintBoundaries[3]) {
|
|
923
908
|
let nuint = Number(uint);
|
|
924
|
-
|
|
909
|
+
writer.push([
|
|
925
910
|
26 | major,
|
|
926
911
|
nuint >>> 24 & 0xff,
|
|
927
912
|
nuint >>> 16 & 0xff,
|
|
@@ -941,34 +926,45 @@ function encodeUintValue(buf, major, uint) {
|
|
|
941
926
|
0,
|
|
942
927
|
0
|
|
943
928
|
], lo = Number(buint & BigInt(0xffffffff)), hi = Number(buint >> BigInt(32) & BigInt(0xffffffff));
|
|
944
|
-
set[8] = 0xff & lo, lo >>= 8, set[7] = 0xff & lo, lo >>= 8, set[6] = 0xff & lo, lo >>= 8, set[5] = 0xff & lo, set[4] = 0xff & hi, hi >>= 8, set[3] = 0xff & hi, hi >>= 8, set[2] = 0xff & hi, hi >>= 8, set[1] = 0xff & hi,
|
|
929
|
+
set[8] = 0xff & lo, lo >>= 8, set[7] = 0xff & lo, lo >>= 8, set[6] = 0xff & lo, lo >>= 8, set[5] = 0xff & lo, set[4] = 0xff & hi, hi >>= 8, set[3] = 0xff & hi, hi >>= 8, set[2] = 0xff & hi, hi >>= 8, set[1] = 0xff & hi, writer.push(set);
|
|
945
930
|
} else throw Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`);
|
|
946
931
|
}
|
|
947
932
|
}
|
|
948
|
-
function encodeNegint(
|
|
933
|
+
function encodeNegint(writer, token) {
|
|
949
934
|
let negint = token.value;
|
|
950
|
-
encodeUintValue(
|
|
935
|
+
encodeUintValue(writer, token.type.majorEncoded, 'bigint' == typeof negint ? negint * neg1b - pos1b : -1 * negint - 1);
|
|
951
936
|
}
|
|
952
937
|
function toToken(data, pos, prefix, length) {
|
|
953
938
|
assertEnoughData(data, pos, prefix + length);
|
|
954
|
-
let buf =
|
|
939
|
+
let buf = data.slice(pos + prefix, pos + prefix + length);
|
|
955
940
|
return new Token(Type.bytes, buf, prefix + length);
|
|
956
941
|
}
|
|
957
942
|
function decodeBytesCompact(data, pos, minor) {
|
|
958
943
|
return toToken(data, pos, 1, minor);
|
|
959
944
|
}
|
|
960
945
|
function tokenBytes(token) {
|
|
961
|
-
return void 0 === token.encodedBytes && (token.encodedBytes = token.type
|
|
946
|
+
return void 0 === token.encodedBytes && (token.encodedBytes = Type.equals(token.type, Type.string) ? byte_utils_fromString(token.value) : token.value), token.encodedBytes;
|
|
962
947
|
}
|
|
963
|
-
function encodeBytes(
|
|
948
|
+
function encodeBytes(writer, token) {
|
|
964
949
|
let bytes = tokenBytes(token);
|
|
965
|
-
encodeUintValue(
|
|
950
|
+
encodeUintValue(writer, token.type.majorEncoded, bytes.length), writer.push(bytes);
|
|
966
951
|
}
|
|
967
952
|
function _3string_toToken(data, pos, prefix, length, options) {
|
|
968
953
|
let totLength = prefix + length;
|
|
969
954
|
assertEnoughData(data, pos, totLength);
|
|
970
|
-
let tok = new Token(Type.string,
|
|
971
|
-
|
|
955
|
+
let tok = new Token(Type.string, function(bytes, start, end) {
|
|
956
|
+
if (end - start < ASCII_THRESHOLD) {
|
|
957
|
+
let str = '';
|
|
958
|
+
for(let i = start; i < end; i++){
|
|
959
|
+
let c = bytes[i];
|
|
960
|
+
if (0x80 & c) return textDecoder.decode(bytes.subarray(start, end));
|
|
961
|
+
str += String.fromCharCode(c);
|
|
962
|
+
}
|
|
963
|
+
return str;
|
|
964
|
+
}
|
|
965
|
+
return textDecoder.decode(bytes.subarray(start, end));
|
|
966
|
+
}(data, pos + prefix, pos + totLength), totLength);
|
|
967
|
+
return !0 === options.retainStringBytes && (tok.byteValue = data.slice(pos + prefix, pos + totLength)), tok;
|
|
972
968
|
}
|
|
973
969
|
function decodeStringCompact(data, pos, minor, options) {
|
|
974
970
|
return _3string_toToken(data, pos, 1, minor, options);
|
|
@@ -979,8 +975,8 @@ function _4array_toToken(_data, _pos, prefix, length) {
|
|
|
979
975
|
function decodeArrayCompact(data, pos, minor) {
|
|
980
976
|
return _4array_toToken(data, pos, 1, minor);
|
|
981
977
|
}
|
|
982
|
-
function encodeArray(
|
|
983
|
-
encodeUintValue(
|
|
978
|
+
function encodeArray(writer, token) {
|
|
979
|
+
encodeUintValue(writer, Type.array.majorEncoded, token.value);
|
|
984
980
|
}
|
|
985
981
|
function _5map_toToken(_data, _pos, prefix, length) {
|
|
986
982
|
return new Token(Type.map, length, prefix);
|
|
@@ -988,14 +984,14 @@ function _5map_toToken(_data, _pos, prefix, length) {
|
|
|
988
984
|
function decodeMapCompact(data, pos, minor) {
|
|
989
985
|
return _5map_toToken(data, pos, 1, minor);
|
|
990
986
|
}
|
|
991
|
-
function encodeMap(
|
|
992
|
-
encodeUintValue(
|
|
987
|
+
function encodeMap(writer, token) {
|
|
988
|
+
encodeUintValue(writer, Type.map.majorEncoded, token.value);
|
|
993
989
|
}
|
|
994
990
|
function decodeTagCompact(_data, _pos, minor) {
|
|
995
991
|
return new Token(Type.tag, minor, 1);
|
|
996
992
|
}
|
|
997
|
-
function encodeTag(
|
|
998
|
-
encodeUintValue(
|
|
993
|
+
function encodeTag(writer, token) {
|
|
994
|
+
encodeUintValue(writer, Type.tag.majorEncoded, token.value);
|
|
999
995
|
}
|
|
1000
996
|
function createToken(value, bytes, options) {
|
|
1001
997
|
if (options) {
|
|
@@ -1004,24 +1000,24 @@ function createToken(value, bytes, options) {
|
|
|
1004
1000
|
}
|
|
1005
1001
|
return new Token(Type.float, value, bytes);
|
|
1006
1002
|
}
|
|
1007
|
-
function encodeFloat(
|
|
1003
|
+
function encodeFloat(writer, token, options) {
|
|
1008
1004
|
let float = token.value;
|
|
1009
|
-
if (!1 === float)
|
|
1005
|
+
if (!1 === float) writer.push([
|
|
1010
1006
|
Type.float.majorEncoded | MINOR_FALSE
|
|
1011
1007
|
]);
|
|
1012
|
-
else if (!0 === float)
|
|
1008
|
+
else if (!0 === float) writer.push([
|
|
1013
1009
|
Type.float.majorEncoded | MINOR_TRUE
|
|
1014
1010
|
]);
|
|
1015
|
-
else if (null === float)
|
|
1011
|
+
else if (null === float) writer.push([
|
|
1016
1012
|
Type.float.majorEncoded | MINOR_NULL
|
|
1017
1013
|
]);
|
|
1018
|
-
else if (void 0 === float)
|
|
1014
|
+
else if (void 0 === float) writer.push([
|
|
1019
1015
|
Type.float.majorEncoded | MINOR_UNDEFINED
|
|
1020
1016
|
]);
|
|
1021
1017
|
else {
|
|
1022
1018
|
var inp;
|
|
1023
1019
|
let success = !1;
|
|
1024
|
-
options && !0 === options.float64 || (encodeFloat16(float), float === readFloat16(_7float_ui8a, 1) || Number.isNaN(float) ? (_7float_ui8a[0] = 0xf9,
|
|
1020
|
+
options && !0 === options.float64 || (encodeFloat16(float), float === readFloat16(_7float_ui8a, 1) || Number.isNaN(float) ? (_7float_ui8a[0] = 0xf9, writer.push(_7float_ui8a.slice(0, 3)), success = !0) : (encodeFloat32(float), float === readFloat32(_7float_ui8a, 1) && (_7float_ui8a[0] = 0xfa, writer.push(_7float_ui8a.slice(0, 5)), success = !0))), success || (inp = float, _7float_dataView.setFloat64(0, inp, !1), readFloat64(_7float_ui8a, 1), _7float_ui8a[0] = 0xfb, writer.push(_7float_ui8a.slice(0, 9)));
|
|
1025
1021
|
}
|
|
1026
1022
|
}
|
|
1027
1023
|
function encodeFloat16(inp) {
|
|
@@ -1120,22 +1116,7 @@ function makeCborEncoders() {
|
|
|
1120
1116
|
return encoders[Type.uint.major] = encodeUint, encoders[Type.negint.major] = encodeNegint, encoders[Type.bytes.major] = encodeBytes, encoders[Type.string.major] = encodeString, encoders[Type.array.major] = encodeArray, encoders[Type.map.major] = encodeMap, encoders[Type.tag.major] = encodeTag, encoders[Type.float.major] = encodeFloat, encoders;
|
|
1121
1117
|
}
|
|
1122
1118
|
function encode_objectToTokens(obj, options = {}, refStack) {
|
|
1123
|
-
let typ =
|
|
1124
|
-
var value1;
|
|
1125
|
-
if (null === value) return 'null';
|
|
1126
|
-
if (void 0 === value) return 'undefined';
|
|
1127
|
-
if (!0 === value || !1 === value) return 'boolean';
|
|
1128
|
-
let typeOf = typeof value;
|
|
1129
|
-
if (typeofs.includes(typeOf)) return typeOf;
|
|
1130
|
-
if ('function' === typeOf) return 'Function';
|
|
1131
|
-
if (Array.isArray(value)) return 'Array';
|
|
1132
|
-
if ((value1 = value) && value1.constructor && value1.constructor.isBuffer && value1.constructor.isBuffer.call(null, value1)) return 'Buffer';
|
|
1133
|
-
let objectType = function(value) {
|
|
1134
|
-
let objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
|
|
1135
|
-
if (objectTypeNames.includes(objectTypeName)) return objectTypeName;
|
|
1136
|
-
}(value);
|
|
1137
|
-
return objectType || 'Object';
|
|
1138
|
-
}(obj), customTypeEncoder = options && options.typeEncoders && options.typeEncoders[typ] || typeEncoders[typ];
|
|
1119
|
+
let typ = is_is(obj), customTypeEncoder = options && options.typeEncoders && options.typeEncoders[typ] || typeEncoders[typ];
|
|
1139
1120
|
if ('function' == typeof customTypeEncoder) {
|
|
1140
1121
|
let tokens = customTypeEncoder(obj, typ, options, refStack);
|
|
1141
1122
|
if (null != tokens) return tokens;
|
|
@@ -1144,35 +1125,91 @@ function encode_objectToTokens(obj, options = {}, refStack) {
|
|
|
1144
1125
|
if (!typeEncoder) throw Error(`${encodeErrPrefix} unsupported type: ${typ}`);
|
|
1145
1126
|
return typeEncoder(obj, typ, options, refStack);
|
|
1146
1127
|
}
|
|
1147
|
-
function
|
|
1148
|
-
|
|
1128
|
+
function tokensToEncoded(writer, tokens, encoders, options) {
|
|
1129
|
+
if (Array.isArray(tokens)) for (let token of tokens)tokensToEncoded(writer, token, encoders, options);
|
|
1130
|
+
else encoders[tokens.type.major](writer, tokens, options);
|
|
1131
|
+
}
|
|
1132
|
+
function encodeCustom(data, encoders, options, destination) {
|
|
1133
|
+
let hasDest = destination instanceof Uint8Array, writeTo = hasDest ? new bl_U8Bl(destination) : defaultWriter, tokens = encode_objectToTokens(data, options);
|
|
1149
1134
|
if (!Array.isArray(tokens) && options.quickEncodeToken) {
|
|
1150
1135
|
let quickBytes = options.quickEncodeToken(tokens);
|
|
1151
|
-
if (quickBytes) return quickBytes;
|
|
1136
|
+
if (quickBytes) return hasDest ? (writeTo.push(quickBytes), writeTo.toBytes()) : quickBytes;
|
|
1152
1137
|
let encoder = encoders[tokens.type.major];
|
|
1153
1138
|
if (encoder.encodedSize) {
|
|
1154
|
-
let
|
|
1155
|
-
if (encoder(
|
|
1156
|
-
return asU8A(
|
|
1139
|
+
let size = encoder.encodedSize(tokens, options);
|
|
1140
|
+
if (hasDest || (writeTo = new bl_Bl(size)), encoder(writeTo, tokens, options), 1 !== writeTo.chunks.length) throw Error(`Unexpected error: pre-calculated length for ${tokens} was wrong`);
|
|
1141
|
+
return hasDest ? writeTo.toBytes() : asU8A(writeTo.chunks[0]);
|
|
1157
1142
|
}
|
|
1158
1143
|
}
|
|
1159
|
-
return
|
|
1160
|
-
if (Array.isArray(tokens)) for (let token of tokens)tokensToEncoded(buf, token, encoders, options);
|
|
1161
|
-
else encoders[tokens.type.major](buf, tokens, options);
|
|
1162
|
-
}(encode_buf, tokens, encoders, options), encode_buf.toBytes(!0);
|
|
1144
|
+
return writeTo.reset(), tokensToEncoded(writeTo, tokens, encoders, options), writeTo.toBytes(!0);
|
|
1163
1145
|
}
|
|
1164
1146
|
function encode_encode(data, options) {
|
|
1165
|
-
return
|
|
1147
|
+
return !0 !== (options = Object.assign({}, defaultEncodeOptions, options)).addBreakTokens ? (defaultWriter.reset(), !function directEncode(writer, data, options, refStack) {
|
|
1148
|
+
let typ = is_is(data), customEncoder = options.typeEncoders && options.typeEncoders[typ];
|
|
1149
|
+
if (customEncoder) {
|
|
1150
|
+
let tokens = customEncoder(data, typ, options, refStack);
|
|
1151
|
+
if (null != tokens) return void tokensToEncoded(writer, tokens, cborEncoders, options);
|
|
1152
|
+
}
|
|
1153
|
+
switch(typ){
|
|
1154
|
+
case 'null':
|
|
1155
|
+
writer.push([
|
|
1156
|
+
SIMPLE_NULL
|
|
1157
|
+
]);
|
|
1158
|
+
return;
|
|
1159
|
+
case 'undefined':
|
|
1160
|
+
writer.push([
|
|
1161
|
+
SIMPLE_UNDEFINED
|
|
1162
|
+
]);
|
|
1163
|
+
return;
|
|
1164
|
+
case 'boolean':
|
|
1165
|
+
writer.push([
|
|
1166
|
+
data ? SIMPLE_TRUE : SIMPLE_FALSE
|
|
1167
|
+
]);
|
|
1168
|
+
return;
|
|
1169
|
+
case 'number':
|
|
1170
|
+
Number.isInteger(data) && Number.isSafeInteger(data) ? data >= 0 ? encodeUintValue(writer, MAJOR_UINT, data) : encodeUintValue(writer, MAJOR_NEGINT, -1 * data - 1) : encodeFloat(writer, new Token(Type.float, data), options);
|
|
1171
|
+
return;
|
|
1172
|
+
case 'bigint':
|
|
1173
|
+
data >= BigInt(0) ? encodeUintValue(writer, MAJOR_UINT, data) : encodeUintValue(writer, MAJOR_NEGINT, data * encode_neg1b - encode_pos1b);
|
|
1174
|
+
return;
|
|
1175
|
+
case 'string':
|
|
1176
|
+
{
|
|
1177
|
+
let bytes = byte_utils_fromString(data);
|
|
1178
|
+
encodeUintValue(writer, MAJOR_STRING, bytes.length), writer.push(bytes);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
case 'Uint8Array':
|
|
1182
|
+
encodeUintValue(writer, MAJOR_BYTES, data.length), writer.push(data);
|
|
1183
|
+
return;
|
|
1184
|
+
case 'Array':
|
|
1185
|
+
if (!data.length) return void writer.push([
|
|
1186
|
+
MAJOR_ARRAY
|
|
1187
|
+
]);
|
|
1188
|
+
for (let elem of (refStack = Ref.createCheck(refStack, data), encodeUintValue(writer, MAJOR_ARRAY, data.length), data))directEncode(writer, elem, options, refStack);
|
|
1189
|
+
return;
|
|
1190
|
+
case 'Object':
|
|
1191
|
+
case 'Map':
|
|
1192
|
+
tokensToEncoded(writer, typeEncoders.Object(data, typ, options, refStack), cborEncoders, options);
|
|
1193
|
+
return;
|
|
1194
|
+
default:
|
|
1195
|
+
{
|
|
1196
|
+
let typeEncoder = typeEncoders[typ];
|
|
1197
|
+
if (!typeEncoder) throw Error(`${encodeErrPrefix} unsupported type: ${typ}`);
|
|
1198
|
+
tokensToEncoded(writer, typeEncoder(data, typ, options, refStack), cborEncoders, options);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}(defaultWriter, data, options, void 0), defaultWriter.toBytes(!0)) : encodeCustom(data, cborEncoders, options);
|
|
1166
1202
|
}
|
|
1167
1203
|
function decode_decode(data, options) {
|
|
1168
1204
|
let [decoded, remainder] = function(data, options) {
|
|
1169
1205
|
if (!(data instanceof Uint8Array)) throw Error(`${decodeErrPrefix} data to decode must be a Uint8Array`);
|
|
1170
|
-
|
|
1206
|
+
options = Object.assign({}, defaultDecodeOptions, options);
|
|
1207
|
+
let u8aData = asU8A(data), tokeniser = options.tokenizer || new Tokeniser(u8aData, options), decoded = function tokensToObject(tokeniser, options) {
|
|
1171
1208
|
if (tokeniser.done()) return DONE;
|
|
1172
1209
|
let token = tokeniser.next();
|
|
1173
|
-
if (token.type
|
|
1210
|
+
if (Type.equals(token.type, Type.break)) return BREAK;
|
|
1174
1211
|
if (token.type.terminal) return token.value;
|
|
1175
|
-
if (token.type
|
|
1212
|
+
if (Type.equals(token.type, Type.array)) {
|
|
1176
1213
|
let arr = [];
|
|
1177
1214
|
for(let i = 0; i < token.value; i++){
|
|
1178
1215
|
let value = tokensToObject(tokeniser, options);
|
|
@@ -1185,8 +1222,8 @@ function decode_decode(data, options) {
|
|
|
1185
1222
|
}
|
|
1186
1223
|
return arr;
|
|
1187
1224
|
}
|
|
1188
|
-
if (token.type
|
|
1189
|
-
let useMaps = !0 === options.useMaps, obj = useMaps ? void 0 : {}, m = useMaps ? new Map() : void 0;
|
|
1225
|
+
if (Type.equals(token.type, Type.map)) return function(token, tokeniser, options) {
|
|
1226
|
+
let useMaps = !0 === options.useMaps, rejectDuplicateMapKeys = !0 === options.rejectDuplicateMapKeys, obj = useMaps ? void 0 : {}, m = useMaps ? new Map() : void 0;
|
|
1190
1227
|
for(let i = 0; i < token.value; i++){
|
|
1191
1228
|
let key = tokensToObject(tokeniser, options);
|
|
1192
1229
|
if (key === BREAK) {
|
|
@@ -1194,15 +1231,15 @@ function decode_decode(data, options) {
|
|
|
1194
1231
|
throw Error(`${decodeErrPrefix} got unexpected break to lengthed map`);
|
|
1195
1232
|
}
|
|
1196
1233
|
if (key === DONE) throw Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`);
|
|
1197
|
-
if (!
|
|
1198
|
-
if (
|
|
1234
|
+
if (!useMaps && 'string' != typeof key) throw Error(`${decodeErrPrefix} non-string keys not supported (got ${typeof key})`);
|
|
1235
|
+
if (rejectDuplicateMapKeys && (useMaps && m.has(key) || !useMaps && Object.hasOwn(obj, key))) throw Error(`${decodeErrPrefix} found repeat map key "${key}"`);
|
|
1199
1236
|
let value = tokensToObject(tokeniser, options);
|
|
1200
1237
|
if (value === DONE) throw Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`);
|
|
1201
1238
|
useMaps ? m.set(key, value) : obj[key] = value;
|
|
1202
1239
|
}
|
|
1203
1240
|
return useMaps ? m : obj;
|
|
1204
1241
|
}(token, tokeniser, options);
|
|
1205
|
-
if (token.type
|
|
1242
|
+
if (Type.equals(token.type, Type.tag)) {
|
|
1206
1243
|
if (options.tags && 'function' == typeof options.tags[token.value]) {
|
|
1207
1244
|
let tagged = tokensToObject(tokeniser, options);
|
|
1208
1245
|
return options.tags[token.value](tagged);
|
|
@@ -8553,21 +8590,7 @@ class digest_Digest {
|
|
|
8553
8590
|
let node_digest = (payload)=>{
|
|
8554
8591
|
let digest = new Uint8Array(digest_prefix.length + 32);
|
|
8555
8592
|
return digest.set(digest_prefix, 0), digest.set(__rspack_external_node_crypto_9ba42079.default.createHash('sha256').update(payload).digest(), digest_prefix.length), new digest_Digest(digest);
|
|
8556
|
-
}, sha256_code = 18,
|
|
8557
|
-
'string',
|
|
8558
|
-
'number',
|
|
8559
|
-
'bigint',
|
|
8560
|
-
'symbol'
|
|
8561
|
-
], objectTypeNames = [
|
|
8562
|
-
'Function',
|
|
8563
|
-
'Generator',
|
|
8564
|
-
'AsyncGenerator',
|
|
8565
|
-
'GeneratorFunction',
|
|
8566
|
-
'AsyncGeneratorFunction',
|
|
8567
|
-
'AsyncFunction',
|
|
8568
|
-
'Observable',
|
|
8569
|
-
'Array',
|
|
8570
|
-
'Buffer',
|
|
8593
|
+
}, sha256_code = 18, objectTypeNames = [
|
|
8571
8594
|
'Object',
|
|
8572
8595
|
'RegExp',
|
|
8573
8596
|
'Date',
|
|
@@ -8583,7 +8606,6 @@ let node_digest = (payload)=>{
|
|
|
8583
8606
|
'URL',
|
|
8584
8607
|
'HTMLElement',
|
|
8585
8608
|
'Int8Array',
|
|
8586
|
-
'Uint8Array',
|
|
8587
8609
|
'Uint8ClampedArray',
|
|
8588
8610
|
'Int16Array',
|
|
8589
8611
|
'Uint16Array',
|
|
@@ -8604,6 +8626,9 @@ class Type {
|
|
|
8604
8626
|
compare(typ) {
|
|
8605
8627
|
return this.major < typ.major ? -1 : +(this.major > typ.major);
|
|
8606
8628
|
}
|
|
8629
|
+
static equals(a, b) {
|
|
8630
|
+
return a === b || a.major === b.major && a.name === b.name;
|
|
8631
|
+
}
|
|
8607
8632
|
}
|
|
8608
8633
|
Type.uint = new Type(0, 'uint', !0), Type.negint = new Type(1, 'negint', !0), Type.bytes = new Type(2, 'bytes', !0), Type.string = new Type(3, 'string', !0), Type.array = new Type(4, 'array', !1), Type.map = new Type(5, 'map', !1), Type.tag = new Type(6, 'tag', !1), Type.float = new Type(7, 'float', !0), Type.false = new Type(7, 'false', !0), Type.true = new Type(7, 'true', !0), Type.null = new Type(7, 'null', !0), Type.undefined = new Type(7, 'undefined', !0), Type.break = new Type(7, 'break', !0);
|
|
8609
8634
|
class Token {
|
|
@@ -8614,11 +8639,11 @@ class Token {
|
|
|
8614
8639
|
return `Token[${this.type}].${this.value}`;
|
|
8615
8640
|
}
|
|
8616
8641
|
}
|
|
8617
|
-
let useBuffer = globalThis.process && !globalThis.process.browser && globalThis.Buffer && 'function' == typeof globalThis.Buffer.isBuffer,
|
|
8642
|
+
let useBuffer = globalThis.process && !globalThis.process.browser && globalThis.Buffer && 'function' == typeof globalThis.Buffer.isBuffer, textEncoder = new TextEncoder(), byte_utils_fromString = useBuffer ? (string)=>string.length >= 24 ? globalThis.Buffer.from(string) : byte_utils_utf8ToBytes(string) : (string)=>string.length >= 200 ? textEncoder.encode(string) : byte_utils_utf8ToBytes(string), byte_utils_fromArray = (arr)=>Uint8Array.from(arr), byte_utils_slice = useBuffer ? (bytes, start, end)=>isBuffer(bytes) ? new Uint8Array(bytes.subarray(start, end)) : bytes.slice(start, end) : (bytes, start, end)=>bytes.slice(start, end), byte_utils_concat = useBuffer ? (chunks, length)=>(chunks = chunks.map((c)=>c instanceof Uint8Array ? c : globalThis.Buffer.from(c)), asU8A(globalThis.Buffer.concat(chunks, length))) : (chunks, length)=>{
|
|
8618
8643
|
let out = new Uint8Array(length), off = 0;
|
|
8619
8644
|
for (let b of chunks)off + b.length > out.length && (b = b.subarray(0, out.length - off)), out.set(b, off), off += b.length;
|
|
8620
8645
|
return out;
|
|
8621
|
-
}, alloc = useBuffer ? (size)=>globalThis.Buffer.allocUnsafe(size) : (size)=>new Uint8Array(size)
|
|
8646
|
+
}, alloc = useBuffer ? (size)=>globalThis.Buffer.allocUnsafe(size) : (size)=>new Uint8Array(size);
|
|
8622
8647
|
class bl_Bl {
|
|
8623
8648
|
constructor(chunkSize = 256){
|
|
8624
8649
|
this.chunkSize = chunkSize, this.cursor = 0, this.maxCursor = -1, this.chunks = [], this._initReuseChunk = null;
|
|
@@ -8649,6 +8674,24 @@ class bl_Bl {
|
|
|
8649
8674
|
return reset && this.reset(), byts;
|
|
8650
8675
|
}
|
|
8651
8676
|
}
|
|
8677
|
+
class bl_U8Bl {
|
|
8678
|
+
constructor(dest){
|
|
8679
|
+
this.dest = dest, this.cursor = 0, this.chunks = [
|
|
8680
|
+
dest
|
|
8681
|
+
];
|
|
8682
|
+
}
|
|
8683
|
+
reset() {
|
|
8684
|
+
this.cursor = 0;
|
|
8685
|
+
}
|
|
8686
|
+
push(bytes) {
|
|
8687
|
+
if (this.cursor + bytes.length > this.dest.length) throw Error('write out of bounds, destination buffer is too small');
|
|
8688
|
+
this.dest.set(bytes, this.cursor), this.cursor += bytes.length;
|
|
8689
|
+
}
|
|
8690
|
+
toBytes(reset = !1) {
|
|
8691
|
+
let byts = this.dest.subarray(0, this.cursor);
|
|
8692
|
+
return reset && this.reset(), byts;
|
|
8693
|
+
}
|
|
8694
|
+
}
|
|
8652
8695
|
let decodeErrPrefix = 'CBOR decode error:', encodeErrPrefix = 'CBOR encode error:', uintMinorPrefixBytes = [];
|
|
8653
8696
|
uintMinorPrefixBytes[23] = 1, uintMinorPrefixBytes[24] = 2, uintMinorPrefixBytes[25] = 3, uintMinorPrefixBytes[26] = 5, uintMinorPrefixBytes[27] = 9;
|
|
8654
8697
|
let uintBoundaries = [
|
|
@@ -8678,7 +8721,7 @@ encodeNegint.encodedSize = function(token) {
|
|
|
8678
8721
|
var b1, b2;
|
|
8679
8722
|
return b1 = tokenBytes(tok1), b2 = tokenBytes(tok2), b1.length < b2.length ? -1 : b1.length > b2.length ? 1 : compare(b1, b2);
|
|
8680
8723
|
};
|
|
8681
|
-
let encodeString = encodeBytes;
|
|
8724
|
+
let textDecoder = new TextDecoder(), ASCII_THRESHOLD = 32, encodeString = encodeBytes;
|
|
8682
8725
|
encodeArray.compareTokens = encodeUint.compareTokens, encodeArray.encodedSize = function(token) {
|
|
8683
8726
|
return encodeUintValue.encodedSize(token.value);
|
|
8684
8727
|
}, encodeMap.compareTokens = encodeUint.compareTokens, encodeMap.encodedSize = function(token) {
|
|
@@ -8828,7 +8871,7 @@ let defaultEncodeOptions = {
|
|
|
8828
8871
|
throw Error('rfc8949MapSorter: complex key types are not supported yet');
|
|
8829
8872
|
},
|
|
8830
8873
|
quickEncodeToken: quickEncodeToken
|
|
8831
|
-
}), cborEncoders = makeCborEncoders(),
|
|
8874
|
+
}), cborEncoders = makeCborEncoders(), defaultWriter = new bl_Bl();
|
|
8832
8875
|
class Ref {
|
|
8833
8876
|
constructor(obj, parent){
|
|
8834
8877
|
this.obj = obj, this.parent = parent;
|
|
@@ -8879,29 +8922,35 @@ let simpleTokens = {
|
|
|
8879
8922
|
];
|
|
8880
8923
|
},
|
|
8881
8924
|
Object (obj, typ, options, refStack) {
|
|
8882
|
-
|
|
8883
|
-
|
|
8925
|
+
var entries;
|
|
8926
|
+
let entries1, isMap = 'Object' !== typ, keys = isMap ? obj.keys() : Object.keys(obj), maxLength = isMap ? obj.size : keys.length;
|
|
8927
|
+
if (maxLength) {
|
|
8928
|
+
entries1 = Array(maxLength), refStack = Ref.createCheck(refStack, obj);
|
|
8929
|
+
let skipUndefined = !isMap && options.ignoreUndefinedProperties, i = 0;
|
|
8930
|
+
for (let key of keys){
|
|
8931
|
+
let value = isMap ? obj.get(key) : obj[key];
|
|
8932
|
+
skipUndefined && void 0 === value || (entries1[i++] = [
|
|
8933
|
+
encode_objectToTokens(key, options, refStack),
|
|
8934
|
+
encode_objectToTokens(value, options, refStack)
|
|
8935
|
+
]);
|
|
8936
|
+
}
|
|
8937
|
+
i < maxLength && (entries1.length = i);
|
|
8938
|
+
}
|
|
8939
|
+
return entries1?.length ? (entries = entries1, options.mapSorter && entries.sort(options.mapSorter), options.addBreakTokens) ? [
|
|
8940
|
+
new Token(Type.map, entries1.length),
|
|
8941
|
+
entries1,
|
|
8942
|
+
new Token(Type.break)
|
|
8943
|
+
] : [
|
|
8944
|
+
new Token(Type.map, entries1.length),
|
|
8945
|
+
entries1
|
|
8946
|
+
] : !0 === options.addBreakTokens ? [
|
|
8884
8947
|
simpleTokens.emptyMap,
|
|
8885
8948
|
new Token(Type.break)
|
|
8886
8949
|
] : simpleTokens.emptyMap;
|
|
8887
|
-
refStack = Ref.createCheck(refStack, obj);
|
|
8888
|
-
let entries = [], i = 0;
|
|
8889
|
-
for (let key of keys)entries[i++] = [
|
|
8890
|
-
encode_objectToTokens(key, options, refStack),
|
|
8891
|
-
encode_objectToTokens(isMap ? obj.get(key) : obj[key], options, refStack)
|
|
8892
|
-
];
|
|
8893
|
-
return (options.mapSorter && entries.sort(options.mapSorter), options.addBreakTokens) ? [
|
|
8894
|
-
new Token(Type.map, length),
|
|
8895
|
-
entries,
|
|
8896
|
-
new Token(Type.break)
|
|
8897
|
-
] : [
|
|
8898
|
-
new Token(Type.map, length),
|
|
8899
|
-
entries
|
|
8900
|
-
];
|
|
8901
8950
|
}
|
|
8902
8951
|
};
|
|
8903
8952
|
for (let typ of (typeEncoders.Map = typeEncoders.Object, typeEncoders.Buffer = typeEncoders.Uint8Array, 'Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64'.split(' ')))typeEncoders[`${typ}Array`] = typeEncoders.DataView;
|
|
8904
|
-
let defaultDecodeOptions = {
|
|
8953
|
+
let MAJOR_UINT = Type.uint.majorEncoded, MAJOR_NEGINT = Type.negint.majorEncoded, MAJOR_BYTES = Type.bytes.majorEncoded, MAJOR_STRING = Type.string.majorEncoded, MAJOR_ARRAY = Type.array.majorEncoded, SIMPLE_FALSE = Type.float.majorEncoded | MINOR_FALSE, SIMPLE_TRUE = Type.float.majorEncoded | MINOR_TRUE, SIMPLE_NULL = Type.float.majorEncoded | MINOR_NULL, SIMPLE_UNDEFINED = Type.float.majorEncoded | MINOR_UNDEFINED, encode_neg1b = BigInt(-1), encode_pos1b = BigInt(1), defaultDecodeOptions = {
|
|
8905
8954
|
strict: !1,
|
|
8906
8955
|
allowIndefinite: !0,
|
|
8907
8956
|
allowUndefined: !0,
|
|
@@ -10239,7 +10288,7 @@ let filecoinMainnet = {
|
|
|
10239
10288
|
address: '0xf55dDbf63F1b55c3F1D4FA7e339a68AB7b64A5eB'
|
|
10240
10289
|
},
|
|
10241
10290
|
storageView: {
|
|
10242
|
-
address: '
|
|
10291
|
+
address: '0x638a4986332bF9B889E5D7435B966C5ecdE077Fa'
|
|
10243
10292
|
}
|
|
10244
10293
|
},
|
|
10245
10294
|
blockExplorer: 'https://filecoin.blockscout.com'
|
|
@@ -10263,7 +10312,7 @@ let filecoinMainnet = {
|
|
|
10263
10312
|
address: '0x839e5c9988e4e9977d40708d0094103c0839Ac9D'
|
|
10264
10313
|
},
|
|
10265
10314
|
storageView: {
|
|
10266
|
-
address: '
|
|
10315
|
+
address: '0x53d235D474585EC102ccaB7e0cdcE951dD00f716'
|
|
10267
10316
|
}
|
|
10268
10317
|
},
|
|
10269
10318
|
blockExplorer: 'https://filecoin-testnet.blockscout.com'
|
|
@@ -12697,8 +12746,24 @@ let serializedType = '0x02', TxEnvelopeEip1559_type = 'eip1559', estimateGas = a
|
|
|
12697
12746
|
return logger.info(`Pending piece upload: ${statusUrl}`), logger.info(`Pending transaction: ${chain.blockExplorer}/tx/${hash}`), await waitForTransaction(filProvider[chainId], hash), {
|
|
12698
12747
|
cid
|
|
12699
12748
|
};
|
|
12700
|
-
}, lighthouse_providerName = 'Lighthouse',
|
|
12701
|
-
if (first)
|
|
12749
|
+
}, lighthouse_providerName = 'Lighthouse', uploadOnLighthouse = async ({ car, name, first, token, verbose, cid })=>{
|
|
12750
|
+
if (first) {
|
|
12751
|
+
let fd = new FormData();
|
|
12752
|
+
fd.append('file', car, `${name}.car`);
|
|
12753
|
+
let res = await fetch('https://upload.lighthouse.storage/api/v0/dag/import', {
|
|
12754
|
+
method: 'POST',
|
|
12755
|
+
headers: {
|
|
12756
|
+
Authorization: `Bearer ${token}`
|
|
12757
|
+
},
|
|
12758
|
+
body: fd
|
|
12759
|
+
});
|
|
12760
|
+
verbose && logger.request('POST', res.url, res.status);
|
|
12761
|
+
let json = await res.json();
|
|
12762
|
+
if (!res.ok) throw new DeployError(lighthouse_providerName, json.error?.message || json.message || 'Unknown error');
|
|
12763
|
+
return {
|
|
12764
|
+
cid: json.data?.Hash || cid
|
|
12765
|
+
};
|
|
12766
|
+
}
|
|
12702
12767
|
let res = await fetch('https://api.lighthouse.storage/api/lighthouse/pin', {
|
|
12703
12768
|
method: 'POST',
|
|
12704
12769
|
headers: {
|
|
@@ -13481,9 +13546,9 @@ class JSONEncoder extends Array {
|
|
|
13481
13546
|
}
|
|
13482
13547
|
prefix(buf) {
|
|
13483
13548
|
let recurs = this.inRecursive[this.inRecursive.length - 1];
|
|
13484
|
-
recurs && (recurs.type
|
|
13549
|
+
recurs && (Type.equals(recurs.type, Type.array) && (recurs.elements++, 1 !== recurs.elements && buf.push([
|
|
13485
13550
|
44
|
|
13486
|
-
])), recurs.type
|
|
13551
|
+
])), Type.equals(recurs.type, Type.map) && (recurs.elements++, 1 !== recurs.elements && (recurs.elements % 2 == 1 ? buf.push([
|
|
13487
13552
|
44
|
|
13488
13553
|
]) : buf.push([
|
|
13489
13554
|
58
|
|
@@ -13527,10 +13592,10 @@ class JSONEncoder extends Array {
|
|
|
13527
13592
|
if ('break' === token.type.name) {
|
|
13528
13593
|
let recurs = this.inRecursive.pop();
|
|
13529
13594
|
if (recurs) {
|
|
13530
|
-
if (recurs.type
|
|
13595
|
+
if (Type.equals(recurs.type, Type.array)) buf.push([
|
|
13531
13596
|
93
|
|
13532
13597
|
]);
|
|
13533
|
-
else if (recurs.type
|
|
13598
|
+
else if (Type.equals(recurs.type, Type.map)) buf.push([
|
|
13534
13599
|
125
|
|
13535
13600
|
]);
|
|
13536
13601
|
else throw Error('Unexpected recursive type; this should not happen!');
|
|
@@ -13730,7 +13795,13 @@ class Tokenizer {
|
|
|
13730
13795
|
}
|
|
13731
13796
|
break;
|
|
13732
13797
|
case 34:
|
|
13733
|
-
return this._pos++, new Token(Type.string,
|
|
13798
|
+
return this._pos++, new Token(Type.string, function(codePoints) {
|
|
13799
|
+
let len = codePoints.length;
|
|
13800
|
+
if (len <= 0x1000) return String.fromCharCode.apply(String, codePoints);
|
|
13801
|
+
let res = '', i = 0;
|
|
13802
|
+
for(; i < len;)res += String.fromCharCode.apply(String, codePoints.slice(i, i += 0x1000));
|
|
13803
|
+
return res;
|
|
13804
|
+
}(chars), this._pos - startPos);
|
|
13734
13805
|
default:
|
|
13735
13806
|
if (ch < 32) throw Error(`${decodeErrPrefix} invalid control character at position ${this._pos}`);
|
|
13736
13807
|
ch < 0x80 ? (chars.push(ch), this._pos++) : readUtf8Char();
|
|
@@ -13865,20 +13936,24 @@ class DagJsonTokenizer extends Tokenizer {
|
|
|
13865
13936
|
}
|
|
13866
13937
|
next() {
|
|
13867
13938
|
let token = this._next();
|
|
13868
|
-
if (token.type
|
|
13939
|
+
if (Type.equals(token.type, Type.map)) {
|
|
13869
13940
|
let keyToken = this._next();
|
|
13870
|
-
if (keyToken.type
|
|
13941
|
+
if (Type.equals(keyToken.type, Type.string) && '/' === keyToken.value) {
|
|
13871
13942
|
let valueToken = this._next();
|
|
13872
|
-
if (valueToken.type
|
|
13873
|
-
|
|
13943
|
+
if (Type.equals(valueToken.type, Type.string)) {
|
|
13944
|
+
let breakToken = this._next();
|
|
13945
|
+
if (!Type.equals(breakToken.type, Type.break)) throw Error('Invalid encoded CID form');
|
|
13874
13946
|
return this.tokenBuffer.push(valueToken), new Token(Type.tag, 42, 0);
|
|
13875
13947
|
}
|
|
13876
|
-
if (valueToken.type
|
|
13948
|
+
if (Type.equals(valueToken.type, Type.map)) {
|
|
13877
13949
|
let innerKeyToken = this._next();
|
|
13878
|
-
if (innerKeyToken.type
|
|
13950
|
+
if (Type.equals(innerKeyToken.type, Type.string) && 'bytes' === innerKeyToken.value) {
|
|
13879
13951
|
let innerValueToken = this._next();
|
|
13880
|
-
if (innerValueToken.type
|
|
13881
|
-
for(let i = 0; i < 2; i++)
|
|
13952
|
+
if (Type.equals(innerValueToken.type, Type.string)) {
|
|
13953
|
+
for(let i = 0; i < 2; i++){
|
|
13954
|
+
let breakToken = this._next();
|
|
13955
|
+
if (!Type.equals(breakToken.type, Type.break)) throw Error('Invalid encoded Bytes form');
|
|
13956
|
+
}
|
|
13882
13957
|
let bytes = base64.decode(`m${innerValueToken.value}`);
|
|
13883
13958
|
return new Token(Type.bytes, bytes, innerValueToken.value.length);
|
|
13884
13959
|
}
|
|
@@ -17543,7 +17618,8 @@ let uploadCAR = async (conf, car)=>{
|
|
|
17543
17618
|
}, storacha_abilities = [
|
|
17544
17619
|
'space/blob/add',
|
|
17545
17620
|
'space/index/add',
|
|
17546
|
-
'upload/add'
|
|
17621
|
+
'upload/add',
|
|
17622
|
+
'filecoin/offer'
|
|
17547
17623
|
], referenceToCID = (ref)=>{
|
|
17548
17624
|
var multihash;
|
|
17549
17625
|
let codeOffset, hashOffset, bytes;
|
|
@@ -17626,8 +17702,8 @@ let uploadCAR = async (conf, car)=>{
|
|
|
17626
17702
|
},
|
|
17627
17703
|
LIGHTHOUSE_TOKEN: {
|
|
17628
17704
|
name: 'Lighthouse',
|
|
17629
|
-
upload:
|
|
17630
|
-
supported: '
|
|
17705
|
+
upload: uploadOnLighthouse,
|
|
17706
|
+
supported: 'both',
|
|
17631
17707
|
protocol: 'ipfs'
|
|
17632
17708
|
},
|
|
17633
17709
|
SWARMY_TOKEN: {
|
|
@@ -20930,7 +21006,7 @@ let ENS_DEPLOYER_ROLE = keccak256(Bytes_fromString('ENS_DEPLOYER')), execTransac
|
|
|
20930
21006
|
if (!(attempt < maxRetries)) return logger.error(gwOfflineMessage);
|
|
20931
21007
|
logger.text(`🔄 Retrying in ${retryInterval / 1000} seconds...`), await promises_setTimeout(retryInterval);
|
|
20932
21008
|
} catch (error) {
|
|
20933
|
-
if (error instanceof DOMException && attempt < maxRetries) logger.info(
|
|
21009
|
+
if (error instanceof DOMException && attempt < maxRetries) logger.info("⌛ Timed out. Retrying..."), await promises_setTimeout(retryInterval);
|
|
20934
21010
|
else throw logger.error(error instanceof DOMException ? gwOfflineMessage : `Error fetching endpoint: ${error.message}`), error;
|
|
20935
21011
|
}
|
|
20936
21012
|
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnipin",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "v1rtl <hi@v1rtl.site>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/omnipin/omnipin.git"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@biomejs/biome": "^2.3.
|
|
10
|
+
"@biomejs/biome": "^2.3.13",
|
|
11
11
|
"@ipld/car": "^5.4.2",
|
|
12
12
|
"@ipld/dag-ucan": "^3.4.5",
|
|
13
|
-
"@rslib/core": "^0.19.
|
|
13
|
+
"@rslib/core": "^0.19.4",
|
|
14
14
|
"@size-limit/file": "^11.2.0",
|
|
15
15
|
"@stauro/filebase-upload": "npm:@jsr/stauro__filebase-upload",
|
|
16
16
|
"@storacha/capabilities": "^1.12.0",
|
|
17
|
-
"@types/bun": "^1.3.
|
|
17
|
+
"@types/bun": "^1.3.8",
|
|
18
18
|
"@types/varint": "^6.0.3",
|
|
19
19
|
"@ucanto/client": "^9.0.2",
|
|
20
20
|
"@ucanto/core": "^10.4.6",
|
|
21
21
|
"@ucanto/principal": "^9.0.3",
|
|
22
22
|
"@ucanto/transport": "^9.2.1",
|
|
23
23
|
"@web3-storage/data-segment": "^5.3.0",
|
|
24
|
-
"cborg": "^4.
|
|
24
|
+
"cborg": "^4.5.8",
|
|
25
25
|
"esbuild": "^0.27.2",
|
|
26
26
|
"ipfs-unixfs": "^12.0.0",
|
|
27
27
|
"ipfs-unixfs-importer": "^16.0.2",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
],
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"overrides": {
|
|
58
|
-
"@multiformats/murmur3": "npm:@omnipin/multiformats-murmur3@2.2.0",
|
|
59
58
|
"multiformats": "13.4.2"
|
|
60
59
|
},
|
|
61
60
|
"release": {
|