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

@protobuf-ts/twirp-transport

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@protobuf-ts/twirp-transport - npm Package Compare versions

Comparing version 1.0.0-alpha.28 to 1.0.0-alpha.29

14

build/commonjs/twirp-format.js

@@ -23,7 +23,11 @@ "use strict";

headers.set('Content-Type', sendJson ? "application/json" : "application/protobuf");
headers.set('Accept', sendJson ? "application/json" : "application/protobuf, application/json");
return headers;
}
exports.createTwirpRequestHeader = createTwirpRequestHeader;
// treat this as a twirp error
// see https://twitchtv.github.io/twirp/docs/spec_v5.html
/**
* Parse Twirp error message from JSON and create RpcError from the Twirp error.
*
* see https://twitchtv.github.io/twirp/docs/spec_v5.html
*/
function parseTwirpErrorResponse(json) {

@@ -42,2 +46,6 @@ if (!runtime_1.isJsonObject(json) || typeof json.code !== "string" || typeof json.msg !== "string")

exports.parseTwirpErrorResponse = parseTwirpErrorResponse;
/**
* Parses fetch API response headers to RpcMetaData.
* Drops the headers Content-Type and Content-Length.
*/
function parseMetadataFromResponseHeaders(headers) {

@@ -48,2 +56,4 @@ let meta = {};

return;
if (key.toLowerCase() === 'content-length')
return;
if (meta.hasOwnProperty(key))

@@ -50,0 +60,0 @@ meta[key].push(value);

10

build/commonjs/twirp-transport.js

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

unary(service, method, input, options) {
var _a, _b, _c, _d, _e, _f, _g;
let opt = options, AbortControllerCtor = (_b = (_a = opt.fetchApi) === null || _a === void 0 ? void 0 : _a.AbortController) !== null && _b !== void 0 ? _b : globalThis.AbortController, HeadersCtor = (_d = (_c = opt.fetchApi) === null || _c === void 0 ? void 0 : _c.Headers) !== null && _d !== void 0 ? _d : globalThis.Headers, fetchFn = (_f = (_e = opt.fetchApi) === null || _e === void 0 ? void 0 : _e.fetch) !== null && _f !== void 0 ? _f : globalThis.fetch, url = this.makeUrl(service, method, opt), requestBody = opt.sendJson ? method.I.toJsonString(input, opt) : method.I.toBinary(input), abort = new AbortControllerCtor(), defHeader = new runtime_rpc_1.Deferred(), defMessage = new runtime_rpc_1.Deferred(), defStatus = new runtime_rpc_1.Deferred(), defTrailer = new runtime_rpc_1.Deferred();
fetchFn(url, {
var _a;
let opt = options, url = this.makeUrl(service, method, opt), requestBody = opt.sendJson ? method.I.toJsonString(input, opt) : method.I.toBinary(input), abort = new globalThis.AbortController(), defHeader = new runtime_rpc_1.Deferred(), defMessage = new runtime_rpc_1.Deferred(), defStatus = new runtime_rpc_1.Deferred(), defTrailer = new runtime_rpc_1.Deferred();
globalThis.fetch(url, {
method: 'POST',
headers: twirp_format_1.createTwirpRequestHeader(new HeadersCtor(), !!opt.sendJson, opt.meta),
headers: twirp_format_1.createTwirpRequestHeader(new globalThis.Headers(), !!opt.sendJson, opt.meta),
body: requestBody,

@@ -77,3 +77,3 @@ signal: abort.signal,

});
return new runtime_rpc_1.UnaryCall(service, method, (_g = opt.meta) !== null && _g !== void 0 ? _g : {}, input, defHeader.promise, defMessage.promise, defStatus.promise, defTrailer.promise, () => abort.abort());
return new runtime_rpc_1.UnaryCall(service, method, (_a = opt.meta) !== null && _a !== void 0 ? _a : {}, input, defHeader.promise, defMessage.promise, defStatus.promise, defTrailer.promise, () => abort.abort());
}

@@ -80,0 +80,0 @@ /**

@@ -20,6 +20,10 @@ import { isJsonObject } from "@protobuf-ts/runtime";

headers.set('Content-Type', sendJson ? "application/json" : "application/protobuf");
headers.set('Accept', sendJson ? "application/json" : "application/protobuf, application/json");
return headers;
}
// treat this as a twirp error
// see https://twitchtv.github.io/twirp/docs/spec_v5.html
/**
* Parse Twirp error message from JSON and create RpcError from the Twirp error.
*
* see https://twitchtv.github.io/twirp/docs/spec_v5.html
*/
export function parseTwirpErrorResponse(json) {

@@ -37,2 +41,6 @@ if (!isJsonObject(json) || typeof json.code !== "string" || typeof json.msg !== "string")

}
/**
* Parses fetch API response headers to RpcMetaData.
* Drops the headers Content-Type and Content-Length.
*/
export function parseMetadataFromResponseHeaders(headers) {

@@ -43,2 +51,4 @@ let meta = {};

return;
if (key.toLowerCase() === 'content-length')
return;
if (meta.hasOwnProperty(key))

@@ -45,0 +55,0 @@ meta[key].push(value);

@@ -19,7 +19,7 @@ import { createTwirpRequestHeader, parseMetadataFromResponseHeaders, parseTwirpErrorResponse } from "./twirp-format";

unary(service, method, input, options) {
var _a, _b, _c, _d, _e, _f, _g;
let opt = options, AbortControllerCtor = (_b = (_a = opt.fetchApi) === null || _a === void 0 ? void 0 : _a.AbortController) !== null && _b !== void 0 ? _b : globalThis.AbortController, HeadersCtor = (_d = (_c = opt.fetchApi) === null || _c === void 0 ? void 0 : _c.Headers) !== null && _d !== void 0 ? _d : globalThis.Headers, fetchFn = (_f = (_e = opt.fetchApi) === null || _e === void 0 ? void 0 : _e.fetch) !== null && _f !== void 0 ? _f : globalThis.fetch, url = this.makeUrl(service, method, opt), requestBody = opt.sendJson ? method.I.toJsonString(input, opt) : method.I.toBinary(input), abort = new AbortControllerCtor(), defHeader = new Deferred(), defMessage = new Deferred(), defStatus = new Deferred(), defTrailer = new Deferred();
fetchFn(url, {
var _a;
let opt = options, url = this.makeUrl(service, method, opt), requestBody = opt.sendJson ? method.I.toJsonString(input, opt) : method.I.toBinary(input), abort = new globalThis.AbortController(), defHeader = new Deferred(), defMessage = new Deferred(), defStatus = new Deferred(), defTrailer = new Deferred();
globalThis.fetch(url, {
method: 'POST',
headers: createTwirpRequestHeader(new HeadersCtor(), !!opt.sendJson, opt.meta),
headers: createTwirpRequestHeader(new globalThis.Headers(), !!opt.sendJson, opt.meta),
body: requestBody,

@@ -74,3 +74,3 @@ signal: abort.signal,

});
return new UnaryCall(service, method, (_g = opt.meta) !== null && _g !== void 0 ? _g : {}, input, defHeader.promise, defMessage.promise, defStatus.promise, defTrailer.promise, () => abort.abort());
return new UnaryCall(service, method, (_a = opt.meta) !== null && _a !== void 0 ? _a : {}, input, defHeader.promise, defMessage.promise, defStatus.promise, defTrailer.promise, () => abort.abort());
}

@@ -77,0 +77,0 @@ /**

@@ -7,4 +7,13 @@ import { JsonValue } from "@protobuf-ts/runtime";

export declare function createTwirpRequestHeader(headers: Headers, sendJson: boolean, meta?: RpcMetadata): Headers;
/**
* Parse Twirp error message from JSON and create RpcError from the Twirp error.
*
* see https://twitchtv.github.io/twirp/docs/spec_v5.html
*/
export declare function parseTwirpErrorResponse(json: JsonValue): RpcError;
/**
* Parses fetch API response headers to RpcMetaData.
* Drops the headers Content-Type and Content-Length.
*/
export declare function parseMetadataFromResponseHeaders(headers: Headers): RpcMetadata;
//# sourceMappingURL=twirp-format.d.ts.map

@@ -8,2 +8,4 @@ import { RpcOptions } from "@protobuf-ts/runtime-rpc";

*
* If you need the "twirp" path prefix, you must add it yourself.
*
* Example: `baseUrl: "https://example.com/twirp"`

@@ -17,9 +19,2 @@ *

* For Twirp, method names are CamelCased just as they would be in Go.
* To speak with a Twirp server, set this option to `true` unless your
* method names are already compatible or your Twirp server is smart
* enough to figure them out.
*/
useCamelCaseMethodName?: boolean;
/**
* For Twirp, method names are CamelCased just as they would be in Go.
* To use the original method name as defined in the .proto, set this

@@ -34,16 +29,3 @@ * option to `true`.

sendJson?: boolean;
/**
* By default, the `TwirpFetchTransport` expects the fetch API in
* `globalThis`.
*
* In Node.js and other environments where the fetch API is not available,
* you have to provide a polyfill in `globalThis` or in this option.
* See [node-fetch](https://github.com/node-fetch/node-fetch) for a polyfill.
*/
fetchApi?: {
fetch: typeof fetch;
AbortController: typeof AbortController;
Headers: typeof Headers;
};
}
//# sourceMappingURL=twirp-options.d.ts.map
{
"name": "@protobuf-ts/twirp-transport",
"version": "1.0.0-alpha.28",
"version": "1.0.0-alpha.29",
"description": "Twirp transport for code generated by the protobuf-ts plugin.",

@@ -42,6 +42,6 @@ "license": "Apache-2.0",

"dependencies": {
"@protobuf-ts/runtime": "^1.0.0-alpha.28",
"@protobuf-ts/runtime-rpc": "^1.0.0-alpha.28"
"@protobuf-ts/runtime": "^1.0.0-alpha.29",
"@protobuf-ts/runtime-rpc": "^1.0.0-alpha.29"
},
"gitHead": "9c43da2e5a5f29d0d0f163f83b78532daace8b19"
"gitHead": "dd4a672e055b7c8fb3822a040c0387fadd12421f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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