npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-pinnedhttps

v0.1.0

Published

A Cordova plugin allowing you to make https requests, with (fingerprint-based) certificate pinning

Downloads

448

Readme

cordova-plugin-pinnedhttps

A phonegap plugin that will allow you to make HTTPS requests with certificate fingerprint verification

Installation

phonegap plugin add cordova-plugin-pinnedhttps

Usage

This plugin compiles and has been tested as part of an other project (a cordova app).

NOTE: This plugin doesn't follow HTTP redirections

/*
The `fingerprints` parameter must either be a string or an array of
strings; each string must be an SHA1 or SHA256 hash. (SHA1 and SHA256 cannot
be mixed)

When the plugins check the identity of a host, it first checks the fingerprint of the last certificate in the chain. If it doesn't match, goes up the chain and checks the certificate above it. The process can repeat up to the root certificate.

This allows you check either for a specific certificate, or a certificate authority that you trust.

Note that some sites use multiple certificates (on the same hostname), and some others use cross-signed certificates. These cases might trigger "INVALID_CERT" errors
 */
var https = new navigator.httpsBuilder(fingerprints);

https.get('https://yoursite.tld/yourpath', function(err, res){
	if (err){
		//Handle errors here. err is a string
		if (err == 'INVALID_CERT'){
			//Certificate found on server doesn't match the provided fingerprint
		} else {
			//Other kinds of connection errors. Error messages are listed below
		}
	} else {
		res.statusCode //Number
		res.headers //Object
		res.body //String
	}
});

var reqOptions = {method:'post', host:'yoursite.tld', path: '/yourpath', [port: 443], [headers: {header1: 'value1', header2: 'value2'}], [body: {}]};

https.request(reqOptions, function(err, res){
	if (err){
		//Handle errors here. err is a string
		if (err == 'INVALID_CERT'){
			//Certificate found on server doesn't match the provided fingerprint
		} else {
			//Other kinds of connection errors. Error messages are listed below
		}
	} else {
		res.statusCode //Number
		res.headers //Object
		res.body //String
	}
});

NOTE : With https.request, if returnBuffer is defined in the reqOptions, then res.body will be returned as an Uint8Array

List of error messages

Error message | Meaning ----------------|------------------------------------ INVALID_PARAMS| Invalid parameters INVALID_URL | Invalid URL INVALID_METHOD| Invalid HTTP method INVALID_HEADERS| Invalid options.headers parameter INVALID_BODY | Invalid options.body parameter INVALID_CERT | Invalid certificate found on server CANT_CONNECT | Can't connect to the server TIMEOUT | Connection timeout INTERNAL_ERROR| Internal error

Testing

  1. Create a Cordova/Phonegap application
  2. Add the iOS and/or the Android platforms
  3. Add the testing framework and bind its page as the main page of the app
  4. Add this plugin
  5. Add this plugin's test cases, by adding the plugin located in the tests folder
	cordova plugin add https://github.com/LockateMe/cordova-plugin-pinnedhttps.git#:/tests

License

This plugin is distributed under the terms of the MIT license.