Skip to content

Commit

Permalink
FIX examples & update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pepf committed Sep 7, 2023
1 parent 1065258 commit 15f80f0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion examples/v6-qrcode-customcache.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion examples/v6-qrcode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 15f80f0

Please sign in to comment.