Commit Graph

249 Commits

Author SHA1 Message Date
Eryu Xia 7ea072a94d
Add abort API support for promise calls (#1478)
For #1478

- Also removed CallOptions in favor of PromiseCallOptions (to align with internal codebase)
- Also updated chrome to 112.0.5615.165 for supporting abort with reason.
2025-04-20 14:55:04 -07:00
Noel Kim (김민혁) 7bd92c665a
fix: format of typescript definition (#1463) 2024-09-20 17:25:42 -07:00
Benjamin Peterson 2c39859be8
Upgrade protobuf to 27.1 and modernize codegen using new APIs (e.g. has_presence()) (#1445)
Fixes https://github.com/grpc/grpc-web/issues/1437.
2024-06-24 20:58:54 -07:00
Eryu Xia ce8aa02c7a
Fix response return type for grpcwebclientbase_test (#1433) 2024-06-12 11:01:19 -07:00
Eryu Xia de3557acc3
Bump version to 1.5.0 (#1382) 2023-11-08 15:39:29 -08:00
Eryu Xia db386b99e6
Internal code sync (#1381) 2023-11-07 16:24:28 -08:00
Andrew Benton 1ab0bdc25b
feat(typescript): mark some `metadata` parameters as optional (#1369)
Resolves https://github.com/grpc/grpc-web/issues/1368
2023-10-16 14:35:11 -07:00
Red Daly 3cd7e0d434
Update ES6 .d.ts imports with comment about corresponding proto import path. (#1330)
https://github.com/grpc/grpc-web/pull/1313 updated the code generator to print a
`proto import: "foo/bar.proto"` suffix for each import statement for the
generated gRPC-web client code. This commit updates ensures the .d.ts file
output by grpc-web contains the same type of comments.
2023-10-05 13:57:37 -07:00
Eryu Xia c4f0905288
Allow mixed-case headers (#1334) 2023-05-14 03:12:19 -07:00
Red Daly e4084fd259
Update ES6 imports with comment about corresponding proto import path. (#1313)
I was experiencing a long import path in the generated code that doesn't
work. Outputting the proto file that corresponds to a JS import is helpful for
both diagnosing the issue and writing a wrapper for altering the import path to
my satisfaction.

Before:

```js
import * as github_com_gonzojive_rules_ts_proto_example_prefix_greeting_pb from '../../../../../github.com/gonzojive/rules_ts_proto/example/prefix/greeting_pb';
```

After:

```js
import * as github_com_gonzojive_rules_ts_proto_example_prefix_greeting_pb from '../../../../../github.com/gonzojive/rules_ts_proto/example/prefix/greeting_pb'; // proto import: "github.com/gonzojive/rules_ts_proto/example/prefix/greeting.proto"
```
2023-03-26 10:09:35 -07:00
Eryu Xia 0ec55aaad7
Bump version to 1.4.2 (#1298) 2022-10-28 14:17:52 -07:00
pro-wh 6577c66b53
GrpcWebClientBase: clean up !useUnaryResponse callback args (#1297) 2022-10-26 16:08:34 -07:00
pro-wh e11903b337
GrpcWebClientReadableStream: keep falsy data (#1230) 2022-10-25 00:49:54 -07:00
Eryu Xia 4974a7b5a9
Expose getName() in MethodDescriptor and fix TS definitions. (#1289) 2022-09-30 16:28:51 -07:00
Eryu Xia ac17547d78
Bump version to 1.4.1 (#1287) 2022-09-27 22:04:46 -07:00
Eryu Xia 8a123090f8
Fix duplicate dot in enum name (#1286) 2022-09-26 17:00:57 -07:00
Eryu Xia d1d99eb80b
Internal code sync (#1280) 2022-09-26 14:12:01 -07:00
Eryu Xia 17e6a81709
Bump protoc plugin version to `1.4.0` (#1282) 2022-09-23 13:07:22 -07:00
Eryu Xia b3d7dbdd5e
Fix Enum with module in generated TS interface. (#1278)
Verified with the example in https://github.com/grpc/grpc-web/issues/1271

// enum.proto
```proto
syntax = "proto3";

enum DocEnum {
    DOC_ENUM_PDF = 0;
    DOC_ENUM_HTML = 1;
}
```

// test.proto
```proto
syntax = "proto3";

import "enum.proto";

package Test;

message HelloRequest {
    DocEnum doc = 1;
}
```

generate:
```
protoc --proto_path=. --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=typescript,mode=grpcwebtext:. *.proto
```
2022-09-16 16:26:10 -07:00
Eryu Xia a5bd765d1d
Fix code and documentation to pass `deadline` metadata as a String. (#1269)
- As Metadata is a <string, string> map per Closure and TS definition.
2022-08-30 16:08:35 -07:00
River 7fe18d1e08
Remove Trailing Slashes from Hostname (#1254)
Hostnames can be passed in with trailing slashes. Since we blindly concat a path with a leading slash, paths like http://hostname//$rpc/path (note the double slash before $rpc) are possible. The duplicated slash can cause issues down the line, especially if the path is separated from the host in requests.

Browsers/servers generally allow double slashes, and while they are valid syntactically under the RFC spec, there is no specified semantic meaning. So a server could interpret a path like http://hostname//$rpc/path as equivalent to http://hostname/$rpc/path (most common), as a separate path with an empty path component before /$rpc, or as something else. The problem is several interpretations are equally valid under the spec and it's implementation-dependent which is used.

Additionally, the path can be separate from the host in a request depending on whether it's in origin form versus absolute form (see https://datatracker.ietf.org/doc/html/rfc7230#section-5.3). In absolute form (GET http://hostname//$rpc/path), the path and host are clear. In origin form (GET //$rpc/path, Host: hostname), it is still clear to us looking at it, but may not be clear to a server. For example the server may think the //$rpc/path is in absolute form due to the double slash, and thus parse it as host: $rpc, path: /path. This is especially problematic as https://datatracker.ietf.org/doc/html/rfc7230#section-5.4 says:

"When a proxy receives a request with an absolute-form of request-target, the proxy MUST ignore the received Host header field (if any) and instead replace it with the host information of the request-target. A proxy that forwards such a request MUST generate a new Host field-value based on the received request-target rather than forward the received Host field-value."

Which means a proxy would corrupt the request when in this format by overwriting the old host value with $rpc

This parsing concern is not idle speculation either. Java's main URI class (https://docs.oracle.com/javase/8/docs/api/java/net/URI.html), parses a URI of the form //$rpc/path as having host/authority $rpc and path /path. Real bugs are observed from usage of this in commonly used libraries such as Netty, and various proxies.

Basically, this doesn't cause issues in the most common cases, but is a bug waiting to happen in many other edge cases, and affects widely used infrastructure.
2022-06-28 15:30:43 -07:00
Zhao 3ca2e70edf
Use Zig to build aarch64 binaries (#1249) 2022-06-06 12:20:21 -07:00
Hein Meling 1779661dde
Add version flag and version info in generated code (#1231)
Example output (edited):

```javascript
"use strict";
/**
 * @fileoverview gRPC-Web generated client stub for ag
 * @enhanceable
 * @public
 */
exports.__esModule = true;
exports.AutograderServiceClient = void 0;
// Code generated by protoc-gen-grpc-web. DO NOT EDIT.
// versions:
//  protoc-gen-grpc-web v1.3.1
//  protoc              v3.19.4
// source: ag/ag.proto
/* eslint-disable */
// @ts-nocheck
```
2022-04-29 16:36:38 -07:00
Eryu Xia a1b706ade0
Internal code sync (#1225) 2022-04-21 16:18:19 -07:00
j-k 78313a239a
Make the static flag overridable (#1210) 2022-03-01 20:44:51 -08:00
Eryu Xia 81ce4c52ff
Revert "Expose MethodDescriptor's public methods (#1160)" (#1199)
This reverts commit 97baed4dbe.
2022-01-31 17:50:44 -08:00
Eryu Xia 11370185b6
Internal code sync (#1194) 2022-01-28 23:35:44 -08:00
Matt Nathan eb313c1f3d
Correctly support proto3 optional fields in commonjs+dts .d.ts output (#1184)
* Correctly support proto3 optional fields in commonjs+dts .d.ts output

Fixes #1072

* Use has_optional_keyword instead of is_optional

* Improve the readability of the condition guarding hasXxx .d.ts field generation.
2022-01-28 12:41:59 -08:00
Lukas Möller 6b1d1e97a9
Fix missing TypeScript return type for `serverStreaming` calls. (#1167)
* Add strongly types to MethodDescriptor constructor
* Adds return type declaration to server streaming call

Co-authored-by: Eryu Xia <eryu@google.com>
2021-11-19 15:15:34 -08:00
Cirillo Ferreira 97baed4dbe
Expose MethodDescriptor's public methods (#1160)
Co-authored-by: Eryu Xia <eryu@google.com>
2021-11-19 01:44:39 -08:00
Eryu Xia 1efe741695
Add missing exports from RpcError and add test. (#1166) 2021-11-12 11:55:38 -08:00
Eryu Xia 5831a96b56
Update generator to stop mentioning methodInfo (in TS files) (#1152) 2021-10-20 16:21:17 -07:00
Eryu Xia 4835cb6df8
Update g++ flags based on MacOS v.s. Linux (#1147) 2021-10-13 20:27:55 -07:00
Eryu Xia 4676d14333
Adding `-static` to generator g++ build flag (#1146) 2021-10-13 18:25:59 -07:00
Eryu Xia 3956560ad0
Redo #1063 - Also set timeout on HTTP request if deadline for grpc call is set. (#1142) 2021-09-28 18:44:18 -07:00
Eryu Xia f1fe57473f
Internal code sync (#1140) 2021-09-28 10:48:20 -07:00
Eryu Xia 627e33718d
Internal code sync (#1139)
- Internal code sync (up to Aug 4, 2021 for now..) & relevant improvements. :)
- Updated Closure dependency to 20210808.0.0 (necessary dependency)
2021-09-22 16:53:00 -07:00
Eryu Xia 78ddf996d8
Clean up Javascript-related Bazel rules. (#1138) 2021-09-21 23:16:28 -07:00
Eryu Xia 32fe12459b
Revamp Closure JsUnit tests runtime and optimize test/build flows. (#1137) 2021-09-21 15:27:21 -07:00
06kellyjac a56e7212a3 Allow for custom install prefix
Also create the dir if it doesn't exist
2021-08-11 14:01:24 -07:00
Stanley Cheung 3c74b0da5c Internal code sync 2021-08-03 15:05:08 -07:00
Yannic Bonenberger 6c1a2ceda1 Also set timeout on HTTP request if deadline for grpc call is set 2021-05-10 13:09:14 -07:00
Stanley Cheung 5a2ab7a75f Linter changes 2021-03-13 23:51:20 -08:00
Stanley Cheung 7afe497d8f Internal code sync 2021-03-13 23:30:51 -08:00
Warren He 201c689222 Allow null response 2021-01-22 17:03:41 -08:00
Stanley Cheung 042ccd160e fix build 2021-01-13 23:49:23 -08:00
Stanley Cheung 3fc20fbaf5 Code sync from internal code base 2021-01-13 23:49:23 -08:00
Stanley Cheung 2e3e8d2c50 Internal code sync 2020-11-20 21:10:26 -08:00
Stanley Cheung eecc629b00 Internal code sync 2020-11-20 21:10:26 -08:00
Stanley Cheung cce2f19faa Add ClientOptions class 2020-10-12 15:06:28 -07:00