Comments (5)
Hi @swimand
You could use the following code snippet at your end to generate qr code
import { createHmac } from "node:crypto";
type QrCache = {
startTime: number;
qrStartToken: string;
qrStartSecret: string;
};
const cache = new Map<string, QrCache>();
/**
* get the first animated qr and store important values in cache
**/
async function startQr(
qrStartSecret: string,
qrStartToken: string,
orderRef: string
) {
const now = Date.now();
const qrStore = { startTime: now, qrStartSecret, qrStartToken };
cache.set(orderRef, qrStore);
return this.generateQr({ ...qrStore, time: 0 });
}
/**
* generate next animated qr based on time and values in cache
**/
async function nextQr(orderRef: string) {
const qr = cache.get(orderRef);
if (!qr) {
return;
}
const qrTime = parseInt(`${(Date.now() - qr.startTime) / 1000}`, 10);
return generateQr(qr.qrStartSecret, qr.qrStartToken, qrTime);
}
function generateQr(qrStartSecret: string, qrStartToken: string, time: number) {
const qrAuthCode = createHmac("sha256", qrStartSecret)
.update(`${time}`)
.digest("hex");
return `bankid.${qrStartToken}.${time}.${qrAuthCode}`;
}
Here
first you would call startQr
and subsequently call nextQr
The support for this doesnt exist today in the library but if you have time feel free to raise a PR
from bankid.
Brilliant, thank you for the code snippet! Will definitely help en QR code generation 👍
from bankid.
The deadline for mandatory QR-code is drawing near, is there a complete example showing show to implement a full BankdID integration using QR-code? Or is the above code the most complete we have?
Thanks for all your work!
from bankid.
I generated a QR code on the FE instead, so i simply send the data and the other necessary items there.
I am using this library to generate the image:
https://www.npmjs.com/package/qrcode
from bankid.
The work on the v6 client (#57) includes a QrGenerator
class (see src/qrgenerator.ts). I believe that qualifies as "QR support" and is enough to close this issue.
from bankid.
Related Issues (20)
- TypeError: fs.readFileSync is not a function on initiating new BankId instance in React app HOT 2
- Documentation for authenticateAndCollect inconsistent
- Not Receiving qrStartToken and qrStartSecret HOT 2
- invalidParameters HOT 8
- Add support for Markdown formatting (userVisibleDataFormat) HOT 2
- ca & pfx types don't match runtime validation HOT 2
- Help acces
- Hey check this out. I found this Spy Bug Detector usefull
- Help
- Stop interval-timer when error thrown HOT 2
- Can you specify a timeout? HOT 2
- Unsupported HOT 5
- Ability to configure baseUrl for v6
- This library requires legacy openssl support HOT 3
- Support of `userVisibleData` and `userVisibleDataFormat` to `.authenticate`? HOT 5
- awaitPendingCollect
- Cancel and awaitPendingCollect
- V6 Client support for /phone/auth
- Test cert expired
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bankid.