{"name":"resolve-alpn","version":"1.2.1","description":"Detects the ALPN protocol","main":"index.js","scripts":{"test":"xo && nyc --reporter=lcovonly --reporter=text --reporter=html ava"},"repository":{"type":"git","url":"git+https://github.com/szmarczak/resolve-alpn.git"},"keywords":["alpn","tls","socket","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":"^3.15.0","nyc":"^15.1.0","pem":"1.14.3","xo":"^0.38.2"},"gitHead":"778781a0521c713ca7605fc3ba31fb8e4be37d6b","_id":"resolve-alpn@1.2.1","_nodeVersion":"16.8.0","_npmVersion":"7.21.0","dist":{"integrity":"sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==","shasum":"b7adbdac3546aaaec20b45e7d8265927072726f9","tarball":"http://registry-npm.ywwl.com/resolve-alpn/download/resolve-alpn-1.2.1.tgz","fileCount":4,"unpackedSize":4645,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhLJL0CRA9TVsSAnZWagAAX64P/R0rS42z848N99J7ttJ4\n35icwgihGUd5sUDhR/j0+k5x3cOm58y0XN0xm9nbQF7rN/0z+x/Zb5L8sokp\n4S5UzGYn1IiBqSUDkjAO0WzlvFucL6pfPApJb2fICU5z09Fj0UGaqhzsygRu\nmld81QSap7GCdGycJAQ3uFyA7ODe0o9CA0wXpi7V5Ph4rBRJ/X0sFlBdoEjc\nPEUzeT4qvpXNti0claoRKDMZWHDJaeAPWJAbGnTukgjbG9XRxcas2CH5a1sR\nknsTj6He49Ls8Cg5j2SGjJDz/ekJDVlcMrXNVbmB002QGi0A9+5+P4oJRBfO\n2ZBdLUrsEDYBDqEUDSqHS5k9h+eJvfVDTw9+Wbbmi13UWK+Rxutyr5UnT2ON\nHjY+EWj05egNNIOw1J2pr6/Z9drCWCpyY1+FT5OmCTYvgHBSLWOyiHNPAp2O\nf5GNybOTonKv4tw+KspFoUSeqVGyACRJvr5rwCBL3459oqvWoNyPEGYr2H7r\nDfgxC3y/u99nxzQx/v7h0Y07YK6ptW5kgfbC4s1onp56fx7v6FQYcewUEOTo\ny4aBFItyqwVMdBviAOuOgFmhQGF9uWJYZSWiz0WOELKft35gAsXG4gRW9awp\ngemmuwuOu7Q7F3hArkkK6ZmtlLcgZwoLMcAgv6PQp+lVdhR4ArDZ1Gl8Chxi\nXWic\r\n=4z4p\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNSH7t3Kxpo66GwY5Byo21LxWli3D9iHduXALg6TOU7AIgDE/gufNlN7VmD2N+tvOubjy+OQf81qNa4/VMEZ54Kms="}],"size":2231,"noattachment":false,"key":"/resolve-alpn/-/resolve-alpn-1.2.1.tgz"},"_npmUser":{"name":"szmarczak","email":"sz.marczak@gmail.com"},"directories":{},"maintainers":[{"name":"szmarczak","email":"sz.marczak@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/resolve-alpn_1.2.1_1630311156553_0.3874047205312978"},"_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":1630311156687,"_cnpm_publish_time":1630311156687,"dist-tags":{"latest":"1.2.1"}}