@qonto/embed-sdk 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/beneficiaries/beneficiaries.d.ts +20 -12
  2. package/dist/beneficiaries/beneficiaries.d.ts.map +1 -1
  3. package/dist/cards/cards.d.ts +20 -14
  4. package/dist/cards/cards.d.ts.map +1 -1
  5. package/dist/cards/cards.serializer.d.ts +3 -1
  6. package/dist/cards/cards.serializer.d.ts.map +1 -1
  7. package/dist/cards/index.d.ts +1 -0
  8. package/dist/cards/index.d.ts.map +1 -1
  9. package/dist/common/constants.d.ts +44 -0
  10. package/dist/common/constants.d.ts.map +1 -1
  11. package/dist/common/environment/environment-manager.d.ts +5 -0
  12. package/dist/common/environment/environment-manager.d.ts.map +1 -1
  13. package/dist/common/initialize/initialize.d.ts +10 -3
  14. package/dist/common/initialize/initialize.d.ts.map +1 -1
  15. package/dist/common/initialize/initialize.validate.d.ts +1 -1
  16. package/dist/iframe/embed-iframe.d.ts +1 -1
  17. package/dist/iframe/embed-iframe.d.ts.map +1 -1
  18. package/dist/iframe/iframe-message-builder.d.ts +8 -0
  19. package/dist/iframe/iframe-message-builder.d.ts.map +1 -0
  20. package/dist/iframe/iframe.types.d.ts +6 -1
  21. package/dist/iframe/iframe.types.d.ts.map +1 -1
  22. package/dist/index.umd.js +1 -1
  23. package/dist/sepa-transfers/sepa-transfers.d.ts +7 -5
  24. package/dist/sepa-transfers/sepa-transfers.d.ts.map +1 -1
  25. package/dist/src/beneficiaries/beneficiaries.js +1 -1
  26. package/dist/src/cards/cards.serializer.js +1 -1
  27. package/dist/src/common/constants.js +1 -1
  28. package/dist/src/common/environment/environment-manager.js +1 -1
  29. package/dist/src/iframe/embed-iframe.js +1 -1
  30. package/dist/src/iframe/iframe-message-builder.js +1 -0
  31. package/dist/src/validation/operation-settings-validation.js +1 -1
  32. package/dist/validation/operation-settings-validation.d.ts.map +1 -1
  33. package/package.json +2 -2
@@ -39,12 +39,15 @@ export declare function getBeneficiaries(getBeneficiariesParams?: {
39
39
  }): Promise<GetBeneficiariesResponse>;
40
40
  /**
41
41
  * Fetches a single beneficiary of the current user by ID.
42
- * @param Object - An object with the beneficiaryId and the optional accessToken
43
- * and stagingToken properties.
42
+ * @param getBeneficiaryParams - An object containing the beneficiaryId and
43
+ * optional `accessToken` and `stagingToken` parameters. If the `accessToken` is
44
+ * not provided, the function will use the token previously passed to the
45
+ * initialize function. The `stagingToken` is optional but it has to be passed to
46
+ * use the SDK in staging environments (it will be ignored in production).
44
47
  * @returns A promise that resolves to a beneficiary.
45
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
46
- * Ensure initialize has been called before using this function if you are not
47
- * passing the access token.
48
+ * @throws \{AuthenticationError\} If the access token is invalid or missing. Ensure
49
+ * initialize has been called before using this function if you are not passing
50
+ * the access token.
48
51
  * @throws \{InvalidParametersError\} If the `beneficiaryId` parameter is not a
49
52
  * string or is missing.
50
53
  * @throws \{EmbedApiError\} If the API request fails or returns an error.
@@ -56,9 +59,14 @@ export declare function getBeneficiary({ beneficiaryId, accessToken, stagingToke
56
59
  }): Promise<Beneficiary>;
57
60
  /**
58
61
  * Adds a new beneficiary in the current user's account.
59
- * @param Object - An object containing the new beneficiary's details and an
60
- * `accessToken`. The `beneficiary` parameter object requires at least the `name`
61
- * and `iban` properties to be present. The rest of the properties are optional.
62
+ * @param addBeneficiaryParams - An object containing the new beneficiary's details and optional
63
+ * `accessToken` and `stagingToken` parameters . The `beneficiary` parameter
64
+ * object requires at least the `name` and `iban` properties to be present. The
65
+ * rest of the properties of the `beneficiary` object are optional. If the
66
+ * `accessToken` is not provided, the function will use the token previously
67
+ * passed to the initialize function. The `stagingToken` is optional but it has
68
+ * to be passed to use the SDK in staging environments (it will be ignored in
69
+ * production).
62
70
  * @throws \{AuthenticationError\} If the access token is invalid or missing.
63
71
  * Ensure initialize has been called before using this function if you are not
64
72
  * passing the access token.
@@ -94,10 +102,10 @@ export declare function trustBeneficiaries({ beneficiarySettings, operationSetti
94
102
  }>): Promise<Beneficiary[]>;
95
103
  /**
96
104
  * Untrusts a list of beneficiaries in the current user's account.
97
- * @param Object - An object containing the list of beneficiary IDs and optional
98
- * `accessToken` and `stagingToken` parameters. If the `accessToken` is not
99
- * provided, the function will use the token previously passed to the initialize
100
- * function. The `stagingToken` is optional but it has to be passed to use the+
105
+ * @param untrustBeneficiariesParams - An object containing the list of beneficiary
106
+ * IDs and optional `accessToken` and `stagingToken` parameters. If the `accessToken`
107
+ * is not provided, the function will use the token previously passed to the initialize
108
+ * function. The `stagingToken` is optional but it has to be passed to use the
101
109
  * SDK in staging environments (it will be ignored in production).
102
110
  * @returns A promise that resolves to an array of untrusted beneficiaries.
103
111
  * @throws \{AuthenticationError\} If the access token is invalid or missing.
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAc/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGtF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqBpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,WAAW,EACX,YAAY,GACb,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE;IACD,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsB1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASzB"}
1
+ {"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAc/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGtF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqBpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,WAAW,EACX,YAAY,GACb,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE;IACD,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsB1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASzB"}
@@ -17,8 +17,13 @@ export interface CardParams<T> {
17
17
  }
18
18
  /**
19
19
  * Fetches the list of cards for the current user.
20
- * If membershipId is provided, it will fetch the cards for the given membership.
21
- * @param Object - An object with the membershipId and the accessToken properties.
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.
23
+ * If the `accessToken` is not provided, the function will use the token previously
24
+ * 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).
22
27
  * @returns A promise that resolves to an array of cards.
23
28
  * @throws \{AuthenticationError\} If the access token is invalid or missing.
24
29
  * Ensure initialize has been called before using this function if you are not
@@ -31,7 +36,8 @@ export declare function getCards({ membershipId, accessToken, stagingToken, }: {
31
36
  }): Promise<Card[]>;
32
37
  /**
33
38
  * Fetches a card by its id.
34
- * @param Object - An object with the cardId and the accessToken properties.
39
+ * @param Object - An object with the cardId and the optional accessToken and
40
+ * stagingToken properties.
35
41
  * @returns A promise that resolves to a card.
36
42
  * @throws \{AuthenticationError\} If the access token is invalid or missing.
37
43
  * Ensure initialize has been called before using this function if you are not
@@ -51,14 +57,14 @@ export declare function getCard({ cardId, accessToken, stagingToken, }: {
51
57
  * with the `uiParentElementId` property. This has to specify the ID of the DOM element where
52
58
  * the UI for MFA will be displayed.
53
59
  * @returns A promise that resolves to an object representing the ordered card.
54
- * @throws InvalidParametersError If the cardId is not provided or if the cardId is not a string.
55
- * @throws InvalidParametersError If the uiParentElementId or operationSettings are not provided.
60
+ * @throws `InvalidParametersError` If the cardId is not provided or if the cardId is not a string.
61
+ * @throws `InvalidParametersError` If the uiParentElementId or operationSettings are not provided.
56
62
  * @example Ordering a physical card to be shipped to the org's business address
57
- * ```
63
+ * ```ts
58
64
  * const cardConfig = {
59
65
  * cardSettings: {
60
66
  * categories: [
61
- * 'transport,
67
+ * 'transport',
62
68
  * 'restaurant_and_bar',
63
69
  * 'food_and_grocery',
64
70
  * 'it_and_electronics',
@@ -96,11 +102,11 @@ export declare function getCard({ cardId, accessToken, stagingToken, }: {
96
102
  * ```
97
103
  *
98
104
  * @example Ordering a virtual card
99
- * ```
105
+ * ```ts
100
106
  * const cardConfig = {
101
107
  * cardSettings: {
102
108
  * categories: [
103
- * 'transport,
109
+ * 'transport',
104
110
  * 'restaurant_and_bar',
105
111
  * 'food_and_grocery',
106
112
  * 'it_and_electronics',
@@ -137,10 +143,10 @@ export declare function orderCard(cardConfig: CardParams<CardOrderSettings>): Pr
137
143
  * with the `uiParentElementId` property. This has to specify the ID of the DOM element where
138
144
  * the UI for MFA will be displayed.
139
145
  * @returns A promise that resolves to an object representing the unlocked card.
140
- * @throws InvalidParametersError If the cardId is not provided or if the cardId is not a string.
141
- * @throws InvalidParametersError If the uiParentElementId or operationSettings are not provided.
146
+ * @throws `InvalidParametersError` If the cardId is not provided or if the cardId is not a string.
147
+ * @throws `InvalidParametersError` If the uiParentElementId or operationSettings are not provided.
142
148
  * @example
143
- * ```
149
+ * ```ts
144
150
  * const cardConfig = {
145
151
  * cardSettings: {
146
152
  * cardId: 'card-id',
@@ -162,8 +168,8 @@ export declare function unlockCard(cardConfig: CardParams<UnlockCardSettings>):
162
168
  * the UI for MFA will be displayed.
163
169
  * @returns A promise that resolves to an object with a `destroyEmbedUI` function. When calling
164
170
  * this function, the UI will be removed from the DOM.
165
- * @throws InvalidParametersError If the cardId is not provided or if the cardId is not a string.
166
- * @throws InvalidParametersError If the uiParentElementId or operationSettings are not provided.
171
+ * @throws `InvalidParametersError` If the cardId is not provided or if the cardId is not a string.
172
+ * @throws `InvalidParametersError` If the uiParentElementId or operationSettings are not provided.
167
173
  */
168
174
  export declare function displayCard(cardConfig: CardParams<DisplayCardSettings>): Promise<DisplayCardReturnObject>;
169
175
  //# sourceMappingURL=cards.d.ts.map
@@ -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;AAGnD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;GAQG;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;;;;;;;GAOG;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,CAsBlC"}
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;AAGnD;;;;;;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,CA8Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsBlC"}
@@ -64,7 +64,9 @@ export declare function filterValidCategories(categories: string[] | undefined):
64
64
  export declare function serializeUnlockCardPayload(payload: CardParams<UnlockCardSettings>): {
65
65
  actionId: string;
66
66
  actionData: {
67
- cardId: string;
67
+ body: {
68
+ cardId: string;
69
+ };
68
70
  };
69
71
  };
70
72
  //# sourceMappingURL=cards.serializer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cards.serializer.d.ts","sourceRoot":"","sources":["../../src/cards/cards.serializer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnE;AA8ED,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI,CA2DlE;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,YAKrE;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC;;;;;EAQxC"}
1
+ {"version":3,"file":"cards.serializer.d.ts","sourceRoot":"","sources":["../../src/cards/cards.serializer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEtB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnE;AA8ED,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI,CA2DlE;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,YAKrE;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC;;;;;;;EAUxC"}
@@ -7,6 +7,7 @@
7
7
  *
8
8
  * Then, the cards object contains the functions to perform card operations:
9
9
  * ```ts
10
+ * await cards.displayCard(/* params here *\/);
10
11
  * await cards.getCards();
11
12
  * await cards.orderCard(/* params here *\/);
12
13
  * await cards.unlockCard(/* params here *\/);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cards/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK;;;;;;CAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cards/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK;;;;;;CAAuB,CAAC"}
@@ -36,6 +36,10 @@ export declare const BRANCHES: {
36
36
  SANDBOX: string;
37
37
  QA: string;
38
38
  };
39
+ /**
40
+ * List of possible tags that can be used to categorize beneficiaries'
41
+ * activities.
42
+ */
39
43
  export declare const ACTIVITY_TAGS: {
40
44
  ATM: string;
41
45
  FALLBACK: string;
@@ -69,11 +73,20 @@ export declare const ACTIVITY_TAGS: {
69
73
  UTILITY: string;
70
74
  VOUCHER: string;
71
75
  };
76
+ /**
77
+ * List of possible statuses a beneficiary can have.
78
+ */
72
79
  export declare const BENEFICIARY_STATUSES: {
73
80
  PENDING: string;
74
81
  VALIDATED: string;
75
82
  DECLINED: string;
76
83
  };
84
+ /**
85
+ * List of possible locales the SDK can be used in.
86
+ * These locales are used to display content in the user's preferred language in
87
+ * those cases where the SDK is used in a web context and needs to display
88
+ * some UI.
89
+ */
77
90
  export declare const LOCALES: {
78
91
  EN: string;
79
92
  FR: string;
@@ -82,6 +95,10 @@ export declare const LOCALES: {
82
95
  IT: string;
83
96
  PT: string;
84
97
  };
98
+ /**
99
+ * List of reasons why a transfer can be declined.
100
+ * These reasons are used to provide more context on why a transfer was not successful.
101
+ */
85
102
  export declare const TRANSFER_DECLINE_REASONS: {
86
103
  BENEFICIARY_BIC_INVALID: string;
87
104
  BENEFICIARY_IBAN_INVALID: string;
@@ -91,6 +108,9 @@ export declare const TRANSFER_DECLINE_REASONS: {
91
108
  DEBIT_ACCOUNT_INSUFFICIENT_FUNDS: string;
92
109
  QONTO_PROCESSING_FAILED: string;
93
110
  };
111
+ /**
112
+ * List of all possible statuses a transfer can be in.
113
+ */
94
114
  export declare const TRANSFER_STATUSES: {
95
115
  PENDING: string;
96
116
  PROCESSING: string;
@@ -98,9 +118,33 @@ export declare const TRANSFER_STATUSES: {
98
118
  DECLINED: string;
99
119
  SETTLED: string;
100
120
  };
121
+ /**
122
+ * List of possible methods for Multi-Factor Authentication (MFA).
123
+ * These methods are used to enhance the security of user accounts.
124
+ */
101
125
  export declare const MFA_METHODS: {
126
+ /**
127
+ * Represents the use of a passkey for authentication. This will attempt to
128
+ * use the passkey stored in the browser so it requires the passkey to have
129
+ * been set up previously.
130
+ */
102
131
  PASSKEY: string;
132
+ /**
133
+ * Represents the use of a one-time password (OTP) sent via SMS for
134
+ * authentication.
135
+ */
103
136
  SMS_OTP: string;
137
+ /**
138
+ * It relies on the Qonto app installed on the user's mobile device. A
139
+ * notification is sent to the app, which the user can approve or deny.
140
+ */
104
141
  PAIRED_DEVICE: string;
142
+ /**
143
+ * Represents the use of a mock MFA method, primarily for testing purposes.
144
+ * It is only available in non-production environments (when initializing the
145
+ * SDK with an `environment` parameter different from `ENVIRONMENTS.PRODUCTION`).
146
+ * This method simulates the MFA flow without requiring any actual authentication
147
+ */
148
+ MOCK: string;
105
149
  };
106
150
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;CAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;CASnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCzB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;CAQpC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;CAM7B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAIvB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;CAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;CASnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;CAQpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;CAM7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;;;OAKG;;CAEJ,CAAC"}
@@ -29,6 +29,11 @@ export declare class EnvironmentManager {
29
29
  * @returns The current environment or undefined if not set
30
30
  */
31
31
  getEnvironment(): Environment | undefined;
32
+ /**
33
+ * Check if the current environment is production
34
+ * @returns True if the environment is production, false otherwise
35
+ */
36
+ isProductionEnvironment(): boolean;
32
37
  /**
33
38
  * Set the branch value
34
39
  * @param branch - The branch to set
@@ -1 +1 @@
1
- {"version":3,"file":"environment-manager.d.ts","sourceRoot":"","sources":["../../../src/common/environment/environment-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3D,KAAK,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AACpE,KAAK,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AACvD,UAAU,eAAe;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAyBD;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAG5C,OAAO,CAAC,WAAW,CAAwC;IAE3D,OAAO,CAAC,MAAM,CAA4B;IAE1C,OAAO;IAaP;;OAEG;WACW,WAAW,IAAI,kBAAkB;IAQ/C;;;OAGG;IACI,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAIrD;;;OAGG;IACI,cAAc,IAAI,WAAW,GAAG,SAAS;IAIhD;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC;;;OAGG;IACI,SAAS,IAAI,MAAM,GAAG,SAAS;IAItC;;OAEG;IACI,KAAK,IAAI,IAAI;IAKb,kBAAkB,IAAI,eAAe;CAa7C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAAmC,CAAC"}
1
+ {"version":3,"file":"environment-manager.d.ts","sourceRoot":"","sources":["../../../src/common/environment/environment-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3D,KAAK,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AACpE,KAAK,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AACvD,UAAU,eAAe;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAyBD;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAG5C,OAAO,CAAC,WAAW,CAAwC;IAE3D,OAAO,CAAC,MAAM,CAA4B;IAE1C,OAAO;IAaP;;OAEG;WACW,WAAW,IAAI,kBAAkB;IAQ/C;;;OAGG;IACI,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAIrD;;;OAGG;IACI,cAAc,IAAI,WAAW,GAAG,SAAS;IAIhD;;;OAGG;IACI,uBAAuB,IAAI,OAAO;IAIzC;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC;;;OAGG;IACI,SAAS,IAAI,MAAM,GAAG,SAAS;IAItC;;OAEG;IACI,KAAK,IAAI,IAAI;IAKb,kBAAkB,IAAI,eAAe;CAa7C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAAmC,CAAC"}
@@ -1,8 +1,15 @@
1
1
  import type { InitializeParams } from './initialize.types';
2
2
  /**
3
- * Initializes the SDK with the provided parameters. This function has to be called
3
+ * Initializes the SDK with the provided parameters. Despite the SDK can be used
4
+ * without calling this function beforehand, in stateful environments like in a
5
+ * single page application running in a browser, it is recommended. This is true
6
+ * because the `initialize` function accepts some parameters that in case of not
7
+ * being passed to it, they would have to be passed in every function call made
8
+ * to the SDK.
9
+ * In order to easier call functions afterwards, this function has to be called
4
10
  * before using any other SDK functions, and as the bare minimum, it requires an
5
11
  * access token.
12
+ * It's useful to rely on the exposed SDK constants to pass some of the parameters.
6
13
  * @param initializeParams - An object with the parameters to initialize the SDK.
7
14
  * The only required parameter is the `accessToken`.
8
15
  * - `accessToken`: The access token to authenticate the user. This has to be previously
@@ -11,7 +18,7 @@ import type { InitializeParams } from './initialize.types';
11
18
  * the SDK will default to `ENVIRONMENTS.PRODUCTION`. Use `ENVIRONMENTS.STAGING` to set
12
19
  * the SDK to staging.
13
20
  * - `branch`: Optional parameter to set the SDK's branch. This is only relevant when the
14
- * `environment` is set to 'staging'. The possible values are `BRANCHES.MASTER`,
21
+ * `environment` is set to `ENVIRONMENTS.STAGING`. The possible values are `BRANCHES.MASTER`,
15
22
  * `BRANCHES.SANDBOX` and `BRANCHES.QA`. If not provided, the SDK will default to
16
23
  * `BRANCHES.MASTER`.
17
24
  * - `operationSettings`: Optional settings to configure the SDK's operations that will
@@ -24,7 +31,7 @@ import type { InitializeParams } from './initialize.types';
24
31
  * - `locale`: Optional 2 digit language code to set the language in which the UI elements
25
32
  * injected by the SDK will show the text.
26
33
 
27
- * @throws InvalidParametersError If the access token is not provided or the specified
34
+ * @throws `InvalidParametersError` If the access token is not provided or the specified
28
35
  * parameters don't comply with the expected format.
29
36
  *
30
37
  * @example Simple initialization with an access token:
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QAyB5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAIrB"}
1
+ {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QAyB5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAIrB"}
@@ -3,7 +3,7 @@ import type { InitializeParams } from './initialize.types';
3
3
  * Validates the parameters passed to the initialize function.
4
4
  * @param params - The parameters to validate.
5
5
  * @returns The validated parameters.
6
- * @throws InvalidParametersError If the access token is not provided.
6
+ * @throws `InvalidParametersError` If the access token is not provided.
7
7
  */
8
8
  export declare function validateInitializeParams(params: InitializeParams): InitializeParams;
9
9
  //# sourceMappingURL=initialize.validate.d.ts.map
@@ -13,7 +13,7 @@ export declare class EmbedIframe {
13
13
  private targetOrigin;
14
14
  constructor(options: IframeOptions);
15
15
  initialize(): Promise<EmbedIframe>;
16
- postMessage(payload: IframeMessage): Promise<unknown>;
16
+ postMessage(message: IframeMessage): Promise<unknown>;
17
17
  private addMessageListener;
18
18
  private removeMessageListener;
19
19
  destroy(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"embed-iframe.d.ts","sourceRoot":"","sources":["../../src/iframe/embed-iframe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD,UAAU,aAAa;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IAQV,OAAO,CAAC,OAAO;IAP3B,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,gBAAgB,CACZ;IACZ,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,YAAY,CAAS;gBAET,OAAO,EAAE,aAAa;IAKpC,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IA0CxC,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IA8BrD,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,qBAAqB;IAc7B,OAAO,IAAI,IAAI;CAehB"}
1
+ {"version":3,"file":"embed-iframe.d.ts","sourceRoot":"","sources":["../../src/iframe/embed-iframe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,UAAU,aAAa;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IAQV,OAAO,CAAC,OAAO;IAP3B,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,gBAAgB,CACZ;IACZ,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,YAAY,CAAS;gBAET,OAAO,EAAE,aAAa;IAKpC,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;IA0CxC,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IA+BrD,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,qBAAqB;IAc7B,OAAO,IAAI,IAAI;CAehB"}
@@ -0,0 +1,8 @@
1
+ import type { ActionData, IframeMessage } from './iframe.types';
2
+ interface BuildIframeMessageParams {
3
+ actionId: string;
4
+ actionData: ActionData;
5
+ }
6
+ export declare function buildIframeMessage({ actionId, actionData, }: BuildIframeMessageParams): IframeMessage;
7
+ export {};
8
+ //# sourceMappingURL=iframe-message-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iframe-message-builder.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe-message-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGhE,UAAU,wBAAwB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,UAAU,GACX,EAAE,wBAAwB,GAAG,aAAa,CAU1C"}
@@ -1,6 +1,11 @@
1
1
  import { ACTIONS } from '@common/constants';
2
+ export interface ActionData {
3
+ scaPreference?: (typeof ACTIONS)[keyof typeof ACTIONS];
4
+ idempotencyKey?: string;
5
+ body?: unknown;
6
+ }
2
7
  export interface IframeMessage {
3
- actionData: unknown;
8
+ actionData: ActionData;
4
9
  actionId: (typeof ACTIONS)[keyof typeof ACTIONS];
5
10
  }
6
11
  //# sourceMappingURL=iframe.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iframe.types.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;CAClD"}
1
+ {"version":3,"file":"iframe.types.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;CAClD"}
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},m={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device"};var f=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:m,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:u,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"}});class g{constructor(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return g.instance||(g.instance=new g),g.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY}}const p=g.getInstance();function h(e){const t=e?.uiParentElementId||p.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||p.getMFAPreference();if(n&&!Object.values(u).includes(n))throw new s("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const i=e?.debugMode||p.getDebugMode();if(void 0!==i&&"boolean"!=typeof i)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:i,...e}}const _=Object.values(l);function y(e){if(!function(e){return _.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${_.join(", ")}.`);return e}function T(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&h(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&y(e.locale),e}const I="https://embed.qonto.com",E="https://embed-js{branch}.staging.qonto.co",b="https://embed.dev.qonto.co",w={[d.PRODUCTION]:{IFRAME_BASE_URL:I,IFRAME_URL:`${I}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:E,IFRAME_URL:`${E}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:b,IFRAME_URL:`${b}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class A{constructor(){this.environment=d.PRODUCTION,this.branch=m.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(m).includes(t)?t:m.SANDBOX}static getInstance(){return A.instance||(A.instance=new A),A.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=m.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return w.production;{const e=w[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const L=A.getInstance();class R{constructor(){this.currentLocale="en"}static getInstance(){return R.instance||(R.instance=new R),R.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const k=R.getInstance();const S={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=T(e);n.setAccessToken(t),i&&n.setStagingToken(i),o&&k.setLocale(o),a&&p.setSettings(a),r&&(L.setEnvironment(r),s&&L.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),k.setDefaultLocale()},constants:f},{initialize:v,logout:D,constants:P}=S;class O extends i{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function N({accessToken:e,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",k.getLocale()),r}async function U(e,t,n){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=L.getEnvironmentUrls().THIRD_PARTY_API_URL,r=await fetch(`${a}/v2/cards/${e.cardId}/data_view`,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(s.iframe_url,e)}var C;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(C||(C={}));const M={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var $,B;function F(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function j(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function Y(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function G(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}($||($={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(B||(B={}));const q=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],x=[...q,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function H(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return F(e,q),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),g=j({membershipId:t,organizationId:n,bankAccountId:i}),p=Y({hasDailyLimit:a,hasTransactionLimit:r}),h=G({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=z(m),y=K(l),T=[...f,...g,...p,...h,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){F(e,x),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:b,typeOfPrint:w}=e,A=function(e){return Object.values(B).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),L=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),R=j({membershipId:t,organizationId:n,bankAccountId:i}),k=Y({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:h}),S=G({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),v=z(m),D=K(l),P=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(E,h),N=[...A,...R,...k,...S,...v,...D,...L,...P,...O];if(N.length>0)throw new s(N)}(e)}(e)}function z(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function K(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class V extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class X{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new V(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),t(new V(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){return this.iframe&&this.iframe.contentWindow?new Promise(((t,n)=>{const i=a=>{if(a.data?.actionId===e.actionId){if("error"===a.data.status)return this.removeMessageListener(e.actionId,i),n(new V(`An error occurred when performing the action ${e.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(e.actionId,i),t(a.data.payload)}};this.addMessageListener(e.actionId,i),this.iframe?.contentWindow?.postMessage(e,this.targetOrigin)})):Promise.reject(new V("Attempted to perform an Embed operation without having the authentication UI initialized."))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function Q({accessToken:e,stagingToken:t,locale:n,debugMode:i}){const a=i||!1,r=n||k.getLocale(),s=L.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function W({parentElementId:e,iframeUrl:t}){return new X({parentElementId:e,iframeUrl:t}).initialize()}const J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));let Z;const ee=new Uint8Array(16);var te={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ne(e,t,n){if(te.randomUUID&&!e)return te.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!Z){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Z=crypto.getRandomValues.bind(crypto)}return Z(ee)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(J[e[t+0]]+J[e[t+1]]+J[e[t+2]]+J[e[t+3]]+"-"+J[e[t+4]]+J[e[t+5]]+"-"+J[e[t+6]]+J[e[t+7]]+"-"+J[e[t+8]]+J[e[t+9]]+"-"+J[e[t+10]]+J[e[t+11]]+J[e[t+12]]+J[e[t+13]]+J[e[t+14]]+J[e[t+15]]).toLowerCase()}(i)}function ie(e){return"virtual"===e.cardLevel?function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ne(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ne(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ae(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function re(e){const t=Object.values(M);return(e||[]).filter((e=>t.includes(e)))}const se={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=L.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new O(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>ae(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return ae(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=h(e.operationSettings);H(e.cardSettings);const s=Q({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await W({iframeUrl:s,parentElementId:i}),c=ie(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ae(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=h(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=j({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=Q({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),d=await W({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:c.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),l=await d.postMessage(m);return d.destroy(),ae(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const t=r(),{uiParentElementId:n}=h(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=j({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=Y(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await U(e.cardSettings,t),a=await W({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},oe=se;function ce({endpointUrl:e,paginationSettings:t}){const n=new URL(e);return t?.page&&n.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&n.searchParams.set("per_page",t.itemsPerPage.toString()),n}function de(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function me(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function le(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const ue="/v2/sepa/beneficiaries";async function fe({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}const ge=[{name:"name"},{name:"iban"}];const pe={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=ce({endpointUrl:new URL(L.getEnvironmentUrls().THIRD_PARTY_API_URL+ue),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.beneficiaries.map((e=>me(e))),a=de(n.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const i=t||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),me(await fe({beneficiaryId:e,accessToken:i,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");F(e,ge);const t=j({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return me(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:ne()}),body:JSON.stringify({beneficiary:le(e)})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings")}(e);return(await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i={method:"PATCH",headers:N({accessToken:t,stagingToken:n}),body:JSON.stringify({ids:e})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:n})).map(me)}};function he(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function _e(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}const ye="/v2/sepa/transfers";const Te=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Ie({sepaTransferSettings:e,operationSettings:t}){if(e.beneficiary)return e.beneficiary;return me(await fe({beneficiaryId:e.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}const Ee="browser",be="server";class we extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ee:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case be:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const Ae={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=ce({endpointUrl:new URL(L.getEnvironmentUrls().THIRD_PARTY_API_URL+ye),paginationSettings:n}),r=await fetch(a,i);if(!r.ok)throw new O("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.transfers.map((e=>he(e))),a=de(n.meta);return{transfers:i,...a?{meta:a}:{}}},getSepaTransfer:async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string")}(e);return he(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:i,stagingToken:n}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const i=t?.accessToken||r(),a=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||ne();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(F(e,Te),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...j({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...G({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>3e4&&(!e.attachments||0===e.attachments.length))throw new s("Attachments are required for transfers over €30,000")}(e);const m={...e,beneficiary:await Ie({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(m.beneficiary.trusted)d=await async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:i}){const a=_e(e),r={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${L.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new O(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:m,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if("undefined"==typeof window||"undefined"==typeof document)throw new we(Ee);const{uiParentElementId:e,debugMode:n}=h(t);let r;try{const t=Q({accessToken:i,stagingToken:a||void 0,debugMode:n});r=await W({iframeUrl:t,parentElementId:e});const s=_e(m);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return he(d)}};e.beneficiaries=pe,e.cards=oe,e.constants=P,e.initialize=v,e.logout=D,e.sepaTransfers=Ae}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},m={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};var f=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:m,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:u,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"}});class g{constructor(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return g.instance||(g.instance=new g),g.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY}}const p=g.getInstance(),h="https://embed.qonto.com",_="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",T={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=m.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(m).includes(t)?t:m.SANDBOX}static getInstance(){return I.instance||(I.instance=new I),I.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=m.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return T.production;{const e=T[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=I.getInstance();function b(e){const t=e?.uiParentElementId||p.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||p.getMFAPreference();if(n){const e=(i=Object.values(u),E.isProductionEnvironment()?i.filter((e=>e!==u.MOCK)):i);if(!e.includes(n))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(E.isProductionEnvironment()&&n===u.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const a=e?.debugMode||p.getDebugMode();if(void 0!==a&&"boolean"!=typeof a)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:a,...e}}const w=Object.values(l);function A(e){if(!function(e){return w.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${w.join(", ")}.`);return e}function L(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&b(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&&A(e.locale),e}class R{constructor(){this.currentLocale="en"}static getInstance(){return R.instance||(R.instance=new R),R.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const k=R.getInstance();const S={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=L(e);n.setAccessToken(t),i&&n.setStagingToken(i),o&&k.setLocale(o),a&&p.setSettings(a),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),k.setDefaultLocale()},constants:f},{initialize:v,logout:D,constants:P}=S;class O extends i{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function N({accessToken:e,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",k.getLocale()),r}async function U(e,t,n){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=E.getEnvironmentUrls().THIRD_PARTY_API_URL,r=await fetch(`${a}/v2/cards/${e.cardId}/data_view`,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(s.iframe_url,e)}var C;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(C||(C={}));const M={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var $,B;function F(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function j(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function Y(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function G(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}($||($={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(B||(B={}));const q=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],x=[...q,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function H(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return F(e,q),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),g=j({membershipId:t,organizationId:n,bankAccountId:i}),p=Y({hasDailyLimit:a,hasTransactionLimit:r}),h=G({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=z(m),y=K(l),T=[...f,...g,...p,...h,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){F(e,x),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:b,typeOfPrint:w}=e,A=function(e){return Object.values(B).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),L=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),R=j({membershipId:t,organizationId:n,bankAccountId:i}),k=Y({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:h}),S=G({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),v=z(m),D=K(l),P=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(E,h),N=[...A,...R,...k,...S,...v,...D,...L,...P,...O];if(N.length>0)throw new s(N)}(e)}(e)}function z(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function K(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class V extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const X=[];for(let e=0;e<256;++e)X.push((e+256).toString(16).slice(1));let Q;const W=new Uint8Array(16);var J={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Z(e,t,n){if(J.randomUUID&&!e)return J.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!Q){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Q=crypto.getRandomValues.bind(crypto)}return Q(W)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(X[e[t+0]]+X[e[t+1]]+X[e[t+2]]+X[e[t+3]]+"-"+X[e[t+4]]+X[e[t+5]]+"-"+X[e[t+6]]+X[e[t+7]]+"-"+X[e[t+8]]+X[e[t+9]]+"-"+X[e[t+10]]+X[e[t+11]]+X[e[t+12]]+X[e[t+13]]+X[e[t+14]]+X[e[t+15]]).toLowerCase()}(i)}class ee{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new V(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),t(new V(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new V("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=function({actionId:e,actionData:t}){const n=p.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||Z()}}}(e);return new Promise(((e,n)=>{const i=a=>{if(a.data?.actionId===t.actionId){if("error"===a.data.status)return this.removeMessageListener(t.actionId,i),n(new V(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(t.actionId,i),e(a.data.payload)}};this.addMessageListener(t.actionId,i),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function te({accessToken:e,stagingToken:t,locale:n,debugMode:i}){const a=i||!1,r=n||k.getLocale(),s=E.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function ne({parentElementId:e,iframeUrl:t}){return new ee({parentElementId:e,iframeUrl:t}).initialize()}function ie(e){return"virtual"===e.cardLevel?function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:Z(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:Z(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ae(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function re(e){const t=Object.values(M);return(e||[]).filter((e=>t.includes(e)))}const se={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=E.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new O(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>ae(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return ae(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=b(e.operationSettings);H(e.cardSettings);const s=te({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await ne({iframeUrl:s,parentElementId:i}),c=ie(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ae(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=b(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=j({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=te({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),d=await ne({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),l=await d.postMessage(m);return d.destroy(),ae(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const t=r(),{uiParentElementId:n}=b(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=j({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=Y(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await U(e.cardSettings,t),a=await ne({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},oe=se;function ce({endpointUrl:e,paginationSettings:t}){const n=new URL(e);return t?.page&&n.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&n.searchParams.set("per_page",t.itemsPerPage.toString()),n}function de(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function me(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function le(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const ue="/v2/sepa/beneficiaries";async function fe({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}const ge=[{name:"name"},{name:"iban"}];const pe={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=ce({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+ue),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.beneficiaries.map((e=>me(e))),a=de(n.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const i=t||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),me(await fe({beneficiaryId:e,accessToken:i,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");F(e,ge);const t=j({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return me(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:Z()}),body:JSON.stringify({beneficiary:le(e)})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings")}(e);return(await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i={method:"PATCH",headers:N({accessToken:t,stagingToken:n}),body:JSON.stringify({ids:e})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:n})).map(me)}};function he(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function _e(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}const ye="/v2/sepa/transfers";const Te=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Ie({sepaTransferSettings:e,operationSettings:t}){if(e.beneficiary)return e.beneficiary;return me(await fe({beneficiaryId:e.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}const Ee="browser",be="server";class we extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ee:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case be:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const Ae={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=ce({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+ye),paginationSettings:n}),r=await fetch(a,i);if(!r.ok)throw new O("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.transfers.map((e=>he(e))),a=de(n.meta);return{transfers:i,...a?{meta:a}:{}}},getSepaTransfer:async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string")}(e);return he(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:i,stagingToken:n}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const i=t?.accessToken||r(),a=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||Z();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(F(e,Te),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...j({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...G({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>3e4&&(!e.attachments||0===e.attachments.length))throw new s("Attachments are required for transfers over €30,000")}(e);const m={...e,beneficiary:await Ie({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(m.beneficiary.trusted)d=await async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:i}){const a=_e(e),r={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new O(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:m,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if("undefined"==typeof window||"undefined"==typeof document)throw new we(Ee);const{uiParentElementId:e,debugMode:n}=b(t);let r;try{const t=te({accessToken:i,stagingToken:a||void 0,debugMode:n});r=await ne({iframeUrl:t,parentElementId:e});const s=_e(m);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return he(d)}};e.beneficiaries=pe,e.cards=oe,e.constants=P,e.initialize=v,e.logout=D,e.sepaTransfers=Ae}));
@@ -24,11 +24,13 @@ export interface SepaTransferParams<T> {
24
24
  }
25
25
  /**
26
26
  * Fetches the list of SEPA transfers for the current user.
27
- * @param getSepaTransfersParams - An optional object with the accessToken
28
- * property. If not passed, the function only works if initialize has been
29
- * previously called. Also, this function allows managing pagination by passing
30
- * the paginationSettings property, which accepts an object with the page and
31
- * itemsPerPage properties.
27
+ * @param getSepaTransfersParams - An optional object containing `accessToken`
28
+ * and `stagingToken` parameters. If the `accessToken` is not provided, the
29
+ * function will use the token previously passed to the initialize function. The
30
+ * `stagingToken` is optional, but it has to be passed to use the SDK in staging
31
+ * environments (it will be ignored in production). This function also allows
32
+ * managing pagination by passing the `paginationSettings` property, which
33
+ * accepts an object with the page and itemsPerPage properties.
32
34
  * @returns A promise that resolves to an object containing an array of SEPA
33
35
  * transfers and a `meta` object containing pagination state.
34
36
  * @throws \{AuthenticationError\} If the access token is invalid or missing.
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAQtF,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAUnD,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,EAAE,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,GAAE,sBAA2B,GAClD,OAAO,CAAC,wBAAwB,CAAC,CAqBnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAwE7D"}
1
+ {"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAQtF,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAUnD,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,EAAE,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,GAAE,sBAA2B,GAClD,OAAO,CAAC,wBAAwB,CAAC,CAqBnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAuE7D"}
@@ -1 +1 @@
1
- import"../common/auth/auth.js";import{validatePresenceOfAuthToken as n}from"../common/auth/auth.validate.js";import{untrustBeneficiaries as e,addBeneficiary as i,getBeneficiary as a,getBeneficiaries as o}from"./beneficiaries.api.js";import{serializeBeneficiary as s}from"./beneficiaries.serializer.js";import{validateTrustBeneficiariesParams as t,validateAddBeneficiaryParams as c,validateGetBeneficiaryParams as r}from"./beneficiaries.validate.js";import{serializePaginationResponse as m}from"../common/api-pagination/api-pagination.js";import"../common/environment/environment-manager.js";import"../common/locale/locale-manager.js";import"../common/operation-settings/operation-settings.js";async function g(e){const i=e?.accessToken||n(),a=await o({accessToken:i,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),t=a.beneficiaries.map((n=>s(n))),c=m(a.meta);return{beneficiaries:t,...c?{meta:c}:{}}}async function f({beneficiaryId:e,accessToken:i,stagingToken:o}){const t=i||n();r(e);const c=await a({beneficiaryId:e,accessToken:t,stagingToken:o});return s(c)}async function p({beneficiary:e,accessToken:a,stagingToken:o}){const t=a||n();c(e);const r=await i({beneficiary:e,accessToken:t,stagingToken:o});return s(r)}async function k({beneficiaryIds:i,accessToken:a,stagingToken:o}){const c=a||n();t(i);return(await e({beneficiaryIds:i,accessToken:c,stagingToken:o})).map(s)}export{p as addBeneficiary,g as getBeneficiaries,f as getBeneficiary,k as untrustBeneficiaries};
1
+ import"../common/auth/auth.js";import{validatePresenceOfAuthToken as n}from"../common/auth/auth.validate.js";import{untrustBeneficiaries as e,addBeneficiary as i,getBeneficiary as a,getBeneficiaries as o}from"./beneficiaries.api.js";import{serializeBeneficiary as s}from"./beneficiaries.serializer.js";import{validateTrustBeneficiariesParams as t,validateAddBeneficiaryParams as c,validateGetBeneficiaryParams as r}from"./beneficiaries.validate.js";import{serializePaginationResponse as m}from"../common/api-pagination/api-pagination.js";import"../common/operation-settings/operation-settings.js";import"../common/environment/environment-manager.js";import"../common/locale/locale-manager.js";async function g(e){const i=e?.accessToken||n(),a=await o({accessToken:i,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),t=a.beneficiaries.map((n=>s(n))),c=m(a.meta);return{beneficiaries:t,...c?{meta:c}:{}}}async function f({beneficiaryId:e,accessToken:i,stagingToken:o}){const t=i||n();r(e);const c=await a({beneficiaryId:e,accessToken:t,stagingToken:o});return s(c)}async function p({beneficiary:e,accessToken:a,stagingToken:o}){const t=a||n();c(e);const r=await i({beneficiary:e,accessToken:t,stagingToken:o});return s(r)}async function k({beneficiaryIds:i,accessToken:a,stagingToken:o}){const c=a||n();t(i);return(await e({beneficiaryIds:i,accessToken:c,stagingToken:o})).map(s)}export{p as addBeneficiary,g as getBeneficiaries,f as getBeneficiary,k as untrustBeneficiaries};
@@ -1 +1 @@
1
- import{CardCategories as t}from"./cards.types.js";import{ACTIONS as i}from"../common/constants.js";import a from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";function n(t){return"virtual"===t.cardLevel?function(t){const n=o(t.categories);return{actionId:i.CARD_ORDER,actionData:{idempotencyKey:a(),body:{card:{payment_monthly_limit:t.monthlyLimit,payment_daily_limit:t.dailyLimit,payment_daily_limit_option:t.hasDailyLimit,payment_transaction_limit:t.transactionLimit,payment_transaction_limit_option:t.hasTransactionLimit,active_days:t.activeDays||[],holder_id:t.membershipId,organization_id:t.organizationId,bank_account_id:t.bankAccountId,categories:n,card_level:t.cardLevel}}}}}(t):function(t){const n=o(t.categories);return{actionId:i.CARD_ORDER,actionData:{idempotencyKey:a(),body:{card:{payment_monthly_limit:t.monthlyLimit,payment_daily_limit:t.dailyLimit,payment_daily_limit_option:t.hasDailyLimit,payment_transaction_limit:t.transactionLimit,payment_transaction_limit_option:t.hasTransactionLimit,active_days:t.activeDays||[],holder_id:t.membershipId,organization_id:t.organizationId,bank_account_id:t.bankAccountId,categories:n,card_level:t.cardLevel,card_design:t.cardDesign,..."plus"===t.cardLevel&&{type_of_print:t.typeOfPrint},ship_to_business_address:t.shipToBusiness,atm_option:t.hasAtmOption,nfc_option:t.hasNfcOption,foreign_option:t.hasForeignPaymentOption,online_option:t.hasOnlinePaymentOption,atm_daily_limit:t.atmDailyLimit,atm_monthly_limit:t.atmMonthlyLimit,...!t.shipToBusiness&&{address:{contact_name:t.address?.contactName,first_line:t.address?.firstLine,second_line:t.address?.secondLine,third_line:t.address?.thirdLine,zipcode:t.address?.zipCode,city:t.address?.city,country:t.address?.country}}}}}}}(t)}function e(t){return{id:t.id,nickname:t.nickname,embossedName:t.embossed_name,status:t.status,maskPan:t.mask_pan,expMonth:parseInt(t.exp_month,10),expYear:parseInt(t.exp_year,10),lastActivityAt:new Date(t.last_activity_at),lastDigits:t.last_digits,shipToBusiness:t.ship_to_business,atmOption:t.atm_option,atmDailyLimitOption:t.atm_daily_limit_option,nfcOption:t.nfc_option,onlineOption:t.online_option,foreignOption:t.foreign_option,atmMonthlyLimit:t.atm_monthly_limit,atmMonthlySpent:t.atm_monthly_spent,atmDailyLimit:t.atm_daily_limit,atmDailySpent:t.atm_daily_spent,paymentMonthlyLimit:t.payment_monthly_limit,paymentMonthlySpent:t.payment_monthly_spent,paymentDailyLimit:t.payment_daily_limit,paymentDailySpent:t.payment_daily_spent,paymentDailyLimitOption:t.payment_daily_limit_option,paymentTransactionLimit:t.payment_transaction_limit,paymentTransactionLimitOption:t.payment_transaction_limit_option,activeDays:t.active_days,holderId:t.holder_id,bankAccountId:t.bank_account_id,organizationId:t.organization_id,updatedAt:new Date(t.updated_at),createdAt:new Date(t.created_at),shippedAt:new Date(t.shipped_at),cardType:t.card_type,cardLevel:t.card_level,paymentLifespanLimit:t.payment_lifespan_limit,paymentLifespanSpent:t.payment_lifespan_spent,preExpiresAt:new Date(t.pre_expires_at),categories:t.categories,renewed:t.renewed,renewal:t.renewal,...t.parent_card_summary&&{parentCardSummary:{id:t.parent_card_summary.id,lastDigits:t.parent_card_summary.last_digits}},hadOperation:t.had_operation,hadPinOperation:t.had_pin_operation,cardDesign:t.card_design,typeOfPrint:t.type_of_print,upsold:t.upsold,upsell:t.upsell,discardOn:new Date(t.discard_on),reordered:t.reordered}}function o(i){const a=Object.values(t);return(i||[]).filter((t=>a.includes(t)))}function s(t){return{actionId:i.CARD_UNLOCK,actionData:{cardId:t.cardSettings.cardId}}}export{o as filterValidCategories,e as serializeCard,n as serializeOrderCardPayload,s as serializeUnlockCardPayload};
1
+ import{CardCategories as t}from"./cards.types.js";import{ACTIONS as i}from"../common/constants.js";import a from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";function n(t){return"virtual"===t.cardLevel?function(t){const n=o(t.categories);return{actionId:i.CARD_ORDER,actionData:{idempotencyKey:a(),body:{card:{payment_monthly_limit:t.monthlyLimit,payment_daily_limit:t.dailyLimit,payment_daily_limit_option:t.hasDailyLimit,payment_transaction_limit:t.transactionLimit,payment_transaction_limit_option:t.hasTransactionLimit,active_days:t.activeDays||[],holder_id:t.membershipId,organization_id:t.organizationId,bank_account_id:t.bankAccountId,categories:n,card_level:t.cardLevel}}}}}(t):function(t){const n=o(t.categories);return{actionId:i.CARD_ORDER,actionData:{idempotencyKey:a(),body:{card:{payment_monthly_limit:t.monthlyLimit,payment_daily_limit:t.dailyLimit,payment_daily_limit_option:t.hasDailyLimit,payment_transaction_limit:t.transactionLimit,payment_transaction_limit_option:t.hasTransactionLimit,active_days:t.activeDays||[],holder_id:t.membershipId,organization_id:t.organizationId,bank_account_id:t.bankAccountId,categories:n,card_level:t.cardLevel,card_design:t.cardDesign,..."plus"===t.cardLevel&&{type_of_print:t.typeOfPrint},ship_to_business_address:t.shipToBusiness,atm_option:t.hasAtmOption,nfc_option:t.hasNfcOption,foreign_option:t.hasForeignPaymentOption,online_option:t.hasOnlinePaymentOption,atm_daily_limit:t.atmDailyLimit,atm_monthly_limit:t.atmMonthlyLimit,...!t.shipToBusiness&&{address:{contact_name:t.address?.contactName,first_line:t.address?.firstLine,second_line:t.address?.secondLine,third_line:t.address?.thirdLine,zipcode:t.address?.zipCode,city:t.address?.city,country:t.address?.country}}}}}}}(t)}function e(t){return{id:t.id,nickname:t.nickname,embossedName:t.embossed_name,status:t.status,maskPan:t.mask_pan,expMonth:parseInt(t.exp_month,10),expYear:parseInt(t.exp_year,10),lastActivityAt:new Date(t.last_activity_at),lastDigits:t.last_digits,shipToBusiness:t.ship_to_business,atmOption:t.atm_option,atmDailyLimitOption:t.atm_daily_limit_option,nfcOption:t.nfc_option,onlineOption:t.online_option,foreignOption:t.foreign_option,atmMonthlyLimit:t.atm_monthly_limit,atmMonthlySpent:t.atm_monthly_spent,atmDailyLimit:t.atm_daily_limit,atmDailySpent:t.atm_daily_spent,paymentMonthlyLimit:t.payment_monthly_limit,paymentMonthlySpent:t.payment_monthly_spent,paymentDailyLimit:t.payment_daily_limit,paymentDailySpent:t.payment_daily_spent,paymentDailyLimitOption:t.payment_daily_limit_option,paymentTransactionLimit:t.payment_transaction_limit,paymentTransactionLimitOption:t.payment_transaction_limit_option,activeDays:t.active_days,holderId:t.holder_id,bankAccountId:t.bank_account_id,organizationId:t.organization_id,updatedAt:new Date(t.updated_at),createdAt:new Date(t.created_at),shippedAt:new Date(t.shipped_at),cardType:t.card_type,cardLevel:t.card_level,paymentLifespanLimit:t.payment_lifespan_limit,paymentLifespanSpent:t.payment_lifespan_spent,preExpiresAt:new Date(t.pre_expires_at),categories:t.categories,renewed:t.renewed,renewal:t.renewal,...t.parent_card_summary&&{parentCardSummary:{id:t.parent_card_summary.id,lastDigits:t.parent_card_summary.last_digits}},hadOperation:t.had_operation,hadPinOperation:t.had_pin_operation,cardDesign:t.card_design,typeOfPrint:t.type_of_print,upsold:t.upsold,upsell:t.upsell,discardOn:new Date(t.discard_on),reordered:t.reordered}}function o(i){const a=Object.values(t);return(i||[]).filter((t=>a.includes(t)))}function s(t){return{actionId:i.CARD_UNLOCK,actionData:{body:{cardId:t.cardSettings.cardId}}}}export{o as filterValidCategories,e as serializeCard,n as serializeOrderCardPayload,s as serializeUnlockCardPayload};
@@ -1 +1 @@
1
- const e={READY:"qonto.ready"},E={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},_={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},n={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},N={ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},a={PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},A={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},I={BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},i={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"},r={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device"};export{E as ACTIONS,N as ACTIVITY_TAGS,a as BENEFICIARY_STATUSES,n as BRANCHES,_ as ENVIRONMENTS,e as IFRAME_EVENTS,A as LOCALES,r as MFA_METHODS,I as TRANSFER_DECLINE_REASONS,i as TRANSFER_STATUSES};
1
+ const e={READY:"qonto.ready"},E={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},_={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},n={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},N={ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},a={PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},A={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},I={BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},i={PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"},r={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};export{E as ACTIONS,N as ACTIVITY_TAGS,a as BENEFICIARY_STATUSES,n as BRANCHES,_ as ENVIRONMENTS,e as IFRAME_EVENTS,A as LOCALES,r as MFA_METHODS,I as TRANSFER_DECLINE_REASONS,i as TRANSFER_STATUSES};
@@ -1 +1 @@
1
- import{ENVIRONMENTS as t,BRANCHES as n}from"../constants.js";const e="https://embed.qonto.com",r="https://embed-js{branch}.staging.qonto.co",s="https://embed.dev.qonto.co",c={[t.PRODUCTION]:{IFRAME_BASE_URL:e,IFRAME_URL:`${e}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[t.STAGING]:{IFRAME_BASE_URL:r,IFRAME_URL:`${r}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[t.LOCAL]:{IFRAME_BASE_URL:s,IFRAME_URL:`${s}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class o{constructor(){this.environment=t.PRODUCTION,this.branch=n.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,r=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(t).includes(e)?e:t.PRODUCTION,this.branch=Object.values(n).includes(r)?r:n.SANDBOX}static getInstance(){return o.instance||(o.instance=new o),o.instance}setEnvironment(t){this.environment=t}getEnvironment(){return this.environment}setBranch(t){this.branch=t}getBranch(){return this.branch}clear(){this.environment=t.PRODUCTION,this.branch=n.MASTER}getEnvironmentUrls(){if(this.environment===t.PRODUCTION)return c.production;{const t=c[this.environment];return Object.entries(t).reduce(((t,[n,e])=>({...t,[n]:e.replace("{branch}",`-${this.branch}`)})),{})}}}const i=o.getInstance();export{o as EnvironmentManager,i as environmentManager};
1
+ import{ENVIRONMENTS as n,BRANCHES as t}from"../constants.js";const e="https://embed.qonto.com",r="https://embed-js{branch}.staging.qonto.co",s="https://embed.dev.qonto.co",c={[n.PRODUCTION]:{IFRAME_BASE_URL:e,IFRAME_URL:`${e}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[n.STAGING]:{IFRAME_BASE_URL:r,IFRAME_URL:`${r}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[n.LOCAL]:{IFRAME_BASE_URL:s,IFRAME_URL:`${s}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class o{constructor(){this.environment=n.PRODUCTION,this.branch=t.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,r=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(n).includes(e)?e:n.PRODUCTION,this.branch=Object.values(t).includes(r)?r:t.SANDBOX}static getInstance(){return o.instance||(o.instance=new o),o.instance}setEnvironment(n){this.environment=n}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===n.PRODUCTION}setBranch(n){this.branch=n}getBranch(){return this.branch}clear(){this.environment=n.PRODUCTION,this.branch=t.MASTER}getEnvironmentUrls(){if(this.environment===n.PRODUCTION)return c.production;{const n=c[this.environment];return Object.entries(n).reduce(((n,[t,e])=>({...n,[t]:e.replace("{branch}",`-${this.branch}`)})),{})}}}const i=o.getInstance();export{o as EnvironmentManager,i as environmentManager};
@@ -1 +1 @@
1
- import{IFRAME_EVENTS as e}from"../common/constants.js";import{EmbedOperationError as t}from"../errors/EmbedOperationError.js";class s{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new t(`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(((s,i)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",r),i(new t(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),r=t=>{t.data.eventId===e.READY&&(clearTimeout(a),window.removeEventListener("message",r),s(this))};window.addEventListener("message",r),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){return this.iframe&&this.iframe.contentWindow?new Promise(((s,i)=>{const n=a=>{if(a.data?.actionId===e.actionId){if("error"===a.data.status)return this.removeMessageListener(e.actionId,n),i(new t(`An error occurred when performing the action ${e.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(e.actionId,n),s(a.data.payload)}};this.addMessageListener(e.actionId,n),this.iframe?.contentWindow?.postMessage(e,this.targetOrigin)})):Promise.reject(new t("Attempted to perform an Embed operation without having the authentication UI initialized."))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const s=this.messageListeners.get(e);if(s){const e=s.indexOf(t);-1!==e&&(s.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}export{s as EmbedIframe};
1
+ import{IFRAME_EVENTS as e}from"../common/constants.js";import{EmbedOperationError as t}from"../errors/EmbedOperationError.js";import{buildIframeMessage as s}from"./iframe-message-builder.js";class i{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new t(`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(((s,i)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",r),i(new t(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),r=t=>{t.data.eventId===e.READY&&(clearTimeout(a),window.removeEventListener("message",r),s(this))};window.addEventListener("message",r),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new t("Attempted to perform an Embed operation without having the authentication UI initialized."));const i=s(e);return new Promise(((e,s)=>{const n=a=>{if(a.data?.actionId===i.actionId){if("error"===a.data.status)return this.removeMessageListener(i.actionId,n),s(new t(`An error occurred when performing the action ${i.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(i.actionId,n),e(a.data.payload)}};this.addMessageListener(i.actionId,n),this.iframe?.contentWindow?.postMessage(i,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const s=this.messageListeners.get(e);if(s){const e=s.indexOf(t);-1!==e&&(s.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}export{i as EmbedIframe};
@@ -0,0 +1 @@
1
+ import{operationSettingsManager as e}from"../common/operation-settings/operation-settings.js";import o from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";function t({actionId:t,actionData:n}){const r=e.getMFAPreference();return{actionId:t,actionData:{...n,scaPreference:n.scaPreference||r,idempotencyKey:n.idempotencyKey||o()}}}export{t as buildIframeMessage};
@@ -1 +1 @@
1
- import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{operationSettingsManager as t}from"../common/operation-settings/operation-settings.js";import{MFA_METHODS as o}from"../common/constants.js";function n(n){const r=n?.uiParentElementId||t.getUIParentElementId();if(!r)throw new e("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=n?.mfaPreference||t.getMFAPreference();if(i&&!Object.values(o).includes(i))throw new e("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const a=n?.debugMode||t.getDebugMode();if(void 0!==a&&"boolean"!=typeof a)throw new e("operationSettings.debugMode must be a boolean.");return{uiParentElementId:r,mfaPreference:i,debugMode:a,...n}}export{n as validateOperationSettingsParams};
1
+ import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{operationSettingsManager as n}from"../common/operation-settings/operation-settings.js";import{MFA_METHODS as t}from"../common/constants.js";import{environmentManager as o}from"../common/environment/environment-manager.js";function r(r){const i=r?.uiParentElementId||n.getUIParentElementId();if(!i)throw new e("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const a=r?.mfaPreference||n.getMFAPreference();if(a){const n=(m=Object.values(t),o.isProductionEnvironment()?m.filter((e=>e!==t.MOCK)):m);if(!n.includes(a))throw new e(`operationSettings.mfaPreference must be one of ${n.join(", ")}`);if(o.isProductionEnvironment()&&a===t.MOCK)throw new e("operationSettings.mfaPreference cannot be set to mock in production environment.")}var m;const s=r?.debugMode||n.getDebugMode();if(void 0!==s&&"boolean"!=typeof s)throw new e("operationSettings.debugMode must be a boolean.");return{uiParentElementId:i,mfaPreference:a,debugMode:s,...r}}export{r as validateOperationSettingsParams};
@@ -1 +1 @@
1
- {"version":3,"file":"operation-settings-validation.d.ts","sourceRoot":"","sources":["../../src/validation/operation-settings-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAGrF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,iBAAiB,CA+BnB"}
1
+ {"version":3,"file":"operation-settings-validation.d.ts","sourceRoot":"","sources":["../../src/validation/operation-settings-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAIrF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,iBAAiB,CA4CnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {
@@ -48,7 +48,7 @@
48
48
  "build:watch": "rollup -c -w",
49
49
  "clean": "rm -rf dist",
50
50
  "commitlint": "commitlint --edit",
51
- "docs": "typedoc",
51
+ "docs": "typedoc && node scripts/remove-mdx-extensions.js",
52
52
  "format:check": "prettier --check .",
53
53
  "format:fix": "prettier --write .",
54
54
  "lint": "eslint .",