diff --git a/README.md b/README.md index a2474ba..0ff4670 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/v6-qrcode-customcache.mjs b/examples/v6-qrcode-customcache.mjs index 3663da9..d966cb6 100644 --- a/examples/v6-qrcode-customcache.mjs +++ b/examples/v6-qrcode-customcache.mjs @@ -45,7 +45,7 @@ const main = async () => { let success = false; // Generate new QR code for 20 seconds, check status of the order on each cycle - for (const newQrCode of qr.nextQr(orderRef, { timeout: 20 })) { + for await (const newQrCode of qr.nextQr(orderRef, { timeout: 20 })) { tryOpenQRCodeInBrowser(newQrCode); const resp = await bankid.collect({ orderRef }); console.log({ orderRef, newQrCode }); diff --git a/examples/v6-qrcode.mjs b/examples/v6-qrcode.mjs index a92db5f..e426139 100644 --- a/examples/v6-qrcode.mjs +++ b/examples/v6-qrcode.mjs @@ -30,7 +30,7 @@ const main = async () => { let success = false; // Generate new QR code for 20 seconds, check status of the order on each cycle - for (const newQrCode of qr.nextQr(orderRef, { timeout: 20 })) { + for await (const newQrCode of qr.nextQr(orderRef, { timeout: 20 })) { tryOpenQRCodeInBrowser(newQrCode); const resp = await bankid.collect({ orderRef }); if (resp.status === "complete") {