UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

38 lines (37 loc) 1.6 kB
try { let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "d0118496-09f1-4a3e-8b57-cda8699b2863", e._sentryDebugIdIdentifier = "sentry-dbid-d0118496-09f1-4a3e-8b57-cda8699b2863"); } catch (e) {} var downloadFile = async (base64, filename) => { saveBlobAsFile(base64ToBlob(base64), filename); }; var base64ToBlob = (base64, mimeType = "application/octet-stream") => { const bytes = window.atob(base64); const amount = bytes.length; const byteArray = new Array(amount); for (let i = 0; i < amount; i += 1) byteArray[i] = bytes.charCodeAt(i); return new Blob([new Uint8Array(byteArray)], { type: mimeType }); }; /** * Utility to save Blob|File reference to disk as a new file * * @param fileData - * @param filename - */ var saveBlobAsFile = (fileData, filename) => { if ("msSaveBlob" in window.navigator && typeof window.navigator.msSaveBlob === "function") window.navigator.msSaveBlob(fileData, filename); else { const blobUrl = window.URL.createObjectURL(fileData); const link = document.createElement("a"); link.style.display = "none"; link.href = blobUrl; link.setAttribute("download", filename); if (typeof link.download === "undefined") link.setAttribute("target", "_blank"); document.body.appendChild(link); link.click(); document.body.removeChild(link); window.URL.revokeObjectURL(blobUrl); } }; //#endregion export { downloadFile as t };