Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: @grpc/grpc-js @ 0.3.6 .. 0.4.0

build/src/call-credentials-filter.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const filter_1 = require("./filter");
class CallCredentialsFilter extends filter_1.BaseFilter {

build/src/call-credentials.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const metadata_1 = require("./metadata");
/**

build/src/call.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const stream_1 = require("stream");

build/src/call-stream.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const http2 = require("http2");
const stream_1 = require("stream");

build/src/channel-credentials.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const tls_1 = require("tls");
const call_credentials_1 = require("./call-credentials");

build/src/channel.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const http2 = require("http2");

build/src/channel-options.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This is for checking provided options at runtime. This is an object for

build/src/client.d.ts

@@ -1,19 +1,18 @@
/// <reference types="node" />
import { ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream, ServiceError } from './call';
import { CallCredentials } from './call-credentials';
-import { Call, Deadline } from './call-stream';
+import { Deadline } from './call-stream';
import { Channel } from './channel';
import { ChannelCredentials } from './channel-credentials';
import { ChannelOptions } from './channel-options';
import { Metadata } from './metadata';
-export declare const kChannel: unique symbol;
+declare const CHANNEL_SYMBOL: unique symbol;
export interface UnaryCallback<ResponseType> {
(err: ServiceError | null, value?: ResponseType): void;
}
export interface CallOptions {
deadline?: Deadline;
host?: string;
- parent?: Call;
propagate_flags?: number;
credentials?: CallCredentials;
}
@@ -26,7 +25,7 @@
* clients.
*/
export declare class Client {
- private readonly [kChannel];
+ private readonly [CHANNEL_SYMBOL];
constructor(address: string, credentials: ChannelCredentials, options?: ClientOptions);
close(): void;
getChannel(): Channel;
@@ -47,3 +46,4 @@
makeBidiStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options?: CallOptions): ClientDuplexStream<RequestType, ResponseType>;
makeBidiStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options?: CallOptions): ClientDuplexStream<RequestType, ResponseType>;
}
+export {};

build/src/client.js

@@ -1,12 +1,26 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const call_1 = require("./call");
const channel_1 = require("./channel");
const constants_1 = require("./constants");
const metadata_1 = require("./metadata");
-// This symbol must be exported (for now).
-// See: https://github.com/Microsoft/TypeScript/issues/20080
-exports.kChannel = Symbol();
+const CHANNEL_SYMBOL = Symbol();
/**
* A generic gRPC client. Primarily useful as a base class for all generated
* clients.
@@ -14,21 +28,21 @@
class Client {
constructor(address, credentials, options = {}) {
if (options.channelOverride) {
- this[exports.kChannel] = options.channelOverride;
+ this[CHANNEL_SYMBOL] = options.channelOverride;
}
else if (options.channelFactoryOverride) {
- this[exports.kChannel] =
+ this[CHANNEL_SYMBOL] =
options.channelFactoryOverride(address, credentials, options);
}
else {
- this[exports.kChannel] = new channel_1.Http2Channel(address, credentials, options);
+ this[CHANNEL_SYMBOL] = new channel_1.Http2Channel(address, credentials, options);
}
}
close() {
- this[exports.kChannel].close();
+ this[CHANNEL_SYMBOL].close();
}
getChannel() {
- return this[exports.kChannel];
+ return this[CHANNEL_SYMBOL];
}
waitForReady(deadline, callback) {
const checkState = (err) => {
@@ -38,7 +52,7 @@
}
let newState;
try {
- newState = this[exports.kChannel].getConnectivityState(true);
+ newState = this[CHANNEL_SYMBOL].getConnectivityState(true);
}
catch (e) {
callback(new Error('The channel has been closed'));
@@ -49,7 +63,7 @@
}
else {
try {
- this[exports.kChannel].watchConnectivityState(newState, deadline, checkState);
+ this[CHANNEL_SYMBOL].watchConnectivityState(newState, deadline, checkState);
}
catch (e) {
callback(new Error('The channel has been closed'));
@@ -113,7 +127,7 @@
makeUnaryRequest(method, serialize, deserialize, argument, metadata, options, callback) {
({ metadata, options, callback } =
this.checkOptionalUnaryResponseArguments(metadata, options, callback));
- const call = this[exports.kChannel].createCall(method, options.deadline, options.host, options.parent, options.propagate_flags);
+ const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
@@ -128,7 +142,7 @@
makeClientStreamRequest(method, serialize, deserialize, metadata, options, callback) {
({ metadata, options, callback } =
this.checkOptionalUnaryResponseArguments(metadata, options, callback));
- const call = this[exports.kChannel].createCall(method, options.deadline, options.host, options.parent, options.propagate_flags);
+ const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
@@ -161,7 +175,7 @@
}
makeServerStreamRequest(method, serialize, deserialize, argument, metadata, options) {
({ metadata, options } = this.checkMetadataAndOptions(metadata, options));
- const call = this[exports.kChannel].createCall(method, options.deadline, options.host, options.parent, options.propagate_flags);
+ const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
@@ -174,7 +188,7 @@
}
makeBidiStreamRequest(method, serialize, deserialize, metadata, options) {
({ metadata, options } = this.checkMetadataAndOptions(metadata, options));
- const call = this[exports.kChannel].createCall(method, options.deadline, options.host, options.parent, options.propagate_flags);
+ const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}

build/src/compression-filter.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const zlib = require("zlib");
const filter_1 = require("./filter");

build/src/constants.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
var Status;
(function (Status) {

build/src/deadline-filter.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const channel_1 = require("./channel");
const constants_1 = require("./constants");

build/src/events.js

@@ -1,3 +1,19 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=events.js.map
\ No newline at end of file

build/src/filter.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
class BaseFilter {
async sendMetadata(metadata) {

build/src/filter-stack.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
class FilterStack {
constructor(filters) {

build/src/index.d.ts

@@ -1,9 +1,14 @@
/// <reference types="node" />
-import { Channel } from './channel';
-import { Client } from './client';
+import { ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream, ServiceError } from './call';
+import { CallCredentials } from './call-credentials';
+import { Deadline, StatusObject } from './call-stream';
+import { Channel, ConnectivityState, Http2Channel } from './channel';
+import { ChannelCredentials } from './channel-credentials';
+import { CallOptions, Client } from './client';
import { LogVerbosity, Status } from './constants';
-import { loadPackageDefinition, makeClientConstructor } from './make-client';
+import { Deserialize, loadPackageDefinition, makeClientConstructor, Serialize } from './make-client';
import { Metadata } from './metadata';
+import { KeyCertPair, ServerCredentials } from './server-credentials';
import { StatusBuilder } from './status-builder';
export interface OAuth2Client {
getRequestMetadata: (url: string, callback: (err: Error | null, headers?: {
@@ -20,27 +25,36 @@
/**** Metadata ****/
export { Metadata };
/**** Constants ****/
-export { LogVerbosity as logVerbosity, Status as status };
+export { LogVerbosity as logVerbosity, Status as status, ConnectivityState as connectivityState };
/**** Client ****/
-export { Client, loadPackageDefinition, makeClientConstructor, makeClientConstructor as makeGenericClientConstructor, Channel };
+export { Client, loadPackageDefinition, makeClientConstructor, makeClientConstructor as makeGenericClientConstructor, Http2Channel as Channel };
/**
* Close a Client object.
* @param client The client to close.
*/
export declare const closeClient: (client: Client) => void;
export declare const waitForClientReady: (client: Client, deadline: number | Date, callback: (error?: Error | undefined) => void) => void;
+export { ChannelCredentials, CallCredentials, Deadline, Serialize as serialize, Deserialize as deserialize, ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream, CallOptions, StatusObject, ServiceError };
+export declare type Call = ClientUnaryCall | ClientReadableStream<any> | ClientWritableStream<any> | ClientDuplexStream<any, any>;
+export declare type MetadataListener = (metadata: Metadata, next: Function) => void;
+export declare type MessageListener = (message: any, next: Function) => void;
+export declare type StatusListener = (status: StatusObject, next: Function) => void;
+export interface Listener {
+ onReceiveMetadata?: MetadataListener;
+ onReceiveMessage?: MessageListener;
+ onReceiveStatus?: StatusListener;
+}
/**** Unimplemented function stubs ****/
export declare const loadObject: (value: any, options: any) => never;
export declare const load: (filename: any, format: any, options: any) => never;
export declare const setLogger: (logger: Partial<Console>) => void;
export declare const setLogVerbosity: (verbosity: LogVerbosity) => void;
export declare const Server: (options: any) => never;
-export declare const ServerCredentials: {
- createSsl: (rootCerts: any, keyCertPairs: any, checkClientCertificate: any) => never;
- createInsecure: () => never;
-};
+export { ServerCredentials };
+export { KeyCertPair };
export declare const getClientChannel: (client: Client) => Channel;
export { StatusBuilder };
export declare const ListenerBuilder: () => never;
export declare const InterceptorBuilder: () => never;
export declare const InterceptingCall: () => never;
+export { GrpcObject } from './make-client';

build/src/index.js

@@ -1,8 +1,29 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const semver = require("semver");
const call_credentials_1 = require("./call-credentials");
+exports.CallCredentials = call_credentials_1.CallCredentials;
+const channel_1 = require("./channel");
+exports.connectivityState = channel_1.ConnectivityState;
+exports.Channel = channel_1.Http2Channel;
const channel_credentials_1 = require("./channel-credentials");
+exports.ChannelCredentials = channel_credentials_1.ChannelCredentials;
const client_1 = require("./client");
exports.Client = client_1.Client;
const constants_1 = require("./constants");
@@ -15,9 +36,11 @@
exports.makeGenericClientConstructor = make_client_1.makeClientConstructor;
const metadata_1 = require("./metadata");
exports.Metadata = metadata_1.Metadata;
+const server_credentials_1 = require("./server-credentials");
+exports.ServerCredentials = server_credentials_1.ServerCredentials;
const status_builder_1 = require("./status-builder");
exports.StatusBuilder = status_builder_1.StatusBuilder;
-const supportedNodeVersions = '^8.11.2 || >=9.4';
+const supportedNodeVersions = '^8.13.0 || >=10.10.0';
if (!semver.satisfies(process.version, supportedNodeVersions)) {
throw new Error(`@grpc/grpc-js only works on Node ${supportedNodeVersions}`);
}
@@ -114,14 +137,6 @@
exports.Server = (options) => {
throw new Error('Not yet implemented');
};
-exports.ServerCredentials = {
- createSsl: (rootCerts, keyCertPairs, checkClientCertificate) => {
- throw new Error('Not yet implemented');
- },
- createInsecure: () => {
- throw new Error('Not yet implemented');
- }
-};
exports.getClientChannel = (client) => {
return client_1.Client.prototype.getChannel.call(client);
};

build/src/logging.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
let _logger = console;

build/src/make-client.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const client_1 = require("./client");
/**

build/src/metadata.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const LEGAL_KEY_REGEX = /^[0-9a-z_.-]+$/;
const LEGAL_NON_BINARY_VALUE_REGEX = /^[ -~]*$/;

build/src/metadata-status-filter.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
const filter_1 = require("./filter");

build/src/object-stream.js

@@ -1,3 +1,19 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=object-stream.js.map
\ No newline at end of file

build/src/server-call.d.ts

@@ -0,0 +1,59 @@
+/// <reference types="node" />
+import { EventEmitter } from 'events';
+import { Duplex, Readable, Writable } from 'stream';
+import { ServiceError } from './call';
+import { Deserialize, Serialize } from './make-client';
+import { Metadata } from './metadata';
+export declare class ServerUnaryCall<RequestType> extends EventEmitter {
+ private call;
+ metadata: Metadata;
+ cancelled: boolean;
+ request: RequestType | null;
+ constructor(call: ServerCall, metadata: Metadata);
+ getPeer(): string;
+ sendMetadata(responseMetadata: Metadata): void;
+}
+export declare class ServerReadableStream<RequestType> extends Readable {
+ private call;
+ metadata: Metadata;
+ private deserialize;
+ cancelled: boolean;
+ constructor(call: ServerCall, metadata: Metadata, deserialize: Deserialize<RequestType>);
+ getPeer(): string;
+ sendMetadata(responseMetadata: Metadata): void;
+}
+export declare class ServerWritableStream<RequestType, ResponseType> extends Writable {
+ private call;
+ metadata: Metadata;
+ private serialize;
+ cancelled: boolean;
+ request: RequestType | null;
+ constructor(call: ServerCall, metadata: Metadata, serialize: Serialize<ResponseType>);
+ getPeer(): string;
+ sendMetadata(responseMetadata: Metadata): void;
+}
+export declare class ServerDuplexStream<RequestType, ResponseType> extends Duplex {
+ private call;
+ metadata: Metadata;
+ private serialize;
+ private deserialize;
+ cancelled: boolean;
+ constructor(call: ServerCall, metadata: Metadata, serialize: Serialize<ResponseType>, deserialize: Deserialize<RequestType>);
+ getPeer(): string;
+ sendMetadata(responseMetadata: Metadata): void;
+}
+export declare class ServerCall {
+}
+export declare type sendUnaryData<ResponseType> = (error: ServiceError | null, value: ResponseType | null, trailer?: Metadata, flags?: number) => void;
+export declare type handleUnaryCall<RequestType, ResponseType> = (call: ServerUnaryCall<RequestType>, callback: sendUnaryData<ResponseType>) => void;
+export declare type handleClientStreamingCall<RequestType, ResponseType> = (call: ServerReadableStream<RequestType>, callback: sendUnaryData<ResponseType>) => void;
+export declare type handleServerStreamingCall<RequestType, ResponseType> = (call: ServerWritableStream<RequestType, ResponseType>) => void;
+export declare type handleBidiStreamingCall<RequestType, ResponseType> = (call: ServerDuplexStream<RequestType, ResponseType>) => void;
+export declare type HandleCall<RequestType, ResponseType> = handleUnaryCall<RequestType, ResponseType> | handleClientStreamingCall<RequestType, ResponseType> | handleServerStreamingCall<RequestType, ResponseType> | handleBidiStreamingCall<RequestType, ResponseType>;
+export declare type Handler<RequestType, ResponseType> = {
+ func: HandleCall<RequestType, ResponseType>;
+ serialize: Serialize<ResponseType>;
+ deserialize: Deserialize<RequestType>;
+ type: HandlerType;
+};
+export declare type HandlerType = 'bidi' | 'clientStream' | 'serverStream' | 'unary';

build/src/server-call.js

@@ -0,0 +1,91 @@
+"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const events_1 = require("events");
+const stream_1 = require("stream");
+class ServerUnaryCall extends events_1.EventEmitter {
+ constructor(call, metadata) {
+ super();
+ this.call = call;
+ this.metadata = metadata;
+ this.cancelled = false;
+ this.request = null; // TODO(cjihrig): Read the unary request here.
+ }
+ getPeer() {
+ throw new Error('not implemented yet');
+ }
+ sendMetadata(responseMetadata) {
+ throw new Error('not implemented yet');
+ }
+}
+exports.ServerUnaryCall = ServerUnaryCall;
+class ServerReadableStream extends stream_1.Readable {
+ constructor(call, metadata, deserialize) {
+ super();
+ this.call = call;
+ this.metadata = metadata;
+ this.deserialize = deserialize;
+ this.cancelled = false;
+ }
+ getPeer() {
+ throw new Error('not implemented yet');
+ }
+ sendMetadata(responseMetadata) {
+ throw new Error('not implemented yet');
+ }
+}
+exports.ServerReadableStream = ServerReadableStream;
+class ServerWritableStream extends stream_1.Writable {
+ constructor(call, metadata, serialize) {
+ super();
+ this.call = call;
+ this.metadata = metadata;
+ this.serialize = serialize;
+ this.cancelled = false;
+ this.request = null; // TODO(cjihrig): Read the unary request here.
+ }
+ getPeer() {
+ throw new Error('not implemented yet');
+ }
+ sendMetadata(responseMetadata) {
+ throw new Error('not implemented yet');
+ }
+}
+exports.ServerWritableStream = ServerWritableStream;
+class ServerDuplexStream extends stream_1.Duplex {
+ constructor(call, metadata, serialize, deserialize) {
+ super();
+ this.call = call;
+ this.metadata = metadata;
+ this.serialize = serialize;
+ this.deserialize = deserialize;
+ this.cancelled = false;
+ }
+ getPeer() {
+ throw new Error('not implemented yet');
+ }
+ sendMetadata(responseMetadata) {
+ throw new Error('not implemented yet');
+ }
+}
+exports.ServerDuplexStream = ServerDuplexStream;
+// Internal class that wraps the HTTP2 request.
+class ServerCall {
+}
+exports.ServerCall = ServerCall;
+//# sourceMappingURL=server-call.js.map
\ No newline at end of file

build/src/server-credentials.d.ts

@@ -0,0 +1,12 @@
+/// <reference types="node" />
+import { SecureServerOptions } from 'http2';
+export declare type KeyCertPair = {
+ private_key: Buffer;
+ cert_chain: Buffer;
+};
+export declare abstract class ServerCredentials {
+ abstract _isSecure(): boolean;
+ abstract _getSettings(): SecureServerOptions | null;
+ static createInsecure(): ServerCredentials;
+ static createSsl(rootCerts: Buffer | null, keyCertPairs: KeyCertPair[], checkClientCertificate?: boolean): ServerCredentials;
+}

build/src/server-credentials.js

@@ -0,0 +1,78 @@
+"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+class ServerCredentials {
+ static createInsecure() {
+ return new InsecureServerCredentials();
+ }
+ static createSsl(rootCerts, keyCertPairs, checkClientCertificate = false) {
+ if (rootCerts !== null && !Buffer.isBuffer(rootCerts)) {
+ throw new TypeError('rootCerts must be null or a Buffer');
+ }
+ if (!Array.isArray(keyCertPairs)) {
+ throw new TypeError('keyCertPairs must be an array');
+ }
+ if (typeof checkClientCertificate !== 'boolean') {
+ throw new TypeError('checkClientCertificate must be a boolean');
+ }
+ const cert = [];
+ const key = [];
+ for (let i = 0; i < keyCertPairs.length; i++) {
+ const pair = keyCertPairs[i];
+ if (pair === null || typeof pair !== 'object') {
+ throw new TypeError(`keyCertPair[${i}] must be an object`);
+ }
+ if (!Buffer.isBuffer(pair.private_key)) {
+ throw new TypeError(`keyCertPair[${i}].private_key must be a Buffer`);
+ }
+ if (!Buffer.isBuffer(pair.cert_chain)) {
+ throw new TypeError(`keyCertPair[${i}].cert_chain must be a Buffer`);
+ }
+ cert.push(pair.cert_chain);
+ key.push(pair.private_key);
+ }
+ return new SecureServerCredentials({
+ ca: rootCerts || undefined,
+ cert,
+ key,
+ requestCert: checkClientCertificate
+ });
+ }
+}
+exports.ServerCredentials = ServerCredentials;
+class InsecureServerCredentials extends ServerCredentials {
+ _isSecure() {
+ return false;
+ }
+ _getSettings() {
+ return null;
+ }
+}
+class SecureServerCredentials extends ServerCredentials {
+ constructor(options) {
+ super();
+ this.options = options;
+ }
+ _isSecure() {
+ return true;
+ }
+ _getSettings() {
+ return this.options;
+ }
+}
+//# sourceMappingURL=server-credentials.js.map
\ No newline at end of file

build/src/server.d.ts

@@ -0,0 +1,18 @@
+import { Deserialize, Serialize, ServiceDefinition } from './make-client';
+import { HandleCall } from './server-call';
+import { ServerCredentials } from './server-credentials';
+export declare class Server {
+ private http2Server;
+ private handlers;
+ private started;
+ constructor(options?: object);
+ addProtoService(): void;
+ addService(service: ServiceDefinition, implementation: object): void;
+ bind(port: string, creds: ServerCredentials): void;
+ bindAsync(port: string, creds: ServerCredentials, callback: (error: Error | null, port: number) => void): void;
+ forceShutdown(): void;
+ register<RequestType, ResponseType>(name: string, handler: HandleCall<RequestType, ResponseType>, serialize: Serialize<ResponseType>, deserialize: Deserialize<RequestType>, type: string): boolean;
+ start(): void;
+ tryShutdown(callback: (error?: Error) => void): void;
+ addHttp2Port(): void;
+}

build/src/server.js

@@ -0,0 +1,171 @@
+"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+const http2 = require("http2");
+const url_1 = require("url");
+const constants_1 = require("./constants");
+function noop() { }
+const unimplementedStatusResponse = {
+ code: constants_1.Status.UNIMPLEMENTED,
+ details: 'The server does not implement this method',
+};
+const defaultHandler = {
+ unary(call, callback) {
+ callback(unimplementedStatusResponse, null);
+ },
+ clientStream(call, callback) {
+ callback(unimplementedStatusResponse, null);
+ },
+ serverStream(call) {
+ call.emit('error', unimplementedStatusResponse);
+ },
+ bidi(call) {
+ call.emit('error', unimplementedStatusResponse);
+ }
+};
+// tslint:enable:no-any
+class Server {
+ constructor(options) {
+ this.http2Server = null;
+ this.handlers = new Map();
+ this.started = false;
+ }
+ addProtoService() {
+ throw new Error('Not implemented. Use addService() instead');
+ }
+ addService(service, implementation) {
+ if (this.started === true) {
+ throw new Error('Can\'t add a service to a started server.');
+ }
+ if (service === null || typeof service !== 'object' ||
+ implementation === null || typeof implementation !== 'object') {
+ throw new Error('addService() requires two objects as arguments');
+ }
+ const serviceKeys = Object.keys(service);
+ if (serviceKeys.length === 0) {
+ throw new Error('Cannot add an empty service to a server');
+ }
+ const implMap = implementation;
+ serviceKeys.forEach((name) => {
+ const attrs = service[name];
+ let methodType;
+ if (attrs.requestStream) {
+ if (attrs.responseStream) {
+ methodType = 'bidi';
+ }
+ else {
+ methodType = 'clientStream';
+ }
+ }
+ else {
+ if (attrs.responseStream) {
+ methodType = 'serverStream';
+ }
+ else {
+ methodType = 'unary';
+ }
+ }
+ let implFn = implMap[name];
+ let impl;
+ if (implFn === undefined && typeof attrs.originalName === 'string') {
+ implFn = implMap[attrs.originalName];
+ }
+ if (implFn !== undefined) {
+ impl = implFn.bind(implementation);
+ }
+ else {
+ impl = defaultHandler[methodType];
+ }
+ const success = this.register(attrs.path, impl, attrs.responseSerialize, attrs.requestDeserialize, methodType);
+ if (success === false) {
+ throw new Error(`Method handler for ${attrs.path} already provided.`);
+ }
+ });
+ }
+ bind(port, creds) {
+ throw new Error('Not implemented. Use bindAsync() instead');
+ }
+ bindAsync(port, creds, callback) {
+ if (this.started === true) {
+ throw new Error('server is already started');
+ }
+ if (typeof port !== 'string') {
+ throw new TypeError('port must be a string');
+ }
+ if (creds === null || typeof creds !== 'object') {
+ throw new TypeError('creds must be an object');
+ }
+ if (typeof callback !== 'function') {
+ throw new TypeError('callback must be a function');
+ }
+ const url = new url_1.URL(`http://${port}`);
+ const options = { host: url.hostname, port: +url.port };
+ if (creds._isSecure()) {
+ this.http2Server = http2.createSecureServer(creds._getSettings());
+ }
+ else {
+ this.http2Server = http2.createServer();
+ }
+ // TODO(cjihrig): Set up the handlers, to allow requests to be processed.
+ function onError(err) {
+ callback(err, -1);
+ }
+ this.http2Server.once('error', onError);
+ this.http2Server.listen(options, () => {
+ const server = this.http2Server;
+ const port = server.address().port;
+ server.removeListener('error', onError);
+ callback(null, port);
+ });
+ }
+ forceShutdown() {
+ throw new Error('Not yet implemented');
+ }
+ register(name, handler, serialize, deserialize, type) {
+ if (this.handlers.has(name)) {
+ return false;
+ }
+ this.handlers.set(name, { func: handler, serialize, deserialize, type: type });
+ return true;
+ }
+ start() {
+ if (this.http2Server === null || this.http2Server.listening !== true) {
+ throw new Error('server must be bound in order to start');
+ }
+ if (this.started === true) {
+ throw new Error('server is already started');
+ }
+ this.started = true;
+ }
+ tryShutdown(callback) {
+ callback = typeof callback === 'function' ? callback : noop;
+ if (this.http2Server === null) {
+ callback(new Error('server is not running'));
+ return;
+ }
+ this.http2Server.close((err) => {
+ this.started = false;
+ callback(err);
+ });
+ }
+ addHttp2Port() {
+ throw new Error('Not yet implemented');
+ }
+}
+exports.Server = Server;
+//# sourceMappingURL=server.js.map
\ No newline at end of file

build/src/status-builder.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* A builder for gRPC status objects.

build/src/subchannel.js

@@ -1,4 +1,20 @@
"use strict";
+/*
+ * Copyright 2019 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const http2 = require("http2");

package.json

@@ -1,12 +1,12 @@
{
"name": "@grpc/grpc-js",
- "version": "0.3.6",
+ "version": "0.4.0",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
"main": "build/src/index.js",
"engines": {
- "node": "^8.11.2 || >=9.4"
+ "node": "^8.13.0 || >=10.10.0"
},
"keywords": [],
"author": {
@@ -15,11 +15,12 @@
"types": "build/src/index.d.ts",
"license": "Apache-2.0",
"devDependencies": {
+ "@grpc/proto-loader": "^0.4.0",
"@types/lodash": "^4.14.108",
- "@types/mocha": "^2.2.43",
- "@types/node": "^10.5.4",
+ "@types/mocha": "^5.2.6",
+ "@types/node": "^11.13.2",
"clang-format": "^1.0.55",
- "gts": "^0.5.1",
+ "gts": "^0.9.0",
"lodash": "^4.17.4",
"typescript": "~3.3.3333"
},
@@ -42,7 +43,7 @@
"posttest": "npm run check"
},
"dependencies": {
- "semver": "^5.5.0"
+ "semver": "^6.0.0"
},
"files": [
"build/src/*.{js,d.ts}",