diff --git a/.gitignore b/.gitignore index c06230a..2b01b9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ # OS specific .DS_Store +# IDE +.vscode +.idea + # Build directory lib @@ -37,9 +41,6 @@ build/Release node_modules jspm_packages -# -*package-lock.json - # Optional npm cache directory .npm diff --git a/README.md b/README.md index f2031f1..47e2375 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,32 @@ npm install --save bankid yarn install bankid ``` -## Usage +## Usage V6 + +```javascript +import { BankIdClientV6 } from "bankid"; + +const client = new BankIdClientV6({ + production: false, +}); + +const { autoStartToken, orderRef } = await client.authenticate({ + endUserIp: "127.0.0.1", +}); + +// Generate deep link from autoStarttoken and try to open BankID app +// See ./examples + +client + .awaitPendingCollect(orderRef) + .then(res => { + console.log(res.completionData) + }) + +``` +Acting on a session is done trough opening the app or trough scanning a QR Code, both examples are documented in detail [in the examples directory](./examples) + +## Usage V5 ```javascript import { BankIdClient } from "bankid"; diff --git a/examples/auth-simple.mjs b/examples/auth-simple.mjs index 548ce96..4c1740c 100644 --- a/examples/auth-simple.mjs +++ b/examples/auth-simple.mjs @@ -1,9 +1,9 @@ -import {BankIdClient} from "../lib/bankid.js"; +import { BankIdClient } from "../lib/bankid.js"; const personalNumber = process.argv[2]; -const bankid = new BankIdClient({production: false}); +const bankid = new BankIdClient({ production: false }); bankid - .authenticateAndCollect({endUserIp: "127.0.0.1", personalNumber}) + .authenticateAndCollect({ endUserIp: "127.0.0.1", personalNumber }) .then(res => console.log(res.completionData.user)) .catch(err => console.error(err)); diff --git a/examples/cancel.mjs b/examples/cancel.mjs index ec54804..1d306af 100644 --- a/examples/cancel.mjs +++ b/examples/cancel.mjs @@ -1,12 +1,15 @@ -import {BankIdClient} from "../lib/bankid.js"; +import { BankIdClient } from "../lib/bankid.js"; const personalNumber = process.argv[2]; -const bankid = new BankIdClient({production: false}); +const bankid = new BankIdClient({ production: false }); async function testCancelation() { - const { orderRef } = await bankid.authenticate({endUserIp: "127.0.0.1", personalNumber}); + const { orderRef } = await bankid.authenticate({ + endUserIp: "127.0.0.1", + personalNumber, + }); await bankid - .cancel({orderRef}) + .cancel({ orderRef }) .then(() => console.log("success")) .catch(console.error); } diff --git a/examples/collect.mjs b/examples/collect.mjs index d41ff60..a2e81fc 100644 --- a/examples/collect.mjs +++ b/examples/collect.mjs @@ -1,16 +1,21 @@ -import {BankIdClient} from "../lib/bankid.js"; +import { BankIdClient } from "../lib/bankid.js"; const personalNumber = process.argv[2]; -const bankid = new BankIdClient({production: false}); +const bankid = new BankIdClient({ production: false }); bankid - .sign({endUserIp: "127.0.0.1", personalNumber, userVisibleData: "visible", userNonVisibleData: "invisible"}) + .sign({ + endUserIp: "127.0.0.1", + personalNumber, + userVisibleData: "visible", + userNonVisibleData: "invisible", + }) .then(res => { const timer = setInterval(() => { const done = () => clearInterval(timer); bankid - .collect({orderRef: res.orderRef}) + .collect({ orderRef: res.orderRef }) .then(res => { console.log(res.status); diff --git a/examples/index.html b/examples/index.html new file mode 100644 index 0000000..9bfb134 --- /dev/null +++ b/examples/index.html @@ -0,0 +1,20 @@ + +
+