{"name":"resolve-alpn","version":"1.1.2","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":"43a065f747bc32728af4e2529d1ee5a61a29c63e","_id":"resolve-alpn@1.1.2","_nodeVersion":"15.10.0","_npmVersion":"7.5.3","dist":{"integrity":"sha512-8OyfzhAtA32LVUsJSke3auIyINcwdh5l3cvYKdKO0nvsYSKuiLfTM5i78PJswFPT8y6cPW+L1v6/hE95chcpDA==","shasum":"30b60cfbb0c0b8dc897940fe13fe255afcdd4d28","tarball":"http://registry-npm.ywwl.com/resolve-alpn/download/resolve-alpn-1.1.2.tgz","fileCount":4,"unpackedSize":4059,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeHJnCRA9TVsSAnZWagAAyo0P/jMJL2LfNQsM4cBGBU/9\ndHz6mgZKY2hmRq1yoYTWQslfw451xtxCp6hMHgIBhS890Y/0sF0i9sP/Pc3e\nyvNqzB9HoJR8JyXN29aJBOW6ZyWNs78jqZ3l5AX8lUa1/ePHdfKpm/jqGK41\n+8to7WHDtPAZsgzAqEf/rUyBXF72Jclenn50cmeBSCa0wq3hccv+/E4JV6jr\nekp6iSeqj9x0/OuU9a9vs0miDQLHc1TYSz8S6+QE7mguhciEbtoMJs/XJG9y\niKix/hdtvljwFOOtxdUUI78EXPNK53QLy5WgeaHTD8h7ODie0l+UMv8IXVx/\nLd27Ikn2HDG+fhdZpfH2TEC51ceE7xUf4WpUlGXAiQIcNVbZZxvW9zow02pg\nbZrfuEystNU/39jXTiINAQ5llcV43MBeeI43Jx8QzMfn00u8Jw2799+md9Mz\nuBwCDlohpqLz203DGX4TAS1KfzSqvAUX4ot4tnxqyRuDgffz3CbgY/28fz3K\ncEdgsVR0JV3R48vUnHophCF/ELLTJB8UTiSpQCUmi3pLRQE7jvvZLLL0An06\njK1V0jx/9kB0JjkGDVspTCAf7fDaMRg50di9tp72cIp681pNmhNQyREGkfW4\npz5EVGBgFrzUbhqbRWcwxyTqCM7NrI/VaowB5w8ouX9b7HSmtPVWbqKMzYgB\nb1n9\r\n=DjEN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIClq8rjOMB0zLUF+JLm4rrya/OhCqd3ggV77GumXmnpqAiEA3Xe9DbGTuvajLlqw/c4OMGbFwDCvPpeHAGVzf3Am0Zc="}],"size":2040,"noattachment":false,"key":"/resolve-alpn/-/resolve-alpn-1.1.2.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.1.2_1618506342776_0.3621364652688188"},"_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":1618506342944,"_cnpm_publish_time":1618506342944,"dist-tags":{"latest":"1.2.1"}}