{"name":"resolve-alpn","version":"1.0.0","description":"Detects the ALPN protocol","main":"index.js","scripts":{"test":"xo && nyc ava","coveralls":"nyc report --reporter=text-lcov | coveralls"},"repository":{"type":"git","url":"git+https://github.com/szmarczak/resolve-alpn.git"},"keywords":["alpn","http2"],"author":{"name":"Szymon Marczak"},"license":"MIT","bugs":{"url":"https://github.com/szmarczak/resolve-alpn/issues"},"homepage":"https://github.com/szmarczak/resolve-alpn#readme","devDependencies":{"ava":"^1.0.1","coveralls":"^3.0.2","nyc":"^13.1.0","pem":"^1.13.2","xo":"^0.23.0"},"gitHead":"64c69e4917328cdcbdef85d677409c4fe3c835d9","_id":"resolve-alpn@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"szmarczak","email":"sz.marczak@gmail.com"},"dist":{"integrity":"sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA==","shasum":"745ad60b3d6aff4b4a48e01b8c0bdc70959e0e8c","tarball":"http://registry-npm.ywwl.com/resolve-alpn/download/resolve-alpn-1.0.0.tgz","fileCount":7,"unpackedSize":5345,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcH6bECRA9TVsSAnZWagAA2SYP/2Ufx6ratYri5VJzXhZH\n1hOoCby9C0bmsFVBkNStqeKsdOHdJ3I6Nse82oJW2i5UFhhh8ikzQZq9VL3q\n8cUafC91RHJv5hmdJ460NnAOhvlCX+bnlnfm/DcpxJCufZfQwMnuI9Yp2M+I\nP2HDCs9BL0vntylq6V1lHuhkk9yJSjxi/jiNFw7UZamaodfGEnwJsSHz9hNp\nEREx7yQsVuVfxpSugLSwLA2MsAeg6RP+KP4NYejKOCtohV/+fnaEstwGeu+l\nlpnHCcPwbTGlt3HD5ceLq/FfnpdwFnS9TfBrhqf5zGe+Yd5nSmPSO35sKX/H\nrkOEK1qMHp864hGHh/cYChSr58moi5veUTBR1PvPSvDV3U1GPsp29OMMWHPv\niL/2tzpJW1PNDIF8i2DEmhqFSOlvo2e48klXbuVk/hH6d0eWAevCAqwlE1MV\nz1yqNi0auXg0vbNyI+ir4PiZJwoa2dCktD2LaKo8qX9RCGPyIk8BH+wGkhIu\nirBZ8YvygVcVuqRn4trQNuZa2sHMqtfQtohaAbDE1MvFXNjFUhk0S6wIQL0N\nl9S7aUZfr6Ac0xllRWFcXvMxBBfI2yokCM8FWTxGk97+/UBQ5kmchbrux/Gr\nAYydWzl83Cr54Hypkga/xVyktkPIuSU5vm2/HYPx7gSCYrCjpfRDlpHhWlZu\nbq5T\r\n=M/td\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEE6WjK/ozMWuiwTx23VByU2Tf0m8CsBSEWShrZeajnwAiEAkAEN2sX4I6UiwaLefPMdh5dodUX+I6MoCmg+jFvHtb0="}],"size":2636,"noattachment":false,"key":"/resolve-alpn/-/resolve-alpn-1.0.0.tgz"},"maintainers":[{"name":"szmarczak","email":"sz.marczak@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/resolve-alpn_1.0.0_1545578180000_0.5579683285245283"},"_hasShrinkwrap":false,"readme":"# `resolve-alpn`\n\n[![Node CI](https://github.com/szmarczak/resolve-alpn/workflows/Node%20CI/badge.svg)](https://github.com/szmarczak/resolve-alpn/actions)\n[![codecov](https://codecov.io/gh/szmarczak/resolve-alpn/branch/master/graph/badge.svg)](https://codecov.io/gh/szmarczak/resolve-alpn)\n\n## API\n\n### resolveALPN(options, connect = tls.connect)\n\nReturns an object with an `alpnProtocol` property. The `socket` property may be also present.\n\n```js\nconst result = await resolveALPN({\n\thost: 'nghttp2.org',\n\tport: 443,\n\tALPNProtocols: ['h2', 'http/1.1'],\n\tservername: 'nghttp2.org'\n});\n\nconsole.log(result); // {alpnProtocol: 'h2'}\n```\n\n**Note:** While the `servername` option is not required in this case, many other servers do. It's best practice to set it anyway.\n\n**Note:** If the socket times out, the promise will resolve and `result.timeout` will be set to `true`.\n\n#### options\n\nSame as [TLS options](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback).\n\n##### options.resolveSocket\n\nBy default, the socket gets destroyed and the promise resolves.<br>\nIf you set this to true, it will return the socket in a `socket` property.\n\n```js\nconst result = await resolveALPN({\n\thost: 'nghttp2.org',\n\tport: 443,\n\tALPNProtocols: ['h2', 'http/1.1'],\n\tservername: 'nghttp2.org',\n\tresolveSocket: true\n});\n\nconsole.log(result); // {alpnProtocol: 'h2', socket: tls.TLSSocket}\n\n// Remember to destroy the socket if you don't use it!\nresult.socket.destroy();\n```\n\n#### connect\n\nType: `Function<TLSSocket> | AsyncFunction<TLSSocket>`\\\nDefault: [`tls.connect`](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tls_tls_connect_options_callback)\n\n**Note:** No matter which function is used (synchronous or asynchronous), it **must** accept a `callback` function as a second argument. The `callback` function gets executed when the socket has successfully connected.\n\n## License\n\nMIT\n","publish_time":1545578180138,"_cnpm_publish_time":1545578180138,"dist-tags":{"latest":"1.2.1"}}