grpc.credentials.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Namespace: credentials</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Namespace: credentials</h1>
  17. <section>
  18. <header>
  19. <h2>
  20. <span class="ancestors"><a href="grpc.html">grpc</a>.</span>credentials</h2>
  21. </header>
  22. <article>
  23. <div class="container-overview">
  24. <div class="description"><p>Credentials module</p>
  25. <p>This module contains factory methods for two different credential types:
  26. CallCredentials and ChannelCredentials. ChannelCredentials are things like
  27. SSL credentials that can be used to secure a connection, and are used to
  28. construct a Client object. CallCredentials genrally modify metadata, so they
  29. can be attached to an individual method call.</p>
  30. <p>CallCredentials can be composed with other CallCredentials to create
  31. CallCredentials. ChannelCredentials can be composed with CallCredentials
  32. to create ChannelCredentials. No combined credential can have more than
  33. one ChannelCredentials.</p>
  34. <p>For example, to create a client secured with SSL that uses Google
  35. default application credentials to authenticate:</p></div>
  36. <dl class="details">
  37. <dt class="tag-source">Source:</dt>
  38. <dd class="tag-source"><ul class="dummy"><li>
  39. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line19">line 19</a>
  40. </li></ul></dd>
  41. </dl>
  42. <h3>Example</h3>
  43. <pre class="prettyprint"><code>var channel_creds = credentials.createSsl(root_certs);
  44. (new GoogleAuth()).getApplicationDefault(function(err, credential) {
  45. var call_creds = credentials.createFromGoogleCredential(credential);
  46. var combined_creds = credentials.combineChannelCredentials(
  47. channel_creds, call_creds);
  48. var client = new Client(address, combined_creds);
  49. });</code></pre>
  50. </div>
  51. <h3 class="subsection-title">Classes</h3>
  52. <dl>
  53. <dt><a href="grpc.credentials-CallCredentials.html">CallCredentials</a></dt>
  54. <dd></dd>
  55. <dt><a href="grpc.credentials-ChannelCredentials.html">ChannelCredentials</a></dt>
  56. <dd></dd>
  57. </dl>
  58. <h3 class="subsection-title">Methods</h3>
  59. <h4 class="name" id=".combineCallCredentials"><span class="type-signature">(static) </span>combineCallCredentials<span class="signature">(&hellip;credentials)</span><span class="type-signature"></span></h4>
  60. <div class="description">
  61. <p>Combine any number of CallCredentials into a single CallCredentials object</p>
  62. </div>
  63. <h5>Parameters:</h5>
  64. <table class="params">
  65. <thead>
  66. <tr>
  67. <th>Name</th>
  68. <th>Type</th>
  69. <th>Attributes</th>
  70. <th class="last">Description</th>
  71. </tr>
  72. </thead>
  73. <tbody>
  74. <tr>
  75. <td class="name"><code>credentials</code></td>
  76. <td class="type">
  77. <span class="param-type">CallCredentials</span>
  78. </td>
  79. <td class="attributes">
  80. &lt;repeatable><br>
  81. </td>
  82. <td class="description last"><p>the CallCredentials to compose</p></td>
  83. </tr>
  84. </tbody>
  85. </table>
  86. <dl class="details">
  87. <dt class="tag-source">Source:</dt>
  88. <dd class="tag-source"><ul class="dummy"><li>
  89. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line191">line 191</a>
  90. </li></ul></dd>
  91. </dl>
  92. <h5>Returns:</h5>
  93. <div class="param-desc">
  94. <p>CallCredentials A credentials object that combines all of the input
  95. credentials</p>
  96. </div>
  97. <h4 class="name" id=".combineChannelCredentials"><span class="type-signature">(static) </span>combineChannelCredentials<span class="signature">(channel_credential, &hellip;credentials)</span><span class="type-signature"></span></h4>
  98. <div class="description">
  99. <p>Combine a ChannelCredentials with any number of CallCredentials into a single
  100. ChannelCredentials object.</p>
  101. </div>
  102. <h5>Parameters:</h5>
  103. <table class="params">
  104. <thead>
  105. <tr>
  106. <th>Name</th>
  107. <th>Type</th>
  108. <th>Attributes</th>
  109. <th class="last">Description</th>
  110. </tr>
  111. </thead>
  112. <tbody>
  113. <tr>
  114. <td class="name"><code>channel_credential</code></td>
  115. <td class="type">
  116. <span class="param-type">ChannelCredentials</span>
  117. </td>
  118. <td class="attributes">
  119. </td>
  120. <td class="description last"><p>The ChannelCredentials to
  121. start with</p></td>
  122. </tr>
  123. <tr>
  124. <td class="name"><code>credentials</code></td>
  125. <td class="type">
  126. <span class="param-type">CallCredentials</span>
  127. </td>
  128. <td class="attributes">
  129. &lt;repeatable><br>
  130. </td>
  131. <td class="description last"><p>The CallCredentials to compose</p></td>
  132. </tr>
  133. </tbody>
  134. </table>
  135. <dl class="details">
  136. <dt class="tag-source">Source:</dt>
  137. <dd class="tag-source"><ul class="dummy"><li>
  138. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line175">line 175</a>
  139. </li></ul></dd>
  140. </dl>
  141. <h5>Returns:</h5>
  142. <div class="param-desc">
  143. <p>ChannelCredentials A credentials object that combines all of the
  144. input credentials</p>
  145. </div>
  146. <h4 class="name" id=".createFromGoogleCredential"><span class="type-signature">(static) </span>createFromGoogleCredential<span class="signature">(google_credential)</span><span class="type-signature"> &rarr; {grpc.credentials.CallCredentials}</span></h4>
  147. <div class="description">
  148. <p>Create a gRPC credential from a Google credential object.</p>
  149. </div>
  150. <h5>Parameters:</h5>
  151. <table class="params">
  152. <thead>
  153. <tr>
  154. <th>Name</th>
  155. <th>Type</th>
  156. <th class="last">Description</th>
  157. </tr>
  158. </thead>
  159. <tbody>
  160. <tr>
  161. <td class="name"><code>google_credential</code></td>
  162. <td class="type">
  163. <span class="param-type"><a href="external-GoogleCredential.html">external:GoogleCredential</a></span>
  164. </td>
  165. <td class="description last"><p>The Google credential
  166. object to use</p></td>
  167. </tr>
  168. </tbody>
  169. </table>
  170. <dl class="details">
  171. <dt class="tag-source">Source:</dt>
  172. <dd class="tag-source"><ul class="dummy"><li>
  173. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line148">line 148</a>
  174. </li></ul></dd>
  175. </dl>
  176. <h5>Returns:</h5>
  177. <div class="param-desc">
  178. <p>The resulting credentials object</p>
  179. </div>
  180. <dl>
  181. <dt>
  182. Type
  183. </dt>
  184. <dd>
  185. <span class="param-type">grpc.credentials.CallCredentials</span>
  186. </dd>
  187. </dl>
  188. <h4 class="name" id=".createFromMetadataGenerator"><span class="type-signature">(static) </span>createFromMetadataGenerator<span class="signature">(metadata_generator)</span><span class="type-signature"> &rarr; {grpc.credentials.CallCredentials}</span></h4>
  189. <div class="description">
  190. <p>Create a gRPC credentials object from a metadata generation function. This
  191. function gets the service URL and a callback as parameters. The error
  192. passed to the callback can optionally have a 'code' value attached to it,
  193. which corresponds to a status code that this library uses.</p>
  194. </div>
  195. <h5>Parameters:</h5>
  196. <table class="params">
  197. <thead>
  198. <tr>
  199. <th>Name</th>
  200. <th>Type</th>
  201. <th class="last">Description</th>
  202. </tr>
  203. </thead>
  204. <tbody>
  205. <tr>
  206. <td class="name"><code>metadata_generator</code></td>
  207. <td class="type">
  208. <span class="param-type"><a href="grpc.credentials.html#~generateMetadata">grpc.credentials~generateMetadata</a></span>
  209. </td>
  210. <td class="description last"><p>The function
  211. that generates metadata</p></td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. <dl class="details">
  216. <dt class="tag-source">Source:</dt>
  217. <dd class="tag-source"><ul class="dummy"><li>
  218. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line118">line 118</a>
  219. </li></ul></dd>
  220. </dl>
  221. <h5>Returns:</h5>
  222. <div class="param-desc">
  223. <p>The credentials object</p>
  224. </div>
  225. <dl>
  226. <dt>
  227. Type
  228. </dt>
  229. <dd>
  230. <span class="param-type">grpc.credentials.CallCredentials</span>
  231. </dd>
  232. </dl>
  233. <h4 class="name" id=".createInsecure"><span class="type-signature">(static) </span>createInsecure<span class="signature">()</span><span class="type-signature"> &rarr; {ChannelCredentials}</span></h4>
  234. <div class="description">
  235. <p>Create an insecure credentials object. This is used to create a channel that
  236. does not use SSL. This cannot be composed with anything.</p>
  237. </div>
  238. <dl class="details">
  239. <dt class="tag-source">Source:</dt>
  240. <dd class="tag-source"><ul class="dummy"><li>
  241. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line207">line 207</a>
  242. </li></ul></dd>
  243. </dl>
  244. <h5>Returns:</h5>
  245. <div class="param-desc">
  246. <p>The insecure credentials object</p>
  247. </div>
  248. <dl>
  249. <dt>
  250. Type
  251. </dt>
  252. <dd>
  253. <span class="param-type">ChannelCredentials</span>
  254. </dd>
  255. </dl>
  256. <h4 class="name" id=".createSsl"><span class="type-signature">(static) </span>createSsl<span class="signature">(root_certs<span class="signature-attributes">opt</span>, private_key<span class="signature-attributes">opt</span>, cert_chain<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {grpc.credentials.ChannelCredentials}</span></h4>
  257. <div class="description">
  258. <p>Create an SSL Credentials object. If using a client-side certificate, both
  259. the second and third arguments must be passed.</p>
  260. </div>
  261. <h5>Parameters:</h5>
  262. <table class="params">
  263. <thead>
  264. <tr>
  265. <th>Name</th>
  266. <th>Type</th>
  267. <th>Attributes</th>
  268. <th class="last">Description</th>
  269. </tr>
  270. </thead>
  271. <tbody>
  272. <tr>
  273. <td class="name"><code>root_certs</code></td>
  274. <td class="type">
  275. <span class="param-type">Buffer</span>
  276. </td>
  277. <td class="attributes">
  278. &lt;optional><br>
  279. </td>
  280. <td class="description last"><p>The root certificate data</p></td>
  281. </tr>
  282. <tr>
  283. <td class="name"><code>private_key</code></td>
  284. <td class="type">
  285. <span class="param-type">Buffer</span>
  286. </td>
  287. <td class="attributes">
  288. &lt;optional><br>
  289. </td>
  290. <td class="description last"><p>The client certificate private key, if
  291. applicable</p></td>
  292. </tr>
  293. <tr>
  294. <td class="name"><code>cert_chain</code></td>
  295. <td class="type">
  296. <span class="param-type">Buffer</span>
  297. </td>
  298. <td class="attributes">
  299. &lt;optional><br>
  300. </td>
  301. <td class="description last"><p>The client certificate cert chain, if applicable</p></td>
  302. </tr>
  303. </tbody>
  304. </table>
  305. <dl class="details">
  306. <dt class="tag-source">Source:</dt>
  307. <dd class="tag-source"><ul class="dummy"><li>
  308. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line91">line 91</a>
  309. </li></ul></dd>
  310. </dl>
  311. <h5>Returns:</h5>
  312. <div class="param-desc">
  313. <p>The SSL Credentials object</p>
  314. </div>
  315. <dl>
  316. <dt>
  317. Type
  318. </dt>
  319. <dd>
  320. <span class="param-type">grpc.credentials.ChannelCredentials</span>
  321. </dd>
  322. </dl>
  323. <h3 class="subsection-title">Type Definitions</h3>
  324. <h4 class="name" id="~generateMetadata"><span class="type-signature"></span>generateMetadata<span class="signature">(params, callback)</span><span class="type-signature"></span></h4>
  325. <h5>Parameters:</h5>
  326. <table class="params">
  327. <thead>
  328. <tr>
  329. <th>Name</th>
  330. <th>Type</th>
  331. <th class="last">Description</th>
  332. </tr>
  333. </thead>
  334. <tbody>
  335. <tr>
  336. <td class="name"><code>params</code></td>
  337. <td class="type">
  338. <span class="param-type">Object</span>
  339. </td>
  340. <td class="description last"><p>Parameters that can modify metadata generation</p>
  341. <h6>Properties</h6>
  342. <table class="params">
  343. <thead>
  344. <tr>
  345. <th>Name</th>
  346. <th>Type</th>
  347. <th class="last">Description</th>
  348. </tr>
  349. </thead>
  350. <tbody>
  351. <tr>
  352. <td class="name"><code>service_url</code></td>
  353. <td class="type">
  354. <span class="param-type">string</span>
  355. </td>
  356. <td class="description last"><p>The URL of the service that the call is
  357. going to</p></td>
  358. </tr>
  359. </tbody>
  360. </table>
  361. </td>
  362. </tr>
  363. <tr>
  364. <td class="name"><code>callback</code></td>
  365. <td class="type">
  366. <span class="param-type"><a href="grpc.credentials.html#~metadataCallback">grpc.credentials~metadataCallback</a></span>
  367. </td>
  368. <td class="description last"></td>
  369. </tr>
  370. </tbody>
  371. </table>
  372. <dl class="details">
  373. <dt class="tag-source">Source:</dt>
  374. <dd class="tag-source"><ul class="dummy"><li>
  375. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line99">line 99</a>
  376. </li></ul></dd>
  377. </dl>
  378. <h4 class="name" id="~metadataCallback"><span class="type-signature"></span>metadataCallback<span class="signature">(error, metadata)</span><span class="type-signature"></span></h4>
  379. <h5>Parameters:</h5>
  380. <table class="params">
  381. <thead>
  382. <tr>
  383. <th>Name</th>
  384. <th>Type</th>
  385. <th class="last">Description</th>
  386. </tr>
  387. </thead>
  388. <tbody>
  389. <tr>
  390. <td class="name"><code>error</code></td>
  391. <td class="type">
  392. <span class="param-type">Error</span>
  393. </td>
  394. <td class="description last"><p>The error, if getting metadata failed</p></td>
  395. </tr>
  396. <tr>
  397. <td class="name"><code>metadata</code></td>
  398. <td class="type">
  399. <span class="param-type"><a href="grpc.Metadata.html">grpc.Metadata</a></span>
  400. </td>
  401. <td class="description last"><p>The metadata</p></td>
  402. </tr>
  403. </tbody>
  404. </table>
  405. <dl class="details">
  406. <dt class="tag-source">Source:</dt>
  407. <dd class="tag-source"><ul class="dummy"><li>
  408. <a href="src_credentials.js.html">src/credentials.js</a>, <a href="src_credentials.js.html#line93">line 93</a>
  409. </li></ul></dd>
  410. </dl>
  411. </article>
  412. </section>
  413. </div>
  414. <nav>
  415. <h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-Duplex.html">Duplex</a></li><li><a href="external-EventEmitter.html">EventEmitter</a></li><li><a href="external-GoogleCredential.html">GoogleCredential</a></li><li><a href="external-Readable.html">Readable</a></li><li><a href="external-Writable.html">Writable</a></li></ul><h3>Classes</h3><ul><li><a href="grpc.Client.html">Client</a></li><li><a href="grpc.credentials-CallCredentials.html">CallCredentials</a></li><li><a href="grpc.credentials-ChannelCredentials.html">ChannelCredentials</a></li><li><a href="grpc.Metadata.html">Metadata</a></li><li><a href="grpc.Server.html">Server</a></li><li><a href="grpc.ServerCredentials.html">ServerCredentials</a></li><li><a href="grpc-ClientDuplexStream.html">ClientDuplexStream</a></li><li><a href="grpc-ClientReadableStream.html">ClientReadableStream</a></li><li><a href="grpc-ClientUnaryCall.html">ClientUnaryCall</a></li><li><a href="grpc-ClientWritableStream.html">ClientWritableStream</a></li><li><a href="grpc-ServerDuplexStream.html">ServerDuplexStream</a></li><li><a href="grpc-ServerReadableStream.html">ServerReadableStream</a></li><li><a href="grpc-ServerUnaryCall.html">ServerUnaryCall</a></li><li><a href="grpc-ServerWritableStream.html">ServerWritableStream</a></li></ul><h3>Events</h3><ul><li><a href="grpc-ClientDuplexStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientDuplexStream.html#event:status">status</a></li><li><a href="grpc-ClientReadableStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientReadableStream.html#event:status">status</a></li><li><a href="grpc-ClientUnaryCall.html#event:metadata">metadata</a></li><li><a href="grpc-ClientUnaryCall.html#event:status">status</a></li><li><a href="grpc-ClientWritableStream.html#event:metadata">metadata</a></li><li><a href="grpc-ClientWritableStream.html#event:status">status</a></li><li><a href="grpc-ServerDuplexStream.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerReadableStream.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerUnaryCall.html#~event:cancelled">cancelled</a></li><li><a href="grpc-ServerWritableStream.html#~event:cancelled">cancelled</a></li></ul><h3>Namespaces</h3><ul><li><a href="grpc.html">grpc</a></li><li><a href="grpc.credentials.html">credentials</a></li></ul>
  416. </nav>
  417. <br class="clear">
  418. <footer>
  419. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Sep 08 2017 11:10:31 GMT-0700 (PDT)
  420. </footer>
  421. <script> prettyPrint(); </script>
  422. <script src="scripts/linenumber.js"> </script>
  423. </body>
  424. </html>