@bufbuild/connect-web
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -40,3 +40,3 @@ "use strict"; | ||
this.code = code; | ||
this.metadata = new Headers(metadata); | ||
this.metadata = new Headers(metadata !== null && metadata !== void 0 ? metadata : {}); | ||
this.details = []; | ||
@@ -48,3 +48,3 @@ } | ||
const typeRegistry = "typeName" in typeOrRegistry | ||
? protobuf_1.TypeRegistry.from(typeOrRegistry, ...moreTypes) | ||
? (0, protobuf_1.createRegistry)(typeOrRegistry, ...moreTypes) | ||
: typeOrRegistry; | ||
@@ -102,3 +102,7 @@ const details = []; | ||
for (const detail of jsonValue.details) { | ||
if (detail === null || typeof detail != "object" || Array.isArray(detail) || typeof detail.type != "string" || typeof detail.value != "string") { | ||
if (detail === null || | ||
typeof detail != "object" || | ||
Array.isArray(detail) || | ||
typeof detail.type != "string" || | ||
typeof detail.value != "string") { | ||
throw newParseError(detail, `.details`); | ||
@@ -105,0 +109,0 @@ } |
@@ -184,3 +184,3 @@ "use strict"; | ||
function createConnectRequestHeaders(headers, timeoutMs, methodKind, useBinaryFormat) { | ||
const result = new Headers(headers); | ||
const result = new Headers(headers !== null && headers !== void 0 ? headers : {}); | ||
let type = "application/"; | ||
@@ -262,4 +262,6 @@ if (methodKind != protobuf_1.MethodKind.Unary) { | ||
} | ||
const error = "error" in jsonValue ? (0, connect_error_js_1.connectErrorFromJson)(jsonValue.error, metadata) : undefined; | ||
const error = "error" in jsonValue | ||
? (0, connect_error_js_1.connectErrorFromJson)(jsonValue.error, metadata) | ||
: undefined; | ||
return { metadata, error }; | ||
} |
@@ -48,2 +48,5 @@ "use strict"; | ||
} | ||
if (header !== undefined && buffer.byteLength >= header.length + 5) { | ||
break; | ||
} | ||
const result = await reader.read(); | ||
@@ -54,5 +57,2 @@ if (result.done) { | ||
append(result.value); | ||
if (header !== undefined && buffer.byteLength >= header.length + 5) { | ||
break; | ||
} | ||
} | ||
@@ -59,0 +59,0 @@ if (header === undefined) { |
@@ -185,3 +185,3 @@ "use strict"; | ||
function createGrpcWebRequestHeaders(headers, timeoutMs) { | ||
const result = new Headers(headers); | ||
const result = new Headers(headers !== null && headers !== void 0 ? headers : {}); | ||
// We provide the most explicit description for our content type. | ||
@@ -188,0 +188,0 @@ // Note that we do not support the grpc-web-text format. |
@@ -15,3 +15,3 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
import { Code, codeFromString, codeToString } from "./code.js"; | ||
import { Any, proto3, protoBase64, TypeRegistry } from "@bufbuild/protobuf"; | ||
import { Any, createRegistry, proto3, protoBase64, } from "@bufbuild/protobuf"; | ||
/** | ||
@@ -38,3 +38,3 @@ * ConnectError captures three pieces of information: a Code, an error | ||
this.code = code; | ||
this.metadata = new Headers(metadata); | ||
this.metadata = new Headers(metadata !== null && metadata !== void 0 ? metadata : {}); | ||
this.details = []; | ||
@@ -45,3 +45,3 @@ } | ||
const typeRegistry = "typeName" in typeOrRegistry | ||
? TypeRegistry.from(typeOrRegistry, ...moreTypes) | ||
? createRegistry(typeOrRegistry, ...moreTypes) | ||
: typeOrRegistry; | ||
@@ -98,3 +98,7 @@ const details = []; | ||
for (const detail of jsonValue.details) { | ||
if (detail === null || typeof detail != "object" || Array.isArray(detail) || typeof detail.type != "string" || typeof detail.value != "string") { | ||
if (detail === null || | ||
typeof detail != "object" || | ||
Array.isArray(detail) || | ||
typeof detail.type != "string" || | ||
typeof detail.value != "string") { | ||
throw newParseError(detail, `.details`); | ||
@@ -101,0 +105,0 @@ } |
@@ -180,3 +180,3 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
function createConnectRequestHeaders(headers, timeoutMs, methodKind, useBinaryFormat) { | ||
const result = new Headers(headers); | ||
const result = new Headers(headers !== null && headers !== void 0 ? headers : {}); | ||
let type = "application/"; | ||
@@ -258,4 +258,6 @@ if (methodKind != MethodKind.Unary) { | ||
} | ||
const error = "error" in jsonValue ? connectErrorFromJson(jsonValue.error, metadata) : undefined; | ||
const error = "error" in jsonValue | ||
? connectErrorFromJson(jsonValue.error, metadata) | ||
: undefined; | ||
return { metadata, error }; | ||
} |
@@ -45,2 +45,5 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
} | ||
if (header !== undefined && buffer.byteLength >= header.length + 5) { | ||
break; | ||
} | ||
const result = await reader.read(); | ||
@@ -51,5 +54,2 @@ if (result.done) { | ||
append(result.value); | ||
if (header !== undefined && buffer.byteLength >= header.length + 5) { | ||
break; | ||
} | ||
} | ||
@@ -56,0 +56,0 @@ if (header === undefined) { |
@@ -181,3 +181,3 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
function createGrpcWebRequestHeaders(headers, timeoutMs) { | ||
const result = new Headers(headers); | ||
const result = new Headers(headers !== null && headers !== void 0 ? headers : {}); | ||
// We provide the most explicit description for our content type. | ||
@@ -184,0 +184,0 @@ // Note that we do not support the grpc-web-text format. |
{ | ||
"name": "@bufbuild/connect-web", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "Apache-2.0", | ||
@@ -21,12 +21,8 @@ "repository": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"default": "./dist/esm/index.js" | ||
"require": "./dist/cjs/index.js" | ||
}, | ||
"main": "./dist/esm/index.js", | ||
"main": "./dist/cjs/index.js", | ||
"peerDependencies": { | ||
"@bufbuild/protobuf": "0.0.10" | ||
"@bufbuild/protobuf": "0.1.0" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.7.4" | ||
}, | ||
"files": [ | ||
@@ -33,0 +29,0 @@ "dist/**/" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153333
0
3520
9