New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bufbuild/connect-web

Package Overview
Dependencies
Maintainers
9
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufbuild/connect-web - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

23

dist/cjs/connect-error.js

@@ -33,4 +33,7 @@ "use strict";

class ConnectError extends Error {
constructor(message, code = code_js_1.Code.Unknown, detailsOrMetadata, metadata) {
var _a;
/**
* Create a new ConnectError. If no code is provided, code "unknown" is
* used.
*/
constructor(message, code = code_js_1.Code.Unknown, metadata) {
super(createMessage(message, code));

@@ -42,5 +45,3 @@ this.name = "ConnectError";

this.code = code;
// TODO once we remove the deprecated constructor, this can become `new Headers(metadata ?? {})`
const metadataInit = (_a = metadata !== null && metadata !== void 0 ? metadata : (Array.isArray(detailsOrMetadata) ? undefined : detailsOrMetadata)) !== null && _a !== void 0 ? _a : {};
this.metadata = new Headers(metadataInit);
this.metadata = new Headers(metadata);
this.details = [];

@@ -58,9 +59,5 @@ }

const any = new protobuf_1.Any(data);
const name = any.typeUrl.substring(any.typeUrl.lastIndexOf("/") + 1);
const type = typeRegistry.findMessage(name);
if (type) {
const message = new type();
if (any.unpackTo(message)) {
details.push(message);
}
const message = any.unpack(typeRegistry);
if (message) {
details.push(message);
}

@@ -103,3 +100,3 @@ }

}
const error = new ConnectError(message !== null && message !== void 0 ? message : "", code, undefined, metadata);
const error = new ConnectError(message !== null && message !== void 0 ? message : "", code, metadata);
if ("details" in jsonValue && Array.isArray(jsonValue.details)) {

@@ -106,0 +103,0 @@ for (const detail of jsonValue.details) {

@@ -242,5 +242,5 @@ "use strict";

if (!(code in code_js_1.Code)) {
return new connect_error_js_1.ConnectError(`invalid grpc-status: ${value}`, code_js_1.Code.Internal, undefined, header);
return new connect_error_js_1.ConnectError(`invalid grpc-status: ${value}`, code_js_1.Code.Internal, header);
}
return new connect_error_js_1.ConnectError(decodeURIComponent((_a = header.get("grpc-message")) !== null && _a !== void 0 ? _a : ""), code, undefined, header);
return new connect_error_js_1.ConnectError(decodeURIComponent((_a = header.get("grpc-message")) !== null && _a !== void 0 ? _a : ""), code, header);
}

@@ -258,3 +258,3 @@ function extractDetailsError(header) {

}
const error = new connect_error_js_1.ConnectError(status.message, status.code, undefined, header);
const error = new connect_error_js_1.ConnectError(status.message, status.code, header);
error.details.push(...status.details);

@@ -261,0 +261,0 @@ return error;

@@ -30,4 +30,7 @@ // Copyright 2021-2023 Buf Technologies, Inc.

export class ConnectError extends Error {
constructor(message, code = Code.Unknown, detailsOrMetadata, metadata) {
var _a;
/**
* Create a new ConnectError. If no code is provided, code "unknown" is
* used.
*/
constructor(message, code = Code.Unknown, metadata) {
super(createMessage(message, code));

@@ -39,5 +42,3 @@ this.name = "ConnectError";

this.code = code;
// TODO once we remove the deprecated constructor, this can become `new Headers(metadata ?? {})`
const metadataInit = (_a = metadata !== null && metadata !== void 0 ? metadata : (Array.isArray(detailsOrMetadata) ? undefined : detailsOrMetadata)) !== null && _a !== void 0 ? _a : {};
this.metadata = new Headers(metadataInit);
this.metadata = new Headers(metadata);
this.details = [];

@@ -54,9 +55,5 @@ }

const any = new Any(data);
const name = any.typeUrl.substring(any.typeUrl.lastIndexOf("/") + 1);
const type = typeRegistry.findMessage(name);
if (type) {
const message = new type();
if (any.unpackTo(message)) {
details.push(message);
}
const message = any.unpack(typeRegistry);
if (message) {
details.push(message);
}

@@ -98,3 +95,3 @@ }

}
const error = new ConnectError(message !== null && message !== void 0 ? message : "", code, undefined, metadata);
const error = new ConnectError(message !== null && message !== void 0 ? message : "", code, metadata);
if ("details" in jsonValue && Array.isArray(jsonValue.details)) {

@@ -101,0 +98,0 @@ for (const detail of jsonValue.details) {

@@ -238,5 +238,5 @@ // Copyright 2021-2023 Buf Technologies, Inc.

if (!(code in Code)) {
return new ConnectError(`invalid grpc-status: ${value}`, Code.Internal, undefined, header);
return new ConnectError(`invalid grpc-status: ${value}`, Code.Internal, header);
}
return new ConnectError(decodeURIComponent((_a = header.get("grpc-message")) !== null && _a !== void 0 ? _a : ""), code, undefined, header);
return new ConnectError(decodeURIComponent((_a = header.get("grpc-message")) !== null && _a !== void 0 ? _a : ""), code, header);
}

@@ -254,3 +254,3 @@ function extractDetailsError(header) {

}
const error = new ConnectError(status.message, status.code, undefined, header);
const error = new ConnectError(status.message, status.code, header);
error.details.push(...status.details);

@@ -257,0 +257,0 @@ return error;

@@ -43,8 +43,2 @@ import { Code } from "./code.js";

constructor(message: string, code?: Code, metadata?: HeadersInit);
/**
* @deprecated We do not support providing error details in the constructor.
* This signature was left here by accident, and will be removed in the next
* release.
*/
constructor(message: string, code?: Code, details?: AnyMessage[], metadata?: HeadersInit);
}

@@ -51,0 +45,0 @@ /**

{
"name": "@bufbuild/connect-web",
"version": "0.6.0",
"version": "0.7.0",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "repository": {

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