@qonto/embed-sdk 0.12.0 → 0.13.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.
- package/dist/common/constants.d.ts +8 -3
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/network/network.d.ts +3 -1
- package/dist/common/network/network.d.ts.map +1 -1
- package/dist/common/operation-settings/operation-settings.d.ts +2 -1
- package/dist/common/operation-settings/operation-settings.d.ts.map +1 -1
- package/dist/common/operation-settings/operation-settings.types.d.ts +3 -0
- package/dist/common/operation-settings/operation-settings.types.d.ts.map +1 -0
- package/dist/common/runtime/runtime.validation.d.ts +3 -0
- package/dist/common/runtime/runtime.validation.d.ts.map +1 -0
- package/dist/common/runtime/runtime.validation.test.d.ts +2 -0
- package/dist/common/runtime/runtime.validation.test.d.ts.map +1 -0
- package/dist/errors/InvalidRuntimeError.d.ts +18 -0
- package/dist/errors/InvalidRuntimeError.d.ts.map +1 -0
- package/dist/index.umd.js +1 -1
- package/dist/mocks/handlers.d.ts +1 -1
- package/dist/mocks/handlers.d.ts.map +1 -1
- package/dist/sepa-transfers/sepa-transfers.d.ts +35 -10
- package/dist/sepa-transfers/sepa-transfers.d.ts.map +1 -1
- package/dist/sepa-transfers/sepa-transfers.serializer.d.ts.map +1 -1
- package/dist/sepa-transfers/sepa-transfers.types.d.ts +17 -4
- package/dist/sepa-transfers/sepa-transfers.types.d.ts.map +1 -1
- package/dist/sepa-transfers/sepa-transfers.utils.d.ts +12 -0
- package/dist/sepa-transfers/sepa-transfers.utils.d.ts.map +1 -0
- package/dist/sepa-transfers/sepa-transfers.utils.test.d.ts +2 -0
- package/dist/sepa-transfers/sepa-transfers.utils.test.d.ts.map +1 -0
- package/dist/sepa-transfers/sepa-transfers.validate.d.ts +1 -1
- package/dist/sepa-transfers/sepa-transfers.validate.d.ts.map +1 -1
- package/dist/src/common/constants.js +1 -1
- package/dist/src/common/network/network.js +1 -1
- package/dist/src/common/operation-settings/operation-settings.js +1 -1
- package/dist/src/common/runtime/runtime.validation.js +1 -0
- package/dist/src/errors/InvalidRuntimeError.js +1 -0
- package/dist/src/iframe/iframe-manager.js +1 -1
- package/dist/src/sepa-transfers/sepa-transfers.js +1 -1
- package/dist/src/sepa-transfers/sepa-transfers.serializer.js +1 -1
- package/dist/src/sepa-transfers/sepa-transfers.utils.js +1 -0
- package/dist/src/sepa-transfers/sepa-transfers.validate.js +1 -1
- package/dist/src/validation/operation-settings-validation.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.public-api.d.ts +2 -2
- package/dist/types/types.public-api.d.ts.map +1 -1
- package/dist/validation/operation-settings-validation.d.ts +19 -1
- package/dist/validation/operation-settings-validation.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ export declare const ACTIONS: {
|
|
|
17
17
|
CARD_UNLOCK: string;
|
|
18
18
|
CARD_SHOW_PIN: string;
|
|
19
19
|
CARD_SET_PIN: string;
|
|
20
|
-
|
|
20
|
+
TRANSFER_SINGLE_CREATE: string;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* List of possible environments the SDK can be used in.
|
|
@@ -81,7 +81,7 @@ export declare const LOCALES: {
|
|
|
81
81
|
IT: string;
|
|
82
82
|
PT: string;
|
|
83
83
|
};
|
|
84
|
-
export declare const
|
|
84
|
+
export declare const TRANSFER_DECLINE_REASONS: {
|
|
85
85
|
BENEFICIARY_BIC_INVALID: string;
|
|
86
86
|
BENEFICIARY_IBAN_INVALID: string;
|
|
87
87
|
BENEFICIARY_STATUS: string;
|
|
@@ -90,11 +90,16 @@ export declare const SEPA_TRANSFER_DECLINE_REASONS: {
|
|
|
90
90
|
DEBIT_ACCOUNT_INSUFFICIENT_FUNDS: string;
|
|
91
91
|
QONTO_PROCESSING_FAILED: string;
|
|
92
92
|
};
|
|
93
|
-
export declare const
|
|
93
|
+
export declare const TRANSFER_STATUSES: {
|
|
94
94
|
PENDING: string;
|
|
95
95
|
PROCESSING: string;
|
|
96
96
|
CANCELED: string;
|
|
97
97
|
DECLINED: string;
|
|
98
98
|
SETTLED: string;
|
|
99
99
|
};
|
|
100
|
+
export declare const MFA_METHODS: {
|
|
101
|
+
PASSKEY: string;
|
|
102
|
+
SMS_OTP: string;
|
|
103
|
+
PAIRED_DEVICE: string;
|
|
104
|
+
};
|
|
100
105
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;CAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCzB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;CAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCzB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;CAQpC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;CAM7B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAIvB,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { MfaMethod } from '@common/operation-settings/operation-settings.types';
|
|
1
2
|
interface BuildRequestHeadersParams {
|
|
2
3
|
accessToken: string;
|
|
3
4
|
stagingToken?: string;
|
|
4
5
|
idempotencyKey?: string;
|
|
6
|
+
mfaPreference?: MfaMethod;
|
|
5
7
|
}
|
|
6
|
-
export declare function buildRequestHeaders({ accessToken, stagingToken, idempotencyKey, }: BuildRequestHeadersParams): Headers;
|
|
8
|
+
export declare function buildRequestHeaders({ accessToken, stagingToken, idempotencyKey, mfaPreference, }: BuildRequestHeadersParams): Headers;
|
|
7
9
|
export {};
|
|
8
10
|
//# sourceMappingURL=network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/common/network/network.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/common/network/network.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAGrF,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,EAAE,yBAAyB,GAAG,OAAO,CAkBrC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OperationSettings } from '@validation/operation-settings-validation';
|
|
2
|
+
import type { MfaMethod } from '@common/operation-settings/operation-settings.types';
|
|
2
3
|
/**
|
|
3
4
|
* A singleton class to manage operation settings
|
|
4
5
|
*/
|
|
@@ -26,7 +27,7 @@ export declare class OperationSettingsManager {
|
|
|
26
27
|
* Gets the MFA preference
|
|
27
28
|
* @returns The current MFA preference or null if not set
|
|
28
29
|
*/
|
|
29
|
-
getMFAPreference():
|
|
30
|
+
getMFAPreference(): MfaMethod;
|
|
30
31
|
/**
|
|
31
32
|
* Gets the debug mode
|
|
32
33
|
* @returns The current debug mode or false if not set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-settings.d.ts","sourceRoot":"","sources":["../../../src/common/operation-settings/operation-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"operation-settings.d.ts","sourceRoot":"","sources":["../../../src/common/operation-settings/operation-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAGrF;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAClD,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO;IAIP;;OAEG;WACW,WAAW,IAAI,wBAAwB;IAOrD;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAY9D;;;OAGG;IACI,oBAAoB,IAAI,MAAM,GAAG,IAAI;IAI5C;;;OAGG;IACI,gBAAgB,IAAI,SAAS;IAIpC;;;OAGG;IACI,YAAY,IAAI,OAAO;IAG9B;;OAEG;IACI,aAAa,IAAI,IAAI;CAI7B;AAGD,eAAO,MAAM,wBAAwB,0BAAyC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-settings.types.d.ts","sourceRoot":"","sources":["../../../src/common/operation-settings/operation-settings.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.validation.d.ts","sourceRoot":"","sources":["../../../src/common/runtime/runtime.validation.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,YAEjC;AAED,wBAAgB,iBAAiB,YAEhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.validation.test.d.ts","sourceRoot":"","sources":["../../../src/common/runtime/runtime.validation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const RUNTIME_ENVIRONMENT: {
|
|
2
|
+
BROWSER: string;
|
|
3
|
+
SERVER: string;
|
|
4
|
+
};
|
|
5
|
+
type RuntimeEnvironment = (typeof RUNTIME_ENVIRONMENT)[keyof typeof RUNTIME_ENVIRONMENT];
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when the code is running in an unexpected runtime environment.
|
|
8
|
+
* This means that a server-only function is being called in a browser or that
|
|
9
|
+
* a browser-only function is being called in a server environment.
|
|
10
|
+
*/
|
|
11
|
+
export declare class InvalidRuntimeError extends Error {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new InvalidRuntimeError
|
|
14
|
+
*/
|
|
15
|
+
constructor(detectedEnvironment: RuntimeEnvironment);
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=InvalidRuntimeError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidRuntimeError.d.ts","sourceRoot":"","sources":["../../src/errors/InvalidRuntimeError.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;CAG/B,CAAC;AAEF,KAAK,kBAAkB,GACrB,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C;;OAEG;gBACS,mBAAmB,EAAE,kBAAkB;CAkBpD"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 i 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 r(){if(!n.hasAccessToken())throw new i;return n.getAccessToken()}class s 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")}`}}class o{constructor(){this.uiParentElementId=null,this.mfaPreference=null,this.debugMode=!1}static getInstance(){return o.instance||(o.instance=new o),o.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=null}}const c=o.getInstance();function d(e){const t=e?.uiParentElementId||c.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||c.getMFAPreference();if(n&&!["passkey","paired-device","sms-otp"].includes(n))throw new s("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const a=e?.debugMode||c.getDebugMode();if(void 0!==a&&"boolean"!=typeof a)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:a}}const m={READY:"qonto.ready"},l={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",TRANSFERS_CREATE:"transfers.create"},u={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},p={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},g={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"};var f=Object.freeze({__proto__:null,ACTIONS:l,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:p,ENVIRONMENTS:u,IFRAME_EVENTS:m,LOCALES:g,SEPA_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"},SEPA_TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"}});const h=Object.values(g);function _(e){if(!function(e){return h.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${h.join(", ")}.`);return e}function y(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&d(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&_(e.locale),e}const T="https://embed.qonto.com",I="https://embed-js{branch}.staging.qonto.co",E="https://embed.dev.qonto.co",A={[u.PRODUCTION]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[u.STAGING]:{IFRAME_BASE_URL:I,IFRAME_URL:`${I}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[u.LOCAL]:{IFRAME_BASE_URL:E,IFRAME_URL:`${E}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class w{constructor(){this.environment=u.PRODUCTION,this.branch=p.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(u).includes(e)?e:u.PRODUCTION,this.branch=Object.values(p).includes(t)?t:p.SANDBOX}static getInstance(){return w.instance||(w.instance=new w),w.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=u.PRODUCTION,this.branch=p.MASTER}getEnvironmentUrls(){if(this.environment===u.PRODUCTION)return A.production;{const e=A[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const b=w.getInstance();class L{constructor(){this.currentLocale="en"}static getInstance(){return L.instance||(L.instance=new L),L.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const R=L.getInstance();const k={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:i,environment:r,branch:s,locale:o}=y(e);n.setAccessToken(t),a&&n.setStagingToken(a),o&&R.setLocale(o),i&&c.setSettings(i),r&&(b.setEnvironment(r),s&&b.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),R.setDefaultLocale()},constants:f},{initialize:D,logout:S,constants:v}=k;class P 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 O({accessToken:e,stagingToken:t,idempotencyKey:a}){const i=new Headers;i.append("Authorization",`Bearer ${e}`);const r=t||n.getStagingToken();return r&&i.append("X-Qonto-Staging-Token",r),a&&i.append("X-Qonto-Idempotency-Key",a),i.append("Content-Type","application/json"),i.append("Accept-Language",R.getLocale()),i}async function N(e,t,n){const a={method:"GET",headers:O({accessToken:t,stagingToken:n})},i=b.getEnvironmentUrls().THIRD_PARTY_API_URL,r=await fetch(`${i}/v2/cards/${e.cardId}/data_view`,a),s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(s.iframe_url,e)}var U;!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"}(U||(U={}));const C={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 $,M;function B(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 s(n.map((e=>`Missing required parameter: ${e}`)))}function F(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function j(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function G(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"}($||($={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(M||(M={}));const Y=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],q=[...Y,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function x(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return B(e,Y),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:i,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,p=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),g=F({membershipId:t,organizationId:n,bankAccountId:a}),f=j({hasDailyLimit:i,hasTransactionLimit:r}),h=G({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=z(m),y=H(l),T=[...p,...g,...f,...h,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){B(e,q),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:i,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:p,hasForeignPaymentOption:g,hasOnlinePaymentOption:f,shipToBusiness:h,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:A,typeOfPrint:w}=e,b=function(e){return Object.values(M).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),L=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']:[]}(w),R=F({membershipId:t,organizationId:n,bankAccountId:a}),k=j({hasDailyLimit:i,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:p,hasForeignPaymentOption:g,hasOnlinePaymentOption:f,hasAtmDailyLimit:y,shipToBusiness:h}),D=G({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),S=z(m),v=H(l),P=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(A),O=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"]}(E,h),N=[...b,...R,...k,...D,...S,...v,...L,...P,...O];if(N.length>0)throw new s(N)}(e)}(e)}function z(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 H(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 V extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class K{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 V(`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",i),t(new V(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),i=t=>{t.data.eventId===m.READY&&(clearTimeout(a),window.removeEventListener("message",i),e(this))};window.addEventListener("message",i),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){return this.iframe&&this.iframe.contentWindow?new Promise(((t,n)=>{const a=i=>{if(i.data?.actionId===e.actionId){if("error"===i.data.status)return this.removeMessageListener(e.actionId,a),n(new V(`An error occurred when performing the action ${e.actionId}.\n${JSON.stringify(i.data.payload)}`));this.removeMessageListener(e.actionId,a),t(i.data.payload)}};this.addMessageListener(e.actionId,a),this.iframe?.contentWindow?.postMessage(e,this.targetOrigin)})):Promise.reject(new V("Attempted to perform an Embed operation without having the authentication UI initialized."))}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 X({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const i=a||!1,r=n||R.getLocale(),s=b.getEnvironmentUrls().IFRAME_URL,o=t?`&staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${i}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function Q({parentElementId:e,iframeUrl:t}){return new K({parentElementId:e,iframeUrl:t}).initialize()}const W=[];for(let e=0;e<256;++e)W.push((e+256).toString(16).slice(1));let J;const Z=new Uint8Array(16);var ee={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function te(e,t,n){if(ee.randomUUID&&!e)return ee.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!J){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");J=crypto.getRandomValues.bind(crypto)}return J(Z)}();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(W[e[t+0]]+W[e[t+1]]+W[e[t+2]]+W[e[t+3]]+"-"+W[e[t+4]]+W[e[t+5]]+"-"+W[e[t+6]]+W[e[t+7]]+"-"+W[e[t+8]]+W[e[t+9]]+"-"+W[e[t+10]]+W[e[t+11]]+W[e[t+12]]+W[e[t+13]]+W[e[t+14]]+W[e[t+15]]).toLowerCase()}(a)}function ne(e){return"virtual"===e.cardLevel?function(e){const t=ie(e.categories);return{actionId:l.CARD_ORDER,actionData:{idempotencyKey:te(),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=ie(e.categories);return{actionId:l.CARD_ORDER,actionData:{idempotencyKey:te(),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 ae(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 ie(e){const t=Object.values(C);return(e||[]).filter((e=>t.includes(e)))}const re={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const a=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const i=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:O({accessToken:t,stagingToken:n})},i=b.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${i}/v2/cards?holder_ids[]=${e}`:`${i}/v2/cards`,s=await fetch(r,a),o=await s.json();if(o.errors)throw new P(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:a,stagingToken:n});return i.map((e=>ae(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const a=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const i=await async function({cardId:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:O({accessToken:t,stagingToken:n})},i=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(i,a),s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:a,stagingToken:n});return ae(i)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:a,debugMode:i}=d(e.operationSettings);x(e.cardSettings);const s=X({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:i}),o=await Q({iframeUrl:s,parentElementId:a}),c=ne(e.cardSettings),m=await o.postMessage(c);return o.destroy(),ae(m)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:a,debugMode:i}=d(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=F({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=X({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:i}),c=await Q({iframeUrl:o,parentElementId:a}),m=function(e){return{actionId:l.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),u=await c.postMessage(m);return c.destroy(),ae(u)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const t=r(),{uiParentElementId:n}=d(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=F({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=j(n);if(a.length>0)throw new s(a)}(e.cardSettings);const a=await N(e.cardSettings,t),i=await Q({iframeUrl:a,parentElementId:n});return{destroyEmbedUI:()=>{i.destroy()}}}catch(e){return Promise.reject(e)}}},se=re;function oe({endpointUrl:e,paginationSettings:t}){const n=new URL(e);return t?.page&&n.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&n.searchParams.set("per_page",t.itemsPerPage.toString()),n}function ce(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 de(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 me(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";const ue=[{name:"name"},{name:"iban"}];const pe={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:O({accessToken:t,stagingToken:n})},i=oe({endpointUrl:new URL(b.getEnvironmentUrls().THIRD_PARTY_API_URL+le),paginationSettings:e}),r=await fetch(i,a),s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),a=n.beneficiaries.map((e=>de(e))),i=ce(n.meta);return{beneficiaries:a,...i?{meta:i}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const a=t||r();!function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e);return de(await async function({accessToken:e,stagingToken:t,beneficiaryId:n}){const a={method:"GET",headers:O({accessToken:e,stagingToken:t})},i=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${le}/${n}`,r=await fetch(i,a),s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiaryId:e,accessToken:a,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const a=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");B(e,ue);const t=F({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return de(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const a={method:"POST",headers:O({accessToken:t,stagingToken:n,idempotencyKey:te()}),body:JSON.stringify({beneficiary:me(e)})},i=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${le}`,r=await fetch(i,a),s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:a,stagingToken:n}))}};function ge(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}}const fe="/v2/sepa/transfers";const he=[{name:"bankAccountId"},{name:"beneficiaryId"},{name:"reference"},{name:"amount"}];const _e={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:O({accessToken:e,stagingToken:t})},i=oe({endpointUrl:new URL(b.getEnvironmentUrls().THIRD_PARTY_API_URL+fe),paginationSettings:n}),r=await fetch(i,a);if(!r.ok)throw new P("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),a=n.transfers.map((e=>ge(e))),i=ce(n.meta);return{transfers:a,...i?{meta:i}:{}}},getSepaTransfer:async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a=t||r();!function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string")}(e);return ge(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a={method:"GET",headers:O({accessToken:e,stagingToken:t})},i=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${fe}/${n}`,r=await fetch(i,a),s=await r.json();if(s.errors)throw new P(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:a,stagingToken:n}))},createSepaTransfer:async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:a}){const i=t||r(),o=a||te();!function(e){if(!e)throw new s("transfer parameter is required for the called function");if("object"!=typeof e)throw new s("transfer must be an object");B(e,he);const t=[...F({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...G({amount:e.amount})].flat();if(t.length>0)throw new s(t)}(e);return ge(await async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:a}){const i=function(e){return{bank_account_id:e.bankAccountId,beneficiary_id:e.beneficiaryId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{}}}(e),r={method:"POST",headers:O({accessToken:t,stagingToken:n,idempotencyKey:a}),body:JSON.stringify({transfer:i})},s=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${fe}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new P(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:e,accessToken:i,stagingToken:n,idempotencyKey:o}))}};e.beneficiaries=pe,e.cards=se,e.constants=v,e.initialize=D,e.logout=S,e.sepaTransfers=_e}));
|
|
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 i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},m={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device"};var g=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:m,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:u,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"}});class f{constructor(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return f.instance||(f.instance=new f),f.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY}}const p=f.getInstance();function h(e){const t=e?.uiParentElementId||p.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||p.getMFAPreference();if(n&&!Object.values(u).includes(n))throw new s("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const i=e?.debugMode||p.getDebugMode();if(void 0!==i&&"boolean"!=typeof i)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:i}}const _=Object.values(l);function y(e){if(!function(e){return _.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${_.join(", ")}.`);return e}function T(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&h(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&y(e.locale),e}const I="https://embed.qonto.com",E="https://embed-js{branch}.staging.qonto.co",A="https://embed.dev.qonto.co",b={[d.PRODUCTION]:{IFRAME_BASE_URL:I,IFRAME_URL:`${I}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:E,IFRAME_URL:`${E}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:A,IFRAME_URL:`${A}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class w{constructor(){this.environment=d.PRODUCTION,this.branch=m.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(m).includes(t)?t:m.SANDBOX}static getInstance(){return w.instance||(w.instance=new w),w.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=m.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return b.production;{const e=b[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const L=w.getInstance();class R{constructor(){this.currentLocale="en"}static getInstance(){return R.instance||(R.instance=new R),R.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const S=R.getInstance();const k={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=T(e);n.setAccessToken(t),i&&n.setStagingToken(i),o&&S.setLocale(o),a&&p.setSettings(a),r&&(L.setEnvironment(r),s&&L.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),S.setDefaultLocale()},constants:g},{initialize:v,logout:D,constants:P}=k;class O extends i{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 N({accessToken:e,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",S.getLocale()),r}async function U(e,t,n){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=L.getEnvironmentUrls().THIRD_PARTY_API_URL,r=await fetch(`${a}/v2/cards/${e.cardId}/data_view`,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(s.iframe_url,e)}var C;!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"}(C||(C={}));const M={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 $,B;function F(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 s(n.map((e=>`Missing required parameter: ${e}`)))}function j(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function G(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function Y(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"}($||($={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(B||(B={}));const q=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],x=[...q,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function z(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return F(e,q),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,g=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),f=j({membershipId:t,organizationId:n,bankAccountId:i}),p=G({hasDailyLimit:a,hasTransactionLimit:r}),h=Y({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=H(m),y=K(l),T=[...g,...f,...p,...h,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){F(e,x),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:g,hasForeignPaymentOption:f,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:A,typeOfPrint:b}=e,w=function(e){return Object.values(B).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),L=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']:[]}(b),R=j({membershipId:t,organizationId:n,bankAccountId:i}),S=G({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:g,hasForeignPaymentOption:f,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:h}),k=Y({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),v=H(m),D=K(l),P=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(A),O=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"]}(E,h),N=[...w,...R,...S,...k,...v,...D,...L,...P,...O];if(N.length>0)throw new s(N)}(e)}(e)}function H(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 K(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 V extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class X{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 V(`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,i=setTimeout((()=>{window.removeEventListener("message",a),t(new V(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){return this.iframe&&this.iframe.contentWindow?new Promise(((t,n)=>{const i=a=>{if(a.data?.actionId===e.actionId){if("error"===a.data.status)return this.removeMessageListener(e.actionId,i),n(new V(`An error occurred when performing the action ${e.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(e.actionId,i),t(a.data.payload)}};this.addMessageListener(e.actionId,i),this.iframe?.contentWindow?.postMessage(e,this.targetOrigin)})):Promise.reject(new V("Attempted to perform an Embed operation without having the authentication UI initialized."))}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 Q({accessToken:e,stagingToken:t,locale:n,debugMode:i}){const a=i||!1,r=n||S.getLocale(),s=L.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function W({parentElementId:e,iframeUrl:t}){return new X({parentElementId:e,iframeUrl:t}).initialize()}const J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));let Z;const ee=new Uint8Array(16);var te={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ne(e,t,n){if(te.randomUUID&&!e)return te.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!Z){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Z=crypto.getRandomValues.bind(crypto)}return Z(ee)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(J[e[t+0]]+J[e[t+1]]+J[e[t+2]]+J[e[t+3]]+"-"+J[e[t+4]]+J[e[t+5]]+"-"+J[e[t+6]]+J[e[t+7]]+"-"+J[e[t+8]]+J[e[t+9]]+"-"+J[e[t+10]]+J[e[t+11]]+J[e[t+12]]+J[e[t+13]]+J[e[t+14]]+J[e[t+15]]).toLowerCase()}(i)}function ie(e){return"virtual"===e.cardLevel?function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ne(),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=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ne(),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 ae(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 re(e){const t=Object.values(M);return(e||[]).filter((e=>t.includes(e)))}const se={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=L.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new O(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>ae(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return ae(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=h(e.operationSettings);z(e.cardSettings);const s=Q({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await W({iframeUrl:s,parentElementId:i}),c=ie(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ae(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=h(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=j({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=Q({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),d=await W({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:c.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),l=await d.postMessage(m);return d.destroy(),ae(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const t=r(),{uiParentElementId:n}=h(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=j({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=G(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await U(e.cardSettings,t),a=await W({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},oe=se;function ce({endpointUrl:e,paginationSettings:t}){const n=new URL(e);return t?.page&&n.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&n.searchParams.set("per_page",t.itemsPerPage.toString()),n}function de(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 me(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 le(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 ue="/v2/sepa/beneficiaries";async function ge({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}const fe=[{name:"name"},{name:"iban"}];const pe={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=ce({endpointUrl:new URL(L.getEnvironmentUrls().THIRD_PARTY_API_URL+ue),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.beneficiaries.map((e=>me(e))),a=de(n.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const i=t||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),me(await ge({beneficiaryId:e,accessToken:i,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");F(e,fe);const t=j({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return me(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:ne()}),body:JSON.stringify({beneficiary:le(e)})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))}};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 _e(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}const ye="/v2/sepa/transfers";const Te=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Ie({sepaTransferSettings:e,operationSettings:t}){if(e.beneficiary)return e.beneficiary;return me(await ge({beneficiaryId:e.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}const Ee="browser",Ae="server";class be extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ee:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case Ae: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 we={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=ce({endpointUrl:new URL(L.getEnvironmentUrls().THIRD_PARTY_API_URL+ye),paginationSettings:n}),r=await fetch(a,i);if(!r.ok)throw new O("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.transfers.map((e=>he(e))),a=de(n.meta);return{transfers:i,...a?{meta:a}:{}}},getSepaTransfer:async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string")}(e);return he(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:i,stagingToken:n}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const i=t?.accessToken||r(),a=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||ne();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(F(e,Te),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...j({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...Y({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>3e4&&(!e.attachments||0===e.attachments.length))throw new s("Attachments are required for transfers over €30,000")}(e);const m={...e,beneficiary:await Ie({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(m.beneficiary.trusted)d=await async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:i}){const a=_e(e),r={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new O(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:m,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if("undefined"==typeof window||"undefined"==typeof document)throw new be(Ee);const{uiParentElementId:e,debugMode:n}=h(t);let r;try{const t=Q({accessToken:i,stagingToken:a||void 0,debugMode:n});r=await W({iframeUrl:t,parentElementId:e});const s=_e(m);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return he(d)}};e.beneficiaries=pe,e.cards=oe,e.constants=P,e.initialize=v,e.logout=D,e.sepaTransfers=we}));
|
package/dist/mocks/handlers.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare const newBeneficiaryDbFields: {
|
|
|
11
11
|
trusted: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare const mockedBeneficiariesList: BeneficiaryDataObject[];
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const mockTransferDataObject: SepaTransferDataObject;
|
|
15
15
|
export declare const mswHandlers: import("msw").HttpHandler[];
|
|
16
16
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAG9C,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAG9C,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAkBpC,CAAC;AAEF,eAAO,MAAM,WAAW,6BA0NvB,CAAC"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import type { PaginationSettings } from '@common/api-pagination/api-pagination.types';
|
|
2
2
|
import type { GetSepaTransfersResponse, NewSepaTransfer, SepaTransfer } from './sepa-transfers.types';
|
|
3
|
+
import { type OperationSettings } from '@validation/operation-settings-validation';
|
|
3
4
|
interface GetSepaTransfersParams {
|
|
4
5
|
accessToken?: string;
|
|
5
6
|
stagingToken?: string;
|
|
6
7
|
paginationSettings?: PaginationSettings;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* This is the common parameter format expected by the SEPA transfers functions.
|
|
11
|
+
* It consists of a `sepaTransferSettings` object and an optional
|
|
12
|
+
* `operationSettings` object. The `sepaTransferSettings` object's properties
|
|
13
|
+
* will be different depending on the function being called. Read the docs of
|
|
14
|
+
* each transfer related function to see the expected properties of the
|
|
15
|
+
* `sepaTransferSettings` object.
|
|
16
|
+
*/
|
|
17
|
+
export interface SepaTransferParams<T> {
|
|
18
|
+
/**
|
|
19
|
+
* An object with the parameters relevant to different card operations. Read the
|
|
20
|
+
* documentation of each function to see the expected properties of this object.
|
|
21
|
+
*/
|
|
22
|
+
sepaTransferSettings: T;
|
|
23
|
+
operationSettings?: OperationSettings;
|
|
24
|
+
}
|
|
8
25
|
/**
|
|
9
26
|
* Fetches the list of SEPA transfers for the current user.
|
|
10
27
|
* @param getSepaTransfersParams - An optional object with the accessToken
|
|
@@ -39,10 +56,20 @@ export declare function getSepaTransfer({ sepaTransferId, accessToken, stagingTo
|
|
|
39
56
|
}): Promise<SepaTransfer>;
|
|
40
57
|
/**
|
|
41
58
|
* Creates a new SEPA transfer from the current user to a given beneficiary.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
59
|
+
* Depending on the beneficiary's trust status, this function will either
|
|
60
|
+
* create the transfer directly via API or open the UI to complete the SCA
|
|
61
|
+
* process.
|
|
62
|
+
* @param createTransferParams - An object with the parameters to create the
|
|
63
|
+
* transfer. If it was not provided when calling the SDK's `initialize`
|
|
64
|
+
* function, an `operationSettings` object has to be passed too with the
|
|
65
|
+
* `accessToken` and `stagingToken` values. If the transfer needs to be created
|
|
66
|
+
* for an untrusted beneficiary, the `operationSettings` object must also include
|
|
67
|
+
* the `uiParentElementId` property. This has to specify the ID of the DOM element
|
|
68
|
+
* where the UI for MFA will be displayed. Note that this means that creating
|
|
69
|
+
* transfers for untrusted beneficiaries can only happen in the client side.
|
|
70
|
+
* The `createSepaTransfer` function requires an `idempotencyKey` as well. If this
|
|
71
|
+
* property is not passed as part of `operationSettings`, a new one will be
|
|
72
|
+
* generated automatically.
|
|
46
73
|
* @returns A promise that resolves to the created SEPA transfer.
|
|
47
74
|
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
48
75
|
* Ensure initialize has been called before using this function if you are not
|
|
@@ -51,12 +78,10 @@ export declare function getSepaTransfer({ sepaTransferId, accessToken, stagingTo
|
|
|
51
78
|
* or is missing, or if the required properties of the transfer object are
|
|
52
79
|
* missing or invalid.
|
|
53
80
|
* @throws \{EmbedApiError\} If the API request fails or returns an error.
|
|
81
|
+
* @throws \{InvalidRuntimeError\} If a transfer for an untrusted beneficiary is
|
|
82
|
+
* attempted to be created in the server. This scenario requires to be performed
|
|
83
|
+
* from a browser.
|
|
54
84
|
*/
|
|
55
|
-
export declare function createSepaTransfer({
|
|
56
|
-
transfer: NewSepaTransfer;
|
|
57
|
-
accessToken?: string;
|
|
58
|
-
stagingToken?: string;
|
|
59
|
-
idempotencyKey?: string;
|
|
60
|
-
}): Promise<SepaTransfer>;
|
|
85
|
+
export declare function createSepaTransfer({ sepaTransferSettings, operationSettings, }: SepaTransferParams<NewSepaTransfer>): Promise<SepaTransfer>;
|
|
61
86
|
export {};
|
|
62
87
|
//# sourceMappingURL=sepa-transfers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAQtF,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,YAAY,
|
|
1
|
+
{"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAQtF,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAUnD,UAAU,sBAAsB;IAC9B,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;;;OAGG;IACH,oBAAoB,EAAE,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,GAAE,sBAA2B,GAClD,OAAO,CAAC,wBAAwB,CAAC,CAqBnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAwE7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepa-transfers.serializer.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,sBAAsB,GAC3B,YAAY,CAoBd;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,eAAe,GACxB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"sepa-transfers.serializer.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,sBAAsB,GAC3B,YAAY,CAoBd;AAED,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,eAAe,GACxB,yBAAyB,CAc3B"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
2
|
-
import {
|
|
2
|
+
import { TRANSFER_DECLINE_REASONS, TRANSFER_STATUSES } from '@common/constants';
|
|
3
|
+
import type { Beneficiary } from '@beneficiaries/beneficiaries.types';
|
|
3
4
|
/**
|
|
4
5
|
* Represents the reasons why a SEPA transfer might be declined.
|
|
5
6
|
*/
|
|
6
|
-
type SepaTransferDeclinedReason = (typeof
|
|
7
|
+
type SepaTransferDeclinedReason = (typeof TRANSFER_DECLINE_REASONS)[keyof typeof TRANSFER_DECLINE_REASONS];
|
|
7
8
|
/**
|
|
8
9
|
* Represents the possible statuses of a SEPA transfer.
|
|
9
10
|
*/
|
|
10
|
-
type SepaTransferStatus = (typeof
|
|
11
|
+
type SepaTransferStatus = (typeof TRANSFER_STATUSES)[keyof typeof TRANSFER_STATUSES];
|
|
11
12
|
/**
|
|
12
13
|
* Represents a SEPA transfer in the system. This type includes all the fields
|
|
13
14
|
* necessary to describe a SEPA transfer and various timestamps related to the
|
|
@@ -126,8 +127,15 @@ export interface NewSepaTransfer {
|
|
|
126
127
|
bankAccountId: string;
|
|
127
128
|
/**
|
|
128
129
|
* The ID of the beneficiary to whom the transfer will be made.
|
|
130
|
+
* Required if `beneficiary` is not provided.
|
|
129
131
|
*/
|
|
130
|
-
beneficiaryId
|
|
132
|
+
beneficiaryId?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The beneficiary details, which include information about the beneficiary
|
|
135
|
+
* such as their name, account number, and bank details.
|
|
136
|
+
* Required if `beneficiaryId` is not provided.
|
|
137
|
+
*/
|
|
138
|
+
beneficiary?: Beneficiary;
|
|
131
139
|
/**
|
|
132
140
|
* The amount to be transferred, represented as a number.
|
|
133
141
|
*/
|
|
@@ -147,6 +155,11 @@ export interface NewSepaTransfer {
|
|
|
147
155
|
* If not provided, the transfer will be processed immediately.
|
|
148
156
|
*/
|
|
149
157
|
scheduledDate?: Date;
|
|
158
|
+
/**
|
|
159
|
+
* An optional array of attachment IDs related to the transfer.
|
|
160
|
+
* Attachments are required for transfers over €30,000.
|
|
161
|
+
*/
|
|
162
|
+
attachments?: string[];
|
|
150
163
|
}
|
|
151
164
|
export interface NewSepaTransferDataObject {
|
|
152
165
|
bank_account_id: string;
|
|
@@ -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,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,
|
|
1
|
+
{"version":3,"file":"sepa-transfers.types.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;GAEG;AACH,KAAK,0BAA0B,GAC7B,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,KAAK,kBAAkB,GACrB,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,WAAW,CAAC,EAAE,MAAM,EAAE,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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NewSepaTransfer } from '@sepa-transfers/sepa-transfers.types';
|
|
2
|
+
import type { SepaTransferParams } from '@sepa-transfers/sepa-transfers';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts a beneficiary object from the provided create new SEPA transfer
|
|
5
|
+
* settings object if it contains it, and otherwise it calls the beneficiaries
|
|
6
|
+
* API to retrieve it by ID.
|
|
7
|
+
* @param param - The settings object containing the SEPA transfer
|
|
8
|
+
* details, including the beneficiary or the beneficiary ID.
|
|
9
|
+
* @returns A promise that resolves to a serialized beneficiary object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findBeneficiary({ sepaTransferSettings, operationSettings, }: SepaTransferParams<NewSepaTransfer>): Promise<import("..").Beneficiary>;
|
|
12
|
+
//# sourceMappingURL=sepa-transfers.utils.d.ts.map
|
|
@@ -0,0 +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,gCAAgC,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,EACpC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,qCAWrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sepa-transfers.utils.test.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { NewSepaTransfer } from '@sepa-transfers/sepa-transfers.types';
|
|
2
2
|
export declare function validateGetSepaTransferParams(sepaTransferId: string): string;
|
|
3
|
-
export declare function validateCreateSepaTransferParams(
|
|
3
|
+
export declare function validateCreateSepaTransferParams(sepaTransferSettings: NewSepaTransfer): NewSepaTransfer;
|
|
4
4
|
//# sourceMappingURL=sepa-transfers.validate.d.ts.map
|
|
@@ -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,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"sepa-transfers.validate.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.validate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAU5E,wBAAgB,6BAA6B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAU5E;AAED,wBAAgB,gCAAgC,CAC9C,oBAAoB,EAAE,eAAe,mBAsDtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e={READY:"qonto.ready"},_={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"},E={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},n={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},N={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"},a={PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},A={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},i={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"},I={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"},r={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device"};export{_ as ACTIONS,N as ACTIVITY_TAGS,a as BENEFICIARY_STATUSES,n as BRANCHES,E as ENVIRONMENTS,e as IFRAME_EVENTS,A as LOCALES,r as MFA_METHODS,i as TRANSFER_DECLINE_REASONS,I as TRANSFER_STATUSES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{authManager as e}from"../auth/auth.js";import{
|
|
1
|
+
import{authManager as e}from"../auth/auth.js";import{operationSettingsManager as n}from"../operation-settings/operation-settings.js";import{localeManager as o}from"../locale/locale-manager.js";function t({accessToken:t,stagingToken:a,idempotencyKey:p,mfaPreference:r}){const c=new Headers;c.append("Authorization",`Bearer ${t}`);const i=a||e.getStagingToken();i&&c.append("X-Qonto-Staging-Token",i),p&&c.append("X-Qonto-Idempotency-Key",p);const s=r||n.getMFAPreference();return s&&c.append("X-Qonto-2fa-Preference",s),c.append("Content-Type","application/json"),c.append("Accept-Language",o.getLocale()),c}export{t as buildRequestHeaders};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
import{MFA_METHODS as e}from"../constants.js";class t{constructor(){this.uiParentElementId=null,this.mfaPreference=e.PASSKEY,this.debugMode=!1}static getInstance(){return t.instance||(t.instance=new t),t.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=e.PASSKEY}}const n=t.getInstance();export{t as OperationSettingsManager,n as operationSettingsManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){return"undefined"!=typeof window&&"undefined"!=typeof document}export{e as isRunningInBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={BROWSER:"browser",SERVER:"server"};class n extends Error{constructor(n){switch(super(),this.name="InvalidRuntimeError",n){case e.BROWSER:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case e.SERVER: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."}}}export{n as InvalidRuntimeError,e as RUNTIME_ENVIRONMENT};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EmbedIframe as e}from"./embed-iframe.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{localeManager as o}from"../common/locale/locale-manager.js";function t({accessToken:e,stagingToken:t,locale:m,debugMode:r}){const a=r||!1,i=m||o.getLocale(),c=n.getEnvironmentUrls().IFRAME_URL,l=t
|
|
1
|
+
import{EmbedIframe as e}from"./embed-iframe.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{localeManager as o}from"../common/locale/locale-manager.js";function t({accessToken:e,stagingToken:t,locale:m,debugMode:r}){const a=r||!1,i=m||o.getLocale(),c=n.getEnvironmentUrls().IFRAME_URL,l=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${c}?debug=${a}&lang=${encodeURIComponent(i)}#access_token=${encodeURIComponent(e)}${l}`}function m({parentElementId:n,iframeUrl:o}){return new e({parentElementId:n,iframeUrl:o}).initialize()}export{t as buildIframeUrl,m as createIframe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../common/auth/auth.js";import{validatePresenceOfAuthToken as
|
|
1
|
+
import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{serializePaginationResponse as a}from"../common/api-pagination/api-pagination.js";import{createSepaTransfer as n,getSepaTransfer as s,getSepaTransfers as o}from"./sepa-transfers.api.js";import{serializeToNewSepaTransferDataObject as r,serializeSepaTransfer as i}from"./sepa-transfers.serializer.js";import{validateCreateSepaTransferParams as m,validateGetSepaTransferParams as c}from"./sepa-transfers.validate.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{buildIframeUrl as f,createIframe as g}from"../iframe/iframe-manager.js";import{ACTIONS as d}from"../common/constants.js";import{findBeneficiary as T}from"./sepa-transfers.utils.js";import{isRunningInBrowser as u}from"../common/runtime/runtime.validation.js";import{InvalidRuntimeError as l,RUNTIME_ENVIRONMENT as k}from"../errors/InvalidRuntimeError.js";import y from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";async function j(e={}){const n=e?.accessToken||t(),s=await o({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),r=s.transfers.map((e=>i(e))),m=a(s.meta);return{transfers:r,...m?{meta:m}:{}}}async function S({sepaTransferId:e,accessToken:a,stagingToken:n}){const o=a||t();c(e);const r=await s({sepaTransferId:e,accessToken:o,stagingToken:n});return i(r)}async function v({sepaTransferSettings:a,operationSettings:s}){const o=s?.accessToken||t(),c=s?.stagingToken||e.getStagingToken(),j=s?.idempotencyKey||y();let S;m(a);const v={...a,beneficiary:await T({sepaTransferSettings:a,operationSettings:{accessToken:o,stagingToken:c||void 0}})};if(v.beneficiary.trusted)S=await n({transfer:v,accessToken:o,stagingToken:c||void 0,idempotencyKey:j});else{if(!u())throw new l(k.BROWSER);const{uiParentElementId:e,debugMode:t}=p(s);let a;try{const n=f({accessToken:o,stagingToken:c||void 0,debugMode:t});a=await g({iframeUrl:n,parentElementId:e});const s=r(v);S=await a.postMessage({actionId:d.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:j}})}finally{a?.destroy()}}return i(S)}export{v as createSepaTransfer,S as getSepaTransfer,j as getSepaTransfers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function t(e){return{bank_account_id:e.bankAccountId,beneficiary_id:
|
|
1
|
+
function e(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function t(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}export{e as serializeSepaTransfer,t as serializeToNewSepaTransferDataObject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getBeneficiary as e}from"../beneficiaries/beneficiaries.api.js";import{serializeBeneficiary as i}from"../beneficiaries/beneficiaries.serializer.js";async function n({sepaTransferSettings:n,operationSettings:r}){if(n.beneficiary)return n.beneficiary;{const a=await e({beneficiaryId:n.beneficiaryId,accessToken:r?.accessToken,stagingToken:r?.stagingToken});return i(a)}}export{n as findBeneficiary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as r,validateExpectedStringValues as n,validateExpectedNumericValues as t}from"../validation/input-param-validation.js";const a=[{name:"bankAccountId"},{name:"
|
|
1
|
+
import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as r,validateExpectedStringValues as n,validateExpectedNumericValues as t}from"../validation/input-param-validation.js";const a=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function i(r){if(!r)throw new e("sepaTransferId parameter is required for the called function");if(r&&"string"!=typeof r)throw new e("sepaTransferId must be a string");return r}function o(i){if(!i)throw new e("sepaTransferSettings parameter is required for the called function");if("object"!=typeof i)throw new e("sepaTransferSettings must be an object");if(r(i,a),!i.beneficiaryId&&!i.beneficiary)throw new e("Either beneficiaryId or beneficiary must be provided");const o=[...n({beneficiaryId:i.beneficiaryId,bankAccountId:i.bankAccountId,note:i.note,reference:i.reference}),...t({amount:i.amount})].flat();if(o.length>0)throw new e(o);if(i.amount>3e4&&(!i.attachments||0===i.attachments.length))throw new e("Attachments are required for transfers over €30,000");return i}export{o as validateCreateSepaTransferParams,i as validateGetSepaTransferParams};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{operationSettingsManager as t}from"../common/operation-settings/operation-settings.js";function
|
|
1
|
+
import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{operationSettingsManager as t}from"../common/operation-settings/operation-settings.js";import{MFA_METHODS as o}from"../common/constants.js";function n(n){const r=n?.uiParentElementId||t.getUIParentElementId();if(!r)throw new e("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=n?.mfaPreference||t.getMFAPreference();if(i&&!Object.values(o).includes(i))throw new e("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const a=n?.debugMode||t.getDebugMode();if(void 0!==a&&"boolean"!=typeof a)throw new e("operationSettings.debugMode must be a boolean.");return{uiParentElementId:r,mfaPreference:i,debugMode:a}}export{n as validateOperationSettingsParams};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, GetSepaTransfersResponse, GetBeneficiariesResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS } from './types.public-api';
|
|
2
|
-
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, GetSepaTransfersResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS, };
|
|
1
|
+
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, NewSepaTransfer, GetSepaTransfersResponse, GetBeneficiariesResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS } from './types.public-api';
|
|
2
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, NewSepaTransfer, GetSepaTransfersResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS, };
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,cAAc,EACf,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,YAAY,EACZ,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,cAAc,GACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,cAAc,EACf,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,cAAc,GACf,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings } from '@cards/cards.types';
|
|
2
2
|
import type { Beneficiary, GetBeneficiariesResponse } from '@beneficiaries/beneficiaries.types';
|
|
3
|
-
import type { SepaTransfer, GetSepaTransfersResponse } from '@sepa-transfers/sepa-transfers.types';
|
|
3
|
+
import type { SepaTransfer, NewSepaTransfer, GetSepaTransfersResponse } from '@sepa-transfers/sepa-transfers.types';
|
|
4
4
|
import type { PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
5
5
|
import type { Locale } from '@common/locale/locale.types';
|
|
6
6
|
import type { BankAccount, ACCOUNT_STATUS } from '@organizations/organizations.types';
|
|
7
|
-
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, GetSepaTransfersResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS, };
|
|
7
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, NewSepaTransfer, GetSepaTransfersResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS, };
|
|
8
8
|
//# sourceMappingURL=types.public-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.public-api.d.ts","sourceRoot":"","sources":["../../src/types/types.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACf,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,YAAY,EACZ,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,cAAc,GACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.public-api.d.ts","sourceRoot":"","sources":["../../src/types/types.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACf,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,WAAW,EACX,cAAc,GACf,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MfaMethod } from '@common/operation-settings/operation-settings.types';
|
|
1
2
|
/**
|
|
2
3
|
* Optional settings to configure the SDK's operations that will be performed
|
|
3
4
|
* after the initialization. This can be also provided when calling the
|
|
@@ -14,7 +15,7 @@ export interface OperationSettings {
|
|
|
14
15
|
* This can be either `MFA_METHODS.PASSKEY`, `MFA_METHODS.PAIRED_DEVICE` or
|
|
15
16
|
* `MFA_METHODS.SMS_OTP`. If not provided, the SDK will default to 'PASSKEY'.
|
|
16
17
|
*/
|
|
17
|
-
mfaPreference?:
|
|
18
|
+
mfaPreference?: MfaMethod;
|
|
18
19
|
/**
|
|
19
20
|
* Whether to enable debug mode for the SDK. If not provided, the SDK will
|
|
20
21
|
* default to false.
|
|
@@ -22,6 +23,23 @@ export interface OperationSettings {
|
|
|
22
23
|
* during the execution of the SDK functions in which an iframe is involved.
|
|
23
24
|
*/
|
|
24
25
|
debugMode?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Optional access token to use for the operation. If not provided, the
|
|
28
|
+
* SDK will use the access token set during initialization.
|
|
29
|
+
*/
|
|
30
|
+
accessToken?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional staging token to use for the operation. The staging token is only
|
|
33
|
+
* needed when working in the staging environment, and it is irrelevant and not
|
|
34
|
+
* needed in production. If not provided, the SDK will use the staging token
|
|
35
|
+
* set during initialization.
|
|
36
|
+
*/
|
|
37
|
+
stagingToken?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional idempotency key to use for the operation. If not provided, the
|
|
40
|
+
* SDK will generate a random key for the functions that require it.
|
|
41
|
+
*/
|
|
42
|
+
idempotencyKey?: string;
|
|
25
43
|
}
|
|
26
44
|
export declare function validateOperationSettingsParams(params: OperationSettings | undefined): OperationSettings;
|
|
27
45
|
//# sourceMappingURL=operation-settings-validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-settings-validation.d.ts","sourceRoot":"","sources":["../../src/validation/operation-settings-validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-settings-validation.d.ts","sourceRoot":"","sources":["../../src/validation/operation-settings-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAGrF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,iBAAiB,CA8BnB"}
|