mirror of
				https://github.com/musix-org/musix-oss
				synced 2025-11-04 00:29:32 +00:00 
			
		
		
		
	Updated
This commit is contained in:
		
							
								
								
									
										201
									
								
								node_modules/@grpc/grpc-js/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										201
									
								
								node_modules/@grpc/grpc-js/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,201 @@
 | 
			
		||||
                                 Apache License
 | 
			
		||||
                           Version 2.0, January 2004
 | 
			
		||||
                        http://www.apache.org/licenses/
 | 
			
		||||
 | 
			
		||||
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 | 
			
		||||
 | 
			
		||||
   1. Definitions.
 | 
			
		||||
 | 
			
		||||
      "License" shall mean the terms and conditions for use, reproduction,
 | 
			
		||||
      and distribution as defined by Sections 1 through 9 of this document.
 | 
			
		||||
 | 
			
		||||
      "Licensor" shall mean the copyright owner or entity authorized by
 | 
			
		||||
      the copyright owner that is granting the License.
 | 
			
		||||
 | 
			
		||||
      "Legal Entity" shall mean the union of the acting entity and all
 | 
			
		||||
      other entities that control, are controlled by, or are under common
 | 
			
		||||
      control with that entity. For the purposes of this definition,
 | 
			
		||||
      "control" means (i) the power, direct or indirect, to cause the
 | 
			
		||||
      direction or management of such entity, whether by contract or
 | 
			
		||||
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
 | 
			
		||||
      outstanding shares, or (iii) beneficial ownership of such entity.
 | 
			
		||||
 | 
			
		||||
      "You" (or "Your") shall mean an individual or Legal Entity
 | 
			
		||||
      exercising permissions granted by this License.
 | 
			
		||||
 | 
			
		||||
      "Source" form shall mean the preferred form for making modifications,
 | 
			
		||||
      including but not limited to software source code, documentation
 | 
			
		||||
      source, and configuration files.
 | 
			
		||||
 | 
			
		||||
      "Object" form shall mean any form resulting from mechanical
 | 
			
		||||
      transformation or translation of a Source form, including but
 | 
			
		||||
      not limited to compiled object code, generated documentation,
 | 
			
		||||
      and conversions to other media types.
 | 
			
		||||
 | 
			
		||||
      "Work" shall mean the work of authorship, whether in Source or
 | 
			
		||||
      Object form, made available under the License, as indicated by a
 | 
			
		||||
      copyright notice that is included in or attached to the work
 | 
			
		||||
      (an example is provided in the Appendix below).
 | 
			
		||||
 | 
			
		||||
      "Derivative Works" shall mean any work, whether in Source or Object
 | 
			
		||||
      form, that is based on (or derived from) the Work and for which the
 | 
			
		||||
      editorial revisions, annotations, elaborations, or other modifications
 | 
			
		||||
      represent, as a whole, an original work of authorship. For the purposes
 | 
			
		||||
      of this License, Derivative Works shall not include works that remain
 | 
			
		||||
      separable from, or merely link (or bind by name) to the interfaces of,
 | 
			
		||||
      the Work and Derivative Works thereof.
 | 
			
		||||
 | 
			
		||||
      "Contribution" shall mean any work of authorship, including
 | 
			
		||||
      the original version of the Work and any modifications or additions
 | 
			
		||||
      to that Work or Derivative Works thereof, that is intentionally
 | 
			
		||||
      submitted to Licensor for inclusion in the Work by the copyright owner
 | 
			
		||||
      or by an individual or Legal Entity authorized to submit on behalf of
 | 
			
		||||
      the copyright owner. For the purposes of this definition, "submitted"
 | 
			
		||||
      means any form of electronic, verbal, or written communication sent
 | 
			
		||||
      to the Licensor or its representatives, including but not limited to
 | 
			
		||||
      communication on electronic mailing lists, source code control systems,
 | 
			
		||||
      and issue tracking systems that are managed by, or on behalf of, the
 | 
			
		||||
      Licensor for the purpose of discussing and improving the Work, but
 | 
			
		||||
      excluding communication that is conspicuously marked or otherwise
 | 
			
		||||
      designated in writing by the copyright owner as "Not a Contribution."
 | 
			
		||||
 | 
			
		||||
      "Contributor" shall mean Licensor and any individual or Legal Entity
 | 
			
		||||
      on behalf of whom a Contribution has been received by Licensor and
 | 
			
		||||
      subsequently incorporated within the Work.
 | 
			
		||||
 | 
			
		||||
   2. Grant of Copyright License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      copyright license to reproduce, prepare Derivative Works of,
 | 
			
		||||
      publicly display, publicly perform, sublicense, and distribute the
 | 
			
		||||
      Work and such Derivative Works in Source or Object form.
 | 
			
		||||
 | 
			
		||||
   3. Grant of Patent License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      (except as stated in this section) patent license to make, have made,
 | 
			
		||||
      use, offer to sell, sell, import, and otherwise transfer the Work,
 | 
			
		||||
      where such license applies only to those patent claims licensable
 | 
			
		||||
      by such Contributor that are necessarily infringed by their
 | 
			
		||||
      Contribution(s) alone or by combination of their Contribution(s)
 | 
			
		||||
      with the Work to which such Contribution(s) was submitted. If You
 | 
			
		||||
      institute patent litigation against any entity (including a
 | 
			
		||||
      cross-claim or counterclaim in a lawsuit) alleging that the Work
 | 
			
		||||
      or a Contribution incorporated within the Work constitutes direct
 | 
			
		||||
      or contributory patent infringement, then any patent licenses
 | 
			
		||||
      granted to You under this License for that Work shall terminate
 | 
			
		||||
      as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
   4. Redistribution. You may reproduce and distribute copies of the
 | 
			
		||||
      Work or Derivative Works thereof in any medium, with or without
 | 
			
		||||
      modifications, and in Source or Object form, provided that You
 | 
			
		||||
      meet the following conditions:
 | 
			
		||||
 | 
			
		||||
      (a) You must give any other recipients of the Work or
 | 
			
		||||
          Derivative Works a copy of this License; and
 | 
			
		||||
 | 
			
		||||
      (b) You must cause any modified files to carry prominent notices
 | 
			
		||||
          stating that You changed the files; and
 | 
			
		||||
 | 
			
		||||
      (c) You must retain, in the Source form of any Derivative Works
 | 
			
		||||
          that You distribute, all copyright, patent, trademark, and
 | 
			
		||||
          attribution notices from the Source form of the Work,
 | 
			
		||||
          excluding those notices that do not pertain to any part of
 | 
			
		||||
          the Derivative Works; and
 | 
			
		||||
 | 
			
		||||
      (d) If the Work includes a "NOTICE" text file as part of its
 | 
			
		||||
          distribution, then any Derivative Works that You distribute must
 | 
			
		||||
          include a readable copy of the attribution notices contained
 | 
			
		||||
          within such NOTICE file, excluding those notices that do not
 | 
			
		||||
          pertain to any part of the Derivative Works, in at least one
 | 
			
		||||
          of the following places: within a NOTICE text file distributed
 | 
			
		||||
          as part of the Derivative Works; within the Source form or
 | 
			
		||||
          documentation, if provided along with the Derivative Works; or,
 | 
			
		||||
          within a display generated by the Derivative Works, if and
 | 
			
		||||
          wherever such third-party notices normally appear. The contents
 | 
			
		||||
          of the NOTICE file are for informational purposes only and
 | 
			
		||||
          do not modify the License. You may add Your own attribution
 | 
			
		||||
          notices within Derivative Works that You distribute, alongside
 | 
			
		||||
          or as an addendum to the NOTICE text from the Work, provided
 | 
			
		||||
          that such additional attribution notices cannot be construed
 | 
			
		||||
          as modifying the License.
 | 
			
		||||
 | 
			
		||||
      You may add Your own copyright statement to Your modifications and
 | 
			
		||||
      may provide additional or different license terms and conditions
 | 
			
		||||
      for use, reproduction, or distribution of Your modifications, or
 | 
			
		||||
      for any such Derivative Works as a whole, provided Your use,
 | 
			
		||||
      reproduction, and distribution of the Work otherwise complies with
 | 
			
		||||
      the conditions stated in this License.
 | 
			
		||||
 | 
			
		||||
   5. Submission of Contributions. Unless You explicitly state otherwise,
 | 
			
		||||
      any Contribution intentionally submitted for inclusion in the Work
 | 
			
		||||
      by You to the Licensor shall be under the terms and conditions of
 | 
			
		||||
      this License, without any additional terms or conditions.
 | 
			
		||||
      Notwithstanding the above, nothing herein shall supersede or modify
 | 
			
		||||
      the terms of any separate license agreement you may have executed
 | 
			
		||||
      with Licensor regarding such Contributions.
 | 
			
		||||
 | 
			
		||||
   6. Trademarks. This License does not grant permission to use the trade
 | 
			
		||||
      names, trademarks, service marks, or product names of the Licensor,
 | 
			
		||||
      except as required for reasonable and customary use in describing the
 | 
			
		||||
      origin of the Work and reproducing the content of the NOTICE file.
 | 
			
		||||
 | 
			
		||||
   7. Disclaimer of Warranty. Unless required by applicable law or
 | 
			
		||||
      agreed to in writing, Licensor provides the Work (and each
 | 
			
		||||
      Contributor provides its Contributions) on an "AS IS" BASIS,
 | 
			
		||||
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 | 
			
		||||
      implied, including, without limitation, any warranties or conditions
 | 
			
		||||
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
 | 
			
		||||
      PARTICULAR PURPOSE. You are solely responsible for determining the
 | 
			
		||||
      appropriateness of using or redistributing the Work and assume any
 | 
			
		||||
      risks associated with Your exercise of permissions under this License.
 | 
			
		||||
 | 
			
		||||
   8. Limitation of Liability. In no event and under no legal theory,
 | 
			
		||||
      whether in tort (including negligence), contract, or otherwise,
 | 
			
		||||
      unless required by applicable law (such as deliberate and grossly
 | 
			
		||||
      negligent acts) or agreed to in writing, shall any Contributor be
 | 
			
		||||
      liable to You for damages, including any direct, indirect, special,
 | 
			
		||||
      incidental, or consequential damages of any character arising as a
 | 
			
		||||
      result of this License or out of the use or inability to use the
 | 
			
		||||
      Work (including but not limited to damages for loss of goodwill,
 | 
			
		||||
      work stoppage, computer failure or malfunction, or any and all
 | 
			
		||||
      other commercial damages or losses), even if such Contributor
 | 
			
		||||
      has been advised of the possibility of such damages.
 | 
			
		||||
 | 
			
		||||
   9. Accepting Warranty or Additional Liability. While redistributing
 | 
			
		||||
      the Work or Derivative Works thereof, You may choose to offer,
 | 
			
		||||
      and charge a fee for, acceptance of support, warranty, indemnity,
 | 
			
		||||
      or other liability obligations and/or rights consistent with this
 | 
			
		||||
      License. However, in accepting such obligations, You may act only
 | 
			
		||||
      on Your own behalf and on Your sole responsibility, not on behalf
 | 
			
		||||
      of any other Contributor, and only if You agree to indemnify,
 | 
			
		||||
      defend, and hold each Contributor harmless for any liability
 | 
			
		||||
      incurred by, or claims asserted against, such Contributor by reason
 | 
			
		||||
      of your accepting any such warranty or additional liability.
 | 
			
		||||
 | 
			
		||||
   END OF TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
   APPENDIX: How to apply the Apache License to your work.
 | 
			
		||||
 | 
			
		||||
      To apply the Apache License to your work, attach the following
 | 
			
		||||
      boilerplate notice, with the fields enclosed by brackets "{}"
 | 
			
		||||
      replaced with your own identifying information. (Don't include
 | 
			
		||||
      the brackets!)  The text should be enclosed in the appropriate
 | 
			
		||||
      comment syntax for the file format. We also recommend that a
 | 
			
		||||
      file or class name and description of purpose be included on the
 | 
			
		||||
      same "printed page" as the copyright notice for easier
 | 
			
		||||
      identification within third-party archives.
 | 
			
		||||
 | 
			
		||||
   Copyright {yyyy} {name of copyright owner}
 | 
			
		||||
 | 
			
		||||
   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.
 | 
			
		||||
							
								
								
									
										31
									
								
								node_modules/@grpc/grpc-js/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								node_modules/@grpc/grpc-js/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
# Pure JavaScript gRPC Client
 | 
			
		||||
 | 
			
		||||
**Note: This is an beta-level release. Some APIs may not yet be present and there may be bugs. Please report any that you encounter**
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
Node 10 is recommended. The exact set of compatible Node versions can be found in the `engines` field of the `package.json` file.
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
npm install @grpc/grpc-js
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
 - Unary and streaming calls
 | 
			
		||||
 - Cancellation
 | 
			
		||||
 - Deadlines
 | 
			
		||||
 - TLS channel credentials
 | 
			
		||||
 - Call credentials (for auth)
 | 
			
		||||
 - Simple reconnection
 | 
			
		||||
 - Channel API
 | 
			
		||||
 | 
			
		||||
This library does not directly handle `.proto` files. To use `.proto` files with this library we recommend using the `@grpc/proto-loader` package.
 | 
			
		||||
 | 
			
		||||
## Some Notes on API Guarantees
 | 
			
		||||
 | 
			
		||||
The public API of this library follows semantic versioning, with some caveats:
 | 
			
		||||
 | 
			
		||||
 - Some methods are prefixed with an underscore. These methods are internal and should not be considered part of the public API.
 | 
			
		||||
 - The class `Call` is only exposed due to limitations of TypeScript. It should not be considered part of the public API.
 | 
			
		||||
 - In general, any API that is exposed by this library but is not exposed by the `grpc` library is likely an error and should not be considered part of the public API.
 | 
			
		||||
							
								
								
									
										16
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
import { Call } from './call-stream';
 | 
			
		||||
import { Http2Channel } from './channel';
 | 
			
		||||
import { BaseFilter, Filter, FilterFactory } from './filter';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export declare class CallCredentialsFilter extends BaseFilter implements Filter {
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    private readonly stream;
 | 
			
		||||
    private serviceUrl;
 | 
			
		||||
    constructor(channel: Http2Channel, stream: Call);
 | 
			
		||||
    sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
}
 | 
			
		||||
export declare class CallCredentialsFilterFactory implements FilterFactory<CallCredentialsFilter> {
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    constructor(channel: Http2Channel);
 | 
			
		||||
    createFilter(callStream: Call): CallCredentialsFilter;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										61
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
"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 {
 | 
			
		||||
    constructor(channel, stream) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
        this.stream = stream;
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
        this.stream = stream;
 | 
			
		||||
        const splitPath = stream.getMethod().split('/');
 | 
			
		||||
        let serviceName = '';
 | 
			
		||||
        /* The standard path format is "/{serviceName}/{methodName}", so if we split
 | 
			
		||||
         * by '/', the first item should be empty and the second should be the
 | 
			
		||||
         * service name */
 | 
			
		||||
        if (splitPath.length >= 2) {
 | 
			
		||||
            serviceName = splitPath[1];
 | 
			
		||||
        }
 | 
			
		||||
        /* Currently, call credentials are only allowed on HTTPS connections, so we
 | 
			
		||||
         * can assume that the scheme is "https" */
 | 
			
		||||
        this.serviceUrl = `https://${stream.getHost()}/${serviceName}`;
 | 
			
		||||
    }
 | 
			
		||||
    async sendMetadata(metadata) {
 | 
			
		||||
        const channelCredentials = this.channel.credentials._getCallCredentials();
 | 
			
		||||
        const streamCredentials = this.stream.getCredentials();
 | 
			
		||||
        const credentials = channelCredentials.compose(streamCredentials);
 | 
			
		||||
        const credsMetadata = credentials.generateMetadata({
 | 
			
		||||
            service_url: this.serviceUrl,
 | 
			
		||||
        });
 | 
			
		||||
        const resultMetadata = await metadata;
 | 
			
		||||
        resultMetadata.merge(await credsMetadata);
 | 
			
		||||
        return resultMetadata;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.CallCredentialsFilter = CallCredentialsFilter;
 | 
			
		||||
class CallCredentialsFilterFactory {
 | 
			
		||||
    constructor(channel) {
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
    }
 | 
			
		||||
    createFilter(callStream) {
 | 
			
		||||
        return new CallCredentialsFilter(this.channel, callStream);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.CallCredentialsFilterFactory = CallCredentialsFilterFactory;
 | 
			
		||||
//# sourceMappingURL=call-credentials-filter.js.map
 | 
			
		||||
							
								
								
									
										32
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export interface CallMetadataOptions {
 | 
			
		||||
    service_url: string;
 | 
			
		||||
}
 | 
			
		||||
export declare type CallMetadataGenerator = (options: CallMetadataOptions, cb: (err: Error | null, metadata?: Metadata) => void) => void;
 | 
			
		||||
/**
 | 
			
		||||
 * A class that represents a generic method of adding authentication-related
 | 
			
		||||
 * metadata on a per-request basis.
 | 
			
		||||
 */
 | 
			
		||||
export declare abstract class CallCredentials {
 | 
			
		||||
    /**
 | 
			
		||||
     * Asynchronously generates a new Metadata object.
 | 
			
		||||
     * @param options Options used in generating the Metadata object.
 | 
			
		||||
     */
 | 
			
		||||
    abstract generateMetadata(options: CallMetadataOptions): Promise<Metadata>;
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new CallCredentials object from properties of both this and
 | 
			
		||||
     * another CallCredentials object. This object's metadata generator will be
 | 
			
		||||
     * called first.
 | 
			
		||||
     * @param callCredentials The other CallCredentials object.
 | 
			
		||||
     */
 | 
			
		||||
    abstract compose(callCredentials: CallCredentials): CallCredentials;
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new CallCredentials object from a given function that generates
 | 
			
		||||
     * Metadata objects.
 | 
			
		||||
     * @param metadataGenerator A function that accepts a set of options, and
 | 
			
		||||
     * generates a Metadata object based on these options, which is passed back
 | 
			
		||||
     * to the caller via a supplied (err, metadata) callback.
 | 
			
		||||
     */
 | 
			
		||||
    static createFromMetadataGenerator(metadataGenerator: CallMetadataGenerator): CallCredentials;
 | 
			
		||||
    static createEmpty(): CallCredentials;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										86
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								node_modules/@grpc/grpc-js/build/src/call-credentials.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,86 @@
 | 
			
		||||
"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");
 | 
			
		||||
/**
 | 
			
		||||
 * A class that represents a generic method of adding authentication-related
 | 
			
		||||
 * metadata on a per-request basis.
 | 
			
		||||
 */
 | 
			
		||||
class CallCredentials {
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new CallCredentials object from a given function that generates
 | 
			
		||||
     * Metadata objects.
 | 
			
		||||
     * @param metadataGenerator A function that accepts a set of options, and
 | 
			
		||||
     * generates a Metadata object based on these options, which is passed back
 | 
			
		||||
     * to the caller via a supplied (err, metadata) callback.
 | 
			
		||||
     */
 | 
			
		||||
    static createFromMetadataGenerator(metadataGenerator) {
 | 
			
		||||
        return new SingleCallCredentials(metadataGenerator);
 | 
			
		||||
    }
 | 
			
		||||
    static createEmpty() {
 | 
			
		||||
        return new EmptyCallCredentials();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.CallCredentials = CallCredentials;
 | 
			
		||||
class ComposedCallCredentials extends CallCredentials {
 | 
			
		||||
    constructor(creds) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.creds = creds;
 | 
			
		||||
    }
 | 
			
		||||
    async generateMetadata(options) {
 | 
			
		||||
        const base = new metadata_1.Metadata();
 | 
			
		||||
        const generated = await Promise.all(this.creds.map(cred => cred.generateMetadata(options)));
 | 
			
		||||
        for (const gen of generated) {
 | 
			
		||||
            base.merge(gen);
 | 
			
		||||
        }
 | 
			
		||||
        return base;
 | 
			
		||||
    }
 | 
			
		||||
    compose(other) {
 | 
			
		||||
        return new ComposedCallCredentials(this.creds.concat([other]));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class SingleCallCredentials extends CallCredentials {
 | 
			
		||||
    constructor(metadataGenerator) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.metadataGenerator = metadataGenerator;
 | 
			
		||||
    }
 | 
			
		||||
    generateMetadata(options) {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            this.metadataGenerator(options, (err, metadata) => {
 | 
			
		||||
                if (metadata !== undefined) {
 | 
			
		||||
                    resolve(metadata);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    reject(err);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    compose(other) {
 | 
			
		||||
        return new ComposedCallCredentials([this, other]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class EmptyCallCredentials extends CallCredentials {
 | 
			
		||||
    generateMetadata(options) {
 | 
			
		||||
        return Promise.resolve(new metadata_1.Metadata());
 | 
			
		||||
    }
 | 
			
		||||
    compose(other) {
 | 
			
		||||
        return other;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//# sourceMappingURL=call-credentials.js.map
 | 
			
		||||
							
								
								
									
										94
									
								
								node_modules/@grpc/grpc-js/build/src/call-stream.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								node_modules/@grpc/grpc-js/build/src/call-stream.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import * as http2 from 'http2';
 | 
			
		||||
import { Duplex } from 'stream';
 | 
			
		||||
import { CallCredentials } from './call-credentials';
 | 
			
		||||
import { Http2Channel } from './channel';
 | 
			
		||||
import { Status } from './constants';
 | 
			
		||||
import { EmitterAugmentation1 } from './events';
 | 
			
		||||
import { Filter } from './filter';
 | 
			
		||||
import { FilterStackFactory } from './filter-stack';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
import { ObjectDuplex, WriteCallback } from './object-stream';
 | 
			
		||||
export declare type Deadline = Date | number;
 | 
			
		||||
export interface CallStreamOptions {
 | 
			
		||||
    deadline: Deadline;
 | 
			
		||||
    flags: number;
 | 
			
		||||
    host: string;
 | 
			
		||||
    parentCall: Call | null;
 | 
			
		||||
}
 | 
			
		||||
export declare type PartialCallStreamOptions = Partial<CallStreamOptions>;
 | 
			
		||||
export interface StatusObject {
 | 
			
		||||
    code: Status;
 | 
			
		||||
    details: string;
 | 
			
		||||
    metadata: Metadata;
 | 
			
		||||
}
 | 
			
		||||
export declare const enum WriteFlags {
 | 
			
		||||
    BufferHint = 1,
 | 
			
		||||
    NoCompress = 2,
 | 
			
		||||
    WriteThrough = 4
 | 
			
		||||
}
 | 
			
		||||
export interface WriteObject {
 | 
			
		||||
    message: Buffer;
 | 
			
		||||
    flags?: number;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * This interface represents a duplex stream associated with a single gRPC call.
 | 
			
		||||
 */
 | 
			
		||||
export declare type Call = {
 | 
			
		||||
    cancelWithStatus(status: Status, details: string): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    sendMetadata(metadata: Metadata): void;
 | 
			
		||||
    getDeadline(): Deadline;
 | 
			
		||||
    getCredentials(): CallCredentials;
 | 
			
		||||
    setCredentials(credentials: CallCredentials): void;
 | 
			
		||||
    getStatus(): StatusObject | null;
 | 
			
		||||
    getMethod(): string;
 | 
			
		||||
    getHost(): string;
 | 
			
		||||
} & EmitterAugmentation1<'metadata', Metadata> & EmitterAugmentation1<'status', StatusObject> & ObjectDuplex<WriteObject, Buffer>;
 | 
			
		||||
export declare class Http2CallStream extends Duplex implements Call {
 | 
			
		||||
    private readonly methodName;
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    private readonly options;
 | 
			
		||||
    credentials: CallCredentials;
 | 
			
		||||
    filterStack: Filter;
 | 
			
		||||
    private http2Stream;
 | 
			
		||||
    private pendingRead;
 | 
			
		||||
    private pendingWrite;
 | 
			
		||||
    private pendingWriteCallback;
 | 
			
		||||
    private pendingFinalCallback;
 | 
			
		||||
    private decoder;
 | 
			
		||||
    private isReadFilterPending;
 | 
			
		||||
    private canPush;
 | 
			
		||||
    private unpushedReadMessages;
 | 
			
		||||
    private unfilteredReadMessages;
 | 
			
		||||
    private mappedStatusCode;
 | 
			
		||||
    private handlingHeaders;
 | 
			
		||||
    private handlingTrailers;
 | 
			
		||||
    private finalStatus;
 | 
			
		||||
    constructor(methodName: string, channel: Http2Channel, options: CallStreamOptions, filterStackFactory: FilterStackFactory);
 | 
			
		||||
    /**
 | 
			
		||||
     * On first call, emits a 'status' event with the given StatusObject.
 | 
			
		||||
     * Subsequent calls are no-ops.
 | 
			
		||||
     * @param status The status of the call.
 | 
			
		||||
     */
 | 
			
		||||
    private endCall;
 | 
			
		||||
    private handleFilterError;
 | 
			
		||||
    private handleFilteredRead;
 | 
			
		||||
    private filterReceivedMessage;
 | 
			
		||||
    private tryPush;
 | 
			
		||||
    private handleTrailers;
 | 
			
		||||
    attachHttp2Stream(stream: http2.ClientHttp2Stream): void;
 | 
			
		||||
    sendMetadata(metadata: Metadata): void;
 | 
			
		||||
    private destroyHttp2Stream;
 | 
			
		||||
    cancelWithStatus(status: Status, details: string): void;
 | 
			
		||||
    getDeadline(): Deadline;
 | 
			
		||||
    getCredentials(): CallCredentials;
 | 
			
		||||
    setCredentials(credentials: CallCredentials): void;
 | 
			
		||||
    getStatus(): StatusObject | null;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    getMethod(): string;
 | 
			
		||||
    getHost(): string;
 | 
			
		||||
    _read(size: number): void;
 | 
			
		||||
    _write(chunk: WriteObject, encoding: string, cb: WriteCallback): void;
 | 
			
		||||
    _final(cb: Function): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										373
									
								
								node_modules/@grpc/grpc-js/build/src/call-stream.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										373
									
								
								node_modules/@grpc/grpc-js/build/src/call-stream.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,373 @@
 | 
			
		||||
"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");
 | 
			
		||||
const call_credentials_1 = require("./call-credentials");
 | 
			
		||||
const constants_1 = require("./constants");
 | 
			
		||||
const metadata_1 = require("./metadata");
 | 
			
		||||
const stream_decoder_1 = require("./stream-decoder");
 | 
			
		||||
const { HTTP2_HEADER_STATUS, HTTP2_HEADER_CONTENT_TYPE, NGHTTP2_CANCEL, } = http2.constants;
 | 
			
		||||
class Http2CallStream extends stream_1.Duplex {
 | 
			
		||||
    constructor(methodName, channel, options, filterStackFactory) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.methodName = methodName;
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
        this.options = options;
 | 
			
		||||
        this.credentials = call_credentials_1.CallCredentials.createEmpty();
 | 
			
		||||
        this.http2Stream = null;
 | 
			
		||||
        this.pendingRead = false;
 | 
			
		||||
        this.pendingWrite = null;
 | 
			
		||||
        this.pendingWriteCallback = null;
 | 
			
		||||
        this.pendingFinalCallback = null;
 | 
			
		||||
        this.decoder = new stream_decoder_1.StreamDecoder();
 | 
			
		||||
        this.isReadFilterPending = false;
 | 
			
		||||
        this.canPush = false;
 | 
			
		||||
        this.unpushedReadMessages = [];
 | 
			
		||||
        this.unfilteredReadMessages = [];
 | 
			
		||||
        // Status code mapped from :status. To be used if grpc-status is not received
 | 
			
		||||
        this.mappedStatusCode = constants_1.Status.UNKNOWN;
 | 
			
		||||
        // Promise objects that are re-assigned to resolving promises when headers
 | 
			
		||||
        // or trailers received. Processing headers/trailers is asynchronous, so we
 | 
			
		||||
        // can use these objects to await their completion. This helps us establish
 | 
			
		||||
        // order of precedence when obtaining the status of the call.
 | 
			
		||||
        this.handlingHeaders = Promise.resolve();
 | 
			
		||||
        this.handlingTrailers = Promise.resolve();
 | 
			
		||||
        // This is populated (non-null) if and only if the call has ended
 | 
			
		||||
        this.finalStatus = null;
 | 
			
		||||
        this.filterStack = filterStackFactory.createFilter(this);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * On first call, emits a 'status' event with the given StatusObject.
 | 
			
		||||
     * Subsequent calls are no-ops.
 | 
			
		||||
     * @param status The status of the call.
 | 
			
		||||
     */
 | 
			
		||||
    endCall(status) {
 | 
			
		||||
        if (this.finalStatus === null) {
 | 
			
		||||
            this.finalStatus = status;
 | 
			
		||||
            /* We do this asynchronously to ensure that no async function is in the
 | 
			
		||||
             * call stack when we return control to the application. If an async
 | 
			
		||||
             * function is in the call stack, any exception thrown by the application
 | 
			
		||||
             * (or our tests) will bubble up and turn into promise rejection, which
 | 
			
		||||
             * will result in an UnhandledPromiseRejectionWarning. Because that is
 | 
			
		||||
             * a warning, the error will be effectively swallowed and execution will
 | 
			
		||||
             * continue */
 | 
			
		||||
            process.nextTick(() => {
 | 
			
		||||
                this.emit('status', status);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    handleFilterError(error) {
 | 
			
		||||
        this.cancelWithStatus(constants_1.Status.INTERNAL, error.message);
 | 
			
		||||
    }
 | 
			
		||||
    handleFilteredRead(message) {
 | 
			
		||||
        /* If we the call has already ended, we don't want to do anything with
 | 
			
		||||
         * this message. Dropping it on the floor is correct behavior */
 | 
			
		||||
        if (this.finalStatus !== null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.isReadFilterPending = false;
 | 
			
		||||
        if (this.canPush) {
 | 
			
		||||
            if (!this.push(message)) {
 | 
			
		||||
                this.canPush = false;
 | 
			
		||||
                this.http2Stream.pause();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.unpushedReadMessages.push(message);
 | 
			
		||||
        }
 | 
			
		||||
        if (this.unfilteredReadMessages.length > 0) {
 | 
			
		||||
            /* nextMessage is guaranteed not to be undefined because
 | 
			
		||||
               unfilteredReadMessages is non-empty */
 | 
			
		||||
            const nextMessage = this.unfilteredReadMessages.shift();
 | 
			
		||||
            this.filterReceivedMessage(nextMessage);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    filterReceivedMessage(framedMessage) {
 | 
			
		||||
        /* If we the call has already ended, we don't want to do anything with
 | 
			
		||||
         * this message. Dropping it on the floor is correct behavior */
 | 
			
		||||
        if (this.finalStatus !== null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (framedMessage === null) {
 | 
			
		||||
            if (this.canPush) {
 | 
			
		||||
                this.push(null);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                this.unpushedReadMessages.push(null);
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.isReadFilterPending = true;
 | 
			
		||||
        this.filterStack
 | 
			
		||||
            .receiveMessage(Promise.resolve(framedMessage))
 | 
			
		||||
            .then(this.handleFilteredRead.bind(this), this.handleFilterError.bind(this));
 | 
			
		||||
    }
 | 
			
		||||
    tryPush(messageBytes) {
 | 
			
		||||
        if (this.isReadFilterPending) {
 | 
			
		||||
            this.unfilteredReadMessages.push(messageBytes);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.filterReceivedMessage(messageBytes);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    handleTrailers(headers) {
 | 
			
		||||
        const code = this.mappedStatusCode;
 | 
			
		||||
        const details = '';
 | 
			
		||||
        let metadata;
 | 
			
		||||
        try {
 | 
			
		||||
            metadata = metadata_1.Metadata.fromHttp2Headers(headers);
 | 
			
		||||
        }
 | 
			
		||||
        catch (e) {
 | 
			
		||||
            metadata = new metadata_1.Metadata();
 | 
			
		||||
        }
 | 
			
		||||
        const status = { code, details, metadata };
 | 
			
		||||
        this.handlingTrailers = (async () => {
 | 
			
		||||
            let finalStatus;
 | 
			
		||||
            try {
 | 
			
		||||
                // Attempt to assign final status.
 | 
			
		||||
                finalStatus = await this.filterStack.receiveTrailers(Promise.resolve(status));
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                await this.handlingHeaders;
 | 
			
		||||
                // This is a no-op if the call was already ended when handling headers.
 | 
			
		||||
                this.endCall({
 | 
			
		||||
                    code: constants_1.Status.INTERNAL,
 | 
			
		||||
                    details: 'Failed to process received status',
 | 
			
		||||
                    metadata: new metadata_1.Metadata(),
 | 
			
		||||
                });
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // It's possible that headers were received but not fully handled yet.
 | 
			
		||||
            // Give the headers handler an opportunity to end the call first,
 | 
			
		||||
            // if an error occurred.
 | 
			
		||||
            await this.handlingHeaders;
 | 
			
		||||
            // This is a no-op if the call was already ended when handling headers.
 | 
			
		||||
            this.endCall(finalStatus);
 | 
			
		||||
        })();
 | 
			
		||||
    }
 | 
			
		||||
    attachHttp2Stream(stream) {
 | 
			
		||||
        if (this.finalStatus !== null) {
 | 
			
		||||
            stream.close(NGHTTP2_CANCEL);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.http2Stream = stream;
 | 
			
		||||
            stream.on('response', (headers, flags) => {
 | 
			
		||||
                switch (headers[':status']) {
 | 
			
		||||
                    // TODO(murgatroid99): handle 100 and 101
 | 
			
		||||
                    case 400:
 | 
			
		||||
                        this.mappedStatusCode = constants_1.Status.INTERNAL;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 401:
 | 
			
		||||
                        this.mappedStatusCode = constants_1.Status.UNAUTHENTICATED;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 403:
 | 
			
		||||
                        this.mappedStatusCode = constants_1.Status.PERMISSION_DENIED;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 404:
 | 
			
		||||
                        this.mappedStatusCode = constants_1.Status.UNIMPLEMENTED;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 429:
 | 
			
		||||
                    case 502:
 | 
			
		||||
                    case 503:
 | 
			
		||||
                    case 504:
 | 
			
		||||
                        this.mappedStatusCode = constants_1.Status.UNAVAILABLE;
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        this.mappedStatusCode = constants_1.Status.UNKNOWN;
 | 
			
		||||
                }
 | 
			
		||||
                if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) {
 | 
			
		||||
                    this.handleTrailers(headers);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    let metadata;
 | 
			
		||||
                    try {
 | 
			
		||||
                        metadata = metadata_1.Metadata.fromHttp2Headers(headers);
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (error) {
 | 
			
		||||
                        this.endCall({
 | 
			
		||||
                            code: constants_1.Status.UNKNOWN,
 | 
			
		||||
                            details: error.message,
 | 
			
		||||
                            metadata: new metadata_1.Metadata(),
 | 
			
		||||
                        });
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
                    this.handlingHeaders = this.filterStack
 | 
			
		||||
                        .receiveMetadata(Promise.resolve(metadata))
 | 
			
		||||
                        .then(finalMetadata => {
 | 
			
		||||
                        this.emit('metadata', finalMetadata);
 | 
			
		||||
                    })
 | 
			
		||||
                        .catch(error => {
 | 
			
		||||
                        this.destroyHttp2Stream();
 | 
			
		||||
                        this.endCall({
 | 
			
		||||
                            code: constants_1.Status.UNKNOWN,
 | 
			
		||||
                            details: error.message,
 | 
			
		||||
                            metadata: new metadata_1.Metadata(),
 | 
			
		||||
                        });
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            stream.on('trailers', this.handleTrailers.bind(this));
 | 
			
		||||
            stream.on('data', (data) => {
 | 
			
		||||
                const messages = this.decoder.write(data);
 | 
			
		||||
                for (const message of messages) {
 | 
			
		||||
                    this.tryPush(message);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            stream.on('end', () => {
 | 
			
		||||
                this.tryPush(null);
 | 
			
		||||
            });
 | 
			
		||||
            stream.on('close', async () => {
 | 
			
		||||
                let code;
 | 
			
		||||
                let details = '';
 | 
			
		||||
                switch (stream.rstCode) {
 | 
			
		||||
                    case http2.constants.NGHTTP2_REFUSED_STREAM:
 | 
			
		||||
                        code = constants_1.Status.UNAVAILABLE;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case http2.constants.NGHTTP2_CANCEL:
 | 
			
		||||
                        code = constants_1.Status.CANCELLED;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case http2.constants.NGHTTP2_ENHANCE_YOUR_CALM:
 | 
			
		||||
                        code = constants_1.Status.RESOURCE_EXHAUSTED;
 | 
			
		||||
                        details = 'Bandwidth exhausted';
 | 
			
		||||
                        break;
 | 
			
		||||
                    case http2.constants.NGHTTP2_INADEQUATE_SECURITY:
 | 
			
		||||
                        code = constants_1.Status.PERMISSION_DENIED;
 | 
			
		||||
                        details = 'Protocol not secure enough';
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        code = constants_1.Status.INTERNAL;
 | 
			
		||||
                }
 | 
			
		||||
                // This guarantees that if trailers were received, the value of the
 | 
			
		||||
                // 'grpc-status' header takes precedence for emitted status data.
 | 
			
		||||
                await this.handlingTrailers;
 | 
			
		||||
                // This is a no-op if trailers were received at all.
 | 
			
		||||
                // This is OK, because status codes emitted here correspond to more
 | 
			
		||||
                // catastrophic issues that prevent us from receiving trailers in the
 | 
			
		||||
                // first place.
 | 
			
		||||
                this.endCall({ code, details, metadata: new metadata_1.Metadata() });
 | 
			
		||||
            });
 | 
			
		||||
            stream.on('error', (err) => {
 | 
			
		||||
                /* We need an error handler here to stop "Uncaught Error" exceptions
 | 
			
		||||
                 * from bubbling up. However, errors here should all correspond to
 | 
			
		||||
                 * "close" events, where we will handle the error more granularly */
 | 
			
		||||
            });
 | 
			
		||||
            if (!this.pendingRead) {
 | 
			
		||||
                stream.pause();
 | 
			
		||||
            }
 | 
			
		||||
            if (this.pendingWrite) {
 | 
			
		||||
                if (!this.pendingWriteCallback) {
 | 
			
		||||
                    throw new Error('Invalid state in write handling code');
 | 
			
		||||
                }
 | 
			
		||||
                stream.write(this.pendingWrite, this.pendingWriteCallback);
 | 
			
		||||
            }
 | 
			
		||||
            if (this.pendingFinalCallback) {
 | 
			
		||||
                stream.end(this.pendingFinalCallback);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(metadata) {
 | 
			
		||||
        this.channel._startHttp2Stream(this.options.host, this.methodName, this, metadata);
 | 
			
		||||
    }
 | 
			
		||||
    destroyHttp2Stream() {
 | 
			
		||||
        // The http2 stream could already have been destroyed if cancelWithStatus
 | 
			
		||||
        // is called in response to an internal http2 error.
 | 
			
		||||
        if (this.http2Stream !== null && !this.http2Stream.destroyed) {
 | 
			
		||||
            /* TODO(murgatroid99): Determine if we want to send different RST_STREAM
 | 
			
		||||
             * codes based on the status code */
 | 
			
		||||
            this.http2Stream.close(NGHTTP2_CANCEL);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    cancelWithStatus(status, details) {
 | 
			
		||||
        this.destroyHttp2Stream();
 | 
			
		||||
        (async () => {
 | 
			
		||||
            // If trailers are currently being processed, the call should be ended
 | 
			
		||||
            // by handleTrailers instead.
 | 
			
		||||
            await this.handlingTrailers;
 | 
			
		||||
            this.endCall({ code: status, details, metadata: new metadata_1.Metadata() });
 | 
			
		||||
        })();
 | 
			
		||||
    }
 | 
			
		||||
    getDeadline() {
 | 
			
		||||
        return this.options.deadline;
 | 
			
		||||
    }
 | 
			
		||||
    getCredentials() {
 | 
			
		||||
        return this.credentials;
 | 
			
		||||
    }
 | 
			
		||||
    setCredentials(credentials) {
 | 
			
		||||
        this.credentials = credentials;
 | 
			
		||||
    }
 | 
			
		||||
    getStatus() {
 | 
			
		||||
        return this.finalStatus;
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        throw new Error('Not yet implemented');
 | 
			
		||||
    }
 | 
			
		||||
    getMethod() {
 | 
			
		||||
        return this.methodName;
 | 
			
		||||
    }
 | 
			
		||||
    getHost() {
 | 
			
		||||
        return this.options.host;
 | 
			
		||||
    }
 | 
			
		||||
    _read(size) {
 | 
			
		||||
        /* If we have already emitted a status, we should not emit any more
 | 
			
		||||
         * messages and we should communicate that the stream has ended */
 | 
			
		||||
        if (this.finalStatus !== null) {
 | 
			
		||||
            this.push(null);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.canPush = true;
 | 
			
		||||
        if (this.http2Stream === null) {
 | 
			
		||||
            this.pendingRead = true;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            while (this.unpushedReadMessages.length > 0) {
 | 
			
		||||
                const nextMessage = this.unpushedReadMessages.shift();
 | 
			
		||||
                this.canPush = this.push(nextMessage);
 | 
			
		||||
                if (nextMessage === null || !this.canPush) {
 | 
			
		||||
                    this.canPush = false;
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            /* Only resume reading from the http2Stream if we don't have any pending
 | 
			
		||||
             * messages to emit, and we haven't gotten the signal to stop pushing
 | 
			
		||||
             * messages */
 | 
			
		||||
            this.http2Stream.resume();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    _write(chunk, encoding, cb) {
 | 
			
		||||
        this.filterStack.sendMessage(Promise.resolve(chunk)).then(message => {
 | 
			
		||||
            if (this.http2Stream === null) {
 | 
			
		||||
                this.pendingWrite = message.message;
 | 
			
		||||
                this.pendingWriteCallback = cb;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                this.http2Stream.write(message.message, cb);
 | 
			
		||||
            }
 | 
			
		||||
        }, this.handleFilterError.bind(this));
 | 
			
		||||
    }
 | 
			
		||||
    _final(cb) {
 | 
			
		||||
        if (this.http2Stream === null) {
 | 
			
		||||
            this.pendingFinalCallback = cb;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.http2Stream.end(cb);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Http2CallStream = Http2CallStream;
 | 
			
		||||
//# sourceMappingURL=call-stream.js.map
 | 
			
		||||
							
								
								
									
										72
									
								
								node_modules/@grpc/grpc-js/build/src/call.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								node_modules/@grpc/grpc-js/build/src/call.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { EventEmitter } from 'events';
 | 
			
		||||
import { Duplex, Readable, Writable } from 'stream';
 | 
			
		||||
import { Call, StatusObject } from './call-stream';
 | 
			
		||||
import { EmitterAugmentation1 } from './events';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
import { ObjectReadable, ObjectWritable } from './object-stream';
 | 
			
		||||
/**
 | 
			
		||||
 * A type extending the built-in Error object with additional fields.
 | 
			
		||||
 */
 | 
			
		||||
export declare type ServiceError = StatusObject & Error;
 | 
			
		||||
/**
 | 
			
		||||
 * A base type for all user-facing values returned by client-side method calls.
 | 
			
		||||
 */
 | 
			
		||||
export declare type SurfaceCall = {
 | 
			
		||||
    cancel(): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
} & EmitterAugmentation1<'metadata', Metadata> & EmitterAugmentation1<'status', StatusObject> & EventEmitter;
 | 
			
		||||
/**
 | 
			
		||||
 * A type representing the return value of a unary method call.
 | 
			
		||||
 */
 | 
			
		||||
export declare type ClientUnaryCall = SurfaceCall;
 | 
			
		||||
/**
 | 
			
		||||
 * A type representing the return value of a server stream method call.
 | 
			
		||||
 */
 | 
			
		||||
export declare type ClientReadableStream<ResponseType> = {
 | 
			
		||||
    deserialize: (chunk: Buffer) => ResponseType;
 | 
			
		||||
} & SurfaceCall & ObjectReadable<ResponseType>;
 | 
			
		||||
/**
 | 
			
		||||
 * A type representing the return value of a client stream method call.
 | 
			
		||||
 */
 | 
			
		||||
export declare type ClientWritableStream<RequestType> = {
 | 
			
		||||
    serialize: (value: RequestType) => Buffer;
 | 
			
		||||
} & SurfaceCall & ObjectWritable<RequestType>;
 | 
			
		||||
/**
 | 
			
		||||
 * A type representing the return value of a bidirectional stream method call.
 | 
			
		||||
 */
 | 
			
		||||
export declare type ClientDuplexStream<RequestType, ResponseType> = ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
 | 
			
		||||
export declare class ClientUnaryCallImpl extends EventEmitter implements ClientUnaryCall {
 | 
			
		||||
    private readonly call;
 | 
			
		||||
    constructor(call: Call);
 | 
			
		||||
    cancel(): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
}
 | 
			
		||||
export declare class ClientReadableStreamImpl<ResponseType> extends Readable implements ClientReadableStream<ResponseType> {
 | 
			
		||||
    private readonly call;
 | 
			
		||||
    readonly deserialize: (chunk: Buffer) => ResponseType;
 | 
			
		||||
    constructor(call: Call, deserialize: (chunk: Buffer) => ResponseType);
 | 
			
		||||
    cancel(): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    _read(_size: number): void;
 | 
			
		||||
}
 | 
			
		||||
export declare class ClientWritableStreamImpl<RequestType> extends Writable implements ClientWritableStream<RequestType> {
 | 
			
		||||
    private readonly call;
 | 
			
		||||
    readonly serialize: (value: RequestType) => Buffer;
 | 
			
		||||
    constructor(call: Call, serialize: (value: RequestType) => Buffer);
 | 
			
		||||
    cancel(): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    _write(chunk: RequestType, encoding: string, cb: Function): void;
 | 
			
		||||
    _final(cb: Function): void;
 | 
			
		||||
}
 | 
			
		||||
export declare class ClientDuplexStreamImpl<RequestType, ResponseType> extends Duplex implements ClientDuplexStream<RequestType, ResponseType> {
 | 
			
		||||
    private readonly call;
 | 
			
		||||
    readonly serialize: (value: RequestType) => Buffer;
 | 
			
		||||
    readonly deserialize: (chunk: Buffer) => ResponseType;
 | 
			
		||||
    constructor(call: Call, serialize: (value: RequestType) => Buffer, deserialize: (chunk: Buffer) => ResponseType);
 | 
			
		||||
    cancel(): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    _read(_size: number): void;
 | 
			
		||||
    _write(chunk: RequestType, encoding: string, cb: Function): void;
 | 
			
		||||
    _final(cb: Function): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										170
									
								
								node_modules/@grpc/grpc-js/build/src/call.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								node_modules/@grpc/grpc-js/build/src/call.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,170 @@
 | 
			
		||||
"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");
 | 
			
		||||
const constants_1 = require("./constants");
 | 
			
		||||
class ClientUnaryCallImpl extends events_1.EventEmitter {
 | 
			
		||||
    constructor(call) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        call.on('metadata', (metadata) => {
 | 
			
		||||
            this.emit('metadata', metadata);
 | 
			
		||||
        });
 | 
			
		||||
        call.on('status', (status) => {
 | 
			
		||||
            this.emit('status', status);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    cancel() {
 | 
			
		||||
        this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        return this.call.getPeer();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ClientUnaryCallImpl = ClientUnaryCallImpl;
 | 
			
		||||
function setUpReadableStream(stream, call, deserialize) {
 | 
			
		||||
    let statusEmitted = false;
 | 
			
		||||
    call.on('data', (data) => {
 | 
			
		||||
        let deserialized;
 | 
			
		||||
        try {
 | 
			
		||||
            deserialized = deserialize(data);
 | 
			
		||||
        }
 | 
			
		||||
        catch (e) {
 | 
			
		||||
            call.cancelWithStatus(constants_1.Status.INTERNAL, 'Failed to parse server response');
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (!stream.push(deserialized)) {
 | 
			
		||||
            call.pause();
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    call.on('end', () => {
 | 
			
		||||
        if (statusEmitted) {
 | 
			
		||||
            stream.push(null);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            call.once('status', () => {
 | 
			
		||||
                stream.push(null);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    call.on('status', (status) => {
 | 
			
		||||
        if (status.code !== constants_1.Status.OK) {
 | 
			
		||||
            const error = Object.assign(new Error(status.details), status);
 | 
			
		||||
            stream.emit('error', error);
 | 
			
		||||
        }
 | 
			
		||||
        stream.emit('status', status);
 | 
			
		||||
        statusEmitted = true;
 | 
			
		||||
    });
 | 
			
		||||
    call.pause();
 | 
			
		||||
}
 | 
			
		||||
class ClientReadableStreamImpl extends stream_1.Readable {
 | 
			
		||||
    constructor(call, deserialize) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.deserialize = deserialize;
 | 
			
		||||
        call.on('metadata', (metadata) => {
 | 
			
		||||
            this.emit('metadata', metadata);
 | 
			
		||||
        });
 | 
			
		||||
        setUpReadableStream(this, call, deserialize);
 | 
			
		||||
    }
 | 
			
		||||
    cancel() {
 | 
			
		||||
        this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        return this.call.getPeer();
 | 
			
		||||
    }
 | 
			
		||||
    _read(_size) {
 | 
			
		||||
        this.call.resume();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ClientReadableStreamImpl = ClientReadableStreamImpl;
 | 
			
		||||
function tryWrite(call, serialize, chunk, encoding, cb) {
 | 
			
		||||
    let message;
 | 
			
		||||
    const flags = Number(encoding);
 | 
			
		||||
    try {
 | 
			
		||||
        message = serialize(chunk);
 | 
			
		||||
    }
 | 
			
		||||
    catch (e) {
 | 
			
		||||
        call.cancelWithStatus(constants_1.Status.INTERNAL, 'Serialization failure');
 | 
			
		||||
        cb(e);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    const writeObj = { message };
 | 
			
		||||
    if (!Number.isNaN(flags)) {
 | 
			
		||||
        writeObj.flags = flags;
 | 
			
		||||
    }
 | 
			
		||||
    call.write(writeObj, cb);
 | 
			
		||||
}
 | 
			
		||||
class ClientWritableStreamImpl extends stream_1.Writable {
 | 
			
		||||
    constructor(call, serialize) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.serialize = serialize;
 | 
			
		||||
        call.on('metadata', (metadata) => {
 | 
			
		||||
            this.emit('metadata', metadata);
 | 
			
		||||
        });
 | 
			
		||||
        call.on('status', (status) => {
 | 
			
		||||
            this.emit('status', status);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    cancel() {
 | 
			
		||||
        this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        return this.call.getPeer();
 | 
			
		||||
    }
 | 
			
		||||
    _write(chunk, encoding, cb) {
 | 
			
		||||
        tryWrite(this.call, this.serialize, chunk, encoding, cb);
 | 
			
		||||
    }
 | 
			
		||||
    _final(cb) {
 | 
			
		||||
        this.call.end();
 | 
			
		||||
        cb();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ClientWritableStreamImpl = ClientWritableStreamImpl;
 | 
			
		||||
class ClientDuplexStreamImpl extends stream_1.Duplex {
 | 
			
		||||
    constructor(call, serialize, deserialize) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.serialize = serialize;
 | 
			
		||||
        this.deserialize = deserialize;
 | 
			
		||||
        call.on('metadata', (metadata) => {
 | 
			
		||||
            this.emit('metadata', metadata);
 | 
			
		||||
        });
 | 
			
		||||
        setUpReadableStream(this, call, deserialize);
 | 
			
		||||
    }
 | 
			
		||||
    cancel() {
 | 
			
		||||
        this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        return this.call.getPeer();
 | 
			
		||||
    }
 | 
			
		||||
    _read(_size) {
 | 
			
		||||
        this.call.resume();
 | 
			
		||||
    }
 | 
			
		||||
    _write(chunk, encoding, cb) {
 | 
			
		||||
        tryWrite(this.call, this.serialize, chunk, encoding, cb);
 | 
			
		||||
    }
 | 
			
		||||
    _final(cb) {
 | 
			
		||||
        this.call.end();
 | 
			
		||||
        cb();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ClientDuplexStreamImpl = ClientDuplexStreamImpl;
 | 
			
		||||
//# sourceMappingURL=call.js.map
 | 
			
		||||
							
								
								
									
										73
									
								
								node_modules/@grpc/grpc-js/build/src/channel-credentials.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								node_modules/@grpc/grpc-js/build/src/channel-credentials.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { ConnectionOptions } from 'tls';
 | 
			
		||||
import { CallCredentials } from './call-credentials';
 | 
			
		||||
/**
 | 
			
		||||
 * A certificate as received by the checkServerIdentity callback.
 | 
			
		||||
 */
 | 
			
		||||
export interface Certificate {
 | 
			
		||||
    /**
 | 
			
		||||
     * The raw certificate in DER form.
 | 
			
		||||
     */
 | 
			
		||||
    raw: Buffer;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * A callback that will receive the expected hostname and presented peer
 | 
			
		||||
 * certificate as parameters. The callback should return an error to
 | 
			
		||||
 * indicate that the presented certificate is considered invalid and
 | 
			
		||||
 * otherwise returned undefined.
 | 
			
		||||
 */
 | 
			
		||||
export declare type CheckServerIdentityCallback = (hostname: string, cert: Certificate) => Error | undefined;
 | 
			
		||||
/**
 | 
			
		||||
 * Additional peer verification options that can be set when creating
 | 
			
		||||
 * SSL credentials.
 | 
			
		||||
 */
 | 
			
		||||
export interface VerifyOptions {
 | 
			
		||||
    /**
 | 
			
		||||
     * If set, this callback will be invoked after the usual hostname verification
 | 
			
		||||
     * has been performed on the peer certificate.
 | 
			
		||||
     */
 | 
			
		||||
    checkServerIdentity?: CheckServerIdentityCallback;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * A class that contains credentials for communicating over a channel, as well
 | 
			
		||||
 * as a set of per-call credentials, which are applied to every method call made
 | 
			
		||||
 * over a channel initialized with an instance of this class.
 | 
			
		||||
 */
 | 
			
		||||
export declare abstract class ChannelCredentials {
 | 
			
		||||
    protected callCredentials: CallCredentials;
 | 
			
		||||
    protected constructor(callCredentials?: CallCredentials);
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a copy of this object with the included set of per-call credentials
 | 
			
		||||
     * expanded to include callCredentials.
 | 
			
		||||
     * @param callCredentials A CallCredentials object to associate with this
 | 
			
		||||
     * instance.
 | 
			
		||||
     */
 | 
			
		||||
    abstract compose(callCredentials: CallCredentials): ChannelCredentials;
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the set of per-call credentials associated with this instance.
 | 
			
		||||
     */
 | 
			
		||||
    _getCallCredentials(): CallCredentials;
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a SecureContext object generated from input parameters if this
 | 
			
		||||
     * instance was created with createSsl, or null if this instance was created
 | 
			
		||||
     * with createInsecure.
 | 
			
		||||
     */
 | 
			
		||||
    abstract _getConnectionOptions(): ConnectionOptions | null;
 | 
			
		||||
    /**
 | 
			
		||||
     * Indicates whether this credentials object creates a secure channel.
 | 
			
		||||
     */
 | 
			
		||||
    abstract _isSecure(): boolean;
 | 
			
		||||
    /**
 | 
			
		||||
     * Return a new ChannelCredentials instance with a given set of credentials.
 | 
			
		||||
     * The resulting instance can be used to construct a Channel that communicates
 | 
			
		||||
     * over TLS.
 | 
			
		||||
     * @param rootCerts The root certificate data.
 | 
			
		||||
     * @param privateKey The client certificate private key, if available.
 | 
			
		||||
     * @param certChain The client certificate key chain, if available.
 | 
			
		||||
     */
 | 
			
		||||
    static createSsl(rootCerts?: Buffer | null, privateKey?: Buffer | null, certChain?: Buffer | null, verifyOptions?: VerifyOptions): ChannelCredentials;
 | 
			
		||||
    /**
 | 
			
		||||
     * Return a new ChannelCredentials instance with no credentials.
 | 
			
		||||
     */
 | 
			
		||||
    static createInsecure(): ChannelCredentials;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										111
									
								
								node_modules/@grpc/grpc-js/build/src/channel-credentials.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								node_modules/@grpc/grpc-js/build/src/channel-credentials.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
"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");
 | 
			
		||||
// tslint:disable-next-line:no-any
 | 
			
		||||
function verifyIsBufferOrNull(obj, friendlyName) {
 | 
			
		||||
    if (obj && !(obj instanceof Buffer)) {
 | 
			
		||||
        throw new TypeError(`${friendlyName}, if provided, must be a Buffer.`);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * A class that contains credentials for communicating over a channel, as well
 | 
			
		||||
 * as a set of per-call credentials, which are applied to every method call made
 | 
			
		||||
 * over a channel initialized with an instance of this class.
 | 
			
		||||
 */
 | 
			
		||||
class ChannelCredentials {
 | 
			
		||||
    constructor(callCredentials) {
 | 
			
		||||
        this.callCredentials = callCredentials || call_credentials_1.CallCredentials.createEmpty();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the set of per-call credentials associated with this instance.
 | 
			
		||||
     */
 | 
			
		||||
    _getCallCredentials() {
 | 
			
		||||
        return this.callCredentials;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Return a new ChannelCredentials instance with a given set of credentials.
 | 
			
		||||
     * The resulting instance can be used to construct a Channel that communicates
 | 
			
		||||
     * over TLS.
 | 
			
		||||
     * @param rootCerts The root certificate data.
 | 
			
		||||
     * @param privateKey The client certificate private key, if available.
 | 
			
		||||
     * @param certChain The client certificate key chain, if available.
 | 
			
		||||
     */
 | 
			
		||||
    static createSsl(rootCerts, privateKey, certChain, verifyOptions) {
 | 
			
		||||
        verifyIsBufferOrNull(rootCerts, 'Root certificate');
 | 
			
		||||
        verifyIsBufferOrNull(privateKey, 'Private key');
 | 
			
		||||
        verifyIsBufferOrNull(certChain, 'Certificate chain');
 | 
			
		||||
        if (privateKey && !certChain) {
 | 
			
		||||
            throw new Error('Private key must be given with accompanying certificate chain');
 | 
			
		||||
        }
 | 
			
		||||
        if (!privateKey && certChain) {
 | 
			
		||||
            throw new Error('Certificate chain must be given with accompanying private key');
 | 
			
		||||
        }
 | 
			
		||||
        const secureContext = tls_1.createSecureContext({
 | 
			
		||||
            ca: rootCerts || undefined,
 | 
			
		||||
            key: privateKey || undefined,
 | 
			
		||||
            cert: certChain || undefined,
 | 
			
		||||
        });
 | 
			
		||||
        const connectionOptions = { secureContext };
 | 
			
		||||
        if (verifyOptions && verifyOptions.checkServerIdentity) {
 | 
			
		||||
            connectionOptions.checkServerIdentity = (host, cert) => {
 | 
			
		||||
                return verifyOptions.checkServerIdentity(host, { raw: cert.raw });
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
        return new SecureChannelCredentialsImpl(connectionOptions);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Return a new ChannelCredentials instance with no credentials.
 | 
			
		||||
     */
 | 
			
		||||
    static createInsecure() {
 | 
			
		||||
        return new InsecureChannelCredentialsImpl();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ChannelCredentials = ChannelCredentials;
 | 
			
		||||
class InsecureChannelCredentialsImpl extends ChannelCredentials {
 | 
			
		||||
    constructor(callCredentials) {
 | 
			
		||||
        super(callCredentials);
 | 
			
		||||
    }
 | 
			
		||||
    compose(callCredentials) {
 | 
			
		||||
        throw new Error('Cannot compose insecure credentials');
 | 
			
		||||
    }
 | 
			
		||||
    _getConnectionOptions() {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    _isSecure() {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class SecureChannelCredentialsImpl extends ChannelCredentials {
 | 
			
		||||
    constructor(connectionOptions, callCredentials) {
 | 
			
		||||
        super(callCredentials);
 | 
			
		||||
        this.connectionOptions = connectionOptions;
 | 
			
		||||
    }
 | 
			
		||||
    compose(callCredentials) {
 | 
			
		||||
        const combinedCallCredentials = this.callCredentials.compose(callCredentials);
 | 
			
		||||
        return new SecureChannelCredentialsImpl(this.connectionOptions, combinedCallCredentials);
 | 
			
		||||
    }
 | 
			
		||||
    _getConnectionOptions() {
 | 
			
		||||
        return this.connectionOptions;
 | 
			
		||||
    }
 | 
			
		||||
    _isSecure() {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//# sourceMappingURL=channel-credentials.js.map
 | 
			
		||||
							
								
								
									
										24
									
								
								node_modules/@grpc/grpc-js/build/src/channel-options.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								node_modules/@grpc/grpc-js/build/src/channel-options.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
/**
 | 
			
		||||
 * An interface that contains options used when initializing a Channel instance.
 | 
			
		||||
 */
 | 
			
		||||
export interface ChannelOptions {
 | 
			
		||||
    'grpc.ssl_target_name_override': string;
 | 
			
		||||
    'grpc.primary_user_agent': string;
 | 
			
		||||
    'grpc.secondary_user_agent': string;
 | 
			
		||||
    'grpc.default_authority': string;
 | 
			
		||||
    'grpc.keepalive_time_ms': number;
 | 
			
		||||
    'grpc.keepalive_timeout_ms': number;
 | 
			
		||||
    [key: string]: string | number;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * This is for checking provided options at runtime. This is an object for
 | 
			
		||||
 * easier membership checking.
 | 
			
		||||
 */
 | 
			
		||||
export declare const recognizedOptions: {
 | 
			
		||||
    'grpc.ssl_target_name_override': boolean;
 | 
			
		||||
    'grpc.primary_user_agent': boolean;
 | 
			
		||||
    'grpc.secondary_user_agent': boolean;
 | 
			
		||||
    'grpc.default_authority': boolean;
 | 
			
		||||
    'grpc.keepalive_time_ms': boolean;
 | 
			
		||||
    'grpc.keepalive_timeout_ms': boolean;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										31
									
								
								node_modules/@grpc/grpc-js/build/src/channel-options.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								node_modules/@grpc/grpc-js/build/src/channel-options.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
"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
 | 
			
		||||
 * easier membership checking.
 | 
			
		||||
 */
 | 
			
		||||
exports.recognizedOptions = {
 | 
			
		||||
    'grpc.ssl_target_name_override': true,
 | 
			
		||||
    'grpc.primary_user_agent': true,
 | 
			
		||||
    'grpc.secondary_user_agent': true,
 | 
			
		||||
    'grpc.default_authority': true,
 | 
			
		||||
    'grpc.keepalive_time_ms': true,
 | 
			
		||||
    'grpc.keepalive_timeout_ms': true,
 | 
			
		||||
};
 | 
			
		||||
//# sourceMappingURL=channel-options.js.map
 | 
			
		||||
							
								
								
									
										92
									
								
								node_modules/@grpc/grpc-js/build/src/channel.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								node_modules/@grpc/grpc-js/build/src/channel.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { EventEmitter } from 'events';
 | 
			
		||||
import { Call, Deadline, Http2CallStream } from './call-stream';
 | 
			
		||||
import { ChannelCredentials } from './channel-credentials';
 | 
			
		||||
import { ChannelOptions } from './channel-options';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export declare enum ConnectivityState {
 | 
			
		||||
    CONNECTING = 0,
 | 
			
		||||
    READY = 1,
 | 
			
		||||
    TRANSIENT_FAILURE = 2,
 | 
			
		||||
    IDLE = 3,
 | 
			
		||||
    SHUTDOWN = 4
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * An interface that represents a communication channel to a server specified
 | 
			
		||||
 * by a given address.
 | 
			
		||||
 */
 | 
			
		||||
export interface Channel {
 | 
			
		||||
    /**
 | 
			
		||||
     * Close the channel. This has the same functionality as the existing
 | 
			
		||||
     * grpc.Client.prototype.close
 | 
			
		||||
     */
 | 
			
		||||
    close(): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the target that this channel connects to
 | 
			
		||||
     */
 | 
			
		||||
    getTarget(): string;
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the channel's current connectivity state. This method is here mainly
 | 
			
		||||
     * because it is in the existing internal Channel class, and there isn't
 | 
			
		||||
     * another good place to put it.
 | 
			
		||||
     * @param tryToConnect If true, the channel will start connecting if it is
 | 
			
		||||
     *     idle. Otherwise, idle channels will only start connecting when a
 | 
			
		||||
     *     call starts.
 | 
			
		||||
     */
 | 
			
		||||
    getConnectivityState(tryToConnect: boolean): ConnectivityState;
 | 
			
		||||
    /**
 | 
			
		||||
     * Watch for connectivity state changes. This is also here mainly because
 | 
			
		||||
     * it is in the existing external Channel class.
 | 
			
		||||
     * @param currentState The state to watch for transitions from. This should
 | 
			
		||||
     *     always be populated by calling getConnectivityState immediately
 | 
			
		||||
     *     before.
 | 
			
		||||
     * @param deadline A deadline for waiting for a state change
 | 
			
		||||
     * @param callback Called with no error when a state change, or with an
 | 
			
		||||
     *     error if the deadline passes without a state change.
 | 
			
		||||
     */
 | 
			
		||||
    watchConnectivityState(currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a call object. Call is an opaque type that is used by the Client
 | 
			
		||||
     * class. This function is called by the gRPC library when starting a
 | 
			
		||||
     * request. Implementers should return an instance of Call that is returned
 | 
			
		||||
     * from calling createCall on an instance of the provided Channel class.
 | 
			
		||||
     * @param method The full method string to request.
 | 
			
		||||
     * @param deadline The call deadline
 | 
			
		||||
     * @param host A host string override for making the request
 | 
			
		||||
     * @param parentCall A server call to propagate some information from
 | 
			
		||||
     * @param propagateFlags A bitwise combination of elements of grpc.propagate
 | 
			
		||||
     *     that indicates what information to propagate from parentCall.
 | 
			
		||||
     */
 | 
			
		||||
    createCall(method: string, deadline: Deadline | null | undefined, host: string | null | undefined, parentCall: Call | null | undefined, propagateFlags: number | null | undefined): Call;
 | 
			
		||||
}
 | 
			
		||||
export declare class Http2Channel extends EventEmitter implements Channel {
 | 
			
		||||
    readonly credentials: ChannelCredentials;
 | 
			
		||||
    private readonly options;
 | 
			
		||||
    private readonly userAgent;
 | 
			
		||||
    private readonly target;
 | 
			
		||||
    private readonly defaultAuthority;
 | 
			
		||||
    private connectivityState;
 | 
			
		||||
    private connecting;
 | 
			
		||||
    private subChannel;
 | 
			
		||||
    private filterStackFactory;
 | 
			
		||||
    private subChannelConnectCallback;
 | 
			
		||||
    private subChannelCloseCallback;
 | 
			
		||||
    private backoffTimerId;
 | 
			
		||||
    private currentBackoff;
 | 
			
		||||
    private currentBackoffDeadline;
 | 
			
		||||
    private handleStateChange;
 | 
			
		||||
    private transitionToState;
 | 
			
		||||
    private startConnecting;
 | 
			
		||||
    constructor(address: string, credentials: ChannelCredentials, options: Partial<ChannelOptions>);
 | 
			
		||||
    _startHttp2Stream(authority: string, methodName: string, stream: Http2CallStream, metadata: Metadata): void;
 | 
			
		||||
    createCall(method: string, deadline: Deadline | null | undefined, host: string | null | undefined, parentCall: Call | null | undefined, propagateFlags: number | null | undefined): Call;
 | 
			
		||||
    /**
 | 
			
		||||
     * Attempts to connect, returning a Promise that resolves when the connection
 | 
			
		||||
     * is successful, or rejects if the channel is shut down.
 | 
			
		||||
     */
 | 
			
		||||
    private connect;
 | 
			
		||||
    getConnectivityState(tryToConnect: boolean): ConnectivityState;
 | 
			
		||||
    watchConnectivityState(currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void): void;
 | 
			
		||||
    getTarget(): string;
 | 
			
		||||
    close(): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										319
									
								
								node_modules/@grpc/grpc-js/build/src/channel.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										319
									
								
								node_modules/@grpc/grpc-js/build/src/channel.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,319 @@
 | 
			
		||||
"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");
 | 
			
		||||
const tls_1 = require("tls");
 | 
			
		||||
const url = require("url");
 | 
			
		||||
const call_credentials_filter_1 = require("./call-credentials-filter");
 | 
			
		||||
const call_stream_1 = require("./call-stream");
 | 
			
		||||
const channel_options_1 = require("./channel-options");
 | 
			
		||||
const compression_filter_1 = require("./compression-filter");
 | 
			
		||||
const constants_1 = require("./constants");
 | 
			
		||||
const deadline_filter_1 = require("./deadline-filter");
 | 
			
		||||
const filter_stack_1 = require("./filter-stack");
 | 
			
		||||
const metadata_status_filter_1 = require("./metadata-status-filter");
 | 
			
		||||
const subchannel_1 = require("./subchannel");
 | 
			
		||||
const { version: clientVersion } = require('../../package.json');
 | 
			
		||||
const MIN_CONNECT_TIMEOUT_MS = 20000;
 | 
			
		||||
const INITIAL_BACKOFF_MS = 1000;
 | 
			
		||||
const BACKOFF_MULTIPLIER = 1.6;
 | 
			
		||||
const MAX_BACKOFF_MS = 120000;
 | 
			
		||||
const BACKOFF_JITTER = 0.2;
 | 
			
		||||
const { HTTP2_HEADER_AUTHORITY, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_TE, HTTP2_HEADER_USER_AGENT, } = http2.constants;
 | 
			
		||||
var ConnectivityState;
 | 
			
		||||
(function (ConnectivityState) {
 | 
			
		||||
    ConnectivityState[ConnectivityState["CONNECTING"] = 0] = "CONNECTING";
 | 
			
		||||
    ConnectivityState[ConnectivityState["READY"] = 1] = "READY";
 | 
			
		||||
    ConnectivityState[ConnectivityState["TRANSIENT_FAILURE"] = 2] = "TRANSIENT_FAILURE";
 | 
			
		||||
    ConnectivityState[ConnectivityState["IDLE"] = 3] = "IDLE";
 | 
			
		||||
    ConnectivityState[ConnectivityState["SHUTDOWN"] = 4] = "SHUTDOWN";
 | 
			
		||||
})(ConnectivityState = exports.ConnectivityState || (exports.ConnectivityState = {}));
 | 
			
		||||
function uniformRandom(min, max) {
 | 
			
		||||
    return Math.random() * (max - min) + min;
 | 
			
		||||
}
 | 
			
		||||
class Http2Channel extends events_1.EventEmitter {
 | 
			
		||||
    constructor(address, credentials, options) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.credentials = credentials;
 | 
			
		||||
        this.options = options;
 | 
			
		||||
        this.connectivityState = ConnectivityState.IDLE;
 | 
			
		||||
        // Helper Promise object only used in the implementation of connect().
 | 
			
		||||
        this.connecting = null;
 | 
			
		||||
        /* For now, we have up to one subchannel, which will exist as long as we are
 | 
			
		||||
         * connecting or trying to connect */
 | 
			
		||||
        this.subChannel = null;
 | 
			
		||||
        this.subChannelConnectCallback = () => { };
 | 
			
		||||
        this.subChannelCloseCallback = () => { };
 | 
			
		||||
        this.currentBackoff = INITIAL_BACKOFF_MS;
 | 
			
		||||
        for (const option in options) {
 | 
			
		||||
            if (options.hasOwnProperty(option)) {
 | 
			
		||||
                if (!channel_options_1.recognizedOptions.hasOwnProperty(option)) {
 | 
			
		||||
                    console.warn(`Unrecognized channel argument '${option}' will be ignored.`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (credentials._isSecure()) {
 | 
			
		||||
            this.target = new url.URL(`https://${address}`);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.target = new url.URL(`http://${address}`);
 | 
			
		||||
        }
 | 
			
		||||
        // TODO(murgatroid99): Add more centralized handling of channel options
 | 
			
		||||
        if (this.options['grpc.default_authority']) {
 | 
			
		||||
            this.defaultAuthority = this.options['grpc.default_authority'];
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.defaultAuthority = this.target.host;
 | 
			
		||||
        }
 | 
			
		||||
        this.filterStackFactory = new filter_stack_1.FilterStackFactory([
 | 
			
		||||
            new call_credentials_filter_1.CallCredentialsFilterFactory(this),
 | 
			
		||||
            new deadline_filter_1.DeadlineFilterFactory(this),
 | 
			
		||||
            new metadata_status_filter_1.MetadataStatusFilterFactory(this),
 | 
			
		||||
            new compression_filter_1.CompressionFilterFactory(this),
 | 
			
		||||
        ]);
 | 
			
		||||
        this.currentBackoffDeadline = new Date();
 | 
			
		||||
        /* The only purpose of these lines is to ensure that this.backoffTimerId has
 | 
			
		||||
         * a value of type NodeJS.Timer. */
 | 
			
		||||
        this.backoffTimerId = setTimeout(() => { }, 0);
 | 
			
		||||
        // Build user-agent string.
 | 
			
		||||
        this.userAgent = [
 | 
			
		||||
            options['grpc.primary_user_agent'],
 | 
			
		||||
            `grpc-node-js/${clientVersion}`,
 | 
			
		||||
            options['grpc.secondary_user_agent'],
 | 
			
		||||
        ]
 | 
			
		||||
            .filter(e => e)
 | 
			
		||||
            .join(' '); // remove falsey values first
 | 
			
		||||
    }
 | 
			
		||||
    handleStateChange(oldState, newState) {
 | 
			
		||||
        const now = new Date();
 | 
			
		||||
        switch (newState) {
 | 
			
		||||
            case ConnectivityState.CONNECTING:
 | 
			
		||||
                if (oldState === ConnectivityState.IDLE) {
 | 
			
		||||
                    this.currentBackoff = INITIAL_BACKOFF_MS;
 | 
			
		||||
                    this.currentBackoffDeadline = new Date(now.getTime() + INITIAL_BACKOFF_MS);
 | 
			
		||||
                }
 | 
			
		||||
                else if (oldState === ConnectivityState.TRANSIENT_FAILURE) {
 | 
			
		||||
                    this.currentBackoff = Math.min(this.currentBackoff * BACKOFF_MULTIPLIER, MAX_BACKOFF_MS);
 | 
			
		||||
                    const jitterMagnitude = BACKOFF_JITTER * this.currentBackoff;
 | 
			
		||||
                    this.currentBackoffDeadline = new Date(now.getTime() +
 | 
			
		||||
                        this.currentBackoff +
 | 
			
		||||
                        uniformRandom(-jitterMagnitude, jitterMagnitude));
 | 
			
		||||
                }
 | 
			
		||||
                this.startConnecting();
 | 
			
		||||
                break;
 | 
			
		||||
            case ConnectivityState.READY:
 | 
			
		||||
                this.emit('connect');
 | 
			
		||||
                break;
 | 
			
		||||
            case ConnectivityState.TRANSIENT_FAILURE:
 | 
			
		||||
                this.subChannel = null;
 | 
			
		||||
                this.backoffTimerId = setTimeout(() => {
 | 
			
		||||
                    this.transitionToState([ConnectivityState.TRANSIENT_FAILURE], ConnectivityState.CONNECTING);
 | 
			
		||||
                }, this.currentBackoffDeadline.getTime() - now.getTime());
 | 
			
		||||
                break;
 | 
			
		||||
            case ConnectivityState.IDLE:
 | 
			
		||||
            case ConnectivityState.SHUTDOWN:
 | 
			
		||||
                if (this.subChannel) {
 | 
			
		||||
                    this.subChannel.close();
 | 
			
		||||
                    this.subChannel.removeListener('connect', this.subChannelConnectCallback);
 | 
			
		||||
                    this.subChannel.removeListener('close', this.subChannelCloseCallback);
 | 
			
		||||
                    this.subChannel = null;
 | 
			
		||||
                    this.emit('shutdown');
 | 
			
		||||
                    clearTimeout(this.backoffTimerId);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                throw new Error('This should never happen');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // Transition from any of a set of oldStates to a specific newState
 | 
			
		||||
    transitionToState(oldStates, newState) {
 | 
			
		||||
        if (oldStates.indexOf(this.connectivityState) > -1) {
 | 
			
		||||
            const oldState = this.connectivityState;
 | 
			
		||||
            this.connectivityState = newState;
 | 
			
		||||
            this.handleStateChange(oldState, newState);
 | 
			
		||||
            this.emit('connectivityStateChanged', newState);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    startConnecting() {
 | 
			
		||||
        const connectionOptions = this.credentials._getConnectionOptions() || {};
 | 
			
		||||
        if (connectionOptions.secureContext !== null) {
 | 
			
		||||
            // If provided, the value of grpc.ssl_target_name_override should be used
 | 
			
		||||
            // to override the target hostname when checking server identity.
 | 
			
		||||
            // This option is used for testing only.
 | 
			
		||||
            if (this.options['grpc.ssl_target_name_override']) {
 | 
			
		||||
                const sslTargetNameOverride = this.options['grpc.ssl_target_name_override'];
 | 
			
		||||
                connectionOptions.checkServerIdentity = (host, cert) => {
 | 
			
		||||
                    return tls_1.checkServerIdentity(sslTargetNameOverride, cert);
 | 
			
		||||
                };
 | 
			
		||||
                connectionOptions.servername = sslTargetNameOverride;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const subChannel = new subchannel_1.Http2SubChannel(this.target, connectionOptions, this.userAgent, this.options);
 | 
			
		||||
        this.subChannel = subChannel;
 | 
			
		||||
        const now = new Date();
 | 
			
		||||
        const connectionTimeout = Math.max(this.currentBackoffDeadline.getTime() - now.getTime(), MIN_CONNECT_TIMEOUT_MS);
 | 
			
		||||
        const connectionTimerId = setTimeout(() => {
 | 
			
		||||
            // This should trigger the 'close' event, which will send us back to
 | 
			
		||||
            // TRANSIENT_FAILURE
 | 
			
		||||
            subChannel.close();
 | 
			
		||||
        }, connectionTimeout);
 | 
			
		||||
        this.subChannelConnectCallback = () => {
 | 
			
		||||
            // Connection succeeded
 | 
			
		||||
            clearTimeout(connectionTimerId);
 | 
			
		||||
            this.transitionToState([ConnectivityState.CONNECTING], ConnectivityState.READY);
 | 
			
		||||
        };
 | 
			
		||||
        subChannel.once('connect', this.subChannelConnectCallback);
 | 
			
		||||
        this.subChannelCloseCallback = () => {
 | 
			
		||||
            // Connection failed
 | 
			
		||||
            clearTimeout(connectionTimerId);
 | 
			
		||||
            /* TODO(murgatroid99): verify that this works for
 | 
			
		||||
             * CONNECTING->TRANSITIVE_FAILURE see nodejs/node#16645 */
 | 
			
		||||
            this.transitionToState([ConnectivityState.CONNECTING, ConnectivityState.READY], ConnectivityState.TRANSIENT_FAILURE);
 | 
			
		||||
        };
 | 
			
		||||
        subChannel.once('close', this.subChannelCloseCallback);
 | 
			
		||||
    }
 | 
			
		||||
    _startHttp2Stream(authority, methodName, stream, metadata) {
 | 
			
		||||
        const connectMetadata = this.connect().then(() => metadata.clone());
 | 
			
		||||
        const finalMetadata = stream.filterStack.sendMetadata(connectMetadata);
 | 
			
		||||
        finalMetadata
 | 
			
		||||
            .then(metadataValue => {
 | 
			
		||||
            const headers = metadataValue.toHttp2Headers();
 | 
			
		||||
            headers[HTTP2_HEADER_AUTHORITY] = authority;
 | 
			
		||||
            headers[HTTP2_HEADER_USER_AGENT] = this.userAgent;
 | 
			
		||||
            headers[HTTP2_HEADER_CONTENT_TYPE] = 'application/grpc';
 | 
			
		||||
            headers[HTTP2_HEADER_METHOD] = 'POST';
 | 
			
		||||
            headers[HTTP2_HEADER_PATH] = methodName;
 | 
			
		||||
            headers[HTTP2_HEADER_TE] = 'trailers';
 | 
			
		||||
            if (this.connectivityState === ConnectivityState.READY) {
 | 
			
		||||
                const subChannel = this.subChannel;
 | 
			
		||||
                subChannel.startCallStream(metadataValue, stream);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                /* In this case, we lost the connection while finalizing
 | 
			
		||||
                 * metadata. That should be very unusual */
 | 
			
		||||
                setImmediate(() => {
 | 
			
		||||
                    this._startHttp2Stream(authority, methodName, stream, metadata);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
            .catch((error) => {
 | 
			
		||||
            // We assume the error code isn't 0 (Status.OK)
 | 
			
		||||
            stream.cancelWithStatus(error.code || constants_1.Status.UNKNOWN, `Getting metadata from plugin failed with error: ${error.message}`);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    createCall(method, deadline, host, parentCall, propagateFlags) {
 | 
			
		||||
        if (this.connectivityState === ConnectivityState.SHUTDOWN) {
 | 
			
		||||
            throw new Error('Channel has been shut down');
 | 
			
		||||
        }
 | 
			
		||||
        const finalOptions = {
 | 
			
		||||
            deadline: deadline === null || deadline === undefined ? Infinity : deadline,
 | 
			
		||||
            flags: propagateFlags || 0,
 | 
			
		||||
            host: host || this.defaultAuthority,
 | 
			
		||||
            parentCall: parentCall || null,
 | 
			
		||||
        };
 | 
			
		||||
        const stream = new call_stream_1.Http2CallStream(method, this, finalOptions, this.filterStackFactory);
 | 
			
		||||
        return stream;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Attempts to connect, returning a Promise that resolves when the connection
 | 
			
		||||
     * is successful, or rejects if the channel is shut down.
 | 
			
		||||
     */
 | 
			
		||||
    connect() {
 | 
			
		||||
        if (this.connectivityState === ConnectivityState.READY) {
 | 
			
		||||
            return Promise.resolve();
 | 
			
		||||
        }
 | 
			
		||||
        else if (this.connectivityState === ConnectivityState.SHUTDOWN) {
 | 
			
		||||
            return Promise.reject(new Error('Channel has been shut down'));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            // In effect, this.connecting is only assigned upon the first attempt to
 | 
			
		||||
            // transition from IDLE to CONNECTING, so this condition could have also
 | 
			
		||||
            // been (connectivityState === IDLE).
 | 
			
		||||
            if (!this.connecting) {
 | 
			
		||||
                this.connecting = new Promise((resolve, reject) => {
 | 
			
		||||
                    this.transitionToState([ConnectivityState.IDLE], ConnectivityState.CONNECTING);
 | 
			
		||||
                    const onConnect = () => {
 | 
			
		||||
                        this.connecting = null;
 | 
			
		||||
                        this.removeListener('shutdown', onShutdown);
 | 
			
		||||
                        resolve();
 | 
			
		||||
                    };
 | 
			
		||||
                    const onShutdown = () => {
 | 
			
		||||
                        this.connecting = null;
 | 
			
		||||
                        this.removeListener('connect', onConnect);
 | 
			
		||||
                        reject(new Error('Channel has been shut down'));
 | 
			
		||||
                    };
 | 
			
		||||
                    this.once('connect', onConnect);
 | 
			
		||||
                    this.once('shutdown', onShutdown);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            return this.connecting;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    getConnectivityState(tryToConnect) {
 | 
			
		||||
        if (tryToConnect) {
 | 
			
		||||
            this.transitionToState([ConnectivityState.IDLE], ConnectivityState.CONNECTING);
 | 
			
		||||
        }
 | 
			
		||||
        return this.connectivityState;
 | 
			
		||||
    }
 | 
			
		||||
    watchConnectivityState(currentState, deadline, callback) {
 | 
			
		||||
        if (this.connectivityState !== currentState) {
 | 
			
		||||
            /* If the connectivity state is different from the provided currentState,
 | 
			
		||||
             * we assume that a state change has successfully occurred */
 | 
			
		||||
            setImmediate(callback);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            let deadlineMs = 0;
 | 
			
		||||
            if (deadline instanceof Date) {
 | 
			
		||||
                deadlineMs = deadline.getTime();
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                deadlineMs = deadline;
 | 
			
		||||
            }
 | 
			
		||||
            let timeout = deadlineMs - Date.now();
 | 
			
		||||
            if (timeout < 0) {
 | 
			
		||||
                timeout = 0;
 | 
			
		||||
            }
 | 
			
		||||
            const timeoutId = setTimeout(() => {
 | 
			
		||||
                this.removeListener('connectivityStateChanged', eventCb);
 | 
			
		||||
                callback(new Error('Channel state did not change before deadline'));
 | 
			
		||||
            }, timeout);
 | 
			
		||||
            const eventCb = () => {
 | 
			
		||||
                clearTimeout(timeoutId);
 | 
			
		||||
                callback();
 | 
			
		||||
            };
 | 
			
		||||
            this.once('connectivityStateChanged', eventCb);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    getTarget() {
 | 
			
		||||
        return this.target.toString();
 | 
			
		||||
    }
 | 
			
		||||
    close() {
 | 
			
		||||
        if (this.connectivityState === ConnectivityState.SHUTDOWN) {
 | 
			
		||||
            throw new Error('Channel has been shut down');
 | 
			
		||||
        }
 | 
			
		||||
        this.transitionToState([
 | 
			
		||||
            ConnectivityState.CONNECTING,
 | 
			
		||||
            ConnectivityState.READY,
 | 
			
		||||
            ConnectivityState.TRANSIENT_FAILURE,
 | 
			
		||||
            ConnectivityState.IDLE,
 | 
			
		||||
        ], ConnectivityState.SHUTDOWN);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Http2Channel = Http2Channel;
 | 
			
		||||
//# sourceMappingURL=channel.js.map
 | 
			
		||||
							
								
								
									
										49
									
								
								node_modules/@grpc/grpc-js/build/src/client.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								node_modules/@grpc/grpc-js/build/src/client.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream, ServiceError } from './call';
 | 
			
		||||
import { CallCredentials } from './call-credentials';
 | 
			
		||||
import { Deadline } from './call-stream';
 | 
			
		||||
import { Channel } from './channel';
 | 
			
		||||
import { ChannelCredentials } from './channel-credentials';
 | 
			
		||||
import { ChannelOptions } from './channel-options';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
declare const CHANNEL_SYMBOL: unique symbol;
 | 
			
		||||
export interface UnaryCallback<ResponseType> {
 | 
			
		||||
    (err: ServiceError | null, value?: ResponseType): void;
 | 
			
		||||
}
 | 
			
		||||
export interface CallOptions {
 | 
			
		||||
    deadline?: Deadline;
 | 
			
		||||
    host?: string;
 | 
			
		||||
    propagate_flags?: number;
 | 
			
		||||
    credentials?: CallCredentials;
 | 
			
		||||
}
 | 
			
		||||
export declare type ClientOptions = Partial<ChannelOptions> & {
 | 
			
		||||
    channelOverride?: Channel;
 | 
			
		||||
    channelFactoryOverride?: (address: string, credentials: ChannelCredentials, options: ClientOptions) => Channel;
 | 
			
		||||
};
 | 
			
		||||
/**
 | 
			
		||||
 * A generic gRPC client. Primarily useful as a base class for all generated
 | 
			
		||||
 * clients.
 | 
			
		||||
 */
 | 
			
		||||
export declare class Client {
 | 
			
		||||
    private readonly [CHANNEL_SYMBOL];
 | 
			
		||||
    constructor(address: string, credentials: ChannelCredentials, options?: ClientOptions);
 | 
			
		||||
    close(): void;
 | 
			
		||||
    getChannel(): Channel;
 | 
			
		||||
    waitForReady(deadline: Deadline, callback: (error?: Error) => void): void;
 | 
			
		||||
    private handleUnaryResponse;
 | 
			
		||||
    private checkOptionalUnaryResponseArguments;
 | 
			
		||||
    makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
 | 
			
		||||
    makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
 | 
			
		||||
    makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
 | 
			
		||||
    makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
 | 
			
		||||
    makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
 | 
			
		||||
    makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
 | 
			
		||||
    makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
 | 
			
		||||
    makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
 | 
			
		||||
    private checkMetadataAndOptions;
 | 
			
		||||
    makeServerStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options?: CallOptions): ClientReadableStream<ResponseType>;
 | 
			
		||||
    makeServerStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options?: CallOptions): ClientReadableStream<ResponseType>;
 | 
			
		||||
    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 {};
 | 
			
		||||
							
								
								
									
										193
									
								
								node_modules/@grpc/grpc-js/build/src/client.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								node_modules/@grpc/grpc-js/build/src/client.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,193 @@
 | 
			
		||||
"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");
 | 
			
		||||
const CHANNEL_SYMBOL = Symbol();
 | 
			
		||||
/**
 | 
			
		||||
 * A generic gRPC client. Primarily useful as a base class for all generated
 | 
			
		||||
 * clients.
 | 
			
		||||
 */
 | 
			
		||||
class Client {
 | 
			
		||||
    constructor(address, credentials, options = {}) {
 | 
			
		||||
        if (options.channelOverride) {
 | 
			
		||||
            this[CHANNEL_SYMBOL] = options.channelOverride;
 | 
			
		||||
        }
 | 
			
		||||
        else if (options.channelFactoryOverride) {
 | 
			
		||||
            this[CHANNEL_SYMBOL] = options.channelFactoryOverride(address, credentials, options);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this[CHANNEL_SYMBOL] = new channel_1.Http2Channel(address, credentials, options);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    close() {
 | 
			
		||||
        this[CHANNEL_SYMBOL].close();
 | 
			
		||||
    }
 | 
			
		||||
    getChannel() {
 | 
			
		||||
        return this[CHANNEL_SYMBOL];
 | 
			
		||||
    }
 | 
			
		||||
    waitForReady(deadline, callback) {
 | 
			
		||||
        const checkState = (err) => {
 | 
			
		||||
            if (err) {
 | 
			
		||||
                callback(new Error('Failed to connect before the deadline'));
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            let newState;
 | 
			
		||||
            try {
 | 
			
		||||
                newState = this[CHANNEL_SYMBOL].getConnectivityState(true);
 | 
			
		||||
            }
 | 
			
		||||
            catch (e) {
 | 
			
		||||
                callback(new Error('The channel has been closed'));
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (newState === channel_1.ConnectivityState.READY) {
 | 
			
		||||
                callback();
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                try {
 | 
			
		||||
                    this[CHANNEL_SYMBOL].watchConnectivityState(newState, deadline, checkState);
 | 
			
		||||
                }
 | 
			
		||||
                catch (e) {
 | 
			
		||||
                    callback(new Error('The channel has been closed'));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
        setImmediate(checkState);
 | 
			
		||||
    }
 | 
			
		||||
    handleUnaryResponse(call, deserialize, callback) {
 | 
			
		||||
        let responseMessage = null;
 | 
			
		||||
        call.on('data', (data) => {
 | 
			
		||||
            if (responseMessage != null) {
 | 
			
		||||
                call.cancelWithStatus(constants_1.Status.INTERNAL, 'Too many responses received');
 | 
			
		||||
            }
 | 
			
		||||
            try {
 | 
			
		||||
                responseMessage = deserialize(data);
 | 
			
		||||
            }
 | 
			
		||||
            catch (e) {
 | 
			
		||||
                call.cancelWithStatus(constants_1.Status.INTERNAL, 'Failed to parse server response');
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        call.on('status', (status) => {
 | 
			
		||||
            /* We assume that call emits status after it emits end, and that it
 | 
			
		||||
             * accounts for any cancelWithStatus calls up until it emits status.
 | 
			
		||||
             * Therefore, considering the above event handlers, status.code should be
 | 
			
		||||
             * OK if and only if we have a non-null responseMessage */
 | 
			
		||||
            if (status.code === constants_1.Status.OK) {
 | 
			
		||||
                callback(null, responseMessage);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                const error = Object.assign(new Error(status.details), status);
 | 
			
		||||
                callback(error);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    checkOptionalUnaryResponseArguments(arg1, arg2, arg3) {
 | 
			
		||||
        if (arg1 instanceof Function) {
 | 
			
		||||
            return { metadata: new metadata_1.Metadata(), options: {}, callback: arg1 };
 | 
			
		||||
        }
 | 
			
		||||
        else if (arg2 instanceof Function) {
 | 
			
		||||
            if (arg1 instanceof metadata_1.Metadata) {
 | 
			
		||||
                return { metadata: arg1, options: {}, callback: arg2 };
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                return { metadata: new metadata_1.Metadata(), options: arg1, callback: arg2 };
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            if (!(arg1 instanceof metadata_1.Metadata &&
 | 
			
		||||
                arg2 instanceof Object &&
 | 
			
		||||
                arg3 instanceof Function)) {
 | 
			
		||||
                throw new Error('Incorrect arguments passed');
 | 
			
		||||
            }
 | 
			
		||||
            return { metadata: arg1, options: arg2, callback: arg3 };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    makeUnaryRequest(method, serialize, deserialize, argument, metadata, options, callback) {
 | 
			
		||||
        ({ metadata, options, callback } = this.checkOptionalUnaryResponseArguments(metadata, options, callback));
 | 
			
		||||
        const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
 | 
			
		||||
        if (options.credentials) {
 | 
			
		||||
            call.setCredentials(options.credentials);
 | 
			
		||||
        }
 | 
			
		||||
        const message = serialize(argument);
 | 
			
		||||
        const writeObj = { message };
 | 
			
		||||
        call.sendMetadata(metadata);
 | 
			
		||||
        call.write(writeObj);
 | 
			
		||||
        call.end();
 | 
			
		||||
        this.handleUnaryResponse(call, deserialize, callback);
 | 
			
		||||
        return new call_1.ClientUnaryCallImpl(call);
 | 
			
		||||
    }
 | 
			
		||||
    makeClientStreamRequest(method, serialize, deserialize, metadata, options, callback) {
 | 
			
		||||
        ({ metadata, options, callback } = this.checkOptionalUnaryResponseArguments(metadata, options, callback));
 | 
			
		||||
        const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
 | 
			
		||||
        if (options.credentials) {
 | 
			
		||||
            call.setCredentials(options.credentials);
 | 
			
		||||
        }
 | 
			
		||||
        call.sendMetadata(metadata);
 | 
			
		||||
        this.handleUnaryResponse(call, deserialize, callback);
 | 
			
		||||
        return new call_1.ClientWritableStreamImpl(call, serialize);
 | 
			
		||||
    }
 | 
			
		||||
    checkMetadataAndOptions(arg1, arg2) {
 | 
			
		||||
        let metadata;
 | 
			
		||||
        let options;
 | 
			
		||||
        if (arg1 instanceof metadata_1.Metadata) {
 | 
			
		||||
            metadata = arg1;
 | 
			
		||||
            if (arg2) {
 | 
			
		||||
                options = arg2;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                options = {};
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            if (arg1) {
 | 
			
		||||
                options = arg1;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                options = {};
 | 
			
		||||
            }
 | 
			
		||||
            metadata = new metadata_1.Metadata();
 | 
			
		||||
        }
 | 
			
		||||
        return { metadata, options };
 | 
			
		||||
    }
 | 
			
		||||
    makeServerStreamRequest(method, serialize, deserialize, argument, metadata, options) {
 | 
			
		||||
        ({ metadata, options } = this.checkMetadataAndOptions(metadata, options));
 | 
			
		||||
        const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
 | 
			
		||||
        if (options.credentials) {
 | 
			
		||||
            call.setCredentials(options.credentials);
 | 
			
		||||
        }
 | 
			
		||||
        const message = serialize(argument);
 | 
			
		||||
        const writeObj = { message };
 | 
			
		||||
        call.sendMetadata(metadata);
 | 
			
		||||
        call.write(writeObj);
 | 
			
		||||
        call.end();
 | 
			
		||||
        return new call_1.ClientReadableStreamImpl(call, deserialize);
 | 
			
		||||
    }
 | 
			
		||||
    makeBidiStreamRequest(method, serialize, deserialize, metadata, options) {
 | 
			
		||||
        ({ metadata, options } = this.checkMetadataAndOptions(metadata, options));
 | 
			
		||||
        const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
 | 
			
		||||
        if (options.credentials) {
 | 
			
		||||
            call.setCredentials(options.credentials);
 | 
			
		||||
        }
 | 
			
		||||
        call.sendMetadata(metadata);
 | 
			
		||||
        return new call_1.ClientDuplexStreamImpl(call, serialize, deserialize);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Client = Client;
 | 
			
		||||
//# sourceMappingURL=client.js.map
 | 
			
		||||
							
								
								
									
										18
									
								
								node_modules/@grpc/grpc-js/build/src/compression-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								node_modules/@grpc/grpc-js/build/src/compression-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { Call, WriteObject } from './call-stream';
 | 
			
		||||
import { Channel } from './channel';
 | 
			
		||||
import { BaseFilter, Filter, FilterFactory } from './filter';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export declare class CompressionFilter extends BaseFilter implements Filter {
 | 
			
		||||
    private sendCompression;
 | 
			
		||||
    private receiveCompression;
 | 
			
		||||
    sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
 | 
			
		||||
    receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
 | 
			
		||||
}
 | 
			
		||||
export declare class CompressionFilterFactory implements FilterFactory<CompressionFilter> {
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    constructor(channel: Channel);
 | 
			
		||||
    createFilter(callStream: Call): CompressionFilter;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										201
									
								
								node_modules/@grpc/grpc-js/build/src/compression-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										201
									
								
								node_modules/@grpc/grpc-js/build/src/compression-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,201 @@
 | 
			
		||||
"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");
 | 
			
		||||
class CompressionHandler {
 | 
			
		||||
    /**
 | 
			
		||||
     * @param message Raw uncompressed message bytes
 | 
			
		||||
     * @param compress Indicates whether the message should be compressed
 | 
			
		||||
     * @return Framed message, compressed if applicable
 | 
			
		||||
     */
 | 
			
		||||
    async writeMessage(message, compress) {
 | 
			
		||||
        let messageBuffer = message;
 | 
			
		||||
        if (compress) {
 | 
			
		||||
            messageBuffer = await this.compressMessage(messageBuffer);
 | 
			
		||||
        }
 | 
			
		||||
        const output = Buffer.allocUnsafe(messageBuffer.length + 5);
 | 
			
		||||
        output.writeUInt8(compress ? 1 : 0, 0);
 | 
			
		||||
        output.writeUInt32BE(messageBuffer.length, 1);
 | 
			
		||||
        messageBuffer.copy(output, 5);
 | 
			
		||||
        return output;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * @param data Framed message, possibly compressed
 | 
			
		||||
     * @return Uncompressed message
 | 
			
		||||
     */
 | 
			
		||||
    async readMessage(data) {
 | 
			
		||||
        const compressed = data.readUInt8(0) === 1;
 | 
			
		||||
        let messageBuffer = data.slice(5);
 | 
			
		||||
        if (compressed) {
 | 
			
		||||
            messageBuffer = await this.decompressMessage(messageBuffer);
 | 
			
		||||
        }
 | 
			
		||||
        return messageBuffer;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class IdentityHandler extends CompressionHandler {
 | 
			
		||||
    async compressMessage(message) {
 | 
			
		||||
        return message;
 | 
			
		||||
    }
 | 
			
		||||
    async writeMessage(message, compress) {
 | 
			
		||||
        const output = Buffer.allocUnsafe(message.length + 5);
 | 
			
		||||
        /* With "identity" compression, messages should always be marked as
 | 
			
		||||
         * uncompressed */
 | 
			
		||||
        output.writeUInt8(0, 0);
 | 
			
		||||
        output.writeUInt32BE(message.length, 1);
 | 
			
		||||
        message.copy(output, 5);
 | 
			
		||||
        return output;
 | 
			
		||||
    }
 | 
			
		||||
    decompressMessage(message) {
 | 
			
		||||
        return Promise.reject(new Error('Received compressed message but "grpc-encoding" header was identity'));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class DeflateHandler extends CompressionHandler {
 | 
			
		||||
    compressMessage(message) {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            zlib.deflate(message, (err, output) => {
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    reject(err);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    resolve(output);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    decompressMessage(message) {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            zlib.inflate(message, (err, output) => {
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    reject(err);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    resolve(output);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class GzipHandler extends CompressionHandler {
 | 
			
		||||
    compressMessage(message) {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            zlib.gzip(message, (err, output) => {
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    reject(err);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    resolve(output);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    decompressMessage(message) {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            zlib.unzip(message, (err, output) => {
 | 
			
		||||
                if (err) {
 | 
			
		||||
                    reject(err);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    resolve(output);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class UnknownHandler extends CompressionHandler {
 | 
			
		||||
    constructor(compressionName) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.compressionName = compressionName;
 | 
			
		||||
    }
 | 
			
		||||
    compressMessage(message) {
 | 
			
		||||
        return Promise.reject(new Error(`Received message compressed wth unsupported compression method ${this.compressionName}`));
 | 
			
		||||
    }
 | 
			
		||||
    decompressMessage(message) {
 | 
			
		||||
        // This should be unreachable
 | 
			
		||||
        return Promise.reject(new Error(`Compression method not supported: ${this.compressionName}`));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function getCompressionHandler(compressionName) {
 | 
			
		||||
    switch (compressionName) {
 | 
			
		||||
        case 'identity':
 | 
			
		||||
            return new IdentityHandler();
 | 
			
		||||
        case 'deflate':
 | 
			
		||||
            return new DeflateHandler();
 | 
			
		||||
        case 'gzip':
 | 
			
		||||
            return new GzipHandler();
 | 
			
		||||
        default:
 | 
			
		||||
            return new UnknownHandler(compressionName);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
class CompressionFilter extends filter_1.BaseFilter {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super(...arguments);
 | 
			
		||||
        this.sendCompression = new IdentityHandler();
 | 
			
		||||
        this.receiveCompression = new IdentityHandler();
 | 
			
		||||
    }
 | 
			
		||||
    async sendMetadata(metadata) {
 | 
			
		||||
        const headers = await metadata;
 | 
			
		||||
        headers.set('grpc-encoding', 'identity');
 | 
			
		||||
        headers.set('grpc-accept-encoding', 'identity,deflate,gzip');
 | 
			
		||||
        return headers;
 | 
			
		||||
    }
 | 
			
		||||
    async receiveMetadata(metadata) {
 | 
			
		||||
        const headers = await metadata;
 | 
			
		||||
        const receiveEncoding = headers.get('grpc-encoding');
 | 
			
		||||
        if (receiveEncoding.length > 0) {
 | 
			
		||||
            const encoding = receiveEncoding[0];
 | 
			
		||||
            if (typeof encoding === 'string') {
 | 
			
		||||
                this.receiveCompression = getCompressionHandler(encoding);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        headers.remove('grpc-encoding');
 | 
			
		||||
        headers.remove('grpc-accept-encoding');
 | 
			
		||||
        return headers;
 | 
			
		||||
    }
 | 
			
		||||
    async sendMessage(message) {
 | 
			
		||||
        /* This filter is special. The input message is the bare message bytes,
 | 
			
		||||
         * and the output is a framed and possibly compressed message. For this
 | 
			
		||||
         * reason, this filter should be at the bottom of the filter stack */
 | 
			
		||||
        const resolvedMessage = await message;
 | 
			
		||||
        const compress = resolvedMessage.flags === undefined
 | 
			
		||||
            ? false
 | 
			
		||||
            : (resolvedMessage.flags & 2 /* NoCompress */) === 0;
 | 
			
		||||
        return {
 | 
			
		||||
            message: await this.sendCompression.writeMessage(resolvedMessage.message, compress),
 | 
			
		||||
            flags: resolvedMessage.flags,
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
    async receiveMessage(message) {
 | 
			
		||||
        /* This filter is also special. The input message is framed and possibly
 | 
			
		||||
         * compressed, and the output message is deframed and uncompressed. So
 | 
			
		||||
         * this is another reason that this filter should be at the bottom of the
 | 
			
		||||
         * filter stack. */
 | 
			
		||||
        return this.receiveCompression.readMessage(await message);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.CompressionFilter = CompressionFilter;
 | 
			
		||||
class CompressionFilterFactory {
 | 
			
		||||
    constructor(channel) {
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
    }
 | 
			
		||||
    createFilter(callStream) {
 | 
			
		||||
        return new CompressionFilter();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.CompressionFilterFactory = CompressionFilterFactory;
 | 
			
		||||
//# sourceMappingURL=compression-filter.js.map
 | 
			
		||||
							
								
								
									
										24
									
								
								node_modules/@grpc/grpc-js/build/src/constants.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								node_modules/@grpc/grpc-js/build/src/constants.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
export declare enum Status {
 | 
			
		||||
    OK = 0,
 | 
			
		||||
    CANCELLED = 1,
 | 
			
		||||
    UNKNOWN = 2,
 | 
			
		||||
    INVALID_ARGUMENT = 3,
 | 
			
		||||
    DEADLINE_EXCEEDED = 4,
 | 
			
		||||
    NOT_FOUND = 5,
 | 
			
		||||
    ALREADY_EXISTS = 6,
 | 
			
		||||
    PERMISSION_DENIED = 7,
 | 
			
		||||
    RESOURCE_EXHAUSTED = 8,
 | 
			
		||||
    FAILED_PRECONDITION = 9,
 | 
			
		||||
    ABORTED = 10,
 | 
			
		||||
    OUT_OF_RANGE = 11,
 | 
			
		||||
    UNIMPLEMENTED = 12,
 | 
			
		||||
    INTERNAL = 13,
 | 
			
		||||
    UNAVAILABLE = 14,
 | 
			
		||||
    DATA_LOSS = 15,
 | 
			
		||||
    UNAUTHENTICATED = 16
 | 
			
		||||
}
 | 
			
		||||
export declare enum LogVerbosity {
 | 
			
		||||
    DEBUG = 0,
 | 
			
		||||
    INFO = 1,
 | 
			
		||||
    ERROR = 2
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								node_modules/@grpc/grpc-js/build/src/constants.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								node_modules/@grpc/grpc-js/build/src/constants.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
"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) {
 | 
			
		||||
    Status[Status["OK"] = 0] = "OK";
 | 
			
		||||
    Status[Status["CANCELLED"] = 1] = "CANCELLED";
 | 
			
		||||
    Status[Status["UNKNOWN"] = 2] = "UNKNOWN";
 | 
			
		||||
    Status[Status["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
 | 
			
		||||
    Status[Status["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
 | 
			
		||||
    Status[Status["NOT_FOUND"] = 5] = "NOT_FOUND";
 | 
			
		||||
    Status[Status["ALREADY_EXISTS"] = 6] = "ALREADY_EXISTS";
 | 
			
		||||
    Status[Status["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
 | 
			
		||||
    Status[Status["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
 | 
			
		||||
    Status[Status["FAILED_PRECONDITION"] = 9] = "FAILED_PRECONDITION";
 | 
			
		||||
    Status[Status["ABORTED"] = 10] = "ABORTED";
 | 
			
		||||
    Status[Status["OUT_OF_RANGE"] = 11] = "OUT_OF_RANGE";
 | 
			
		||||
    Status[Status["UNIMPLEMENTED"] = 12] = "UNIMPLEMENTED";
 | 
			
		||||
    Status[Status["INTERNAL"] = 13] = "INTERNAL";
 | 
			
		||||
    Status[Status["UNAVAILABLE"] = 14] = "UNAVAILABLE";
 | 
			
		||||
    Status[Status["DATA_LOSS"] = 15] = "DATA_LOSS";
 | 
			
		||||
    Status[Status["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
 | 
			
		||||
})(Status = exports.Status || (exports.Status = {}));
 | 
			
		||||
var LogVerbosity;
 | 
			
		||||
(function (LogVerbosity) {
 | 
			
		||||
    LogVerbosity[LogVerbosity["DEBUG"] = 0] = "DEBUG";
 | 
			
		||||
    LogVerbosity[LogVerbosity["INFO"] = 1] = "INFO";
 | 
			
		||||
    LogVerbosity[LogVerbosity["ERROR"] = 2] = "ERROR";
 | 
			
		||||
})(LogVerbosity = exports.LogVerbosity || (exports.LogVerbosity = {}));
 | 
			
		||||
//# sourceMappingURL=constants.js.map
 | 
			
		||||
							
								
								
									
										17
									
								
								node_modules/@grpc/grpc-js/build/src/deadline-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								node_modules/@grpc/grpc-js/build/src/deadline-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
import { Call } from './call-stream';
 | 
			
		||||
import { Http2Channel } from './channel';
 | 
			
		||||
import { BaseFilter, Filter, FilterFactory } from './filter';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export declare class DeadlineFilter extends BaseFilter implements Filter {
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    private readonly callStream;
 | 
			
		||||
    private timer;
 | 
			
		||||
    private deadline;
 | 
			
		||||
    constructor(channel: Http2Channel, callStream: Call);
 | 
			
		||||
    sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
}
 | 
			
		||||
export declare class DeadlineFilterFactory implements FilterFactory<DeadlineFilter> {
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    constructor(channel: Http2Channel);
 | 
			
		||||
    createFilter(callStream: Call): DeadlineFilter;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										86
									
								
								node_modules/@grpc/grpc-js/build/src/deadline-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								node_modules/@grpc/grpc-js/build/src/deadline-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,86 @@
 | 
			
		||||
"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");
 | 
			
		||||
const units = [
 | 
			
		||||
    ['m', 1],
 | 
			
		||||
    ['S', 1000],
 | 
			
		||||
    ['M', 60 * 1000],
 | 
			
		||||
    ['H', 60 * 60 * 1000],
 | 
			
		||||
];
 | 
			
		||||
function getDeadline(deadline) {
 | 
			
		||||
    const now = new Date().getTime();
 | 
			
		||||
    const timeoutMs = Math.max(deadline - now, 0);
 | 
			
		||||
    for (const [unit, factor] of units) {
 | 
			
		||||
        const amount = timeoutMs / factor;
 | 
			
		||||
        if (amount < 1e8) {
 | 
			
		||||
            return String(Math.ceil(amount)) + unit;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    throw new Error('Deadline is too far in the future');
 | 
			
		||||
}
 | 
			
		||||
class DeadlineFilter extends filter_1.BaseFilter {
 | 
			
		||||
    constructor(channel, callStream) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
        this.callStream = callStream;
 | 
			
		||||
        this.timer = null;
 | 
			
		||||
        const callDeadline = callStream.getDeadline();
 | 
			
		||||
        if (callDeadline instanceof Date) {
 | 
			
		||||
            this.deadline = callDeadline.getTime();
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.deadline = callDeadline;
 | 
			
		||||
        }
 | 
			
		||||
        const now = new Date().getTime();
 | 
			
		||||
        let timeout = this.deadline - now;
 | 
			
		||||
        if (timeout < 0) {
 | 
			
		||||
            timeout = 0;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.deadline !== Infinity) {
 | 
			
		||||
            this.timer = setTimeout(() => {
 | 
			
		||||
                callStream.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, 'Deadline exceeded');
 | 
			
		||||
            }, timeout);
 | 
			
		||||
            callStream.on('status', () => clearTimeout(this.timer));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    async sendMetadata(metadata) {
 | 
			
		||||
        if (this.deadline === Infinity) {
 | 
			
		||||
            return metadata;
 | 
			
		||||
        }
 | 
			
		||||
        /* The input metadata promise depends on the original channel.connect()
 | 
			
		||||
         * promise, so when it is complete that implies that the channel is
 | 
			
		||||
         * connected */
 | 
			
		||||
        const finalMetadata = await metadata;
 | 
			
		||||
        const timeoutString = getDeadline(this.deadline);
 | 
			
		||||
        finalMetadata.set('grpc-timeout', timeoutString);
 | 
			
		||||
        return finalMetadata;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.DeadlineFilter = DeadlineFilter;
 | 
			
		||||
class DeadlineFilterFactory {
 | 
			
		||||
    constructor(channel) {
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
    }
 | 
			
		||||
    createFilter(callStream) {
 | 
			
		||||
        return new DeadlineFilter(this.channel, callStream);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.DeadlineFilterFactory = DeadlineFilterFactory;
 | 
			
		||||
//# sourceMappingURL=deadline-filter.js.map
 | 
			
		||||
							
								
								
									
										9
									
								
								node_modules/@grpc/grpc-js/build/src/events.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								node_modules/@grpc/grpc-js/build/src/events.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
export interface EmitterAugmentation1<Name extends string | symbol, Arg> {
 | 
			
		||||
    addListener(event: Name, listener: (arg1: Arg) => void): this;
 | 
			
		||||
    emit(event: Name, arg1: Arg): boolean;
 | 
			
		||||
    on(event: Name, listener: (arg1: Arg) => void): this;
 | 
			
		||||
    once(event: Name, listener: (arg1: Arg) => void): this;
 | 
			
		||||
    prependListener(event: Name, listener: (arg1: Arg) => void): this;
 | 
			
		||||
    prependOnceListener(event: Name, listener: (arg1: Arg) => void): this;
 | 
			
		||||
    removeListener(event: Name, listener: (arg1: Arg) => void): this;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								node_modules/@grpc/grpc-js/build/src/events.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								node_modules/@grpc/grpc-js/build/src/events.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +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
 | 
			
		||||
							
								
								
									
										18
									
								
								node_modules/@grpc/grpc-js/build/src/filter-stack.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								node_modules/@grpc/grpc-js/build/src/filter-stack.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { Call, StatusObject, WriteObject } from './call-stream';
 | 
			
		||||
import { Filter, FilterFactory } from './filter';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export declare class FilterStack implements Filter {
 | 
			
		||||
    private readonly filters;
 | 
			
		||||
    constructor(filters: Filter[]);
 | 
			
		||||
    sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
 | 
			
		||||
    receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
 | 
			
		||||
    receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
 | 
			
		||||
}
 | 
			
		||||
export declare class FilterStackFactory implements FilterFactory<FilterStack> {
 | 
			
		||||
    private readonly factories;
 | 
			
		||||
    constructor(factories: Array<FilterFactory<Filter>>);
 | 
			
		||||
    createFilter(callStream: Call): FilterStack;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										69
									
								
								node_modules/@grpc/grpc-js/build/src/filter-stack.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								node_modules/@grpc/grpc-js/build/src/filter-stack.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
"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) {
 | 
			
		||||
        this.filters = filters;
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(metadata) {
 | 
			
		||||
        let result = metadata;
 | 
			
		||||
        for (let i = 0; i < this.filters.length; i++) {
 | 
			
		||||
            result = this.filters[i].sendMetadata(result);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    receiveMetadata(metadata) {
 | 
			
		||||
        let result = metadata;
 | 
			
		||||
        for (let i = this.filters.length - 1; i >= 0; i--) {
 | 
			
		||||
            result = this.filters[i].receiveMetadata(result);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    sendMessage(message) {
 | 
			
		||||
        let result = message;
 | 
			
		||||
        for (let i = 0; i < this.filters.length; i++) {
 | 
			
		||||
            result = this.filters[i].sendMessage(result);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    receiveMessage(message) {
 | 
			
		||||
        let result = message;
 | 
			
		||||
        for (let i = this.filters.length - 1; i >= 0; i--) {
 | 
			
		||||
            result = this.filters[i].receiveMessage(result);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    receiveTrailers(status) {
 | 
			
		||||
        let result = status;
 | 
			
		||||
        for (let i = this.filters.length - 1; i >= 0; i--) {
 | 
			
		||||
            result = this.filters[i].receiveTrailers(result);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.FilterStack = FilterStack;
 | 
			
		||||
class FilterStackFactory {
 | 
			
		||||
    constructor(factories) {
 | 
			
		||||
        this.factories = factories;
 | 
			
		||||
    }
 | 
			
		||||
    createFilter(callStream) {
 | 
			
		||||
        return new FilterStack(this.factories.map(factory => factory.createFilter(callStream)));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.FilterStackFactory = FilterStackFactory;
 | 
			
		||||
//# sourceMappingURL=filter-stack.js.map
 | 
			
		||||
							
								
								
									
										24
									
								
								node_modules/@grpc/grpc-js/build/src/filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								node_modules/@grpc/grpc-js/build/src/filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { Call, StatusObject, WriteObject } from './call-stream';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
/**
 | 
			
		||||
 * Filter classes represent related per-call logic and state that is primarily
 | 
			
		||||
 * used to modify incoming and outgoing data
 | 
			
		||||
 */
 | 
			
		||||
export interface Filter {
 | 
			
		||||
    sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
 | 
			
		||||
    receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
 | 
			
		||||
    receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
 | 
			
		||||
}
 | 
			
		||||
export declare abstract class BaseFilter {
 | 
			
		||||
    sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
 | 
			
		||||
    sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
 | 
			
		||||
    receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
 | 
			
		||||
    receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
 | 
			
		||||
}
 | 
			
		||||
export interface FilterFactory<T extends Filter> {
 | 
			
		||||
    createFilter(callStream: Call): T;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								node_modules/@grpc/grpc-js/build/src/filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								node_modules/@grpc/grpc-js/build/src/filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
"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) {
 | 
			
		||||
        return metadata;
 | 
			
		||||
    }
 | 
			
		||||
    async receiveMetadata(metadata) {
 | 
			
		||||
        return metadata;
 | 
			
		||||
    }
 | 
			
		||||
    async sendMessage(message) {
 | 
			
		||||
        return message;
 | 
			
		||||
    }
 | 
			
		||||
    async receiveMessage(message) {
 | 
			
		||||
        return message;
 | 
			
		||||
    }
 | 
			
		||||
    async receiveTrailers(status) {
 | 
			
		||||
        return status;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.BaseFilter = BaseFilter;
 | 
			
		||||
//# sourceMappingURL=filter.js.map
 | 
			
		||||
							
								
								
									
										61
									
								
								node_modules/@grpc/grpc-js/build/src/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								node_modules/@grpc/grpc-js/build/src/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
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 { Deserialize, loadPackageDefinition, makeClientConstructor, Serialize } from './make-client';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
import { Server } from './server';
 | 
			
		||||
import { KeyCertPair, ServerCredentials } from './server-credentials';
 | 
			
		||||
import { StatusBuilder } from './status-builder';
 | 
			
		||||
export interface OAuth2Client {
 | 
			
		||||
    getRequestMetadata: (url: string, callback: (err: Error | null, headers?: {
 | 
			
		||||
        Authorization: string;
 | 
			
		||||
    }) => void) => void;
 | 
			
		||||
    getRequestHeaders: (url?: string) => Promise<{
 | 
			
		||||
        Authorization: string;
 | 
			
		||||
    }>;
 | 
			
		||||
}
 | 
			
		||||
/**** Client Credentials ****/
 | 
			
		||||
export declare const credentials: {
 | 
			
		||||
    [key: string]: Function;
 | 
			
		||||
};
 | 
			
		||||
/**** Metadata ****/
 | 
			
		||||
export { Metadata };
 | 
			
		||||
/**** Constants ****/
 | 
			
		||||
export { LogVerbosity as logVerbosity, Status as status, ConnectivityState as connectivityState, };
 | 
			
		||||
/**** Client ****/
 | 
			
		||||
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: Deadline, 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 { Server };
 | 
			
		||||
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';
 | 
			
		||||
							
								
								
									
										150
									
								
								node_modules/@grpc/grpc-js/build/src/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								node_modules/@grpc/grpc-js/build/src/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,150 @@
 | 
			
		||||
"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");
 | 
			
		||||
exports.logVerbosity = constants_1.LogVerbosity;
 | 
			
		||||
exports.status = constants_1.Status;
 | 
			
		||||
const logging = require("./logging");
 | 
			
		||||
const make_client_1 = require("./make-client");
 | 
			
		||||
exports.loadPackageDefinition = make_client_1.loadPackageDefinition;
 | 
			
		||||
exports.makeClientConstructor = make_client_1.makeClientConstructor;
 | 
			
		||||
exports.makeGenericClientConstructor = make_client_1.makeClientConstructor;
 | 
			
		||||
const metadata_1 = require("./metadata");
 | 
			
		||||
exports.Metadata = metadata_1.Metadata;
 | 
			
		||||
const server_1 = require("./server");
 | 
			
		||||
exports.Server = server_1.Server;
 | 
			
		||||
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 = require('../../package.json').engines.node;
 | 
			
		||||
if (!semver.satisfies(process.version, supportedNodeVersions)) {
 | 
			
		||||
    throw new Error(`@grpc/grpc-js only works on Node ${supportedNodeVersions}`);
 | 
			
		||||
}
 | 
			
		||||
function mixin(...sources) {
 | 
			
		||||
    const result = {};
 | 
			
		||||
    for (const source of sources) {
 | 
			
		||||
        for (const propName of Object.getOwnPropertyNames(source)) {
 | 
			
		||||
            const property = source[propName]; // tslint:disable-line no-any
 | 
			
		||||
            if (typeof property === 'function') {
 | 
			
		||||
                result[propName] = property;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
/**** Client Credentials ****/
 | 
			
		||||
// Using assign only copies enumerable properties, which is what we want
 | 
			
		||||
exports.credentials = mixin({
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a gRPC credential from a Google credential object.
 | 
			
		||||
     * @param googleCredentials The authentication client to use.
 | 
			
		||||
     * @return The resulting CallCredentials object.
 | 
			
		||||
     */
 | 
			
		||||
    createFromGoogleCredential: (googleCredentials) => {
 | 
			
		||||
        return call_credentials_1.CallCredentials.createFromMetadataGenerator((options, callback) => {
 | 
			
		||||
            // google-auth-library pre-v2.0.0 does not have getRequestHeaders
 | 
			
		||||
            // but has getRequestMetadata, which is deprecated in v2.0.0
 | 
			
		||||
            let getHeaders;
 | 
			
		||||
            if (typeof googleCredentials.getRequestHeaders === 'function') {
 | 
			
		||||
                getHeaders = googleCredentials.getRequestHeaders(options.service_url);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                getHeaders = new Promise((resolve, reject) => {
 | 
			
		||||
                    googleCredentials.getRequestMetadata(options.service_url, (err, headers) => {
 | 
			
		||||
                        if (err) {
 | 
			
		||||
                            reject(err);
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
                        resolve(headers);
 | 
			
		||||
                    });
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            getHeaders.then(headers => {
 | 
			
		||||
                const metadata = new metadata_1.Metadata();
 | 
			
		||||
                metadata.add('authorization', headers.Authorization);
 | 
			
		||||
                callback(null, metadata);
 | 
			
		||||
            }, err => {
 | 
			
		||||
                callback(err);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    /**
 | 
			
		||||
     * Combine a ChannelCredentials with any number of CallCredentials into a
 | 
			
		||||
     * single ChannelCredentials object.
 | 
			
		||||
     * @param channelCredentials The ChannelCredentials object.
 | 
			
		||||
     * @param callCredentials Any number of CallCredentials objects.
 | 
			
		||||
     * @return The resulting ChannelCredentials object.
 | 
			
		||||
     */
 | 
			
		||||
    combineChannelCredentials: (channelCredentials, ...callCredentials) => {
 | 
			
		||||
        return callCredentials.reduce((acc, other) => acc.compose(other), channelCredentials);
 | 
			
		||||
    },
 | 
			
		||||
    /**
 | 
			
		||||
     * Combine any number of CallCredentials into a single CallCredentials
 | 
			
		||||
     * object.
 | 
			
		||||
     * @param first The first CallCredentials object.
 | 
			
		||||
     * @param additional Any number of additional CallCredentials objects.
 | 
			
		||||
     * @return The resulting CallCredentials object.
 | 
			
		||||
     */
 | 
			
		||||
    combineCallCredentials: (first, ...additional) => {
 | 
			
		||||
        return additional.reduce((acc, other) => acc.compose(other), first);
 | 
			
		||||
    },
 | 
			
		||||
}, channel_credentials_1.ChannelCredentials, call_credentials_1.CallCredentials);
 | 
			
		||||
/**
 | 
			
		||||
 * Close a Client object.
 | 
			
		||||
 * @param client The client to close.
 | 
			
		||||
 */
 | 
			
		||||
exports.closeClient = (client) => client.close();
 | 
			
		||||
exports.waitForClientReady = (client, deadline, callback) => client.waitForReady(deadline, callback);
 | 
			
		||||
/**** Unimplemented function stubs ****/
 | 
			
		||||
/* tslint:disable:no-any variable-name */
 | 
			
		||||
exports.loadObject = (value, options) => {
 | 
			
		||||
    throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
 | 
			
		||||
};
 | 
			
		||||
exports.load = (filename, format, options) => {
 | 
			
		||||
    throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
 | 
			
		||||
};
 | 
			
		||||
exports.setLogger = (logger) => {
 | 
			
		||||
    logging.setLogger(logger);
 | 
			
		||||
};
 | 
			
		||||
exports.setLogVerbosity = (verbosity) => {
 | 
			
		||||
    logging.setLoggerVerbosity(verbosity);
 | 
			
		||||
};
 | 
			
		||||
exports.getClientChannel = (client) => {
 | 
			
		||||
    return client_1.Client.prototype.getChannel.call(client);
 | 
			
		||||
};
 | 
			
		||||
exports.ListenerBuilder = () => {
 | 
			
		||||
    throw new Error('Not yet implemented');
 | 
			
		||||
};
 | 
			
		||||
exports.InterceptorBuilder = () => {
 | 
			
		||||
    throw new Error('Not yet implemented');
 | 
			
		||||
};
 | 
			
		||||
exports.InterceptingCall = () => {
 | 
			
		||||
    throw new Error('Not yet implemented');
 | 
			
		||||
};
 | 
			
		||||
//# sourceMappingURL=index.js.map
 | 
			
		||||
							
								
								
									
										16
									
								
								node_modules/@grpc/grpc-js/build/src/load-balancing-config.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								node_modules/@grpc/grpc-js/build/src/load-balancing-config.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
export interface RoundRobinConfig {
 | 
			
		||||
}
 | 
			
		||||
export interface XdsConfig {
 | 
			
		||||
    balancerName: string;
 | 
			
		||||
    childPolicy: LoadBalancingConfig[];
 | 
			
		||||
    fallbackPolicy: LoadBalancingConfig[];
 | 
			
		||||
}
 | 
			
		||||
export interface GrpcLbConfig {
 | 
			
		||||
    childPolicy: LoadBalancingConfig[];
 | 
			
		||||
}
 | 
			
		||||
export interface LoadBalancingConfig {
 | 
			
		||||
    round_robin?: RoundRobinConfig;
 | 
			
		||||
    xds?: XdsConfig;
 | 
			
		||||
    grpclb?: GrpcLbConfig;
 | 
			
		||||
}
 | 
			
		||||
export declare function validateConfig(obj: any): LoadBalancingConfig;
 | 
			
		||||
							
								
								
									
										87
									
								
								node_modules/@grpc/grpc-js/build/src/load-balancing-config.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								node_modules/@grpc/grpc-js/build/src/load-balancing-config.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,87 @@
 | 
			
		||||
"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 file is an implementation of gRFC A24:
 | 
			
		||||
 * https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md */
 | 
			
		||||
const util_1 = require("util");
 | 
			
		||||
/* In these functions we assume the input came from a JSON object. Therefore we
 | 
			
		||||
 * expect that the prototype is uninteresting and that `in` can be used
 | 
			
		||||
 * effectively */
 | 
			
		||||
function validateXdsConfig(xds) {
 | 
			
		||||
    if (!('balancerName' in xds) || !util_1.isString(xds.balancerName)) {
 | 
			
		||||
        throw new Error('Invalid xds config: invalid balancerName');
 | 
			
		||||
    }
 | 
			
		||||
    const xdsConfig = {
 | 
			
		||||
        balancerName: xds.balancerName,
 | 
			
		||||
        childPolicy: [],
 | 
			
		||||
        fallbackPolicy: []
 | 
			
		||||
    };
 | 
			
		||||
    if ('childPolicy' in xds) {
 | 
			
		||||
        if (!util_1.isArray(xds.childPolicy)) {
 | 
			
		||||
            throw new Error('Invalid xds config: invalid childPolicy');
 | 
			
		||||
        }
 | 
			
		||||
        for (const policy of xds.childPolicy) {
 | 
			
		||||
            xdsConfig.childPolicy.push(validateConfig(policy));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ('fallbackPolicy' in xds) {
 | 
			
		||||
        if (!util_1.isArray(xds.fallbackPolicy)) {
 | 
			
		||||
            throw new Error('Invalid xds config: invalid fallbackPolicy');
 | 
			
		||||
        }
 | 
			
		||||
        for (const policy of xds.fallbackPolicy) {
 | 
			
		||||
            xdsConfig.fallbackPolicy.push(validateConfig(policy));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return xdsConfig;
 | 
			
		||||
}
 | 
			
		||||
function validateGrpcLbConfig(grpclb) {
 | 
			
		||||
    const grpcLbConfig = {
 | 
			
		||||
        childPolicy: []
 | 
			
		||||
    };
 | 
			
		||||
    if ('childPolicy' in grpclb) {
 | 
			
		||||
        if (!util_1.isArray(grpclb.childPolicy)) {
 | 
			
		||||
            throw new Error('Invalid xds config: invalid childPolicy');
 | 
			
		||||
        }
 | 
			
		||||
        for (const policy of grpclb.childPolicy) {
 | 
			
		||||
            grpcLbConfig.childPolicy.push(validateConfig(policy));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return grpcLbConfig;
 | 
			
		||||
}
 | 
			
		||||
function validateConfig(obj) {
 | 
			
		||||
    if ('round_robin' in obj) {
 | 
			
		||||
        if ('xds' in obj || 'grpclb' in obj) {
 | 
			
		||||
            throw new Error('Multiple load balancing policies configured');
 | 
			
		||||
        }
 | 
			
		||||
        if (obj['round_robin'] instanceof Object) {
 | 
			
		||||
            return { round_robin: {} };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ('xds' in obj) {
 | 
			
		||||
        if ('grpclb' in obj) {
 | 
			
		||||
            throw new Error('Multiple load balancing policies configured');
 | 
			
		||||
        }
 | 
			
		||||
        return { xds: validateXdsConfig(obj.xds) };
 | 
			
		||||
    }
 | 
			
		||||
    if ('grpclb' in obj) {
 | 
			
		||||
        return { grpclb: validateGrpcLbConfig(obj.grpclb) };
 | 
			
		||||
    }
 | 
			
		||||
    throw new Error('No recognized load balancing policy configured');
 | 
			
		||||
}
 | 
			
		||||
exports.validateConfig = validateConfig;
 | 
			
		||||
//# sourceMappingURL=load-balancing-config.js.map
 | 
			
		||||
							
								
								
									
										6
									
								
								node_modules/@grpc/grpc-js/build/src/logging.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								node_modules/@grpc/grpc-js/build/src/logging.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { LogVerbosity } from './constants';
 | 
			
		||||
export declare const getLogger: () => Partial<Console>;
 | 
			
		||||
export declare const setLogger: (logger: Partial<Console>) => void;
 | 
			
		||||
export declare const setLoggerVerbosity: (verbosity: LogVerbosity) => void;
 | 
			
		||||
export declare const log: (severity: LogVerbosity, ...args: any[]) => void;
 | 
			
		||||
							
								
								
									
										37
									
								
								node_modules/@grpc/grpc-js/build/src/logging.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								node_modules/@grpc/grpc-js/build/src/logging.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
"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;
 | 
			
		||||
let _logVerbosity = constants_1.LogVerbosity.DEBUG;
 | 
			
		||||
exports.getLogger = () => {
 | 
			
		||||
    return _logger;
 | 
			
		||||
};
 | 
			
		||||
exports.setLogger = (logger) => {
 | 
			
		||||
    _logger = logger;
 | 
			
		||||
};
 | 
			
		||||
exports.setLoggerVerbosity = (verbosity) => {
 | 
			
		||||
    _logVerbosity = verbosity;
 | 
			
		||||
};
 | 
			
		||||
// tslint:disable-next-line no-any
 | 
			
		||||
exports.log = (severity, ...args) => {
 | 
			
		||||
    if (severity >= _logVerbosity && typeof _logger.error === 'function') {
 | 
			
		||||
        _logger.error(...args);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
//# sourceMappingURL=logging.js.map
 | 
			
		||||
							
								
								
									
										62
									
								
								node_modules/@grpc/grpc-js/build/src/make-client.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								node_modules/@grpc/grpc-js/build/src/make-client.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { ChannelCredentials } from './channel-credentials';
 | 
			
		||||
import { ChannelOptions } from './channel-options';
 | 
			
		||||
import { Client } from './client';
 | 
			
		||||
export interface Serialize<T> {
 | 
			
		||||
    (value: T): Buffer;
 | 
			
		||||
}
 | 
			
		||||
export interface Deserialize<T> {
 | 
			
		||||
    (bytes: Buffer): T;
 | 
			
		||||
}
 | 
			
		||||
export interface MethodDefinition<RequestType, ResponseType> {
 | 
			
		||||
    path: string;
 | 
			
		||||
    requestStream: boolean;
 | 
			
		||||
    responseStream: boolean;
 | 
			
		||||
    requestSerialize: Serialize<RequestType>;
 | 
			
		||||
    responseSerialize: Serialize<ResponseType>;
 | 
			
		||||
    requestDeserialize: Deserialize<RequestType>;
 | 
			
		||||
    responseDeserialize: Deserialize<ResponseType>;
 | 
			
		||||
    originalName?: string;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceDefinition {
 | 
			
		||||
    [index: string]: MethodDefinition<object, object>;
 | 
			
		||||
}
 | 
			
		||||
export interface ProtobufTypeDefinition {
 | 
			
		||||
    format: string;
 | 
			
		||||
    type: object;
 | 
			
		||||
    fileDescriptorProtos: Buffer[];
 | 
			
		||||
}
 | 
			
		||||
export interface PackageDefinition {
 | 
			
		||||
    [index: string]: ServiceDefinition | ProtobufTypeDefinition;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceClient extends Client {
 | 
			
		||||
    [methodName: string]: Function;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceClientConstructor {
 | 
			
		||||
    new (address: string, credentials: ChannelCredentials, options?: Partial<ChannelOptions>): ServiceClient;
 | 
			
		||||
    service: ServiceDefinition;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Creates a constructor for a client with the given methods, as specified in
 | 
			
		||||
 * the methods argument. The resulting class will have an instance method for
 | 
			
		||||
 * each method in the service, which is a partial application of one of the
 | 
			
		||||
 * [Client]{@link grpc.Client} request methods, depending on `requestSerialize`
 | 
			
		||||
 * and `responseSerialize`, with the `method`, `serialize`, and `deserialize`
 | 
			
		||||
 * arguments predefined.
 | 
			
		||||
 * @param methods An object mapping method names to
 | 
			
		||||
 *     method attributes
 | 
			
		||||
 * @param serviceName The fully qualified name of the service
 | 
			
		||||
 * @param classOptions An options object.
 | 
			
		||||
 * @return New client constructor, which is a subclass of
 | 
			
		||||
 *     {@link grpc.Client}, and has the same arguments as that constructor.
 | 
			
		||||
 */
 | 
			
		||||
export declare function makeClientConstructor(methods: ServiceDefinition, serviceName: string, classOptions?: {}): ServiceClientConstructor;
 | 
			
		||||
export interface GrpcObject {
 | 
			
		||||
    [index: string]: GrpcObject | ServiceClientConstructor | ProtobufTypeDefinition;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Load a gRPC package definition as a gRPC object hierarchy.
 | 
			
		||||
 * @param packageDef The package definition object.
 | 
			
		||||
 * @return The resulting gRPC object.
 | 
			
		||||
 */
 | 
			
		||||
export declare function loadPackageDefinition(packageDef: PackageDefinition): GrpcObject;
 | 
			
		||||
							
								
								
									
										128
									
								
								node_modules/@grpc/grpc-js/build/src/make-client.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								node_modules/@grpc/grpc-js/build/src/make-client.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,128 @@
 | 
			
		||||
"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");
 | 
			
		||||
/**
 | 
			
		||||
 * Map with short names for each of the requester maker functions. Used in
 | 
			
		||||
 * makeClientConstructor
 | 
			
		||||
 * @private
 | 
			
		||||
 */
 | 
			
		||||
const requesterFuncs = {
 | 
			
		||||
    unary: client_1.Client.prototype.makeUnaryRequest,
 | 
			
		||||
    server_stream: client_1.Client.prototype.makeServerStreamRequest,
 | 
			
		||||
    client_stream: client_1.Client.prototype.makeClientStreamRequest,
 | 
			
		||||
    bidi: client_1.Client.prototype.makeBidiStreamRequest,
 | 
			
		||||
};
 | 
			
		||||
/**
 | 
			
		||||
 * Creates a constructor for a client with the given methods, as specified in
 | 
			
		||||
 * the methods argument. The resulting class will have an instance method for
 | 
			
		||||
 * each method in the service, which is a partial application of one of the
 | 
			
		||||
 * [Client]{@link grpc.Client} request methods, depending on `requestSerialize`
 | 
			
		||||
 * and `responseSerialize`, with the `method`, `serialize`, and `deserialize`
 | 
			
		||||
 * arguments predefined.
 | 
			
		||||
 * @param methods An object mapping method names to
 | 
			
		||||
 *     method attributes
 | 
			
		||||
 * @param serviceName The fully qualified name of the service
 | 
			
		||||
 * @param classOptions An options object.
 | 
			
		||||
 * @return New client constructor, which is a subclass of
 | 
			
		||||
 *     {@link grpc.Client}, and has the same arguments as that constructor.
 | 
			
		||||
 */
 | 
			
		||||
function makeClientConstructor(methods, serviceName, classOptions) {
 | 
			
		||||
    if (!classOptions) {
 | 
			
		||||
        classOptions = {};
 | 
			
		||||
    }
 | 
			
		||||
    class ServiceClientImpl extends client_1.Client {
 | 
			
		||||
    }
 | 
			
		||||
    Object.keys(methods).forEach(name => {
 | 
			
		||||
        const attrs = methods[name];
 | 
			
		||||
        let methodType;
 | 
			
		||||
        // TODO(murgatroid99): Verify that we don't need this anymore
 | 
			
		||||
        if (typeof name === 'string' && name.charAt(0) === '$') {
 | 
			
		||||
            throw new Error('Method names cannot start with $');
 | 
			
		||||
        }
 | 
			
		||||
        if (attrs.requestStream) {
 | 
			
		||||
            if (attrs.responseStream) {
 | 
			
		||||
                methodType = 'bidi';
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                methodType = 'client_stream';
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            if (attrs.responseStream) {
 | 
			
		||||
                methodType = 'server_stream';
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                methodType = 'unary';
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        const serialize = attrs.requestSerialize;
 | 
			
		||||
        const deserialize = attrs.responseDeserialize;
 | 
			
		||||
        const methodFunc = partial(requesterFuncs[methodType], attrs.path, serialize, deserialize);
 | 
			
		||||
        ServiceClientImpl.prototype[name] = methodFunc;
 | 
			
		||||
        // Associate all provided attributes with the method
 | 
			
		||||
        Object.assign(ServiceClientImpl.prototype[name], attrs);
 | 
			
		||||
        if (attrs.originalName) {
 | 
			
		||||
            ServiceClientImpl.prototype[attrs.originalName] =
 | 
			
		||||
                ServiceClientImpl.prototype[name];
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    ServiceClientImpl.service = methods;
 | 
			
		||||
    return ServiceClientImpl;
 | 
			
		||||
}
 | 
			
		||||
exports.makeClientConstructor = makeClientConstructor;
 | 
			
		||||
function partial(fn, path, serialize, deserialize) {
 | 
			
		||||
    // tslint:disable-next-line:no-any
 | 
			
		||||
    return function (...args) {
 | 
			
		||||
        return fn.call(this, path, serialize, deserialize, ...args);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
function isProtobufTypeDefinition(obj) {
 | 
			
		||||
    return 'format' in obj;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Load a gRPC package definition as a gRPC object hierarchy.
 | 
			
		||||
 * @param packageDef The package definition object.
 | 
			
		||||
 * @return The resulting gRPC object.
 | 
			
		||||
 */
 | 
			
		||||
function loadPackageDefinition(packageDef) {
 | 
			
		||||
    const result = {};
 | 
			
		||||
    for (const serviceFqn in packageDef) {
 | 
			
		||||
        if (packageDef.hasOwnProperty(serviceFqn)) {
 | 
			
		||||
            const service = packageDef[serviceFqn];
 | 
			
		||||
            const nameComponents = serviceFqn.split('.');
 | 
			
		||||
            const serviceName = nameComponents[nameComponents.length - 1];
 | 
			
		||||
            let current = result;
 | 
			
		||||
            for (const packageName of nameComponents.slice(0, -1)) {
 | 
			
		||||
                if (!current[packageName]) {
 | 
			
		||||
                    current[packageName] = {};
 | 
			
		||||
                }
 | 
			
		||||
                current = current[packageName];
 | 
			
		||||
            }
 | 
			
		||||
            if (isProtobufTypeDefinition(service)) {
 | 
			
		||||
                current[serviceName] = service;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                current[serviceName] = makeClientConstructor(service, serviceName, {});
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
exports.loadPackageDefinition = loadPackageDefinition;
 | 
			
		||||
//# sourceMappingURL=make-client.js.map
 | 
			
		||||
							
								
								
									
										12
									
								
								node_modules/@grpc/grpc-js/build/src/metadata-status-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								node_modules/@grpc/grpc-js/build/src/metadata-status-filter.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
import { Call } from './call-stream';
 | 
			
		||||
import { StatusObject } from './call-stream';
 | 
			
		||||
import { Channel } from './channel';
 | 
			
		||||
import { BaseFilter, Filter, FilterFactory } from './filter';
 | 
			
		||||
export declare class MetadataStatusFilter extends BaseFilter implements Filter {
 | 
			
		||||
    receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
 | 
			
		||||
}
 | 
			
		||||
export declare class MetadataStatusFilterFactory implements FilterFactory<MetadataStatusFilter> {
 | 
			
		||||
    private readonly channel;
 | 
			
		||||
    constructor(channel: Channel);
 | 
			
		||||
    createFilter(callStream: Call): MetadataStatusFilter;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								node_modules/@grpc/grpc-js/build/src/metadata-status-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								node_modules/@grpc/grpc-js/build/src/metadata-status-filter.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
"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");
 | 
			
		||||
class MetadataStatusFilter extends filter_1.BaseFilter {
 | 
			
		||||
    async receiveTrailers(status) {
 | 
			
		||||
        // tslint:disable-next-line:prefer-const
 | 
			
		||||
        let { code, details, metadata } = await status;
 | 
			
		||||
        if (code !== constants_1.Status.UNKNOWN) {
 | 
			
		||||
            // we already have a known status, so don't assign a new one.
 | 
			
		||||
            return { code, details, metadata };
 | 
			
		||||
        }
 | 
			
		||||
        const metadataMap = metadata.getMap();
 | 
			
		||||
        if (typeof metadataMap['grpc-status'] === 'string') {
 | 
			
		||||
            const receivedCode = Number(metadataMap['grpc-status']);
 | 
			
		||||
            if (receivedCode in constants_1.Status) {
 | 
			
		||||
                code = receivedCode;
 | 
			
		||||
            }
 | 
			
		||||
            metadata.remove('grpc-status');
 | 
			
		||||
        }
 | 
			
		||||
        if (typeof metadataMap['grpc-message'] === 'string') {
 | 
			
		||||
            details = decodeURI(metadataMap['grpc-message']);
 | 
			
		||||
            metadata.remove('grpc-message');
 | 
			
		||||
        }
 | 
			
		||||
        return { code, details, metadata };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.MetadataStatusFilter = MetadataStatusFilter;
 | 
			
		||||
class MetadataStatusFilterFactory {
 | 
			
		||||
    constructor(channel) {
 | 
			
		||||
        this.channel = channel;
 | 
			
		||||
    }
 | 
			
		||||
    createFilter(callStream) {
 | 
			
		||||
        return new MetadataStatusFilter();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.MetadataStatusFilterFactory = MetadataStatusFilterFactory;
 | 
			
		||||
//# sourceMappingURL=metadata-status-filter.js.map
 | 
			
		||||
							
								
								
									
										78
									
								
								node_modules/@grpc/grpc-js/build/src/metadata.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								node_modules/@grpc/grpc-js/build/src/metadata.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import * as http2 from 'http2';
 | 
			
		||||
export declare type MetadataValue = string | Buffer;
 | 
			
		||||
export declare type MetadataObject = Map<string, MetadataValue[]>;
 | 
			
		||||
export interface MetadataOptions {
 | 
			
		||||
    idempotentRequest?: boolean;
 | 
			
		||||
    waitForReady?: boolean;
 | 
			
		||||
    cacheableRequest?: boolean;
 | 
			
		||||
    corked?: boolean;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * A class for storing metadata. Keys are normalized to lowercase ASCII.
 | 
			
		||||
 */
 | 
			
		||||
export declare class Metadata {
 | 
			
		||||
    private options?;
 | 
			
		||||
    protected internalRepr: MetadataObject;
 | 
			
		||||
    constructor(options?: MetadataOptions | undefined);
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the given value for the given key by replacing any other values
 | 
			
		||||
     * associated with that key. Normalizes the key.
 | 
			
		||||
     * @param key The key to whose value should be set.
 | 
			
		||||
     * @param value The value to set. Must be a buffer if and only
 | 
			
		||||
     *   if the normalized key ends with '-bin'.
 | 
			
		||||
     */
 | 
			
		||||
    set(key: string, value: MetadataValue): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds the given value for the given key by appending to a list of previous
 | 
			
		||||
     * values associated with that key. Normalizes the key.
 | 
			
		||||
     * @param key The key for which a new value should be appended.
 | 
			
		||||
     * @param value The value to add. Must be a buffer if and only
 | 
			
		||||
     *   if the normalized key ends with '-bin'.
 | 
			
		||||
     */
 | 
			
		||||
    add(key: string, value: MetadataValue): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Removes the given key and any associated values. Normalizes the key.
 | 
			
		||||
     * @param key The key whose values should be removed.
 | 
			
		||||
     */
 | 
			
		||||
    remove(key: string): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a list of all values associated with the key. Normalizes the key.
 | 
			
		||||
     * @param key The key whose value should be retrieved.
 | 
			
		||||
     * @return A list of values associated with the given key.
 | 
			
		||||
     */
 | 
			
		||||
    get(key: string): MetadataValue[];
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a plain object mapping each key to the first value associated with it.
 | 
			
		||||
     * This reflects the most common way that people will want to see metadata.
 | 
			
		||||
     * @return A key/value mapping of the metadata.
 | 
			
		||||
     */
 | 
			
		||||
    getMap(): {
 | 
			
		||||
        [key: string]: MetadataValue;
 | 
			
		||||
    };
 | 
			
		||||
    /**
 | 
			
		||||
     * Clones the metadata object.
 | 
			
		||||
     * @return The newly cloned object.
 | 
			
		||||
     */
 | 
			
		||||
    clone(): Metadata;
 | 
			
		||||
    /**
 | 
			
		||||
     * Merges all key-value pairs from a given Metadata object into this one.
 | 
			
		||||
     * If both this object and the given object have values in the same key,
 | 
			
		||||
     * values from the other Metadata object will be appended to this object's
 | 
			
		||||
     * values.
 | 
			
		||||
     * @param other A Metadata object.
 | 
			
		||||
     */
 | 
			
		||||
    merge(other: Metadata): void;
 | 
			
		||||
    setOptions(options: MetadataOptions): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates an OutgoingHttpHeaders object that can be used with the http2 API.
 | 
			
		||||
     */
 | 
			
		||||
    toHttp2Headers(): http2.OutgoingHttpHeaders;
 | 
			
		||||
    private _getCoreRepresentation;
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a new Metadata object based fields in a given IncomingHttpHeaders
 | 
			
		||||
     * object.
 | 
			
		||||
     * @param headers An IncomingHttpHeaders object.
 | 
			
		||||
     */
 | 
			
		||||
    static fromHttp2Headers(headers: http2.IncomingHttpHeaders): Metadata;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										231
									
								
								node_modules/@grpc/grpc-js/build/src/metadata.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								node_modules/@grpc/grpc-js/build/src/metadata.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,231 @@
 | 
			
		||||
"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 = /^[ -~]*$/;
 | 
			
		||||
function isLegalKey(key) {
 | 
			
		||||
    return LEGAL_KEY_REGEX.test(key);
 | 
			
		||||
}
 | 
			
		||||
function isLegalNonBinaryValue(value) {
 | 
			
		||||
    return LEGAL_NON_BINARY_VALUE_REGEX.test(value);
 | 
			
		||||
}
 | 
			
		||||
function isBinaryKey(key) {
 | 
			
		||||
    return key.endsWith('-bin');
 | 
			
		||||
}
 | 
			
		||||
function normalizeKey(key) {
 | 
			
		||||
    return key.toLowerCase();
 | 
			
		||||
}
 | 
			
		||||
function validate(key, value) {
 | 
			
		||||
    if (!isLegalKey(key)) {
 | 
			
		||||
        throw new Error('Metadata key "' + key + '" contains illegal characters');
 | 
			
		||||
    }
 | 
			
		||||
    if (value != null) {
 | 
			
		||||
        if (isBinaryKey(key)) {
 | 
			
		||||
            if (!(value instanceof Buffer)) {
 | 
			
		||||
                throw new Error("keys that end with '-bin' must have Buffer values");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            if (value instanceof Buffer) {
 | 
			
		||||
                throw new Error("keys that don't end with '-bin' must have String values");
 | 
			
		||||
            }
 | 
			
		||||
            if (!isLegalNonBinaryValue(value)) {
 | 
			
		||||
                throw new Error('Metadata string value "' + value + '" contains illegal characters');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * A class for storing metadata. Keys are normalized to lowercase ASCII.
 | 
			
		||||
 */
 | 
			
		||||
class Metadata {
 | 
			
		||||
    constructor(options) {
 | 
			
		||||
        this.options = options;
 | 
			
		||||
        this.internalRepr = new Map();
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the given value for the given key by replacing any other values
 | 
			
		||||
     * associated with that key. Normalizes the key.
 | 
			
		||||
     * @param key The key to whose value should be set.
 | 
			
		||||
     * @param value The value to set. Must be a buffer if and only
 | 
			
		||||
     *   if the normalized key ends with '-bin'.
 | 
			
		||||
     */
 | 
			
		||||
    set(key, value) {
 | 
			
		||||
        key = normalizeKey(key);
 | 
			
		||||
        validate(key, value);
 | 
			
		||||
        this.internalRepr.set(key, [value]);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds the given value for the given key by appending to a list of previous
 | 
			
		||||
     * values associated with that key. Normalizes the key.
 | 
			
		||||
     * @param key The key for which a new value should be appended.
 | 
			
		||||
     * @param value The value to add. Must be a buffer if and only
 | 
			
		||||
     *   if the normalized key ends with '-bin'.
 | 
			
		||||
     */
 | 
			
		||||
    add(key, value) {
 | 
			
		||||
        key = normalizeKey(key);
 | 
			
		||||
        validate(key, value);
 | 
			
		||||
        const existingValue = this.internalRepr.get(key);
 | 
			
		||||
        if (existingValue === undefined) {
 | 
			
		||||
            this.internalRepr.set(key, [value]);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            existingValue.push(value);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Removes the given key and any associated values. Normalizes the key.
 | 
			
		||||
     * @param key The key whose values should be removed.
 | 
			
		||||
     */
 | 
			
		||||
    remove(key) {
 | 
			
		||||
        key = normalizeKey(key);
 | 
			
		||||
        validate(key);
 | 
			
		||||
        this.internalRepr.delete(key);
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a list of all values associated with the key. Normalizes the key.
 | 
			
		||||
     * @param key The key whose value should be retrieved.
 | 
			
		||||
     * @return A list of values associated with the given key.
 | 
			
		||||
     */
 | 
			
		||||
    get(key) {
 | 
			
		||||
        key = normalizeKey(key);
 | 
			
		||||
        validate(key);
 | 
			
		||||
        return this.internalRepr.get(key) || [];
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a plain object mapping each key to the first value associated with it.
 | 
			
		||||
     * This reflects the most common way that people will want to see metadata.
 | 
			
		||||
     * @return A key/value mapping of the metadata.
 | 
			
		||||
     */
 | 
			
		||||
    getMap() {
 | 
			
		||||
        const result = {};
 | 
			
		||||
        this.internalRepr.forEach((values, key) => {
 | 
			
		||||
            if (values.length > 0) {
 | 
			
		||||
                const v = values[0];
 | 
			
		||||
                result[key] = v instanceof Buffer ? v.slice() : v;
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Clones the metadata object.
 | 
			
		||||
     * @return The newly cloned object.
 | 
			
		||||
     */
 | 
			
		||||
    clone() {
 | 
			
		||||
        const newMetadata = new Metadata();
 | 
			
		||||
        const newInternalRepr = newMetadata.internalRepr;
 | 
			
		||||
        this.internalRepr.forEach((value, key) => {
 | 
			
		||||
            const clonedValue = value.map(v => {
 | 
			
		||||
                if (v instanceof Buffer) {
 | 
			
		||||
                    return Buffer.from(v);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    return v;
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            newInternalRepr.set(key, clonedValue);
 | 
			
		||||
        });
 | 
			
		||||
        return newMetadata;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Merges all key-value pairs from a given Metadata object into this one.
 | 
			
		||||
     * If both this object and the given object have values in the same key,
 | 
			
		||||
     * values from the other Metadata object will be appended to this object's
 | 
			
		||||
     * values.
 | 
			
		||||
     * @param other A Metadata object.
 | 
			
		||||
     */
 | 
			
		||||
    merge(other) {
 | 
			
		||||
        other.internalRepr.forEach((values, key) => {
 | 
			
		||||
            const mergedValue = (this.internalRepr.get(key) || []).concat(values);
 | 
			
		||||
            this.internalRepr.set(key, mergedValue);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    setOptions(options) {
 | 
			
		||||
        this.options = options;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates an OutgoingHttpHeaders object that can be used with the http2 API.
 | 
			
		||||
     */
 | 
			
		||||
    toHttp2Headers() {
 | 
			
		||||
        // NOTE: Node <8.9 formats http2 headers incorrectly.
 | 
			
		||||
        const result = {};
 | 
			
		||||
        this.internalRepr.forEach((values, key) => {
 | 
			
		||||
            // We assume that the user's interaction with this object is limited to
 | 
			
		||||
            // through its public API (i.e. keys and values are already validated).
 | 
			
		||||
            result[key] = values.map(value => {
 | 
			
		||||
                if (value instanceof Buffer) {
 | 
			
		||||
                    return value.toString('base64');
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    return value;
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    // For compatibility with the other Metadata implementation
 | 
			
		||||
    _getCoreRepresentation() {
 | 
			
		||||
        return this.internalRepr;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a new Metadata object based fields in a given IncomingHttpHeaders
 | 
			
		||||
     * object.
 | 
			
		||||
     * @param headers An IncomingHttpHeaders object.
 | 
			
		||||
     */
 | 
			
		||||
    static fromHttp2Headers(headers) {
 | 
			
		||||
        const result = new Metadata();
 | 
			
		||||
        Object.keys(headers).forEach(key => {
 | 
			
		||||
            // Reserved headers (beginning with `:`) are not valid keys.
 | 
			
		||||
            if (key.charAt(0) === ':') {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const values = headers[key];
 | 
			
		||||
            try {
 | 
			
		||||
                if (isBinaryKey(key)) {
 | 
			
		||||
                    if (Array.isArray(values)) {
 | 
			
		||||
                        values.forEach(value => {
 | 
			
		||||
                            result.add(key, Buffer.from(value, 'base64'));
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (values !== undefined) {
 | 
			
		||||
                        values.split(',').forEach(v => {
 | 
			
		||||
                            result.add(key, Buffer.from(v.trim(), 'base64'));
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    if (Array.isArray(values)) {
 | 
			
		||||
                        values.forEach(value => {
 | 
			
		||||
                            result.add(key, value);
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (values !== undefined) {
 | 
			
		||||
                        values.split(',').forEach(v => result.add(key, v.trim()));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (error) {
 | 
			
		||||
                error.message = `Failed to add metadata entry ${key}: ${values}. ${error.message}`;
 | 
			
		||||
                process.emitWarning(error);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Metadata = Metadata;
 | 
			
		||||
//# sourceMappingURL=metadata.js.map
 | 
			
		||||
							
								
								
									
										37
									
								
								node_modules/@grpc/grpc-js/build/src/object-stream.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								node_modules/@grpc/grpc-js/build/src/object-stream.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { Duplex, Readable, Writable } from 'stream';
 | 
			
		||||
import { EmitterAugmentation1 } from './events';
 | 
			
		||||
export declare type WriteCallback = (error: Error | null | undefined) => void;
 | 
			
		||||
export interface IntermediateObjectReadable<T> extends Readable {
 | 
			
		||||
    read(size?: number): any & T;
 | 
			
		||||
}
 | 
			
		||||
export declare type ObjectReadable<T> = {
 | 
			
		||||
    read(size?: number): T;
 | 
			
		||||
} & EmitterAugmentation1<'data', T> & IntermediateObjectReadable<T>;
 | 
			
		||||
export interface IntermediateObjectWritable<T> extends Writable {
 | 
			
		||||
    _write(chunk: any & T, encoding: string, callback: Function): void;
 | 
			
		||||
    write(chunk: any & T, cb?: WriteCallback): boolean;
 | 
			
		||||
    write(chunk: any & T, encoding?: any, cb?: WriteCallback): boolean;
 | 
			
		||||
    setDefaultEncoding(encoding: string): this;
 | 
			
		||||
    end(): void;
 | 
			
		||||
    end(chunk: any & T, cb?: Function): void;
 | 
			
		||||
    end(chunk: any & T, encoding?: any, cb?: Function): void;
 | 
			
		||||
}
 | 
			
		||||
export interface ObjectWritable<T> extends IntermediateObjectWritable<T> {
 | 
			
		||||
    _write(chunk: T, encoding: string, callback: Function): void;
 | 
			
		||||
    write(chunk: T, cb?: Function): boolean;
 | 
			
		||||
    write(chunk: T, encoding?: any, cb?: Function): boolean;
 | 
			
		||||
    setDefaultEncoding(encoding: string): this;
 | 
			
		||||
    end(): void;
 | 
			
		||||
    end(chunk: T, cb?: Function): void;
 | 
			
		||||
    end(chunk: T, encoding?: any, cb?: Function): void;
 | 
			
		||||
}
 | 
			
		||||
export declare type ObjectDuplex<T, U> = {
 | 
			
		||||
    read(size?: number): U;
 | 
			
		||||
    _write(chunk: T, encoding: string, callback: Function): void;
 | 
			
		||||
    write(chunk: T, cb?: Function): boolean;
 | 
			
		||||
    write(chunk: T, encoding?: any, cb?: Function): boolean;
 | 
			
		||||
    end(): void;
 | 
			
		||||
    end(chunk: T, cb?: Function): void;
 | 
			
		||||
    end(chunk: T, encoding?: any, cb?: Function): void;
 | 
			
		||||
} & Duplex & ObjectWritable<T> & ObjectReadable<U>;
 | 
			
		||||
							
								
								
									
										19
									
								
								node_modules/@grpc/grpc-js/build/src/object-stream.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								node_modules/@grpc/grpc-js/build/src/object-stream.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +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
 | 
			
		||||
							
								
								
									
										1
									
								
								node_modules/@grpc/grpc-js/build/src/resolver-dns.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/@grpc/grpc-js/build/src/resolver-dns.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
export declare function setup(): void;
 | 
			
		||||
							
								
								
									
										141
									
								
								node_modules/@grpc/grpc-js/build/src/resolver-dns.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								node_modules/@grpc/grpc-js/build/src/resolver-dns.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,141 @@
 | 
			
		||||
"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 resolver_1 = require("./resolver");
 | 
			
		||||
const dns = require("dns");
 | 
			
		||||
const util = require("util");
 | 
			
		||||
const service_config_1 = require("./service-config");
 | 
			
		||||
/* These regular expressions match IP addresses with optional ports in different
 | 
			
		||||
 * formats. In each case, capture group 1 contains the address, and capture
 | 
			
		||||
 * group 2 contains the port number, if present */
 | 
			
		||||
const IPv4_REGEX = /^(\d{1,3}(?:\.\d{1,3}){3})(?::(\d+))?$/;
 | 
			
		||||
const IPv6_REGEX = /^([0-9a-f]{0,4}(?::{1,2}[0-9a-f]{0,4})+)$/i;
 | 
			
		||||
const IPv6_BRACKET_REGEX = /^\[([0-9a-f]{0,4}(?::{1,2}[0-9a-f]{0,4})+)\](?::(\d+))?$/i;
 | 
			
		||||
const DNS_REGEX = /^(?:dns:)?(?:\/\/\w+\/)?(\w+)(?::(\d+))?$/;
 | 
			
		||||
const DEFAULT_PORT = '443';
 | 
			
		||||
const resolve4Promise = util.promisify(dns.resolve4);
 | 
			
		||||
const resolve6Promise = util.promisify(dns.resolve6);
 | 
			
		||||
function parseIP(target) {
 | 
			
		||||
    /* These three regular expressions are all mutually exclusive, so we just
 | 
			
		||||
     * want the first one that matches the target string, if any do. */
 | 
			
		||||
    const match = IPv4_REGEX.exec(target) || IPv6_REGEX.exec(target) || IPv6_BRACKET_REGEX.exec(target);
 | 
			
		||||
    if (match === null) {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    const addr = match[1];
 | 
			
		||||
    let port;
 | 
			
		||||
    if (match[2]) {
 | 
			
		||||
        port = match[2];
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        port = DEFAULT_PORT;
 | 
			
		||||
    }
 | 
			
		||||
    return `${addr}:${port}`;
 | 
			
		||||
}
 | 
			
		||||
function mergeArrays(...arrays) {
 | 
			
		||||
    const result = [];
 | 
			
		||||
    for (let i = 0; i < Math.max.apply(null, arrays.map((array) => array.length)); i++) {
 | 
			
		||||
        for (let array of arrays) {
 | 
			
		||||
            if (i < array.length) {
 | 
			
		||||
                result.push(array[i]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
class DnsResolver {
 | 
			
		||||
    constructor(target, listener) {
 | 
			
		||||
        this.target = target;
 | 
			
		||||
        this.listener = listener;
 | 
			
		||||
        /* The promise results here contain, in order, the A record, the AAAA record,
 | 
			
		||||
         * and either the TXT record or an error if TXT resolution failed */
 | 
			
		||||
        this.pendingResultPromise = null;
 | 
			
		||||
        this.ipResult = parseIP(target);
 | 
			
		||||
        const dnsMatch = DNS_REGEX.exec(target);
 | 
			
		||||
        if (dnsMatch === null) {
 | 
			
		||||
            this.dnsHostname = null;
 | 
			
		||||
            this.port = null;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.dnsHostname = dnsMatch[1];
 | 
			
		||||
            if (dnsMatch[2]) {
 | 
			
		||||
                this.port = dnsMatch[2];
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                this.port = DEFAULT_PORT;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        this.percentage = Math.random() * 100;
 | 
			
		||||
        this.startResolution();
 | 
			
		||||
    }
 | 
			
		||||
    startResolution() {
 | 
			
		||||
        if (this.ipResult !== null) {
 | 
			
		||||
            setImmediate(() => {
 | 
			
		||||
                this.listener.onSuccessfulResolution([this.ipResult], null, null);
 | 
			
		||||
            });
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.dnsHostname !== null) {
 | 
			
		||||
            const hostname = this.dnsHostname;
 | 
			
		||||
            const Aresult = resolve4Promise(hostname);
 | 
			
		||||
            const AAAAresult = resolve6Promise(hostname);
 | 
			
		||||
            const TXTresult = new Promise((resolve, reject) => {
 | 
			
		||||
                dns.resolveTxt(hostname, (err, records) => {
 | 
			
		||||
                    if (err) {
 | 
			
		||||
                        resolve(err);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        resolve(records);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
            this.pendingResultPromise = Promise.all([Aresult, AAAAresult, TXTresult]);
 | 
			
		||||
            this.pendingResultPromise.then(([Arecord, AAAArecord, TXTrecord]) => {
 | 
			
		||||
                this.pendingResultPromise = null;
 | 
			
		||||
                const allAddresses = mergeArrays(AAAArecord, Arecord);
 | 
			
		||||
                let serviceConfig = null;
 | 
			
		||||
                let serviceConfigError = null;
 | 
			
		||||
                if (TXTrecord instanceof Error) {
 | 
			
		||||
                    serviceConfigError = TXTrecord;
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    try {
 | 
			
		||||
                        serviceConfig = service_config_1.extractAndSelectServiceConfig(TXTrecord, this.percentage);
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (err) {
 | 
			
		||||
                        serviceConfigError = err;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                this.listener.onSuccessfulResolution(allAddresses, serviceConfig, serviceConfigError);
 | 
			
		||||
            }, (err) => {
 | 
			
		||||
                this.pendingResultPromise = null;
 | 
			
		||||
                this.listener.onError(err);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    updateResolution() {
 | 
			
		||||
        if (this.pendingResultPromise === null) {
 | 
			
		||||
            this.startResolution();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function setup() {
 | 
			
		||||
    resolver_1.registerResolver('dns:', DnsResolver);
 | 
			
		||||
    resolver_1.registerDefaultResolver(DnsResolver);
 | 
			
		||||
}
 | 
			
		||||
exports.setup = setup;
 | 
			
		||||
//# sourceMappingURL=resolver-dns.js.map
 | 
			
		||||
							
								
								
									
										15
									
								
								node_modules/@grpc/grpc-js/build/src/resolver.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								node_modules/@grpc/grpc-js/build/src/resolver.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
import { ServiceError } from "./call";
 | 
			
		||||
import { ServiceConfig } from "./service-config";
 | 
			
		||||
export interface ResolverListener {
 | 
			
		||||
    onSuccessfulResolution(addressList: string[], serviceConfig: ServiceConfig | null, serviceConfigError: Error | null): void;
 | 
			
		||||
    onError(error: ServiceError): void;
 | 
			
		||||
}
 | 
			
		||||
export interface Resolver {
 | 
			
		||||
    updateResolution(): void;
 | 
			
		||||
}
 | 
			
		||||
export interface ResolverConstructor {
 | 
			
		||||
    new (target: string, listener: ResolverListener): Resolver;
 | 
			
		||||
}
 | 
			
		||||
export declare function registerResolver(prefix: string, resolverClass: ResolverConstructor): void;
 | 
			
		||||
export declare function registerDefaultResolver(resolverClass: ResolverConstructor): void;
 | 
			
		||||
export declare function createResolver(target: string, listener: ResolverListener): Resolver;
 | 
			
		||||
							
								
								
									
										41
									
								
								node_modules/@grpc/grpc-js/build/src/resolver.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								node_modules/@grpc/grpc-js/build/src/resolver.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
"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 registeredResolvers = {};
 | 
			
		||||
let defaultResolver = null;
 | 
			
		||||
function registerResolver(prefix, resolverClass) {
 | 
			
		||||
    registeredResolvers[prefix] = resolverClass;
 | 
			
		||||
}
 | 
			
		||||
exports.registerResolver = registerResolver;
 | 
			
		||||
function registerDefaultResolver(resolverClass) {
 | 
			
		||||
    defaultResolver = resolverClass;
 | 
			
		||||
}
 | 
			
		||||
exports.registerDefaultResolver = registerDefaultResolver;
 | 
			
		||||
function createResolver(target, listener) {
 | 
			
		||||
    for (const prefix of Object.keys(registeredResolvers)) {
 | 
			
		||||
        if (target.startsWith(prefix)) {
 | 
			
		||||
            return new registeredResolvers[prefix](target, listener);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (defaultResolver !== null) {
 | 
			
		||||
        return new defaultResolver(target, listener);
 | 
			
		||||
    }
 | 
			
		||||
    throw new Error('No resolver could be created for the provided target');
 | 
			
		||||
}
 | 
			
		||||
exports.createResolver = createResolver;
 | 
			
		||||
//# sourceMappingURL=resolver.js.map
 | 
			
		||||
							
								
								
									
										125
									
								
								node_modules/@grpc/grpc-js/build/src/server-call.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								node_modules/@grpc/grpc-js/build/src/server-call.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,125 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { EventEmitter } from 'events';
 | 
			
		||||
import * as http2 from 'http2';
 | 
			
		||||
import { Duplex, Readable, Writable } from 'stream';
 | 
			
		||||
import { ServiceError } from './call';
 | 
			
		||||
import { StatusObject } from './call-stream';
 | 
			
		||||
import { Deserialize, Serialize } from './make-client';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export declare type ServerSurfaceCall = {
 | 
			
		||||
    cancelled: boolean;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    sendMetadata(responseMetadata: Metadata): void;
 | 
			
		||||
} & EventEmitter;
 | 
			
		||||
export declare type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & {
 | 
			
		||||
    request: RequestType | null;
 | 
			
		||||
};
 | 
			
		||||
export declare type ServerReadableStream<RequestType, ResponseType> = ServerSurfaceCall & Readable;
 | 
			
		||||
export declare type ServerWritableStream<RequestType, ResponseType> = ServerSurfaceCall & Writable & {
 | 
			
		||||
    request: RequestType | null;
 | 
			
		||||
};
 | 
			
		||||
export declare type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall & Duplex;
 | 
			
		||||
export declare class ServerUnaryCallImpl<RequestType, ResponseType> extends EventEmitter implements ServerUnaryCall<RequestType, ResponseType> {
 | 
			
		||||
    private call;
 | 
			
		||||
    metadata: Metadata;
 | 
			
		||||
    cancelled: boolean;
 | 
			
		||||
    request: RequestType | null;
 | 
			
		||||
    constructor(call: Http2ServerCallStream<RequestType, ResponseType>, metadata: Metadata);
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    sendMetadata(responseMetadata: Metadata): void;
 | 
			
		||||
}
 | 
			
		||||
export declare class ServerReadableStreamImpl<RequestType, ResponseType> extends Readable implements ServerReadableStream<RequestType, ResponseType> {
 | 
			
		||||
    private call;
 | 
			
		||||
    metadata: Metadata;
 | 
			
		||||
    deserialize: Deserialize<RequestType>;
 | 
			
		||||
    cancelled: boolean;
 | 
			
		||||
    constructor(call: Http2ServerCallStream<RequestType, ResponseType>, metadata: Metadata, deserialize: Deserialize<RequestType>);
 | 
			
		||||
    _read(size: number): void;
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    sendMetadata(responseMetadata: Metadata): void;
 | 
			
		||||
}
 | 
			
		||||
export declare class ServerWritableStreamImpl<RequestType, ResponseType> extends Writable implements ServerWritableStream<RequestType, ResponseType> {
 | 
			
		||||
    private call;
 | 
			
		||||
    metadata: Metadata;
 | 
			
		||||
    serialize: Serialize<ResponseType>;
 | 
			
		||||
    cancelled: boolean;
 | 
			
		||||
    request: RequestType | null;
 | 
			
		||||
    private trailingMetadata;
 | 
			
		||||
    constructor(call: Http2ServerCallStream<RequestType, ResponseType>, metadata: Metadata, serialize: Serialize<ResponseType>);
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    sendMetadata(responseMetadata: Metadata): void;
 | 
			
		||||
    _write(chunk: ResponseType, encoding: string, callback: (...args: any[]) => void): Promise<void>;
 | 
			
		||||
    _final(callback: Function): void;
 | 
			
		||||
    end(metadata?: any): void;
 | 
			
		||||
}
 | 
			
		||||
export declare class ServerDuplexStreamImpl<RequestType, ResponseType> extends Duplex implements ServerDuplexStream<RequestType, ResponseType> {
 | 
			
		||||
    private call;
 | 
			
		||||
    metadata: Metadata;
 | 
			
		||||
    serialize: Serialize<ResponseType>;
 | 
			
		||||
    deserialize: Deserialize<RequestType>;
 | 
			
		||||
    cancelled: boolean;
 | 
			
		||||
    private trailingMetadata;
 | 
			
		||||
    constructor(call: Http2ServerCallStream<RequestType, ResponseType>, metadata: Metadata, serialize: Serialize<ResponseType>, deserialize: Deserialize<RequestType>);
 | 
			
		||||
    getPeer(): string;
 | 
			
		||||
    sendMetadata(responseMetadata: Metadata): void;
 | 
			
		||||
}
 | 
			
		||||
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, ResponseType>, callback: sendUnaryData<ResponseType>) => void;
 | 
			
		||||
export declare type handleClientStreamingCall<RequestType, ResponseType> = (call: ServerReadableStream<RequestType, ResponseType>, 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 interface UnaryHandler<RequestType, ResponseType> {
 | 
			
		||||
    func: handleUnaryCall<RequestType, ResponseType>;
 | 
			
		||||
    serialize: Serialize<ResponseType>;
 | 
			
		||||
    deserialize: Deserialize<RequestType>;
 | 
			
		||||
    type: HandlerType;
 | 
			
		||||
}
 | 
			
		||||
export interface ClientStreamingHandler<RequestType, ResponseType> {
 | 
			
		||||
    func: handleClientStreamingCall<RequestType, ResponseType>;
 | 
			
		||||
    serialize: Serialize<ResponseType>;
 | 
			
		||||
    deserialize: Deserialize<RequestType>;
 | 
			
		||||
    type: HandlerType;
 | 
			
		||||
}
 | 
			
		||||
export interface ServerStreamingHandler<RequestType, ResponseType> {
 | 
			
		||||
    func: handleServerStreamingCall<RequestType, ResponseType>;
 | 
			
		||||
    serialize: Serialize<ResponseType>;
 | 
			
		||||
    deserialize: Deserialize<RequestType>;
 | 
			
		||||
    type: HandlerType;
 | 
			
		||||
}
 | 
			
		||||
export interface BidiStreamingHandler<RequestType, ResponseType> {
 | 
			
		||||
    func: handleBidiStreamingCall<RequestType, ResponseType>;
 | 
			
		||||
    serialize: Serialize<ResponseType>;
 | 
			
		||||
    deserialize: Deserialize<RequestType>;
 | 
			
		||||
    type: HandlerType;
 | 
			
		||||
}
 | 
			
		||||
export declare type Handler<RequestType, ResponseType> = UnaryHandler<RequestType, ResponseType> | ClientStreamingHandler<RequestType, ResponseType> | ServerStreamingHandler<RequestType, ResponseType> | BidiStreamingHandler<RequestType, ResponseType>;
 | 
			
		||||
export declare type HandlerType = 'bidi' | 'clientStream' | 'serverStream' | 'unary';
 | 
			
		||||
export declare class Http2ServerCallStream<RequestType, ResponseType> extends EventEmitter {
 | 
			
		||||
    private stream;
 | 
			
		||||
    private handler;
 | 
			
		||||
    cancelled: boolean;
 | 
			
		||||
    deadline: NodeJS.Timer;
 | 
			
		||||
    private wantTrailers;
 | 
			
		||||
    private metadataSent;
 | 
			
		||||
    private canPush;
 | 
			
		||||
    private isPushPending;
 | 
			
		||||
    private bufferedMessages;
 | 
			
		||||
    private messagesToPush;
 | 
			
		||||
    constructor(stream: http2.ServerHttp2Stream, handler: Handler<RequestType, ResponseType>);
 | 
			
		||||
    sendMetadata(customMetadata?: Metadata): void;
 | 
			
		||||
    receiveMetadata(headers: http2.IncomingHttpHeaders): Metadata | undefined;
 | 
			
		||||
    receiveUnaryMessage(): Promise<RequestType>;
 | 
			
		||||
    serializeMessage(value: ResponseType): Buffer;
 | 
			
		||||
    deserializeMessage(bytes: Buffer): Promise<RequestType>;
 | 
			
		||||
    sendUnaryMessage(err: ServiceError | null, value: ResponseType | null, metadata?: Metadata, flags?: number): Promise<void>;
 | 
			
		||||
    sendStatus(statusObj: StatusObject): void;
 | 
			
		||||
    sendError(error: ServiceError): void;
 | 
			
		||||
    write(chunk: Buffer): boolean | undefined;
 | 
			
		||||
    resume(): void;
 | 
			
		||||
    setupSurfaceCall(call: ServerSurfaceCall): void;
 | 
			
		||||
    setupReadable(readable: ServerReadableStream<RequestType, ResponseType> | ServerDuplexStream<RequestType, ResponseType>): void;
 | 
			
		||||
    consumeUnpushedMessages(readable: ServerReadableStream<RequestType, ResponseType> | ServerDuplexStream<RequestType, ResponseType>): boolean;
 | 
			
		||||
    private pushOrBufferMessage;
 | 
			
		||||
    private pushMessage;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										416
									
								
								node_modules/@grpc/grpc-js/build/src/server-call.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										416
									
								
								node_modules/@grpc/grpc-js/build/src/server-call.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,416 @@
 | 
			
		||||
"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");
 | 
			
		||||
const stream_1 = require("stream");
 | 
			
		||||
const constants_1 = require("./constants");
 | 
			
		||||
const metadata_1 = require("./metadata");
 | 
			
		||||
const stream_decoder_1 = require("./stream-decoder");
 | 
			
		||||
const GRPC_ACCEPT_ENCODING_HEADER = 'grpc-accept-encoding';
 | 
			
		||||
const GRPC_ENCODING_HEADER = 'grpc-encoding';
 | 
			
		||||
const GRPC_MESSAGE_HEADER = 'grpc-message';
 | 
			
		||||
const GRPC_STATUS_HEADER = 'grpc-status';
 | 
			
		||||
const GRPC_TIMEOUT_HEADER = 'grpc-timeout';
 | 
			
		||||
const DEADLINE_REGEX = /(\d{1,8})\s*([HMSmun])/;
 | 
			
		||||
const deadlineUnitsToMs = {
 | 
			
		||||
    H: 3600000,
 | 
			
		||||
    M: 60000,
 | 
			
		||||
    S: 1000,
 | 
			
		||||
    m: 1,
 | 
			
		||||
    u: 0.001,
 | 
			
		||||
    n: 0.000001,
 | 
			
		||||
};
 | 
			
		||||
const defaultResponseHeaders = {
 | 
			
		||||
    // TODO(cjihrig): Remove these encoding headers from the default response
 | 
			
		||||
    // once compression is integrated.
 | 
			
		||||
    [GRPC_ACCEPT_ENCODING_HEADER]: 'identity',
 | 
			
		||||
    [GRPC_ENCODING_HEADER]: 'identity',
 | 
			
		||||
    [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_OK,
 | 
			
		||||
    [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'application/grpc+proto',
 | 
			
		||||
};
 | 
			
		||||
const defaultResponseOptions = {
 | 
			
		||||
    waitForTrailers: true,
 | 
			
		||||
};
 | 
			
		||||
class ServerUnaryCallImpl extends events_1.EventEmitter {
 | 
			
		||||
    constructor(call, metadata) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.metadata = metadata;
 | 
			
		||||
        this.cancelled = false;
 | 
			
		||||
        this.request = null;
 | 
			
		||||
        this.call.setupSurfaceCall(this);
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        throw new Error('not implemented yet');
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(responseMetadata) {
 | 
			
		||||
        this.call.sendMetadata(responseMetadata);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ServerUnaryCallImpl = ServerUnaryCallImpl;
 | 
			
		||||
class ServerReadableStreamImpl extends stream_1.Readable {
 | 
			
		||||
    constructor(call, metadata, deserialize) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.metadata = metadata;
 | 
			
		||||
        this.deserialize = deserialize;
 | 
			
		||||
        this.cancelled = false;
 | 
			
		||||
        this.call.setupSurfaceCall(this);
 | 
			
		||||
        this.call.setupReadable(this);
 | 
			
		||||
    }
 | 
			
		||||
    _read(size) {
 | 
			
		||||
        if (!this.call.consumeUnpushedMessages(this)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.call.resume();
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        throw new Error('not implemented yet');
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(responseMetadata) {
 | 
			
		||||
        this.call.sendMetadata(responseMetadata);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ServerReadableStreamImpl = ServerReadableStreamImpl;
 | 
			
		||||
class ServerWritableStreamImpl extends stream_1.Writable {
 | 
			
		||||
    constructor(call, metadata, serialize) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.metadata = metadata;
 | 
			
		||||
        this.serialize = serialize;
 | 
			
		||||
        this.cancelled = false;
 | 
			
		||||
        this.request = null;
 | 
			
		||||
        this.trailingMetadata = new metadata_1.Metadata();
 | 
			
		||||
        this.call.setupSurfaceCall(this);
 | 
			
		||||
        this.on('error', err => {
 | 
			
		||||
            this.call.sendError(err);
 | 
			
		||||
            this.end();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        throw new Error('not implemented yet');
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(responseMetadata) {
 | 
			
		||||
        this.call.sendMetadata(responseMetadata);
 | 
			
		||||
    }
 | 
			
		||||
    async _write(chunk, encoding, 
 | 
			
		||||
    // tslint:disable-next-line:no-any
 | 
			
		||||
    callback) {
 | 
			
		||||
        try {
 | 
			
		||||
            const response = await this.call.serializeMessage(chunk);
 | 
			
		||||
            if (!this.call.write(response)) {
 | 
			
		||||
                this.call.once('drain', callback);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
            err.code = constants_1.Status.INTERNAL;
 | 
			
		||||
            this.emit('error', err);
 | 
			
		||||
        }
 | 
			
		||||
        callback();
 | 
			
		||||
    }
 | 
			
		||||
    _final(callback) {
 | 
			
		||||
        this.call.sendStatus({
 | 
			
		||||
            code: constants_1.Status.OK,
 | 
			
		||||
            details: 'OK',
 | 
			
		||||
            metadata: this.trailingMetadata,
 | 
			
		||||
        });
 | 
			
		||||
        callback(null);
 | 
			
		||||
    }
 | 
			
		||||
    // tslint:disable-next-line:no-any
 | 
			
		||||
    end(metadata) {
 | 
			
		||||
        if (metadata) {
 | 
			
		||||
            this.trailingMetadata = metadata;
 | 
			
		||||
        }
 | 
			
		||||
        super.end();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ServerWritableStreamImpl = ServerWritableStreamImpl;
 | 
			
		||||
class ServerDuplexStreamImpl extends stream_1.Duplex {
 | 
			
		||||
    constructor(call, metadata, serialize, deserialize) {
 | 
			
		||||
        super({ objectMode: true });
 | 
			
		||||
        this.call = call;
 | 
			
		||||
        this.metadata = metadata;
 | 
			
		||||
        this.serialize = serialize;
 | 
			
		||||
        this.deserialize = deserialize;
 | 
			
		||||
        this.cancelled = false;
 | 
			
		||||
        this.trailingMetadata = new metadata_1.Metadata();
 | 
			
		||||
        this.call.setupSurfaceCall(this);
 | 
			
		||||
        this.call.setupReadable(this);
 | 
			
		||||
        this.on('error', err => {
 | 
			
		||||
            this.call.sendError(err);
 | 
			
		||||
            this.end();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    getPeer() {
 | 
			
		||||
        throw new Error('not implemented yet');
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(responseMetadata) {
 | 
			
		||||
        this.call.sendMetadata(responseMetadata);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.ServerDuplexStreamImpl = ServerDuplexStreamImpl;
 | 
			
		||||
ServerDuplexStreamImpl.prototype._read =
 | 
			
		||||
    ServerReadableStreamImpl.prototype._read;
 | 
			
		||||
ServerDuplexStreamImpl.prototype._write =
 | 
			
		||||
    ServerWritableStreamImpl.prototype._write;
 | 
			
		||||
ServerDuplexStreamImpl.prototype._final =
 | 
			
		||||
    ServerWritableStreamImpl.prototype._final;
 | 
			
		||||
ServerDuplexStreamImpl.prototype.end = ServerWritableStreamImpl.prototype.end;
 | 
			
		||||
const noopTimer = setTimeout(() => { }, 0);
 | 
			
		||||
// Internal class that wraps the HTTP2 request.
 | 
			
		||||
class Http2ServerCallStream extends events_1.EventEmitter {
 | 
			
		||||
    constructor(stream, handler) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.stream = stream;
 | 
			
		||||
        this.handler = handler;
 | 
			
		||||
        this.cancelled = false;
 | 
			
		||||
        this.deadline = noopTimer;
 | 
			
		||||
        this.wantTrailers = false;
 | 
			
		||||
        this.metadataSent = false;
 | 
			
		||||
        this.canPush = false;
 | 
			
		||||
        this.isPushPending = false;
 | 
			
		||||
        this.bufferedMessages = [];
 | 
			
		||||
        this.messagesToPush = [];
 | 
			
		||||
        this.stream.once('error', (err) => {
 | 
			
		||||
            err.code = constants_1.Status.INTERNAL;
 | 
			
		||||
            this.sendError(err);
 | 
			
		||||
        });
 | 
			
		||||
        this.stream.once('close', () => {
 | 
			
		||||
            if (this.stream.rstCode === http2.constants.NGHTTP2_CANCEL) {
 | 
			
		||||
                this.cancelled = true;
 | 
			
		||||
                this.emit('cancelled', 'cancelled');
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        this.stream.on('drain', () => {
 | 
			
		||||
            this.emit('drain');
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    sendMetadata(customMetadata) {
 | 
			
		||||
        if (this.metadataSent) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.metadataSent = true;
 | 
			
		||||
        const custom = customMetadata ? customMetadata.toHttp2Headers() : null;
 | 
			
		||||
        // TODO(cjihrig): Include compression headers.
 | 
			
		||||
        const headers = Object.assign(defaultResponseHeaders, custom);
 | 
			
		||||
        this.stream.respond(headers, defaultResponseOptions);
 | 
			
		||||
    }
 | 
			
		||||
    receiveMetadata(headers) {
 | 
			
		||||
        const metadata = metadata_1.Metadata.fromHttp2Headers(headers);
 | 
			
		||||
        // TODO(cjihrig): Receive compression metadata.
 | 
			
		||||
        const timeoutHeader = metadata.get(GRPC_TIMEOUT_HEADER);
 | 
			
		||||
        if (timeoutHeader.length > 0) {
 | 
			
		||||
            const match = timeoutHeader[0].toString().match(DEADLINE_REGEX);
 | 
			
		||||
            if (match === null) {
 | 
			
		||||
                const err = new Error('Invalid deadline');
 | 
			
		||||
                err.code = constants_1.Status.OUT_OF_RANGE;
 | 
			
		||||
                this.sendError(err);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const timeout = (+match[1] * deadlineUnitsToMs[match[2]]) | 0;
 | 
			
		||||
            this.deadline = setTimeout(handleExpiredDeadline, timeout, this);
 | 
			
		||||
            metadata.remove(GRPC_TIMEOUT_HEADER);
 | 
			
		||||
        }
 | 
			
		||||
        return metadata;
 | 
			
		||||
    }
 | 
			
		||||
    receiveUnaryMessage() {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            const stream = this.stream;
 | 
			
		||||
            const chunks = [];
 | 
			
		||||
            let totalLength = 0;
 | 
			
		||||
            stream.on('data', (data) => {
 | 
			
		||||
                chunks.push(data);
 | 
			
		||||
                totalLength += data.byteLength;
 | 
			
		||||
            });
 | 
			
		||||
            stream.once('end', async () => {
 | 
			
		||||
                try {
 | 
			
		||||
                    const requestBytes = Buffer.concat(chunks, totalLength);
 | 
			
		||||
                    resolve(await this.deserializeMessage(requestBytes));
 | 
			
		||||
                }
 | 
			
		||||
                catch (err) {
 | 
			
		||||
                    err.code = constants_1.Status.INTERNAL;
 | 
			
		||||
                    this.sendError(err);
 | 
			
		||||
                    resolve();
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    serializeMessage(value) {
 | 
			
		||||
        const messageBuffer = this.handler.serialize(value);
 | 
			
		||||
        // TODO(cjihrig): Call compression aware serializeMessage().
 | 
			
		||||
        const byteLength = messageBuffer.byteLength;
 | 
			
		||||
        const output = Buffer.allocUnsafe(byteLength + 5);
 | 
			
		||||
        output.writeUInt8(0, 0);
 | 
			
		||||
        output.writeUInt32BE(byteLength, 1);
 | 
			
		||||
        messageBuffer.copy(output, 5);
 | 
			
		||||
        return output;
 | 
			
		||||
    }
 | 
			
		||||
    async deserializeMessage(bytes) {
 | 
			
		||||
        // TODO(cjihrig): Call compression aware deserializeMessage().
 | 
			
		||||
        const receivedMessage = bytes.slice(5);
 | 
			
		||||
        return this.handler.deserialize(receivedMessage);
 | 
			
		||||
    }
 | 
			
		||||
    async sendUnaryMessage(err, value, metadata, flags) {
 | 
			
		||||
        if (!metadata) {
 | 
			
		||||
            metadata = new metadata_1.Metadata();
 | 
			
		||||
        }
 | 
			
		||||
        if (err) {
 | 
			
		||||
            err.metadata = metadata;
 | 
			
		||||
            this.sendError(err);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
            const response = await this.serializeMessage(value);
 | 
			
		||||
            this.write(response);
 | 
			
		||||
            this.sendStatus({ code: constants_1.Status.OK, details: 'OK', metadata });
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
            err.code = constants_1.Status.INTERNAL;
 | 
			
		||||
            this.sendError(err);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    sendStatus(statusObj) {
 | 
			
		||||
        if (this.cancelled) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        clearTimeout(this.deadline);
 | 
			
		||||
        if (!this.wantTrailers) {
 | 
			
		||||
            this.wantTrailers = true;
 | 
			
		||||
            this.stream.once('wantTrailers', () => {
 | 
			
		||||
                const trailersToSend = Object.assign({
 | 
			
		||||
                    [GRPC_STATUS_HEADER]: statusObj.code,
 | 
			
		||||
                    [GRPC_MESSAGE_HEADER]: encodeURI(statusObj.details),
 | 
			
		||||
                }, statusObj.metadata.toHttp2Headers());
 | 
			
		||||
                this.stream.sendTrailers(trailersToSend);
 | 
			
		||||
            });
 | 
			
		||||
            this.sendMetadata();
 | 
			
		||||
            this.stream.end();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    sendError(error) {
 | 
			
		||||
        const status = {
 | 
			
		||||
            code: constants_1.Status.UNKNOWN,
 | 
			
		||||
            details: error.hasOwnProperty('message')
 | 
			
		||||
                ? error.message
 | 
			
		||||
                : 'Unknown Error',
 | 
			
		||||
            metadata: error.hasOwnProperty('metadata')
 | 
			
		||||
                ? error.metadata
 | 
			
		||||
                : new metadata_1.Metadata(),
 | 
			
		||||
        };
 | 
			
		||||
        if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
 | 
			
		||||
            status.code = error.code;
 | 
			
		||||
            if (error.hasOwnProperty('details')) {
 | 
			
		||||
                status.details = error.details;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        this.sendStatus(status);
 | 
			
		||||
    }
 | 
			
		||||
    write(chunk) {
 | 
			
		||||
        if (this.cancelled) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.sendMetadata();
 | 
			
		||||
        return this.stream.write(chunk);
 | 
			
		||||
    }
 | 
			
		||||
    resume() {
 | 
			
		||||
        this.stream.resume();
 | 
			
		||||
    }
 | 
			
		||||
    setupSurfaceCall(call) {
 | 
			
		||||
        this.once('cancelled', reason => {
 | 
			
		||||
            call.cancelled = true;
 | 
			
		||||
            call.emit('cancelled', reason);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    setupReadable(readable) {
 | 
			
		||||
        const decoder = new stream_decoder_1.StreamDecoder();
 | 
			
		||||
        this.stream.on('data', async (data) => {
 | 
			
		||||
            const messages = decoder.write(data);
 | 
			
		||||
            for (const message of messages) {
 | 
			
		||||
                this.pushOrBufferMessage(readable, message);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        this.stream.once('end', () => {
 | 
			
		||||
            this.pushOrBufferMessage(readable, null);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    consumeUnpushedMessages(readable) {
 | 
			
		||||
        this.canPush = true;
 | 
			
		||||
        while (this.messagesToPush.length > 0) {
 | 
			
		||||
            const nextMessage = this.messagesToPush.shift();
 | 
			
		||||
            const canPush = readable.push(nextMessage);
 | 
			
		||||
            if (nextMessage === null || canPush === false) {
 | 
			
		||||
                this.canPush = false;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return this.canPush;
 | 
			
		||||
    }
 | 
			
		||||
    pushOrBufferMessage(readable, messageBytes) {
 | 
			
		||||
        if (this.isPushPending) {
 | 
			
		||||
            this.bufferedMessages.push(messageBytes);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this.pushMessage(readable, messageBytes);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    async pushMessage(readable, messageBytes) {
 | 
			
		||||
        if (messageBytes === null) {
 | 
			
		||||
            if (this.canPush) {
 | 
			
		||||
                readable.push(null);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                this.messagesToPush.push(null);
 | 
			
		||||
            }
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.isPushPending = true;
 | 
			
		||||
        try {
 | 
			
		||||
            const deserialized = await this.deserializeMessage(messageBytes);
 | 
			
		||||
            if (this.canPush) {
 | 
			
		||||
                if (!readable.push(deserialized)) {
 | 
			
		||||
                    this.canPush = false;
 | 
			
		||||
                    this.stream.pause();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                this.messagesToPush.push(deserialized);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
            // Ignore any remaining messages when errors occur.
 | 
			
		||||
            this.bufferedMessages.length = 0;
 | 
			
		||||
            err.code = constants_1.Status.INTERNAL;
 | 
			
		||||
            readable.emit('error', err);
 | 
			
		||||
        }
 | 
			
		||||
        this.isPushPending = false;
 | 
			
		||||
        if (this.bufferedMessages.length > 0) {
 | 
			
		||||
            this.pushMessage(readable, this.bufferedMessages.shift());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Http2ServerCallStream = Http2ServerCallStream;
 | 
			
		||||
function handleExpiredDeadline(call) {
 | 
			
		||||
    const err = new Error('Deadline exceeded');
 | 
			
		||||
    err.code = constants_1.Status.DEADLINE_EXCEEDED;
 | 
			
		||||
    call.sendError(err);
 | 
			
		||||
    call.cancelled = true;
 | 
			
		||||
    call.emit('cancelled', 'deadline');
 | 
			
		||||
}
 | 
			
		||||
//# sourceMappingURL=server-call.js.map
 | 
			
		||||
							
								
								
									
										12
									
								
								node_modules/@grpc/grpc-js/build/src/server-credentials.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								node_modules/@grpc/grpc-js/build/src/server-credentials.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { SecureServerOptions } from 'http2';
 | 
			
		||||
export interface 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								node_modules/@grpc/grpc-js/build/src/server-credentials.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								node_modules/@grpc/grpc-js/build/src/server-credentials.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -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
 | 
			
		||||
							
								
								
									
										20
									
								
								node_modules/@grpc/grpc-js/build/src/server.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								node_modules/@grpc/grpc-js/build/src/server.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
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 sessions;
 | 
			
		||||
    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;
 | 
			
		||||
    private _setupHandlers;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										302
									
								
								node_modules/@grpc/grpc-js/build/src/server.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										302
									
								
								node_modules/@grpc/grpc-js/build/src/server.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,302 @@
 | 
			
		||||
"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");
 | 
			
		||||
const metadata_1 = require("./metadata");
 | 
			
		||||
const server_call_1 = require("./server-call");
 | 
			
		||||
function noop() { }
 | 
			
		||||
const unimplementedStatusResponse = {
 | 
			
		||||
    code: constants_1.Status.UNIMPLEMENTED,
 | 
			
		||||
    details: 'The server does not implement this method',
 | 
			
		||||
    metadata: new metadata_1.Metadata(),
 | 
			
		||||
};
 | 
			
		||||
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.sessions = new Set();
 | 
			
		||||
        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();
 | 
			
		||||
        }
 | 
			
		||||
        this.http2Server.setTimeout(0, noop);
 | 
			
		||||
        this._setupHandlers();
 | 
			
		||||
        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() {
 | 
			
		||||
        // Close the server if it is still running.
 | 
			
		||||
        if (this.http2Server && this.http2Server.listening) {
 | 
			
		||||
            this.http2Server.close();
 | 
			
		||||
        }
 | 
			
		||||
        this.started = false;
 | 
			
		||||
        // Always destroy any available sessions. It's possible that one or more
 | 
			
		||||
        // tryShutdown() calls are in progress. Don't wait on them to finish.
 | 
			
		||||
        this.sessions.forEach(session => {
 | 
			
		||||
            // Cast NGHTTP2_CANCEL to any because TypeScript doesn't seem to
 | 
			
		||||
            // recognize destroy(code) as a valid signature.
 | 
			
		||||
            // tslint:disable-next-line:no-any
 | 
			
		||||
            session.destroy(http2.constants.NGHTTP2_CANCEL);
 | 
			
		||||
        });
 | 
			
		||||
        this.sessions.clear();
 | 
			
		||||
    }
 | 
			
		||||
    register(name, handler, serialize, deserialize, type) {
 | 
			
		||||
        if (this.handlers.has(name)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        this.handlers.set(name, {
 | 
			
		||||
            func: handler,
 | 
			
		||||
            serialize,
 | 
			
		||||
            deserialize,
 | 
			
		||||
            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) {
 | 
			
		||||
        let pendingChecks = 0;
 | 
			
		||||
        function maybeCallback() {
 | 
			
		||||
            pendingChecks--;
 | 
			
		||||
            if (pendingChecks === 0) {
 | 
			
		||||
                callback();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        // Close the server if necessary.
 | 
			
		||||
        this.started = false;
 | 
			
		||||
        if (this.http2Server && this.http2Server.listening) {
 | 
			
		||||
            pendingChecks++;
 | 
			
		||||
            this.http2Server.close(maybeCallback);
 | 
			
		||||
        }
 | 
			
		||||
        // If any sessions are active, close them gracefully.
 | 
			
		||||
        pendingChecks += this.sessions.size;
 | 
			
		||||
        this.sessions.forEach(session => {
 | 
			
		||||
            session.close(maybeCallback);
 | 
			
		||||
        });
 | 
			
		||||
        // If the server is closed and there are no active sessions, just call back.
 | 
			
		||||
        if (pendingChecks === 0) {
 | 
			
		||||
            callback();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    addHttp2Port() {
 | 
			
		||||
        throw new Error('Not yet implemented');
 | 
			
		||||
    }
 | 
			
		||||
    _setupHandlers() {
 | 
			
		||||
        if (this.http2Server === null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        this.http2Server.on('stream', (stream, headers) => {
 | 
			
		||||
            const contentType = headers[http2.constants.HTTP2_HEADER_CONTENT_TYPE];
 | 
			
		||||
            if (typeof contentType !== 'string' ||
 | 
			
		||||
                !contentType.startsWith('application/grpc')) {
 | 
			
		||||
                stream.respond({
 | 
			
		||||
                    [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,
 | 
			
		||||
                }, { endStream: true });
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            try {
 | 
			
		||||
                const path = headers[http2.constants.HTTP2_HEADER_PATH];
 | 
			
		||||
                const handler = this.handlers.get(path);
 | 
			
		||||
                if (handler === undefined) {
 | 
			
		||||
                    throw unimplementedStatusResponse;
 | 
			
		||||
                }
 | 
			
		||||
                const call = new server_call_1.Http2ServerCallStream(stream, handler);
 | 
			
		||||
                const metadata = call.receiveMetadata(headers);
 | 
			
		||||
                switch (handler.type) {
 | 
			
		||||
                    case 'unary':
 | 
			
		||||
                        handleUnary(call, handler, metadata);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'clientStream':
 | 
			
		||||
                        handleClientStreaming(call, handler, metadata);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'serverStream':
 | 
			
		||||
                        handleServerStreaming(call, handler, metadata);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'bidi':
 | 
			
		||||
                        handleBidiStreaming(call, handler, metadata);
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        throw new Error(`Unknown handler type: ${handler.type}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (err) {
 | 
			
		||||
                const call = new server_call_1.Http2ServerCallStream(stream, null);
 | 
			
		||||
                if (err.code === undefined) {
 | 
			
		||||
                    err.code = constants_1.Status.INTERNAL;
 | 
			
		||||
                }
 | 
			
		||||
                call.sendError(err);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        this.http2Server.on('session', session => {
 | 
			
		||||
            if (!this.started) {
 | 
			
		||||
                session.destroy();
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            this.sessions.add(session);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Server = Server;
 | 
			
		||||
async function handleUnary(call, handler, metadata) {
 | 
			
		||||
    const emitter = new server_call_1.ServerUnaryCallImpl(call, metadata);
 | 
			
		||||
    const request = await call.receiveUnaryMessage();
 | 
			
		||||
    if (request === undefined || call.cancelled) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    emitter.request = request;
 | 
			
		||||
    handler.func(emitter, (err, value, trailer, flags) => {
 | 
			
		||||
        call.sendUnaryMessage(err, value, trailer, flags);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function handleClientStreaming(call, handler, metadata) {
 | 
			
		||||
    const stream = new server_call_1.ServerReadableStreamImpl(call, metadata, handler.deserialize);
 | 
			
		||||
    function respond(err, value, trailer, flags) {
 | 
			
		||||
        stream.destroy();
 | 
			
		||||
        call.sendUnaryMessage(err, value, trailer, flags);
 | 
			
		||||
    }
 | 
			
		||||
    if (call.cancelled) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    stream.on('error', respond);
 | 
			
		||||
    handler.func(stream, respond);
 | 
			
		||||
}
 | 
			
		||||
async function handleServerStreaming(call, handler, metadata) {
 | 
			
		||||
    const request = await call.receiveUnaryMessage();
 | 
			
		||||
    if (request === undefined || call.cancelled) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    const stream = new server_call_1.ServerWritableStreamImpl(call, metadata, handler.serialize);
 | 
			
		||||
    stream.request = request;
 | 
			
		||||
    handler.func(stream);
 | 
			
		||||
}
 | 
			
		||||
function handleBidiStreaming(call, handler, metadata) {
 | 
			
		||||
    const stream = new server_call_1.ServerDuplexStreamImpl(call, metadata, handler.serialize, handler.deserialize);
 | 
			
		||||
    if (call.cancelled) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    handler.func(stream);
 | 
			
		||||
}
 | 
			
		||||
//# sourceMappingURL=server.js.map
 | 
			
		||||
							
								
								
									
										31
									
								
								node_modules/@grpc/grpc-js/build/src/service-config.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								node_modules/@grpc/grpc-js/build/src/service-config.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
import * as lbconfig from './load-balancing-config';
 | 
			
		||||
export interface MethodConfigName {
 | 
			
		||||
    service: string;
 | 
			
		||||
    method?: string;
 | 
			
		||||
}
 | 
			
		||||
export interface MethodConfig {
 | 
			
		||||
    name: MethodConfigName[];
 | 
			
		||||
    waitForReady?: boolean;
 | 
			
		||||
    timeout?: string;
 | 
			
		||||
    maxRequestBytes?: number;
 | 
			
		||||
    maxResponseBytes?: number;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceConfig {
 | 
			
		||||
    loadBalancingPolicy?: string;
 | 
			
		||||
    loadBalancingConfig: lbconfig.LoadBalancingConfig[];
 | 
			
		||||
    methodConfig: MethodConfig[];
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceConfigCanaryConfig {
 | 
			
		||||
    clientLanguage?: string[];
 | 
			
		||||
    percentage?: number;
 | 
			
		||||
    clientHostname?: string[];
 | 
			
		||||
    serviceConfig: ServiceConfig;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Find the "grpc_config" record among the TXT records, parse its value as JSON, validate its contents,
 | 
			
		||||
 * and select a service config with selection fields that all match this client. Most of these steps
 | 
			
		||||
 * can fail with an error; the caller must handle any errors thrown this way.
 | 
			
		||||
 * @param txtRecord The TXT record array that is output from a successful call to dns.resolveTxt
 | 
			
		||||
 * @param percentage A number chosen from the range [0, 100) that is used to select which config to use
 | 
			
		||||
 */
 | 
			
		||||
export declare function extractAndSelectServiceConfig(txtRecord: string[][], percentage: number): ServiceConfig | null;
 | 
			
		||||
							
								
								
									
										235
									
								
								node_modules/@grpc/grpc-js/build/src/service-config.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										235
									
								
								node_modules/@grpc/grpc-js/build/src/service-config.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,235 @@
 | 
			
		||||
"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 file implements gRFC A2 and the service config spec:
 | 
			
		||||
 * https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md
 | 
			
		||||
 * https://github.com/grpc/grpc/blob/master/doc/service_config.md */
 | 
			
		||||
const lbconfig = require("./load-balancing-config");
 | 
			
		||||
const util_1 = require("util");
 | 
			
		||||
const os = require("os");
 | 
			
		||||
const TIMEOUT_REGEX = /^\d+(\.\d{1,9})?s$/;
 | 
			
		||||
const CLIENT_LANGUAGE_STRING = 'node';
 | 
			
		||||
function validateName(obj) {
 | 
			
		||||
    if (!('service' in obj) || !util_1.isString(obj.service)) {
 | 
			
		||||
        throw new Error('Invalid method config name: invalid service');
 | 
			
		||||
    }
 | 
			
		||||
    const result = {
 | 
			
		||||
        service: obj.service
 | 
			
		||||
    };
 | 
			
		||||
    if ('method' in obj) {
 | 
			
		||||
        if (util_1.isString(obj.method)) {
 | 
			
		||||
            result.method = obj.method;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throw new Error('Invalid method config name: invalid method');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
function validateMethodConfig(obj) {
 | 
			
		||||
    const result = {
 | 
			
		||||
        name: []
 | 
			
		||||
    };
 | 
			
		||||
    if (!('name' in obj) || !util_1.isArray(obj.name)) {
 | 
			
		||||
        throw new Error('Invalid method config: invalid name array');
 | 
			
		||||
    }
 | 
			
		||||
    for (const name of obj.name) {
 | 
			
		||||
        result.name.push(validateName(name));
 | 
			
		||||
    }
 | 
			
		||||
    if ('waitForReady' in obj) {
 | 
			
		||||
        if (!util_1.isBoolean(obj.waitForReady)) {
 | 
			
		||||
            throw new Error('Invalid method config: invalid waitForReady');
 | 
			
		||||
        }
 | 
			
		||||
        result.waitForReady = obj.waitForReady;
 | 
			
		||||
    }
 | 
			
		||||
    if ('timeout' in obj) {
 | 
			
		||||
        if (!util_1.isString(obj.timeout) || !TIMEOUT_REGEX.test(obj.timeout)) {
 | 
			
		||||
            throw new Error('Invalid method config: invalid timeout');
 | 
			
		||||
        }
 | 
			
		||||
        result.timeout = obj.timeout;
 | 
			
		||||
    }
 | 
			
		||||
    if ('maxRequestBytes' in obj) {
 | 
			
		||||
        if (!util_1.isNumber(obj.maxRequestBytes)) {
 | 
			
		||||
            throw new Error('Invalid method config: invalid maxRequestBytes');
 | 
			
		||||
        }
 | 
			
		||||
        result.maxRequestBytes = obj.maxRequestBytes;
 | 
			
		||||
    }
 | 
			
		||||
    if ('maxResponseBytes' in obj) {
 | 
			
		||||
        if (!util_1.isNumber(obj.maxResponseBytes)) {
 | 
			
		||||
            throw new Error('Invalid method config: invalid maxRequestBytes');
 | 
			
		||||
        }
 | 
			
		||||
        result.maxResponseBytes = obj.maxResponseBytes;
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
function validateServiceConfig(obj) {
 | 
			
		||||
    const result = {
 | 
			
		||||
        loadBalancingConfig: [],
 | 
			
		||||
        methodConfig: []
 | 
			
		||||
    };
 | 
			
		||||
    if ('loadBalancingPolicy' in obj) {
 | 
			
		||||
        if (util_1.isString(obj.loadBalancingPolicy)) {
 | 
			
		||||
            result.loadBalancingPolicy = obj.loadBalancingPolicy;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throw new Error('Invalid service config: invalid loadBalancingPolicy');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ('loadBalancingConfig' in obj) {
 | 
			
		||||
        if (util_1.isArray(obj.loadBalancingConfig)) {
 | 
			
		||||
            for (const config of obj.loadBalancingConfig) {
 | 
			
		||||
                result.loadBalancingConfig.push(lbconfig.validateConfig(config));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throw new Error('Invalid service config: invalid loadBalancingConfig');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ('methodConfig' in obj) {
 | 
			
		||||
        if (util_1.isArray(obj.methodConfig)) {
 | 
			
		||||
            for (const methodConfig of obj.methodConfig) {
 | 
			
		||||
                result.methodConfig.push(validateMethodConfig(methodConfig));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // Validate method name uniqueness
 | 
			
		||||
    const seenMethodNames = [];
 | 
			
		||||
    for (const methodConfig of result.methodConfig) {
 | 
			
		||||
        for (const name of methodConfig.name) {
 | 
			
		||||
            for (const seenName of seenMethodNames) {
 | 
			
		||||
                if (name.service === seenName.service && name.method === seenName.method) {
 | 
			
		||||
                    throw new Error(`Invalid service config: duplicate name ${name.service}/${name.method}`);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            seenMethodNames.push(name);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
function validateCanaryConfig(obj) {
 | 
			
		||||
    if (!('serviceConfig' in obj)) {
 | 
			
		||||
        throw new Error('Invalid service config choice: missing service config');
 | 
			
		||||
    }
 | 
			
		||||
    const result = {
 | 
			
		||||
        serviceConfig: validateServiceConfig(obj.serviceConfig)
 | 
			
		||||
    };
 | 
			
		||||
    if ('clientLanguage' in obj) {
 | 
			
		||||
        if (util_1.isArray(obj.clientLanguage)) {
 | 
			
		||||
            result.clientLanguage = [];
 | 
			
		||||
            for (const lang of obj.clientLanguage) {
 | 
			
		||||
                if (util_1.isString(lang)) {
 | 
			
		||||
                    result.clientLanguage.push(lang);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    throw new Error('Invalid service config choice: invalid clientLanguage');
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throw new Error('Invalid service config choice: invalid clientLanguage');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ('clientHostname' in obj) {
 | 
			
		||||
        if (util_1.isArray(obj.clientHostname)) {
 | 
			
		||||
            result.clientHostname = [];
 | 
			
		||||
            for (const lang of obj.clientHostname) {
 | 
			
		||||
                if (util_1.isString(lang)) {
 | 
			
		||||
                    result.clientHostname.push(lang);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    throw new Error('Invalid service config choice: invalid clientHostname');
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throw new Error('Invalid service config choice: invalid clientHostname');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if ('percentage' in obj) {
 | 
			
		||||
        if (util_1.isNumber(obj.percentage) && 0 <= obj.percentage && obj.percentage <= 100) {
 | 
			
		||||
            result.percentage = obj.percentage;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throw new Error('Invalid service config choice: invalid percentage');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // Validate that no unexpected fields are present
 | 
			
		||||
    const allowedFields = ['clientLanguage', 'percentage', 'clientHostname', 'serviceConfig'];
 | 
			
		||||
    for (const field in obj) {
 | 
			
		||||
        if (!allowedFields.includes(field)) {
 | 
			
		||||
            throw new Error(`Invalid service config choice: unexpected field ${field}`);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
function validateAndSelectCanaryConfig(obj, percentage) {
 | 
			
		||||
    if (!util_1.isArray(obj)) {
 | 
			
		||||
        throw new Error('Invalid service config list');
 | 
			
		||||
    }
 | 
			
		||||
    for (const config of obj) {
 | 
			
		||||
        const validatedConfig = validateCanaryConfig(config);
 | 
			
		||||
        /* For each field, we check if it is present, then only discard the
 | 
			
		||||
         * config if the field value does not match the current client */
 | 
			
		||||
        if (util_1.isNumber(validatedConfig.percentage) && percentage > validatedConfig.percentage) {
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        if (util_1.isArray(validatedConfig.clientHostname)) {
 | 
			
		||||
            let hostnameMatched = false;
 | 
			
		||||
            for (const hostname of validatedConfig.clientHostname) {
 | 
			
		||||
                if (hostname === os.hostname()) {
 | 
			
		||||
                    hostnameMatched = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (!hostnameMatched) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (util_1.isArray(validatedConfig.clientLanguage)) {
 | 
			
		||||
            let languageMatched = false;
 | 
			
		||||
            for (const language of validatedConfig.clientLanguage) {
 | 
			
		||||
                if (language === CLIENT_LANGUAGE_STRING) {
 | 
			
		||||
                    languageMatched = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (!languageMatched) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return validatedConfig.serviceConfig;
 | 
			
		||||
    }
 | 
			
		||||
    throw new Error('No matching service config found');
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Find the "grpc_config" record among the TXT records, parse its value as JSON, validate its contents,
 | 
			
		||||
 * and select a service config with selection fields that all match this client. Most of these steps
 | 
			
		||||
 * can fail with an error; the caller must handle any errors thrown this way.
 | 
			
		||||
 * @param txtRecord The TXT record array that is output from a successful call to dns.resolveTxt
 | 
			
		||||
 * @param percentage A number chosen from the range [0, 100) that is used to select which config to use
 | 
			
		||||
 */
 | 
			
		||||
function extractAndSelectServiceConfig(txtRecord, percentage) {
 | 
			
		||||
    for (const record of txtRecord) {
 | 
			
		||||
        if (record.length > 0 && record[0].startsWith('grpc_config=')) {
 | 
			
		||||
            const recordString = [record[0].substring('grpc_config='.length)].concat(record.slice(1)).join('');
 | 
			
		||||
            const recordJson = JSON.parse(recordString);
 | 
			
		||||
            return validateAndSelectCanaryConfig(recordJson, percentage);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return null;
 | 
			
		||||
}
 | 
			
		||||
exports.extractAndSelectServiceConfig = extractAndSelectServiceConfig;
 | 
			
		||||
//# sourceMappingURL=service-config.js.map
 | 
			
		||||
							
								
								
									
										28
									
								
								node_modules/@grpc/grpc-js/build/src/status-builder.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								node_modules/@grpc/grpc-js/build/src/status-builder.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
import { StatusObject } from './call-stream';
 | 
			
		||||
import { Status } from './constants';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
/**
 | 
			
		||||
 * A builder for gRPC status objects.
 | 
			
		||||
 */
 | 
			
		||||
export declare class StatusBuilder {
 | 
			
		||||
    private code;
 | 
			
		||||
    private details;
 | 
			
		||||
    private metadata;
 | 
			
		||||
    constructor();
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds a status code to the builder.
 | 
			
		||||
     */
 | 
			
		||||
    withCode(code: Status): this;
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds details to the builder.
 | 
			
		||||
     */
 | 
			
		||||
    withDetails(details: string): this;
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds metadata to the builder.
 | 
			
		||||
     */
 | 
			
		||||
    withMetadata(metadata: Metadata): this;
 | 
			
		||||
    /**
 | 
			
		||||
     * Builds the status object.
 | 
			
		||||
     */
 | 
			
		||||
    build(): Partial<StatusObject>;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										67
									
								
								node_modules/@grpc/grpc-js/build/src/status-builder.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								node_modules/@grpc/grpc-js/build/src/status-builder.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
			
		||||
"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.
 | 
			
		||||
 */
 | 
			
		||||
class StatusBuilder {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.code = null;
 | 
			
		||||
        this.details = null;
 | 
			
		||||
        this.metadata = null;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds a status code to the builder.
 | 
			
		||||
     */
 | 
			
		||||
    withCode(code) {
 | 
			
		||||
        this.code = code;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds details to the builder.
 | 
			
		||||
     */
 | 
			
		||||
    withDetails(details) {
 | 
			
		||||
        this.details = details;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds metadata to the builder.
 | 
			
		||||
     */
 | 
			
		||||
    withMetadata(metadata) {
 | 
			
		||||
        this.metadata = metadata;
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Builds the status object.
 | 
			
		||||
     */
 | 
			
		||||
    build() {
 | 
			
		||||
        const status = {};
 | 
			
		||||
        if (this.code !== null) {
 | 
			
		||||
            status.code = this.code;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.details !== null) {
 | 
			
		||||
            status.details = this.details;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.metadata !== null) {
 | 
			
		||||
            status.metadata = this.metadata;
 | 
			
		||||
        }
 | 
			
		||||
        return status;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.StatusBuilder = StatusBuilder;
 | 
			
		||||
//# sourceMappingURL=status-builder.js.map
 | 
			
		||||
							
								
								
									
										11
									
								
								node_modules/@grpc/grpc-js/build/src/stream-decoder.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								node_modules/@grpc/grpc-js/build/src/stream-decoder.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
export declare class StreamDecoder {
 | 
			
		||||
    private readState;
 | 
			
		||||
    private readCompressFlag;
 | 
			
		||||
    private readPartialSize;
 | 
			
		||||
    private readSizeRemaining;
 | 
			
		||||
    private readMessageSize;
 | 
			
		||||
    private readPartialMessage;
 | 
			
		||||
    private readMessageRemaining;
 | 
			
		||||
    write(data: Buffer): Buffer[];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										95
									
								
								node_modules/@grpc/grpc-js/build/src/stream-decoder.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								node_modules/@grpc/grpc-js/build/src/stream-decoder.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
			
		||||
"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 ReadState;
 | 
			
		||||
(function (ReadState) {
 | 
			
		||||
    ReadState[ReadState["NO_DATA"] = 0] = "NO_DATA";
 | 
			
		||||
    ReadState[ReadState["READING_SIZE"] = 1] = "READING_SIZE";
 | 
			
		||||
    ReadState[ReadState["READING_MESSAGE"] = 2] = "READING_MESSAGE";
 | 
			
		||||
})(ReadState || (ReadState = {}));
 | 
			
		||||
class StreamDecoder {
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.readState = ReadState.NO_DATA;
 | 
			
		||||
        this.readCompressFlag = Buffer.alloc(1);
 | 
			
		||||
        this.readPartialSize = Buffer.alloc(4);
 | 
			
		||||
        this.readSizeRemaining = 4;
 | 
			
		||||
        this.readMessageSize = 0;
 | 
			
		||||
        this.readPartialMessage = [];
 | 
			
		||||
        this.readMessageRemaining = 0;
 | 
			
		||||
    }
 | 
			
		||||
    write(data) {
 | 
			
		||||
        let readHead = 0;
 | 
			
		||||
        let toRead;
 | 
			
		||||
        const result = [];
 | 
			
		||||
        while (readHead < data.length) {
 | 
			
		||||
            switch (this.readState) {
 | 
			
		||||
                case ReadState.NO_DATA:
 | 
			
		||||
                    this.readCompressFlag = data.slice(readHead, readHead + 1);
 | 
			
		||||
                    readHead += 1;
 | 
			
		||||
                    this.readState = ReadState.READING_SIZE;
 | 
			
		||||
                    this.readPartialSize.fill(0);
 | 
			
		||||
                    this.readSizeRemaining = 4;
 | 
			
		||||
                    this.readMessageSize = 0;
 | 
			
		||||
                    this.readMessageRemaining = 0;
 | 
			
		||||
                    this.readPartialMessage = [];
 | 
			
		||||
                    break;
 | 
			
		||||
                case ReadState.READING_SIZE:
 | 
			
		||||
                    toRead = Math.min(data.length - readHead, this.readSizeRemaining);
 | 
			
		||||
                    data.copy(this.readPartialSize, 4 - this.readSizeRemaining, readHead, readHead + toRead);
 | 
			
		||||
                    this.readSizeRemaining -= toRead;
 | 
			
		||||
                    readHead += toRead;
 | 
			
		||||
                    // readSizeRemaining >=0 here
 | 
			
		||||
                    if (this.readSizeRemaining === 0) {
 | 
			
		||||
                        this.readMessageSize = this.readPartialSize.readUInt32BE(0);
 | 
			
		||||
                        this.readMessageRemaining = this.readMessageSize;
 | 
			
		||||
                        if (this.readMessageRemaining > 0) {
 | 
			
		||||
                            this.readState = ReadState.READING_MESSAGE;
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            const message = Buffer.concat([this.readCompressFlag, this.readPartialSize], 5);
 | 
			
		||||
                            this.readState = ReadState.NO_DATA;
 | 
			
		||||
                            result.push(message);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                case ReadState.READING_MESSAGE:
 | 
			
		||||
                    toRead = Math.min(data.length - readHead, this.readMessageRemaining);
 | 
			
		||||
                    this.readPartialMessage.push(data.slice(readHead, readHead + toRead));
 | 
			
		||||
                    this.readMessageRemaining -= toRead;
 | 
			
		||||
                    readHead += toRead;
 | 
			
		||||
                    // readMessageRemaining >=0 here
 | 
			
		||||
                    if (this.readMessageRemaining === 0) {
 | 
			
		||||
                        // At this point, we have read a full message
 | 
			
		||||
                        const framedMessageBuffers = [
 | 
			
		||||
                            this.readCompressFlag,
 | 
			
		||||
                            this.readPartialSize,
 | 
			
		||||
                        ].concat(this.readPartialMessage);
 | 
			
		||||
                        const framedMessage = Buffer.concat(framedMessageBuffers, this.readMessageSize + 5);
 | 
			
		||||
                        this.readState = ReadState.NO_DATA;
 | 
			
		||||
                        result.push(framedMessage);
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    throw new Error('Unexpected read state');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.StreamDecoder = StreamDecoder;
 | 
			
		||||
//# sourceMappingURL=stream-decoder.js.map
 | 
			
		||||
							
								
								
									
										33
									
								
								node_modules/@grpc/grpc-js/build/src/subchannel.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								node_modules/@grpc/grpc-js/build/src/subchannel.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import { EventEmitter } from 'events';
 | 
			
		||||
import * as http2 from 'http2';
 | 
			
		||||
import * as url from 'url';
 | 
			
		||||
import { Call, Http2CallStream } from './call-stream';
 | 
			
		||||
import { ChannelOptions } from './channel-options';
 | 
			
		||||
import { Metadata } from './metadata';
 | 
			
		||||
export interface SubChannel extends EventEmitter {
 | 
			
		||||
    /**
 | 
			
		||||
     * Attach a call stream to this subchannel's connection to start it
 | 
			
		||||
     * @param headers The headers to start the stream with
 | 
			
		||||
     * @param callStream The stream to start
 | 
			
		||||
     */
 | 
			
		||||
    startCallStream(metadata: Metadata, callStream: Call): void;
 | 
			
		||||
    close(): void;
 | 
			
		||||
}
 | 
			
		||||
export declare class Http2SubChannel extends EventEmitter implements SubChannel {
 | 
			
		||||
    private session;
 | 
			
		||||
    private refCount;
 | 
			
		||||
    private userAgent;
 | 
			
		||||
    private keepaliveTimeMs;
 | 
			
		||||
    private keepaliveTimeoutMs;
 | 
			
		||||
    private keepaliveIntervalId;
 | 
			
		||||
    private keepaliveTimeoutId;
 | 
			
		||||
    constructor(target: url.URL, connectionOptions: http2.SecureClientSessionOptions, userAgent: string, channelArgs: Partial<ChannelOptions>);
 | 
			
		||||
    private ref;
 | 
			
		||||
    private unref;
 | 
			
		||||
    private sendPing;
 | 
			
		||||
    private startKeepalivePings;
 | 
			
		||||
    private stopKeepalivePings;
 | 
			
		||||
    startCallStream(metadata: Metadata, callStream: Http2CallStream): void;
 | 
			
		||||
    close(): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										117
									
								
								node_modules/@grpc/grpc-js/build/src/subchannel.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								node_modules/@grpc/grpc-js/build/src/subchannel.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,117 @@
 | 
			
		||||
"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");
 | 
			
		||||
const { HTTP2_HEADER_AUTHORITY, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_TE, HTTP2_HEADER_USER_AGENT, } = http2.constants;
 | 
			
		||||
/* setInterval and setTimeout only accept signed 32 bit integers. JS doesn't
 | 
			
		||||
 * have a constant for the max signed 32 bit integer, so this is a simple way
 | 
			
		||||
 * to calculate it */
 | 
			
		||||
const KEEPALIVE_TIME_MS = ~(1 << 31);
 | 
			
		||||
const KEEPALIVE_TIMEOUT_MS = 20000;
 | 
			
		||||
class Http2SubChannel extends events_1.EventEmitter {
 | 
			
		||||
    constructor(target, connectionOptions, userAgent, channelArgs) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.refCount = 0;
 | 
			
		||||
        this.keepaliveTimeMs = KEEPALIVE_TIME_MS;
 | 
			
		||||
        this.keepaliveTimeoutMs = KEEPALIVE_TIMEOUT_MS;
 | 
			
		||||
        this.session = http2.connect(target, connectionOptions);
 | 
			
		||||
        this.session.unref();
 | 
			
		||||
        this.session.on('connect', () => {
 | 
			
		||||
            this.emit('connect');
 | 
			
		||||
        });
 | 
			
		||||
        this.session.on('close', () => {
 | 
			
		||||
            this.stopKeepalivePings();
 | 
			
		||||
            this.emit('close');
 | 
			
		||||
        });
 | 
			
		||||
        this.session.on('error', () => {
 | 
			
		||||
            this.stopKeepalivePings();
 | 
			
		||||
            this.emit('close');
 | 
			
		||||
        });
 | 
			
		||||
        this.session.on('goaway', () => {
 | 
			
		||||
            this.stopKeepalivePings();
 | 
			
		||||
            this.emit('close');
 | 
			
		||||
        });
 | 
			
		||||
        this.userAgent = userAgent;
 | 
			
		||||
        if (channelArgs['grpc.keepalive_time_ms']) {
 | 
			
		||||
            this.keepaliveTimeMs = channelArgs['grpc.keepalive_time_ms'];
 | 
			
		||||
        }
 | 
			
		||||
        if (channelArgs['grpc.keepalive_timeout_ms']) {
 | 
			
		||||
            this.keepaliveTimeoutMs = channelArgs['grpc.keepalive_timeout_ms'];
 | 
			
		||||
        }
 | 
			
		||||
        this.keepaliveIntervalId = setTimeout(() => { }, 0);
 | 
			
		||||
        clearTimeout(this.keepaliveIntervalId);
 | 
			
		||||
        this.keepaliveTimeoutId = setTimeout(() => { }, 0);
 | 
			
		||||
        clearTimeout(this.keepaliveTimeoutId);
 | 
			
		||||
    }
 | 
			
		||||
    ref() {
 | 
			
		||||
        if (this.refCount === 0) {
 | 
			
		||||
            this.session.ref();
 | 
			
		||||
            this.startKeepalivePings();
 | 
			
		||||
        }
 | 
			
		||||
        this.refCount += 1;
 | 
			
		||||
    }
 | 
			
		||||
    unref() {
 | 
			
		||||
        this.refCount -= 1;
 | 
			
		||||
        if (this.refCount === 0) {
 | 
			
		||||
            this.session.unref();
 | 
			
		||||
            this.stopKeepalivePings();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    sendPing() {
 | 
			
		||||
        this.keepaliveTimeoutId = setTimeout(() => {
 | 
			
		||||
            this.emit('close');
 | 
			
		||||
        }, this.keepaliveTimeoutMs);
 | 
			
		||||
        this.session.ping((err, duration, payload) => {
 | 
			
		||||
            clearTimeout(this.keepaliveTimeoutId);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /* TODO(murgatroid99): refactor subchannels so that keepalives can be handled
 | 
			
		||||
     * per subchannel */
 | 
			
		||||
    startKeepalivePings() {
 | 
			
		||||
        this.keepaliveIntervalId = setInterval(() => {
 | 
			
		||||
            this.sendPing();
 | 
			
		||||
        }, this.keepaliveTimeMs);
 | 
			
		||||
        this.sendPing();
 | 
			
		||||
    }
 | 
			
		||||
    stopKeepalivePings() {
 | 
			
		||||
        clearInterval(this.keepaliveIntervalId);
 | 
			
		||||
        clearTimeout(this.keepaliveTimeoutId);
 | 
			
		||||
    }
 | 
			
		||||
    // Prerequisite: this subchannel is connected
 | 
			
		||||
    startCallStream(metadata, callStream) {
 | 
			
		||||
        const headers = metadata.toHttp2Headers();
 | 
			
		||||
        headers[HTTP2_HEADER_AUTHORITY] = callStream.getHost();
 | 
			
		||||
        headers[HTTP2_HEADER_USER_AGENT] = this.userAgent;
 | 
			
		||||
        headers[HTTP2_HEADER_CONTENT_TYPE] = 'application/grpc';
 | 
			
		||||
        headers[HTTP2_HEADER_METHOD] = 'POST';
 | 
			
		||||
        headers[HTTP2_HEADER_PATH] = callStream.getMethod();
 | 
			
		||||
        headers[HTTP2_HEADER_TE] = 'trailers';
 | 
			
		||||
        const http2Stream = this.session.request(headers);
 | 
			
		||||
        this.ref();
 | 
			
		||||
        http2Stream.on('close', () => {
 | 
			
		||||
            this.unref();
 | 
			
		||||
        });
 | 
			
		||||
        callStream.attachHttp2Stream(http2Stream);
 | 
			
		||||
    }
 | 
			
		||||
    close() {
 | 
			
		||||
        this.session.close();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Http2SubChannel = Http2SubChannel;
 | 
			
		||||
//# sourceMappingURL=subchannel.js.map
 | 
			
		||||
							
								
								
									
										81
									
								
								node_modules/@grpc/grpc-js/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								node_modules/@grpc/grpc-js/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "@grpc/grpc-js@^0.5.2",
 | 
			
		||||
  "_id": "@grpc/grpc-js@0.5.2",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-NE1tP/1AF6BqhLdILElnF7aOBfoky+4ZOdZU/0NmKo2d+9F9QD8zGoElpBk/5BfyQZ3u1Zs+wFbDOFpVUzDx1w==",
 | 
			
		||||
  "_location": "/@grpc/grpc-js",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "@grpc/grpc-js@^0.5.2",
 | 
			
		||||
    "name": "@grpc/grpc-js",
 | 
			
		||||
    "escapedName": "@grpc%2fgrpc-js",
 | 
			
		||||
    "scope": "@grpc",
 | 
			
		||||
    "rawSpec": "^0.5.2",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "^0.5.2"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/google-gax"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-0.5.2.tgz",
 | 
			
		||||
  "_shasum": "8e39876033749e1611fe9fa181d9535077805abe",
 | 
			
		||||
  "_spec": "@grpc/grpc-js@^0.5.2",
 | 
			
		||||
  "_where": "C:\\Users\\matia\\Documents\\GitHub\\FutoX-Musix\\node_modules\\google-gax",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Google Inc."
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "contributors": [
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Google Inc."
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "semver": "^6.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "gRPC Library for Node - pure JS implementation",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@grpc/proto-loader": "^0.5.0",
 | 
			
		||||
    "@types/lodash": "^4.14.108",
 | 
			
		||||
    "@types/mocha": "^5.2.6",
 | 
			
		||||
    "@types/node": "^12.0.2",
 | 
			
		||||
    "clang-format": "^1.0.55",
 | 
			
		||||
    "gts": "^1.0.0",
 | 
			
		||||
    "lodash": "^4.17.4",
 | 
			
		||||
    "typescript": "~3.5.1"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": "^8.13.0 || >=10.10.0"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "build/src/*.{js,d.ts}",
 | 
			
		||||
    "LICENSE"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://grpc.io/",
 | 
			
		||||
  "keywords": [],
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "main": "build/src/index.js",
 | 
			
		||||
  "name": "@grpc/grpc-js",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "npm run compile",
 | 
			
		||||
    "check": "gts check",
 | 
			
		||||
    "clean": "gts clean",
 | 
			
		||||
    "compile": "tsc -p .",
 | 
			
		||||
    "fix": "gts fix",
 | 
			
		||||
    "format": "clang-format -i -style=\"{Language: JavaScript, BasedOnStyle: Google, ColumnLimit: 80}\" src/*.ts test/*.ts",
 | 
			
		||||
    "lint": "tslint -c node_modules/google-ts-style/tslint.json -p . -t codeFrame --type-check",
 | 
			
		||||
    "posttest": "npm run check",
 | 
			
		||||
    "prepare": "npm run compile",
 | 
			
		||||
    "pretest": "npm run compile",
 | 
			
		||||
    "test": "gulp test"
 | 
			
		||||
  },
 | 
			
		||||
  "types": "build/src/index.d.ts",
 | 
			
		||||
  "version": "0.5.2"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										201
									
								
								node_modules/@grpc/proto-loader/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										201
									
								
								node_modules/@grpc/proto-loader/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,201 @@
 | 
			
		||||
                                 Apache License
 | 
			
		||||
                           Version 2.0, January 2004
 | 
			
		||||
                        http://www.apache.org/licenses/
 | 
			
		||||
 | 
			
		||||
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 | 
			
		||||
 | 
			
		||||
   1. Definitions.
 | 
			
		||||
 | 
			
		||||
      "License" shall mean the terms and conditions for use, reproduction,
 | 
			
		||||
      and distribution as defined by Sections 1 through 9 of this document.
 | 
			
		||||
 | 
			
		||||
      "Licensor" shall mean the copyright owner or entity authorized by
 | 
			
		||||
      the copyright owner that is granting the License.
 | 
			
		||||
 | 
			
		||||
      "Legal Entity" shall mean the union of the acting entity and all
 | 
			
		||||
      other entities that control, are controlled by, or are under common
 | 
			
		||||
      control with that entity. For the purposes of this definition,
 | 
			
		||||
      "control" means (i) the power, direct or indirect, to cause the
 | 
			
		||||
      direction or management of such entity, whether by contract or
 | 
			
		||||
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
 | 
			
		||||
      outstanding shares, or (iii) beneficial ownership of such entity.
 | 
			
		||||
 | 
			
		||||
      "You" (or "Your") shall mean an individual or Legal Entity
 | 
			
		||||
      exercising permissions granted by this License.
 | 
			
		||||
 | 
			
		||||
      "Source" form shall mean the preferred form for making modifications,
 | 
			
		||||
      including but not limited to software source code, documentation
 | 
			
		||||
      source, and configuration files.
 | 
			
		||||
 | 
			
		||||
      "Object" form shall mean any form resulting from mechanical
 | 
			
		||||
      transformation or translation of a Source form, including but
 | 
			
		||||
      not limited to compiled object code, generated documentation,
 | 
			
		||||
      and conversions to other media types.
 | 
			
		||||
 | 
			
		||||
      "Work" shall mean the work of authorship, whether in Source or
 | 
			
		||||
      Object form, made available under the License, as indicated by a
 | 
			
		||||
      copyright notice that is included in or attached to the work
 | 
			
		||||
      (an example is provided in the Appendix below).
 | 
			
		||||
 | 
			
		||||
      "Derivative Works" shall mean any work, whether in Source or Object
 | 
			
		||||
      form, that is based on (or derived from) the Work and for which the
 | 
			
		||||
      editorial revisions, annotations, elaborations, or other modifications
 | 
			
		||||
      represent, as a whole, an original work of authorship. For the purposes
 | 
			
		||||
      of this License, Derivative Works shall not include works that remain
 | 
			
		||||
      separable from, or merely link (or bind by name) to the interfaces of,
 | 
			
		||||
      the Work and Derivative Works thereof.
 | 
			
		||||
 | 
			
		||||
      "Contribution" shall mean any work of authorship, including
 | 
			
		||||
      the original version of the Work and any modifications or additions
 | 
			
		||||
      to that Work or Derivative Works thereof, that is intentionally
 | 
			
		||||
      submitted to Licensor for inclusion in the Work by the copyright owner
 | 
			
		||||
      or by an individual or Legal Entity authorized to submit on behalf of
 | 
			
		||||
      the copyright owner. For the purposes of this definition, "submitted"
 | 
			
		||||
      means any form of electronic, verbal, or written communication sent
 | 
			
		||||
      to the Licensor or its representatives, including but not limited to
 | 
			
		||||
      communication on electronic mailing lists, source code control systems,
 | 
			
		||||
      and issue tracking systems that are managed by, or on behalf of, the
 | 
			
		||||
      Licensor for the purpose of discussing and improving the Work, but
 | 
			
		||||
      excluding communication that is conspicuously marked or otherwise
 | 
			
		||||
      designated in writing by the copyright owner as "Not a Contribution."
 | 
			
		||||
 | 
			
		||||
      "Contributor" shall mean Licensor and any individual or Legal Entity
 | 
			
		||||
      on behalf of whom a Contribution has been received by Licensor and
 | 
			
		||||
      subsequently incorporated within the Work.
 | 
			
		||||
 | 
			
		||||
   2. Grant of Copyright License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      copyright license to reproduce, prepare Derivative Works of,
 | 
			
		||||
      publicly display, publicly perform, sublicense, and distribute the
 | 
			
		||||
      Work and such Derivative Works in Source or Object form.
 | 
			
		||||
 | 
			
		||||
   3. Grant of Patent License. Subject to the terms and conditions of
 | 
			
		||||
      this License, each Contributor hereby grants to You a perpetual,
 | 
			
		||||
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
 | 
			
		||||
      (except as stated in this section) patent license to make, have made,
 | 
			
		||||
      use, offer to sell, sell, import, and otherwise transfer the Work,
 | 
			
		||||
      where such license applies only to those patent claims licensable
 | 
			
		||||
      by such Contributor that are necessarily infringed by their
 | 
			
		||||
      Contribution(s) alone or by combination of their Contribution(s)
 | 
			
		||||
      with the Work to which such Contribution(s) was submitted. If You
 | 
			
		||||
      institute patent litigation against any entity (including a
 | 
			
		||||
      cross-claim or counterclaim in a lawsuit) alleging that the Work
 | 
			
		||||
      or a Contribution incorporated within the Work constitutes direct
 | 
			
		||||
      or contributory patent infringement, then any patent licenses
 | 
			
		||||
      granted to You under this License for that Work shall terminate
 | 
			
		||||
      as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
   4. Redistribution. You may reproduce and distribute copies of the
 | 
			
		||||
      Work or Derivative Works thereof in any medium, with or without
 | 
			
		||||
      modifications, and in Source or Object form, provided that You
 | 
			
		||||
      meet the following conditions:
 | 
			
		||||
 | 
			
		||||
      (a) You must give any other recipients of the Work or
 | 
			
		||||
          Derivative Works a copy of this License; and
 | 
			
		||||
 | 
			
		||||
      (b) You must cause any modified files to carry prominent notices
 | 
			
		||||
          stating that You changed the files; and
 | 
			
		||||
 | 
			
		||||
      (c) You must retain, in the Source form of any Derivative Works
 | 
			
		||||
          that You distribute, all copyright, patent, trademark, and
 | 
			
		||||
          attribution notices from the Source form of the Work,
 | 
			
		||||
          excluding those notices that do not pertain to any part of
 | 
			
		||||
          the Derivative Works; and
 | 
			
		||||
 | 
			
		||||
      (d) If the Work includes a "NOTICE" text file as part of its
 | 
			
		||||
          distribution, then any Derivative Works that You distribute must
 | 
			
		||||
          include a readable copy of the attribution notices contained
 | 
			
		||||
          within such NOTICE file, excluding those notices that do not
 | 
			
		||||
          pertain to any part of the Derivative Works, in at least one
 | 
			
		||||
          of the following places: within a NOTICE text file distributed
 | 
			
		||||
          as part of the Derivative Works; within the Source form or
 | 
			
		||||
          documentation, if provided along with the Derivative Works; or,
 | 
			
		||||
          within a display generated by the Derivative Works, if and
 | 
			
		||||
          wherever such third-party notices normally appear. The contents
 | 
			
		||||
          of the NOTICE file are for informational purposes only and
 | 
			
		||||
          do not modify the License. You may add Your own attribution
 | 
			
		||||
          notices within Derivative Works that You distribute, alongside
 | 
			
		||||
          or as an addendum to the NOTICE text from the Work, provided
 | 
			
		||||
          that such additional attribution notices cannot be construed
 | 
			
		||||
          as modifying the License.
 | 
			
		||||
 | 
			
		||||
      You may add Your own copyright statement to Your modifications and
 | 
			
		||||
      may provide additional or different license terms and conditions
 | 
			
		||||
      for use, reproduction, or distribution of Your modifications, or
 | 
			
		||||
      for any such Derivative Works as a whole, provided Your use,
 | 
			
		||||
      reproduction, and distribution of the Work otherwise complies with
 | 
			
		||||
      the conditions stated in this License.
 | 
			
		||||
 | 
			
		||||
   5. Submission of Contributions. Unless You explicitly state otherwise,
 | 
			
		||||
      any Contribution intentionally submitted for inclusion in the Work
 | 
			
		||||
      by You to the Licensor shall be under the terms and conditions of
 | 
			
		||||
      this License, without any additional terms or conditions.
 | 
			
		||||
      Notwithstanding the above, nothing herein shall supersede or modify
 | 
			
		||||
      the terms of any separate license agreement you may have executed
 | 
			
		||||
      with Licensor regarding such Contributions.
 | 
			
		||||
 | 
			
		||||
   6. Trademarks. This License does not grant permission to use the trade
 | 
			
		||||
      names, trademarks, service marks, or product names of the Licensor,
 | 
			
		||||
      except as required for reasonable and customary use in describing the
 | 
			
		||||
      origin of the Work and reproducing the content of the NOTICE file.
 | 
			
		||||
 | 
			
		||||
   7. Disclaimer of Warranty. Unless required by applicable law or
 | 
			
		||||
      agreed to in writing, Licensor provides the Work (and each
 | 
			
		||||
      Contributor provides its Contributions) on an "AS IS" BASIS,
 | 
			
		||||
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 | 
			
		||||
      implied, including, without limitation, any warranties or conditions
 | 
			
		||||
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
 | 
			
		||||
      PARTICULAR PURPOSE. You are solely responsible for determining the
 | 
			
		||||
      appropriateness of using or redistributing the Work and assume any
 | 
			
		||||
      risks associated with Your exercise of permissions under this License.
 | 
			
		||||
 | 
			
		||||
   8. Limitation of Liability. In no event and under no legal theory,
 | 
			
		||||
      whether in tort (including negligence), contract, or otherwise,
 | 
			
		||||
      unless required by applicable law (such as deliberate and grossly
 | 
			
		||||
      negligent acts) or agreed to in writing, shall any Contributor be
 | 
			
		||||
      liable to You for damages, including any direct, indirect, special,
 | 
			
		||||
      incidental, or consequential damages of any character arising as a
 | 
			
		||||
      result of this License or out of the use or inability to use the
 | 
			
		||||
      Work (including but not limited to damages for loss of goodwill,
 | 
			
		||||
      work stoppage, computer failure or malfunction, or any and all
 | 
			
		||||
      other commercial damages or losses), even if such Contributor
 | 
			
		||||
      has been advised of the possibility of such damages.
 | 
			
		||||
 | 
			
		||||
   9. Accepting Warranty or Additional Liability. While redistributing
 | 
			
		||||
      the Work or Derivative Works thereof, You may choose to offer,
 | 
			
		||||
      and charge a fee for, acceptance of support, warranty, indemnity,
 | 
			
		||||
      or other liability obligations and/or rights consistent with this
 | 
			
		||||
      License. However, in accepting such obligations, You may act only
 | 
			
		||||
      on Your own behalf and on Your sole responsibility, not on behalf
 | 
			
		||||
      of any other Contributor, and only if You agree to indemnify,
 | 
			
		||||
      defend, and hold each Contributor harmless for any liability
 | 
			
		||||
      incurred by, or claims asserted against, such Contributor by reason
 | 
			
		||||
      of your accepting any such warranty or additional liability.
 | 
			
		||||
 | 
			
		||||
   END OF TERMS AND CONDITIONS
 | 
			
		||||
 | 
			
		||||
   APPENDIX: How to apply the Apache License to your work.
 | 
			
		||||
 | 
			
		||||
      To apply the Apache License to your work, attach the following
 | 
			
		||||
      boilerplate notice, with the fields enclosed by brackets "{}"
 | 
			
		||||
      replaced with your own identifying information. (Don't include
 | 
			
		||||
      the brackets!)  The text should be enclosed in the appropriate
 | 
			
		||||
      comment syntax for the file format. We also recommend that a
 | 
			
		||||
      file or class name and description of purpose be included on the
 | 
			
		||||
      same "printed page" as the copyright notice for easier
 | 
			
		||||
      identification within third-party archives.
 | 
			
		||||
 | 
			
		||||
   Copyright {yyyy} {name of copyright owner}
 | 
			
		||||
 | 
			
		||||
   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.
 | 
			
		||||
							
								
								
									
										53
									
								
								node_modules/@grpc/proto-loader/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								node_modules/@grpc/proto-loader/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
# gRPC Protobuf Loader
 | 
			
		||||
 | 
			
		||||
A utility package for loading `.proto` files for use with gRPC, using the latest Protobuf.js package.
 | 
			
		||||
Please refer to [protobuf.js' documentation](https://github.com/dcodeIO/protobuf.js/blob/master/README.md)
 | 
			
		||||
to understands its features and limitations.
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
npm install @grpc/proto-loader
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
const protoLoader = require('@grpc/proto-loader');
 | 
			
		||||
const grpcLibrary = require('grpc');
 | 
			
		||||
// OR
 | 
			
		||||
const grpcLibrary = require('@grpc/grpc-js');
 | 
			
		||||
 | 
			
		||||
protoLoader.load(protoFileName, options).then(packageDefinition => {
 | 
			
		||||
  const packageObject = grpcLibrary.loadPackageDefinition(packageDefinition);
 | 
			
		||||
});
 | 
			
		||||
// OR
 | 
			
		||||
const packageDefinition = protoLoader.loadSync(protoFileName, options);
 | 
			
		||||
const packageObject = grpcLibrary.loadPackageDefinition(packageDefinition);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
The options parameter is an object that can have the following optional properties:
 | 
			
		||||
 | 
			
		||||
| Field name | Valid values | Description
 | 
			
		||||
|------------|--------------|------------
 | 
			
		||||
| `keepCase` | `true` or `false` | Preserve field names. The default is to change them to camel case.
 | 
			
		||||
| `longs` | `String` or `Number` | The type to use to represent `long` values. Defaults to a `Long` object type.
 | 
			
		||||
| `enums` | `String` | The type to use to represent `enum` values. Defaults to the numeric value.
 | 
			
		||||
| `bytes` | `Array` or `String` | The type to use to represent `bytes` values. Defaults to `Buffer`.
 | 
			
		||||
| `defaults` | `true` or `false` | Set default values on output objects. Defaults to `false`.
 | 
			
		||||
| `arrays` | `true` or `false` | Set empty arrays for missing array values even if `defaults` is `false` Defaults to `false`.
 | 
			
		||||
| `objects` | `true` or `false` | Set empty objects for missing object values even if `defaults` is `false` Defaults to `false`.
 | 
			
		||||
| `oneofs` | `true` or `false` | Set virtual oneof properties to the present field's name. Defaults to `false`.
 | 
			
		||||
| `includeDirs` | An array of strings | A list of search paths for imported `.proto` files.
 | 
			
		||||
 | 
			
		||||
The following options object closely approximates the existing behavior of `grpc.load`:
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
const options = {
 | 
			
		||||
  keepCase: true,
 | 
			
		||||
  longs: String,
 | 
			
		||||
  enums: String,
 | 
			
		||||
  defaults: true,
 | 
			
		||||
  oneofs: true
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										79
									
								
								node_modules/@grpc/proto-loader/build/src/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								node_modules/@grpc/proto-loader/build/src/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
/// <reference types="node" />
 | 
			
		||||
import * as Protobuf from 'protobufjs';
 | 
			
		||||
import * as descriptor from 'protobufjs/ext/descriptor';
 | 
			
		||||
declare module 'protobufjs' {
 | 
			
		||||
    interface Type {
 | 
			
		||||
        toDescriptor(protoVersion: string): Protobuf.Message<descriptor.IDescriptorProto> & descriptor.IDescriptorProto;
 | 
			
		||||
    }
 | 
			
		||||
    interface Root {
 | 
			
		||||
        toDescriptor(protoVersion: string): Protobuf.Message<descriptor.IFileDescriptorSet> & descriptor.IFileDescriptorSet;
 | 
			
		||||
    }
 | 
			
		||||
    interface Enum {
 | 
			
		||||
        toDescriptor(protoVersion: string): Protobuf.Message<descriptor.IEnumDescriptorProto> & descriptor.IEnumDescriptorProto;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
export interface Serialize<T> {
 | 
			
		||||
    (value: T): Buffer;
 | 
			
		||||
}
 | 
			
		||||
export interface Deserialize<T> {
 | 
			
		||||
    (bytes: Buffer): T;
 | 
			
		||||
}
 | 
			
		||||
export interface ProtobufTypeDefinition {
 | 
			
		||||
    format: string;
 | 
			
		||||
    type: object;
 | 
			
		||||
    fileDescriptorProtos: Buffer[];
 | 
			
		||||
}
 | 
			
		||||
export interface MessageTypeDefinition extends ProtobufTypeDefinition {
 | 
			
		||||
    format: 'Protocol Buffer 3 DescriptorProto';
 | 
			
		||||
}
 | 
			
		||||
export interface EnumTypeDefinition extends ProtobufTypeDefinition {
 | 
			
		||||
    format: 'Protocol Buffer 3 EnumDescriptorProto';
 | 
			
		||||
}
 | 
			
		||||
export interface MethodDefinition<RequestType, ResponseType> {
 | 
			
		||||
    path: string;
 | 
			
		||||
    requestStream: boolean;
 | 
			
		||||
    responseStream: boolean;
 | 
			
		||||
    requestSerialize: Serialize<RequestType>;
 | 
			
		||||
    responseSerialize: Serialize<ResponseType>;
 | 
			
		||||
    requestDeserialize: Deserialize<RequestType>;
 | 
			
		||||
    responseDeserialize: Deserialize<ResponseType>;
 | 
			
		||||
    originalName?: string;
 | 
			
		||||
    requestType: MessageTypeDefinition;
 | 
			
		||||
    responseType: MessageTypeDefinition;
 | 
			
		||||
}
 | 
			
		||||
export interface ServiceDefinition {
 | 
			
		||||
    [index: string]: MethodDefinition<object, object>;
 | 
			
		||||
}
 | 
			
		||||
export declare type AnyDefinition = ServiceDefinition | MessageTypeDefinition | EnumTypeDefinition;
 | 
			
		||||
export interface PackageDefinition {
 | 
			
		||||
    [index: string]: AnyDefinition;
 | 
			
		||||
}
 | 
			
		||||
export declare type Options = Protobuf.IParseOptions & Protobuf.IConversionOptions & {
 | 
			
		||||
    includeDirs?: string[];
 | 
			
		||||
};
 | 
			
		||||
/**
 | 
			
		||||
 * Load a .proto file with the specified options.
 | 
			
		||||
 * @param filename One or multiple file paths to load. Can be an absolute path
 | 
			
		||||
 *     or relative to an include path.
 | 
			
		||||
 * @param options.keepCase Preserve field names. The default is to change them
 | 
			
		||||
 *     to camel case.
 | 
			
		||||
 * @param options.longs The type that should be used to represent `long` values.
 | 
			
		||||
 *     Valid options are `Number` and `String`. Defaults to a `Long` object type
 | 
			
		||||
 *     from a library.
 | 
			
		||||
 * @param options.enums The type that should be used to represent `enum` values.
 | 
			
		||||
 *     The only valid option is `String`. Defaults to the numeric value.
 | 
			
		||||
 * @param options.bytes The type that should be used to represent `bytes`
 | 
			
		||||
 *     values. Valid options are `Array` and `String`. The default is to use
 | 
			
		||||
 *     `Buffer`.
 | 
			
		||||
 * @param options.defaults Set default values on output objects. Defaults to
 | 
			
		||||
 *     `false`.
 | 
			
		||||
 * @param options.arrays Set empty arrays for missing array values even if
 | 
			
		||||
 *     `defaults` is `false`. Defaults to `false`.
 | 
			
		||||
 * @param options.objects Set empty objects for missing object values even if
 | 
			
		||||
 *     `defaults` is `false`. Defaults to `false`.
 | 
			
		||||
 * @param options.oneofs Set virtual oneof properties to the present field's
 | 
			
		||||
 *     name
 | 
			
		||||
 * @param options.includeDirs Paths to search for imported `.proto` files.
 | 
			
		||||
 */
 | 
			
		||||
export declare function load(filename: string | string[], options?: Options): Promise<PackageDefinition>;
 | 
			
		||||
export declare function loadSync(filename: string | string[], options?: Options): PackageDefinition;
 | 
			
		||||
							
								
								
									
										249
									
								
								node_modules/@grpc/proto-loader/build/src/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										249
									
								
								node_modules/@grpc/proto-loader/build/src/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,249 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/**
 | 
			
		||||
 * @license
 | 
			
		||||
 * Copyright 2018 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.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
var fs = require("fs");
 | 
			
		||||
var path = require("path");
 | 
			
		||||
var Protobuf = require("protobufjs");
 | 
			
		||||
var descriptor = require("protobufjs/ext/descriptor");
 | 
			
		||||
var camelCase = require("lodash.camelcase");
 | 
			
		||||
var descriptorOptions = {
 | 
			
		||||
    longs: String,
 | 
			
		||||
    enums: String,
 | 
			
		||||
    bytes: String,
 | 
			
		||||
    defaults: true,
 | 
			
		||||
    oneofs: true,
 | 
			
		||||
    json: true
 | 
			
		||||
};
 | 
			
		||||
function joinName(baseName, name) {
 | 
			
		||||
    if (baseName === '') {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        return baseName + '.' + name;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function isHandledReflectionObject(obj) {
 | 
			
		||||
    return obj instanceof Protobuf.Service || obj instanceof Protobuf.Type ||
 | 
			
		||||
        obj instanceof Protobuf.Enum;
 | 
			
		||||
}
 | 
			
		||||
function isNamespaceBase(obj) {
 | 
			
		||||
    return obj instanceof Protobuf.Namespace || obj instanceof Protobuf.Root;
 | 
			
		||||
}
 | 
			
		||||
function getAllHandledReflectionObjects(obj, parentName) {
 | 
			
		||||
    var objName = joinName(parentName, obj.name);
 | 
			
		||||
    if (isHandledReflectionObject(obj)) {
 | 
			
		||||
        return [[objName, obj]];
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        if (isNamespaceBase(obj) && typeof obj.nested !== 'undefined') {
 | 
			
		||||
            return Object.keys(obj.nested)
 | 
			
		||||
                .map(function (name) {
 | 
			
		||||
                return getAllHandledReflectionObjects(obj.nested[name], objName);
 | 
			
		||||
            })
 | 
			
		||||
                .reduce(function (accumulator, currentValue) { return accumulator.concat(currentValue); }, []);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return [];
 | 
			
		||||
}
 | 
			
		||||
function createDeserializer(cls, options) {
 | 
			
		||||
    return function deserialize(argBuf) {
 | 
			
		||||
        return cls.toObject(cls.decode(argBuf), options);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
function createSerializer(cls) {
 | 
			
		||||
    return function serialize(arg) {
 | 
			
		||||
        var message = cls.fromObject(arg);
 | 
			
		||||
        return cls.encode(message).finish();
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
function createMethodDefinition(method, serviceName, options) {
 | 
			
		||||
    /* This is only ever called after the corresponding root.resolveAll(), so we
 | 
			
		||||
     * can assume that the resolved request and response types are non-null */
 | 
			
		||||
    var requestType = method.resolvedRequestType;
 | 
			
		||||
    var responseType = method.resolvedResponseType;
 | 
			
		||||
    return {
 | 
			
		||||
        path: '/' + serviceName + '/' + method.name,
 | 
			
		||||
        requestStream: !!method.requestStream,
 | 
			
		||||
        responseStream: !!method.responseStream,
 | 
			
		||||
        requestSerialize: createSerializer(requestType),
 | 
			
		||||
        requestDeserialize: createDeserializer(requestType, options),
 | 
			
		||||
        responseSerialize: createSerializer(responseType),
 | 
			
		||||
        responseDeserialize: createDeserializer(responseType, options),
 | 
			
		||||
        // TODO(murgatroid99): Find a better way to handle this
 | 
			
		||||
        originalName: camelCase(method.name),
 | 
			
		||||
        requestType: createMessageDefinition(requestType),
 | 
			
		||||
        responseType: createMessageDefinition(responseType)
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
function createServiceDefinition(service, name, options) {
 | 
			
		||||
    var def = {};
 | 
			
		||||
    for (var _i = 0, _a = service.methodsArray; _i < _a.length; _i++) {
 | 
			
		||||
        var method = _a[_i];
 | 
			
		||||
        def[method.name] = createMethodDefinition(method, name, options);
 | 
			
		||||
    }
 | 
			
		||||
    return def;
 | 
			
		||||
}
 | 
			
		||||
var fileDescriptorCache = new Map();
 | 
			
		||||
function getFileDescriptors(root) {
 | 
			
		||||
    if (fileDescriptorCache.has(root)) {
 | 
			
		||||
        return fileDescriptorCache.get(root);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        var descriptorList = root.toDescriptor('proto3').file;
 | 
			
		||||
        var bufferList = descriptorList.map(function (value) {
 | 
			
		||||
            return Buffer.from(descriptor.FileDescriptorProto.encode(value).finish());
 | 
			
		||||
        });
 | 
			
		||||
        fileDescriptorCache.set(root, bufferList);
 | 
			
		||||
        return bufferList;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function createMessageDefinition(message) {
 | 
			
		||||
    var messageDescriptor = message.toDescriptor('proto3');
 | 
			
		||||
    return {
 | 
			
		||||
        format: 'Protocol Buffer 3 DescriptorProto',
 | 
			
		||||
        type: messageDescriptor.$type.toObject(messageDescriptor, descriptorOptions),
 | 
			
		||||
        fileDescriptorProtos: getFileDescriptors(message.root)
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
function createEnumDefinition(enumType) {
 | 
			
		||||
    var enumDescriptor = enumType.toDescriptor('proto3');
 | 
			
		||||
    return {
 | 
			
		||||
        format: 'Protocol Buffer 3 EnumDescriptorProto',
 | 
			
		||||
        type: enumDescriptor.$type.toObject(enumDescriptor, descriptorOptions),
 | 
			
		||||
        fileDescriptorProtos: getFileDescriptors(enumType.root)
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * function createDefinition(obj: Protobuf.Service, name: string, options:
 | 
			
		||||
 * Options): ServiceDefinition; function createDefinition(obj: Protobuf.Type,
 | 
			
		||||
 * name: string, options: Options): MessageTypeDefinition; function
 | 
			
		||||
 * createDefinition(obj: Protobuf.Enum, name: string, options: Options):
 | 
			
		||||
 * EnumTypeDefinition;
 | 
			
		||||
 */
 | 
			
		||||
function createDefinition(obj, name, options) {
 | 
			
		||||
    if (obj instanceof Protobuf.Service) {
 | 
			
		||||
        return createServiceDefinition(obj, name, options);
 | 
			
		||||
    }
 | 
			
		||||
    else if (obj instanceof Protobuf.Type) {
 | 
			
		||||
        return createMessageDefinition(obj);
 | 
			
		||||
    }
 | 
			
		||||
    else if (obj instanceof Protobuf.Enum) {
 | 
			
		||||
        return createEnumDefinition(obj);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        throw new Error('Type mismatch in reflection object handling');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function createPackageDefinition(root, options) {
 | 
			
		||||
    var def = {};
 | 
			
		||||
    root.resolveAll();
 | 
			
		||||
    for (var _i = 0, _a = getAllHandledReflectionObjects(root, ''); _i < _a.length; _i++) {
 | 
			
		||||
        var _b = _a[_i], name = _b[0], obj = _b[1];
 | 
			
		||||
        def[name] = createDefinition(obj, name, options);
 | 
			
		||||
    }
 | 
			
		||||
    return def;
 | 
			
		||||
}
 | 
			
		||||
function addIncludePathResolver(root, includePaths) {
 | 
			
		||||
    var originalResolvePath = root.resolvePath;
 | 
			
		||||
    root.resolvePath = function (origin, target) {
 | 
			
		||||
        if (path.isAbsolute(target)) {
 | 
			
		||||
            return target;
 | 
			
		||||
        }
 | 
			
		||||
        for (var _i = 0, includePaths_1 = includePaths; _i < includePaths_1.length; _i++) {
 | 
			
		||||
            var directory = includePaths_1[_i];
 | 
			
		||||
            var fullPath = path.join(directory, target);
 | 
			
		||||
            try {
 | 
			
		||||
                fs.accessSync(fullPath, fs.constants.R_OK);
 | 
			
		||||
                return fullPath;
 | 
			
		||||
            }
 | 
			
		||||
            catch (err) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return originalResolvePath(origin, target);
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * Load a .proto file with the specified options.
 | 
			
		||||
 * @param filename One or multiple file paths to load. Can be an absolute path
 | 
			
		||||
 *     or relative to an include path.
 | 
			
		||||
 * @param options.keepCase Preserve field names. The default is to change them
 | 
			
		||||
 *     to camel case.
 | 
			
		||||
 * @param options.longs The type that should be used to represent `long` values.
 | 
			
		||||
 *     Valid options are `Number` and `String`. Defaults to a `Long` object type
 | 
			
		||||
 *     from a library.
 | 
			
		||||
 * @param options.enums The type that should be used to represent `enum` values.
 | 
			
		||||
 *     The only valid option is `String`. Defaults to the numeric value.
 | 
			
		||||
 * @param options.bytes The type that should be used to represent `bytes`
 | 
			
		||||
 *     values. Valid options are `Array` and `String`. The default is to use
 | 
			
		||||
 *     `Buffer`.
 | 
			
		||||
 * @param options.defaults Set default values on output objects. Defaults to
 | 
			
		||||
 *     `false`.
 | 
			
		||||
 * @param options.arrays Set empty arrays for missing array values even if
 | 
			
		||||
 *     `defaults` is `false`. Defaults to `false`.
 | 
			
		||||
 * @param options.objects Set empty objects for missing object values even if
 | 
			
		||||
 *     `defaults` is `false`. Defaults to `false`.
 | 
			
		||||
 * @param options.oneofs Set virtual oneof properties to the present field's
 | 
			
		||||
 *     name
 | 
			
		||||
 * @param options.includeDirs Paths to search for imported `.proto` files.
 | 
			
		||||
 */
 | 
			
		||||
function load(filename, options) {
 | 
			
		||||
    var root = new Protobuf.Root();
 | 
			
		||||
    options = options || {};
 | 
			
		||||
    if (!!options.includeDirs) {
 | 
			
		||||
        if (!(Array.isArray(options.includeDirs))) {
 | 
			
		||||
            return Promise.reject(new Error('The includeDirs option must be an array'));
 | 
			
		||||
        }
 | 
			
		||||
        addIncludePathResolver(root, options.includeDirs);
 | 
			
		||||
    }
 | 
			
		||||
    return root.load(filename, options).then(function (loadedRoot) {
 | 
			
		||||
        loadedRoot.resolveAll();
 | 
			
		||||
        return createPackageDefinition(root, options);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.load = load;
 | 
			
		||||
function loadSync(filename, options) {
 | 
			
		||||
    var root = new Protobuf.Root();
 | 
			
		||||
    options = options || {};
 | 
			
		||||
    if (!!options.includeDirs) {
 | 
			
		||||
        if (!(Array.isArray(options.includeDirs))) {
 | 
			
		||||
            throw new Error('The includeDirs option must be an array');
 | 
			
		||||
        }
 | 
			
		||||
        addIncludePathResolver(root, options.includeDirs);
 | 
			
		||||
    }
 | 
			
		||||
    var loadedRoot = root.loadSync(filename, options);
 | 
			
		||||
    loadedRoot.resolveAll();
 | 
			
		||||
    return createPackageDefinition(root, options);
 | 
			
		||||
}
 | 
			
		||||
exports.loadSync = loadSync;
 | 
			
		||||
// Load Google's well-known proto files that aren't exposed by Protobuf.js.
 | 
			
		||||
{
 | 
			
		||||
    // Protobuf.js exposes: any, duration, empty, field_mask, struct, timestamp,
 | 
			
		||||
    // and wrappers. compiler/plugin is excluded in Protobuf.js and here.
 | 
			
		||||
    var wellKnownProtos = ['api', 'descriptor', 'source_context', 'type'];
 | 
			
		||||
    var sourceDir = path.join(path.dirname(require.resolve('protobufjs')), 'google', 'protobuf');
 | 
			
		||||
    for (var _i = 0, wellKnownProtos_1 = wellKnownProtos; _i < wellKnownProtos_1.length; _i++) {
 | 
			
		||||
        var proto = wellKnownProtos_1[_i];
 | 
			
		||||
        var file = path.join(sourceDir, proto + ".proto");
 | 
			
		||||
        var descriptor_1 = Protobuf.loadSync(file).toJSON();
 | 
			
		||||
        // @ts-ignore
 | 
			
		||||
        Protobuf.common(proto, descriptor_1.nested.google.nested);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//# sourceMappingURL=index.js.map
 | 
			
		||||
							
								
								
									
										83
									
								
								node_modules/@grpc/proto-loader/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								node_modules/@grpc/proto-loader/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "@grpc/proto-loader@^0.5.0",
 | 
			
		||||
  "_id": "@grpc/proto-loader@0.5.2",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-eBKD/FPxQoY1x6QONW2nBd54QUEyzcFP9FenujmoeDPy1rutVSHki1s/wR68F6O1QfCNDx+ayBH1O2CVNMzyyw==",
 | 
			
		||||
  "_location": "/@grpc/proto-loader",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "@grpc/proto-loader@^0.5.0",
 | 
			
		||||
    "name": "@grpc/proto-loader",
 | 
			
		||||
    "escapedName": "@grpc%2fproto-loader",
 | 
			
		||||
    "scope": "@grpc",
 | 
			
		||||
    "rawSpec": "^0.5.0",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "^0.5.0"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/@firebase/firestore"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.2.tgz",
 | 
			
		||||
  "_shasum": "c84f83be962f518bc303ca2d5e6ef2239439786c",
 | 
			
		||||
  "_spec": "@grpc/proto-loader@^0.5.0",
 | 
			
		||||
  "_where": "C:\\Users\\matia\\Documents\\GitHub\\FutoX-Musix\\node_modules\\@firebase\\firestore",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Google Inc."
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/grpc/grpc-node/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "contributors": [
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Michael Lumish",
 | 
			
		||||
      "email": "mlumish@google.com"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "lodash.camelcase": "^4.3.0",
 | 
			
		||||
    "protobufjs": "^6.8.6"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "gRPC utility library for loading .proto files",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/lodash.camelcase": "^4.3.4",
 | 
			
		||||
    "@types/node": "^10.12.5",
 | 
			
		||||
    "clang-format": "^1.2.2",
 | 
			
		||||
    "gts": "^0.5.3",
 | 
			
		||||
    "typescript": "~3.3.3333"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": ">=6"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "LICENSE",
 | 
			
		||||
    "build/src/*.d.ts",
 | 
			
		||||
    "build/src/*.js"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://grpc.io/",
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "main": "build/src/index.js",
 | 
			
		||||
  "name": "@grpc/proto-loader",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git+https://github.com/grpc/grpc-node.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "npm run compile",
 | 
			
		||||
    "check": "gts check",
 | 
			
		||||
    "clean": "gts clean",
 | 
			
		||||
    "compile": "tsc -p .",
 | 
			
		||||
    "fix": "gts fix",
 | 
			
		||||
    "format": "clang-format -i -style=\"{Language: JavaScript, BasedOnStyle: Google, ColumnLimit: 80}\" src/*.ts test/*.ts",
 | 
			
		||||
    "lint": "tslint -c node_modules/google-ts-style/tslint.json -p . -t codeFrame --type-check",
 | 
			
		||||
    "posttest": "npm run check",
 | 
			
		||||
    "prepare": "npm run compile",
 | 
			
		||||
    "pretest": "npm run compile",
 | 
			
		||||
    "test": "gulp test"
 | 
			
		||||
  },
 | 
			
		||||
  "typings": "build/src/index.d.ts",
 | 
			
		||||
  "version": "0.5.2"
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user