@pbkit/grpc-web-client
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -34,2 +34,6 @@ import type { RpcClientImpl } from "@pbkit/runtime/rpc"; | ||
} | ||
export declare class GrpcWebError extends Error { | ||
status: Status; | ||
constructor(status: Status, message: string); | ||
} | ||
export declare function createGrpcWebClientImpl(config: CreateGrpcWebClientImplConfig): RpcClientImpl<Metadata, Header, Trailer>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createGrpcWebClientImpl = exports.Status = void 0; | ||
exports.createGrpcWebClientImpl = exports.GrpcWebError = exports.Status = void 0; | ||
const event_buffer_1 = require("@pbkit/runtime/async/event-buffer"); | ||
@@ -27,2 +27,9 @@ const observer_1 = require("@pbkit/runtime/async/observer"); | ||
})(Status = exports.Status || (exports.Status = {})); | ||
class GrpcWebError extends Error { | ||
constructor(status, message) { | ||
super(message); | ||
this.status = status; | ||
} | ||
} | ||
exports.GrpcWebError = GrpcWebError; | ||
function createGrpcWebClientImpl(config) { | ||
@@ -55,9 +62,15 @@ return (methodDescriptor) => { | ||
grpcClient.onMessage(eventBuffer.push); | ||
grpcClient.onEnd((status, statusMessage, trailer) => { | ||
grpcClient.onEnd((_status, statusMessage, trailer) => { | ||
const status = String(_status); | ||
if (_status > grpc_web_1.grpc.Code.Canceled) { | ||
eventBuffer.error(new GrpcWebError(status, statusMessage)); | ||
} | ||
else { | ||
eventBuffer.finish(); | ||
} | ||
trailerPromise.resolve({ | ||
...grpcMetadataToRecord(trailer), | ||
status: status.toString(), | ||
status, | ||
statusMessage, | ||
}); | ||
eventBuffer.finish(); | ||
}); | ||
@@ -64,0 +77,0 @@ (async () => { |
{ | ||
"name": "@pbkit/grpc-web-client", | ||
"packageManager": "yarn@3.1.1", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "pbkit grpc web client", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1", | ||
"@pbkit/runtime": "^0.0.21", | ||
"@pbkit/runtime": "^0.0.35", | ||
"google-protobuf": "^3.18.0-rc.2" | ||
@@ -24,0 +24,0 @@ }, |
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
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
6395
149
0
+ Added@pbkit/runtime@0.0.35(transitive)
- Removed@pbkit/runtime@0.0.21(transitive)
Updated@pbkit/runtime@^0.0.35