@bufbuild/protobuf 2.10.2 → 2.12.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/cjs/clone.js +1 -1
- package/dist/cjs/codegenv1/enum.js +1 -1
- package/dist/cjs/codegenv1/extension.js +1 -1
- package/dist/cjs/codegenv1/file.js +1 -1
- package/dist/cjs/codegenv1/index.js +1 -1
- package/dist/cjs/codegenv1/message.js +1 -1
- package/dist/cjs/codegenv1/service.js +1 -1
- package/dist/cjs/codegenv1/symbols.js +1 -1
- package/dist/cjs/codegenv1/types.js +1 -1
- package/dist/cjs/codegenv2/boot.js +1 -1
- package/dist/cjs/codegenv2/embed.js +1 -1
- package/dist/cjs/codegenv2/enum.js +1 -1
- package/dist/cjs/codegenv2/extension.js +1 -1
- package/dist/cjs/codegenv2/file.js +1 -1
- package/dist/cjs/codegenv2/index.js +1 -1
- package/dist/cjs/codegenv2/message.js +1 -1
- package/dist/cjs/codegenv2/restore-json-names.js +1 -1
- package/dist/cjs/codegenv2/scalar.js +1 -1
- package/dist/cjs/codegenv2/service.js +1 -1
- package/dist/cjs/codegenv2/symbols.js +1 -1
- package/dist/cjs/codegenv2/types.js +1 -1
- package/dist/cjs/create.js +1 -1
- package/dist/cjs/descriptors.d.ts +12 -5
- package/dist/cjs/descriptors.js +1 -1
- package/dist/cjs/equals.js +1 -1
- package/dist/cjs/extensions.js +1 -1
- package/dist/cjs/fields.js +1 -1
- package/dist/cjs/from-binary.js +8 -8
- package/dist/cjs/from-json.d.ts +1 -1
- package/dist/cjs/from-json.js +81 -89
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/is-message.js +1 -1
- package/dist/cjs/json-value.js +1 -1
- package/dist/cjs/merge.js +1 -1
- package/dist/cjs/proto-int64.js +1 -1
- package/dist/cjs/reflect/error.js +1 -1
- package/dist/cjs/reflect/guard.js +1 -1
- package/dist/cjs/reflect/index.js +1 -1
- package/dist/cjs/reflect/names.d.ts +11 -0
- package/dist/cjs/reflect/names.js +15 -1
- package/dist/cjs/reflect/nested-types.js +1 -1
- package/dist/cjs/reflect/path.d.ts +1 -1
- package/dist/cjs/reflect/path.js +1 -1
- package/dist/cjs/reflect/reflect-check.js +1 -1
- package/dist/cjs/reflect/reflect-types.js +1 -1
- package/dist/cjs/reflect/reflect.js +1 -1
- package/dist/cjs/reflect/scalar.js +1 -1
- package/dist/cjs/reflect/unsafe.js +1 -1
- package/dist/cjs/registry.js +25 -2
- package/dist/cjs/to-binary.js +1 -1
- package/dist/cjs/to-json.d.ts +1 -1
- package/dist/cjs/to-json.js +12 -15
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/types.js +1 -1
- package/dist/cjs/wire/base64-encoding.js +1 -1
- package/dist/cjs/wire/binary-encoding.d.ts +9 -7
- package/dist/cjs/wire/binary-encoding.js +19 -9
- package/dist/cjs/wire/index.js +1 -1
- package/dist/cjs/wire/size-delimited.js +1 -1
- package/dist/cjs/wire/text-encoding.d.ts +4 -2
- package/dist/cjs/wire/text-encoding.js +9 -2
- package/dist/cjs/wire/text-format.js +1 -1
- package/dist/cjs/wkt/any.js +1 -1
- package/dist/cjs/wkt/duration.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/any_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/api_pb.d.ts +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/api_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +2 -2
- package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/cpp_features_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.d.ts +37 -23
- package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.js +2 -2
- package/dist/cjs/wkt/gen/google/protobuf/duration_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/empty_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/field_mask_pb.d.ts +32 -36
- package/dist/cjs/wkt/gen/google/protobuf/field_mask_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/go_features_pb.d.ts +65 -0
- package/dist/cjs/wkt/gen/google/protobuf/go_features_pb.js +39 -3
- package/dist/cjs/wkt/gen/google/protobuf/java_features_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.d.ts +5 -5
- package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/type_pb.d.ts +3 -3
- package/dist/cjs/wkt/gen/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.js +1 -1
- package/dist/cjs/wkt/index.js +1 -1
- package/dist/cjs/wkt/timestamp.js +1 -1
- package/dist/cjs/wkt/wrappers.d.ts +10 -0
- package/dist/cjs/wkt/wrappers.js +25 -1
- package/dist/esm/clone.js +1 -1
- package/dist/esm/codegenv1/enum.js +1 -1
- package/dist/esm/codegenv1/extension.js +1 -1
- package/dist/esm/codegenv1/file.js +1 -1
- package/dist/esm/codegenv1/index.js +1 -1
- package/dist/esm/codegenv1/message.js +1 -1
- package/dist/esm/codegenv1/service.js +1 -1
- package/dist/esm/codegenv1/symbols.js +1 -1
- package/dist/esm/codegenv1/types.js +1 -1
- package/dist/esm/codegenv2/boot.js +1 -1
- package/dist/esm/codegenv2/embed.js +1 -1
- package/dist/esm/codegenv2/enum.js +1 -1
- package/dist/esm/codegenv2/extension.js +1 -1
- package/dist/esm/codegenv2/file.js +1 -1
- package/dist/esm/codegenv2/index.js +1 -1
- package/dist/esm/codegenv2/message.js +1 -1
- package/dist/esm/codegenv2/restore-json-names.js +1 -1
- package/dist/esm/codegenv2/scalar.js +1 -1
- package/dist/esm/codegenv2/service.js +1 -1
- package/dist/esm/codegenv2/symbols.js +1 -1
- package/dist/esm/codegenv2/types.js +1 -1
- package/dist/esm/create.js +1 -1
- package/dist/esm/descriptors.d.ts +12 -5
- package/dist/esm/descriptors.js +1 -1
- package/dist/esm/equals.js +1 -1
- package/dist/esm/extensions.js +1 -1
- package/dist/esm/fields.js +1 -1
- package/dist/esm/from-binary.js +8 -8
- package/dist/esm/from-json.d.ts +1 -1
- package/dist/esm/from-json.js +82 -90
- package/dist/esm/index.js +1 -1
- package/dist/esm/is-message.js +1 -1
- package/dist/esm/json-value.js +1 -1
- package/dist/esm/merge.js +1 -1
- package/dist/esm/proto-int64.js +1 -1
- package/dist/esm/reflect/error.js +1 -1
- package/dist/esm/reflect/guard.js +1 -1
- package/dist/esm/reflect/index.js +1 -1
- package/dist/esm/reflect/names.d.ts +11 -0
- package/dist/esm/reflect/names.js +14 -1
- package/dist/esm/reflect/nested-types.js +1 -1
- package/dist/esm/reflect/path.d.ts +1 -1
- package/dist/esm/reflect/path.js +1 -1
- package/dist/esm/reflect/reflect-check.js +1 -1
- package/dist/esm/reflect/reflect-types.js +1 -1
- package/dist/esm/reflect/reflect.js +1 -1
- package/dist/esm/reflect/scalar.js +1 -1
- package/dist/esm/reflect/unsafe.js +1 -1
- package/dist/esm/registry.js +25 -2
- package/dist/esm/to-binary.js +1 -1
- package/dist/esm/to-json.d.ts +1 -1
- package/dist/esm/to-json.js +14 -17
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/wire/base64-encoding.js +1 -1
- package/dist/esm/wire/binary-encoding.d.ts +9 -7
- package/dist/esm/wire/binary-encoding.js +19 -9
- package/dist/esm/wire/index.js +1 -1
- package/dist/esm/wire/size-delimited.js +1 -1
- package/dist/esm/wire/text-encoding.d.ts +4 -2
- package/dist/esm/wire/text-encoding.js +9 -2
- package/dist/esm/wire/text-format.js +1 -1
- package/dist/esm/wkt/any.js +1 -1
- package/dist/esm/wkt/duration.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/any_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/api_pb.d.ts +1 -1
- package/dist/esm/wkt/gen/google/protobuf/api_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.d.ts +2 -2
- package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.d.ts +37 -23
- package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +2 -2
- package/dist/esm/wkt/gen/google/protobuf/duration_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/empty_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.d.ts +32 -36
- package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/go_features_pb.d.ts +65 -0
- package/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +38 -2
- package/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.d.ts +5 -5
- package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/type_pb.d.ts +3 -3
- package/dist/esm/wkt/gen/google/protobuf/type_pb.js +1 -1
- package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +1 -1
- package/dist/esm/wkt/index.js +1 -1
- package/dist/esm/wkt/timestamp.js +1 -1
- package/dist/esm/wkt/wrappers.d.ts +10 -0
- package/dist/esm/wkt/wrappers.js +24 -1
- package/package.json +1 -1
package/dist/cjs/merge.js
CHANGED
package/dist/cjs/proto-int64.js
CHANGED
|
@@ -9,8 +9,19 @@ export declare function qualifiedName(desc: AnyDesc): string;
|
|
|
9
9
|
/**
|
|
10
10
|
* Converts snake_case to protoCamelCase according to the convention
|
|
11
11
|
* used by protoc to convert a field name to a JSON name.
|
|
12
|
+
*
|
|
13
|
+
* See https://protobuf.com/docs/language-spec#default-json-names
|
|
14
|
+
*
|
|
15
|
+
* The function protoSnakeCase provides the reverse.
|
|
12
16
|
*/
|
|
13
17
|
export declare function protoCamelCase(snakeCase: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts protoCamelCase to snake_case.
|
|
20
|
+
*
|
|
21
|
+
* This function is the reverse of function protoCamelCase. Note that some names
|
|
22
|
+
* are not reversible - for example, "foo__bar" -> "fooBar" -> "foo_bar".
|
|
23
|
+
*/
|
|
24
|
+
export declare function protoSnakeCase(lowerCamelCase: string): string;
|
|
14
25
|
/**
|
|
15
26
|
* Escapes names that are reserved for ECMAScript built-in object properties.
|
|
16
27
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.qualifiedName = qualifiedName;
|
|
17
17
|
exports.protoCamelCase = protoCamelCase;
|
|
18
|
+
exports.protoSnakeCase = protoSnakeCase;
|
|
18
19
|
exports.safeObjectProperty = safeObjectProperty;
|
|
19
20
|
/**
|
|
20
21
|
* Return a fully-qualified name for a Protobuf descriptor.
|
|
@@ -46,6 +47,10 @@ function qualifiedName(desc) {
|
|
|
46
47
|
/**
|
|
47
48
|
* Converts snake_case to protoCamelCase according to the convention
|
|
48
49
|
* used by protoc to convert a field name to a JSON name.
|
|
50
|
+
*
|
|
51
|
+
* See https://protobuf.com/docs/language-spec#default-json-names
|
|
52
|
+
*
|
|
53
|
+
* The function protoSnakeCase provides the reverse.
|
|
49
54
|
*/
|
|
50
55
|
function protoCamelCase(snakeCase) {
|
|
51
56
|
let capNext = false;
|
|
@@ -80,6 +85,15 @@ function protoCamelCase(snakeCase) {
|
|
|
80
85
|
}
|
|
81
86
|
return b.join("");
|
|
82
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Converts protoCamelCase to snake_case.
|
|
90
|
+
*
|
|
91
|
+
* This function is the reverse of function protoCamelCase. Note that some names
|
|
92
|
+
* are not reversible - for example, "foo__bar" -> "fooBar" -> "foo_bar".
|
|
93
|
+
*/
|
|
94
|
+
function protoSnakeCase(lowerCamelCase) {
|
|
95
|
+
return lowerCamelCase.replace(/[A-Z]/g, (letter) => "_" + letter.toLowerCase());
|
|
96
|
+
}
|
|
83
97
|
/**
|
|
84
98
|
* Names that cannot be used for object properties because they are reserved
|
|
85
99
|
* by built-in JavaScript properties.
|
|
@@ -89,7 +89,7 @@ export declare function buildPath(schema: DescMessage): PathBuilder;
|
|
|
89
89
|
* paths that refer to an extension.
|
|
90
90
|
*/
|
|
91
91
|
export declare function parsePath(schema: DescMessage, path: string, options?: {
|
|
92
|
-
registry?: Registry;
|
|
92
|
+
registry?: Registry | undefined;
|
|
93
93
|
}): Path;
|
|
94
94
|
/**
|
|
95
95
|
* Stringify a path.
|
package/dist/cjs/reflect/path.js
CHANGED
package/dist/cjs/registry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -197,6 +197,8 @@ function initBaseRegistry(inputs) {
|
|
|
197
197
|
const EDITION_PROTO2 = 998;
|
|
198
198
|
// bootstrap-inject google.protobuf.Edition.EDITION_PROTO3: const $name: Edition.$localName = $number;
|
|
199
199
|
const EDITION_PROTO3 = 999;
|
|
200
|
+
// bootstrap-inject google.protobuf.Edition.EDITION_UNSTABLE: const $name: Edition.$localName = $number;
|
|
201
|
+
const EDITION_UNSTABLE = 9999;
|
|
200
202
|
// bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_STRING: const $name: FieldDescriptorProto_Type.$localName = $number;
|
|
201
203
|
const TYPE_STRING = 9;
|
|
202
204
|
// bootstrap-inject google.protobuf.FieldDescriptorProto.Type.TYPE_GROUP: const $name: FieldDescriptorProto_Type.$localName = $number;
|
|
@@ -227,9 +229,11 @@ const PACKED = 1;
|
|
|
227
229
|
const DELIMITED = 2;
|
|
228
230
|
// bootstrap-inject google.protobuf.FeatureSet.EnumType.OPEN: const $name: FeatureSet_EnumType.$localName = $number;
|
|
229
231
|
const OPEN = 1;
|
|
232
|
+
// bootstrap-inject google.protobuf.FeatureSet.Utf8Validation.VERIFY: const $name: FeatureSet_Utf8Validation.$localName = $number;
|
|
233
|
+
const VERIFY = 2;
|
|
230
234
|
// biome-ignore format: want this to read well
|
|
231
235
|
// bootstrap-inject defaults: EDITION_PROTO2 to EDITION_2024: export const minimumEdition: SupportedEdition = $minimumEdition, maximumEdition: SupportedEdition = $maximumEdition;
|
|
232
|
-
// generated from protoc
|
|
236
|
+
// generated from protoc v34.0
|
|
233
237
|
exports.minimumEdition = 998, exports.maximumEdition = 1001;
|
|
234
238
|
const featureDefaults = {
|
|
235
239
|
// EDITION_PROTO2
|
|
@@ -568,6 +572,7 @@ function newField(proto, parentOrFile, reg, oneof, mapEntries) {
|
|
|
568
572
|
message: undefined,
|
|
569
573
|
enum: undefined,
|
|
570
574
|
presence: getFieldPresence(proto, oneof, isExtension, parentOrFile),
|
|
575
|
+
utf8Validation: isUtf8Validated(proto, parentOrFile),
|
|
571
576
|
listKind: undefined,
|
|
572
577
|
mapKind: undefined,
|
|
573
578
|
mapKey: undefined,
|
|
@@ -696,6 +701,12 @@ function getFileEdition(proto) {
|
|
|
696
701
|
case "proto3":
|
|
697
702
|
return EDITION_PROTO3;
|
|
698
703
|
case "editions":
|
|
704
|
+
// EDITION_UNSTABLE is a sandbox for in-development features. Collapse
|
|
705
|
+
// it to maximumEdition so SupportedEdition and feature resolution do
|
|
706
|
+
// not leak the test-only edition to users.
|
|
707
|
+
if (proto.edition === EDITION_UNSTABLE) {
|
|
708
|
+
return exports.maximumEdition;
|
|
709
|
+
}
|
|
699
710
|
if (proto.edition in featureDefaults) {
|
|
700
711
|
return proto.edition;
|
|
701
712
|
}
|
|
@@ -891,6 +902,18 @@ function isDelimitedEncoding(proto, parent) {
|
|
|
891
902
|
parent,
|
|
892
903
|
}));
|
|
893
904
|
}
|
|
905
|
+
/**
|
|
906
|
+
* Reject invalid UTF-8 when reading string fields from the binary wire format?
|
|
907
|
+
* Driven by the resolved `utf8_validation` feature: VERIFY (proto3 / editions
|
|
908
|
+
* 2023+ default) enforces; NONE (proto2 default) does not.
|
|
909
|
+
*/
|
|
910
|
+
function isUtf8Validated(proto, parent) {
|
|
911
|
+
return (VERIFY ==
|
|
912
|
+
resolveFeature("utf8Validation", {
|
|
913
|
+
proto,
|
|
914
|
+
parent,
|
|
915
|
+
}));
|
|
916
|
+
}
|
|
894
917
|
function resolveFeature(name, ref) {
|
|
895
918
|
var _a, _b;
|
|
896
919
|
const featureSet = (_a = ref.proto.options) === null || _a === void 0 ? void 0 : _a.features;
|
package/dist/cjs/to-binary.js
CHANGED
package/dist/cjs/to-json.d.ts
CHANGED
package/dist/cjs/to-json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -226,10 +226,12 @@ function scalarToJson(field, value) {
|
|
|
226
226
|
case descriptors_js_1.ScalarType.INT64:
|
|
227
227
|
case descriptors_js_1.ScalarType.SFIXED64:
|
|
228
228
|
case descriptors_js_1.ScalarType.SINT64:
|
|
229
|
-
if (typeof value
|
|
230
|
-
|
|
229
|
+
if (typeof value == "bigint" ||
|
|
230
|
+
typeof value == "string" ||
|
|
231
|
+
(typeof value == "number" && Number.isInteger(value))) {
|
|
232
|
+
return value.toString();
|
|
231
233
|
}
|
|
232
|
-
|
|
234
|
+
throw new Error(`cannot encode ${field} to JSON: ${(_e = (0, reflect_check_js_1.checkField)(field, value)) === null || _e === void 0 ? void 0 : _e.message}`);
|
|
233
235
|
// bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.
|
|
234
236
|
// Either standard or URL-safe base64 encoding with/without paddings are accepted.
|
|
235
237
|
case descriptors_js_1.ScalarType.BYTES:
|
|
@@ -286,13 +288,10 @@ function anyToJson(val, opts) {
|
|
|
286
288
|
if (!desc || !message) {
|
|
287
289
|
throw new Error(`cannot encode message ${val.$typeName} to JSON: "${val.typeUrl}" is not in the type registry`);
|
|
288
290
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
typeof json !== "object") {
|
|
294
|
-
json = { value: json };
|
|
295
|
-
}
|
|
291
|
+
const reflected = (0, reflect_js_1.reflect)(desc, message);
|
|
292
|
+
const json = (0, wrappers_js_1.hasCustomJsonRepresentation)(desc)
|
|
293
|
+
? { value: tryWktToJson(reflected, opts) }
|
|
294
|
+
: reflectToJson(reflected, opts);
|
|
296
295
|
json["@type"] = val.typeUrl;
|
|
297
296
|
return json;
|
|
298
297
|
}
|
|
@@ -325,10 +324,8 @@ function durationToJson(val) {
|
|
|
325
324
|
function fieldMaskToJson(val) {
|
|
326
325
|
return val.paths
|
|
327
326
|
.map((p) => {
|
|
328
|
-
if (
|
|
329
|
-
throw new Error(`cannot encode message ${val.$typeName} to JSON: lowerCamelCase of path name "`
|
|
330
|
-
p +
|
|
331
|
-
'" is irreversible');
|
|
327
|
+
if ((0, names_js_1.protoSnakeCase)((0, names_js_1.protoCamelCase)(p)) !== p) {
|
|
328
|
+
throw new Error(`cannot encode message ${val.$typeName} to JSON: lowerCamelCase of path name "${p}" is irreversible`);
|
|
332
329
|
}
|
|
333
330
|
return (0, names_js_1.protoCamelCase)(p);
|
|
334
331
|
})
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type Message<TypeName extends string = string> = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Unknown fields and extensions stored on the message.
|
|
17
17
|
*/
|
|
18
|
-
$unknown?: UnknownField[];
|
|
18
|
+
$unknown?: UnknownField[] | undefined;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Extract the message type from a message descriptor.
|
package/dist/cjs/types.js
CHANGED
|
@@ -63,7 +63,7 @@ export declare class BinaryWriter {
|
|
|
63
63
|
private readonly encodeUtf8;
|
|
64
64
|
/**
|
|
65
65
|
* We cannot allocate a buffer for the entire output
|
|
66
|
-
* because we don't know
|
|
66
|
+
* because we don't know its size.
|
|
67
67
|
*
|
|
68
68
|
* So we collect smaller chunks of known size and
|
|
69
69
|
* concat them later.
|
|
@@ -120,7 +120,7 @@ export declare class BinaryWriter {
|
|
|
120
120
|
*/
|
|
121
121
|
int32(value: number): this;
|
|
122
122
|
/**
|
|
123
|
-
* Write a `bool` value, a
|
|
123
|
+
* Write a `bool` value, a varint.
|
|
124
124
|
*/
|
|
125
125
|
bool(value: boolean): this;
|
|
126
126
|
/**
|
|
@@ -152,7 +152,7 @@ export declare class BinaryWriter {
|
|
|
152
152
|
*/
|
|
153
153
|
sint32(value: number): this;
|
|
154
154
|
/**
|
|
155
|
-
* Write a `
|
|
155
|
+
* Write a `sfixed64` value, a signed, fixed-length 64-bit integer.
|
|
156
156
|
*/
|
|
157
157
|
sfixed64(value: string | number | bigint): this;
|
|
158
158
|
/**
|
|
@@ -184,9 +184,10 @@ export declare class BinaryReader {
|
|
|
184
184
|
readonly len: number;
|
|
185
185
|
protected readonly buf: Uint8Array;
|
|
186
186
|
private readonly view;
|
|
187
|
-
constructor(buf: Uint8Array, decodeUtf8?: (bytes: Uint8Array) => string);
|
|
187
|
+
constructor(buf: Uint8Array, decodeUtf8?: (bytes: Uint8Array, strict?: boolean) => string);
|
|
188
188
|
/**
|
|
189
|
-
* Reads a tag - field number and wire type.
|
|
189
|
+
* Reads a tag - field number and wire type. Tags are uint32 varints; values
|
|
190
|
+
* that do not fit in uint32 are rejected.
|
|
190
191
|
*/
|
|
191
192
|
tag(): [number, WireType];
|
|
192
193
|
/**
|
|
@@ -258,7 +259,8 @@ export declare class BinaryReader {
|
|
|
258
259
|
*/
|
|
259
260
|
bytes(): Uint8Array;
|
|
260
261
|
/**
|
|
261
|
-
* Read a `string` field, length-delimited data converted to UTF-8 text.
|
|
262
|
+
* Read a `string` field, length-delimited data converted to UTF-8 text. If
|
|
263
|
+
* `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
|
|
262
264
|
*/
|
|
263
|
-
string(): string;
|
|
265
|
+
string(strict?: boolean): string;
|
|
264
266
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -181,7 +181,7 @@ class BinaryWriter {
|
|
|
181
181
|
return this;
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
|
-
* Write a `bool` value, a
|
|
184
|
+
* Write a `bool` value, a varint.
|
|
185
185
|
*/
|
|
186
186
|
bool(value) {
|
|
187
187
|
this.buf.push(value ? 1 : 0);
|
|
@@ -248,7 +248,7 @@ class BinaryWriter {
|
|
|
248
248
|
return this;
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
|
-
* Write a `
|
|
251
|
+
* Write a `sfixed64` value, a signed, fixed-length 64-bit integer.
|
|
252
252
|
*/
|
|
253
253
|
sfixed64(value) {
|
|
254
254
|
let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = proto_int64_js_1.protoInt64.enc(value);
|
|
@@ -307,12 +307,21 @@ class BinaryReader {
|
|
|
307
307
|
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
|
-
* Reads a tag - field number and wire type.
|
|
310
|
+
* Reads a tag - field number and wire type. Tags are uint32 varints; values
|
|
311
|
+
* that do not fit in uint32 are rejected.
|
|
311
312
|
*/
|
|
312
313
|
tag() {
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
const start = this.pos;
|
|
315
|
+
const tag = this.uint32();
|
|
316
|
+
const bytesRead = this.pos - start;
|
|
317
|
+
if (bytesRead > 5 || (bytesRead == 5 && this.buf[this.pos - 1] > 0x0f)) {
|
|
318
|
+
throw new Error("illegal tag: varint overflows uint32");
|
|
319
|
+
}
|
|
320
|
+
const fieldNo = tag >>> 3;
|
|
321
|
+
const wireType = tag & 7;
|
|
322
|
+
if (fieldNo <= 0 || wireType > 5) {
|
|
315
323
|
throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
|
|
324
|
+
}
|
|
316
325
|
return [fieldNo, wireType];
|
|
317
326
|
}
|
|
318
327
|
/**
|
|
@@ -458,10 +467,11 @@ class BinaryReader {
|
|
|
458
467
|
return this.buf.subarray(start, start + len);
|
|
459
468
|
}
|
|
460
469
|
/**
|
|
461
|
-
* Read a `string` field, length-delimited data converted to UTF-8 text.
|
|
470
|
+
* Read a `string` field, length-delimited data converted to UTF-8 text. If
|
|
471
|
+
* `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
|
|
462
472
|
*/
|
|
463
|
-
string() {
|
|
464
|
-
return this.decodeUtf8(this.bytes());
|
|
473
|
+
string(strict) {
|
|
474
|
+
return this.decodeUtf8(this.bytes(), strict);
|
|
465
475
|
}
|
|
466
476
|
}
|
|
467
477
|
exports.BinaryReader = BinaryReader;
|
package/dist/cjs/wire/index.js
CHANGED
|
@@ -8,9 +8,11 @@ interface TextEncoding {
|
|
|
8
8
|
*/
|
|
9
9
|
encodeUtf8: (text: string) => Uint8Array<ArrayBuffer>;
|
|
10
10
|
/**
|
|
11
|
-
* Decode UTF-8 text from binary.
|
|
11
|
+
* Decode UTF-8 text from binary. If `strict` is true, throw on invalid byte
|
|
12
|
+
* sequences instead of silently substituting U+FFFD. Implementations that
|
|
13
|
+
* do not support strict decoding may ignore the flag.
|
|
12
14
|
*/
|
|
13
|
-
decodeUtf8: (bytes: Uint8Array) => string;
|
|
15
|
+
decodeUtf8: (bytes: Uint8Array, strict?: boolean) => string;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Protobuf-ES requires the Text Encoding API to convert UTF-8 from and to
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -32,11 +32,18 @@ function getTextEncoding() {
|
|
|
32
32
|
if (globalThis[symbol] == undefined) {
|
|
33
33
|
const te = new globalThis.TextEncoder();
|
|
34
34
|
const td = new globalThis.TextDecoder();
|
|
35
|
+
let tdStrict;
|
|
35
36
|
globalThis[symbol] = {
|
|
36
37
|
encodeUtf8(text) {
|
|
37
38
|
return te.encode(text);
|
|
38
39
|
},
|
|
39
|
-
decodeUtf8(bytes) {
|
|
40
|
+
decodeUtf8(bytes, strict) {
|
|
41
|
+
if (strict) {
|
|
42
|
+
if (tdStrict === undefined) {
|
|
43
|
+
tdStrict = new globalThis.TextDecoder("utf-8", { fatal: true });
|
|
44
|
+
}
|
|
45
|
+
return tdStrict.decode(bytes);
|
|
46
|
+
}
|
|
40
47
|
return td.decode(bytes);
|
|
41
48
|
},
|
|
42
49
|
checkUtf8(text) {
|
package/dist/cjs/wkt/any.js
CHANGED
package/dist/cjs/wkt/duration.js
CHANGED
|
@@ -75,7 +75,7 @@ export type Api = Message<"google.protobuf.Api"> & {
|
|
|
75
75
|
*
|
|
76
76
|
* @generated from field: google.protobuf.SourceContext source_context = 5;
|
|
77
77
|
*/
|
|
78
|
-
sourceContext?: SourceContext;
|
|
78
|
+
sourceContext?: SourceContext | undefined;
|
|
79
79
|
/**
|
|
80
80
|
* Included interfaces. See [Mixin][].
|
|
81
81
|
*
|
|
@@ -121,7 +121,7 @@ export type CodeGeneratorRequest = Message<"google.protobuf.compiler.CodeGenerat
|
|
|
121
121
|
*
|
|
122
122
|
* @generated from field: optional google.protobuf.compiler.Version compiler_version = 3;
|
|
123
123
|
*/
|
|
124
|
-
compilerVersion?: Version;
|
|
124
|
+
compilerVersion?: Version | undefined;
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
127
127
|
* An encoded CodeGeneratorRequest is written to the plugin's stdin.
|
|
@@ -371,7 +371,7 @@ export type CodeGeneratorResponse_File = Message<"google.protobuf.compiler.CodeG
|
|
|
371
371
|
*
|
|
372
372
|
* @generated from field: optional google.protobuf.GeneratedCodeInfo generated_code_info = 16;
|
|
373
373
|
*/
|
|
374
|
-
generatedCodeInfo?: GeneratedCodeInfo;
|
|
374
|
+
generatedCodeInfo?: GeneratedCodeInfo | undefined;
|
|
375
375
|
};
|
|
376
376
|
/**
|
|
377
377
|
* Represents a single generated file.
|