@bufbuild/protobuf 0.0.2-alpha.2 → 0.0.2-alpha.3

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.
Files changed (41) hide show
  1. package/dist/cjs/google/protobuf/any_pb.js +13 -33
  2. package/dist/cjs/google/protobuf/api_pb.js +10 -30
  3. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +10 -45
  4. package/dist/cjs/google/protobuf/descriptor_pb.js +13 -39
  5. package/dist/cjs/google/protobuf/duration_pb.js +10 -30
  6. package/dist/cjs/google/protobuf/empty_pb.js +10 -30
  7. package/dist/cjs/google/protobuf/field_mask_pb.js +10 -30
  8. package/dist/cjs/google/protobuf/source_context_pb.js +10 -30
  9. package/dist/cjs/google/protobuf/struct_pb.js +10 -30
  10. package/dist/cjs/google/protobuf/timestamp_pb.js +10 -30
  11. package/dist/cjs/google/protobuf/type_pb.js +10 -30
  12. package/dist/cjs/google/protobuf/wrappers_pb.js +10 -39
  13. package/dist/cjs/index.js +3 -1
  14. package/dist/cjs/private/json-format-common.js +3 -3
  15. package/dist/cjs/proto-base64.js +138 -0
  16. package/dist/esm/google/protobuf/any_pb.js +13 -33
  17. package/dist/esm/google/protobuf/api_pb.js +10 -30
  18. package/dist/esm/google/protobuf/compiler/plugin_pb.js +10 -45
  19. package/dist/esm/google/protobuf/descriptor_pb.js +13 -39
  20. package/dist/esm/google/protobuf/duration_pb.js +10 -30
  21. package/dist/esm/google/protobuf/empty_pb.js +10 -30
  22. package/dist/esm/google/protobuf/field_mask_pb.js +10 -30
  23. package/dist/esm/google/protobuf/source_context_pb.js +10 -30
  24. package/dist/esm/google/protobuf/struct_pb.js +10 -30
  25. package/dist/esm/google/protobuf/timestamp_pb.js +10 -30
  26. package/dist/esm/google/protobuf/type_pb.js +10 -30
  27. package/dist/esm/google/protobuf/wrappers_pb.js +10 -39
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/private/json-format-common.js +3 -3
  30. package/dist/esm/proto-base64.js +135 -0
  31. package/dist/types/google/protobuf/any_pb.d.ts +3 -3
  32. package/dist/types/google/protobuf/descriptor_pb.d.ts +16 -3
  33. package/dist/types/index.d.ts +1 -0
  34. package/dist/types/message-type.d.ts +2 -1
  35. package/dist/types/message.d.ts +3 -3
  36. package/dist/types/private/util.d.ts +2 -2
  37. package/dist/types/proto-base64.d.ts +26 -0
  38. package/package.json +1 -1
  39. package/dist/cjs/private/base64.js +0 -132
  40. package/dist/esm/private/base64.js +0 -127
  41. package/dist/types/private/base64.d.ts +0 -18
@@ -1,36 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/empty.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
34
14
  import { Message, proto3 } from "../../index.js";
35
15
  /**
36
16
  * A generic empty message that you can re-use to avoid defining duplicated
@@ -1,36 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/field_mask.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
34
14
  import { Message, proto3 } from "../../index.js";
35
15
  /**
36
16
  * `FieldMask` represents a set of symbolic field paths, for example:
@@ -1,36 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/source_context.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
34
14
  import { Message, proto3 } from "../../index.js";
35
15
  /**
36
16
  * `SourceContext` represents information about the source of a
@@ -1,36 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
34
14
  import { Message, proto3 } from "../../index.js";
35
15
  /**
36
16
  * `NullValue` is a singleton enumeration to represent the null value for the
@@ -1,36 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/timestamp.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
34
14
  import { Message, proto3, protoInt64 } from "../../index.js";
35
15
  /**
36
16
  * A Timestamp represents a point in time independent of any time zone or local
@@ -1,36 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
34
14
  import { Message, proto3 } from "../../index.js";
35
15
  import { SourceContext } from "./source_context_pb.js";
36
16
  import { Any } from "./any_pb.js";
@@ -1,45 +1,16 @@
1
- /* eslint-disable */
2
- // @generated by protoc-gen-es v0.0.2-alpha.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
3
- // @generated from file google/protobuf/wrappers.proto (package google.protobuf, syntax proto3)
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
4
2
  //
5
- // Protocol Buffers - Google's data interchange format
6
- // Copyright 2008 Google Inc. All rights reserved.
7
- // https://developers.google.com/protocol-buffers/
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
8
6
  //
9
- // Redistribution and use in source and binary forms, with or without
10
- // modification, are permitted provided that the following conditions are
11
- // met:
7
+ // http://www.apache.org/licenses/LICENSE-2.0
12
8
  //
13
- // * Redistributions of source code must retain the above copyright
14
- // notice, this list of conditions and the following disclaimer.
15
- // * Redistributions in binary form must reproduce the above
16
- // copyright notice, this list of conditions and the following disclaimer
17
- // in the documentation and/or other materials provided with the
18
- // distribution.
19
- // * Neither the name of Google Inc. nor the names of its
20
- // contributors may be used to endorse or promote products derived from
21
- // this software without specific prior written permission.
22
- //
23
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- // Wrappers for primitive (non-message) types. These types are useful
35
- // for embedding primitives in the `google.protobuf.Any` type and for places
36
- // where we need to distinguish between the absence of a primitive
37
- // typed field and its default value.
38
- //
39
- // These wrappers have no meaningful use within repeated fields as they lack
40
- // the ability to detect presence on individual elements.
41
- // These wrappers have no meaningful use within a map or a oneof since
42
- // individual entries of a map or fields of a oneof can already detect presence.
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
43
14
  import { Message, ScalarType, proto3, protoInt64 } from "../../index.js";
44
15
  /**
45
16
  * Wrapper message for `double`.
package/dist/esm/index.js CHANGED
@@ -14,6 +14,7 @@
14
14
  export { proto3 } from "./proto3.js";
15
15
  export { proto2 } from "./proto2.js";
16
16
  export { protoInt64 } from "./proto-int64.js";
17
+ export { protoBase64 } from "./proto-base64.js";
17
18
  export { Message, } from "./message.js";
18
19
  export { ScalarType } from "./field.js";
19
20
  export { MethodKind, MethodIdempotency } from "./service-type.js";
@@ -15,7 +15,7 @@ import { unwrapField, wrapField } from "./field-wrapper.js";
15
15
  import { ScalarType } from "../field.js";
16
16
  import { assert, assertFloat32, assertInt32, assertUInt32 } from "./assert.js";
17
17
  import { protoInt64 } from "../proto-int64.js";
18
- import { base64decode, base64encode } from "./base64.js";
18
+ import { protoBase64 } from "../proto-base64.js";
19
19
  /* eslint-disable no-case-declarations, @typescript-eslint/restrict-plus-operands,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
20
20
  // Default options for parsing JSON.
21
21
  const jsonReadDefaults = {
@@ -363,7 +363,7 @@ function readScalar(type, json) {
363
363
  return new Uint8Array(0);
364
364
  if (typeof json !== "string")
365
365
  break;
366
- return base64decode(json);
366
+ return protoBase64.dec(json);
367
367
  }
368
368
  throw new Error();
369
369
  }
@@ -459,7 +459,7 @@ function writeScalar(type, value, emitIntrinsicDefault) {
459
459
  case ScalarType.BYTES:
460
460
  assert(value instanceof Uint8Array);
461
461
  return emitIntrinsicDefault || value.byteLength > 0
462
- ? base64encode(value)
462
+ ? protoBase64.enc(value)
463
463
  : undefined;
464
464
  }
465
465
  }
@@ -0,0 +1,135 @@
1
+ // Copyright 2021-2022 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */
15
+ // lookup table from base64 character to byte
16
+ let encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
17
+ // lookup table from base64 character *code* to byte because lookup by number is fast
18
+ let decTable = [];
19
+ for (let i = 0; i < encTable.length; i++)
20
+ decTable[encTable[i].charCodeAt(0)] = i;
21
+ // support base64url variants
22
+ decTable["-".charCodeAt(0)] = encTable.indexOf("+");
23
+ decTable["_".charCodeAt(0)] = encTable.indexOf("/");
24
+ export const protoBase64 = {
25
+ /**
26
+ * Decodes a base64 string to a byte array.
27
+ *
28
+ * - ignores white-space, including line breaks and tabs
29
+ * - allows inner padding (can decode concatenated base64 strings)
30
+ * - does not require padding
31
+ * - understands base64url encoding:
32
+ * "-" instead of "+",
33
+ * "_" instead of "/",
34
+ * no padding
35
+ */
36
+ dec(base64Str) {
37
+ // estimate byte size, not accounting for inner padding and whitespace
38
+ let es = (base64Str.length * 3) / 4;
39
+ // if (es % 3 !== 0)
40
+ // throw new Error("invalid base64 string");
41
+ if (base64Str[base64Str.length - 2] == "=")
42
+ es -= 2;
43
+ else if (base64Str[base64Str.length - 1] == "=")
44
+ es -= 1;
45
+ let bytes = new Uint8Array(es), bytePos = 0, // position in byte array
46
+ groupPos = 0, // position in base64 group
47
+ b, // current byte
48
+ p = 0; // previous byte
49
+ for (let i = 0; i < base64Str.length; i++) {
50
+ b = decTable[base64Str.charCodeAt(i)];
51
+ if (b === undefined) {
52
+ switch (base64Str[i]) {
53
+ // @ts-ignore TS7029: Fallthrough case in switch
54
+ case "=":
55
+ groupPos = 0; // reset state when padding found
56
+ // @ts-ignore TS7029: Fallthrough case in switch
57
+ case "\n":
58
+ case "\r":
59
+ case "\t":
60
+ case " ":
61
+ continue; // skip white-space, and padding
62
+ default:
63
+ throw Error("invalid base64 string.");
64
+ }
65
+ }
66
+ switch (groupPos) {
67
+ case 0:
68
+ p = b;
69
+ groupPos = 1;
70
+ break;
71
+ case 1:
72
+ bytes[bytePos++] = (p << 2) | ((b & 48) >> 4);
73
+ p = b;
74
+ groupPos = 2;
75
+ break;
76
+ case 2:
77
+ bytes[bytePos++] = ((p & 15) << 4) | ((b & 60) >> 2);
78
+ p = b;
79
+ groupPos = 3;
80
+ break;
81
+ case 3:
82
+ bytes[bytePos++] = ((p & 3) << 6) | b;
83
+ groupPos = 0;
84
+ break;
85
+ }
86
+ }
87
+ if (groupPos == 1)
88
+ throw Error("invalid base64 string.");
89
+ return bytes.subarray(0, bytePos);
90
+ },
91
+ /**
92
+ * Decodes a base64 string to a byte array.
93
+ *
94
+ * - ignores white-space, including line breaks and tabs
95
+ * - allows inner padding (can decode concatenated base64 strings)
96
+ * - does not require padding
97
+ * - understands base64url encoding:
98
+ * "-" instead of "+",
99
+ * "_" instead of "/",
100
+ * no padding
101
+ */
102
+ enc(bytes) {
103
+ let base64 = "", groupPos = 0, // position in base64 group
104
+ b, // current byte
105
+ p = 0; // carry over from previous byte
106
+ for (let i = 0; i < bytes.length; i++) {
107
+ b = bytes[i];
108
+ switch (groupPos) {
109
+ case 0:
110
+ base64 += encTable[b >> 2];
111
+ p = (b & 3) << 4;
112
+ groupPos = 1;
113
+ break;
114
+ case 1:
115
+ base64 += encTable[p | (b >> 4)];
116
+ p = (b & 15) << 2;
117
+ groupPos = 2;
118
+ break;
119
+ case 2:
120
+ base64 += encTable[p | (b >> 6)];
121
+ base64 += encTable[b & 63];
122
+ groupPos = 0;
123
+ break;
124
+ }
125
+ }
126
+ // padding required?
127
+ if (groupPos) {
128
+ base64 += encTable[p];
129
+ base64 += "=";
130
+ if (groupPos == 1)
131
+ base64 += "=";
132
+ }
133
+ return base64;
134
+ },
135
+ };
@@ -26,7 +26,7 @@ import { Message } from "../../index.js";
26
26
  * foo = any.unpack(Foo.class);
27
27
  * }
28
28
  *
29
- * Example 3: Pack and unpack a message in Python.
29
+ * Example 3: Pack and unpack a message in Python.
30
30
  *
31
31
  * foo = Foo(...)
32
32
  * any = Any()
@@ -36,7 +36,7 @@ import { Message } from "../../index.js";
36
36
  * any.Unpack(foo)
37
37
  * ...
38
38
  *
39
- * Example 4: Pack and unpack a message in Go
39
+ * Example 4: Pack and unpack a message in Go
40
40
  *
41
41
  * foo := &pb.Foo{...}
42
42
  * any, err := anypb.New(foo)
@@ -57,7 +57,7 @@ import { Message } from "../../index.js";
57
57
  *
58
58
  *
59
59
  * JSON
60
- * ====
60
+ *
61
61
  * The JSON representation of an `Any` value uses the regular
62
62
  * representation of the deserialized, embedded message, with an
63
63
  * additional field `@type` which contains the type URL. Example:
@@ -286,7 +286,6 @@ export declare class FieldDescriptorProto extends Message<FieldDescriptorProto>
286
286
  * For booleans, "true" or "false".
287
287
  * For strings, contains the default text contents (not escaped in any way).
288
288
  * For bytes, contains the C escaped value. All bytes >= 128 are escaped.
289
- * TODO(kenton): Base-64 encode?
290
289
  *
291
290
  * @generated from field: optional string default_value = 7;
292
291
  */
@@ -1020,9 +1019,23 @@ export declare class FieldOptions extends Message<FieldOptions> {
1020
1019
  * check its required fields, regardless of whether or not the message has
1021
1020
  * been parsed.
1022
1021
  *
1022
+ * As of 2021, lazy does no correctness checks on the byte stream during
1023
+ * parsing. This may lead to crashes if and when an invalid byte stream is
1024
+ * finally parsed upon access.
1025
+ *
1026
+ * TODO(b/211906113): Enable validation on lazy fields.
1027
+ *
1023
1028
  * @generated from field: optional bool lazy = 5 [default = false];
1024
1029
  */
1025
1030
  lazy?: boolean;
1031
+ /**
1032
+ * unverified_lazy does no correctness checks on the byte stream. This should
1033
+ * only be used where lazy with verification is prohibitive for performance
1034
+ * reasons.
1035
+ *
1036
+ * @generated from field: optional bool unverified_lazy = 15 [default = false];
1037
+ */
1038
+ unverifiedLazy?: boolean;
1026
1039
  /**
1027
1040
  * Is this field deprecated?
1028
1041
  * Depending on the target platform, this can emit Deprecated annotations
@@ -1413,8 +1426,8 @@ export declare class SourceCodeInfo_Location extends Message<SourceCodeInfo_Loca
1413
1426
  * location.
1414
1427
  *
1415
1428
  * Each element is a field number or an index. They form a path from
1416
- * the root FileDescriptorProto to the place where the definition. For
1417
- * example, this path:
1429
+ * the root FileDescriptorProto to the place where the definition occurs.
1430
+ * For example, this path:
1418
1431
  * [ 4, 3, 2, 7, 1 ]
1419
1432
  * refers to:
1420
1433
  * file.message_type(3) // 4, 3
@@ -1,6 +1,7 @@
1
1
  export { proto3 } from "./proto3.js";
2
2
  export { proto2 } from "./proto2.js";
3
3
  export { protoInt64 } from "./proto-int64.js";
4
+ export { protoBase64 } from "./proto-base64.js";
4
5
  export { Message, AnyMessage, PartialMessage, PlainMessage, } from "./message.js";
5
6
  export type { FieldInfo } from "./field.js";
6
7
  export type { FieldList } from "./field-list.js";
@@ -45,6 +45,7 @@ export interface MessageType<T extends Message<T> = AnyMessage> {
45
45
  fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): T;
46
46
  /**
47
47
  * Returns true if the given arguments have equal field values, recursively.
48
+ * Will also return true if both messages are `undefined` or `null`.
48
49
  */
49
- equals(a: T | PlainMessage<T> | undefined, b: T | PlainMessage<T> | undefined): boolean;
50
+ equals(a: T | PlainMessage<T> | undefined | null, b: T | PlainMessage<T> | undefined | null): boolean;
50
51
  }