@qonto/embed-sdk 0.27.0 → 0.29.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 (36) hide show
  1. package/dist/cards/cards.api.d.ts +11 -0
  2. package/dist/cards/cards.api.d.ts.map +1 -1
  3. package/dist/cards/cards.d.ts +37 -21
  4. package/dist/cards/cards.d.ts.map +1 -1
  5. package/dist/cards/cards.validate.d.ts +11 -0
  6. package/dist/cards/cards.validate.d.ts.map +1 -1
  7. package/dist/cards/cards.validate.test.d.ts +2 -0
  8. package/dist/cards/cards.validate.test.d.ts.map +1 -0
  9. package/dist/index.d.ts +3 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.umd.js +1 -1
  12. package/dist/mocks/handlers.d.ts +2 -0
  13. package/dist/mocks/handlers.d.ts.map +1 -1
  14. package/dist/organizations/index.d.ts +3 -11
  15. package/dist/organizations/index.d.ts.map +1 -1
  16. package/dist/organizations/organizations.api.d.ts +5 -0
  17. package/dist/organizations/organizations.api.d.ts.map +1 -1
  18. package/dist/organizations/organizations.d.ts +11 -4
  19. package/dist/organizations/organizations.d.ts.map +1 -1
  20. package/dist/organizations/organizations.public-api.d.ts +1 -4
  21. package/dist/organizations/organizations.public-api.d.ts.map +1 -1
  22. package/dist/organizations/organizations.types.d.ts +36 -0
  23. package/dist/organizations/organizations.types.d.ts.map +1 -1
  24. package/dist/payment-links/index.d.ts +1 -6
  25. package/dist/payment-links/index.d.ts.map +1 -1
  26. package/dist/src/cards/cards.api.js +1 -1
  27. package/dist/src/cards/cards.js +1 -1
  28. package/dist/src/cards/cards.validate.js +1 -1
  29. package/dist/src/index.js +1 -1
  30. package/dist/src/organizations/index.js +1 -0
  31. package/dist/src/organizations/organizations.api.js +1 -0
  32. package/dist/src/organizations/organizations.js +1 -0
  33. package/dist/src/organizations/organizations.public-api.js +1 -0
  34. package/dist/src/organizations/organizations.serializer.js +1 -0
  35. package/dist/src/payment-links/index.js +1 -0
  36. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import type { CardDataObject, DisplayCardSettings } from './cards.types';
2
2
  import type { OperationSettings } from '@validation/operation-settings-validation';
3
+ import type { NetworkCallDescriptor } from '@common/network/network';
3
4
  interface GetCardsParams {
4
5
  membershipId?: string;
5
6
  accessToken: string;
@@ -11,7 +12,17 @@ interface GetCardParams {
11
12
  stagingToken?: string;
12
13
  }
13
14
  export type GetCardIframeUrlParams = DisplayCardSettings & Pick<OperationSettings, 'accessToken' | 'stagingToken' | 'mfaPreference'>;
15
+ export declare function prepareGetCardsCall({ membershipId, accessToken, stagingToken, }: {
16
+ membershipId?: string;
17
+ accessToken?: string;
18
+ stagingToken?: string;
19
+ }): NetworkCallDescriptor;
14
20
  export declare function getCards({ membershipId, accessToken, stagingToken, }: GetCardsParams): Promise<CardDataObject[]>;
21
+ export declare function prepareGetCardCall({ cardId, accessToken, stagingToken, }: {
22
+ cardId: string;
23
+ accessToken?: string;
24
+ stagingToken?: string;
25
+ }): NetworkCallDescriptor;
15
26
  export declare function getCard({ cardId, accessToken, stagingToken, }: GetCardParams): Promise<CardDataObject>;
16
27
  export declare function getCardIframeURL(getCardIframeUrlParams: GetCardIframeUrlParams): Promise<string>;
17
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"cards.api.d.ts","sourceRoot":"","sources":["../../src/cards/cards.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAEnF,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GACtD,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC,CAAC;AAE5E,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAoB5C;AAED,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBzC;AAED,wBAAsB,gBAAgB,CACpC,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
1
+ {"version":3,"file":"cards.api.d.ts","sourceRoot":"","sources":["../../src/cards/cards.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GACtD,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAiBxB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAY5C;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAYzC;AAED,wBAAsB,gBAAgB,CACpC,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
@@ -6,6 +6,9 @@ import { type OperationSettings } from '@validation/operation-settings-validatio
6
6
  * `operationSettings` object. The `cardSettings` object's properties will be
7
7
  * different depending on the function being called. Read the docs of each card
8
8
  * related function to see the expected properties of the `cardSettings` object.
9
+ * The `operationSettings` object can include a `proxyRequestFunction` which allows
10
+ * the SDK to operate without needing an access token in the client. This is the
11
+ * recommended approach for production environments to avoid exposing sensitive tokens.
9
12
  */
10
13
  export interface CardParams<T> {
11
14
  /**
@@ -13,41 +16,54 @@ export interface CardParams<T> {
13
16
  * documentation of each function to see the expected properties of this object.
14
17
  */
15
18
  cardSettings: T;
19
+ /**
20
+ * Optional operation settings that can include:
21
+ * - `proxyRequestFunction`: A function that allows the SDK to make requests through your server
22
+ * to avoid exposing sensitive tokens in the client. This is the recommended approach.
23
+ * - `accessToken`: An access token for direct API calls (not recommended for client-side code)
24
+ * - `stagingToken`: A token for testing in staging environments
25
+ * - Other operation-specific settings
26
+ */
16
27
  operationSettings?: OperationSettings;
17
28
  }
18
29
  /**
19
30
  * Fetches the list of cards for the current user.
20
- * @param getCardsParams - An object with the optional `membershipId`, `accessToken`,
21
- * and `stagingToken` properties. If the `membershipId` parameter is passed, the
22
- * function will return the cards that belong to the specified membership only.
31
+ * @param getCardsParams - An object with optional parameters:
32
+ * - `cardSettings`: An object that can contain the optional `membershipId` property.
33
+ * - `operationSettings`: An object with operation-level settings such as
34
+ * `proxyRequestFunction` (preferred over using the access token flow),
35
+ * `accessToken`, `stagingToken`, and other optional parameters.
36
+ * See {@link OperationSettings} for more details.
37
+ * If the `membershipId` parameter is passed, the function will return the cards
38
+ * that belong to the specified membership only.
23
39
  * If the `accessToken` is not provided, the function will use the token previously
24
40
  * passed to the initialize function. The `stagingToken` is optional, but it has
25
- * to be passed to use the SDK in staging
26
- * environments (it will be ignored in production).
41
+ * to be passed to use the SDK in staging environments (it will be ignored in production).
27
42
  * @returns A promise that resolves to an array of cards.
28
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
29
- * Ensure initialize has been called before using this function if you are not
30
- * passing the access token.
43
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and `accessToken` are invalid or missing within
44
+ * `operationSettings`.
45
+ * @throws \{EmbedApiError\} If the API request fails or returns an error.
31
46
  */
32
- export declare function getCards({ membershipId, accessToken, stagingToken, }: {
47
+ export declare function getCards(getCardsParams?: CardParams<{
33
48
  membershipId?: string;
34
- accessToken?: string;
35
- stagingToken?: string;
36
- }): Promise<Card[]>;
49
+ }>): Promise<Card[]>;
37
50
  /**
38
51
  * Fetches a card by its id.
39
- * @param Object - An object with the cardId and the optional accessToken and
40
- * stagingToken properties.
52
+ * @param getCardParams - An object containing:
53
+ * - `cardSettings`: An object with the `cardId` property (string).
54
+ * - `operationSettings`: An object with operation-level settings such as
55
+ * `proxyRequestFunction` (preferred over using the access token flow),
56
+ * `accessToken`, `stagingToken`, and other optional parameters.
57
+ * See {@link OperationSettings} for more details.
41
58
  * @returns A promise that resolves to a card.
42
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
43
- * Ensure initialize has been called before using this function if you are not
44
- * passing the access token.
59
+ * @throws \{InvalidParametersError\} If the cardId is not provided or if the cardId is not a string.
60
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and `accessToken` are invalid or missing within
61
+ * `operationSettings`.
62
+ * @throws \{EmbedApiError\} If the API request fails or returns an error.
45
63
  */
46
- export declare function getCard({ cardId, accessToken, stagingToken, }: {
64
+ export declare function getCard({ cardSettings, operationSettings, }: CardParams<{
47
65
  cardId: string;
48
- accessToken?: string;
49
- stagingToken?: string;
50
- }): Promise<Card>;
66
+ }>): Promise<Card>;
51
67
  /**
52
68
  * Requests the creation of a card by showing the user the UI to perform MFA in the calling page.
53
69
  * It will show an element on the screen where users will be able to go through the MFA
@@ -1 +1 @@
1
- {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAInD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAelB;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsClC"}
1
+ {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAavB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAMnD;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,QAAQ,CAC5B,cAAc,CAAC,EAAE,UAAU,CAAC;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrD,OAAO,CAAC,IAAI,EAAE,CAAC,CAkCjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAC,EAC5B,YAAY,EACZ,iBAAiB,GAClB,EAAE,UAAU,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsClC"}
@@ -2,4 +2,15 @@ import { type CardOrderSettings, type DisplayCardSettings, type UnlockCardSettin
2
2
  export declare function validateOrderCardParams(params: CardOrderSettings): void | VirtualCardOrderSettings;
3
3
  export declare function validateUnlockCardParams(params: UnlockCardSettings): void;
4
4
  export declare function validateDisplayCardParams(params: DisplayCardSettings): DisplayCardSettings;
5
+ /**
6
+ * Validates the parameters for the getCard function
7
+ * @param params - Card settings with cardId property
8
+ * @returns The validated params
9
+ * @throws InvalidParametersError if cardId is missing or not a string
10
+ */
11
+ export declare function validateGetCardParams(params: {
12
+ cardId: string;
13
+ }): {
14
+ cardId: string;
15
+ };
5
16
  //# sourceMappingURL=cards.validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cards.validate.d.ts","sourceRoot":"","sources":["../../src/cards/cards.validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAGxB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAC;AAyB5B,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,mCAWhE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,QAelE;AA2ND,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,mBAAmB,uBAkCpE"}
1
+ {"version":3,"file":"cards.validate.d.ts","sourceRoot":"","sources":["../../src/cards/cards.validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAGxB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAC;AAyB5B,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,mCAWhE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,QAelE;AA2ND,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,mBAAmB,uBAkCpE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;YAAR,MAAM;EAiB7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cards.validate.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cards.validate.test.d.ts","sourceRoot":"","sources":["../../src/cards/cards.validate.test.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -2,8 +2,9 @@ import { initialize, logout, constants } from '@common';
2
2
  import { cards } from '@cards';
3
3
  import { beneficiaries } from '@beneficiaries';
4
4
  import { sepaTransfers } from '@sepa-transfers';
5
- import { paymentLinks } from '@payment-links/payment-links.public-api';
5
+ import { paymentLinks } from '@payment-links';
6
+ import { organizations } from '@organizations';
6
7
  import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, Item, CreatePaymentLinkSettings, PaymentLinkParams } from '@types';
7
- export { initialize, logout, cards, sepaTransfers, beneficiaries, constants, paymentLinks, };
8
+ export { initialize, logout, cards, sepaTransfers, beneficiaries, constants, paymentLinks, organizations, };
8
9
  export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, SepaTransfer, Item, CreatePaymentLinkSettings, PaymentLinkParams, };
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,GACb,CAAC;AACF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,GAClB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,GACd,CAAC;AACF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,yBAAyB,EACzB,iBAAiB,GAClB,CAAC"}
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const t=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!t.hasAccessToken())throw new a;return t.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},m={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},f=3e4;var g=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},AMOUNT_REQUIRING_ATTACHMENTS:f,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:m,MFA_METHODS:l,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"}});class p{constructor(){this.mfaPreference=l.PASSKEY,this.debugMode=!1}static getInstance(){return p.instance||(p.instance=new p),p.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const h=p.getInstance(),y="https://embed.qonto.com",T="https://embed-js{branch}.staging.qonto.co",_="https://embed.dev.qonto.co",I={[d.PRODUCTION]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class b{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,n=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(n)?n:u.SANDBOX}static getInstance(){return b.instance||(b.instance=new b),b.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return I.production;{const e=I[this.environment];return Object.entries(e).reduce(((e,[n,t])=>({...e,[n]:t.replace("{branch}",`-${this.branch}`)})),{})}}}const w=b.getInstance(),E={requiresUI:!1};function k(e,{requiresUI:n}=E){const t=e?.uiParentElementId||h.getUIParentElementId();if(n&&!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=e?.mfaPreference||h.getMFAPreference();if(i){const e=(a=Object.values(l),w.isProductionEnvironment()?a.filter((e=>e!==l.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(w.isProductionEnvironment()&&i===l.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var a;const r=e?.debugMode||h.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||h.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:t,mfaPreference:i,debugMode:r,proxyRequestFunction:o}}const A=Object.values(m);function R(e){if(!function(e){return A.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${A.join(", ")}.`);return e}function S(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&k(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&&R(e.locale),e}class v{constructor(){this.currentLocale="en"}static getInstance(){return v.instance||(v.instance=new v),v.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=v.getInstance();const P={initialize:function(e){const{accessToken:n,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=S(e);n&&t.setAccessToken(n),i&&t.setStagingToken(i),o&&L.setLocale(o),a&&h.setSettings(a),r&&(w.setEnvironment(r),s&&w.setBranch(s))},logout:function(){t.clearAccessToken(),t.clearStagingToken(),L.setDefaultLocale(),h.clearSettings()},constants:g},{initialize:D,logout:O,constants:N}=P;class U extends i{constructor(e){super();const n=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${n}`}}function C(){return"undefined"!=typeof window&&"undefined"!=typeof document}function M(){return!C()}function $({accessToken:e,stagingToken:n,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=n||t.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||h.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",L.getLocale()),r}async function F({path:e,options:n}){const t=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,i=await fetch(t,{...n,headers:$(n.headers),body:JSON.stringify(n.body)}),a=await i.json();if(!i.ok)throw a.errors?new U(a.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${a.code}: ${a.detail}`);return a}function q(e){const n={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},t=JSON.stringify(n);return i=t,M()?Buffer.from(i).toString("base64"):btoa(i);var i}function B(e){return JSON.parse((n=e,M()?Buffer.from(n,"base64").toString("utf-8"):atob(n)));var n}var G;!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"}(G||(G={}));const K={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 x,j;function H(e,n){const t=n.filter((n=>n.requiredIfPresent?!e[n.name]&&e[n.requiredIfPresent]:void 0===e[n.name])).map((e=>e.name));if(t.length>0)throw new s(t.map((e=>`Missing required parameter: ${e}`)))}function Y(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function z(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function V(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"}(x||(x={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(j||(j={}));const W=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],X=[...W,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function Q(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return H(e,W),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(l),g=Y({membershipId:n,organizationId:t,bankAccountId:i}),p=z({hasDailyLimit:a,hasTransactionLimit:r}),h=V({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=J(u),T=Z(m),_=[...f,...g,...p,...h,...y,...T];if(_.length>0)throw new s(_)}(e),e}(e):function(e){H(e,X),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:y,hasAtmDailyLimit:T,atmDailyLimit:_,atmMonthlyLimit:I,address:b,cardDesign:w,typeOfPrint:E}=e,k=function(e){return Object.values(j).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(l),A=function(e){const n=null!=e&&"string"!=typeof e,t=!["print","embossed",void 0,null].includes(e);return n||t?['typeOfPrint must be one of "print", "embossed" or null']:[]}(E),R=Y({membershipId:n,organizationId:t,bankAccountId:i}),S=z({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:T,shipToBusiness:h}),v=V({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:I}),L=J(u),P=Z(m),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(w),O=function(e,n){if(n)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(b,h),N=[...k,...R,...S,...v,...L,...P,...A,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function J(e){const n=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&n?["activeDays must be an array of integers between 1 and 7"]:[]}function Z(e){const n=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&n?["categories must be an array of strings"]:[]}class ee extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ne=[];for(let e=0;e<256;++e)ne.push((e+256).toString(16).slice(1));let te;const ie=new Uint8Array(16);var ae={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function re(e,n,t){if(ae.randomUUID&&!e)return ae.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!te){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");te=crypto.getRandomValues.bind(crypto)}return te(ie)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(ne[e[n+0]]+ne[e[n+1]]+ne[e[n+2]]+ne[e[n+3]]+"-"+ne[e[n+4]]+ne[e[n+5]]+"-"+ne[e[n+6]]+ne[e[n+7]]+"-"+ne[e[n+8]]+ne[e[n+9]]+"-"+ne[e[n+10]]+ne[e[n+11]]+ne[e[n+12]]+ne[e[n+13]]+ne[e[n+14]]+ne[e[n+15]]).toLowerCase()}(i)}function se({actionId:e,actionData:n}){const t=h.getMFAPreference();return{actionId:e,actionData:{...n,scaPreference:n.scaPreference||t,idempotencyKey:n.idempotencyKey||re()}}}class oe{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const n=new URL(e.iframeUrl);this.targetOrigin=`${n.protocol}//${n.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new ee(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,n)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const t=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),n(new ee(`Could not install the authentication UI because the timeout of ${t}ms was reached.\nPlease make sure the application can reach the Internet.`))}),t),a=n=>{n.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new ee("Attempted to perform an Embed operation without having the authentication UI initialized."));const n=se(e);return new Promise(((e,t)=>{const i=a=>{if(a.data?.actionId===n.actionId){if("error"===a.data.status)return this.removeMessageListener(n.actionId,i),t(new ee(`An error occurred when performing the action ${n.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(n.actionId,i),e(a.data.payload)}};this.addMessageListener(n.actionId,i),this.iframe?.contentWindow?.postMessage(n,this.targetOrigin)}))}addMessageListener(e,n){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(n),window.addEventListener("message",n)}removeMessageListener(e,n){const t=this.messageListeners.get(e);if(t){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),window.removeEventListener("message",n))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function ce({accessToken:e,stagingToken:n,locale:t,debugMode:i}){const a=i||!1,r=t||L.getLocale(),s=w.getEnvironmentUrls().IFRAME_URL,o=n?`;staging_token=${encodeURIComponent(n)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function de({parentElementId:e,iframeUrl:n}){return new oe({parentElementId:e,iframeUrl:n}).initialize()}function ue(e){return"virtual"===e.cardLevel?function(e){const n=le(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:re(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel}}}}}(e):function(e){const n=le(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:re(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function me(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 le(e){const n=Object.values(K);return(e||[]).filter((e=>n.includes(e)))}const fe={getCards:async function({membershipId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=w.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new U(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:t});return a.map((e=>me(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:t});return me(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=k(e.operationSettings,{requiresUI:!0});Q(e.cardSettings);const s=ce({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),o=await de({iframeUrl:s,parentElementId:i}),c=ue(e.cardSettings),d=await o.postMessage(c);return o.destroy(),me(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=k(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=Y({cardId:e.cardId});if(n.length>0)throw new s(n)}(e.cardSettings);const o=ce({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),d=await de({iframeUrl:o,parentElementId:i}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),m=await d.postMessage(u);return d.destroy(),me(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:n,accessToken:t,stagingToken:i,debugMode:a,mfaPreference:o}=k(e.operationSettings,{requiresUI:!0}),c=t||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=Y({cardId:e.cardId});if(n.length>0)throw new s(n);let t={};void 0!==e.allowPinReveal&&(t={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(t={...t,allowBlocking:e.allowBlocking});const i=z(t);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:n,stagingToken:t,mfaPreference:i}=e,a={method:"GET",headers:$({accessToken:n,stagingToken:t,mfaPreference:i})},r=w.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(!s.ok)throw o.errors?new U(o.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:u,allowBlocking:m}=e.cardSettings,l=function(e,n){const t=new URL(e);return"boolean"==typeof n.allowPinReveal&&t.searchParams.set("canSeePin",n.allowPinReveal.toString()),"boolean"==typeof n.allowBlocking&&t.searchParams.set("canBlock",n.allowBlocking.toString()),!0===n.debugMode&&t.searchParams.set("debug",n.debugMode.toString()),t.toString()}(d,{allowPinReveal:u,allowBlocking:m,debugMode:a}),f=await de({iframeUrl:l,parentElementId:n});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},ge=fe;function pe(e){const n=new URLSearchParams;return e?.page&&n.append("page",e.page.toString()),e?.itemsPerPage&&n.append("per_page",e.itemsPerPage.toString()),n}function he({endpointUrl:e,paginationSettings:n}){return function({url:e,searchParams:n}){const t=new URL(e.toString());for(const[e,i]of n.entries())t.searchParams.append(e,i);return t}({url:new URL(e),searchParams:pe(n)})}function ye(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 Te(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 _e(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 Ie="/v2/sepa/beneficiaries";function be({paginationSettings:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:{accessToken:n,stagingToken:t}},a=pe(e),r=a.size?`?${a.toString()}`:"";return{path:`${Ie}${r}`,options:i}}function we({beneficiaryId:e,accessToken:n,stagingToken:t}){return{path:`${Ie}/${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:t}}}}async function Ee({accessToken:e,stagingToken:n,beneficiaryId:t}){const i=we({beneficiaryId:t,accessToken:e,stagingToken:n}),{beneficiary:a}=await F(i);return a}function ke({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i=re()}){return{path:Ie,options:{method:"POST",headers:{accessToken:n,stagingToken:t,idempotencyKey:i},body:{beneficiary:_e(e)}}}}function Ae({beneficiaryIds:e,accessToken:n,stagingToken:t}){return{path:`${Ie}/untrust`,options:{method:"PATCH",headers:{accessToken:n,stagingToken:t},body:{ids:e}}}}function Re({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${Ie}/${e.id}`,options:c}}const Se=[{name:"name"},{name:"iban"}];const ve={getBeneficiaries:async function(e){const{stagingToken:n,proxyRequestFunction:t,accessToken:i,paginationSettings:a}=k(e?.operationSettings||{});if(t){const e=q(be({paginationSettings:a})),n=B(await t(e)),i=n.body.beneficiaries.map((e=>Te(e))),r=ye(n.body.meta);return{beneficiaries:i,...r?{meta:r}:{}}}{const e=i||r(),t=await async function({paginationSettings:e,accessToken:n,stagingToken:t}){const i=be({paginationSettings:e,accessToken:n,stagingToken:t}),{beneficiaries:a,meta:r}=await F(i);return{beneficiaries:a,meta:r}}({accessToken:e,stagingToken:n,paginationSettings:a}),s=t.beneficiaries.map((e=>Te(e))),o=ye(t.meta);return{beneficiaries:s,...o?{meta:o}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=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");return e}(e?.beneficiaryId),{proxyRequestFunction:i,accessToken:a,stagingToken:o}=k(n||{});if(i){const e=q(we({beneficiaryId:t}));return Te(B(await i(e)).body.beneficiary)}{const e=a||r();return Te(await Ee({beneficiaryId:t,accessToken:e,stagingToken:o}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=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");H(e,Se);const n=Y({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(n.length>0)throw new s(n);return e}(e),{proxyRequestFunction:i,accessToken:a,stagingToken:o,idempotencyKey:c}=k(n||{});if(i){const e=q(ke({beneficiary:t,idempotencyKey:c}));return Te(B(await i(e)).body.beneficiary)}{const e=a||r(),n=await async function({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i=re()}){const a=ke({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i}),{beneficiary:r}=await F(a);return r}({beneficiary:t,accessToken:e,stagingToken:o,idempotencyKey:c});return Te(n)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){const{id:n,name:t,email:i,activityTag:a}=e||{};if(!n)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!t&&!i&&!a)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=Y({name:t,email:i,activityTag:a});if(r.length>0)throw new s(r);return{id:n,name:t,email:i,activityTag:a}}(e),{stagingToken:i,idempotencyKey:a,mfaPreference:o,proxyRequestFunction:c}=k(n),d={beneficiaryParamsBeingEdited:t,idempotencyKey:a,mfaPreference:o};if(c){const e=q(Re(d));return Te(B(await c(e)).body.beneficiary)}{const e=n?.accessToken||r(),t=await async function({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=Re({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}),{beneficiary:s}=await F(r);return s}({...d,accessToken:e,stagingToken:i});return Te(t)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:i,accessToken:a,stagingToken:o}=k(n||{});if(i){const e=q(Ae({beneficiaryIds:t}));return B(await i(e)).body.beneficiaries.map(Te)}{const e=a||r(),n=await async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i=Ae({beneficiaryIds:e,accessToken:n,stagingToken:t}),{beneficiaries:a}=await F(i);return a}({beneficiaryIds:t,accessToken:e,stagingToken:o});return n.map(Te)}}},Le=ve;function Pe(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}const De="/v2/sepa/bulk_transfers";function Oe(e){if(!e)throw new s("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new s("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new s("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new s("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,n)=>{!function(e,n){if(!e)throw new s(`Invalid bulkTransfer at index ${n}: bulkTransfer object is required`);if(!e.beneficiaryId&&!e.beneficiary)throw new s(`Invalid bulkTransfer at index ${n}: Either beneficiaryId for an existing beneficiary or beneficiary details must be provided`);if(e.beneficiaryId&&e.beneficiary)throw new s(`Invalid bulkTransfer at index ${n}: Provide either beneficiaryId for an existing beneficiary or beneficiary details to create/update one, not both`);if(e.beneficiary){if(!e.beneficiary.iban)throw new s(`Invalid bulkTransfer at index ${n}: IBAN is required when providing beneficiary details`);if(!e.beneficiary.name)throw new s(`Invalid bulkTransfer at index ${n}: Beneficiary name is required when providing beneficiary details`)}const t=Y({beneficiaryId:e.beneficiaryId,reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),i=V({amount:e.amount}),a=[...t,...i].flat();if(a.length>0)throw new s(a);if(e.amount>f&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new s(`Invalid bulkTransfer at index ${n}: Attachments are required for transfers over €30000`)}(e,n)})),e}const Ne="browser",Ue="server";class Ce extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ne:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case Ue:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}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}}function $e(e){const n=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:n,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}const Fe="/v2/sepa/transfers";const qe=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Be({sepaTransferSettings:e,operationSettings:n}){if(e?.beneficiary)return e.beneficiary;return Te(await Ee({beneficiaryId:e?.beneficiaryId,accessToken:n?.accessToken,stagingToken:n?.stagingToken}))}const Ge={getSepaTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),i=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=he({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Fe}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new U("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),a=i.transfers.map(Me),s=ye(i.meta);return{transfers:a,...s?{meta:s}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);return Me(await async function({accessToken:e,stagingToken:n,sepaTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Fe}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.transfer}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),o=n?.idempotencyKey||re();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(H(e,qe),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const n=[...Y({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...V({amount:e.amount})].flat();if(n.length>0)throw new s(n);if(e.amount>f&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u={...e,beneficiary:await Be({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(u.beneficiary?.trusted)d=await async function({transfer:e,accessToken:n,stagingToken:t,idempotencyKey:i}){const a=$e(e),r={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Fe}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new U(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:u,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if(!C())throw new Ce(Ne);const{uiParentElementId:e,debugMode:t}=k(n,{requiresUI:!0});let r;try{const n=ce({accessToken:i,stagingToken:a||void 0,debugMode:t});r=await de({iframeUrl:n,parentElementId:e});const s=$e(u);d=await r.postMessage(se({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}}))}finally{r?.destroy()}}return Me(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Fe}/${e}/cancel`,r=await fetch(a,i);if(204!==r.status){const e=await r.json();if(e.errors)throw new U(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken})},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),{stagingToken:i,paginationSettings:a}=k(n||{}),s=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=he({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${De}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new U("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:t,stagingToken:i,paginationSettings:a}),o=s.bulkTransfers?.map(Pe),c=ye(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),{stagingToken:i}=k(n||{}),a=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Pe(await async function({accessToken:e,stagingToken:n,bulkTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${De}/${t}`),r=await fetch(a,i),s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:t,stagingToken:i,bulkTransferId:a}))},createBulkTransfer:async function({bulkTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),s=n?.idempotencyKey||re();if(Oe(e),!C())throw new Ce(Ne);const{uiParentElementId:o,debugMode:d}=k(n,{requiresUI:!0});let u,m;try{const n=ce({accessToken:i,stagingToken:a||void 0,debugMode:d});m=await de({iframeUrl:n,parentElementId:o});const t={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};u=await m.postMessage(se({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:t,idempotencyKey:s}}))}finally{m?.destroy()}return Pe(u)}}},Ke={GOOD:"good",SERVICE:"service"},xe={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},je=e=>{if(!(e=>Object.values(xe).includes(e))(e))throw new s(`currency ${e} is not valid, valid currencies are ${Object.values(xe).join(", ")}`)},He={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},Ye=e=>{if(!(e=>Object.values(He).includes(e))(e))throw new s(`unit ${e} is not valid, valid units are ${Object.values(He).join(", ")}`)},ze=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],Ve=[{name:"currency"},{name:"value"}];const We=e=>{if(!Object.values(Ke).includes(e))throw new s(`type ${e} is not valid, valid types are ${Object.values(Ke).join(", ")}`)},Xe={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e,operationSettings:n})=>{const{items:t,redirectUrl:i}=e,a=n?.accessToken||r();!function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{H(e,ze),H(e.unitPrice,Ve);const n=[...Y({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...V({quantity:e.quantity})].flat();if(n.length>0)throw new s(n);We(e.type),je(e.unitPrice.currency),Ye(e.measureUnit)}))}(t),function(e){if(!e)throw new s("redirectUrl is required for the called function");const n=Y({redirectUrl:e});if(n.length>0)throw new s(n);try{new URL(e)}catch{throw new s("redirectUrl is not a valid URL")}}(i);return`${w.getEnvironmentUrls().IFRAME_BASE_URL+"/payment-links/creation-flow/products-and-services"}#access_token=${a}?${new URLSearchParams({...t?{items:JSON.stringify(t)}:{},redirectUrl:i}).toString()}`}};e.beneficiaries=Le,e.cards=ge,e.constants=N,e.initialize=D,e.logout=O,e.paymentLinks=Xe,e.sepaTransfers=Ge}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const t=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!t.hasAccessToken())throw new a;return t.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},m={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},f=3e4;var g=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},AMOUNT_REQUIRING_ATTACHMENTS:f,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:m,MFA_METHODS:l,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"}});class p{constructor(){this.mfaPreference=l.PASSKEY,this.debugMode=!1}static getInstance(){return p.instance||(p.instance=new p),p.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const h=p.getInstance(),y="https://embed.qonto.com",T="https://embed-js{branch}.staging.qonto.co",_="https://embed.dev.qonto.co",I={[d.PRODUCTION]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class b{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,n=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(n)?n:u.SANDBOX}static getInstance(){return b.instance||(b.instance=new b),b.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return I.production;{const e=I[this.environment];return Object.entries(e).reduce(((e,[n,t])=>({...e,[n]:t.replace("{branch}",`-${this.branch}`)})),{})}}}const w=b.getInstance(),k={requiresUI:!1};function E(e,{requiresUI:n}=k){const t=e?.uiParentElementId||h.getUIParentElementId();if(n&&!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=e?.mfaPreference||h.getMFAPreference();if(i){const e=(a=Object.values(l),w.isProductionEnvironment()?a.filter((e=>e!==l.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(w.isProductionEnvironment()&&i===l.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var a;const r=e?.debugMode||h.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||h.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:t,mfaPreference:i,debugMode:r,proxyRequestFunction:o}}const A=Object.values(m);function R(e){if(!function(e){return A.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${A.join(", ")}.`);return e}function S(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&E(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&R(e.locale),e}class v{constructor(){this.currentLocale="en"}static getInstance(){return v.instance||(v.instance=new v),v.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=v.getInstance();const P={initialize:function(e){const{accessToken:n,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=S(e);n&&t.setAccessToken(n),i&&t.setStagingToken(i),o&&L.setLocale(o),a&&h.setSettings(a),r&&(w.setEnvironment(r),s&&w.setBranch(s))},logout:function(){t.clearAccessToken(),t.clearStagingToken(),L.setDefaultLocale(),h.clearSettings()},constants:g},{initialize:D,logout:O,constants:N}=P;class U extends i{constructor(e){super();const n=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${n}`}}function C(){return"undefined"!=typeof window&&"undefined"!=typeof document}function M(){return!C()}function $({accessToken:e,stagingToken:n,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=n||t.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||h.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",L.getLocale()),r}async function F({path:e,options:n}){const t=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,i=await fetch(t,{...n,headers:$(n.headers),body:JSON.stringify(n.body)}),a=await i.json();if(!i.ok)throw a.errors?new U(a.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${a.code}: ${a.detail}`);return a}function q(e){const n={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},t=JSON.stringify(n);return i=t,M()?Buffer.from(i).toString("base64"):btoa(i);var i}function B(e){return JSON.parse((n=e,M()?Buffer.from(n,"base64").toString("utf-8"):atob(n)));var n}function G({membershipId:e,accessToken:n,stagingToken:t}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:n,stagingToken:t}}}}function K({cardId:e,accessToken:n,stagingToken:t}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:t}}}}var x;!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"}(x||(x={}));const j={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 H,Y;function z(e,n){const t=n.filter((n=>n.requiredIfPresent?!e[n.name]&&e[n.requiredIfPresent]:void 0===e[n.name])).map((e=>e.name));if(t.length>0)throw new s(t.map((e=>`Missing required parameter: ${e}`)))}function V(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function W(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function X(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"}(H||(H={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(Y||(Y={}));const Q=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],J=[...Q,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function Z(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return z(e,Q),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(l),g=V({membershipId:n,organizationId:t,bankAccountId:i}),p=W({hasDailyLimit:a,hasTransactionLimit:r}),h=X({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=ee(u),T=ne(m),_=[...f,...g,...p,...h,...y,...T];if(_.length>0)throw new s(_)}(e),e}(e):function(e){z(e,J),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:y,hasAtmDailyLimit:T,atmDailyLimit:_,atmMonthlyLimit:I,address:b,cardDesign:w,typeOfPrint:k}=e,E=function(e){return Object.values(Y).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(l),A=function(e){const n=null!=e&&"string"!=typeof e,t=!["print","embossed",void 0,null].includes(e);return n||t?['typeOfPrint must be one of "print", "embossed" or null']:[]}(k),R=V({membershipId:n,organizationId:t,bankAccountId:i}),S=W({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:T,shipToBusiness:h}),v=X({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:I}),L=ee(u),P=ne(m),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(w),O=function(e,n){if(n)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(b,h),N=[...E,...R,...S,...v,...L,...P,...A,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function ee(e){const n=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&n?["activeDays must be an array of integers between 1 and 7"]:[]}function ne(e){const n=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&n?["categories must be an array of strings"]:[]}class te extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ie=[];for(let e=0;e<256;++e)ie.push((e+256).toString(16).slice(1));let ae;const re=new Uint8Array(16);var se={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function oe(e,n,t){if(se.randomUUID&&!e)return se.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!ae){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ae=crypto.getRandomValues.bind(crypto)}return ae(re)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(ie[e[n+0]]+ie[e[n+1]]+ie[e[n+2]]+ie[e[n+3]]+"-"+ie[e[n+4]]+ie[e[n+5]]+"-"+ie[e[n+6]]+ie[e[n+7]]+"-"+ie[e[n+8]]+ie[e[n+9]]+"-"+ie[e[n+10]]+ie[e[n+11]]+ie[e[n+12]]+ie[e[n+13]]+ie[e[n+14]]+ie[e[n+15]]).toLowerCase()}(i)}function ce({actionId:e,actionData:n}){const t=h.getMFAPreference();return{actionId:e,actionData:{...n,scaPreference:n.scaPreference||t,idempotencyKey:n.idempotencyKey||oe()}}}class de{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const n=new URL(e.iframeUrl);this.targetOrigin=`${n.protocol}//${n.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new te(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,n)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const t=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),n(new te(`Could not install the authentication UI because the timeout of ${t}ms was reached.\nPlease make sure the application can reach the Internet.`))}),t),a=n=>{n.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new te("Attempted to perform an Embed operation without having the authentication UI initialized."));const n=ce(e);return new Promise(((e,t)=>{const i=a=>{if(a.data?.actionId===n.actionId){if("error"===a.data.status)return this.removeMessageListener(n.actionId,i),t(new te(`An error occurred when performing the action ${n.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(n.actionId,i),e(a.data.payload)}};this.addMessageListener(n.actionId,i),this.iframe?.contentWindow?.postMessage(n,this.targetOrigin)}))}addMessageListener(e,n){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(n),window.addEventListener("message",n)}removeMessageListener(e,n){const t=this.messageListeners.get(e);if(t){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),window.removeEventListener("message",n))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function ue({accessToken:e,stagingToken:n,locale:t,debugMode:i}){const a=i||!1,r=t||L.getLocale(),s=w.getEnvironmentUrls().IFRAME_URL,o=n?`;staging_token=${encodeURIComponent(n)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function me({parentElementId:e,iframeUrl:n}){return new de({parentElementId:e,iframeUrl:n}).initialize()}function le(e){return"virtual"===e.cardLevel?function(e){const n=ge(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:oe(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel}}}}}(e):function(e){const n=ge(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:oe(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function fe(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 ge(e){const n=Object.values(j);return(e||[]).filter((e=>n.includes(e)))}const pe={getCards:async function(e){try{const n=e?.cardSettings?.membershipId;if(n&&"string"!=typeof n)throw new s("membershipId must be a string");const{proxyRequestFunction:t,stagingToken:i}=E(e?.operationSettings||{});if(t){const e=q(G({membershipId:n,stagingToken:i})),a=await t(e);return B(a).body.cards.map((e=>fe(e)))}{const t=e?.operationSettings?.accessToken||r(),a=await async function({membershipId:e,accessToken:n,stagingToken:t}){const i=G({membershipId:e,accessToken:n,stagingToken:t}),{cards:a}=await F(i);return a}({membershipId:n,accessToken:t,stagingToken:i});return a.map((e=>fe(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:n}){try{!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId parameter is required for the called function");const n=V({cardId:e.cardId});if(n.length>0)throw new s(n)}(e);const t=e.cardId,{proxyRequestFunction:i,stagingToken:a}=E(n||{});if(i){const e=q(K({cardId:t,stagingToken:a})),n=await i(e),r=B(n).body.cards;if(Array.isArray(r)&&r.length>0)return fe(r[0]);throw new s("Unable to retrieve card data")}{const e=n?.accessToken||r(),i=await async function({cardId:e,accessToken:n,stagingToken:t}){const i=K({cardId:e,accessToken:n,stagingToken:t}),{cards:a}=await F(i);return a[0]}({cardId:t,accessToken:e,stagingToken:a});return fe(i)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});Z(e.cardSettings);const s=ue({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),o=await me({iframeUrl:s,parentElementId:i}),c=le(e.cardSettings),d=await o.postMessage(c);return o.destroy(),fe(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=V({cardId:e.cardId});if(n.length>0)throw new s(n)}(e.cardSettings);const o=ue({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),d=await me({iframeUrl:o,parentElementId:i}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),m=await d.postMessage(u);return d.destroy(),fe(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:n,accessToken:t,stagingToken:i,debugMode:a,mfaPreference:o}=E(e.operationSettings,{requiresUI:!0}),c=t||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=V({cardId:e.cardId});if(n.length>0)throw new s(n);let t={};void 0!==e.allowPinReveal&&(t={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(t={...t,allowBlocking:e.allowBlocking});const i=W(t);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:n,stagingToken:t,mfaPreference:i}=e,a={method:"GET",headers:$({accessToken:n,stagingToken:t,mfaPreference:i})},r=w.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(!s.ok)throw o.errors?new U(o.errors.map((e=>`${e.code}: ${e.detail}`))):new U(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:u,allowBlocking:m}=e.cardSettings,l=function(e,n){const t=new URL(e);return"boolean"==typeof n.allowPinReveal&&t.searchParams.set("canSeePin",n.allowPinReveal.toString()),"boolean"==typeof n.allowBlocking&&t.searchParams.set("canBlock",n.allowBlocking.toString()),!0===n.debugMode&&t.searchParams.set("debug",n.debugMode.toString()),t.toString()}(d,{allowPinReveal:u,allowBlocking:m,debugMode:a}),f=await me({iframeUrl:l,parentElementId:n});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},he=pe;function ye(e){const n=new URLSearchParams;return e?.page&&n.append("page",e.page.toString()),e?.itemsPerPage&&n.append("per_page",e.itemsPerPage.toString()),n}function Te({endpointUrl:e,paginationSettings:n}){return function({url:e,searchParams:n}){const t=new URL(e.toString());for(const[e,i]of n.entries())t.searchParams.append(e,i);return t}({url:new URL(e),searchParams:ye(n)})}function _e(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 Ie(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 be(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 we="/v2/sepa/beneficiaries";function ke({paginationSettings:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:{accessToken:n,stagingToken:t}},a=ye(e),r=a.size?`?${a.toString()}`:"";return{path:`${we}${r}`,options:i}}function Ee({beneficiaryId:e,accessToken:n,stagingToken:t}){return{path:`${we}/${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:t}}}}async function Ae({accessToken:e,stagingToken:n,beneficiaryId:t}){const i=Ee({beneficiaryId:t,accessToken:e,stagingToken:n}),{beneficiary:a}=await F(i);return a}function Re({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i=oe()}){return{path:we,options:{method:"POST",headers:{accessToken:n,stagingToken:t,idempotencyKey:i},body:{beneficiary:be(e)}}}}function Se({beneficiaryIds:e,accessToken:n,stagingToken:t}){return{path:`${we}/untrust`,options:{method:"PATCH",headers:{accessToken:n,stagingToken:t},body:{ids:e}}}}function ve({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${we}/${e.id}`,options:c}}const Le=[{name:"name"},{name:"iban"}];const Pe={getBeneficiaries:async function(e){const{stagingToken:n,proxyRequestFunction:t,accessToken:i,paginationSettings:a}=E(e?.operationSettings||{});if(t){const e=q(ke({paginationSettings:a})),n=B(await t(e)),i=n.body.beneficiaries.map((e=>Ie(e))),r=_e(n.body.meta);return{beneficiaries:i,...r?{meta:r}:{}}}{const e=i||r(),t=await async function({paginationSettings:e,accessToken:n,stagingToken:t}){const i=ke({paginationSettings:e,accessToken:n,stagingToken:t}),{beneficiaries:a,meta:r}=await F(i);return{beneficiaries:a,meta:r}}({accessToken:e,stagingToken:n,paginationSettings:a}),s=t.beneficiaries.map((e=>Ie(e))),o=_e(t.meta);return{beneficiaries:s,...o?{meta:o}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=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");return e}(e?.beneficiaryId),{proxyRequestFunction:i,accessToken:a,stagingToken:o}=E(n||{});if(i){const e=q(Ee({beneficiaryId:t}));return Ie(B(await i(e)).body.beneficiary)}{const e=a||r();return Ie(await Ae({beneficiaryId:t,accessToken:e,stagingToken:o}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=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");z(e,Le);const n=V({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(n.length>0)throw new s(n);return e}(e),{proxyRequestFunction:i,accessToken:a,stagingToken:o,idempotencyKey:c}=E(n||{});if(i){const e=q(Re({beneficiary:t,idempotencyKey:c}));return Ie(B(await i(e)).body.beneficiary)}{const e=a||r(),n=await async function({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i=oe()}){const a=Re({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i}),{beneficiary:r}=await F(a);return r}({beneficiary:t,accessToken:e,stagingToken:o,idempotencyKey:c});return Ie(n)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){const{id:n,name:t,email:i,activityTag:a}=e||{};if(!n)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!t&&!i&&!a)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=V({name:t,email:i,activityTag:a});if(r.length>0)throw new s(r);return{id:n,name:t,email:i,activityTag:a}}(e),{stagingToken:i,idempotencyKey:a,mfaPreference:o,proxyRequestFunction:c}=E(n),d={beneficiaryParamsBeingEdited:t,idempotencyKey:a,mfaPreference:o};if(c){const e=q(ve(d));return Ie(B(await c(e)).body.beneficiary)}{const e=n?.accessToken||r(),t=await async function({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=ve({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}),{beneficiary:s}=await F(r);return s}({...d,accessToken:e,stagingToken:i});return Ie(t)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:i,accessToken:a,stagingToken:o}=E(n||{});if(i){const e=q(Se({beneficiaryIds:t}));return B(await i(e)).body.beneficiaries.map(Ie)}{const e=a||r(),n=await async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i=Se({beneficiaryIds:e,accessToken:n,stagingToken:t}),{beneficiaries:a}=await F(i);return a}({beneficiaryIds:t,accessToken:e,stagingToken:o});return n.map(Ie)}}},De=Pe;function Oe(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}const Ne="/v2/sepa/bulk_transfers";function Ue(e){if(!e)throw new s("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new s("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new s("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new s("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,n)=>{!function(e,n){if(!e)throw new s(`Invalid bulkTransfer at index ${n}: bulkTransfer object is required`);if(!e.beneficiaryId&&!e.beneficiary)throw new s(`Invalid bulkTransfer at index ${n}: Either beneficiaryId for an existing beneficiary or beneficiary details must be provided`);if(e.beneficiaryId&&e.beneficiary)throw new s(`Invalid bulkTransfer at index ${n}: Provide either beneficiaryId for an existing beneficiary or beneficiary details to create/update one, not both`);if(e.beneficiary){if(!e.beneficiary.iban)throw new s(`Invalid bulkTransfer at index ${n}: IBAN is required when providing beneficiary details`);if(!e.beneficiary.name)throw new s(`Invalid bulkTransfer at index ${n}: Beneficiary name is required when providing beneficiary details`)}const t=V({beneficiaryId:e.beneficiaryId,reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),i=X({amount:e.amount}),a=[...t,...i].flat();if(a.length>0)throw new s(a);if(e.amount>f&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new s(`Invalid bulkTransfer at index ${n}: Attachments are required for transfers over €30000`)}(e,n)})),e}const Ce="browser",Me="server";class $e extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ce:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case Me:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}function Fe(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 qe(e){const n=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:n,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}const Be="/v2/sepa/transfers";const Ge=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Ke({sepaTransferSettings:e,operationSettings:n}){if(e?.beneficiary)return e.beneficiary;return Ie(await Ae({beneficiaryId:e?.beneficiaryId,accessToken:n?.accessToken,stagingToken:n?.stagingToken}))}const xe={getSepaTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),i=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=Te({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Be}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new U("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),a=i.transfers.map(Fe),s=_e(i.meta);return{transfers:a,...s?{meta:s}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);return Fe(await async function({accessToken:e,stagingToken:n,sepaTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Be}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.transfer}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),o=n?.idempotencyKey||oe();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(z(e,Ge),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const n=[...V({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...X({amount:e.amount})].flat();if(n.length>0)throw new s(n);if(e.amount>f&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u={...e,beneficiary:await Ke({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(u.beneficiary?.trusted)d=await async function({transfer:e,accessToken:n,stagingToken:t,idempotencyKey:i}){const a=qe(e),r={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Be}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new U(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:u,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if(!C())throw new $e(Ce);const{uiParentElementId:e,debugMode:t}=E(n,{requiresUI:!0});let r;try{const n=ue({accessToken:i,stagingToken:a||void 0,debugMode:t});r=await me({iframeUrl:n,parentElementId:e});const s=qe(u);d=await r.postMessage(ce({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}}))}finally{r?.destroy()}}return Fe(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Be}/${e}/cancel`,r=await fetch(a,i);if(204!==r.status){const e=await r.json();if(e.errors)throw new U(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken})},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),{stagingToken:i,paginationSettings:a}=E(n||{}),s=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=Te({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ne}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new U("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:t,stagingToken:i,paginationSettings:a}),o=s.bulkTransfers?.map(Oe),c=_e(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),{stagingToken:i}=E(n||{}),a=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Oe(await async function({accessToken:e,stagingToken:n,bulkTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ne}/${t}`),r=await fetch(a,i),s=await r.json();if(s.errors)throw new U(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:t,stagingToken:i,bulkTransferId:a}))},createBulkTransfer:async function({bulkTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),s=n?.idempotencyKey||oe();if(Ue(e),!C())throw new $e(Ce);const{uiParentElementId:o,debugMode:d}=E(n,{requiresUI:!0});let u,m;try{const n=ue({accessToken:i,stagingToken:a||void 0,debugMode:d});m=await me({iframeUrl:n,parentElementId:o});const t={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};u=await m.postMessage(ce({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:t,idempotencyKey:s}}))}finally{m?.destroy()}return Oe(u)}}},je={GOOD:"good",SERVICE:"service"},He={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},Ye=e=>{if(!(e=>Object.values(He).includes(e))(e))throw new s(`currency ${e} is not valid, valid currencies are ${Object.values(He).join(", ")}`)},ze={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},Ve=e=>{if(!(e=>Object.values(ze).includes(e))(e))throw new s(`unit ${e} is not valid, valid units are ${Object.values(ze).join(", ")}`)},We=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],Xe=[{name:"currency"},{name:"value"}];const Qe=e=>{if(!Object.values(je).includes(e))throw new s(`type ${e} is not valid, valid types are ${Object.values(je).join(", ")}`)},Je={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e,operationSettings:n})=>{const{items:t,redirectUrl:i}=e,a=n?.accessToken||r();!function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{z(e,We),z(e.unitPrice,Xe);const n=[...V({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...X({quantity:e.quantity})].flat();if(n.length>0)throw new s(n);Qe(e.type),Ye(e.unitPrice.currency),Ve(e.measureUnit)}))}(t),function(e){if(!e)throw new s("redirectUrl is required for the called function");const n=V({redirectUrl:e});if(n.length>0)throw new s(n);try{new URL(e)}catch{throw new s("redirectUrl is not a valid URL")}}(i);return`${w.getEnvironmentUrls().IFRAME_BASE_URL+"/payment-links/creation-flow/products-and-services"}#access_token=${a}?${new URLSearchParams({...t?{items:JSON.stringify(t)}:{},redirectUrl:i}).toString()}`}},Ze=({accessToken:e,stagingToken:n})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:e,stagingToken:n}}}),en=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),nn={getBankAccounts:async e=>{const{stagingToken:n,proxyRequestFunction:t}=E(e);if(t){const e=Ze({stagingToken:n}),i=await t(q(e)),{body:a}=B(i);return a.bank_accounts.map(en)}{const t=e.accessToken||r(),i=await(async({accessToken:e,stagingToken:n})=>{const t=Ze({accessToken:e,stagingToken:n});return await F(t)})({accessToken:t,stagingToken:n});return i.bank_accounts.map(en)}}};e.beneficiaries=De,e.cards=he,e.constants=N,e.initialize=D,e.logout=O,e.organizations=nn,e.paymentLinks=Je,e.sepaTransfers=xe}));
@@ -1,6 +1,7 @@
1
1
  import type { Beneficiary, BeneficiaryDataObject } from '@beneficiaries/beneficiaries.types';
2
2
  import type { SepaTransferDataObject } from '@sepa-transfers/sepa-transfers.types';
3
3
  import type { BulkTransferDataObject, NewBulkTransfer, BulkTransferSettings } from '@sepa-transfers/bulk-transfers/bulk-transfers.types';
4
+ import type { CardDataObject } from '@cards/cards.types';
4
5
  export declare const INVALID_ACCESS_TOKEN = "INVALID_ACCESS_TOKEN";
5
6
  export declare const singleBeneficiary: BeneficiaryDataObject;
6
7
  export declare const newBeneficiaryDbFields: {
@@ -17,6 +18,7 @@ export declare const mockListOfSepaTransferDataObjects: SepaTransferDataObject[]
17
18
  export declare const mockBulkTransferDataObject: BulkTransferDataObject;
18
19
  export declare const mockListOfBulkTransferDataObjects: BulkTransferDataObject[];
19
20
  export declare const mockDisplayCardIframeUrl = "https://example.com/card-iframe#access_token=any_valid_token";
21
+ export declare const mockCardData: CardDataObject;
20
22
  export declare const mockBulkTransferValidBankAccountId = "bank_1";
21
23
  export declare const mockUntrustedBeneficiary: Beneficiary;
22
24
  export declare const mockValidTrustedTransfer: NewBulkTransfer;
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EACV,sBAAsB,EAGtB,eAAe,EACf,oBAAoB,EACrB,MAAM,qDAAqD,CAAC;AAG7D,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAkBpC,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,EAqBrE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,sBAqBxC,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,EAoBrE,CAAC;AAEF,eAAO,MAAM,wBAAwB,iEAC2B,CAAC;AAGjE,eAAO,MAAM,kCAAkC,WAAW,CAAC;AAE3D,eAAO,MAAM,wBAAwB,EAAE,WAYtC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAKtC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,eAKnC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,oBAAoB,CAAC,eAAe,CAI7E,CAAC;AAEJ,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;CAiB1C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;CAiB7C,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;CAuBzC,CAAC;AAEF,eAAO,MAAM,WAAW,6BAmcvB,CAAC"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EACV,sBAAsB,EAGtB,eAAe,EACf,oBAAoB,EACrB,MAAM,qDAAqD,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAOzD,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAkBpC,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,EAqBrE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,sBAqBxC,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,EAoBrE,CAAC;AAEF,eAAO,MAAM,wBAAwB,iEAC2B,CAAC;AAEjE,eAAO,MAAM,YAAY,EAAE,cAuD1B,CAAC;AAGF,eAAO,MAAM,kCAAkC,WAAW,CAAC;AAE3D,eAAO,MAAM,wBAAwB,EAAE,WAYtC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAKtC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,eAKnC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,oBAAoB,CAAC,eAAe,CAI7E,CAAC;AAEJ,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;CAiB1C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;CAiB7C,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;CAuBzC,CAAC;AAEF,eAAO,MAAM,WAAW,6BA2YvB,CAAC"}
@@ -1,20 +1,12 @@
1
1
  /**
2
- * The organizations namespace contains all the functions related to organizations
3
- * operations. It can be accessed like this:
2
+ * The organizations namespace contains all the functions related to organizations'
3
+ * operations such as retrieving bank accounts. It can be accessed like this:
4
4
  * ```ts
5
5
  * import { organizations } from '@qonto/embed-sdk/organizations';
6
- * ```
7
- *
8
- * Then, the organizations object contains the functions to perform organizations
9
- * operations:
10
- * ```ts
11
6
  * await organizations.getBankAccounts({accessToken, stagingToken});
12
7
  * ```
13
8
  */
14
9
  export declare const organizations: {
15
- getBankAccounts: (params: {
16
- accessToken?: string;
17
- stagingToken?: string;
18
- }) => Promise<import("./organizations.types").BankAccount[]>;
10
+ getBankAccounts: (operationSettings: import("../validation/operation-settings-validation").OperationSettings) => Promise<import("./organizations.types").BankAccount[]>;
19
11
  };
20
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/organizations/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa;;mBAhBrB,CAAC;oBAAwB,CAAC;;CAgBkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/organizations/index.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;CAAuC,CAAC"}
@@ -1,4 +1,9 @@
1
+ import { type NetworkCallDescriptor } from '@common/network/network';
1
2
  import type { OrganizationDataObject } from './organizations.types';
3
+ export declare const prepareGetOrganization: ({ accessToken, stagingToken, }: {
4
+ accessToken?: string;
5
+ stagingToken?: string;
6
+ }) => NetworkCallDescriptor;
2
7
  export declare const getOrganization: ({ accessToken, stagingToken, }: {
3
8
  accessToken: string;
4
9
  stagingToken?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.api.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAMpE,eAAO,MAAM,eAAe,GAAU,gCAGnC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,OAAO,CAAC,sBAAsB,CAyBjC,CAAC"}
1
+ {"version":3,"file":"organizations.api.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAIpE,eAAO,MAAM,sBAAsB,GAAI,gCAGpC;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,qBAYH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,gCAGnC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,OAAO,CAAC,sBAAsB,CAQjC,CAAC"}
@@ -1,6 +1,13 @@
1
1
  import type { BankAccount } from './organizations.types';
2
- export declare const getBankAccounts: (params: {
3
- accessToken?: string;
4
- stagingToken?: string;
5
- }) => Promise<BankAccount[]>;
2
+ import { type OperationSettings } from '@validation/operation-settings-validation';
3
+ /**
4
+ * Retrieves the bank accounts for the organization.
5
+ *
6
+ * @param operationSettings - An object with operation-level settings such as
7
+ * `accessToken`, `stagingToken`, `proxyRequestFunction`, and other optional
8
+ * parameters. See {@link OperationSettings} for more details.
9
+ * @returns A promise that resolves to the bank accounts for the organization.
10
+ * @throws EmbedApiError If the API request fails or returns an error.
11
+ */
12
+ export declare const getBankAccounts: (operationSettings: OperationSettings) => Promise<BankAccount[]>;
6
13
  //# sourceMappingURL=organizations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,eAAO,MAAM,eAAe,EAAE,CAAC,MAAM,EAAE;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAK,OAAO,CAAC,WAAW,EAAE,CAa1B,CAAC"}
1
+ {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,2CAA2C,CAAC;AAMnD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,EAAE,CAC5B,iBAAiB,EAAE,iBAAiB,KACjC,OAAO,CAAC,WAAW,EAAE,CAuBzB,CAAC"}
@@ -1,8 +1,5 @@
1
1
  declare const organizations: {
2
- getBankAccounts: (params: {
3
- accessToken?: string;
4
- stagingToken?: string;
5
- }) => Promise<import("./organizations.types").BankAccount[]>;
2
+ getBankAccounts: (operationSettings: import("../validation/operation-settings-validation").OperationSettings) => Promise<import("./organizations.types").BankAccount[]>;
6
3
  };
7
4
  export { organizations };
8
5
  //# sourceMappingURL=organizations.public-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.public-api.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.public-api.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,aAAa;;mBAKuJ,CAAC;oBAAwB,CAAC;;CAHnM,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"organizations.public-api.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.public-api.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,aAAa;;CAElB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -13,17 +13,53 @@ export type BankAccountDataObject = {
13
13
  main: boolean;
14
14
  };
15
15
  export type BankAccount = {
16
+ /**
17
+ * The slug of the bank account is a string that uniquely identifies the bank account.
18
+ */
16
19
  slug: string;
20
+ /**
21
+ * The IBAN of the bank account is the International Bank Account Number, which can be used to identify the bank account when making or receiving international payments.
22
+ */
17
23
  iban: string;
24
+ /**
25
+ * The BIC of the bank account is the Bank Identifier Code, which can be used to identify a specific bank when making or receiving international payments.
26
+ */
18
27
  bic: string;
28
+ /**
29
+ * The currency of the bank account is a string that represents the currency of the bank account.
30
+ */
19
31
  currency: string;
32
+ /**
33
+ * The balance of the bank account is a number that represents the balance of the bank account in the currency of the bank account.
34
+ */
20
35
  balance: number;
36
+ /**
37
+ * The balance in cents of the bank account is a number that represents the balance of the bank account in cents.
38
+ */
21
39
  balanceCents: number;
40
+ /**
41
+ * The authorized balance of the bank account is a number that represents the authorized balance in the currency of the bank account.
42
+ */
22
43
  authorizedBalance: number;
44
+ /**
45
+ * The authorized balance in cents of the bank account is a number that represents the authorized balance in cents.
46
+ */
23
47
  authorizedBalanceCents: number;
48
+ /**
49
+ * The user-friendly name of the bank account.
50
+ */
24
51
  name: string;
52
+ /**
53
+ * The date and time the bank account was last updated.
54
+ */
25
55
  updatedAt: Date;
56
+ /**
57
+ * The status of the bank account. Ex: 'active', 'waiting_for_funds', 'closed', 'pending'.
58
+ */
26
59
  status: (typeof ACCOUNT_STATUS)[keyof typeof ACCOUNT_STATUS];
60
+ /**
61
+ * Whether the bank account is the main bank account of the organization.
62
+ */
27
63
  main: boolean;
28
64
  };
29
65
  export declare const ACCOUNT_STATUS: {
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.types.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC,CAAC"}
1
+ {"version":3,"file":"organizations.types.d.ts","sourceRoot":"","sources":["../../src/organizations/organizations.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;IAC7D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC,CAAC"}
@@ -1,13 +1,8 @@
1
1
  /**
2
2
  * The paymentLinks namespace contains all the functions related to paymentLinks
3
- * operations. It can be accessed like this:
3
+ * operations such as starting the payment link creation flow. It can be accessed like this:
4
4
  * ```ts
5
5
  * import { paymentLinks } from '@qonto/embed-sdk/paymentLinks';
6
- * ```
7
- *
8
- * Then, the paymentLinks object contains the functions to perform paymentLinks
9
- * operations:
10
- * ```ts
11
6
  * const url = paymentLinks.getPaymentLinkCreationFlowUrl({accessToken, items, redirectUrl});
12
7
  * window.open(url, '_blank');
13
8
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment-links/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY;;CAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment-links/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;CAAqC,CAAC"}
@@ -1 +1 @@
1
- import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as r}from"../common/environment/environment-manager.js";import{buildRequestHeaders as n}from"../common/network/network.js";async function o({membershipId:o,accessToken:a,stagingToken:s}){const t={method:"GET",headers:n({accessToken:a,stagingToken:s})},c=r.getEnvironmentUrls().THIRD_PARTY_API_URL,i=o?`${c}/v2/cards?holder_ids[]=${o}`:`${c}/v2/cards`,d=await fetch(i,t),m=await d.json();if(m.errors)throw new e(m.errors.map((e=>`${e.code}: ${e.detail}`)));return m.cards}async function a({cardId:o,accessToken:a,stagingToken:s}){const t={method:"GET",headers:n({accessToken:a,stagingToken:s})},c=`${r.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${o}`,i=await fetch(c,t),d=await i.json();if(d.errors)throw new e(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.cards[0]}async function s(o){const{accessToken:a,stagingToken:s,mfaPreference:t}=o,c={method:"GET",headers:n({accessToken:a,stagingToken:s,mfaPreference:t})},i=r.getEnvironmentUrls().THIRD_PARTY_API_URL,d=await fetch(`${i}/v2/cards/${o.cardId}/data_view`,c),m=await d.json();if(!d.ok)throw m.errors?new e(m.errors.map((e=>`${e.code}: ${e.detail}`))):new e(`${m.code}: ${m.detail}`);return m.iframe_url}export{a as getCard,s as getCardIframeURL,o as getCards};
1
+ import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{buildRequestHeaders as o,makeNetworkCall as r}from"../common/network/network.js";function s({membershipId:e,accessToken:n,stagingToken:o}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}}async function a({membershipId:e,accessToken:n,stagingToken:o}){const a=s({membershipId:e,accessToken:n,stagingToken:o}),{cards:t}=await r(a);return t}function t({cardId:e,accessToken:n,stagingToken:o}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}}async function c({cardId:e,accessToken:n,stagingToken:o}){const s=t({cardId:e,accessToken:n,stagingToken:o}),{cards:a}=await r(s);return a[0]}async function i(r){const{accessToken:s,stagingToken:a,mfaPreference:t}=r,c={method:"GET",headers:o({accessToken:s,stagingToken:a,mfaPreference:t})},i=n.getEnvironmentUrls().THIRD_PARTY_API_URL,d=await fetch(`${i}/v2/cards/${r.cardId}/data_view`,c),m=await d.json();if(!d.ok)throw m.errors?new e(m.errors.map((e=>`${e.code}: ${e.detail}`))):new e(`${m.code}: ${m.detail}`);return m.iframe_url}export{c as getCard,i as getCardIframeURL,a as getCards,t as prepareGetCardCall,s as prepareGetCardsCall};
@@ -1 +1 @@
1
- import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{getCardIframeURL as r,getCard as a,getCards as n}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as s,validateUnlockCardParams as o,validateOrderCardParams as i}from"./cards.validate.js";import{createIframe as c,buildIframeUrl as m}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as d,serializeCard as g,serializeOrderCardPayload as u}from"./cards.serializer.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{InvalidParametersError as l}from"../errors/InvalidParametersError.js";import{getPopulatedIframeURL as f}from"./cards.helper.js";async function k({membershipId:e,accessToken:r,stagingToken:a}){try{const s=r||t();if(e&&"string"!=typeof e)throw new l("membershipId must be a string");return(await n({membershipId:e,accessToken:s,stagingToken:a})).map((e=>g(e)))}catch(e){return Promise.reject(e)}}async function T({cardId:e,accessToken:r,stagingToken:n}){try{const s=r||t();if(e&&"string"!=typeof e)throw new l("cardId must be a string");const o=await a({cardId:e,accessToken:s,stagingToken:n});return g(o)}catch(e){return Promise.reject(e)}}async function y(r){try{const a=t(),{uiParentElementId:n,debugMode:s}=p(r.operationSettings,{requiresUI:!0});i(r.cardSettings);const o=m({accessToken:a,stagingToken:e.getStagingToken()||void 0,debugMode:s}),d=await c({iframeUrl:o,parentElementId:n}),l=u(r.cardSettings),f=await d.postMessage(l);return d.destroy(),g(f)}catch(e){return Promise.reject(e)}}async function I(r){try{const a=t(),{uiParentElementId:n,debugMode:s}=p(r.operationSettings,{requiresUI:!0});o(r.cardSettings);const i=m({accessToken:a,stagingToken:e.getStagingToken()||void 0,debugMode:s}),u=await c({iframeUrl:i,parentElementId:n}),l=d(r),f=await u.postMessage(l);return u.destroy(),g(f)}catch(e){return Promise.reject(e)}}async function w(e){try{const{uiParentElementId:a,accessToken:n,stagingToken:o,debugMode:i,mfaPreference:m}=p(e.operationSettings,{requiresUI:!0}),d=n||t();s(e.cardSettings);const g=await r({...e.cardSettings,accessToken:d,stagingToken:o,mfaPreference:m}),{allowPinReveal:u,allowBlocking:l}=e.cardSettings,k=f(g,{allowPinReveal:u,allowBlocking:l,debugMode:i}),T=await c({iframeUrl:k,parentElementId:a});return{destroyEmbedUI:()=>{T.destroy()}}}catch(e){return Promise.reject(e)}}export{w as displayCard,T as getCard,k as getCards,y as orderCard,I as unlockCard};
1
+ import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{encodeNetworkCall as r,decodeNetworkResponse as n}from"../common/network/network.js";import{getCardIframeURL as a,prepareGetCardCall as o,getCard as s,prepareGetCardsCall as i,getCards as c}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as d,validateUnlockCardParams as m,validateOrderCardParams as g,validateGetCardParams as u}from"./cards.validate.js";import{createIframe as p,buildIframeUrl as l}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as f,serializeCard as k,serializeOrderCardPayload as y}from"./cards.serializer.js";import{validateOperationSettingsParams as w}from"../validation/operation-settings-validation.js";import{InvalidParametersError as T}from"../errors/InvalidParametersError.js";import{getPopulatedIframeURL as I}from"./cards.helper.js";async function h(e){try{const a=e?.cardSettings?.membershipId;if(a&&"string"!=typeof a)throw new T("membershipId must be a string");const{proxyRequestFunction:o,stagingToken:s}=w(e?.operationSettings||{});if(o){const e=i({membershipId:a,stagingToken:s}),t=r(e),c=await o(t);return n(c).body.cards.map((e=>k(e)))}{const r=e?.operationSettings?.accessToken||t();return(await c({membershipId:a,accessToken:r,stagingToken:s})).map((e=>k(e)))}}catch(e){return Promise.reject(e)}}async function j({cardSettings:e,operationSettings:a}){try{u(e);const i=e.cardId,{proxyRequestFunction:c,stagingToken:d}=w(a||{});if(c){const e=o({cardId:i,stagingToken:d}),t=r(e),a=await c(t),s=n(a).body.cards;if(Array.isArray(s)&&s.length>0)return k(s[0]);throw new T("Unable to retrieve card data")}{const e=a?.accessToken||t(),r=await s({cardId:i,accessToken:e,stagingToken:d});return k(r)}}catch(e){return Promise.reject(e)}}async function S(r){try{const n=t(),{uiParentElementId:a,debugMode:o}=w(r.operationSettings,{requiresUI:!0});g(r.cardSettings);const s=l({accessToken:n,stagingToken:e.getStagingToken()||void 0,debugMode:o}),i=await p({iframeUrl:s,parentElementId:a}),c=y(r.cardSettings),d=await i.postMessage(c);return i.destroy(),k(d)}catch(e){return Promise.reject(e)}}async function b(r){try{const n=t(),{uiParentElementId:a,debugMode:o}=w(r.operationSettings,{requiresUI:!0});m(r.cardSettings);const s=l({accessToken:n,stagingToken:e.getStagingToken()||void 0,debugMode:o}),i=await p({iframeUrl:s,parentElementId:a}),c=f(r),d=await i.postMessage(c);return i.destroy(),k(d)}catch(e){return Promise.reject(e)}}async function P(e){try{const{uiParentElementId:r,accessToken:n,stagingToken:o,debugMode:s,mfaPreference:i}=w(e.operationSettings,{requiresUI:!0}),c=n||t();d(e.cardSettings);const m=await a({...e.cardSettings,accessToken:c,stagingToken:o,mfaPreference:i}),{allowPinReveal:g,allowBlocking:u}=e.cardSettings,l=I(m,{allowPinReveal:g,allowBlocking:u,debugMode:s}),f=await p({iframeUrl:l,parentElementId:r});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}export{P as displayCard,j as getCard,h as getCards,S as orderCard,b as unlockCard};
@@ -1 +1 @@
1
- import{PhysicalCardLevel as i}from"./cards.types.js";import{validateExpectedStringValues as t,validateExpectedBooleanValues as n,validatePresenceOfRequiredParams as e,validateExpectedNumericValues as a}from"../validation/input-param-validation.js";import{InvalidParametersError as r}from"../errors/InvalidParametersError.js";const o=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],s=[...o,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function m(m){if(!m)throw new r("cardSettings parameter is required for the called function");return"virtual"===m.cardLevel?function(i){return e(i,o),function(i){const{membershipId:e,organizationId:o,bankAccountId:s,hasDailyLimit:m,hasTransactionLimit:c,monthlyLimit:u,dailyLimit:h,transactionLimit:f,activeDays:y,categories:p,cardLevel:L}=i,g=function(i){return"virtual"!==i?['cardLevel must be "virtual"']:[]}(L),I=t({membershipId:e,organizationId:o,bankAccountId:s}),w=n({hasDailyLimit:m,hasTransactionLimit:c}),v=a({monthlyLimit:u,dailyLimit:h,transactionLimit:f}),b=d(y),A=l(p),D=[...g,...I,...w,...v,...b,...A];if(D.length>0)throw new r(D)}(i),i}(m):function(o){e(o,s),function(e){const{membershipId:o,organizationId:s,bankAccountId:m,hasDailyLimit:c,hasTransactionLimit:u,monthlyLimit:h,dailyLimit:f,transactionLimit:y,activeDays:p,categories:L,cardLevel:g,hasNfcOption:I,hasForeignPaymentOption:w,hasOnlinePaymentOption:v,shipToBusiness:b,hasAtmOption:A,hasAtmDailyLimit:D,atmDailyLimit:O,atmMonthlyLimit:P,address:k,cardDesign:q,typeOfPrint:z}=e,T=function(t){return Object.values(i).includes(t)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(g),B=function(i){const t=null!=i&&"string"!=typeof i,n=!["print","embossed",void 0,null].includes(i);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(z),N=t({membershipId:o,organizationId:s,bankAccountId:m}),j=n({hasDailyLimit:c,hasTransactionLimit:u,hasAtmOption:A,hasNfcOption:I,hasForeignPaymentOption:w,hasOnlinePaymentOption:v,hasAtmDailyLimit:D,shipToBusiness:b}),M=a({monthlyLimit:h,dailyLimit:f,transactionLimit:y,atmDailyLimit:O,atmMonthlyLimit:P}),R=d(p),S=l(L),C=function(i){return["undefined","string"].includes(typeof i)?[]:["cardDesign must be a string"]}(q),F=function(i,t){if(t)return[];return!i||i.contactName&&i.firstLine&&i.zipCode&&i.city&&i.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(k,b),x=[...T,...N,...j,...M,...R,...S,...B,...C,...F];if(x.length>0)throw new r(x)}(o)}(m)}function c(i){if(!i)throw new r("cardSettings parameter is required for the called function");if(!i.cardId)throw new r("cardId is required for the called function");const n=t({cardId:i.cardId});if(n.length>0)throw new r(n)}function d(i){const t=!Array.isArray(i)||!i.every((i=>Number.isInteger(i)&&i>0&&i<8));return void 0!==i&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function l(i){const t=!Array.isArray(i)||i.some((i=>"string"!=typeof i));return void 0!==i&&t?["categories must be an array of strings"]:[]}function u(i){if(!i)throw new r("cardSettings parameter is required for the called function");if(!i.cardId)throw new r("cardId is required for the called function");const e=t({cardId:i.cardId});if(e.length>0)throw new r(e);let a={};void 0!==i.allowPinReveal&&(a={allowPinReveal:i.allowPinReveal}),void 0!==i.allowBlocking&&(a={...a,allowBlocking:i.allowBlocking});const o=n(a);if(o.length>0)throw new r(o);return i}export{u as validateDisplayCardParams,m as validateOrderCardParams,c as validateUnlockCardParams};
1
+ import{PhysicalCardLevel as i}from"./cards.types.js";import{validateExpectedStringValues as t,validateExpectedBooleanValues as n,validatePresenceOfRequiredParams as e,validateExpectedNumericValues as a}from"../validation/input-param-validation.js";import{InvalidParametersError as r}from"../errors/InvalidParametersError.js";const o=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],s=[...o,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function c(c){if(!c)throw new r("cardSettings parameter is required for the called function");return"virtual"===c.cardLevel?function(i){return e(i,o),function(i){const{membershipId:e,organizationId:o,bankAccountId:s,hasDailyLimit:c,hasTransactionLimit:m,monthlyLimit:u,dailyLimit:h,transactionLimit:f,activeDays:y,categories:p,cardLevel:L}=i,w=function(i){return"virtual"!==i?['cardLevel must be "virtual"']:[]}(L),g=t({membershipId:e,organizationId:o,bankAccountId:s}),I=n({hasDailyLimit:c,hasTransactionLimit:m}),v=a({monthlyLimit:u,dailyLimit:h,transactionLimit:f}),b=d(y),A=l(p),D=[...w,...g,...I,...v,...b,...A];if(D.length>0)throw new r(D)}(i),i}(c):function(o){e(o,s),function(e){const{membershipId:o,organizationId:s,bankAccountId:c,hasDailyLimit:m,hasTransactionLimit:u,monthlyLimit:h,dailyLimit:f,transactionLimit:y,activeDays:p,categories:L,cardLevel:w,hasNfcOption:g,hasForeignPaymentOption:I,hasOnlinePaymentOption:v,shipToBusiness:b,hasAtmOption:A,hasAtmDailyLimit:D,atmDailyLimit:O,atmMonthlyLimit:P,address:q,cardDesign:k,typeOfPrint:z}=e,T=function(t){return Object.values(i).includes(t)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(w),B=function(i){const t=null!=i&&"string"!=typeof i,n=!["print","embossed",void 0,null].includes(i);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(z),N=t({membershipId:o,organizationId:s,bankAccountId:c}),j=n({hasDailyLimit:m,hasTransactionLimit:u,hasAtmOption:A,hasNfcOption:g,hasForeignPaymentOption:I,hasOnlinePaymentOption:v,hasAtmDailyLimit:D,shipToBusiness:b}),S=a({monthlyLimit:h,dailyLimit:f,transactionLimit:y,atmDailyLimit:O,atmMonthlyLimit:P}),M=d(p),R=l(L),C=function(i){return["undefined","string"].includes(typeof i)?[]:["cardDesign must be a string"]}(k),F=function(i,t){if(t)return[];return!i||i.contactName&&i.firstLine&&i.zipCode&&i.city&&i.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(q,b),x=[...T,...N,...j,...S,...M,...R,...B,...C,...F];if(x.length>0)throw new r(x)}(o)}(c)}function m(i){if(!i)throw new r("cardSettings parameter is required for the called function");if(!i.cardId)throw new r("cardId is required for the called function");const n=t({cardId:i.cardId});if(n.length>0)throw new r(n)}function d(i){const t=!Array.isArray(i)||!i.every((i=>Number.isInteger(i)&&i>0&&i<8));return void 0!==i&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function l(i){const t=!Array.isArray(i)||i.some((i=>"string"!=typeof i));return void 0!==i&&t?["categories must be an array of strings"]:[]}function u(i){if(!i)throw new r("cardSettings parameter is required for the called function");if(!i.cardId)throw new r("cardId is required for the called function");const e=t({cardId:i.cardId});if(e.length>0)throw new r(e);let a={};void 0!==i.allowPinReveal&&(a={allowPinReveal:i.allowPinReveal}),void 0!==i.allowBlocking&&(a={...a,allowBlocking:i.allowBlocking});const o=n(a);if(o.length>0)throw new r(o);return i}function h(i){if(!i)throw new r("cardSettings parameter is required for the called function");if(!i.cardId)throw new r("cardId parameter is required for the called function");const n=t({cardId:i.cardId});if(n.length>0)throw new r(n);return i}export{u as validateDisplayCardParams,h as validateGetCardParams,c as validateOrderCardParams,m as validateUnlockCardParams};
package/dist/src/index.js CHANGED
@@ -1 +1 @@
1
- export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";export{sepaTransfers}from"./sepa-transfers/index.js";export{paymentLinks}from"./payment-links/payment-links.public-api.js";
1
+ export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";export{sepaTransfers}from"./sepa-transfers/index.js";export{paymentLinks}from"./payment-links/index.js";export{organizations}from"./organizations/index.js";
@@ -0,0 +1 @@
1
+ import{organizations as o}from"./organizations.public-api.js";const i=o;export{i as organizations};
@@ -0,0 +1 @@
1
+ import{makeNetworkCall as n}from"../common/network/network.js";const o=({accessToken:n,stagingToken:o})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}),e=async({accessToken:e,stagingToken:s})=>{const t=o({accessToken:e,stagingToken:s});return await n(t)};export{e as getOrganization,o as prepareGetOrganization};
@@ -0,0 +1 @@
1
+ import"../common/auth/auth.js";import{validatePresenceOfAuthToken as o}from"../common/auth/auth.validate.js";import{getOrganization as t,prepareGetOrganization as n}from"./organizations.api.js";import{serializeBankAccount as a}from"./organizations.serializer.js";import{validateOperationSettingsParams as i}from"../validation/operation-settings-validation.js";import{encodeNetworkCall as s,decodeNetworkResponse as r}from"../common/network/network.js";const e=async e=>{const{stagingToken:m,proxyRequestFunction:c}=i(e);if(c){const o=n({stagingToken:m}),t=await c(s(o)),{body:i}=r(t);return i.bank_accounts.map(a)}{const n=e.accessToken||o();return(await t({accessToken:n,stagingToken:m})).bank_accounts.map(a)}};export{e as getBankAccounts};
@@ -0,0 +1 @@
1
+ import{getBankAccounts as o}from"./organizations.js";const t={getBankAccounts:o};export{t as organizations};
@@ -0,0 +1 @@
1
+ const a=a=>({slug:a.slug,iban:a.iban,bic:a.bic,currency:a.currency,balance:a.balance,balanceCents:a.balance_cents,authorizedBalance:a.authorized_balance,authorizedBalanceCents:a.authorized_balance_cents,name:a.name,updatedAt:new Date(a.updated_at),status:a.status,main:a.main});export{a as serializeBankAccount};
@@ -0,0 +1 @@
1
+ import{paymentLinks as p}from"./payment-links.public-api.js";const i=p;export{i as paymentLinks};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {
@@ -52,7 +52,7 @@
52
52
  "build:watch": "rollup -c -w",
53
53
  "clean": "rm -rf dist",
54
54
  "commitlint": "commitlint --edit",
55
- "docs": "typedoc && node scripts/remove-mdx-extensions.js && node scripts/move-guides-to-docs.js",
55
+ "docs": "typedoc && node scripts/remove-mdx-extensions.js && node scripts/move-doc-pages-to-docs.js",
56
56
  "format:check": "prettier --check .",
57
57
  "format:fix": "prettier --write .",
58
58
  "lint": "eslint .",