Socket
Socket
Sign inDemoInstall

rec-la

Package Overview
Dependencies
63
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rec-la

SSL cert for HTTPS loopback


Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

rec-la

Loopback domain and SSL certs.

https://<any hostname>.rec.la/ => https://localhost/

<any hostname>.rec.la points to localhost

Exception: www.rec.la, a page to download the certificates.

Why ?

At Pryv we often have to locally develop web applications that intensively use AJAX REST requests.

Browsers inforce Same-Origin Policy mechanism that restricts resources being loaded from another origin. This can be allowed, by sending correct Cross-Origin Resource Sharing (CORS) headers.

Making requests to HTTPS APIs from HTTP sites on localhost would not be possible without changing security options on your browser.

This is why we refurbished a domain and its SSL certs to a full loopback domain, se developpers cann benefit from a loopback signed Certificate.

Update

From rec-la v0.2.* certificates are not shipped with the npm package, but downloaded and updated regularly from www.rec.la.

Certificates will be checked and eventually refreshed at install and each time the packages is loaded.

You can update the certs manually with npm run update

Note: If the certificates are outdated and loaded synchronously with require('rec-la').httpsOptions(); They will be updated and the service stoped, so it can be rebooted manually.

Usage

Command line

NPMInstaled with -g
Launch a webservernpm run webserver <directory> [port]rec-la <directory> [port]
Launch a proxynpm run proxy <host>:<port> <port>rec-la-proxy <host>:<port> <port>
Update certsnpm run updaterec-la-update

ANY

Just use the certificates in certs/ or from www.rec.la for any usage

Files:

  • rec.la-cert.crt : The certificate
  • rec.la-key.pem : The key
  • rec.la-ca.pem : Certificate of the authority
  • rec.la-bundle.crt : Bundle of key + ca
  • pack.json : All this packed in a json file

From a node app

Execute: npm install rec-la --save

Pure node:
var https = require('https');

var options = require('rec-la').httpsOptions();

https.createServer(options, (req, res) => {
  res.writeHead(200);
  res.end('hello world\n');
}).listen(8443);
or (check and update before):
var https = require('https');

var httpsOptionsAsync = require('rec-la').httpsOptionsAsync;

httpsOptionsAsync(function (err, httpsOptions) {
  https.createServer(httpsOptions, (req, res) => {
    res.writeHead(200);
    res.end('hello world\n');
  }).listen(8443);
});
Express:
var https = require('https');
var express = require('express');
var app = express();

//...... Your code ....

var httpsOptionsAsync = require('../nodejs-hook').httpsOptionsAsync;

httpsOptionsAsync(function (err, httpsOptions) {
	https.createServer(httpsOptions, app).listen(8443);
}

Vue.js:

Enable local https for Vue.js development

const recLaOptions = require('rec-la').httpsOptions();
recLaOptions.https = true;
recLaOptions.host = 'l.rec.la';

module.exports = {
  // your options
  // ...
  devServer: recLaOptions
};

Now vue-cli-service serve will be served under https://l.rec.la

WebServer

For your convenience we provide a small node.js server building.

Install: npm install
Run: node webserver/main.js <path> [port]

Or install for command line usage with npm install rec-la -g
Then you can call directly $ rec-la <path> [port]

Proxy

You can also use it as a reverse proxy to convert https => http calls.

Examples:

  • from the repository npm run proxy localhost:3000 to proxy https://l.rec.la:4443 => http://localhost:3000
  • If install with npm install rec-la -g, do $ rec-la-proxy <hostname>:[port] [local port]

Keywords

FAQs

Last updated on 22 Oct 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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