@qonto/embed-sdk 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/common/constants.d.ts +8 -0
  2. package/dist/common/constants.d.ts.map +1 -1
  3. package/dist/common/initialize/initialize.d.ts +2 -0
  4. package/dist/common/initialize/initialize.d.ts.map +1 -1
  5. package/dist/common/initialize/initialize.types.d.ts +7 -1
  6. package/dist/common/initialize/initialize.types.d.ts.map +1 -1
  7. package/dist/common/initialize/initialize.validate.d.ts.map +1 -1
  8. package/dist/common/locale/index.d.ts +1 -1
  9. package/dist/common/locale/index.d.ts.map +1 -1
  10. package/dist/common/locale/locale-manager.d.ts +13 -0
  11. package/dist/common/locale/locale-manager.d.ts.map +1 -0
  12. package/dist/common/locale/locale-manager.test.d.ts +2 -0
  13. package/dist/common/locale/locale-manager.test.d.ts.map +1 -0
  14. package/dist/common/locale/locale.types.d.ts +8 -0
  15. package/dist/common/locale/locale.types.d.ts.map +1 -0
  16. package/dist/common/locale/locale.validate.d.ts +3 -0
  17. package/dist/common/locale/locale.validate.d.ts.map +1 -0
  18. package/dist/common/network/network.d.ts.map +1 -1
  19. package/dist/iframe/iframe-manager.d.ts +3 -2
  20. package/dist/iframe/iframe-manager.d.ts.map +1 -1
  21. package/dist/index.umd.js +1 -1
  22. package/dist/mocks/handlers.d.ts.map +1 -1
  23. package/dist/sepa-transfers/index.d.ts +1 -0
  24. package/dist/sepa-transfers/index.d.ts.map +1 -1
  25. package/dist/sepa-transfers/sepa-transfers.api.d.ts +8 -1
  26. package/dist/sepa-transfers/sepa-transfers.api.d.ts.map +1 -1
  27. package/dist/sepa-transfers/sepa-transfers.d.ts +22 -1
  28. package/dist/sepa-transfers/sepa-transfers.d.ts.map +1 -1
  29. package/dist/sepa-transfers/sepa-transfers.public-api.d.ts +2 -1
  30. package/dist/sepa-transfers/sepa-transfers.public-api.d.ts.map +1 -1
  31. package/dist/sepa-transfers/sepa-transfers.serializer.d.ts +2 -1
  32. package/dist/sepa-transfers/sepa-transfers.serializer.d.ts.map +1 -1
  33. package/dist/sepa-transfers/sepa-transfers.types.d.ts +90 -0
  34. package/dist/sepa-transfers/sepa-transfers.types.d.ts.map +1 -1
  35. package/dist/sepa-transfers/sepa-transfers.validate.d.ts +2 -0
  36. package/dist/sepa-transfers/sepa-transfers.validate.d.ts.map +1 -1
  37. package/dist/src/common/constants.js +1 -1
  38. package/dist/src/common/initialize/initialize.js +1 -1
  39. package/dist/src/common/initialize/initialize.validate.js +1 -1
  40. package/dist/src/common/locale/locale-manager.js +1 -0
  41. package/dist/src/common/locale/locale.validate.js +1 -0
  42. package/dist/src/common/network/network.js +1 -1
  43. package/dist/src/iframe/iframe-manager.js +1 -1
  44. package/dist/src/sepa-transfers/sepa-transfers.api.js +1 -1
  45. package/dist/src/sepa-transfers/sepa-transfers.js +1 -1
  46. package/dist/src/sepa-transfers/sepa-transfers.public-api.js +1 -1
  47. package/dist/src/sepa-transfers/sepa-transfers.serializer.js +1 -1
  48. package/dist/src/sepa-transfers/sepa-transfers.validate.js +1 -1
  49. package/dist/types/index.d.ts +2 -2
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/dist/types/types.public-api.d.ts +2 -1
  52. package/dist/types/types.public-api.d.ts.map +1 -1
  53. package/package.json +1 -1
@@ -73,6 +73,14 @@ export declare const BENEFICIARY_STATUSES: {
73
73
  VALIDATED: string;
74
74
  DECLINED: string;
75
75
  };
76
+ export declare const LOCALES: {
77
+ EN: string;
78
+ FR: string;
79
+ DE: string;
80
+ ES: string;
81
+ IT: string;
82
+ PT: string;
83
+ };
76
84
  export declare const SEPA_TRANSFER_DECLINE_REASONS: {
77
85
  BENEFICIARY_BIC_INVALID: string;
78
86
  BENEFICIARY_IBAN_INVALID: string;
@@ -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,6BAA6B;;;;;;;;CAQzC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;CAMlC,CAAC"}
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,6BAA6B;;;;;;;;CAQzC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;CAMlC,CAAC"}
@@ -21,6 +21,8 @@ import type { InitializeParams } from './initialize.types';
21
21
  * - `mfaPreference`: The MFA preference to use for the operations. This can be either
22
22
  * `MFA_METHODS.PASSKEY`, `MFA_METHODS.PAIRED_DEVICE` or `MFA_METHODS.SMS_OTP`. If not
23
23
  * provided, the SDK will default to `MFA_METHODS.PASSKEY`.
24
+ * - `locale`: Optional 2 digit language code to set the language in which the UI elements
25
+ * injected by the SDK will show the text.
24
26
 
25
27
  * @throws InvalidParametersError If the access token is not provided or the specified
26
28
  * parameters don't comply with the expected format.
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QAiB5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAGrB"}
1
+ {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QAyB5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAIrB"}
@@ -1,4 +1,5 @@
1
1
  import type { OperationSettings } from '@validation/operation-settings-validation';
2
+ import type { Locale } from '@common/locale/locale.types';
2
3
  /**
3
4
  * An object with the parameters to initialize the SDK. The only required parameter
4
5
  * is the `accessToken`.
@@ -14,7 +15,12 @@ export interface InitializeParams {
14
15
  * This is helpful for testing purposes, and it is irrelevant in production.
15
16
  */
16
17
  stagingToken?: string;
17
- locale?: 'en' | 'fr' | 'es' | 'de' | 'it' | 'pt';
18
+ /**
19
+ * The locale to use for the SDK. This is optional, and if not provided, it will
20
+ * default to English. Setting the locale will make the SDK render its UI in the
21
+ * specified language.
22
+ */
23
+ locale?: Locale;
18
24
  /**
19
25
  * Optional parameter to set the SDK's environment. If not provided,
20
26
  * the SDK will default to `'production'`. Use `ENVIRONMENTS.STAGING` to set
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.types.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjD;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
1
+ {"version":3,"file":"initialize.types.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.validate.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,gBAAgB,GACvB,gBAAgB,CAYlB"}
1
+ {"version":3,"file":"initialize.validate.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,gBAAgB,GACvB,gBAAgB,CAclB"}
@@ -1,2 +1,2 @@
1
- export declare function setLocale(): void;
1
+ export { localeManager } from './locale-manager';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/locale/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,SAExB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/locale/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Locale } from '@common/locale/locale.types';
2
+ declare class LocaleManager {
3
+ private static instance;
4
+ private currentLocale;
5
+ private constructor();
6
+ static getInstance(): LocaleManager;
7
+ setLocale(locale: Locale): void;
8
+ getLocale(): Locale;
9
+ setDefaultLocale(): void;
10
+ }
11
+ export declare const localeManager: LocaleManager;
12
+ export {};
13
+ //# sourceMappingURL=locale-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-manager.d.ts","sourceRoot":"","sources":["../../../src/common/locale/locale-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,cAAM,aAAa;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgB;IACvC,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,aAAa;IAOnC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,SAAS,IAAI,MAAM;IAInB,gBAAgB,IAAI,IAAI;CAGzB;AAED,eAAO,MAAM,aAAa,eAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=locale-manager.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-manager.test.d.ts","sourceRoot":"","sources":["../../../src/common/locale/locale-manager.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { LOCALES } from '@common/constants';
2
+ /**
3
+ * Represents the supported locales in the SDK.
4
+ * Each locale corresponds to a key in the LOCALES constant, which is available
5
+ * in the \@common/constants module.
6
+ */
7
+ export type Locale = (typeof LOCALES)[keyof typeof LOCALES];
8
+ //# sourceMappingURL=locale.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.types.d.ts","sourceRoot":"","sources":["../../../src/common/locale/locale.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Locale } from '@common/locale/locale.types';
2
+ export declare function validateLocale(locale: Locale): Locale;
3
+ //# sourceMappingURL=locale.validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.validate.d.ts","sourceRoot":"","sources":["../../../src/common/locale/locale.validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAM1D,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/common/network/network.ts"],"names":[],"mappings":"AAEA,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE,yBAAyB,GAAG,OAAO,CAcrC"}
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/common/network/network.ts"],"names":[],"mappings":"AAGA,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE,yBAAyB,GAAG,OAAO,CAarC"}
@@ -1,15 +1,16 @@
1
1
  import { EmbedIframe } from './embed-iframe';
2
+ import type { Locale } from '@common/locale/locale.types';
2
3
  interface BuildIframeUrlParams {
3
4
  accessToken: string;
4
5
  stagingToken?: string;
5
- language?: string;
6
+ locale?: Locale;
6
7
  debugMode?: boolean;
7
8
  }
8
9
  interface CreateIframeParams {
9
10
  parentElementId: string;
10
11
  iframeUrl: string;
11
12
  }
12
- export declare function buildIframeUrl({ accessToken, stagingToken, language, debugMode, }: BuildIframeUrlParams): string;
13
+ export declare function buildIframeUrl({ accessToken, stagingToken, locale, debugMode, }: BuildIframeUrlParams): string;
13
14
  export declare function createIframe({ parentElementId, iframeUrl, }: CreateIframeParams): Promise<EmbedIframe>;
14
15
  export {};
15
16
  //# sourceMappingURL=iframe-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iframe-manager.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,kBAAkB;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,EAAE,oBAAoB,UAQtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,eAAe,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3C"}
1
+ {"version":3,"file":"iframe-manager.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAG1D,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,kBAAkB;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,YAAY,EACZ,MAAM,EACN,SAAS,GACV,EAAE,oBAAoB,UAQtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,eAAe,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3C"}
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 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")}`}}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 i=e?.debugMode||c.getDebugMode();if(void 0!==i&&"boolean"!=typeof i)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:i}}function m(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}const l={READY:"qonto.ready"},u={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"},p={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},g={MASTER:"master",SANDBOX:"sandbox",QA:"qa"};var h=Object.freeze({__proto__:null,ACTIONS:u,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:g,ENVIRONMENTS:p,IFRAME_EVENTS:l,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 f="https://embed.qonto.com",_="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",T={[p.PRODUCTION]:{IFRAME_BASE_URL:f,IFRAME_URL:`${f}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[p.STAGING]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[p.LOCAL]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=p.PRODUCTION,this.branch=g.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(p).includes(e)?e:p.PRODUCTION,this.branch=Object.values(g).includes(t)?t:g.SANDBOX}static getInstance(){return I.instance||(I.instance=new I),I.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=p.PRODUCTION,this.branch=g.MASTER}getEnvironmentUrls(){if(this.environment===p.PRODUCTION)return T.production;{const e=T[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=I.getInstance();const A={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s}=m(e);n.setAccessToken(t),i&&n.setStagingToken(i),a&&c.setSettings(a),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken()},constants:h},{initialize:w,logout:b,constants:R}=A;class L 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 D({accessToken:e,stagingToken:t,idempotencyKey:i}){const a=new Headers;a.append("Authorization",`Bearer ${e}`);const r=t||n.getStagingToken();return r&&a.append("X-Qonto-Staging-Token",r),i&&a.append("X-Qonto-Idempotency-Key",i),a.append("Content-Type","application/json"),a.append("Accept-Language","en"),a}async function k(e,t,n){const i={method:"GET",headers:D({accessToken:t,stagingToken:n})},a=E.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 L(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 v;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(v||(v={}));const S={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 P,N;function O(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 U(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function C(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function M(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"}(P||(P={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(N||(N={}));const $=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],B=[...$,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function F(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return O(e,$),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,p=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),g=U({membershipId:t,organizationId:n,bankAccountId:i}),h=C({hasDailyLimit:a,hasTransactionLimit:r}),f=M({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=G(m),y=j(l),T=[...p,...g,...h,...f,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){O(e,B),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:p,hasForeignPaymentOption:g,hasOnlinePaymentOption:h,shipToBusiness:f,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:A,typeOfPrint:w}=e,b=function(e){return Object.values(N).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),R=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),L=U({membershipId:t,organizationId:n,bankAccountId:i}),D=C({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:p,hasForeignPaymentOption:g,hasOnlinePaymentOption:h,hasAtmDailyLimit:y,shipToBusiness:f}),k=M({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),v=G(m),S=j(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,f),$=[...b,...L,...D,...k,...v,...S,...R,...P,...O];if($.length>0)throw new s($)}(e)}(e)}function G(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 j(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 Y extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class q{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 Y(`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 Y(`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===l.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 Y(`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 Y("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,language:n,debugMode:i}){const a=i||!1,r=n||"en",s=E.getEnvironmentUrls().IFRAME_URL,o=t?`&staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function z({parentElementId:e,iframeUrl:t}){return new q({parentElementId:e,iframeUrl:t}).initialize()}const H=[];for(let e=0;e<256;++e)H.push((e+256).toString(16).slice(1));let V;const K=new Uint8Array(16);var X={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Q(e,t,n){if(X.randomUUID&&!e)return X.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!V){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");V=crypto.getRandomValues.bind(crypto)}return V(K)}();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(H[e[t+0]]+H[e[t+1]]+H[e[t+2]]+H[e[t+3]]+"-"+H[e[t+4]]+H[e[t+5]]+"-"+H[e[t+6]]+H[e[t+7]]+"-"+H[e[t+8]]+H[e[t+9]]+"-"+H[e[t+10]]+H[e[t+11]]+H[e[t+12]]+H[e[t+13]]+H[e[t+14]]+H[e[t+15]]).toLowerCase()}(i)}function W(e){return"virtual"===e.cardLevel?function(e){const t=Z(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:Q(),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=Z(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:Q(),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 J(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 Z(e){const t=Object.values(S);return(e||[]).filter((e=>t.includes(e)))}const ee={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:D({accessToken:t,stagingToken:n})},a=E.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 L(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>J(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:D({accessToken:t,stagingToken:n})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new L(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return J(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=d(e.operationSettings);F(e.cardSettings);const s=x({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await z({iframeUrl:s,parentElementId:i}),c=W(e.cardSettings),m=await o.postMessage(c);return o.destroy(),J(m)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=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=U({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=x({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),c=await z({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:u.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),l=await c.postMessage(m);return c.destroy(),J(l)}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=U({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=C(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await k(e.cardSettings,t),a=await z({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},te=ee;function ne({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 ie(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 ae(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 re(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 se="/v2/sepa/beneficiaries";const oe=[{name:"name"},{name:"iban"}];const ce={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:D({accessToken:t,stagingToken:n})},a=ne({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+se),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new L(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=>ae(e))),a=ie(n.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const i=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 ae(await async function({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:D({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${se}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new L(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({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");O(e,oe);const t=U({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 ae(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:D({accessToken:t,stagingToken:n,idempotencyKey:Q()}),body:JSON.stringify({beneficiary:re(e)})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${se}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new L(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))}},de="/v2/sepa/transfers";function me(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 le={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const i={method:"GET",headers:D({accessToken:e,stagingToken:t})},a=ne({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+de),paginationSettings:n}),r=await fetch(a,i);if(!r.ok)throw new L("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new L(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=>me(e))),a=ie(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 me(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const i={method:"GET",headers:D({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${de}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new L(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:i,stagingToken:n}))}};e.beneficiaries=ce,e.cards=te,e.constants=R,e.initialize=w,e.logout=b,e.sepaTransfers=le}));
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 +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,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAGnF,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,YAAY,EAAE,sBAkB1B,CAAC;AAEF,eAAO,MAAM,WAAW,6BAkMvB,CAAC"}
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,YAAY,EAAE,sBAkB1B,CAAC;AAEF,eAAO,MAAM,WAAW,6BA0NvB,CAAC"}
@@ -14,5 +14,6 @@
14
14
  export declare const sepaTransfers: {
15
15
  getSepaTransfers: typeof import("./sepa-transfers").getSepaTransfers;
16
16
  getSepaTransfer: typeof import("./sepa-transfers").getSepaTransfer;
17
+ createSepaTransfer: typeof import("./sepa-transfers").createSepaTransfer;
17
18
  };
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa;;;CAAuC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa;;;;CAAuC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { PaginationResponseDataObject, PaginationSettings } from '@common/api-pagination/api-pagination.types';
2
- import type { SepaTransferDataObject } from './sepa-transfers.types';
2
+ import type { NewSepaTransfer, SepaTransferDataObject } from './sepa-transfers.types';
3
3
  interface GetSepaTransfersParams {
4
4
  accessToken: string;
5
5
  stagingToken?: string;
@@ -14,8 +14,15 @@ interface GetSepaTransfersApiResponse {
14
14
  transfers: SepaTransferDataObject[];
15
15
  meta: PaginationResponseDataObject;
16
16
  }
17
+ export interface CreateSepaTransferParams {
18
+ transfer: NewSepaTransfer;
19
+ accessToken: string;
20
+ stagingToken?: string;
21
+ idempotencyKey: string;
22
+ }
17
23
  export declare const SEPA_TRANSFERS_ENDPOINT = "/v2/sepa/transfers";
18
24
  export declare function getSepaTransfers({ accessToken, stagingToken, paginationSettings, }: GetSepaTransfersParams): Promise<GetSepaTransfersApiResponse>;
19
25
  export declare function getSepaTransfer({ accessToken, stagingToken, sepaTransferId, }: GetSepaTransferParams): Promise<SepaTransferDataObject>;
26
+ export declare function createSepaTransfer({ transfer, accessToken, stagingToken, idempotencyKey, }: CreateSepaTransferParams): Promise<SepaTransferDataObject>;
20
27
  export {};
21
28
  //# sourceMappingURL=sepa-transfers.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.api.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAMrE,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,2BAA2B;IACnC,SAAS,EAAE,sBAAsB,EAAE,CAAC;IACpC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAED,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,wBAAsB,gBAAgB,CAAC,EACrC,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,EAAE,sBAAsB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAkC/D;AAED,wBAAsB,eAAe,CAAC,EACpC,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAqBzD"}
1
+ {"version":3,"file":"sepa-transfers.api.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAEV,eAAe,EACf,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAOhC,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,2BAA2B;IACnC,SAAS,EAAE,sBAAsB,EAAE,CAAC;IACpC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,wBAAsB,gBAAgB,CAAC,EACrC,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,EAAE,sBAAsB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAkC/D;AAED,wBAAsB,eAAe,CAAC,EACpC,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAqBzD;AAED,wBAAsB,kBAAkB,CAAC,EACvC,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE,wBAAwB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAyB5D"}
@@ -1,5 +1,5 @@
1
1
  import type { PaginationSettings } from '@common/api-pagination/api-pagination.types';
2
- import type { GetSepaTransfersResponse, SepaTransfer } from './sepa-transfers.types';
2
+ import type { GetSepaTransfersResponse, NewSepaTransfer, SepaTransfer } from './sepa-transfers.types';
3
3
  interface GetSepaTransfersParams {
4
4
  accessToken?: string;
5
5
  stagingToken?: string;
@@ -37,5 +37,26 @@ export declare function getSepaTransfer({ sepaTransferId, accessToken, stagingTo
37
37
  accessToken?: string;
38
38
  stagingToken?: string;
39
39
  }): Promise<SepaTransfer>;
40
+ /**
41
+ * Creates a new SEPA transfer from the current user to a given beneficiary.
42
+ * @param createTransferParams - An object with the transfer and optional
43
+ * accessToken, stagingToken, and idempotencyKey properties. The transfer
44
+ * property is required and should be an object containing the details of the
45
+ * transfer to be created.
46
+ * @returns A promise that resolves to the created SEPA transfer.
47
+ * @throws \{AuthenticationError\} If the access token is invalid or missing.
48
+ * Ensure initialize has been called before using this function if you are not
49
+ * passing the access token.
50
+ * @throws \{InvalidParametersError\} If the `transfer` parameter is not an object
51
+ * or is missing, or if the required properties of the transfer object are
52
+ * missing or invalid.
53
+ * @throws \{EmbedApiError\} If the API request fails or returns an error.
54
+ */
55
+ export declare function createSepaTransfer({ transfer, accessToken, stagingToken, idempotencyKey, }: {
56
+ transfer: NewSepaTransfer;
57
+ accessToken?: string;
58
+ stagingToken?: string;
59
+ idempotencyKey?: string;
60
+ }): Promise<SepaTransfer>;
40
61
  export {};
41
62
  //# 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":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAOtF,OAAO,KAAK,EACV,wBAAwB,EACxB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAIhC,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;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"}
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,EACb,MAAM,wBAAwB,CAAC;AAOhC,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;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;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,YAAY,CAAC,CAWxB"}
@@ -1,7 +1,8 @@
1
- import { getSepaTransfers, getSepaTransfer } from './sepa-transfers';
1
+ import { getSepaTransfers, getSepaTransfer, createSepaTransfer } from './sepa-transfers';
2
2
  declare const sepaTransfers: {
3
3
  getSepaTransfers: typeof getSepaTransfers;
4
4
  getSepaTransfer: typeof getSepaTransfer;
5
+ createSepaTransfer: typeof createSepaTransfer;
5
6
  };
6
7
  export { sepaTransfers };
7
8
  //# sourceMappingURL=sepa-transfers.public-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.public-api.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAErE,QAAA,MAAM,aAAa;;;CAGlB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"sepa-transfers.public-api.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,QAAA,MAAM,aAAa;;;;CAIlB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
- import type { SepaTransfer, SepaTransferDataObject } from './sepa-transfers.types';
1
+ import type { SepaTransfer, SepaTransferDataObject, NewSepaTransfer, NewSepaTransferDataObject } from './sepa-transfers.types';
2
2
  export declare function serializeSepaTransfer(data: SepaTransferDataObject): SepaTransfer;
3
+ export declare function serializeToNewSepaTransferDataObject(transfer: NewSepaTransfer): NewSepaTransferDataObject;
3
4
  //# sourceMappingURL=sepa-transfers.serializer.d.ts.map
@@ -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,EACvB,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,sBAAsB,GAC3B,YAAY,CAoBd"}
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,CAW3B"}
@@ -16,20 +16,68 @@ type SepaTransferStatus = (typeof SEPA_TRANSFER_STATUSES)[keyof typeof SEPA_TRAN
16
16
  export interface SepaTransfer {
17
17
  id: string;
18
18
  initiatorId: string;
19
+ /**
20
+ * The ID of the bank account from which the transfer is made.
21
+ */
19
22
  bankAccountId: string;
23
+ /**
24
+ * The amount of money being transferred, represented as a number.
25
+ */
20
26
  amount: number;
27
+ /**
28
+ * The amount of money being transferred, represented in cents as a number.
29
+ */
21
30
  amountCents: number;
31
+ /**
32
+ * The currency of the amount being transferred, represented as a string.
33
+ * @example 'EUR'
34
+ */
22
35
  amountCurrency: string;
36
+ /**
37
+ * The current status of the SEPA transfer, represented as a string.
38
+ */
23
39
  status: SepaTransferStatus;
40
+ /**
41
+ * The ID of the beneficiary to whom the transfer is made.
42
+ */
24
43
  beneficiaryId: string;
44
+ /**
45
+ * A reference string for the transfer, which can be used for tracking or
46
+ * identification purposes.
47
+ */
25
48
  reference: string;
49
+ /**
50
+ * An optional note that can be included with the transfer for additional
51
+ * information or context.
52
+ */
26
53
  note: string;
54
+ /**
55
+ * The reason for the transfer being declined, if applicable.
56
+ */
27
57
  declinedReason: SepaTransferDeclinedReason;
58
+ /**
59
+ * The date when the transfer is scheduled to be processed.
60
+ */
28
61
  scheduledDate: Date;
62
+ /**
63
+ * The date and time when the transfer was created.
64
+ */
29
65
  createdAt: Date;
66
+ /**
67
+ * The date and time when the transfer was last updated.
68
+ */
30
69
  updatedAt: Date;
70
+ /**
71
+ * The date and time when the transfer was processed.
72
+ */
31
73
  processedAt: Date;
74
+ /**
75
+ * The date and time when the transfer was completed.
76
+ */
32
77
  completedAt: Date;
78
+ /**
79
+ * The ID of the transaction associated with this SEPA transfer.
80
+ */
33
81
  transactionId: string;
34
82
  }
35
83
  export interface SepaTransferDataObject {
@@ -66,5 +114,47 @@ export interface GetSepaTransfersResponse {
66
114
  */
67
115
  meta?: PaginationState;
68
116
  }
117
+ /**
118
+ * Represents the parameters required to create a new SEPA transfer.
119
+ * This interface is used to define the structure of the data needed to
120
+ * initiate a SEPA transfer
121
+ */
122
+ export interface NewSepaTransfer {
123
+ /**
124
+ * The ID of the bank account from which the transfer will be made.
125
+ */
126
+ bankAccountId: string;
127
+ /**
128
+ * The ID of the beneficiary to whom the transfer will be made.
129
+ */
130
+ beneficiaryId: string;
131
+ /**
132
+ * The amount to be transferred, represented as a number.
133
+ */
134
+ amount: number;
135
+ /**
136
+ * A reference string for the transfer, which can be used for tracking or
137
+ * identification purposes.
138
+ */
139
+ reference: string;
140
+ /**
141
+ * An optional note that can be included with the transfer for additional
142
+ * information or context.
143
+ */
144
+ note?: string;
145
+ /**
146
+ * An optional date when the transfer is scheduled to be processed.
147
+ * If not provided, the transfer will be processed immediately.
148
+ */
149
+ scheduledDate?: Date;
150
+ }
151
+ export interface NewSepaTransferDataObject {
152
+ bank_account_id: string;
153
+ beneficiary_id: string;
154
+ amount: string;
155
+ reference: string;
156
+ note?: string;
157
+ scheduled_date?: string;
158
+ }
69
159
  export {};
70
160
  //# sourceMappingURL=sepa-transfers.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.types.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,KAAK,0BAA0B,GAC7B,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,OAAO,6BAA6B,CAAC,CAAC;AAErF;;GAEG;AACH,KAAK,kBAAkB,GACrB,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,0BAA0B,CAAC;IAC3C,aAAa,EAAE,IAAI,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC;IAClB,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"}
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,EACL,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,KAAK,0BAA0B,GAC7B,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,OAAO,6BAA6B,CAAC,CAAC;AAErF;;GAEG;AACH,KAAK,kBAAkB,GACrB,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAEvE;;;;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;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;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;CACtB;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"}
@@ -1,2 +1,4 @@
1
+ import type { NewSepaTransfer } from '@sepa-transfers/sepa-transfers.types';
1
2
  export declare function validateGetSepaTransferParams(sepaTransferId: string): string;
3
+ export declare function validateCreateSepaTransferParams(transfer: NewSepaTransfer): NewSepaTransfer;
2
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":"AAEA,wBAAgB,6BAA6B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAU5E"}
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;AAS5E,wBAAgB,6BAA6B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAU5E;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,eAAe,mBAgCzE"}
@@ -1 +1 @@
1
- const _={READY:"qonto.ready"},e={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"},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={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"};export{e as ACTIONS,N as ACTIVITY_TAGS,a as BENEFICIARY_STATUSES,n as BRANCHES,E as ENVIRONMENTS,_ as IFRAME_EVENTS,A as SEPA_TRANSFER_DECLINE_REASONS,i as SEPA_TRANSFER_STATUSES};
1
+ const _={READY:"qonto.ready"},e={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"},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"};export{e as ACTIONS,N as ACTIVITY_TAGS,a as BENEFICIARY_STATUSES,n as BRANCHES,E as ENVIRONMENTS,_ as IFRAME_EVENTS,A as LOCALES,i as SEPA_TRANSFER_DECLINE_REASONS,I as SEPA_TRANSFER_STATUSES};
@@ -1 +1 @@
1
- import{authManager as n}from"../auth/auth.js";import{validateInitializeParams as t}from"./initialize.validate.js";import{operationSettingsManager as e}from"../operation-settings/operation-settings.js";import{environmentManager as o}from"../environment/environment-manager.js";function i(i){const{accessToken:s,stagingToken:r,operationSettings:a,environment:c,branch:m}=t(i);n.setAccessToken(s),r&&n.setStagingToken(r),a&&e.setSettings(a),c&&(o.setEnvironment(c),m&&o.setBranch(m))}function s(){n.clearAccessToken(),n.clearStagingToken()}export{i as initialize,s as logout};
1
+ import{authManager as e}from"../auth/auth.js";import{validateInitializeParams as t}from"./initialize.validate.js";import{operationSettingsManager as n}from"../operation-settings/operation-settings.js";import{environmentManager as o}from"../environment/environment-manager.js";import{localeManager as a}from"../locale/locale-manager.js";function i(i){const{accessToken:s,stagingToken:r,operationSettings:c,environment:m,branch:l,locale:g}=t(i);e.setAccessToken(s),r&&e.setStagingToken(r),g&&a.setLocale(g),c&&n.setSettings(c),m&&(o.setEnvironment(m),l&&o.setBranch(l))}function s(){e.clearAccessToken(),e.clearStagingToken(),a.setDefaultLocale()}export{i as initialize,s as logout};
@@ -1 +1 @@
1
- import{InvalidParametersError as n}from"../../errors/InvalidParametersError.js";import{validateOperationSettingsParams as o}from"../../validation/operation-settings-validation.js";function t(t){if(!t?.accessToken)throw new n("Access token is required when calling initialize()");return t?.operationSettings&&o(t.operationSettings),function(o){if(o.environment){if(!["production","staging","local"].includes(o.environment))throw new n('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(o.branch&&!["master","sandbox","qa"].includes(o.branch))throw new n('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')}}(t),t}export{t as validateInitializeParams};
1
+ import{InvalidParametersError as n}from"../../errors/InvalidParametersError.js";import{validateOperationSettingsParams as o}from"../../validation/operation-settings-validation.js";import{validateLocale as e}from"../locale/locale.validate.js";function t(t){if(!t?.accessToken)throw new n("Access token is required when calling initialize()");return t?.operationSettings&&o(t.operationSettings),function(o){if(o.environment){if(!["production","staging","local"].includes(o.environment))throw new n('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(o.branch&&!["master","sandbox","qa"].includes(o.branch))throw new n('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')}}(t),t.locale&&e(t.locale),t}export{t as validateInitializeParams};
@@ -0,0 +1 @@
1
+ class e{constructor(){this.currentLocale="en"}static getInstance(){return e.instance||(e.instance=new e),e.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const t=e.getInstance();export{t as localeManager};
@@ -0,0 +1 @@
1
+ import{LOCALES as r}from"../constants.js";import{InvalidParametersError as o}from"../../errors/InvalidParametersError.js";const e=Object.values(r);function n(r){if(!function(r){return e.includes(r)}(r))throw new o(`Unsupported locale: ${r}. The locale must be one of: ${e.join(", ")}.`);return r}export{n as validateLocale};
@@ -1 +1 @@
1
- import{authManager as e}from"../auth/auth.js";function n({accessToken:n,stagingToken:t,idempotencyKey:o}){const a=new Headers;a.append("Authorization",`Bearer ${n}`);const p=t||e.getStagingToken();return p&&a.append("X-Qonto-Staging-Token",p),o&&a.append("X-Qonto-Idempotency-Key",o),a.append("Content-Type","application/json"),a.append("Accept-Language","en"),a}export{n as buildRequestHeaders};
1
+ import{authManager as e}from"../auth/auth.js";import{localeManager as n}from"../locale/locale-manager.js";function o({accessToken:o,stagingToken:t,idempotencyKey:a}){const p=new Headers;p.append("Authorization",`Bearer ${o}`);const c=t||e.getStagingToken();return c&&p.append("X-Qonto-Staging-Token",c),a&&p.append("X-Qonto-Idempotency-Key",a),p.append("Content-Type","application/json"),p.append("Accept-Language",n.getLocale()),p}export{o as buildRequestHeaders};
@@ -1 +1 @@
1
- import{EmbedIframe as e}from"./embed-iframe.js";import{environmentManager as n}from"../common/environment/environment-manager.js";function o({accessToken:e,stagingToken:o,language:t,debugMode:r}){const m=r||!1,i=t||"en",a=n.getEnvironmentUrls().IFRAME_URL,c=o?`&staging_token=${encodeURIComponent(o)}`:"";return`${a}?debug=${m}&lang=${encodeURIComponent(i)}#access_token=${encodeURIComponent(e)}${c}`}function t({parentElementId:n,iframeUrl:o}){return new e({parentElementId:n,iframeUrl:o}).initialize()}export{o as buildIframeUrl,t as createIframe};
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{buildRequestHeaders as n}from"../common/network/network.js";import{environmentManager as e}from"../common/environment/environment-manager.js";import{addPaginationParamsToUrl as r}from"../common/api-pagination/api-pagination.js";import{EmbedApiError as o}from"../errors/EmbedApiError.js";const t="/v2/sepa/transfers";async function a({accessToken:a,stagingToken:s,paginationSettings:i}){const m={method:"GET",headers:n({accessToken:a,stagingToken:s})},c=new URL(e.getEnvironmentUrls().THIRD_PARTY_API_URL+t),f=r({endpointUrl:c,paginationSettings:i}),g=await fetch(f,m);if(!g.ok)throw new o("Failed to fetch SEPA transfers");const p=await g.json();if(p.errors)throw new o(p.errors.map((n=>`${n.code}: ${n.detail}`)));return{transfers:p.transfers,meta:p.meta}}async function s({accessToken:r,stagingToken:a,sepaTransferId:s}){const i={method:"GET",headers:n({accessToken:r,stagingToken:a})},m=`${e.getEnvironmentUrls().THIRD_PARTY_API_URL}${t}/${s}`,c=await fetch(m,i),f=await c.json();if(f.errors)throw new o(f.errors.map((n=>`${n.code}: ${n.detail}`)));return f.external_transfer}export{t as SEPA_TRANSFERS_ENDPOINT,s as getSepaTransfer,a as getSepaTransfers};
1
+ import{buildRequestHeaders as e}from"../common/network/network.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{addPaginationParamsToUrl as r}from"../common/api-pagination/api-pagination.js";import{EmbedApiError as t}from"../errors/EmbedApiError.js";import{serializeToNewSepaTransferDataObject as o}from"./sepa-transfers.serializer.js";const s="/v2/sepa/transfers";async function a({accessToken:o,stagingToken:a,paginationSettings:i}){const c={method:"GET",headers:e({accessToken:o,stagingToken:a})},m=new URL(n.getEnvironmentUrls().THIRD_PARTY_API_URL+s),f=r({endpointUrl:m,paginationSettings:i}),g=await fetch(f,c);if(!g.ok)throw new t("Failed to fetch SEPA transfers");const p=await g.json();if(p.errors)throw new t(p.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:p.transfers,meta:p.meta}}async function i({accessToken:r,stagingToken:o,sepaTransferId:a}){const i={method:"GET",headers:e({accessToken:r,stagingToken:o})},c=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${s}/${a}`,m=await fetch(c,i),f=await m.json();if(f.errors)throw new t(f.errors.map((e=>`${e.code}: ${e.detail}`)));return f.external_transfer}async function c({transfer:r,accessToken:a,stagingToken:i,idempotencyKey:c}){const m=o(r),f={method:"POST",headers:e({accessToken:a,stagingToken:i,idempotencyKey:c}),body:JSON.stringify({transfer:m})},g=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${s}`,p=await fetch(g,f),T=await p.json();if(T.errors)throw new t(T.errors.map((e=>`${e.code}: ${e.detail}`)));return T.transfer}export{s as SEPA_TRANSFERS_ENDPOINT,c as createSepaTransfer,i as getSepaTransfer,a as getSepaTransfers};
@@ -1 +1 @@
1
- import"../common/auth/auth.js";import{validatePresenceOfAuthToken as a}from"../common/auth/auth.validate.js";import{serializePaginationResponse as s}from"../common/api-pagination/api-pagination.js";import{getSepaTransfer as n,getSepaTransfers as t}from"./sepa-transfers.api.js";import{serializeSepaTransfer as e}from"./sepa-transfers.serializer.js";import{validateGetSepaTransferParams as r}from"./sepa-transfers.validate.js";async function o(n={}){const r=n?.accessToken||a(),o=await t({accessToken:r,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),i=o.transfers.map((a=>e(a))),p=s(o.meta);return{transfers:i,...p?{meta:p}:{}}}async function i({sepaTransferId:s,accessToken:t,stagingToken:o}){const i=t||a();r(s);const p=await n({sepaTransferId:s,accessToken:i,stagingToken:o});return e(p)}export{i as getSepaTransfer,o as getSepaTransfers};
1
+ import"../common/auth/auth.js";import{validatePresenceOfAuthToken as a}from"../common/auth/auth.validate.js";import{serializePaginationResponse as s}from"../common/api-pagination/api-pagination.js";import{createSepaTransfer as e,getSepaTransfer as n,getSepaTransfers as t}from"./sepa-transfers.api.js";import{serializeSepaTransfer as o}from"./sepa-transfers.serializer.js";import{validateCreateSepaTransferParams as r,validateGetSepaTransferParams as i}from"./sepa-transfers.validate.js";import c from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";async function m(e={}){const n=e?.accessToken||a(),r=await t({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=r.transfers.map((a=>o(a))),c=s(r.meta);return{transfers:i,...c?{meta:c}:{}}}async function p({sepaTransferId:s,accessToken:e,stagingToken:t}){const r=e||a();i(s);const c=await n({sepaTransferId:s,accessToken:r,stagingToken:t});return o(c)}async function f({transfer:s,accessToken:n,stagingToken:t,idempotencyKey:i}){const m=n||a(),p=i||c();r(s);const f=await e({transfer:s,accessToken:m,stagingToken:t,idempotencyKey:p});return o(f)}export{f as createSepaTransfer,p as getSepaTransfer,m as getSepaTransfers};
@@ -1 +1 @@
1
- import{getSepaTransfer as e,getSepaTransfers as r}from"./sepa-transfers.js";const s={getSepaTransfers:r,getSepaTransfer:e};export{s as sepaTransfers};
1
+ import{createSepaTransfer as e,getSepaTransfer as r,getSepaTransfers as a}from"./sepa-transfers.js";const s={getSepaTransfers:a,getSepaTransfer:r,createSepaTransfer:e};export{s as sepaTransfers};
@@ -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}}export{e as serializeSepaTransfer};
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:e.beneficiaryId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{}}}export{e as serializeSepaTransfer,t as serializeToNewSepaTransferDataObject};
@@ -1 +1 @@
1
- import{InvalidParametersError as r}from"../errors/InvalidParametersError.js";function e(e){if(!e)throw new r("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new r("sepaTransferId must be a string");return e}export{e as validateGetSepaTransferParams};
1
+ import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as r,validateExpectedStringValues as n,validateExpectedNumericValues as t}from"../validation/input-param-validation.js";const a=[{name:"bankAccountId"},{name:"beneficiaryId"},{name:"reference"},{name:"amount"}];function o(r){if(!r)throw new e("sepaTransferId parameter is required for the called function");if(r&&"string"!=typeof r)throw new e("sepaTransferId must be a string");return r}function i(o){if(!o)throw new e("transfer parameter is required for the called function");if("object"!=typeof o)throw new e("transfer must be an object");r(o,a);const i=[...n({beneficiaryId:o.beneficiaryId,bankAccountId:o.bankAccountId,note:o.note,reference:o.reference}),...t({amount:o.amount})].flat();if(i.length>0)throw new e(i);return o}export{i as validateCreateSepaTransferParams,o as validateGetSepaTransferParams};
@@ -1,3 +1,3 @@
1
- import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, GetSepaTransfersResponse, GetBeneficiariesResponse, PaginationState, BankAccount, ACCOUNT_STATUS } from './types.public-api';
2
- export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, GetSepaTransfersResponse, PaginationState, BankAccount, ACCOUNT_STATUS, };
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, };
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,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,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,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"}
@@ -2,6 +2,7 @@ import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrd
2
2
  import type { Beneficiary, GetBeneficiariesResponse } from '@beneficiaries/beneficiaries.types';
3
3
  import type { SepaTransfer, GetSepaTransfersResponse } from '@sepa-transfers/sepa-transfers.types';
4
4
  import type { PaginationState } from '@common/api-pagination/api-pagination.types';
5
+ import type { Locale } from '@common/locale/locale.types';
5
6
  import type { BankAccount, ACCOUNT_STATUS } from '@organizations/organizations.types';
6
- export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, GetSepaTransfersResponse, PaginationState, BankAccount, ACCOUNT_STATUS, };
7
+ export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, SepaTransfer, GetSepaTransfersResponse, PaginationState, Locale, BankAccount, ACCOUNT_STATUS, };
7
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,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,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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {