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

@cz-nic/mojeid-connect

v2.0.0

Published

MojeID LITE Connection library

Downloads

1

Readme

build status

MojeID LITE Connect library

The javascript library MojeID LITE (or mojeID Connect) allows loading myID data into a client-side web page using the OpenID Connect protocol.

This functionality can be used, for example, to easily pre-fill the web form with the details of a user who has an active mojeID account.

Description of the library (in Czech) can be found on the page 4.1.11. Knihovna MojeID LITE.

Installation

Install package from npm:

npm install @cz-nic/mojeid-connect

Try the package examples

The package contains examples that you can try immediately. Follow instructions:

Create symlinks to the distributed library and node modules:

ln -s ../../../ node_modules/@cz-nic/mojeid-connect/examples/node_modules
ln -s ../dist node_modules/@cz-nic/mojeid-connect/examples/dist

Data transfer between provider and client is possible only via https protocol. You must have your own web server communicating over HTTPS.

Install your own testing local web server:

npm install http-server

To test over secure layer HTTPS on your localhost, you must first generate your own certificate. Generate self signed certificate for your localhost. Files cert.pem and key.pem are created.

Create self signed SSL certificate:

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -nodes -subj "/CN=localhost"

Run web server under HTTPS protocol on your localhost on a port 8000:

node_modules/http-server/bin/http-server ./node_modules/@cz-nic/mojeid-connect/examples/ --ssl --cert cert.pem --key key.pem -p 8000

Test package examples on your local web:

Open your browser and enter the url: https://localhost:8000/. Skip warning "Your connection is not private" by clicking to button "Advanced settings" and "Continue to localhost (unreliable)". This is caused by self signed certificate, that you have created.

Now you can test prefill form on prepared examples.

Usage in your project

Check the examples in the folder node_modules/@cz-nic/mojeid-connect/examples/. The simplest example is:

<!DOCTYPE html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>The simplest example</title>
  <script src="/dist/mojeid_connect.2.0.0.js" id="mojeid-connect-script"
    data-jsrsasign="/node_modules/jsrsasign/lib/jsrsasign-all-min.js"></script>
  <script>
    mojeID = mojeid_connect.createMojeidConnect({
      clientName: "The simplest example",
      runRegisterInsideListener: 'DOMContentLoaded',
      claims: [
          'family_name',
          'given_name',
          'nickname',
          'email',
          'phone_number',
          'address',
          'birthdate',
          'gender',
          'website',
          'profile'
      ]
    });
  </script>
 </head>
 <body>
  <h1>The simplest</h1>
  <form>
   <div><label>Name:</label><input type="text" id="given_name"/></div>
   <div><label>Family name:</label><input type="text" id="family_name"/></div>
   <div><label>Phone:</label><input type="text" id="phone_number"/></div>
   <div><label>Email:</label><input type="text" id="email"/></div>
   <div><label>Address:</label><textarea cols="25" rows="5" id="address"></textarea></div>
   <div><label>Birth date:</label><input type="text" id="birthdate"/></div>
   <div><label>Gender:</label><input type="text" id="gender"/></div>
   <div><label>Nickname:</label><input type="text" id="nickname"/></div>
   <div><label>Website:</label><input type="text" id="website"/></div>
   <div><label>Personal profile:</label><input type="text" id="profile"/></div>
  </form>
  <div class="button-frame">
      <button id="button-prefill" onclick="mojeID.requestAuthentication()">Pre-fill by mojeID</button>
  </div>
 </body>
</html>

Testing directly from the git project

Download the project:

git clone https://github.com/CZ-NIC/mojeid-connect-js.git

Install npm environment:

npm install

Run tests:

npm run test

Run code coverage:

npm run test-coverage

Compile the library. Files are compiled into the ./dist folder.

npm run build

Create certificate as it is described in Create self signed SSL certificate. Create symlinks to the distributed library and node modules (only once) and run server:

ln -s ../node_modules examples/node_modules
ln -s ../dist examples/dist

node_modules/http-server/bin/http-server ./examples/ --ssl --cert cert.pem --key key.pem -p 8000

Written by: Zdeněk Böhm, 26. 9. 2019