@qonto/embed-sdk 0.43.0 → 0.45.0

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.
Files changed (33) hide show
  1. package/dist/errors/EmbedUIElementError.d.ts +11 -0
  2. package/dist/errors/EmbedUIElementError.d.ts.map +1 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.umd.js +2 -2
  6. package/dist/organizations/organizations.types.d.ts +3 -1
  7. package/dist/organizations/organizations.types.d.ts.map +1 -1
  8. package/dist/sepa-transfers/sepa-transfers.d.ts +66 -4
  9. package/dist/sepa-transfers/sepa-transfers.d.ts.map +1 -1
  10. package/dist/sepa-transfers/sepa-transfers.types.d.ts +12 -1
  11. package/dist/sepa-transfers/sepa-transfers.types.d.ts.map +1 -1
  12. package/dist/sepa-transfers/sepa-transfers.utils.d.ts +2 -2
  13. package/dist/sepa-transfers/sepa-transfers.utils.d.ts.map +1 -1
  14. package/dist/sepa-transfers/sepa-transfers.validate.d.ts +2 -1
  15. package/dist/sepa-transfers/sepa-transfers.validate.d.ts.map +1 -1
  16. package/dist/src/errors/EmbedUIElementError.js +1 -0
  17. package/dist/src/index.js +1 -1
  18. package/dist/src/organizations/organizations.api.js +1 -1
  19. package/dist/src/organizations/organizations.js +1 -1
  20. package/dist/src/sepa-transfers/sepa-transfers.js +1 -1
  21. package/dist/src/sepa-transfers/sepa-transfers.validate.js +1 -1
  22. package/dist/src/ui/index.js +1 -1
  23. package/dist/src/ui/ui-elements.js +1 -0
  24. package/dist/src/ui/ui-elements.public-api.js +1 -0
  25. package/dist/ui/index.d.ts +15 -3
  26. package/dist/ui/index.d.ts.map +1 -1
  27. package/dist/ui/ui-elements.d.ts +19 -0
  28. package/dist/ui/ui-elements.d.ts.map +1 -0
  29. package/dist/ui/ui-elements.public-api.d.ts +4 -0
  30. package/dist/ui/ui-elements.public-api.d.ts.map +1 -0
  31. package/dist/ui/ui-elements.types.d.ts +39 -2
  32. package/dist/ui/ui-elements.types.d.ts.map +1 -1
  33. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ import { QontoEmbedSdkError } from './QontoEmbedSdkError';
2
+ /**
3
+ * Error thrown when a UI element operation fails
4
+ */
5
+ export declare class EmbedUIElementError extends QontoEmbedSdkError {
6
+ /**
7
+ * Creates a new EmbedUIElementError
8
+ */
9
+ constructor(message: string);
10
+ }
11
+ //# sourceMappingURL=EmbedUIElementError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbedUIElementError.d.ts","sourceRoot":"","sources":["../../src/errors/EmbedUIElementError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD;;OAEG;gBACS,OAAO,EAAE,MAAM;CAK5B"}
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@ import { paymentLinks } from '@payment-links';
6
6
  import { organizations } from '@organizations';
7
7
  import { transactions } from '@transactions';
8
8
  import { authLinks } from '@auth-links';
9
+ import { ui } from '@ui';
9
10
  import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, Transaction, Item, CreatePaymentLinkSettings, PaymentLinkParams, AuthLinkRequestParams, AuthLinkRequestResult, AuthLinkRequestSettings, PostAuthAction } from '@types';
10
- import { createUIElement } from '@ui';
11
- export { initialize, logout, cards, sepaTransfers, beneficiaries, constants, paymentLinks, organizations, transactions, authLinks, createUIElement, };
11
+ export { initialize, logout, cards, sepaTransfers, beneficiaries, constants, paymentLinks, organizations, transactions, authLinks, ui, };
12
12
  export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, Transaction, Item, CreatePaymentLinkSettings, PaymentLinkParams, AuthLinkRequestParams, AuthLinkRequestResult, AuthLinkRequestSettings, PostAuthAction, };
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACf,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,SAAS,EACT,eAAe,GAChB,CAAC;AACF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,GACf,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACf,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,SAAS,EACT,EAAE,GACH,CAAC;AACF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,GACf,CAAC"}
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.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 n=t.getInstance();class a extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class r extends a{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 o(){if(!n.hasAccessToken())throw new r;return n.getAccessToken()}class i extends a{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 s={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",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},l={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},u={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},g={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"},f={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},p=3e4,h={ACCEPT:"ACCEPT",REJECT:"REJECT"},m={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"};var b=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"},AMOUNT_REQUIRING_ATTACHMENTS:p,AUTH_LINK_ACTIONS:m,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:l,ENVIRONMENTS:d,IFRAME_EVENTS:s,LOCALES:u,MFA_METHODS:f,TRANSACTION_STATUSES:{PENDING:"pending",DECLINED:"declined",COMPLETED:"completed"},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:g,VOP_CHECK_RESULTS:{MATCH_RESULT_MATCH:"MATCH_RESULT_MATCH",MATCH_RESULT_NO_MATCH:"MATCH_RESULT_NO_MATCH",MATCH_RESULT_CLOSE_MATCH:"MATCH_RESULT_CLOSE_MATCH",MATCH_RESULT_NOT_POSSIBLE:"MATCH_RESULT_NOT_POSSIBLE",MATCH_RESULT_UNSPECIFIED:"MATCH_RESULT_UNSPECIFIED"},VOP_DECISIONS:h});class y{constructor(){this.mfaPreference=f.PASSKEY,this.debugMode=!1}static getInstance(){return y.instance||(y.instance=new y),y.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=f.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const v=y.getInstance(),_="https://embed.qonto.com",w="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",k={[d.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:w,IFRAME_URL:`${w}/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 E{constructor(){this.environment=d.PRODUCTION,this.branch=l.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(l).includes(t)?t:l.SANDBOX}static getInstance(){return E.instance||(E.instance=new E),E.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=l.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return k.production;{const e=k[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const A=E.getInstance(),S={requiresUI:!1};function I(e,{requiresUI:t}=S){const n=e?.uiParentElementId||v.getUIParentElementId();if(t&&!n)throw new i("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 a=e?.mfaPreference||v.getMFAPreference();if(a){const e=(r=Object.values(f),A.isProductionEnvironment()?r.filter((e=>e!==f.MOCK)):r);if(!e.includes(a))throw new i(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(A.isProductionEnvironment()&&a===f.MOCK)throw new i("operationSettings.mfaPreference cannot be set to mock in production environment.")}var r;const o=e?.debugMode||v.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new i("operationSettings.debugMode must be a boolean.");const s=e?.proxyRequestFunction||v.getProxyRequestFunction();if(s&&"function"!=typeof s)throw new i("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:n,mfaPreference:a,debugMode:o,proxyRequestFunction:s}}const $=Object.values(u);function R(e){if(!function(e){return $.includes(e)}(e))throw new i(`Unsupported locale: ${e}. The locale must be one of: ${$.join(", ")}.`);return e}function P(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new i("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&I(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new i('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 i('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&&R(e.locale),e}class C{constructor(){this.currentLocale="en"}static getInstance(){return C.instance||(C.instance=new C),C.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=C.getInstance();const N={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:r,environment:o,branch:i,locale:s}=P(e);t&&n.setAccessToken(t),a&&n.setStagingToken(a),s&&L.setLocale(s),r&&v.setSettings(r),o&&(A.setEnvironment(o),i&&A.setBranch(i))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),L.setDefaultLocale(),v.clearSettings()},constants:b},{initialize:q,logout:O,constants:D}=N;class U extends a{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function x(){return"undefined"!=typeof window&&"undefined"!=typeof document}function M(){return!x()}function z({accessToken:e,stagingToken:t,idempotencyKey:a,mfaPreference:r}){const o=new Headers;o.append("Authorization",`Bearer ${e}`);const i=t||n.getStagingToken();i&&o.append("X-Qonto-Staging-Token",i),a&&o.append("X-Qonto-Idempotency-Key",a);const s=r||v.getMFAPreference();return s&&o.append("X-Qonto-2fa-Preference",s),o.append("Content-Type","application/json"),o.append("Accept-Language",L.getLocale()),o}async function j({path:e,options:t}){const n=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,a=await fetch(n,{...t,headers:z(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===a.status)return;const r=await a.json();if(!a.ok)throw r.errors?new U(r.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${r.code}: ${r.detail}`);return r}function F(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return a=n,M()?Buffer.from(a).toString("base64"):btoa(a);var a}function B(e){return JSON.parse((t=e,M()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function H({accessToken:e,stagingToken:t,action:n,callbackUrl:a}){const r={post_authn_action:n};return a&&(r.callback_url=a),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:r}}}}function G({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function K({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Y({accessToken:e,stagingToken:t}){return H({accessToken:e,stagingToken:t,action:m.CARD_DISPLAY})}var V;!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"}(V||(V={}));const W={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 Z,J;function Q(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new i(n.map((e=>`Missing required parameter: ${e}`)))}function X(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function ee(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function te(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"}(Z||(Z={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(J||(J={}));const ne=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],ae=[...ne,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function re(e){if(!e)throw new i("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Q(e,ne),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(g),p=X({membershipId:t,organizationId:n,bankAccountId:a}),h=ee({hasDailyLimit:r,hasTransactionLimit:o}),m=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d}),b=oe(l),y=ie(u),v=[...f,...p,...h,...m,...b,...y];if(v.length>0)throw new i(v)}(e),e}(e):function(e){Q(e,ae),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,shipToBusiness:m,hasAtmOption:b,hasAtmDailyLimit:y,atmDailyLimit:v,atmMonthlyLimit:_,address:w,cardDesign:T,typeOfPrint:k}=e,E=function(e){return Object.values(J).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(g),A=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(k),S=X({membershipId:t,organizationId:n,bankAccountId:a}),I=ee({hasDailyLimit:r,hasTransactionLimit:o,hasAtmOption:b,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,hasAtmDailyLimit:y,shipToBusiness:m}),$=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d,atmDailyLimit:v,atmMonthlyLimit:_}),R=oe(l),P=ie(u),C=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(T),L=function(e,t){if(t)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,m),N=[...E,...S,...I,...$,...R,...P,...A,...C,...L];if(N.length>0)throw new i(N)}(e)}(e)}function oe(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function ie(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class se extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));let de;const le=new Uint8Array(16);var ue={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(e,t,n){if(ue.randomUUID&&!e)return ue.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!de){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");de=crypto.getRandomValues.bind(crypto)}return de(le)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=15&a[6]|64,a[8]=63&a[8]|128,function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(a)}function fe({actionId:e,actionData:t}){const n=v.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||ge()}}}class pe{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new se(`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,t)=>{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 n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",r),t(new se(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),r=t=>{t.data.eventId===s.READY&&(clearTimeout(a),window.removeEventListener("message",r),e(this))};window.addEventListener("message",r),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new se("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=fe(e);return new Promise(((e,n)=>{const a=r=>{if(r.data?.actionId===t.actionId){if("error"===r.data.status)return this.removeMessageListener(t.actionId,a),n(new se(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(r.data.payload)}`));this.removeMessageListener(t.actionId,a),e(r.data.payload)}};this.addMessageListener(t.actionId,a),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}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 he({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const r=a||!1,o=n||L.getLocale(),i=A.getEnvironmentUrls().IFRAME_URL,s=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${i}?debug=${r}&lang=${encodeURIComponent(o)}#access_token=${encodeURIComponent(e)}${s}`}function me({parentElementId:e,iframeUrl:t}){return new pe({parentElementId:e,iframeUrl:t}).initialize()}function be(e){return"virtual"===e.cardLevel?function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),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:t,card_level:e.cardLevel}}}}}(e):function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),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:t,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 ye(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 ve(e){const t=Object.values(W);return(e||[]).filter((e=>t.includes(e)))}const _e="--qonto-embed";function we(e){return!e.href||e.href.startsWith(window.location.origin)}function Te(e){return"CSSStyleRule"===e.constructor.name}function ke(e=_e){return x()?function(e,t){return[...e].filter(we).reduce(((e,n)=>[...n.cssRules].filter(Te).reduce(((e,n)=>{if("style"in n){const a=[...n.style].map((e=>[e.trim(),n.style.getPropertyValue(e).trim()])).filter((([e])=>e.startsWith(t))).reduce(((e,[n,a])=>({...e,[n.replace(`${t}-`,"")]:a})),{});return{...e,...a}}return e}),e)),{})}(document.styleSheets,e):{}}async function Ee({decorationParams:e,operationSettings:t,cardIframeUrl:n}){const{cardId:a,allowPinReveal:r,allowBlocking:o}=e,{uiParentElementId:i,debugMode:s}=t,c=function(e,t){const n=new URL(e);n.searchParams.set("cardId",t.cardId),"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const a=ke(_e);return Object.keys(a).length>0&&n.searchParams.set("customization",JSON.stringify(a)),n.toString()}(n,{cardId:a,allowPinReveal:r,allowBlocking:o,debugMode:s}),d=await me({iframeUrl:c,parentElementId:i});return{destroyEmbedUI:()=>{d.destroy()}}}const Ae={getCards:async function(e){try{const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new i("membershipId must be a string");const{proxyRequestFunction:n,stagingToken:a}=I(e?.operationSettings||{});if(n){const e=F(G({membershipId:t,stagingToken:a})),r=await n(e);return B(r).body.cards.map((e=>ye(e)))}{const n=e?.operationSettings?.accessToken||o(),r=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a=G({membershipId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r}({membershipId:t,accessToken:n,stagingToken:a});return r.map((e=>ye(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:t}){try{!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId parameter is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e);const n=e.cardId,{proxyRequestFunction:a,stagingToken:r}=I(t||{});if(a){const e=F(K({cardId:n,stagingToken:r})),t=await a(e),o=B(t).body.cards;if(Array.isArray(o)&&o.length>0)return ye(o[0]);throw new i("Unable to retrieve card data")}{const e=t?.accessToken||o(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const a=K({cardId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r[0]}({cardId:n,accessToken:e,stagingToken:r});return ye(a)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});re(e.cardSettings);const i=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),s=await me({iframeUrl:i,parentElementId:a}),c=be(e.cardSettings),d=await s.postMessage(c);return s.destroy(),ye(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e.cardSettings);const s=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),d=await me({iframeUrl:s,parentElementId:a}),l=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),u=await d.postMessage(l);return d.destroy(),ye(u)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:a,debugMode:r,mfaPreference:s,proxyRequestFunction:c}=I(e.operationSettings,{requiresUI:!0});if(function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=ee(n);if(a.length>0)throw new i(a)}(e.cardSettings),c){const n=F(Y({stagingToken:a})),o=await c(n),i=B(o).body;return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r},cardIframeUrl:i.url})}{const i=n||o(),c=await async function(e){const t=Y(e),{embed_auth_link:n}=await j(t);return n}({...e.cardSettings,accessToken:i,stagingToken:a});return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r,mfaPreference:s},cardIframeUrl:c.url})}}catch(e){return Promise.reject(e)}}},Se=Ae;function Ie(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function $e({endpointUrl:e,paginationSettings:t}){return function({url:e,searchParams:t}){const n=new URL(e.toString());for(const[e,a]of t.entries())n.searchParams.append(e,a);return n}({url:new URL(e),searchParams:Ie(t)})}function Re(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 Pe(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 Ce(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 Le="/v2/sepa/beneficiaries";function Ne({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Le}${o}`,options:a}}function qe({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${Le}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Oe({accessToken:e,stagingToken:t,beneficiaryId:n}){const a=qe({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:r}=await j(a);return r}function De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){return{path:Le,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:a},body:{beneficiary:Ce(e)}}}}function Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${Le}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}function xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const{name:o,email:i,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r},body:{beneficiary:{name:o,email:i,activity_tag:s}}};return{path:`${Le}/${e.id}`,options:c}}const Me=[{name:"name"},{name:"iban"}];const ze={getBeneficiaries:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(Ne({paginationSettings:r})),t=B(await n(e)),a=t.body.beneficiaries.map((e=>Pe(e))),o=Re(t.body.meta);return{beneficiaries:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a=Ne({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:r,meta:o}=await j(a);return{beneficiaries:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.beneficiaries.map((e=>Pe(e))),s=Re(n.meta);return{beneficiaries:i,...s?{meta:s}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(qe({beneficiaryId:n}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o();return Pe(await Oe({beneficiaryId:n,accessToken:e,stagingToken:s}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new i("beneficiary must be an object");Q(e,Me);const t=X({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new i(t);return e}(e),{proxyRequestFunction:a,accessToken:r,stagingToken:s,idempotencyKey:c}=I(t||{});if(a){const e=F(De({beneficiary:n,idempotencyKey:c}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o(),t=await async function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){const r=De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a}),{beneficiary:o}=await j(r);return o}({beneficiary:n,accessToken:e,stagingToken:s,idempotencyKey:c});return Pe(t)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:a,activityTag:r}=e||{};if(!t)throw new i("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!r)throw new i("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=X({name:n,email:a,activityTag:r});if(o.length>0)throw new i(o);return{id:t,name:n,email:a,activityTag:r}}(e),{stagingToken:a,idempotencyKey:r,mfaPreference:s,proxyRequestFunction:c}=I(t),d={beneficiaryParamsBeingEdited:n,idempotencyKey:r,mfaPreference:s};if(c){const e=F(xe(d));return Pe(B(await c(e)).body.beneficiary)}{const e=t?.accessToken||o(),n=await async function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const o=xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}),{beneficiary:i}=await j(o);return i}({...d,accessToken:e,stagingToken:a});return Pe(n)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new i("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ue({beneficiaryIds:n}));return B(await a(e)).body.beneficiaries.map(Pe)}{const e=r||o(),t=await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const a=Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:r}=await j(a);return r}({beneficiaryIds:n,accessToken:e,stagingToken:s});return t.map(Pe)}}},je=ze;function Fe(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 Be(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}function He(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 Ge(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}:{}}}function Ke(e){return{name:e.name,iban:e.iban}}const Ye="/v2/sepa",Ve=`${Ye}/transfers`;function We({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Ve}${o}`,options:a}}function Ze({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Je({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}async function Qe({sepaPayee:e,accessToken:t,stagingToken:n}){const a=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await j(a)}const Xe="/v2/sepa/bulk_transfers";async function et({sepaPayees:e,accessToken:t,stagingToken:n}){const a=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Ke)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await j(a)}function tt(e){if(!e)throw new i("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new i("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new i("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new i("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new i(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new i(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=X({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),a=te({amount:e.amount}),r=[...n,...a].flat();if(r.length>0)throw new i(r);if(e.amount>p&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new i(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const nt="browser",at="server";class rt extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case nt:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case at: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 ot=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function it(e,t){const n=t?.locale||L.getLocale(),a=new URL(e);return n&&a.searchParams.append("lang",n),t?.mfaPreference&&a.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&a.searchParams.append("idempotencyKey",t.idempotencyKey),a.toString()}function st(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}const ct={request:async function({requestSettings:e,operationSettings:t}){!function(e){if(!e||"object"!=typeof e)throw new i("requestSettings must be an object");const t=e,{action:n,callbackUrl:a}=e;Q(t,[{name:"action"}]);const r=X(t),o=Object.values(m);if(o.includes(n)||r.push(`action must be one of ${o.join(", ")}`),r.length>0)throw new i(r);if(void 0!==a&&""===a.trim())throw new i("callbackUrl cannot be empty")}(e);const{proxyRequestFunction:n,stagingToken:a}=I(t||{});if(n){const t=F(H({stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}));return st(B(await n(t)).body)}{const n=t?.accessToken||o();return st(await async function(e){const t=H({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await j(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}({accessToken:n,stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}))}}};async function dt(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(We({paginationSettings:r})),t=B(await n(e)),a=t.body.transfers.map(He),o=Re(t.body.meta);return{transfers:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a=We({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:r,meta:o}=await j(a);return{transfers:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.transfers.map(He),s=Re(n.meta);return{transfers:i,...s?{meta:s}:{}}}}const lt={getSepaTransfers:dt,getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ze({sepaTransferId:n}));return He(B(await a(e)).body.transfer)}{const e=r||o(),t=await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a=Ze({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:r}=await j(a);return r}({sepaTransferId:n,accessToken:e,stagingToken:s});return He(t)}},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),s=t?.idempotencyKey||ge();let d;!function(e){if(!e)throw new i("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new i("sepaTransferSettings must be an object");if(Q(e,ot),!e.beneficiaryId&&!e.beneficiary)throw new i("Either beneficiaryId or beneficiary must be provided");const t=[...X({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...te({amount:e.amount})].flat();if(t.length>0)throw new i(t);if(e.amount>p&&(!e.attachmentIds||0===e.attachmentIds.length))throw new i("Attachments are required for transfers over €30,000")}(e);const l=await async function({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:Pe(await Oe({beneficiaryId:e?.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}({sepaTransferSettings:e,operationSettings:{accessToken:a,stagingToken:r||void 0}}),u={name:l.name,iban:l.iban},g=await Qe({sepaPayee:u,accessToken:a,stagingToken:r||void 0});var f;if((yield(f=g,{matchResult:f.match_result,matchedName:f.matched_name}))===h.REJECT)return;const m={...e,beneficiary:l};if(m.beneficiary?.trusted)d=await async function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:a,idempotencyKey:r}){const o=Ge(e),i={method:"POST",headers:z({accessToken:n,stagingToken:a,idempotencyKey:r}),body:JSON.stringify({transfer:o,vop_proof_token:t})},s=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ve}`,c=await fetch(s,i),d=await c.json();if(d.errors)throw new U(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.transfer}({transfer:m,vopProofToken:g.proof_token.token,accessToken:a,stagingToken:r||void 0,idempotencyKey:s});else{if(!x())throw new rt(nt);const{uiParentElementId:e,debugMode:n}=I(t,{requiresUI:!0});let o;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:n});o=await me({iframeUrl:t,parentElementId:e});const i=Ge(m);d=await o.postMessage(fe({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...i}},idempotencyKey:s}}))}finally{o?.destroy()}}return He(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Je({sepaTransferId:n}));B(await a(e))}else{const e=r||o();await async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a=Je({sepaTransferId:e,accessToken:t,stagingToken:n});await j(a)}({sepaTransferId:n,accessToken:e,stagingToken:s})}},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new i("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new i("callbackUrl must be a string");return e.callbackUrl}(e),{proxyRequestFunction:a,stagingToken:r,accessToken:s}=I(t||{}),c=a?{proxyRequestFunction:a}:{stagingToken:r,accessToken:s||o()},d=await ct.request({requestSettings:{action:m.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:c});return{...d,url:it(d.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:t}=e||{},n=t?.accessToken||o(),{stagingToken:a,paginationSettings:r}=I(t||{}),i=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=$e({endpointUrl:new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}`),paginationSettings:n}),o=await fetch(r,a);if(!o.ok)throw new U("Failed to fetch SEPA bulk transfers");const i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:i.bulk_transfers,meta:i.meta}}({accessToken:n,stagingToken:a,paginationSettings:r}),s=i.bulkTransfers?.map(Fe),c=Re(i.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||o(),{stagingToken:a}=I(t||{}),r=function(e){if(!e)throw new i("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new i("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Fe(await async function({accessToken:e,stagingToken:t,bulkTransferId:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}/${n}`),o=await fetch(r,a),i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return i.bulk_transfer}({accessToken:n,stagingToken:a,bulkTransferId:r}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),i=t?.idempotencyKey||ge();tt(e);const{uiParentElementId:s,debugMode:d}=I(t,{requiresUI:!0});if(!x())throw new rt(nt);const l=new Map;for(const t of e.bulkTransfers){const e=t.beneficiary.iban;e&&!l.has(e)&&l.set(e,{name:t.beneficiary.name,iban:e})}const u=Array.from(l.values()),g=await et({sepaPayees:u,accessToken:a,stagingToken:r||void 0});if((yield g.requests.map(Be))===h.REJECT)return;let f,p;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:d});p=await me({iframeUrl:t,parentElementId:s});const n={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};f=await p.postMessage(fe({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:n,idempotencyKey:i}}))}finally{p?.destroy()}return Fe(f)}}},ut={GOOD:"good",SERVICE:"service"},gt={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},ft=e=>{if(!(e=>Object.values(gt).includes(e))(e))throw new i(`currency ${e} is not valid, valid currencies are ${Object.values(gt).join(", ")}`)},pt={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},ht=e=>{if(!(e=>Object.values(pt).includes(e))(e))throw new i(`unit ${e} is not valid, valid units are ${Object.values(pt).join(", ")}`)},mt=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],bt=[{name:"currency"},{name:"value"}];const yt=e=>{if(!Object.values(ut).includes(e))throw new i(`type ${e} is not valid, valid types are ${Object.values(ut).join(", ")}`)},vt={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e})=>{const{items:t,authUrl:n}=e;!function(e){if(!e)throw new i("authUrl is required for the called function");const t=X({authUrl:e});if(t.length>0)throw new i(t);try{new URL(e)}catch{throw new i("authUrl is not a valid URL")}}(n),function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{Q(e,mt),Q(e.unitPrice,bt);const t=[...X({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...te({quantity:e.quantity})].flat();if(t.length>0)throw new i(t);yt(e.type),ft(e.unitPrice.currency),ht(e.measureUnit)}))}(t);const a=new URLSearchParams({...t?{items:JSON.stringify(t)}:{}});return a.toString()?`${n}?${a.toString()}`:n}},_t=({accessToken:e,stagingToken:t})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}),wt=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),Tt={getBankAccounts:async e=>{const{stagingToken:t,proxyRequestFunction:n}=I(e);if(n){const e=_t({stagingToken:t}),a=await n(F(e)),{body:r}=B(a);return r.bank_accounts.map(wt)}{const n=e.accessToken||o(),a=await(async({accessToken:e,stagingToken:t})=>{const n=_t({accessToken:e,stagingToken:t});return await j(n)})({accessToken:n,stagingToken:t});return a.bank_accounts.map(wt)}}},kt="/v2/transactions";function Et({bankAccountId:e,iban:t,status:n,updatedAtFrom:a,updatedAtTo:r,emittedAtFrom:o,emittedAtTo:i,settledAtFrom:s,settledAtTo:c,side:d,operationType:l,withAttachments:u,paginationSettings:g,accessToken:f,stagingToken:p}){const h={method:"GET",headers:{accessToken:f,stagingToken:p}},m=new URLSearchParams;e&&m.append("bank_account_id",e),t&&m.append("iban",t),n&&m.append("status",n),a&&m.append("updated_at_from",a),r&&m.append("updated_at_to",r),o&&m.append("emitted_at_from",o),i&&m.append("emitted_at_to",i),s&&m.append("settled_at_from",s),c&&m.append("settled_at_to",c),d&&m.append("side",d),l&&m.append("operation_type",l),void 0!==u&&m.append("with_attachments",String(u));const b=Ie(g);for(const[e,t]of b)m.append(e,t);const y=m.toString();return{path:`${kt}${y?`?${y}`:""}`,options:h}}function At({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${kt}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function St(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const It={getTransactions:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{}),i={...e?.transactionSettings||{},paginationSettings:r};if(n){const e=F(Et(i)),t=B(await n(e));return{transactions:t.body.transactions.map(St),meta:t.body.meta}}{const e=a||o(),n=await async function(e){const t=Et(e),{transactions:n,meta:a}=await j(t);return{transactions:n,meta:a}}({...i,accessToken:e,stagingToken:t});return{transactions:n.transactions.map(St),meta:n.meta}}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{proxyRequestFunction:n,accessToken:a,stagingToken:r}=I(t||{}),{transactionId:s}=function(e){if(!e)throw new i("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new i("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new i("transactionSettings.transactionId must be a string.");return e}(e);if(n){const e=F(At({transactionId:s}));return St(B(await n(e)).body.transaction)}{const e=a||o();return St(await async function(e){const t=At(e),{transaction:n}=await j(t);return n}({transactionId:s,accessToken:e,stagingToken:r}))}}},$t=It;function Rt(e,t,n,a){var r,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(i=(o<3?r(i):o>3?r(t,n,i):r(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}"function"==typeof SuppressedError&&SuppressedError;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.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 n=t.getInstance();class a extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class r extends a{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 o(){if(!n.hasAccessToken())throw new r;return n.getAccessToken()}class i extends a{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 s={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",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},l={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},u={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},g={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"},f={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},p=3e4,h={ACCEPT:"ACCEPT",REJECT:"REJECT"},m={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"};var b=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"},AMOUNT_REQUIRING_ATTACHMENTS:p,AUTH_LINK_ACTIONS:m,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:l,ENVIRONMENTS:d,IFRAME_EVENTS:s,LOCALES:u,MFA_METHODS:f,TRANSACTION_STATUSES:{PENDING:"pending",DECLINED:"declined",COMPLETED:"completed"},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:g,VOP_CHECK_RESULTS:{MATCH_RESULT_MATCH:"MATCH_RESULT_MATCH",MATCH_RESULT_NO_MATCH:"MATCH_RESULT_NO_MATCH",MATCH_RESULT_CLOSE_MATCH:"MATCH_RESULT_CLOSE_MATCH",MATCH_RESULT_NOT_POSSIBLE:"MATCH_RESULT_NOT_POSSIBLE",MATCH_RESULT_UNSPECIFIED:"MATCH_RESULT_UNSPECIFIED"},VOP_DECISIONS:h});class y{constructor(){this.mfaPreference=f.PASSKEY,this.debugMode=!1}static getInstance(){return y.instance||(y.instance=new y),y.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=f.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const v=y.getInstance(),_="https://embed.qonto.com",w="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",k={[d.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:w,IFRAME_URL:`${w}/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 E{constructor(){this.environment=d.PRODUCTION,this.branch=l.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(l).includes(t)?t:l.SANDBOX}static getInstance(){return E.instance||(E.instance=new E),E.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=l.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return k.production;{const e=k[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const A=E.getInstance(),S={requiresUI:!1};function I(e,{requiresUI:t}=S){const n=e?.uiParentElementId||v.getUIParentElementId();if(t&&!n)throw new i("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 a=e?.mfaPreference||v.getMFAPreference();if(a){const e=(r=Object.values(f),A.isProductionEnvironment()?r.filter((e=>e!==f.MOCK)):r);if(!e.includes(a))throw new i(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(A.isProductionEnvironment()&&a===f.MOCK)throw new i("operationSettings.mfaPreference cannot be set to mock in production environment.")}var r;const o=e?.debugMode||v.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new i("operationSettings.debugMode must be a boolean.");const s=e?.proxyRequestFunction||v.getProxyRequestFunction();if(s&&"function"!=typeof s)throw new i("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:n,mfaPreference:a,debugMode:o,proxyRequestFunction:s}}const $=Object.values(u);function R(e){if(!function(e){return $.includes(e)}(e))throw new i(`Unsupported locale: ${e}. The locale must be one of: ${$.join(", ")}.`);return e}function P(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new i("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&I(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new i('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 i('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&&R(e.locale),e}class C{constructor(){this.currentLocale="en"}static getInstance(){return C.instance||(C.instance=new C),C.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=C.getInstance();const N={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:r,environment:o,branch:i,locale:s}=P(e);t&&n.setAccessToken(t),a&&n.setStagingToken(a),s&&L.setLocale(s),r&&v.setSettings(r),o&&(A.setEnvironment(o),i&&A.setBranch(i))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),L.setDefaultLocale(),v.clearSettings()},constants:b},{initialize:q,logout:O,constants:D}=N;class U extends a{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function x(){return"undefined"!=typeof window&&"undefined"!=typeof document}function M(){return!x()}function z({accessToken:e,stagingToken:t,idempotencyKey:a,mfaPreference:r}){const o=new Headers;o.append("Authorization",`Bearer ${e}`);const i=t||n.getStagingToken();i&&o.append("X-Qonto-Staging-Token",i),a&&o.append("X-Qonto-Idempotency-Key",a);const s=r||v.getMFAPreference();return s&&o.append("X-Qonto-2fa-Preference",s),o.append("Content-Type","application/json"),o.append("Accept-Language",L.getLocale()),o}async function j({path:e,options:t}){const n=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,a=await fetch(n,{...t,headers:z(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===a.status)return;const r=await a.json();if(!a.ok)throw r.errors?new U(r.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${r.code}: ${r.detail}`);return r}function F(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return a=n,M()?Buffer.from(a).toString("base64"):btoa(a);var a}function B(e){return JSON.parse((t=e,M()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function H({accessToken:e,stagingToken:t,action:n,callbackUrl:a}){const r={post_authn_action:n};return a&&(r.callback_url=a),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:r}}}}function G({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function K({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Y({accessToken:e,stagingToken:t}){return H({accessToken:e,stagingToken:t,action:m.CARD_DISPLAY})}var V;!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"}(V||(V={}));const W={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 Z,J;function Q(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new i(n.map((e=>`Missing required parameter: ${e}`)))}function X(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function ee(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function te(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"}(Z||(Z={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(J||(J={}));const ne=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],ae=[...ne,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function re(e){if(!e)throw new i("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Q(e,ne),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(g),p=X({membershipId:t,organizationId:n,bankAccountId:a}),h=ee({hasDailyLimit:r,hasTransactionLimit:o}),m=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d}),b=oe(l),y=ie(u),v=[...f,...p,...h,...m,...b,...y];if(v.length>0)throw new i(v)}(e),e}(e):function(e){Q(e,ae),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:r,hasTransactionLimit:o,monthlyLimit:s,dailyLimit:c,transactionLimit:d,activeDays:l,categories:u,cardLevel:g,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,shipToBusiness:m,hasAtmOption:b,hasAtmDailyLimit:y,atmDailyLimit:v,atmMonthlyLimit:_,address:w,cardDesign:T,typeOfPrint:k}=e,E=function(e){return Object.values(J).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(g),A=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(k),S=X({membershipId:t,organizationId:n,bankAccountId:a}),I=ee({hasDailyLimit:r,hasTransactionLimit:o,hasAtmOption:b,hasNfcOption:f,hasForeignPaymentOption:p,hasOnlinePaymentOption:h,hasAtmDailyLimit:y,shipToBusiness:m}),$=te({monthlyLimit:s,dailyLimit:c,transactionLimit:d,atmDailyLimit:v,atmMonthlyLimit:_}),R=oe(l),P=ie(u),C=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(T),L=function(e,t){if(t)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,m),N=[...E,...S,...I,...$,...R,...P,...A,...C,...L];if(N.length>0)throw new i(N)}(e)}(e)}function oe(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function ie(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class se extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));let de;const le=new Uint8Array(16);var ue={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(e,t,n){if(ue.randomUUID&&!e)return ue.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!de){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");de=crypto.getRandomValues.bind(crypto)}return de(le)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=15&a[6]|64,a[8]=63&a[8]|128,function(e,t=0){return(ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]).toLowerCase()}(a)}function fe({actionId:e,actionData:t}){const n=v.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||ge()}}}class pe{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new se(`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,t)=>{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 n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",r),t(new se(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),r=t=>{t.data.eventId===s.READY&&(clearTimeout(a),window.removeEventListener("message",r),e(this))};window.addEventListener("message",r),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new se("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=fe(e);return new Promise(((e,n)=>{const a=r=>{if(r.data?.actionId===t.actionId){if("error"===r.data.status)return this.removeMessageListener(t.actionId,a),n(new se(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(r.data.payload)}`));this.removeMessageListener(t.actionId,a),e(r.data.payload)}};this.addMessageListener(t.actionId,a),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}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 he({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const r=a||!1,o=n||L.getLocale(),i=A.getEnvironmentUrls().IFRAME_URL,s=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${i}?debug=${r}&lang=${encodeURIComponent(o)}#access_token=${encodeURIComponent(e)}${s}`}function me({parentElementId:e,iframeUrl:t}){return new pe({parentElementId:e,iframeUrl:t}).initialize()}function be(e){return"virtual"===e.cardLevel?function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),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:t,card_level:e.cardLevel}}}}}(e):function(e){const t=ve(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ge(),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:t,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 ye(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 ve(e){const t=Object.values(W);return(e||[]).filter((e=>t.includes(e)))}const _e="--qonto-embed";function we(e){return!e.href||e.href.startsWith(window.location.origin)}function Te(e){return"CSSStyleRule"===e.constructor.name}function ke(e=_e){return x()?function(e,t){return[...e].filter(we).reduce(((e,n)=>[...n.cssRules].filter(Te).reduce(((e,n)=>{if("style"in n){const a=[...n.style].map((e=>[e.trim(),n.style.getPropertyValue(e).trim()])).filter((([e])=>e.startsWith(t))).reduce(((e,[n,a])=>({...e,[n.replace(`${t}-`,"")]:a})),{});return{...e,...a}}return e}),e)),{})}(document.styleSheets,e):{}}async function Ee({decorationParams:e,operationSettings:t,cardIframeUrl:n}){const{cardId:a,allowPinReveal:r,allowBlocking:o}=e,{uiParentElementId:i,debugMode:s}=t,c=function(e,t){const n=new URL(e);n.searchParams.set("cardId",t.cardId),"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const a=ke(_e);return Object.keys(a).length>0&&n.searchParams.set("customization",JSON.stringify(a)),n.toString()}(n,{cardId:a,allowPinReveal:r,allowBlocking:o,debugMode:s}),d=await me({iframeUrl:c,parentElementId:i});return{destroyEmbedUI:()=>{d.destroy()}}}const Ae={getCards:async function(e){try{const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new i("membershipId must be a string");const{proxyRequestFunction:n,stagingToken:a}=I(e?.operationSettings||{});if(n){const e=F(G({membershipId:t,stagingToken:a})),r=await n(e);return B(r).body.cards.map((e=>ye(e)))}{const n=e?.operationSettings?.accessToken||o(),r=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a=G({membershipId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r}({membershipId:t,accessToken:n,stagingToken:a});return r.map((e=>ye(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:t}){try{!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId parameter is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e);const n=e.cardId,{proxyRequestFunction:a,stagingToken:r}=I(t||{});if(a){const e=F(K({cardId:n,stagingToken:r})),t=await a(e),o=B(t).body.cards;if(Array.isArray(o)&&o.length>0)return ye(o[0]);throw new i("Unable to retrieve card data")}{const e=t?.accessToken||o(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const a=K({cardId:e,accessToken:t,stagingToken:n}),{cards:r}=await j(a);return r[0]}({cardId:n,accessToken:e,stagingToken:r});return ye(a)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});re(e.cardSettings);const i=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),s=await me({iframeUrl:i,parentElementId:a}),c=be(e.cardSettings),d=await s.postMessage(c);return s.destroy(),ye(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=o(),{uiParentElementId:a,debugMode:r}=I(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t)}(e.cardSettings);const s=he({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:r}),d=await me({iframeUrl:s,parentElementId:a}),l=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),u=await d.postMessage(l);return d.destroy(),ye(u)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:a,debugMode:r,mfaPreference:s,proxyRequestFunction:c}=I(e.operationSettings,{requiresUI:!0});if(function(e){if(!e)throw new i("cardSettings parameter is required for the called function");if(!e.cardId)throw new i("cardId is required for the called function");const t=X({cardId:e.cardId});if(t.length>0)throw new i(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=ee(n);if(a.length>0)throw new i(a)}(e.cardSettings),c){const n=F(Y({stagingToken:a})),o=await c(n),i=B(o).body;return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r},cardIframeUrl:i.url})}{const i=n||o(),c=await async function(e){const t=Y(e),{embed_auth_link:n}=await j(t);return n}({...e.cardSettings,accessToken:i,stagingToken:a});return Ee({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:r,mfaPreference:s},cardIframeUrl:c.url})}}catch(e){return Promise.reject(e)}}},Se=Ae;function Ie(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function $e({endpointUrl:e,paginationSettings:t}){return function({url:e,searchParams:t}){const n=new URL(e.toString());for(const[e,a]of t.entries())n.searchParams.append(e,a);return n}({url:new URL(e),searchParams:Ie(t)})}function Re(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 Pe(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 Ce(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 Le="/v2/sepa/beneficiaries";function Ne({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Le}${o}`,options:a}}function qe({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${Le}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Oe({accessToken:e,stagingToken:t,beneficiaryId:n}){const a=qe({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:r}=await j(a);return r}function De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){return{path:Le,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:a},body:{beneficiary:Ce(e)}}}}function Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${Le}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}function xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const{name:o,email:i,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r},body:{beneficiary:{name:o,email:i,activity_tag:s}}};return{path:`${Le}/${e.id}`,options:c}}const Me=[{name:"name"},{name:"iban"}];const ze={getBeneficiaries:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(Ne({paginationSettings:r})),t=B(await n(e)),a=t.body.beneficiaries.map((e=>Pe(e))),o=Re(t.body.meta);return{beneficiaries:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a=Ne({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:r,meta:o}=await j(a);return{beneficiaries:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.beneficiaries.map((e=>Pe(e))),s=Re(n.meta);return{beneficiaries:i,...s?{meta:s}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(qe({beneficiaryId:n}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o();return Pe(await Oe({beneficiaryId:n,accessToken:e,stagingToken:s}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new i("beneficiary must be an object");Q(e,Me);const t=X({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new i(t);return e}(e),{proxyRequestFunction:a,accessToken:r,stagingToken:s,idempotencyKey:c}=I(t||{});if(a){const e=F(De({beneficiary:n,idempotencyKey:c}));return Pe(B(await a(e)).body.beneficiary)}{const e=r||o(),t=await async function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=ge()}){const r=De({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a}),{beneficiary:o}=await j(r);return o}({beneficiary:n,accessToken:e,stagingToken:s,idempotencyKey:c});return Pe(t)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:a,activityTag:r}=e||{};if(!t)throw new i("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!r)throw new i("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=X({name:n,email:a,activityTag:r});if(o.length>0)throw new i(o);return{id:t,name:n,email:a,activityTag:r}}(e),{stagingToken:a,idempotencyKey:r,mfaPreference:s,proxyRequestFunction:c}=I(t),d={beneficiaryParamsBeingEdited:n,idempotencyKey:r,mfaPreference:s};if(c){const e=F(xe(d));return Pe(B(await c(e)).body.beneficiary)}{const e=t?.accessToken||o(),n=await async function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}){const o=xe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:r}),{beneficiary:i}=await j(o);return i}({...d,accessToken:e,stagingToken:a});return Pe(n)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new i("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ue({beneficiaryIds:n}));return B(await a(e)).body.beneficiaries.map(Pe)}{const e=r||o(),t=await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const a=Ue({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:r}=await j(a);return r}({beneficiaryIds:n,accessToken:e,stagingToken:s});return t.map(Pe)}}},je=ze;function Fe(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 Be(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}function He(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 Ge(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}:{}}}function Ke(e){return{name:e.name,iban:e.iban}}const Ye="/v2/sepa",Ve=`${Ye}/transfers`;function We({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},r=Ie(e),o=r.size?`?${r.toString()}`:"";return{path:`${Ve}${o}`,options:a}}function Ze({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Je({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ve}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}async function Qe({sepaPayee:e,accessToken:t,stagingToken:n}){const a=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await j(a)}const Xe="/v2/sepa/bulk_transfers";async function et({sepaPayees:e,accessToken:t,stagingToken:n}){const a=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Ke)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await j(a)}function tt(e){if(!e)throw new i("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new i("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new i("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new i("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new i(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new i(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new i(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=X({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),a=te({amount:e.amount}),r=[...n,...a].flat();if(r.length>0)throw new i(r);if(e.amount>p&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new i(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const nt="browser",at="server";class rt extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case nt:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case at: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 ot=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function it(e,t){const n=t?.locale||L.getLocale(),a=new URL(e);return n&&a.searchParams.append("lang",n),t?.mfaPreference&&a.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&a.searchParams.append("idempotencyKey",t.idempotencyKey),a.toString()}function st(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}const ct={request:async function({requestSettings:e,operationSettings:t}){!function(e){if(!e||"object"!=typeof e)throw new i("requestSettings must be an object");const t=e,{action:n,callbackUrl:a}=e;Q(t,[{name:"action"}]);const r=X(t),o=Object.values(m);if(o.includes(n)||r.push(`action must be one of ${o.join(", ")}`),r.length>0)throw new i(r);if(void 0!==a&&""===a.trim())throw new i("callbackUrl cannot be empty")}(e);const{proxyRequestFunction:n,stagingToken:a}=I(t||{});if(n){const t=F(H({stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}));return st(B(await n(t)).body)}{const n=t?.accessToken||o();return st(await async function(e){const t=H({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await j(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}({accessToken:n,stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}))}}};async function dt(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{});if(n){const e=F(We({paginationSettings:r})),t=B(await n(e)),a=t.body.transfers.map(He),o=Re(t.body.meta);return{transfers:a,...o?{meta:o}:{}}}{const e=a||o(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a=We({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:r,meta:o}=await j(a);return{transfers:r,meta:o}}({accessToken:e,stagingToken:t,paginationSettings:r}),i=n.transfers.map(He),s=Re(n.meta);return{transfers:i,...s?{meta:s}:{}}}}const lt={getSepaTransfers:dt,getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Ze({sepaTransferId:n}));return He(B(await a(e)).body.transfer)}{const e=r||o(),t=await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a=Ze({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:r}=await j(a);return r}({sepaTransferId:n,accessToken:e,stagingToken:s});return He(t)}},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),s=t?.idempotencyKey||ge();let d;!function(e){if(!e)throw new i("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new i("sepaTransferSettings must be an object");if(!e.beneficiaryId&&!e.beneficiary)throw new i("Either beneficiaryId or beneficiary must be provided");const t=X({beneficiaryId:e.beneficiaryId});if(t.length>0)throw new i(t)}(e);const l=await async function({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:Pe(await Oe({beneficiaryId:e?.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}({sepaTransferSettings:e,operationSettings:{accessToken:a,stagingToken:r||void 0}}),u={name:l.name,iban:l.iban},g=await Qe({sepaPayee:u,accessToken:a,stagingToken:r||void 0}),f=yield(m=g,{matchResult:m.match_result,matchedName:m.matched_name});var m;let b;if("string"==typeof f){if(f===h.REJECT)return}else{if(f.vopDecision===h.REJECT)return;b=f.sepaTransferSettings}const y={...e,...b};!function(e){if(!e)throw new i("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new i("sepaTransferSettings must be an object");Q(e,ot);const t=[...X({bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...te({amount:e.amount})].flat();if(t.length>0)throw new i(t);if(e.amount>p&&(!e.attachmentIds||0===e.attachmentIds.length))throw new i("Attachments are required for transfers over €30,000")}(y);const v={...y,beneficiary:l};if(v.beneficiary?.trusted)d=await async function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:a,idempotencyKey:r}){const o=Ge(e),i={method:"POST",headers:z({accessToken:n,stagingToken:a,idempotencyKey:r}),body:JSON.stringify({transfer:o,vop_proof_token:t})},s=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ve}`,c=await fetch(s,i),d=await c.json();if(d.errors)throw new U(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.transfer}({transfer:v,vopProofToken:g.proof_token.token,accessToken:a,stagingToken:r||void 0,idempotencyKey:s});else{if(!x())throw new rt(nt);const{uiParentElementId:e,debugMode:n}=I(t,{requiresUI:!0});let o;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:n});o=await me({iframeUrl:t,parentElementId:e});const i=Ge(v);d=await o.postMessage(fe({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...i}},idempotencyKey:s}}))}finally{o?.destroy()}}return He(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new i("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new i("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:r,stagingToken:s}=I(t||{});if(a){const e=F(Je({sepaTransferId:n}));B(await a(e))}else{const e=r||o();await async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a=Je({sepaTransferId:e,accessToken:t,stagingToken:n});await j(a)}({sepaTransferId:n,accessToken:e,stagingToken:s})}},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new i("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new i("callbackUrl must be a string");return e.callbackUrl}(e),{proxyRequestFunction:a,stagingToken:r,accessToken:s}=I(t||{}),c=a?{proxyRequestFunction:a}:{stagingToken:r,accessToken:s||o()},d=await ct.request({requestSettings:{action:m.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:c});return{...d,url:it(d.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:t}=e||{},n=t?.accessToken||o(),{stagingToken:a,paginationSettings:r}=I(t||{}),i=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=$e({endpointUrl:new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}`),paginationSettings:n}),o=await fetch(r,a);if(!o.ok)throw new U("Failed to fetch SEPA bulk transfers");const i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:i.bulk_transfers,meta:i.meta}}({accessToken:n,stagingToken:a,paginationSettings:r}),s=i.bulkTransfers?.map(Fe),c=Re(i.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||o(),{stagingToken:a}=I(t||{}),r=function(e){if(!e)throw new i("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new i("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Fe(await async function({accessToken:e,stagingToken:t,bulkTransferId:n}){const a={method:"GET",headers:z({accessToken:e,stagingToken:t})},r=new URL(`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}/${n}`),o=await fetch(r,a),i=await o.json();if(i.errors)throw new U(i.errors.map((e=>`${e.code}: ${e.detail}`)));return i.bulk_transfer}({accessToken:n,stagingToken:a,bulkTransferId:r}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const a=t?.accessToken||o(),r=t?.stagingToken||n.getStagingToken(),i=t?.idempotencyKey||ge();tt(e);const{uiParentElementId:s,debugMode:d}=I(t,{requiresUI:!0});if(!x())throw new rt(nt);const l=new Map;for(const t of e.bulkTransfers){const e=t.beneficiary.iban;e&&!l.has(e)&&l.set(e,{name:t.beneficiary.name,iban:e})}const u=Array.from(l.values()),g=await et({sepaPayees:u,accessToken:a,stagingToken:r||void 0});if((yield g.requests.map(Be))===h.REJECT)return;let f,p;try{const t=he({accessToken:a,stagingToken:r||void 0,debugMode:d});p=await me({iframeUrl:t,parentElementId:s});const n={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};f=await p.postMessage(fe({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:n,idempotencyKey:i}}))}finally{p?.destroy()}return Fe(f)}}},ut={GOOD:"good",SERVICE:"service"},gt={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},ft=e=>{if(!(e=>Object.values(gt).includes(e))(e))throw new i(`currency ${e} is not valid, valid currencies are ${Object.values(gt).join(", ")}`)},pt={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},ht=e=>{if(!(e=>Object.values(pt).includes(e))(e))throw new i(`unit ${e} is not valid, valid units are ${Object.values(pt).join(", ")}`)},mt=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],bt=[{name:"currency"},{name:"value"}];const yt=e=>{if(!Object.values(ut).includes(e))throw new i(`type ${e} is not valid, valid types are ${Object.values(ut).join(", ")}`)},vt={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e})=>{const{items:t,authUrl:n}=e;!function(e){if(!e)throw new i("authUrl is required for the called function");const t=X({authUrl:e});if(t.length>0)throw new i(t);try{new URL(e)}catch{throw new i("authUrl is not a valid URL")}}(n),function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{Q(e,mt),Q(e.unitPrice,bt);const t=[...X({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...te({quantity:e.quantity})].flat();if(t.length>0)throw new i(t);yt(e.type),ft(e.unitPrice.currency),ht(e.measureUnit)}))}(t);const a=new URLSearchParams({...t?{items:JSON.stringify(t)}:{}});return a.toString()?`${n}?${a.toString()}`:n}},_t=({accessToken:e,stagingToken:t})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}),wt=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),Tt={getBankAccounts:async e=>{const{stagingToken:t,proxyRequestFunction:n}=I(e);if(n){const e=_t({stagingToken:t}),a=await n(F(e)),{body:r}=B(a);return r.organization.bank_accounts.map(wt)}{const n=e.accessToken||o(),a=await(async({accessToken:e,stagingToken:t})=>{const n=_t({accessToken:e,stagingToken:t});return await j(n)})({accessToken:n,stagingToken:t});return a.organization.bank_accounts.map(wt)}}},kt="/v2/transactions";function Et({bankAccountId:e,iban:t,status:n,updatedAtFrom:a,updatedAtTo:r,emittedAtFrom:o,emittedAtTo:i,settledAtFrom:s,settledAtTo:c,side:d,operationType:l,withAttachments:u,paginationSettings:g,accessToken:f,stagingToken:p}){const h={method:"GET",headers:{accessToken:f,stagingToken:p}},m=new URLSearchParams;e&&m.append("bank_account_id",e),t&&m.append("iban",t),n&&m.append("status",n),a&&m.append("updated_at_from",a),r&&m.append("updated_at_to",r),o&&m.append("emitted_at_from",o),i&&m.append("emitted_at_to",i),s&&m.append("settled_at_from",s),c&&m.append("settled_at_to",c),d&&m.append("side",d),l&&m.append("operation_type",l),void 0!==u&&m.append("with_attachments",String(u));const b=Ie(g);for(const[e,t]of b)m.append(e,t);const y=m.toString();return{path:`${kt}${y?`?${y}`:""}`,options:h}}function At({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${kt}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function St(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const It={getTransactions:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:r}=I(e?.operationSettings||{}),i={...e?.transactionSettings||{},paginationSettings:r};if(n){const e=F(Et(i)),t=B(await n(e));return{transactions:t.body.transactions.map(St),meta:t.body.meta}}{const e=a||o(),n=await async function(e){const t=Et(e),{transactions:n,meta:a}=await j(t);return{transactions:n,meta:a}}({...i,accessToken:e,stagingToken:t});return{transactions:n.transactions.map(St),meta:n.meta}}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{proxyRequestFunction:n,accessToken:a,stagingToken:r}=I(t||{}),{transactionId:s}=function(e){if(!e)throw new i("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new i("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new i("transactionSettings.transactionId must be a string.");return e}(e);if(n){const e=F(At({transactionId:s}));return St(B(await n(e)).body.transaction)}{const e=a||o();return St(await async function(e){const t=At(e),{transaction:n}=await j(t);return n}({transactionId:s,accessToken:e,stagingToken:r}))}}},$t=It;function Rt(e,t,n,a){var r,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(i=(o<3?r(i):o>3?r(t,n,i):r(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}"function"==typeof SuppressedError&&SuppressedError;
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
@@ -687,4 +687,4 @@ const Wa=2;class Za{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n)
687
687
  >${Wn("Next")}</qonto-button
688
688
  </div>
689
689
  </div>`:""}
690
- `}};pr.styles=ma,Rt([Bn({type:Object})],pr.prototype,"operationSettings",void 0),Rt([Bn({type:String})],pr.prototype,"locale",void 0),Rt([Hn()],pr.prototype,"transfers",void 0),Rt([Hn()],pr.prototype,"paginationState",void 0),Rt([Hn()],pr.prototype,"isLoading",void 0),Rt([Hn()],pr.prototype,"error",void 0),pr=Rt([(e,t)=>(e.addInitializer(Qn),e),zn("qonto-transfer-list")],pr);const hr={TRANSFER_LIST:"transfer-list"};e.authLinks=ct,e.beneficiaries=je,e.cards=Se,e.constants=D,e.createUIElement=async({uiElementSettings:e,operationSettings:t})=>{if(M())return;const{uiElementName:n}=function(e){if(!e?.uiElementName)throw new i("uiElementSettings.uiElementName is required when calling createUIElement");const t=Object.values(hr);if(!t.includes(e?.uiElementName))throw new i(`uiElementSettings.uiElementName must be one of ${t.join(", ")}`);return{uiElementName:e.uiElementName}}(e),{uiParentElementId:a}=I(t,{requiresUI:!0}),r=document.getElementById(a);if(!r)throw new Error(`Could not find container element with id: ${a}`);if(n===hr.TRANSFER_LIST)return void await function({containerElement:e,uiElementSettings:t,operationSettings:n}){const a=document.createElement("qonto-transfer-list");a.operationSettings=n,a.locale=n?.locale||L.getLocale(),a.addEventListener("transfer-selected",(e=>{t?.uiElementEventListener?.({eventName:"transfer-selected",eventDetail:e.detail})})),e.appendChild(a)}({containerElement:r,uiElementSettings:e,operationSettings:t});const o=document.createElement(`qonto-${n}`);r.appendChild(o)},e.initialize=q,e.logout=O,e.organizations=Tt,e.paymentLinks=vt,e.sepaTransfers=lt,e.transactions=$t}));
690
+ `}};pr.styles=ma,Rt([Bn({type:Object})],pr.prototype,"operationSettings",void 0),Rt([Bn({type:String})],pr.prototype,"locale",void 0),Rt([Hn()],pr.prototype,"transfers",void 0),Rt([Hn()],pr.prototype,"paginationState",void 0),Rt([Hn()],pr.prototype,"isLoading",void 0),Rt([Hn()],pr.prototype,"error",void 0),pr=Rt([(e,t)=>(e.addInitializer(Qn),e),zn("qonto-transfer-list")],pr);const hr={TRANSFER_LIST:"transfer-list"};class mr extends a{constructor(e){super(),this.name="EmbedUIElementError",this.message=e}}const br={createUIElement:async e=>{if(M())return;const{uiElementSettings:t,operationSettings:n={}}=e,{uiElementName:a}=function(e){if(!e?.uiElementName)throw new i("uiElementSettings.uiElementName is required when calling createUIElement");const t=Object.values(hr);if(!t.includes(e?.uiElementName))throw new i(`uiElementSettings.uiElementName must be one of ${t.join(", ")}`);return{uiElementName:e.uiElementName}}(t),{uiParentElementId:r}=I(n,{requiresUI:!0}),o=document.getElementById(r);if(!o)throw new mr(`Could not find container element with id: ${r}`);if(a===hr.TRANSFER_LIST)return void function({containerElement:e,uiElementSettings:t,operationSettings:n}){const a=document.createElement("qonto-transfer-list");a.operationSettings=n,a.locale=n?.locale||L.getLocale(),a.addEventListener("transfer-selected",(e=>{t?.uiElementEventListener?.({eventName:"transfer-selected",eventDetail:e.detail})})),e.appendChild(a)}({containerElement:o,uiElementSettings:t,operationSettings:n});const s=document.createElement(`qonto-${a}`);o.appendChild(s)}};e.authLinks=ct,e.beneficiaries=je,e.cards=Se,e.constants=D,e.initialize=q,e.logout=O,e.organizations=Tt,e.paymentLinks=vt,e.sepaTransfers=lt,e.transactions=$t,e.ui=br}));
@@ -69,6 +69,8 @@ export declare const ACCOUNT_STATUS: {
69
69
  readonly PENDING: "pending";
70
70
  };
71
71
  export type OrganizationDataObject = {
72
- bank_accounts: BankAccountDataObject[];
72
+ organization: {
73
+ bank_accounts: BankAccountDataObject[];
74
+ };
73
75
  };
74
76
  //# sourceMappingURL=organizations.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.types.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC,CAAC"}
1
+ {"version":3,"file":"organizations.types.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE;QACZ,aAAa,EAAE,qBAAqB,EAAE,CAAC;KACxC,CAAC;CACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CancelSepaTransferParams, GetSepaTransfer, GetSepaTransfersResponse, NewSepaTransfer, SepaTransfer, SepaTransferCreationFlowRequest, SepaTransferParams, VopVerificationResult } from './sepa-transfers.types';
1
+ import type { BeneficiaryInformationForVop, CancelSepaTransferParams, GetSepaTransfer, GetSepaTransfersResponse, NewSepaTransfer, SepaTransfer, SepaTransferCreationFlowRequest, SepaTransferParams, VopVerificationResult } from './sepa-transfers.types';
2
2
  import type { AuthLinkRequestResult } from '@auth-links/auth-links.types';
3
3
  /**
4
4
  * Fetches the list of SEPA transfers for the current user.
@@ -53,9 +53,20 @@ export declare function getSepaTransfer({ sepaTransferSettings, operationSetting
53
53
  * Once the transfer creation process is completed, the generator will return
54
54
  * the created SEPA transfer.
55
55
  * @param createTransferParams - An object with the parameters to create the
56
- * transfer. If it was not provided when calling the SDK's `initialize`
56
+ * transfer. When making the call to create the generator, not all the transfer
57
+ * details are required but only the beneficiary related data (beneficiaryId or
58
+ * beneficiary object). The rest of the transfer details can be provided later,
59
+ * after the VoP check is completed, and the caller calls next(). That next()
60
+ * call must include the remaining information if it was not provided at the
61
+ * beginning. This allows the caller to get only beneficiary details to start
62
+ * the process and require the user to give the transfer data after the VoP
63
+ * result.
64
+ * If it was not provided when calling the SDK's `initialize`
57
65
  * function, an `operationSettings` object has to be passed too with the
58
- * `accessToken` and `stagingToken` values. If the transfer needs to be created
66
+ * authentication information, which should ideally be the `proxyRequestFunction`,
67
+ * or alternatively the `accessToken` (not recommended for security reasons). The
68
+ * `operationSettings` object can have other data, like the `stagingToken`.
69
+ * If the transfer needs to be created
59
70
  * for an untrusted beneficiary, the `operationSettings` object must also include
60
71
  * the `uiParentElementId` property. This has to specify the ID of the DOM element
61
72
  * where the UI for MFA will be displayed. Note that this means that creating
@@ -80,8 +91,59 @@ export declare function getSepaTransfer({ sepaTransferSettings, operationSetting
80
91
  * @throws `InvalidRuntimeError` If a transfer for an untrusted beneficiary is
81
92
  * attempted to be created in the server. This scenario requires to be performed
82
93
  * from a browser.
94
+ * @example Passing the transfer details after the VoP check:
95
+ * ```typescript
96
+ * const transferCreationProcess = sepaTransfers.createSepaTransfer({
97
+ * sepaTransferSettings: {
98
+ * beneficiaryId: 'benef_12345',
99
+ * },
100
+ * operationSettings: {
101
+ * uiParentElementId: 'sepa-transfer-container',
102
+ * },
103
+ * });
104
+ * // First, we get the VoP verification result
105
+ * const vopCheckResult = await transferCreationProcess.next();
106
+ * // Here, you would typically show the result to the user and ask for confirmation
107
+ * // If the user accepts to proceed with the transfer creation
108
+ * const createdTransfer = await transferCreationProcess.next({
109
+ * vopDecision: VOP_DECISIONS.ACCEPT,
110
+ * sepaTransferSettings: {
111
+ * bankAccountId: 'ba_67890',
112
+ * amount: 1500,
113
+ * amountCurrency: 'EUR',
114
+ * reference: 'Invoice 12345',
115
+ * note: 'Payment for services',
116
+ * scheduledDate: new Date(),
117
+ * },
118
+ * });
119
+ * ```
120
+ *
121
+ * @example Providing all the transfer details at the beginning:
122
+ * ```typescript
123
+ * const transferCreationProcess = sepaTransfers.createSepaTransfer({
124
+ * sepaTransferSettings: {
125
+ * beneficiaryId: 'benef_12345',
126
+ * bankAccountId: 'ba_67890',
127
+ * amount: 1500,
128
+ * amountCurrency: 'EUR',
129
+ * reference: 'Invoice 12345',
130
+ * note: 'Payment for services',
131
+ * scheduledDate: new Date(),
132
+ * },
133
+ * operationSettings: {
134
+ * uiParentElementId: 'sepa-transfer-container',
135
+ * },
136
+ * });
137
+ * // First, we get the VoP verification result
138
+ * const vopCheckResult = await transferCreationProcess.next();
139
+ * // Here, you would typically show the result to the user and ask for confirmation
140
+ * // If the user accepts to proceed with the transfer creation
141
+ * const createdTransfer = await transferCreationProcess.next({
142
+ * vopDecision: VOP_DECISIONS.ACCEPT,
143
+ * });
144
+ * ```
83
145
  */
84
- export declare function createSepaTransfer({ sepaTransferSettings, operationSettings, }: SepaTransferParams<NewSepaTransfer>): AsyncGenerator<VopVerificationResult, SepaTransfer | undefined>;
146
+ export declare function createSepaTransfer({ sepaTransferSettings, operationSettings, }: SepaTransferParams<NewSepaTransfer | BeneficiaryInformationForVop>): AsyncGenerator<VopVerificationResult, SepaTransfer | undefined>;
85
147
  /**
86
148
  * Cancels an existing SEPA transfer identified by the provided `sepaTransferId`.
87
149
  * @param cancelSepaTransferParams - An object with the parameters to cancel the
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,+BAA+B,EAE/B,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AA+BhC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,GACjD,OAAO,CAAC,wBAAwB,CAAC,CAsDnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,EACpC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CA0B7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAuB,kBAAkB,CAAC,EACxC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,cAAc,CACrD,qBAAqB,EACrB,YAAY,GAAG,SAAS,CACzB,CAiGA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyBtF"}
1
+ {"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,+BAA+B,EAE/B,kBAAkB,EAGlB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAgChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,GACjD,OAAO,CAAC,wBAAwB,CAAC,CAsDnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,EACpC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CA0B7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AACH,wBAAuB,kBAAkB,CAAC,EACxC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CACnB,eAAe,GAAG,4BAA4B,CAC/C,GAAG,cAAc,CAAC,qBAAqB,EAAE,YAAY,GAAG,SAAS,CAAC,CAsHlE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyBtF"}
@@ -1,5 +1,5 @@
1
1
  import type { PaginationSettings, PaginationState } from '@common/api-pagination/api-pagination.types';
2
- import { TRANSFER_DECLINE_REASONS, TRANSFER_STATUSES, VOP_CHECK_RESULTS } from '@common/constants';
2
+ import { TRANSFER_DECLINE_REASONS, TRANSFER_STATUSES, VOP_CHECK_RESULTS, VOP_DECISIONS } from '@common/constants';
3
3
  import type { Beneficiary } from '@beneficiaries/beneficiaries.types';
4
4
  import type { OperationSettings } from '@validation/operation-settings-validation';
5
5
  import type { AuthLinkRequestSettings } from '@auth-links/auth-links.types';
@@ -163,6 +163,12 @@ export interface NewSepaTransfer {
163
163
  */
164
164
  attachmentIds?: string[];
165
165
  }
166
+ /**
167
+ * Used in the first step of creating a sepa transfer, moment in which the whole
168
+ * transfer object is not needed because the first step is the verification of
169
+ * payee, which only needs beneficiary information.
170
+ */
171
+ export type BeneficiaryInformationForVop = Pick<NewSepaTransfer, 'beneficiaryId' | 'beneficiary'>;
166
172
  /**
167
173
  * Represents the parameters required to fetch a SEPA transfer.
168
174
  * This interface is used to define the structure of the data needed to
@@ -231,6 +237,7 @@ export interface VopVerificationResult {
231
237
  matchedName?: string;
232
238
  }
233
239
  export type VopCheckResult = (typeof VOP_CHECK_RESULTS)[keyof typeof VOP_CHECK_RESULTS];
240
+ export type VopDecision = (typeof VOP_DECISIONS)[keyof typeof VOP_DECISIONS];
234
241
  /**
235
242
  * Parameters for the `getSepaTransferCreationFlowLink` function. It must be an
236
243
  * object with a single property `callbackUrl`, which is a string representing
@@ -238,5 +245,9 @@ export type VopCheckResult = (typeof VOP_CHECK_RESULTS)[keyof typeof VOP_CHECK_R
238
245
  * creation flow.
239
246
  */
240
247
  export type SepaTransferCreationFlowRequest = Omit<AuthLinkRequestSettings, 'action'>;
248
+ export interface VopDecisionWithExtraData {
249
+ vopDecision: VopDecision;
250
+ sepaTransferSettings?: NewSepaTransfer;
251
+ }
241
252
  export {};
242
253
  //# sourceMappingURL=sepa-transfers.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.types.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;GAEG;AACH,KAAK,0BAA0B,GAC7B,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,kBAAkB,CAAC;IAC3B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,cAAc,EAAE,0BAA0B,CAAC;IAC3C;;OAEG;IACH,aAAa,EAAE,IAAI,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACzB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAChD,uBAAuB,EACvB,QAAQ,CACT,CAAC"}
1
+ {"version":3,"file":"sepa-transfers.types.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;GAEG;AACH,KAAK,0BAA0B,GAC7B,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,kBAAkB,CAAC;IAC3B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,cAAc,EAAE,0BAA0B,CAAC;IAC3C;;OAEG;IACH,aAAa,EAAE,IAAI,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,eAAe,EACf,eAAe,GAAG,aAAa,CAChC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACzB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAChD,uBAAuB,EACvB,QAAQ,CACT,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,WAAW,CAAC;IACzB,oBAAoB,CAAC,EAAE,eAAe,CAAC;CACxC"}
@@ -1,4 +1,4 @@
1
- import type { NewSepaTransfer } from '@sepa-transfers/sepa-transfers.types';
1
+ import type { BeneficiaryInformationForVop } from '@sepa-transfers/sepa-transfers.types';
2
2
  import type { SepaTransferParams } from '@sepa-transfers/sepa-transfers.types';
3
3
  import type { OperationSettings } from '@validation/operation-settings-validation';
4
4
  /**
@@ -9,6 +9,6 @@ import type { OperationSettings } from '@validation/operation-settings-validatio
9
9
  * details, including the beneficiary or the beneficiary ID.
10
10
  * @returns A promise that resolves to a serialized beneficiary object.
11
11
  */
12
- export declare function findBeneficiary({ sepaTransferSettings, operationSettings, }: SepaTransferParams<NewSepaTransfer>): Promise<import("..").Beneficiary>;
12
+ export declare function findBeneficiary({ sepaTransferSettings, operationSettings, }: SepaTransferParams<BeneficiaryInformationForVop>): Promise<import("..").Beneficiary>;
13
13
  export declare function decorateUrlWithExtraParams(url: string, operationSettings: OperationSettings | undefined): string;
14
14
  //# sourceMappingURL=sepa-transfers.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.utils.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAGnF;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,EACpC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,qCAWrC;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,UAoBjD"}
1
+ {"version":3,"file":"sepa-transfers.utils.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAGnF;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,EACpC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,4BAA4B,CAAC,qCAWlD;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,UAoBjD"}
@@ -1,5 +1,6 @@
1
- import type { NewSepaTransfer, SepaTransferCreationFlowRequest } from '@sepa-transfers/sepa-transfers.types';
1
+ import type { BeneficiaryInformationForVop, NewSepaTransfer, SepaTransferCreationFlowRequest } from '@sepa-transfers/sepa-transfers.types';
2
2
  export declare function validateGetSepaTransferParams(sepaTransferId: string | undefined): string;
3
+ export declare function validateTransferBeneficiaryParams(sepaTransferSettings: BeneficiaryInformationForVop | undefined): BeneficiaryInformationForVop;
3
4
  export declare function validateCreateSepaTransferParams(sepaTransferSettings: NewSepaTransfer | undefined): NewSepaTransfer;
4
5
  export declare function validateCancelSepaTransferParams(sepaTransferId: string | undefined): string;
5
6
  export declare function validateGetSepaTransferCreationFlowLinkParams(params?: SepaTransferCreationFlowRequest): string;
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.validate.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.validate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAS9C,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,MAAM,CAUR;AAED,wBAAgB,gCAAgC,CAC9C,oBAAoB,EAAE,eAAe,GAAG,SAAS,mBAsDlD;AAED,wBAAgB,gCAAgC,CAC9C,cAAc,EAAE,MAAM,GAAG,SAAS,UAWnC;AAED,wBAAgB,6CAA6C,CAC3D,MAAM,CAAC,EAAE,+BAA+B,GACvC,MAAM,CAUR"}
1
+ {"version":3,"file":"sepa-transfers.validate.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.validate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,EACf,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAS9C,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,MAAM,CAUR;AAED,wBAAgB,iCAAiC,CAC/C,oBAAoB,EAAE,4BAA4B,GAAG,SAAS,GAC7D,4BAA4B,CA0B9B;AAED,wBAAgB,gCAAgC,CAC9C,oBAAoB,EAAE,eAAe,GAAG,SAAS,mBA4ClD;AAED,wBAAgB,gCAAgC,CAC9C,cAAc,EAAE,MAAM,GAAG,SAAS,UAWnC;AAED,wBAAgB,6CAA6C,CAC3D,MAAM,CAAC,EAAE,+BAA+B,GACvC,MAAM,CAUR"}
@@ -0,0 +1 @@
1
+ import{QontoEmbedSdkError as r}from"./QontoEmbedSdkError.js";class e extends r{constructor(r){super(),this.name="EmbedUIElementError",this.message=r}}export{e as EmbedUIElementError};
package/dist/src/index.js CHANGED
@@ -1 +1 @@
1
- export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";export{sepaTransfers}from"./sepa-transfers/index.js";export{paymentLinks}from"./payment-links/index.js";export{organizations}from"./organizations/index.js";export{transactions}from"./transactions/index.js";export{authLinks}from"./auth-links/index.js";export{createUIElement}from"./ui/index.js";
1
+ export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";export{sepaTransfers}from"./sepa-transfers/index.js";export{paymentLinks}from"./payment-links/index.js";export{organizations}from"./organizations/index.js";export{transactions}from"./transactions/index.js";export{authLinks}from"./auth-links/index.js";export{ui}from"./ui/index.js";
@@ -1 +1 @@
1
- import{makeNetworkCall as n}from"../common/network/network.js";const o=({accessToken:n,stagingToken:o})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}),e=async({accessToken:e,stagingToken:s})=>{const t=o({accessToken:e,stagingToken:s});return await n(t)};export{e as getOrganization,o as prepareGetOrganization};
1
+ import{makeNetworkCall as n}from"../common/network/network.js";const o=({accessToken:n,stagingToken:o})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}),e=async({accessToken:e,stagingToken:s})=>{const t=o({accessToken:e,stagingToken:s});return await n(t)};export{e as getOrganization,o as prepareGetOrganization};
@@ -1 +1 @@
1
- import"../common/auth/auth.js";import{validatePresenceOfAuthToken as o}from"../common/auth/auth.validate.js";import{prepareGetOrganization as t,getOrganization as n}from"./organizations.api.js";import{serializeBankAccount as a}from"./organizations.serializer.js";import{validateOperationSettingsParams as i}from"../validation/operation-settings-validation.js";import{encodeNetworkCall as s,decodeNetworkResponse as r}from"../common/network/network.js";const e=async e=>{const{stagingToken:m,proxyRequestFunction:c}=i(e);if(c){const o=t({stagingToken:m}),n=await c(s(o)),{body:i}=r(n);return i.bank_accounts.map(a)}{const t=e.accessToken||o();return(await n({accessToken:t,stagingToken:m})).bank_accounts.map(a)}};export{e as getBankAccounts};
1
+ import"../common/auth/auth.js";import{validatePresenceOfAuthToken as o}from"../common/auth/auth.validate.js";import{prepareGetOrganization as n,getOrganization as t}from"./organizations.api.js";import{serializeBankAccount as a}from"./organizations.serializer.js";import{validateOperationSettingsParams as i}from"../validation/operation-settings-validation.js";import{encodeNetworkCall as r,decodeNetworkResponse as s}from"../common/network/network.js";const e=async e=>{const{stagingToken:m,proxyRequestFunction:c}=i(e);if(c){const o=n({stagingToken:m}),t=await c(r(o)),{body:i}=s(t);return i.organization.bank_accounts.map(a)}{const n=e.accessToken||o();return(await t({accessToken:n,stagingToken:m})).organization.bank_accounts.map(a)}};export{e as getBankAccounts};
@@ -1 +1 @@
1
- import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as n}from"../common/auth/auth.validate.js";import{serializePaginationResponse as t}from"../common/api-pagination/api-pagination.js";import{prepareGetSepaTransfersCall as a,getSepaTransfers as s,prepareCancelSepaTransferCall as o,cancelSepaTransfer as r,verifySepaPayee as i,createSepaTransfer as c,prepareGetSepaTransferCall as m,getSepaTransfer as p}from"./sepa-transfers.api.js";import{serializeSepaTransfer as f,serializeToVopVerificationResult as g,serializeToNewSepaTransferDataObject as T}from"./sepa-transfers.serializer.js";import{validateGetSepaTransferCreationFlowLinkParams as u,validateCancelSepaTransferParams as d,validateCreateSepaTransferParams as k,validateGetSepaTransferParams as l}from"./sepa-transfers.validate.js";import{validateOperationSettingsParams as y}from"../validation/operation-settings-validation.js";import{buildIframeUrl as S,createIframe as w}from"../iframe/iframe-manager.js";import{buildIframeMessage as j}from"../iframe/iframe-message-builder.js";import{AUTH_LINK_ACTIONS as R,VOP_DECISIONS as E,ACTIONS as b}from"../common/constants.js";import{decorateUrlWithExtraParams as v,findBeneficiary as I}from"./sepa-transfers.utils.js";import{isRunningInBrowser as q}from"../common/runtime/runtime.validation.js";import{InvalidRuntimeError as x,RUNTIME_ENVIRONMENT as F}from"../errors/InvalidRuntimeError.js";import{encodeNetworkCall as _,decodeNetworkResponse as h}from"../common/network/network.js";import{authLinks as A}from"../auth-links/index.js";import P from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";async function C(e){const{stagingToken:o,proxyRequestFunction:r,accessToken:i,paginationSettings:c}=y(e?.operationSettings||{});if(r){const e=a({paginationSettings:c}),n=_(e),s=await r(n),o=h(s),i=o.body.transfers.map(f),m=t(o.body.meta);return{transfers:i,...m?{meta:m}:{}}}{const e=i||n(),a=await s({accessToken:e,stagingToken:o,paginationSettings:c}),r=a.transfers.map(f),m=t(a.meta);return{transfers:r,...m?{meta:m}:{}}}}async function K({sepaTransferSettings:e,operationSettings:t}){const a=l(e?.sepaTransferId),{proxyRequestFunction:s,accessToken:o,stagingToken:r}=y(t||{});if(s){const e=m({sepaTransferId:a}),n=_(e),t=await s(n),o=h(t);return f(o.body.transfer)}{const e=o||n(),t=await p({sepaTransferId:a,accessToken:e,stagingToken:r});return f(t)}}async function*M({sepaTransferSettings:t,operationSettings:a}){const s=a?.accessToken||n(),o=a?.stagingToken||e.getStagingToken(),r=a?.idempotencyKey||P();let m;k(t);const p=await I({sepaTransferSettings:t,operationSettings:{accessToken:s,stagingToken:o||void 0}}),u={name:p.name,iban:p.iban},d=await i({sepaPayee:u,accessToken:s,stagingToken:o||void 0});if((yield g(d))===E.REJECT)return;const l={...t,beneficiary:p};if(l.beneficiary?.trusted)m=await c({transfer:l,vopProofToken:d.proof_token.token,accessToken:s,stagingToken:o||void 0,idempotencyKey:r});else{if(!q())throw new x(F.BROWSER);const{uiParentElementId:e,debugMode:n}=y(a,{requiresUI:!0});let t;try{const a=S({accessToken:s,stagingToken:o||void 0,debugMode:n});t=await w({iframeUrl:a,parentElementId:e});const i=T(l);m=await t.postMessage(j({actionId:b.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...i}},idempotencyKey:r}}))}finally{t?.destroy()}}return f(m)}async function N({sepaTransferSettings:e,operationSettings:t}){const a=d(e?.sepaTransferId),{proxyRequestFunction:s,accessToken:i,stagingToken:c}=y(t||{});if(s){const e=o({sepaTransferId:a}),n=_(e),t=await s(n);h(t)}else{const e=i||n();await r({sepaTransferId:a,accessToken:e,stagingToken:c})}}async function U({sepaTransferSettings:e,operationSettings:t}){const a=u(e),{proxyRequestFunction:s,stagingToken:o,accessToken:r}=y(t||{}),i=s?{proxyRequestFunction:s}:{stagingToken:o,accessToken:r||n()},c=await A.request({requestSettings:{action:R.SEPA_TRANSFER_CREATE,callbackUrl:a},operationSettings:i});return{...c,url:v(c.url,t)}}export{N as cancelSepaTransfer,M as createSepaTransfer,K as getSepaTransfer,U as getSepaTransferCreationFlowLink,C as getSepaTransfers};
1
+ import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as n}from"../common/auth/auth.validate.js";import{serializePaginationResponse as t}from"../common/api-pagination/api-pagination.js";import{prepareGetSepaTransfersCall as s,getSepaTransfers as a,prepareCancelSepaTransferCall as o,cancelSepaTransfer as r,verifySepaPayee as i,createSepaTransfer as c,prepareGetSepaTransferCall as p,getSepaTransfer as m}from"./sepa-transfers.api.js";import{serializeSepaTransfer as f,serializeToVopVerificationResult as g,serializeToNewSepaTransferDataObject as T}from"./sepa-transfers.serializer.js";import{validateGetSepaTransferCreationFlowLinkParams as u,validateCancelSepaTransferParams as d,validateTransferBeneficiaryParams as k,validateCreateSepaTransferParams as l,validateGetSepaTransferParams as y}from"./sepa-transfers.validate.js";import{validateOperationSettingsParams as S}from"../validation/operation-settings-validation.js";import{buildIframeUrl as w,createIframe as j}from"../iframe/iframe-manager.js";import{buildIframeMessage as E}from"../iframe/iframe-message-builder.js";import{AUTH_LINK_ACTIONS as R,VOP_DECISIONS as b,ACTIONS as v}from"../common/constants.js";import{decorateUrlWithExtraParams as I,findBeneficiary as q}from"./sepa-transfers.utils.js";import{isRunningInBrowser as x}from"../common/runtime/runtime.validation.js";import{InvalidRuntimeError as F,RUNTIME_ENVIRONMENT as _}from"../errors/InvalidRuntimeError.js";import{encodeNetworkCall as h,decodeNetworkResponse as A}from"../common/network/network.js";import{authLinks as C}from"../auth-links/index.js";import P from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";async function K(e){const{stagingToken:o,proxyRequestFunction:r,accessToken:i,paginationSettings:c}=S(e?.operationSettings||{});if(r){const e=s({paginationSettings:c}),n=h(e),a=await r(n),o=A(a),i=o.body.transfers.map(f),p=t(o.body.meta);return{transfers:i,...p?{meta:p}:{}}}{const e=i||n(),s=await a({accessToken:e,stagingToken:o,paginationSettings:c}),r=s.transfers.map(f),p=t(s.meta);return{transfers:r,...p?{meta:p}:{}}}}async function M({sepaTransferSettings:e,operationSettings:t}){const s=y(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:o,stagingToken:r}=S(t||{});if(a){const e=p({sepaTransferId:s}),n=h(e),t=await a(n),o=A(t);return f(o.body.transfer)}{const e=o||n(),t=await m({sepaTransferId:s,accessToken:e,stagingToken:r});return f(t)}}async function*N({sepaTransferSettings:t,operationSettings:s}){const a=s?.accessToken||n(),o=s?.stagingToken||e.getStagingToken(),r=s?.idempotencyKey||P();let p;k(t);const m=await q({sepaTransferSettings:t,operationSettings:{accessToken:a,stagingToken:o||void 0}}),u={name:m.name,iban:m.iban},d=await i({sepaPayee:u,accessToken:a,stagingToken:o||void 0}),y=yield g(d);let R;if("string"==typeof y){if(y===b.REJECT)return}else{if(y.vopDecision===b.REJECT)return;R=y.sepaTransferSettings}const I={...t,...R};l(I);const h={...I,beneficiary:m};if(h.beneficiary?.trusted)p=await c({transfer:h,vopProofToken:d.proof_token.token,accessToken:a,stagingToken:o||void 0,idempotencyKey:r});else{if(!x())throw new F(_.BROWSER);const{uiParentElementId:e,debugMode:n}=S(s,{requiresUI:!0});let t;try{const s=w({accessToken:a,stagingToken:o||void 0,debugMode:n});t=await j({iframeUrl:s,parentElementId:e});const i=T(h);p=await t.postMessage(E({actionId:v.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...i}},idempotencyKey:r}}))}finally{t?.destroy()}}return f(p)}async function U({sepaTransferSettings:e,operationSettings:t}){const s=d(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:i,stagingToken:c}=S(t||{});if(a){const e=o({sepaTransferId:s}),n=h(e),t=await a(n);A(t)}else{const e=i||n();await r({sepaTransferId:s,accessToken:e,stagingToken:c})}}async function D({sepaTransferSettings:e,operationSettings:t}){const s=u(e),{proxyRequestFunction:a,stagingToken:o,accessToken:r}=S(t||{}),i=a?{proxyRequestFunction:a}:{stagingToken:o,accessToken:r||n()},c=await C.request({requestSettings:{action:R.SEPA_TRANSFER_CREATE,callbackUrl:s},operationSettings:i});return{...c,url:I(c.url,t)}}export{U as cancelSepaTransfer,N as createSepaTransfer,M as getSepaTransfer,D as getSepaTransferCreationFlowLink,K as getSepaTransfers};
@@ -1 +1 @@
1
- import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as r,validateExpectedStringValues as t,validateExpectedNumericValues as n}from"../validation/input-param-validation.js";import{AMOUNT_REQUIRING_ATTACHMENTS as a}from"../common/constants.js";const i=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function o(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 f(o){if(!o)throw new e("sepaTransferSettings parameter is required for the called function");if("object"!=typeof o)throw new e("sepaTransferSettings must be an object");if(r(o,i),!o.beneficiaryId&&!o.beneficiary)throw new e("Either beneficiaryId or beneficiary must be provided");const f=[...t({beneficiaryId:o.beneficiaryId,bankAccountId:o.bankAccountId,note:o.note,reference:o.reference}),...n({amount:o.amount})].flat();if(f.length>0)throw new e(f);if(o.amount>a&&(!o.attachmentIds||0===o.attachmentIds.length))throw new e("Attachments are required for transfers over €30,000");return o}function c(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}function s(r){if(!r||!r.callbackUrl)throw new e("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof r.callbackUrl)throw new e("callbackUrl must be a string");return r.callbackUrl}export{c as validateCancelSepaTransferParams,f as validateCreateSepaTransferParams,s as validateGetSepaTransferCreationFlowLinkParams,o as validateGetSepaTransferParams};
1
+ import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validateExpectedStringValues as r,validatePresenceOfRequiredParams as t,validateExpectedNumericValues as n}from"../validation/input-param-validation.js";import{AMOUNT_REQUIRING_ATTACHMENTS as a}from"../common/constants.js";const i=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function o(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 f(t){if(!t)throw new e("sepaTransferSettings parameter is required for the called function");if("object"!=typeof t)throw new e("sepaTransferSettings must be an object");if(!t.beneficiaryId&&!t.beneficiary)throw new e("Either beneficiaryId or beneficiary must be provided");const n=r({beneficiaryId:t.beneficiaryId});if(n.length>0)throw new e(n);return t}function s(o){if(!o)throw new e("sepaTransferSettings parameter is required for the called function");if("object"!=typeof o)throw new e("sepaTransferSettings must be an object");t(o,i);const f=[...r({bankAccountId:o.bankAccountId,note:o.note,reference:o.reference}),...n({amount:o.amount})].flat();if(f.length>0)throw new e(f);if(o.amount>a&&(!o.attachmentIds||0===o.attachmentIds.length))throw new e("Attachments are required for transfers over €30,000");return o}function c(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}function u(r){if(!r||!r.callbackUrl)throw new e("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof r.callbackUrl)throw new e("callbackUrl must be a string");return r.callbackUrl}export{c as validateCancelSepaTransferParams,s as validateCreateSepaTransferParams,u as validateGetSepaTransferCreationFlowLinkParams,o as validateGetSepaTransferParams,f as validateTransferBeneficiaryParams};
@@ -1 +1 @@
1
- import"./customizable-components/transfer-list/transfer-list.js";import{isRunningInServer as t}from"../common/runtime/runtime.validation.js";import{validateCreateUIElementParams as e}from"./ui-elements.validation.js";import{validateOperationSettingsParams as n}from"../validation/operation-settings-validation.js";import{UI_ELEMENT_NAMES as i}from"./ui-elements.constants.js";import{createTransferListElement as o}from"./ui-elements/transfer-list.js";const r=async({uiElementSettings:r,operationSettings:m})=>{if(t())return;const{uiElementName:s}=e(r),{uiParentElementId:a}=n(m,{requiresUI:!0}),l=document.getElementById(a);if(!l)throw new Error(`Could not find container element with id: ${a}`);if(s===i.TRANSFER_LIST)return void await o({containerElement:l,uiElementSettings:r,operationSettings:m});const u=document.createElement(`qonto-${s}`);l.appendChild(u)};export{r as createUIElement};
1
+ import{ui as i}from"./ui-elements.public-api.js";const e=i;export{e as ui};
@@ -0,0 +1 @@
1
+ import"./customizable-components/transfer-list/transfer-list.js";import{isRunningInServer as t}from"../common/runtime/runtime.validation.js";import{validateCreateUIElementParams as e}from"./ui-elements.validation.js";import{validateOperationSettingsParams as n}from"../validation/operation-settings-validation.js";import{UI_ELEMENT_NAMES as i}from"./ui-elements.constants.js";import{createTransferListElement as o}from"./ui-elements/transfer-list.js";import{EmbedUIElementError as r}from"../errors/EmbedUIElementError.js";const m=async m=>{if(t())return;const{uiElementSettings:s,operationSettings:a={}}=m,{uiElementName:l}=e(s),{uiParentElementId:u}=n(a,{requiresUI:!0}),d=document.getElementById(u);if(!d)throw new r(`Could not find container element with id: ${u}`);if(l===i.TRANSFER_LIST)return void o({containerElement:d,uiElementSettings:s,operationSettings:a});const p=document.createElement(`qonto-${l}`);d.appendChild(p)};export{m as createUIElement};
@@ -0,0 +1 @@
1
+ import{createUIElement as e}from"./ui-elements.js";const t={createUIElement:e};export{t as ui};
@@ -1,4 +1,16 @@
1
- import './customizable-components';
2
- import type { UIElementParams } from '@ui/ui-elements.types';
3
- export declare const createUIElement: ({ uiElementSettings, operationSettings, }: UIElementParams<unknown>) => Promise<void>;
1
+ /**
2
+ * The ui namespace contains all the functions related to UI Elements.
3
+ * It can be accessed like this:
4
+ * ```ts
5
+ * import { ui } from '@qonto/embed-sdk/ui';
6
+ * ```
7
+ *
8
+ * Then, the ui object contains the functions to perform UI Element operations:
9
+ * ```ts
10
+ * await ui.createUIElement(/* params here *\/);
11
+ * ```
12
+ */
13
+ export declare const ui: {
14
+ createUIElement: (createUIElementParams: import("./ui-elements.types").UIElementParams<unknown>) => Promise<void>;
15
+ };
4
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,uBAAuB,CAAC;AAKhF,eAAO,MAAM,eAAe,GAAU,2CAGnC,eAAe,CAAC,OAAO,CAAC,KAAG,OAAO,CAAC,IAAI,CA6BzC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,EAAE;;CAAyB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import './customizable-components';
2
+ import type { UIElementParams } from '@ui/ui-elements.types';
3
+ /**
4
+ * Creates a UI element based on the provided settings and appends it to the specified parent container.
5
+ * As the bare minimum, the `uiElementSettings` must include the `uiElementName`, and the `operationSettings`
6
+ * must include the `uiParentElementId` where the new element will be appended. This function requires
7
+ * authentication, which can be passed via the {@link OperationSettings} object.
8
+ * @param createUIElementParams - Parameters for creating the UI element, including settings for the element
9
+ * and operation:
10
+ * - `uiElementSettings` - Settings for the UI element to be created. Must include `uiElementName`, which
11
+ * determines the type of element to create. Example: `{ uiElementName: 'transfer-list' }`.
12
+ * - `operationSettings` - Settings for the operation, including the `uiParentElementId` where the new element
13
+ * will be appended. Must also include authentication details if required.
14
+ * @throws InvalidParametersError - Thrown if required parameters are missing or invalid in `uiElementSettings`
15
+ * or `operationSettings`.
16
+ * @throws EmbedUIElementError - Thrown if the specified parent container element cannot be found in the DOM.
17
+ */
18
+ export declare const createUIElement: (createUIElementParams: UIElementParams<unknown>) => Promise<void>;
19
+ //# sourceMappingURL=ui-elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-elements.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,uBAAuB,CAAC;AAMhF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAC1B,uBAAuB,eAAe,CAAC,OAAO,CAAC,KAC9C,OAAO,CAAC,IAAI,CA8Bd,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const ui: {
2
+ createUIElement: (createUIElementParams: import("./ui-elements.types.ts").UIElementParams<unknown>) => Promise<void>;
3
+ };
4
+ //# sourceMappingURL=ui-elements.public-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-elements.public-api.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.public-api.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,EAAE;;CAEd,CAAC"}
@@ -1,15 +1,52 @@
1
1
  import type { OperationSettings } from '@validation/operation-settings-validation';
2
2
  import { UI_ELEMENT_NAMES } from '@ui/ui-elements.constants';
3
+ /**
4
+ * Type representing the valid names of UI elements.
5
+ */
3
6
  type UIElementNames = (typeof UI_ELEMENT_NAMES)[keyof typeof UI_ELEMENT_NAMES];
7
+ /**
8
+ * Common event format for UI elements. Consists of two properties:
9
+ * `eventName` and optional `eventDetail`.
10
+ * The `eventName` property is a string that identifies the type of event
11
+ * emitted by the UI element.
12
+ * The `eventDetail` property is an optional object that contains additional
13
+ * information about the event. The structure of this object will depend on
14
+ * the specific event being emitted.
15
+ */
4
16
  interface UIElementEvent {
5
17
  eventName: string;
6
18
  eventDetail?: Record<string, unknown>;
7
19
  }
20
+ /**
21
+ * Common settings format for UI elements. Consists of three properties:
22
+ * `uiElementName`, `uiElementParams`, and `uiElementEventListener`.
23
+ * The `uiElementName` property is required and specifies the type of UI element
24
+ * to render.
25
+ * The `uiElementParams` property is a generic object that holds parameters that
26
+ * will depend on the specific UI element being created.
27
+ * The `uiElementEventListener` property is a callback function that will be
28
+ * invoked when the UI element emits events. It receives an event object
29
+ * containing the event name and optional event details. Each UI element
30
+ * will define its own set of events that can be listened to.
31
+ */
8
32
  export interface UIElementSettings<T> {
9
33
  uiElementName: UIElementNames;
10
- uiElementParams: T;
11
- uiElementEventListener: (event: UIElementEvent) => void;
34
+ uiElementParams?: T;
35
+ uiElementEventListener?: (event: UIElementEvent) => void;
12
36
  }
37
+ /**
38
+ * Common parameter format for UI element operations. Consists of an object with
39
+ * two properties: `uiElementSettings` and `operationSettings`.
40
+ * The `uiElementSettings` property is required and contains settings specific
41
+ * to the UI element being operated on. As the bare minimum, it must include
42
+ * the `uiElementName` to identify the type of UI element to be rendered.
43
+ * The `operationSettings` property is optional (if it has been passed to the
44
+ * initialize function previously) and contains settings related
45
+ * to the overall operation. For UI elements, it has to include at least the
46
+ * `uiParentElementId`, which specifies the DOM element where the UI element
47
+ * will be appended. In addition, it may include authentication details, in which
48
+ * the preferred method is to provide a `proxyRequestFunction`.
49
+ */
13
50
  export interface UIElementParams<T> {
14
51
  uiElementSettings: UIElementSettings<T>;
15
52
  operationSettings?: OperationSettings;
@@ -1 +1 @@
1
- {"version":3,"file":"ui-elements.types.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE/E,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,aAAa,EAAE,cAAc,CAAC;IAC9B,eAAe,EAAE,CAAC,CAAC;IACnB,sBAAsB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACzD;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACxC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
1
+ {"version":3,"file":"ui-elements.types.d.ts","sourceRoot":"","sources":["../../src/ui/ui-elements.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;GAEG;AACH,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE/E;;;;;;;;GAQG;AACH,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,aAAa,EAAE,cAAc,CAAC;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC;IACpB,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACxC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.43.0",
3
+ "version": "0.45.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {