Socket
Socket
Sign inDemoInstall

resolve-alpn

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

.github/workflows/nodejs.yml

7

index.js

@@ -16,2 +16,9 @@ 'use strict';

socket.on('error', reject);
socket.once('timeout', async () => {
socket.off('error', reject);
resolve({alpnProtocol: undefined, socket});
await Promise.resolve();
socket.emit('timeout');
});
});

16

package.json
{
"name": "resolve-alpn",
"version": "1.0.0",
"version": "1.0.1",
"description": "Detects the ALPN protocol",
"main": "index.js",
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
"test": "xo && nyc --reporter=lcovonly --reporter=text --reporter=html ava"
},

@@ -16,2 +15,4 @@ "repository": {

"alpn",
"tls",
"socket",
"http2"

@@ -26,8 +27,7 @@ ],

"devDependencies": {
"ava": "^1.0.1",
"coveralls": "^3.0.2",
"nyc": "^13.1.0",
"pem": "^1.13.2",
"xo": "^0.23.0"
"ava": "^3.15.0",
"nyc": "^15.1.0",
"pem": "1.14.3",
"xo": "^0.38.2"
}
}
# `resolve-alpn`
[![Build Status](https://travis-ci.org/szmarczak/resolve-alpn.svg?branch=master)](https://travis-ci.org/szmarczak/resolve-alpn) [![Coverage Status](https://coveralls.io/repos/github/szmarczak/resolve-alpn/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/resolve-alpn?branch=master)
[![Node CI](https://github.com/szmarczak/resolve-alpn/workflows/Node%20CI/badge.svg)](https://github.com/szmarczak/resolve-alpn/actions)
[![codecov](https://codecov.io/gh/szmarczak/resolve-alpn/branch/master/graph/badge.svg)](https://codecov.io/gh/szmarczak/resolve-alpn)

@@ -14,3 +15,5 @@ ## API

host: 'nghttp2.org',
ALPNProtocols: ['h2', 'http/1.1']
port: 443,
ALPNProtocols: ['h2', 'http/1.1'],
servername: 'nghttp2.org'
});

@@ -21,2 +24,4 @@

**Note:** While the `servername` option is not required in this case, many other servers do. It's best practice to set it anyway.
#### options

@@ -34,3 +39,5 @@

host: 'nghttp2.org',
port: 443,
ALPNProtocols: ['h2', 'http/1.1'],
servername: 'nghttp2.org',
resolveSocket: true

@@ -41,4 +48,4 @@ });

// Remember to close the socket!
result.socket.end();
// Remember to destroy the socket if you don't use it!
result.socket.destroy();
```

@@ -45,0 +52,0 @@

@@ -1,9 +0,9 @@

import http2 from 'http2';
import tls from 'tls';
import util from 'util';
import test from 'ava';
import pem from 'pem';
import resolveALPN from '.';
const http2 = require('http2');
const tls = require('tls');
const {promisify} = require('util');
const test = require('ava');
const pem = require('pem');
const resolveALPN = require('.');
const createCertificate = util.promisify(pem.createCertificate);
const createCertificate = promisify(pem.createCertificate);

@@ -37,4 +37,4 @@ const createServer = async () => {

s.listen = util.promisify(s.listen);
s.close = util.promisify(s.close);
s.listen = promisify(s.listen);
s.close = promisify(s.close);

@@ -85,3 +85,30 @@ s.options = {

test('empty options', async t => {
await t.throwsAsync(() => resolveALPN(), {code: 'ECONNREFUSED'});
const error = await t.throwsAsync(() => resolveALPN());
const {code} = error;
t.true(code === 'ECONNREFUSED' || code === 'ERR_MISSING_ARGS' || code === 'EADDRNOTAVAIL', error.stack);
});
test('works with timeout', async t => {
t.timeout(100);
const {socket} = await resolveALPN({
host: '123.123.123.123',
port: 443,
ALPNProtocols: ['h2'],
timeout: 1
});
await new Promise((resolve, reject) => {
socket.once('error', error => {
reject(error);
t.fail(error);
});
socket.once('timeout', resolve);
});
socket.destroy();
t.pass();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc