Socket
Socket
Sign inDemoInstall

@protobuf-ts/runtime

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@protobuf-ts/runtime - npm Package Compare versions

Comparing version 2.9.0 to 2.9.1

4

build/commonjs/goog-varint.js

@@ -141,3 +141,3 @@ "use strict";

lowBits = lowBits * base + digit1e6;
// Carry bits from lowBits to
// Carry bits from lowBits to highBits
if (lowBits >= TWO_PWR_32_DBL) {

@@ -163,3 +163,3 @@ highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);

// built-in conversions.
if (bitsHigh <= 0x1FFFFF) {
if ((bitsHigh >>> 0) <= 0x1FFFFF) {
return '' + (TWO_PWR_32_DBL * bitsHigh + (bitsLow >>> 0));

@@ -166,0 +166,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PbLong = exports.PbULong = void 0;
exports.PbLong = exports.PbULong = exports.detectBi = void 0;
const goog_varint_1 = require("./goog-varint");
let BI;
function detectBi() {

@@ -12,3 +13,3 @@ const dv = new DataView(new ArrayBuffer(8));

&& typeof dv.setBigUint64 === "function";
return ok ? {
BI = ok ? {
MIN: BigInt("-9223372036854775808"),

@@ -22,3 +23,4 @@ MAX: BigInt("9223372036854775807"),

}
const BI = detectBi();
exports.detectBi = detectBi;
detectBi();
function assertBi(bi) {

@@ -31,3 +33,4 @@ if (!bi)

// constants for binary math
const TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
const TWO_PWR_32_DBL = 0x100000000;
const HALF_2_PWR_32 = 0x080000000;
// base class for PbLong and PbULong provides shared code

@@ -100,3 +103,3 @@ class SharedPbLong {

if (minus)
throw new Error('signed value');
throw new Error('signed value for ulong');
return new PbULong(lo, hi);

@@ -161,5 +164,5 @@ case "number":

if (value < BI.MIN)
throw new Error('ulong too small');
throw new Error('signed long too small');
if (value > BI.MAX)
throw new Error('ulong too large');
throw new Error('signed long too large');
BI.V.setBigInt64(0, value, true);

@@ -177,2 +180,8 @@ return new PbLong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));

let [minus, lo, hi] = goog_varint_1.int64fromString(value);
if (minus) {
if (hi > HALF_2_PWR_32 || (hi == HALF_2_PWR_32 && lo != 0))
throw new Error('signed long too small');
}
else if (hi >= HALF_2_PWR_32)
throw new Error('signed long too large');
let pbl = new PbLong(lo, hi);

@@ -195,3 +204,3 @@ return minus ? pbl.negate() : pbl;

isNegative() {
return (this.hi & 0x80000000) !== 0;
return (this.hi & HALF_2_PWR_32) !== 0;
}

@@ -198,0 +207,0 @@ /**

@@ -63,2 +63,5 @@ "use strict";

if (field.oneof) {
if (jsonValue === null && (field.kind !== 'enum' || field.T()[0] !== 'google.protobuf.NullValue')) {
continue;
}
// since json objects are unordered by specification, it is not possible to take the last of multiple oneofs

@@ -164,7 +167,7 @@ if (oneofsHandled.includes(field.oneof))

*
* google.protobuf.NullValue accepts only JSON `null`.
* google.protobuf.NullValue accepts only JSON `null` (or the old `"NULL_VALUE"`).
*/
enum(type, json, fieldName, ignoreUnknownFields) {
if (type[0] == 'google.protobuf.NullValue')
assert_1.assert(json === null, `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
assert_1.assert(json === null || json === "NULL_VALUE", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
if (json === null)

@@ -171,0 +174,0 @@ // we require 0 to be default value for all enums

@@ -127,7 +127,7 @@ "use strict";

/**
* Returns `null` for google.protobuf.NullValue.
* Returns `null` as the default for google.protobuf.NullValue.
*/
enum(type, value, fieldName, optional, emitDefaultValues, enumAsInteger) {
if (type[0] == 'google.protobuf.NullValue')
return null;
return !emitDefaultValues && !optional ? undefined : null;
if (value === undefined) {

@@ -134,0 +134,0 @@ assert_1.assert(optional);

@@ -136,3 +136,3 @@ // Copyright 2008 Google Inc. All rights reserved.

lowBits = lowBits * base + digit1e6;
// Carry bits from lowBits to
// Carry bits from lowBits to highBits
if (lowBits >= TWO_PWR_32_DBL) {

@@ -157,3 +157,3 @@ highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);

// built-in conversions.
if (bitsHigh <= 0x1FFFFF) {
if ((bitsHigh >>> 0) <= 0x1FFFFF) {
return '' + (TWO_PWR_32_DBL * bitsHigh + (bitsLow >>> 0));

@@ -160,0 +160,0 @@ }

import { int64fromString, int64toString } from "./goog-varint";
function detectBi() {
let BI;
export function detectBi() {
const dv = new DataView(new ArrayBuffer(8));

@@ -9,3 +10,3 @@ const ok = globalThis.BigInt !== undefined

&& typeof dv.setBigUint64 === "function";
return ok ? {
BI = ok ? {
MIN: BigInt("-9223372036854775808"),

@@ -19,3 +20,3 @@ MAX: BigInt("9223372036854775807"),

}
const BI = detectBi();
detectBi();
function assertBi(bi) {

@@ -28,3 +29,4 @@ if (!bi)

// constants for binary math
const TWO_PWR_32_DBL = (1 << 16) * (1 << 16);
const TWO_PWR_32_DBL = 0x100000000;
const HALF_2_PWR_32 = 0x080000000;
// base class for PbLong and PbULong provides shared code

@@ -97,3 +99,3 @@ class SharedPbLong {

if (minus)
throw new Error('signed value');
throw new Error('signed value for ulong');
return new PbULong(lo, hi);

@@ -157,5 +159,5 @@ case "number":

if (value < BI.MIN)
throw new Error('ulong too small');
throw new Error('signed long too small');
if (value > BI.MAX)
throw new Error('ulong too large');
throw new Error('signed long too large');
BI.V.setBigInt64(0, value, true);

@@ -173,2 +175,8 @@ return new PbLong(BI.V.getInt32(0, true), BI.V.getInt32(4, true));

let [minus, lo, hi] = int64fromString(value);
if (minus) {
if (hi > HALF_2_PWR_32 || (hi == HALF_2_PWR_32 && lo != 0))
throw new Error('signed long too small');
}
else if (hi >= HALF_2_PWR_32)
throw new Error('signed long too large');
let pbl = new PbLong(lo, hi);

@@ -191,3 +199,3 @@ return minus ? pbl.negate() : pbl;

isNegative() {
return (this.hi & 0x80000000) !== 0;
return (this.hi & HALF_2_PWR_32) !== 0;
}

@@ -194,0 +202,0 @@ /**

@@ -60,2 +60,5 @@ import { isJsonObject, typeofJsonValue } from "./json-typings";

if (field.oneof) {
if (jsonValue === null && (field.kind !== 'enum' || field.T()[0] !== 'google.protobuf.NullValue')) {
continue;
}
// since json objects are unordered by specification, it is not possible to take the last of multiple oneofs

@@ -161,7 +164,7 @@ if (oneofsHandled.includes(field.oneof))

*
* google.protobuf.NullValue accepts only JSON `null`.
* google.protobuf.NullValue accepts only JSON `null` (or the old `"NULL_VALUE"`).
*/
enum(type, json, fieldName, ignoreUnknownFields) {
if (type[0] == 'google.protobuf.NullValue')
assert(json === null, `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
assert(json === null || json === "NULL_VALUE", `Unable to parse field ${this.info.typeName}#${fieldName}, enum ${type[0]} only accepts null.`);
if (json === null)

@@ -168,0 +171,0 @@ // we require 0 to be default value for all enums

@@ -124,7 +124,7 @@ import { base64encode } from "./base64";

/**
* Returns `null` for google.protobuf.NullValue.
* Returns `null` as the default for google.protobuf.NullValue.
*/
enum(type, value, fieldName, optional, emitDefaultValues, enumAsInteger) {
if (type[0] == 'google.protobuf.NullValue')
return null;
return !emitDefaultValues && !optional ? undefined : null;
if (value === undefined) {

@@ -131,0 +131,0 @@ assert(optional);

@@ -0,1 +1,2 @@

export declare function detectBi(): void;
declare abstract class SharedPbLong {

@@ -2,0 +3,0 @@ /**

@@ -35,3 +35,3 @@ import type { JsonObject, JsonValue } from "./json-typings";

*
* google.protobuf.NullValue accepts only JSON `null`.
* google.protobuf.NullValue accepts only JSON `null` (or the old `"NULL_VALUE"`).
*/

@@ -38,0 +38,0 @@ enum(type: EnumInfo, json: unknown, fieldName: string, ignoreUnknownFields: boolean): UnknownEnum | false;

@@ -21,3 +21,3 @@ import type { JsonValue } from "./json-typings";

/**
* Returns `null` for google.protobuf.NullValue.
* Returns `null` as the default for google.protobuf.NullValue.
*/

@@ -24,0 +24,0 @@ enum(type: EnumInfo, value: unknown, fieldName: string, optional: boolean, emitDefaultValues: boolean, enumAsInteger: boolean): JsonValue | undefined;

{
"name": "@protobuf-ts/runtime",
"version": "2.9.0",
"version": "2.9.1",
"description": "Runtime library for code generated by the protoc plugin \"protobuf-ts\"",

@@ -40,3 +40,3 @@ "license": "(Apache-2.0 AND BSD-3-Clause)",

},
"gitHead": "1349fe9643bc6d6aa5d3d10ce631500279cf3b51"
"gitHead": "15e71e2133631e00e13e570c191186b711377c9b"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc