@qonto/embed-sdk 0.23.0 → 0.23.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/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const t=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!t.hasAccessToken())throw new a;return t.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},m={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};var f=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:m,MFA_METHODS:l,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"}});class g{constructor(){this.mfaPreference=l.PASSKEY,this.debugMode=!1}static getInstance(){return g.instance||(g.instance=new g),g.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const p=g.getInstance(),h="https://embed.qonto.com",y="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",_={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,n=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(n)?n:u.SANDBOX}static getInstance(){return I.instance||(I.instance=new I),I.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return _.production;{const e=_[this.environment];return Object.entries(e).reduce(((e,[n,t])=>({...e,[n]:t.replace("{branch}",`-${this.branch}`)})),{})}}}const w=I.getInstance(),b={requiresUI:!1};function E(e,{requiresUI:n}=b){const t=e?.uiParentElementId||p.getUIParentElementId();if(n&&!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=e?.mfaPreference||p.getMFAPreference();if(i){const e=(a=Object.values(l),w.isProductionEnvironment()?a.filter((e=>e!==l.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(w.isProductionEnvironment()&&i===l.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var a;const r=e?.debugMode||p.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||p.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:t,mfaPreference:i,debugMode:r,proxyRequestFunction:o,...e}}const A=Object.values(m);function k(e){if(!function(e){return A.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${A.join(", ")}.`);return e}function R(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&E(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&k(e.locale),e}class S{constructor(){this.currentLocale="en"}static getInstance(){return S.instance||(S.instance=new S),S.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const P=S.getInstance();const L={initialize:function(e){const{accessToken:n,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=R(e);n&&t.setAccessToken(n),i&&t.setStagingToken(i),o&&P.setLocale(o),a&&p.setSettings(a),r&&(w.setEnvironment(r),s&&w.setBranch(s))},logout:function(){t.clearAccessToken(),t.clearStagingToken(),P.setDefaultLocale()},constants:f},{initialize:v,logout:D,constants:O}=L;class N extends i{constructor(e){super();const n=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${n}`}}function U(){return"undefined"!=typeof window&&"undefined"!=typeof document}function C(){return!U()}function $({accessToken:e,stagingToken:n,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=n||t.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",P.getLocale()),r}function M(e){const n={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},t=JSON.stringify(n);return i=t,C()?Buffer.from(i).toString("base64"):btoa(i);var i}function F(e){return JSON.parse((n=e,C()?Buffer.from(n,"base64").toString("utf-8"):atob(n)));var n}var B;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(B||(B={}));const q={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var j,x;function Y(e,n){const t=n.filter((n=>n.requiredIfPresent?!e[n.name]&&e[n.requiredIfPresent]:void 0===e[n.name])).map((e=>e.name));if(t.length>0)throw new s(t.map((e=>`Missing required parameter: ${e}`)))}function G(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function H(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function K(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(j||(j={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(x||(x={}));const z=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],V=[...z,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function X(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Y(e,z),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(l),g=G({membershipId:n,organizationId:t,bankAccountId:i}),p=H({hasDailyLimit:a,hasTransactionLimit:r}),h=K({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=Q(u),T=J(m),_=[...f,...g,...p,...h,...y,...T];if(_.length>0)throw new s(_)}(e),e}(e):function(e){Y(e,V),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:y,hasAtmDailyLimit:T,atmDailyLimit:_,atmMonthlyLimit:I,address:w,cardDesign:b,typeOfPrint:E}=e,A=function(e){return Object.values(x).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(l),k=function(e){const n=null!=e&&"string"!=typeof e,t=!["print","embossed",void 0,null].includes(e);return n||t?['typeOfPrint must be one of "print", "embossed" or null']:[]}(E),R=G({membershipId:n,organizationId:t,bankAccountId:i}),S=H({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:T,shipToBusiness:h}),P=K({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:I}),L=Q(u),v=J(m),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,n){if(n)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(w,h),N=[...A,...R,...S,...P,...L,...v,...k,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function Q(e){const n=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&n?["activeDays must be an array of integers between 1 and 7"]:[]}function J(e){const n=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&n?["categories must be an array of strings"]:[]}class W extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const Z=[];for(let e=0;e<256;++e)Z.push((e+256).toString(16).slice(1));let ee;const ne=new Uint8Array(16);var te={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ie(e,n,t){if(te.randomUUID&&!e)return te.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!ee){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ee=crypto.getRandomValues.bind(crypto)}return ee(ne)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(Z[e[n+0]]+Z[e[n+1]]+Z[e[n+2]]+Z[e[n+3]]+"-"+Z[e[n+4]]+Z[e[n+5]]+"-"+Z[e[n+6]]+Z[e[n+7]]+"-"+Z[e[n+8]]+Z[e[n+9]]+"-"+Z[e[n+10]]+Z[e[n+11]]+Z[e[n+12]]+Z[e[n+13]]+Z[e[n+14]]+Z[e[n+15]]).toLowerCase()}(i)}class ae{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const n=new URL(e.iframeUrl);this.targetOrigin=`${n.protocol}//${n.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new W(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,n)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const t=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),n(new W(`Could not install the authentication UI because the timeout of ${t}ms was reached.\nPlease make sure the application can reach the Internet.`))}),t),a=n=>{n.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new W("Attempted to perform an Embed operation without having the authentication UI initialized."));const n=function({actionId:e,actionData:n}){const t=p.getMFAPreference();return{actionId:e,actionData:{...n,scaPreference:n.scaPreference||t,idempotencyKey:n.idempotencyKey||ie()}}}(e);return new Promise(((e,t)=>{const i=a=>{if(a.data?.actionId===n.actionId){if("error"===a.data.status)return this.removeMessageListener(n.actionId,i),t(new W(`An error occurred when performing the action ${n.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(n.actionId,i),e(a.data.payload)}};this.addMessageListener(n.actionId,i),this.iframe?.contentWindow?.postMessage(n,this.targetOrigin)}))}addMessageListener(e,n){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(n),window.addEventListener("message",n)}removeMessageListener(e,n){const t=this.messageListeners.get(e);if(t){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),window.removeEventListener("message",n))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function re({accessToken:e,stagingToken:n,locale:t,debugMode:i}){const a=i||!1,r=t||P.getLocale(),s=w.getEnvironmentUrls().IFRAME_URL,o=n?`;staging_token=${encodeURIComponent(n)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function se({parentElementId:e,iframeUrl:n}){return new ae({parentElementId:e,iframeUrl:n}).initialize()}function oe(e){return"virtual"===e.cardLevel?function(e){const n=de(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ie(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel}}}}}(e):function(e){const n=de(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ie(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ce(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function de(e){const n=Object.values(q);return(e||[]).filter((e=>n.includes(e)))}const ue={getCards:async function({membershipId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=w.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new N(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:t});return a.map((e=>ce(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:t});return ce(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});X(e.cardSettings);const s=re({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),o=await se({iframeUrl:s,parentElementId:i}),c=oe(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ce(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=G({cardId:e.cardId});if(n.length>0)throw new s(n)}(e.cardSettings);const o=re({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),d=await se({iframeUrl:o,parentElementId:i}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),m=await d.postMessage(u);return d.destroy(),ce(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:n,accessToken:t,stagingToken:i,debugMode:a,mfaPreference:o}=E(e.operationSettings,{requiresUI:!0}),c=t||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=G({cardId:e.cardId});if(n.length>0)throw new s(n);let t={};void 0!==e.allowPinReveal&&(t={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(t={...t,allowBlocking:e.allowBlocking});const i=H(t);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:n,stagingToken:t,mfaPreference:i}=e,a={method:"GET",headers:$({accessToken:n,stagingToken:t,mfaPreference:i})},r=w.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(!s.ok)throw o.errors?new N(o.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:u,allowBlocking:m}=e.cardSettings,l=function(e,n){const t=new URL(e);return"boolean"==typeof n.allowPinReveal&&t.searchParams.set("canSeePin",n.allowPinReveal.toString()),"boolean"==typeof n.allowBlocking&&t.searchParams.set("canBlock",n.allowBlocking.toString()),!0===n.debugMode&&t.searchParams.set("debug",n.debugMode.toString()),t.toString()}(d,{allowPinReveal:u,allowBlocking:m,debugMode:a}),f=await se({iframeUrl:l,parentElementId:n});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},me=ue;function le({endpointUrl:e,paginationSettings:n}){const t=new URL(e);return n?.page&&t.searchParams.set("page",n.page.toString()),n?.itemsPerPage&&t.searchParams.set("per_page",n.itemsPerPage.toString()),t}function fe(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function ge(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function pe(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const he="/v2/sepa/beneficiaries";async function ye({accessToken:e,stagingToken:n,beneficiaryId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}function Te({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${he}/${e.id}`,options:c}}async function _e({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=Te({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}),{beneficiary:s}=await async function({path:e,options:n}){const t=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,i=await fetch(t,{...n,headers:$(n.headers),body:JSON.stringify(n.body)}),a=await i.json();if(!i.ok)throw a.errors?new N(a.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${a.code}: ${a.detail}`);return a}(r);return s}const Ie=[{name:"name"},{name:"iban"}];const we={getBeneficiaries:async function(e){const n=e?.accessToken||r(),t=await async function({paginationSettings:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=le({endpointUrl:new URL(w.getEnvironmentUrls().THIRD_PARTY_API_URL+he),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=t.beneficiaries.map((e=>ge(e))),a=fe(t.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:n,stagingToken:t}){const i=n||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),ge(await ye({beneficiaryId:e,accessToken:i,stagingToken:t}))},addBeneficiary:async function({beneficiary:e,accessToken:n,stagingToken:t}){const i=n||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");Y(e,Ie);const n=G({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(n.length>0)throw new s(n)}(e);return ge(await async function({beneficiary:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:ie()}),body:JSON.stringify({beneficiary:pe(e)})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:t}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){const{id:n,name:t,email:i,activityTag:a}=e;if(!n)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!t&&!i&&!a)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=G({name:t,email:i,activityTag:a});if(r.length>0)throw new s(r);return{id:n,name:t,email:i,activityTag:a}}(e),{stagingToken:i,idempotencyKey:a,mfaPreference:o,proxyRequestFunction:c}=E(n),d={beneficiaryParamsBeingEdited:t,stagingToken:i,idempotencyKey:a,mfaPreference:o};if(c){const e=M(Te(d));return ge(F(await c(e)).body.beneficiary)}{const e=n?.accessToken||r();return ge(await _e({...d,accessToken:e}))}},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i=n||r();!function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings")}(e);return(await async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i={method:"PATCH",headers:$({accessToken:n,stagingToken:t}),body:JSON.stringify({ids:e})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:t})).map(ge)}},be="/v2/sepa/bulk_transfers";function Ee(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Ae(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function ke(e){const n=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:n,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}const Re="/v2/sepa/transfers";const Se=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Pe({sepaTransferSettings:e,operationSettings:n}){if(e?.beneficiary)return e.beneficiary;return ge(await ye({beneficiaryId:e?.beneficiaryId,accessToken:n?.accessToken,stagingToken:n?.stagingToken}))}const Le="browser",ve="server";class De extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Le:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case ve:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const Oe={getSepaTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),i=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=le({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),a=i.transfers.map(Ae),s=fe(i.meta);return{transfers:a,...s?{meta:s}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);return Ae(await async function({accessToken:e,stagingToken:n,sepaTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.transfer}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),o=n?.idempotencyKey||ie();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(Y(e,Se),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const n=[...G({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...K({amount:e.amount})].flat();if(n.length>0)throw new s(n);if(e.amount>3e4&&(!e.attachments||0===e.attachments.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u={...e,beneficiary:await Pe({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(u.beneficiary?.trusted)d=await async function({transfer:e,accessToken:n,stagingToken:t,idempotencyKey:i}){const a=ke(e),r={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new N(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:u,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if(!U())throw new De(Le);const{uiParentElementId:e,debugMode:t}=E(n,{requiresUI:!0});let r;try{const n=re({accessToken:i,stagingToken:a||void 0,debugMode:t});r=await se({iframeUrl:n,parentElementId:e});const s=ke(u);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return Ae(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}/${e}/cancel`,r=await fetch(a,i);if(204!==r.status){const e=await r.json();if(e.errors)throw new N(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken})},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),{stagingToken:i,paginationSettings:a}=E(n||{}),s=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=le({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${be}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:t,stagingToken:i,paginationSettings:a}),o=s.bulkTransfers?.map(Ee),c=fe(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),{stagingToken:i}=E(n||{}),a=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Ee(await async function({accessToken:e,stagingToken:n,bulkTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${be}/${t}`),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:t,stagingToken:i,bulkTransferId:a}))}}};e.beneficiaries=we,e.cards=me,e.constants=O,e.initialize=v,e.logout=D,e.sepaTransfers=Oe}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const t=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!t.hasAccessToken())throw new a;return t.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},m={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};var f=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:m,MFA_METHODS:l,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"}});class g{constructor(){this.mfaPreference=l.PASSKEY,this.debugMode=!1}static getInstance(){return g.instance||(g.instance=new g),g.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const p=g.getInstance(),h="https://embed.qonto.com",y="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",_={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,n=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(n)?n:u.SANDBOX}static getInstance(){return I.instance||(I.instance=new I),I.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return _.production;{const e=_[this.environment];return Object.entries(e).reduce(((e,[n,t])=>({...e,[n]:t.replace("{branch}",`-${this.branch}`)})),{})}}}const w=I.getInstance(),b={requiresUI:!1};function E(e,{requiresUI:n}=b){const t=e?.uiParentElementId||p.getUIParentElementId();if(n&&!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=e?.mfaPreference||p.getMFAPreference();if(i){const e=(a=Object.values(l),w.isProductionEnvironment()?a.filter((e=>e!==l.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(w.isProductionEnvironment()&&i===l.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var a;const r=e?.debugMode||p.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||p.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:t,mfaPreference:i,debugMode:r,proxyRequestFunction:o,...e}}const A=Object.values(m);function k(e){if(!function(e){return A.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${A.join(", ")}.`);return e}function R(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&E(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&k(e.locale),e}class S{constructor(){this.currentLocale="en"}static getInstance(){return S.instance||(S.instance=new S),S.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const P=S.getInstance();const L={initialize:function(e){const{accessToken:n,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=R(e);n&&t.setAccessToken(n),i&&t.setStagingToken(i),o&&P.setLocale(o),a&&p.setSettings(a),r&&(w.setEnvironment(r),s&&w.setBranch(s))},logout:function(){t.clearAccessToken(),t.clearStagingToken(),P.setDefaultLocale()},constants:f},{initialize:v,logout:D,constants:O}=L;class N extends i{constructor(e){super();const n=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${n}`}}function U(){return"undefined"!=typeof window&&"undefined"!=typeof document}function C(){return!U()}function $({accessToken:e,stagingToken:n,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=n||t.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",P.getLocale()),r}function M(e){const n={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},t=JSON.stringify(n);return i=t,C()?Buffer.from(i).toString("base64"):btoa(i);var i}function F(e){return JSON.parse((n=e,C()?Buffer.from(n,"base64").toString("utf-8"):atob(n)));var n}var B;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(B||(B={}));const q={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var j,x;function Y(e,n){const t=n.filter((n=>n.requiredIfPresent?!e[n.name]&&e[n.requiredIfPresent]:void 0===e[n.name])).map((e=>e.name));if(t.length>0)throw new s(t.map((e=>`Missing required parameter: ${e}`)))}function G(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function H(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function K(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(j||(j={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(x||(x={}));const z=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],V=[...z,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function X(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Y(e,z),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(l),g=G({membershipId:n,organizationId:t,bankAccountId:i}),p=H({hasDailyLimit:a,hasTransactionLimit:r}),h=K({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=Q(u),T=J(m),_=[...f,...g,...p,...h,...y,...T];if(_.length>0)throw new s(_)}(e),e}(e):function(e){Y(e,V),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:y,hasAtmDailyLimit:T,atmDailyLimit:_,atmMonthlyLimit:I,address:w,cardDesign:b,typeOfPrint:E}=e,A=function(e){return Object.values(x).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(l),k=function(e){const n=null!=e&&"string"!=typeof e,t=!["print","embossed",void 0,null].includes(e);return n||t?['typeOfPrint must be one of "print", "embossed" or null']:[]}(E),R=G({membershipId:n,organizationId:t,bankAccountId:i}),S=H({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:T,shipToBusiness:h}),P=K({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:I}),L=Q(u),v=J(m),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,n){if(n)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(w,h),N=[...A,...R,...S,...P,...L,...v,...k,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function Q(e){const n=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&n?["activeDays must be an array of integers between 1 and 7"]:[]}function J(e){const n=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&n?["categories must be an array of strings"]:[]}class W extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const Z=[];for(let e=0;e<256;++e)Z.push((e+256).toString(16).slice(1));let ee;const ne=new Uint8Array(16);var te={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ie(e,n,t){if(te.randomUUID&&!e)return te.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!ee){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ee=crypto.getRandomValues.bind(crypto)}return ee(ne)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(Z[e[n+0]]+Z[e[n+1]]+Z[e[n+2]]+Z[e[n+3]]+"-"+Z[e[n+4]]+Z[e[n+5]]+"-"+Z[e[n+6]]+Z[e[n+7]]+"-"+Z[e[n+8]]+Z[e[n+9]]+"-"+Z[e[n+10]]+Z[e[n+11]]+Z[e[n+12]]+Z[e[n+13]]+Z[e[n+14]]+Z[e[n+15]]).toLowerCase()}(i)}class ae{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const n=new URL(e.iframeUrl);this.targetOrigin=`${n.protocol}//${n.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new W(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,n)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const t=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),n(new W(`Could not install the authentication UI because the timeout of ${t}ms was reached.\nPlease make sure the application can reach the Internet.`))}),t),a=n=>{n.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new W("Attempted to perform an Embed operation without having the authentication UI initialized."));const n=function({actionId:e,actionData:n}){const t=p.getMFAPreference();return{actionId:e,actionData:{...n,scaPreference:n.scaPreference||t,idempotencyKey:n.idempotencyKey||ie()}}}(e);return new Promise(((e,t)=>{const i=a=>{if(a.data?.actionId===n.actionId){if("error"===a.data.status)return this.removeMessageListener(n.actionId,i),t(new W(`An error occurred when performing the action ${n.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(n.actionId,i),e(a.data.payload)}};this.addMessageListener(n.actionId,i),this.iframe?.contentWindow?.postMessage(n,this.targetOrigin)}))}addMessageListener(e,n){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(n),window.addEventListener("message",n)}removeMessageListener(e,n){const t=this.messageListeners.get(e);if(t){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),window.removeEventListener("message",n))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function re({accessToken:e,stagingToken:n,locale:t,debugMode:i}){const a=i||!1,r=t||P.getLocale(),s=w.getEnvironmentUrls().IFRAME_URL,o=n?`;staging_token=${encodeURIComponent(n)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function se({parentElementId:e,iframeUrl:n}){return new ae({parentElementId:e,iframeUrl:n}).initialize()}function oe(e){return"virtual"===e.cardLevel?function(e){const n=de(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ie(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel}}}}}(e):function(e){const n=de(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ie(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ce(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function de(e){const n=Object.values(q);return(e||[]).filter((e=>n.includes(e)))}const ue={getCards:async function({membershipId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=w.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new N(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:t});return a.map((e=>ce(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:t});return ce(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});X(e.cardSettings);const s=re({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),o=await se({iframeUrl:s,parentElementId:i}),c=oe(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ce(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=G({cardId:e.cardId});if(n.length>0)throw new s(n)}(e.cardSettings);const o=re({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),d=await se({iframeUrl:o,parentElementId:i}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),m=await d.postMessage(u);return d.destroy(),ce(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:n,accessToken:t,stagingToken:i,debugMode:a,mfaPreference:o}=E(e.operationSettings,{requiresUI:!0}),c=t||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=G({cardId:e.cardId});if(n.length>0)throw new s(n);let t={};void 0!==e.allowPinReveal&&(t={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(t={...t,allowBlocking:e.allowBlocking});const i=H(t);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:n,stagingToken:t,mfaPreference:i}=e,a={method:"GET",headers:$({accessToken:n,stagingToken:t,mfaPreference:i})},r=w.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(!s.ok)throw o.errors?new N(o.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:u,allowBlocking:m}=e.cardSettings,l=function(e,n){const t=new URL(e);return"boolean"==typeof n.allowPinReveal&&t.searchParams.set("canSeePin",n.allowPinReveal.toString()),"boolean"==typeof n.allowBlocking&&t.searchParams.set("canBlock",n.allowBlocking.toString()),!0===n.debugMode&&t.searchParams.set("debug",n.debugMode.toString()),t.toString()}(d,{allowPinReveal:u,allowBlocking:m,debugMode:a}),f=await se({iframeUrl:l,parentElementId:n});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},me=ue;function le({endpointUrl:e,paginationSettings:n}){const t=new URL(e);return n?.page&&t.searchParams.set("page",n.page.toString()),n?.itemsPerPage&&t.searchParams.set("per_page",n.itemsPerPage.toString()),t}function fe(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function ge(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function pe(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const he="/v2/sepa/beneficiaries";async function ye({accessToken:e,stagingToken:n,beneficiaryId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}function Te({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${he}/${e.id}`,options:c}}async function _e({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=Te({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}),{beneficiary:s}=await async function({path:e,options:n}){const t=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,i=await fetch(t,{...n,headers:$(n.headers),body:JSON.stringify(n.body)}),a=await i.json();if(!i.ok)throw a.errors?new N(a.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${a.code}: ${a.detail}`);return a}(r);return s}const Ie=[{name:"name"},{name:"iban"}];const we={getBeneficiaries:async function(e){const n=e?.accessToken||r(),t=await async function({paginationSettings:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=le({endpointUrl:new URL(w.getEnvironmentUrls().THIRD_PARTY_API_URL+he),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=t.beneficiaries.map((e=>ge(e))),a=fe(t.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:n,stagingToken:t}){const i=n||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),ge(await ye({beneficiaryId:e,accessToken:i,stagingToken:t}))},addBeneficiary:async function({beneficiary:e,accessToken:n,stagingToken:t}){const i=n||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");Y(e,Ie);const n=G({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(n.length>0)throw new s(n)}(e);return ge(await async function({beneficiary:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:ie()}),body:JSON.stringify({beneficiary:pe(e)})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:t}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){const{id:n,name:t,email:i,activityTag:a}=e;if(!n)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!t&&!i&&!a)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=G({name:t,email:i,activityTag:a});if(r.length>0)throw new s(r);return{id:n,name:t,email:i,activityTag:a}}(e),{stagingToken:i,idempotencyKey:a,mfaPreference:o,proxyRequestFunction:c}=E(n),d={beneficiaryParamsBeingEdited:t,stagingToken:i,idempotencyKey:a,mfaPreference:o};if(c){const e=M(Te(d));return ge(F(await c(e)).body.beneficiary)}{const e=n?.accessToken||r();return ge(await _e({...d,accessToken:e}))}},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i=n||r();!function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings")}(e);return(await async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i={method:"PATCH",headers:$({accessToken:n,stagingToken:t}),body:JSON.stringify({ids:e})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:t})).map(ge)}},be="/v2/sepa/bulk_transfers";function Ee(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Ae(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function ke(e){const n=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:n,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}const Re="/v2/sepa/transfers";const Se=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Pe({sepaTransferSettings:e,operationSettings:n}){if(e?.beneficiary)return e.beneficiary;return ge(await ye({beneficiaryId:e?.beneficiaryId,accessToken:n?.accessToken,stagingToken:n?.stagingToken}))}const Le="browser",ve="server";class De extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Le:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case ve:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const Oe={getSepaTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),i=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=le({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),a=i.transfers.map(Ae),s=fe(i.meta);return{transfers:a,...s?{meta:s}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);return Ae(await async function({accessToken:e,stagingToken:n,sepaTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.transfer}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),o=n?.idempotencyKey||ie();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(Y(e,Se),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const n=[...G({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...K({amount:e.amount})].flat();if(n.length>0)throw new s(n);if(e.amount>3e4&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u={...e,beneficiary:await Pe({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(u.beneficiary?.trusted)d=await async function({transfer:e,accessToken:n,stagingToken:t,idempotencyKey:i}){const a=ke(e),r={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new N(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:u,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if(!U())throw new De(Le);const{uiParentElementId:e,debugMode:t}=E(n,{requiresUI:!0});let r;try{const n=re({accessToken:i,stagingToken:a||void 0,debugMode:t});r=await se({iframeUrl:n,parentElementId:e});const s=ke(u);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return Ae(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}/${e}/cancel`,r=await fetch(a,i);if(204!==r.status){const e=await r.json();if(e.errors)throw new N(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken})},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),{stagingToken:i,paginationSettings:a}=E(n||{}),s=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=le({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${be}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:t,stagingToken:i,paginationSettings:a}),o=s.bulkTransfers?.map(Ee),c=fe(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),{stagingToken:i}=E(n||{}),a=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Ee(await async function({accessToken:e,stagingToken:n,bulkTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${be}/${t}`),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:t,stagingToken:i,bulkTransferId:a}))}}};e.beneficiaries=we,e.cards=me,e.constants=O,e.initialize=v,e.logout=D,e.sepaTransfers=Oe}));
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.serializer.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,sBAAsB,GAC3B,YAAY,CAoBd;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,eAAe,GACxB,yBAAyB,CAc3B"}
1
+ {"version":3,"file":"sepa-transfers.serializer.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,sBAAsB,GAC3B,YAAY,CAoBd;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,eAAe,GACxB,yBAAyB,CAgB3B"}
@@ -160,7 +160,7 @@ export interface NewSepaTransfer {
160
160
  * An optional array of attachment IDs related to the transfer.
161
161
  * Attachments are required for transfers over €30,000.
162
162
  */
163
- attachments?: string[];
163
+ attachmentIds?: string[];
164
164
  }
165
165
  /**
166
166
  * Represents the parameters required to fetch a SEPA transfer.
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.types.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.types.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"sepa-transfers.types.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.types.ts"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- function e(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function t(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}export{e as serializeSepaTransfer,t as serializeToNewSepaTransferDataObject};
1
+ function e(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function t(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}export{e as serializeSepaTransfer,t as serializeToNewSepaTransferDataObject};
@@ -1 +1 @@
1
- import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as r,validateExpectedStringValues as n,validateExpectedNumericValues as t}from"../validation/input-param-validation.js";const a=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function i(r){if(!r)throw new e("sepaTransferId parameter is required for the called function");if(r&&"string"!=typeof r)throw new e("sepaTransferId must be a string");return r}function o(i){if(!i)throw new e("sepaTransferSettings parameter is required for the called function");if("object"!=typeof i)throw new e("sepaTransferSettings must be an object");if(r(i,a),!i.beneficiaryId&&!i.beneficiary)throw new e("Either beneficiaryId or beneficiary must be provided");const o=[...n({beneficiaryId:i.beneficiaryId,bankAccountId:i.bankAccountId,note:i.note,reference:i.reference}),...t({amount:i.amount})].flat();if(o.length>0)throw new e(o);if(i.amount>3e4&&(!i.attachments||0===i.attachments.length))throw new e("Attachments are required for transfers over €30,000");return i}function f(r){if(!r)throw new e("sepaTransferId parameter is required for the called function");if("string"!=typeof r)throw new e("sepaTransferId must be a string");return r}export{f as validateCancelSepaTransferParams,o as validateCreateSepaTransferParams,i as validateGetSepaTransferParams};
1
+ import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as r,validateExpectedStringValues as n,validateExpectedNumericValues as t}from"../validation/input-param-validation.js";const a=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function i(r){if(!r)throw new e("sepaTransferId parameter is required for the called function");if(r&&"string"!=typeof r)throw new e("sepaTransferId must be a string");return r}function o(i){if(!i)throw new e("sepaTransferSettings parameter is required for the called function");if("object"!=typeof i)throw new e("sepaTransferSettings must be an object");if(r(i,a),!i.beneficiaryId&&!i.beneficiary)throw new e("Either beneficiaryId or beneficiary must be provided");const o=[...n({beneficiaryId:i.beneficiaryId,bankAccountId:i.bankAccountId,note:i.note,reference:i.reference}),...t({amount:i.amount})].flat();if(o.length>0)throw new e(o);if(i.amount>3e4&&(!i.attachmentIds||0===i.attachmentIds.length))throw new e("Attachments are required for transfers over €30,000");return i}function f(r){if(!r)throw new e("sepaTransferId parameter is required for the called function");if("string"!=typeof r)throw new e("sepaTransferId must be a string");return r}export{f as validateCancelSepaTransferParams,o as validateCreateSepaTransferParams,i as validateGetSepaTransferParams};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {