bankid-api
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

API integration against BankId

Setup

const path = require("path");
const BankId = require("../lib/BankId").default;
 
const instance = new BankId(
  path.resolve(__dirname, "../cert/bankid-test.pfx"),
  path.resolve(__dirname, "../cert/bankid-test.crt"),
  "qwerty123",
);
 
//new requrement for v3
const ip = "192.168.1.1";

Authenticate

instance
  .authenticate(ip, { personalNumber: "190101014801" })
  .then((response) => {
    console.log("got order reference: ", response.orderRef);
    return instance.collect(response.orderRef, 1000, (status, hintCode) => {
      console.log("status, hintcode:", status, hintCode);
    });
  })
  .then((result) => {
    console.log("auth result: ", result);
  })
  .catch((e) => {
    console.log("something went wrong");
    console.error(e);
  });

Sign

instance
  .sign(ip, "This text will show", "This text is hidden", {
    personalNumber: "190101014801",
  })
  .then((response) => {
    console.log("got order reference: ", response.orderRef);
    return instance.collect(response.orderRef, 1000, (status, hintCode) => {
      console.log("status, hintcode:", status, hintCode);
    });
  })
  .then((result) => {
    console.log("sign result: ", result);
  })
  .catch((e) => {
    console.log("something went wrong");
    console.error(e);
  });

Cancel

instance
  .sign(ip, "This text will show", "This text is hidden", {
    personalNumber: "190101014801",
  })
  .then((response) => {
    console.log("got order reference: ", response.orderRef);
    return instance.cancel(response.orderRef);
  })
  .then((result) => {
    console.log("cancel result: ", result);
  })
  .catch((e) => {
    console.log("something went wrong");
    console.error(e);
  });

Package Sidebar

Install

npm i bankid-api

Weekly Downloads

0

Version

2.0.2

License

ISC

Unpacked Size

45.7 kB

Total Files

12

Last publish

Collaborators

  • richarddavison