@aptre/protobuf-es-lite 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/json.js CHANGED
@@ -5,6 +5,7 @@ import { unwrapField, wrapField } from "./field-wrapper.js";
5
5
  import { enumZeroValue, normalizeEnumValue } from "./enum.js";
6
6
  import { protoInt64 } from "./proto-int64.js";
7
7
  import { protoBase64 } from "./proto-base64.js";
8
+ import { throwSanitizeKey } from "./names.js";
8
9
  // Default options for parsing JSON.
9
10
  const jsonReadDefaults = {
10
11
  ignoreUnknownFields: false,
@@ -173,6 +174,7 @@ function readField(target, jsonValue, field, options) {
173
174
  }
174
175
  throw new Error(m);
175
176
  }
177
+ throwSanitizeKey(key);
176
178
  switch (field.V.kind) {
177
179
  case "message":
178
180
  const messageType = resolveMessageType(field.V.T);
package/dist/names.js CHANGED
@@ -209,6 +209,8 @@ const reservedObjectProperties = new Set([
209
209
  "toString",
210
210
  "toJSON",
211
211
  "valueOf",
212
+ "__proto__",
213
+ "prototype",
212
214
  ]);
213
215
  /**
214
216
  * Names that cannot be used for object properties because they are reserved
@@ -246,7 +248,7 @@ export const safeIdentifier = (name) => {
246
248
  return name;
247
249
  };
248
250
  export function checkSanitizeKey(key) {
249
- return typeof key === "string" && key !== "__proto__";
251
+ return typeof key === "string" && !!key.length && !reservedObjectProperties.has(key);
250
252
  }
251
253
  export function throwSanitizeKey(key) {
252
254
  if (typeof key !== "string") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aptre/protobuf-es-lite",
3
3
  "description": "Lightweight Protobuf codegen for TypeScript and JavaScript.",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "url": "git+ssh://git@github.com/aperturerobotics/protobuf-es-lite.git"