Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dnt-connect

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dnt-connect

Node.JS library for DNT's single sign on service DNT Connect

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

DNT Connect

Build status NPM downloads NPM version Node version Dependency status

Node.JS library for DNT's single sign on service – DNT Connect. This README explains the technical implemetation of using DNT Connect in your Node application. For detaials on data returned through the API and various response codes see this document. Please contact opensource@turistforneingen.no if you are interested in using DNT Connect for your application in order to get an API key.

Requirements

Require Node.JS version >= 0.10.

Install

npm install dnt-connect --save

Usage

var Connect = require('dnt-connect');

New Client

var client = new Connect('myClientName', 'myBase64EncodedSecretKey');

Imortant! The key should be a base64 representation of your secret key in order for the dnt-connect package to decrypt the response from DNT Connect properly.

Bounce

Bounce is used to check if a user is currently authenticated with DNT Connect. The bounce url will bounce the user automaticly back to the provided redirect_url with user data if the user is authenticated.

var url = client.bounce('http://mysite.com/auth')

Signon

Signon is used to require a user to sign in with their DNT Connect user or register a new user. The user credentials will be sent to the redirect_url when the users is sucessfully authenticated.

var url = client.signon('http://mysite.com/auth')

Middleare

For your convenience we have provided a fully compatible Express.js middeware tha can bounce or do a full signon of your users. A full example can be found in here.

app.get('/connect', connect.middleware('signon'), function getAuth(req, res) {
  if (req.dntConnect.err) {
    res.status(500).json({error: err.message});
  } else {
    res.status(200).json({data: req.dntConnect.data});
  }
});

Decrypt Response

All data sent and recieved to and from DNT Connect is encrypted by 256 bit AES cipher in CBC mode. In order to read recieved data from DNT Connect your application needs to call #decrypt() wich will use your privat DNT Connect API key to decrypt and verify the data.

NB The return from the #decrypt() method is an Array with two elements in it; data and valid. The reason for this is because of Destructing assignments, new in ECMAScript 6.

try {
  var data = client.decrypt({data: queryData, hmac: queryHmac});
  if (data[1] === false) {
    console.log('Validation failed');
  } else {
    console.log('Decrypted data');
    console.log(data[0]);
  }
} catch (e) {
  // Decryption or serialization failed
}

MIT Licensed

Keywords

FAQs

Package last updated on 31 Aug 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc