@microblink/photopay-in-browser-sdk
Version:
A simple payment barcode scanning library for WebAssembly-enabled browsers.
42 lines (41 loc) • 1.21 kB
JavaScript
/**
* Copyright (c) Microblink Ltd. All rights reserved.
*/
import * as PhotoPaySDK from "../../../es/photopay-sdk";
export function hasVideoDevices() {
return new Promise((resolve) => {
if (!window.navigator ||
!window.navigator.mediaDevices ||
typeof window.navigator.mediaDevices.enumerateDevices !== 'function') {
resolve(false);
return;
}
window.navigator.mediaDevices.enumerateDevices().then((devices) => {
devices = devices || [];
for (const device of devices) {
if (device && device.kind === 'videoinput') {
resolve(true);
return;
}
}
resolve(false);
});
});
}
export function isWasmSupported() {
return new Promise((resolve) => {
const wasmSupport = PhotoPaySDK.isBrowserSupported();
resolve(wasmSupport);
});
}
export async function checkMandatoryCapabilites() {
const wasmSupport = await isWasmSupported();
return wasmSupport;
}
/**
* Determine whether this is a desktop device based on the screen resolution.
*/
export function isDesktop() {
const viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
return viewportWidth >= 1024;
}