@@ -69,65 +69,52 @@ if (!semver.satisfies(process.version, supportedNodeVersions)) {
69
69
throw new Error ( `@grpc/grpc-js only works on Node ${ supportedNodeVersions } ` ) ;
70
70
}
71
71
72
- interface IndexedObject {
73
- [ key : string ] : any ; // eslint-disable-line @typescript-eslint/no-explicit-any
74
- [ key : number ] : any ; // eslint-disable-line @typescript-eslint/no-explicit-any
75
- }
76
-
77
- function mixin ( ...sources : IndexedObject [ ] ) {
78
- const result : { [ key : string ] : Function } = { } ;
79
- for ( const source of sources ) {
80
- for ( const propName of Object . getOwnPropertyNames ( source ) ) {
81
- const property : any = source [ propName ] ; // eslint-disable-line @typescript-eslint/no-explicit-any
82
- if ( typeof property === 'function' ) {
83
- result [ propName ] = property ;
84
- }
85
- }
86
- }
87
- return result ;
88
- }
89
-
90
72
export { OAuth2Client } ;
91
73
92
74
/**** Client Credentials ****/
93
75
94
76
// Using assign only copies enumerable properties, which is what we want
95
- export const credentials = mixin (
96
- {
97
- /**
98
- * Combine a ChannelCredentials with any number of CallCredentials into a
99
- * single ChannelCredentials object.
100
- * @param channelCredentials The ChannelCredentials object.
101
- * @param callCredentials Any number of CallCredentials objects.
102
- * @return The resulting ChannelCredentials object.
103
- */
104
- combineChannelCredentials : (
105
- channelCredentials : ChannelCredentials ,
106
- ...callCredentials : CallCredentials [ ]
107
- ) : ChannelCredentials => {
108
- return callCredentials . reduce (
109
- ( acc , other ) => acc . compose ( other ) ,
110
- channelCredentials
111
- ) ;
112
- } ,
113
-
114
- /**
115
- * Combine any number of CallCredentials into a single CallCredentials
116
- * object.
117
- * @param first The first CallCredentials object.
118
- * @param additional Any number of additional CallCredentials objects.
119
- * @return The resulting CallCredentials object.
120
- */
121
- combineCallCredentials : (
122
- first : CallCredentials ,
123
- ...additional : CallCredentials [ ]
124
- ) : CallCredentials => {
125
- return additional . reduce ( ( acc , other ) => acc . compose ( other ) , first ) ;
126
- } ,
77
+ export const credentials = {
78
+ /**
79
+ * Combine a ChannelCredentials with any number of CallCredentials into a
80
+ * single ChannelCredentials object.
81
+ * @param channelCredentials The ChannelCredentials object.
82
+ * @param callCredentials Any number of CallCredentials objects.
83
+ * @return The resulting ChannelCredentials object.
84
+ */
85
+ combineChannelCredentials : (
86
+ channelCredentials : ChannelCredentials ,
87
+ ...callCredentials : CallCredentials [ ]
88
+ ) : ChannelCredentials => {
89
+ return callCredentials . reduce (
90
+ ( acc , other ) => acc . compose ( other ) ,
91
+ channelCredentials
92
+ ) ;
127
93
} ,
128
- ChannelCredentials ,
129
- CallCredentials
130
- ) ;
94
+
95
+ /**
96
+ * Combine any number of CallCredentials into a single CallCredentials
97
+ * object.
98
+ * @param first The first CallCredentials object.
99
+ * @param additional Any number of additional CallCredentials objects.
100
+ * @return The resulting CallCredentials object.
101
+ */
102
+ combineCallCredentials : (
103
+ first : CallCredentials ,
104
+ ...additional : CallCredentials [ ]
105
+ ) : CallCredentials => {
106
+ return additional . reduce ( ( acc , other ) => acc . compose ( other ) , first ) ;
107
+ } ,
108
+
109
+ // from channel-credentials.ts
110
+ createInsecure : ChannelCredentials . createInsecure ,
111
+ createSsl : ChannelCredentials . createSsl ,
112
+
113
+ // from call-credentials.ts
114
+ createFromMetadataGenerator : CallCredentials . createFromMetadataGenerator ,
115
+ createFromGoogleCredential : CallCredentials . createFromGoogleCredential ,
116
+ createEmpty : CallCredentials . createEmpty ,
117
+ } ;
131
118
132
119
/**** Metadata ****/
133
120
0 commit comments