@polyguard/sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.js +15 -1
- package/package.json +1 -1
- package/src/PolyguardWebsocketClientImpl.js +22 -2
package/dist/sdk.js
CHANGED
|
@@ -11515,7 +11515,21 @@
|
|
|
11515
11515
|
} else if (data && data.qr_url) {
|
|
11516
11516
|
console.log("qr_url", data.qr_url);
|
|
11517
11517
|
const qrDiv = modal.querySelector("#polyguard-qr");
|
|
11518
|
-
if (qrDiv)
|
|
11518
|
+
if (!qrDiv) return;
|
|
11519
|
+
const isMobile = /Mobi|Android/i.test(navigator.userAgent);
|
|
11520
|
+
if (isMobile) {
|
|
11521
|
+
qrDiv.innerHTML = `<button id="polyguard-open-app-button" style="background: #7be7c2; color: #222; font-weight: 600; border-radius: 8px; border: none; padding: 10px 32px; font-size: 16px; cursor: pointer;">Open Polyguard App</button>`;
|
|
11522
|
+
qrDiv.style.background = "transparent";
|
|
11523
|
+
qrDiv.querySelector("#polyguard-open-app-button").onclick = () => window.location.assign(data.qr_url);
|
|
11524
|
+
const instructionText = qrDiv.nextElementSibling;
|
|
11525
|
+
if (instructionText) {
|
|
11526
|
+
instructionText.textContent = "Tap the button to verify with the Polyguard app.";
|
|
11527
|
+
}
|
|
11528
|
+
const instructionList = instructionText.nextElementSibling;
|
|
11529
|
+
if (instructionList && instructionList.children[1]) {
|
|
11530
|
+
instructionList.children[1].textContent = "If you do not have the Polyguard app, you will be redirected to download it.";
|
|
11531
|
+
}
|
|
11532
|
+
} else {
|
|
11519
11533
|
import_qrcode.default.toString(data.qr_url, { type: "svg" }, (err, svg) => {
|
|
11520
11534
|
if (!err) qrDiv.innerHTML = svg;
|
|
11521
11535
|
});
|
package/package.json
CHANGED
|
@@ -128,9 +128,29 @@ export class PolyguardWebsocketClientImpl {
|
|
|
128
128
|
return;
|
|
129
129
|
} else if (data && data.qr_url) {
|
|
130
130
|
console.log('qr_url', data.qr_url);
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
const qrDiv = modal.querySelector('#polyguard-qr');
|
|
133
|
-
if (qrDiv)
|
|
133
|
+
if (!qrDiv) return;
|
|
134
|
+
|
|
135
|
+
const isMobile = /Mobi|Android/i.test(navigator.userAgent);
|
|
136
|
+
|
|
137
|
+
if (isMobile) {
|
|
138
|
+
// For mobile, display a button to open the app
|
|
139
|
+
qrDiv.innerHTML = `<button id="polyguard-open-app-button" style="background: #7be7c2; color: #222; font-weight: 600; border-radius: 8px; border: none; padding: 10px 32px; font-size: 16px; cursor: pointer;">Open Polyguard App</button>`;
|
|
140
|
+
qrDiv.style.background = 'transparent';
|
|
141
|
+
qrDiv.querySelector('#polyguard-open-app-button').onclick = () => window.location.assign(data.qr_url);
|
|
142
|
+
|
|
143
|
+
// Update surrounding text
|
|
144
|
+
const instructionText = qrDiv.nextElementSibling;
|
|
145
|
+
if (instructionText) {
|
|
146
|
+
instructionText.textContent = 'Tap the button to verify with the Polyguard app.';
|
|
147
|
+
}
|
|
148
|
+
const instructionList = instructionText.nextElementSibling;
|
|
149
|
+
if (instructionList && instructionList.children[1]) {
|
|
150
|
+
instructionList.children[1].textContent = 'If you do not have the Polyguard app, you will be redirected to download it.';
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
// For desktop, display the QR code
|
|
134
154
|
QRCode.toString(data.qr_url, { type: 'svg' }, (err, svg) => {
|
|
135
155
|
if (!err) qrDiv.innerHTML = svg;
|
|
136
156
|
});
|