UNPKG

1.99 kBtext/x-cView Raw
1/*
2 *
3 * Copyright 2015 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19#ifndef NET_GRPC_NODE_CHANNEL_CREDENTIALS_H_
20#define NET_GRPC_NODE_CHANNEL_CREDENTIALS_H_
21
22#include <nan.h>
23#include <node.h>
24#include "grpc/grpc.h"
25#include "grpc/grpc_security.h"
26
27namespace grpc {
28namespace node {
29
30/* Wrapper class for grpc_channel_credentials structs */
31class ChannelCredentials : public Nan::ObjectWrap {
32 public:
33 static void Init(v8::Local<v8::Object> exports);
34 static bool HasInstance(v8::Local<v8::Value> val);
35 /* Wrap a grpc_channel_credentials struct in a javascript object */
36 static v8::Local<v8::Value> WrapStruct(grpc_channel_credentials *credentials);
37
38 /* Returns the grpc_channel_credentials struct that this object wraps */
39 grpc_channel_credentials *GetWrappedCredentials();
40
41 private:
42 explicit ChannelCredentials(grpc_channel_credentials *credentials);
43 ~ChannelCredentials();
44
45 // Prevent copying
46 ChannelCredentials(const ChannelCredentials &);
47 ChannelCredentials &operator=(const ChannelCredentials &);
48
49 static NAN_METHOD(New);
50 static NAN_METHOD(CreateSsl);
51 static NAN_METHOD(CreateInsecure);
52
53 static NAN_METHOD(Compose);
54 static Nan::Callback *constructor;
55 // Used for typechecking instances of this javascript class
56 static Nan::Persistent<v8::FunctionTemplate> fun_tpl;
57
58 grpc_channel_credentials *wrapped_credentials;
59};
60
61} // namespace node
62} // namespace grpc
63
64#endif // NET_GRPC_NODE_CHANNEL_CREDENTIALS_H_