@qonto/embed-sdk 0.23.1 → 0.25.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 (34) hide show
  1. package/dist/beneficiaries/beneficiaries.api.d.ts +16 -4
  2. package/dist/beneficiaries/beneficiaries.api.d.ts.map +1 -1
  3. package/dist/beneficiaries/beneficiaries.d.ts +56 -70
  4. package/dist/beneficiaries/beneficiaries.d.ts.map +1 -1
  5. package/dist/beneficiaries/beneficiaries.validate.d.ts +4 -4
  6. package/dist/beneficiaries/beneficiaries.validate.d.ts.map +1 -1
  7. package/dist/common/api-pagination/api-pagination.d.ts +5 -0
  8. package/dist/common/api-pagination/api-pagination.d.ts.map +1 -1
  9. package/dist/common/initialize/initialize.d.ts.map +1 -1
  10. package/dist/index.umd.js +1 -1
  11. package/dist/payment-links/index.d.ts +18 -0
  12. package/dist/payment-links/index.d.ts.map +1 -0
  13. package/dist/payment-links/payment-links.d.ts +32 -0
  14. package/dist/payment-links/payment-links.d.ts.map +1 -0
  15. package/dist/payment-links/payment-links.public-api.d.ts +5 -0
  16. package/dist/payment-links/payment-links.public-api.d.ts.map +1 -0
  17. package/dist/payment-links/payment-links.test.d.ts +2 -0
  18. package/dist/payment-links/payment-links.test.d.ts.map +1 -0
  19. package/dist/payment-links/payment-links.types.d.ts +29 -0
  20. package/dist/payment-links/payment-links.types.d.ts.map +1 -0
  21. package/dist/payment-links/validation/currency.validation.d.ts +2 -0
  22. package/dist/payment-links/validation/currency.validation.d.ts.map +1 -0
  23. package/dist/payment-links/validation/payment-links.validate.d.ts +5 -0
  24. package/dist/payment-links/validation/payment-links.validate.d.ts.map +1 -0
  25. package/dist/payment-links/validation/unit.validation.d.ts +2 -0
  26. package/dist/payment-links/validation/unit.validation.d.ts.map +1 -0
  27. package/dist/src/beneficiaries/beneficiaries.api.js +1 -1
  28. package/dist/src/beneficiaries/beneficiaries.js +1 -1
  29. package/dist/src/beneficiaries/beneficiaries.validate.js +1 -1
  30. package/dist/src/common/api-pagination/api-pagination.js +1 -1
  31. package/dist/src/common/initialize/initialize.js +1 -1
  32. package/dist/src/validation/operation-settings-validation.js +1 -1
  33. package/dist/validation/operation-settings-validation.d.ts.map +1 -1
  34. package/package.json +5 -1
@@ -3,7 +3,7 @@ import type { PaginationResponseDataObject, PaginationSettings } from '@common/a
3
3
  import { type NetworkCallDescriptor } from '@common/network/network';
4
4
  import type { MfaMethod } from '@common/operation-settings/operation-settings.types';
5
5
  interface GetBeneficiariesParams {
6
- accessToken: string;
6
+ accessToken?: string;
7
7
  stagingToken?: string;
8
8
  paginationSettings?: PaginationSettings;
9
9
  }
@@ -14,8 +14,9 @@ interface GetBeneficiaryParams {
14
14
  }
15
15
  interface AddBeneficiaryParams {
16
16
  beneficiary: NewBeneficiary;
17
- accessToken: string;
17
+ accessToken?: string;
18
18
  stagingToken?: string;
19
+ idempotencyKey?: string;
19
20
  }
20
21
  interface UntrustBeneficiariesParams {
21
22
  beneficiaryIds: string[];
@@ -33,10 +34,21 @@ interface GetBeneficiariesApiResponse {
33
34
  beneficiaries: BeneficiaryDataObject[];
34
35
  meta: PaginationResponseDataObject;
35
36
  }
37
+ export declare function prepareGetBeneficiariesCall({ paginationSettings, accessToken, stagingToken, }: GetBeneficiariesParams): NetworkCallDescriptor;
36
38
  export declare function getBeneficiaries({ paginationSettings, accessToken, stagingToken, }: GetBeneficiariesParams): Promise<GetBeneficiariesApiResponse>;
39
+ export declare function prepareGetBeneficiaryCall({ beneficiaryId, accessToken, stagingToken, }: {
40
+ beneficiaryId: string;
41
+ accessToken?: string;
42
+ stagingToken?: string;
43
+ }): NetworkCallDescriptor;
37
44
  export declare function getBeneficiary({ accessToken, stagingToken, beneficiaryId, }: GetBeneficiaryParams): Promise<BeneficiaryDataObject>;
38
- export declare function addBeneficiary({ beneficiary, accessToken, stagingToken, }: AddBeneficiaryParams): Promise<any>;
39
- export declare function trustBeneficiaries(): Promise<void>;
45
+ export declare function prepareAddBeneficiaryCall({ beneficiary, accessToken, stagingToken, idempotencyKey, }: AddBeneficiaryParams): NetworkCallDescriptor;
46
+ export declare function addBeneficiary({ beneficiary, accessToken, stagingToken, idempotencyKey, }: AddBeneficiaryParams): Promise<BeneficiaryDataObject>;
47
+ export declare function prepareUntrustBeneficiaryCall({ beneficiaryIds, accessToken, stagingToken, }: {
48
+ beneficiaryIds: string[];
49
+ accessToken?: string;
50
+ stagingToken?: string;
51
+ }): NetworkCallDescriptor;
40
52
  export declare function untrustBeneficiaries({ beneficiaryIds, accessToken, stagingToken, }: UntrustBeneficiariesParams): Promise<BeneficiaryDataObject[]>;
41
53
  export declare function prepareUpdateBeneficiaryCall({ beneficiaryParamsBeingEdited, accessToken, stagingToken, idempotencyKey, mfaPreference, }: UpdateBeneficiaryParams): NetworkCallDescriptor;
42
54
  export declare function updateBeneficiary({ beneficiaryParamsBeingEdited, accessToken, stagingToken, idempotencyKey, mfaPreference, }: UpdateBeneficiaryParams): Promise<BeneficiaryDataObject>;
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACf,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAErF,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,0BAA0B;IAClC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,uBAAuB;IAC/B,4BAA4B,EAAE,6BAA6B,CAAC;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,UAAU,2BAA2B;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAID,wBAAsB,gBAAgB,CAAC,EACrC,kBAAkB,EAClB,WAAW,EACX,YAAY,GACb,EAAE,sBAAsB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CA+B/D;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,YAAY,EACZ,aAAa,GACd,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAqBvD;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE,oBAAoB,gBAyBtB;AAED,wBAAsB,kBAAkB,kBAEvC;AAED,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAuB/D;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,EAAE,uBAAuB,GAAG,qBAAqB,CAmBjD;AAED,wBAAsB,iBAAiB,CAAC,EACtC,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,EAAE,uBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAY1D"}
1
+ {"version":3,"file":"beneficiaries.api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAErF,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,0BAA0B;IAClC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,uBAAuB;IAC/B,4BAA4B,EAAE,6BAA6B,CAAC;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,UAAU,2BAA2B;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAID,wBAAgB,2BAA2B,CAAC,EAC1C,kBAAkB,EAClB,WAAW,EACX,YAAY,GACb,EAAE,sBAAsB,GAAG,qBAAqB,CAgBhD;AAED,wBAAsB,gBAAgB,CAAC,EACrC,kBAAkB,EAClB,WAAW,EACX,YAAY,GACb,EAAE,sBAAsB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAe/D;AAED,wBAAgB,yBAAyB,CAAC,EACxC,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,qBAAqB,CAWxB;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,YAAY,EACZ,aAAa,GACd,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAUvD;AAED,wBAAgB,yBAAyB,CAAC,EACxC,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAyB,GAC1B,EAAE,oBAAoB,GAAG,qBAAqB,CAe9C;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAyB,GAC1B,EAAE,oBAAoB,kCAWtB;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,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,qBAAqB,CAYxB;AAED,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAU/D;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,EAAE,uBAAuB,GAAG,qBAAqB,CAmBjD;AAED,wBAAsB,iBAAiB,CAAC,EACtC,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,EAAE,uBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAY1D"}
@@ -1,5 +1,4 @@
1
1
  import type { Beneficiary, EditableBeneficiaryProperties, GetBeneficiariesResponse, NewBeneficiary } from './beneficiaries.types';
2
- import type { PaginationSettings } from '@common/api-pagination/api-pagination.types';
3
2
  import { type OperationSettings } from '@validation/operation-settings-validation';
4
3
  /**
5
4
  * This is the common parameter format most of the beneficiaries functions expect
@@ -15,69 +14,60 @@ export interface BeneficiaryParams<T> {
15
14
  * Read the documentation of each function to see the expected properties of
16
15
  * this object.
17
16
  */
18
- beneficiarySettings: T;
17
+ beneficiarySettings?: T;
19
18
  operationSettings?: OperationSettings;
20
19
  }
21
20
  /**
22
21
  * Fetches the list of beneficiaries for the current user.
23
- * @param getBeneficiariesParams - An optional object with the accessToken
24
- * property. If not passed, the function only works if initialize has been
25
- * previously called. Also, this function allows managing pagination by passing
26
- * the paginationSettings property, which accepts an object with the page and
27
- * itemsPerPage properties.
22
+ * @param getBeneficiariesParams - An object containing:
23
+ * - `operationSettings`: An object with operation-level settings such as
24
+ * `proxyRequestFunction` (preferred over using the access token flow),
25
+ * `accessToken`, `stagingToken`, `mfaPreference`, and other optional
26
+ * parameters. This function also allows managing pagination by passing the
27
+ * `paginationSettings` property under `operationSettings`, which accepts an
28
+ * object with the page and itemsPerPage properties. See {@link BeneficiaryParams}.
28
29
  * @returns A promise that resolves to an array of beneficiaries and a `meta`
29
30
  * object containing pagination state.
30
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
31
- * Ensure initialize has been called before using this function if you are not
32
- * passing the access token.
31
+ * @throws \{InvalidParametersError\} If any of the values provided under
32
+ * operationSettings is invalid.
33
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and
34
+ * `accessToken` are invalid or missing within `operationSettings`.
33
35
  * @throws \{EmbedApiError\} If the API request fails or returns an error.
34
36
  */
35
- export declare function getBeneficiaries(getBeneficiariesParams?: {
36
- accessToken?: string;
37
- stagingToken?: string;
38
- paginationSettings?: PaginationSettings;
39
- }): Promise<GetBeneficiariesResponse>;
37
+ export declare function getBeneficiaries(getBeneficiariesParams?: BeneficiaryParams<never>): Promise<GetBeneficiariesResponse>;
40
38
  /**
41
39
  * Fetches a single beneficiary of the current user by ID.
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).
40
+ * @param getBeneficiaryParams - An object containing:
41
+ * - `beneficiarySettings`: An object with the `beneficiaryId` property (string).
42
+ * - `operationSettings`: An object with operation-level settings such as
43
+ * `proxyRequestFunction` (preferred over using the access token flow),
44
+ * `accessToken`, `stagingToken`, `mfaPreference`, and other optional parameters.
45
+ * See {@link BeneficiaryParams}.
47
46
  * @returns A promise that resolves to a beneficiary.
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.
51
- * @throws \{InvalidParametersError\} If the `beneficiaryId` parameter is not a
52
- * string or is missing.
47
+ * @throws \{InvalidParametersError\} If the `beneficiaryId` parameter is not a string or is missing.
48
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and `accessToken` are invalid or missing within
49
+ * `operationSettings`.
53
50
  * @throws \{EmbedApiError\} If the API request fails or returns an error.
54
51
  */
55
- export declare function getBeneficiary({ beneficiaryId, accessToken, stagingToken, }: {
52
+ export declare function getBeneficiary({ beneficiarySettings, operationSettings, }: BeneficiaryParams<{
56
53
  beneficiaryId: string;
57
- accessToken?: string;
58
- stagingToken?: string;
59
- }): Promise<Beneficiary>;
54
+ }>): Promise<Beneficiary>;
60
55
  /**
61
56
  * Adds a new beneficiary in the current user's account.
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).
70
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
71
- * Ensure initialize has been called before using this function if you are not
72
- * passing the access token.
73
- * @throws \{InvalidParametersError\} If the `beneficiary` parameter is not an
74
- * object or if it does not contain the required properties.
57
+ * @param addBeneficiaryParams - An object containing:
58
+ * - `beneficiarySettings`: An object with the new beneficiary details. Requires at
59
+ * least the `name` and `iban` properties to be present.
60
+ * - `operationSettings`: An object with operation-level settings such as
61
+ * `proxyRequestFunction` (preferred over using the access token flow),
62
+ * `accessToken`, `stagingToken`, `idempotencyKey`, and other optional
63
+ * parameters. See {@link BeneficiaryParams}.
64
+ * @returns A promise that resolves to the created beneficiary.
65
+ * @throws \{InvalidParametersError\} If any required property is missing or invalid.
66
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and
67
+ * `accessToken` are invalid or missing within `operationSettings`.
68
+ * @throws \{EmbedApiError\} If the API request fails or returns an error.
75
69
  */
76
- export declare function addBeneficiary({ beneficiary, accessToken, stagingToken, }: {
77
- beneficiary: NewBeneficiary;
78
- accessToken?: string;
79
- stagingToken?: string;
80
- }): Promise<Beneficiary>;
70
+ export declare function addBeneficiary({ beneficiarySettings, operationSettings, }: BeneficiaryParams<NewBeneficiary>): Promise<Beneficiary>;
81
71
  /**
82
72
  * Update any of the editable properites of a beneficiary in the current user's
83
73
  * account by ID.
@@ -86,17 +76,14 @@ export declare function addBeneficiary({ beneficiary, accessToken, stagingToken,
86
76
  * and any of the editable properties of a beneficiary, which are `name`,
87
77
  * `email` and `activityTag`.
88
78
  * - `operationSettings`: An object with operation-level settings such as
89
- * `accessToken`, `stagingToken`, `mfaPreference`, and other optional
79
+ * `proxyRequestFunction` (preferred over using the access token flow),
80
+ * `accessToken`, `stagingToken`, `mfaPreference`, `idempotencyKey`, and other optional
90
81
  * parameters. See {@link BeneficiaryParams}.
91
82
  * @returns A promise that resolves to the updated beneficiary.
92
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
93
- * Ensure initialize has been called before using this function if you are not
94
- * passing the access token.
95
- * @throws \{InvalidParametersError\} If the `updateBeneficiaryParams.benefiarySettings.id`
96
- * parameter is not present.
97
- * @throws \{InvalidParametersError\} If the none of `name`, `email` or
98
- * `activityTag` properties are included in `updateBeneficiaryParams.benefiarySettings`
99
- * or they are provided but their type is incorrect.
83
+ * @throws \{InvalidParametersError\} If the beneficiary ID is missing or if none of the
84
+ * editable properties (`name`, `email`, `activityTag`) are provided or are of incorrect type.
85
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and
86
+ * `accessToken` are invalid or missing within `operationSettings`.
100
87
  * @throws \{EmbedApiError\} If the API request fails or returns an error.
101
88
  */
102
89
  export declare function updateBeneficiary({ beneficiarySettings, operationSettings, }: BeneficiaryParams<EditableBeneficiaryProperties>): Promise<Beneficiary>;
@@ -124,22 +111,21 @@ export declare function trustBeneficiaries({ beneficiarySettings, operationSetti
124
111
  }>): Promise<Beneficiary[]>;
125
112
  /**
126
113
  * Untrusts a list of beneficiaries in the current user's account.
127
- * @param untrustBeneficiariesParams - An object containing the list of beneficiary
128
- * IDs and optional `accessToken` and `stagingToken` parameters. If the `accessToken`
129
- * is not provided, the function will use the token previously passed to the initialize
130
- * function. The `stagingToken` is optional but it has to be passed to use the
131
- * SDK in staging environments (it will be ignored in production).
114
+ * @param untrustBeneficiariesParams - An object containing:
115
+ * - `beneficiarySettings`: An object with the list of beneficiary IDs to
116
+ * untrust (e.g., `{ beneficiaryIds: string[] }`).
117
+ * - `operationSettings`: An object with operation-level settings such as
118
+ * `proxyRequestFunction` (preferred over using the access token flow),
119
+ * `accessToken`, `stagingToken`, and other optional parameters.
120
+ * See {@link BeneficiaryParams}.
132
121
  * @returns A promise that resolves to an array of untrusted beneficiaries.
133
- * @throws \{AuthenticationError\} If the access token is invalid or missing.
134
- * Ensure initialize has been called before using this function if you are not
135
- * passing the access token.
136
- * @throws \{InvalidParametersError\} If the `beneficiaryIds` parameter is not
137
- * an array of strings or is missing.
122
+ * @throws \{InvalidParametersError\} If the `beneficiaryIds` parameter is not an
123
+ * array of strings or is missing.
124
+ * @throws \{AuthenticationError\} If both the `proxyRequestFunction` and
125
+ * `accessToken` are invalid or missing within `operationSettings`.
138
126
  * @throws \{EmbedApiError\} If the API request fails or returns an error.
139
127
  */
140
- export declare function untrustBeneficiaries({ beneficiaryIds, accessToken, stagingToken, }: {
128
+ export declare function untrustBeneficiaries({ beneficiarySettings, operationSettings, }: BeneficiaryParams<{
141
129
  beneficiaryIds: string[];
142
- accessToken?: string;
143
- stagingToken?: string;
144
- }): Promise<Beneficiary[]>;
130
+ }>): Promise<Beneficiary[]>;
145
131
  //# sourceMappingURL=beneficiaries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAEX,6BAA6B,EAC7B,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAiB/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGtF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAMnD;;;;;;;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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAkCzE;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,CAwB1B;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,EAEX,6BAA6B,EAC7B,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAwB/B,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAMnD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAChD,OAAO,CAAC,wBAAwB,CAAC,CAsDnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,EACnC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA0BrE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,EACnC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA0B1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAkCzE;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,CAwB1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC;IAAE,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA0B1E"}
@@ -1,6 +1,6 @@
1
1
  import type { EditableBeneficiaryProperties, NewBeneficiary } from '@beneficiaries/beneficiaries.types';
2
- export declare function validateGetBeneficiaryParams(beneficiaryId: string): string;
3
- export declare function validateAddBeneficiaryParams(beneficiary: NewBeneficiary): NewBeneficiary;
4
- export declare function validateUpdateBeneficiaryParams(beneficiaryBeingEdited: EditableBeneficiaryProperties): EditableBeneficiaryProperties;
5
- export declare function validateTrustBeneficiariesParams(beneficiaryIds: string[]): string[];
2
+ export declare function validateGetBeneficiaryParams(beneficiaryId: string | undefined): string;
3
+ export declare function validateAddBeneficiaryParams(beneficiary: NewBeneficiary | undefined): NewBeneficiary;
4
+ export declare function validateUpdateBeneficiaryParams(beneficiaryBeingEdited?: EditableBeneficiaryProperties): EditableBeneficiaryProperties;
5
+ export declare function validateTrustBeneficiariesParams(beneficiaryIds?: string[]): string[];
6
6
  //# sourceMappingURL=beneficiaries.validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.validate.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.validate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACf,MAAM,oCAAoC,CAAC;AAM5C,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAU1E;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,cAAc,GAC1B,cAAc,CAyBhB;AAED,wBAAgB,+BAA+B,CAC7C,sBAAsB,EAAE,6BAA6B,GACpD,6BAA6B,CAuB/B;AAED,wBAAgB,gCAAgC,CAC9C,cAAc,EAAE,MAAM,EAAE,GACvB,MAAM,EAAE,CAeV"}
1
+ {"version":3,"file":"beneficiaries.validate.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.validate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACf,MAAM,oCAAoC,CAAC;AAM5C,wBAAgB,4BAA4B,CAC1C,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,MAAM,CAUR;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,cAAc,GAAG,SAAS,GACtC,cAAc,CAyBhB;AAED,wBAAgB,+BAA+B,CAC7C,sBAAsB,CAAC,EAAE,6BAA6B,GACrD,6BAA6B,CAuB/B;AAED,wBAAgB,gCAAgC,CAC9C,cAAc,CAAC,EAAE,MAAM,EAAE,GACxB,MAAM,EAAE,CAeV"}
@@ -3,6 +3,11 @@ interface AddPaginationParamsToUrlArgs {
3
3
  endpointUrl: URL;
4
4
  paginationSettings?: PaginationSettings;
5
5
  }
6
+ export declare function buildPaginationParams(paginationSettings?: PaginationSettings): URLSearchParams;
7
+ export declare function addSearchParamsToUrl({ url, searchParams, }: {
8
+ url: URL;
9
+ searchParams: URLSearchParams;
10
+ }): URL;
6
11
  export declare function addPaginationParamsToUrl({ endpointUrl, paginationSettings, }: AddPaginationParamsToUrlArgs): URL;
7
12
  export declare function serializePaginationResponse(paginationResponse: PaginationResponseDataObject): PaginationState | undefined;
8
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"api-pagination.d.ts","sourceRoot":"","sources":["../../../src/common/api-pagination/api-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAErD,UAAU,4BAA4B;IACpC,WAAW,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,kBAAkB,GACnB,EAAE,4BAA4B,GAAG,GAAG,CAYpC;AAED,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,4BAA4B,GAC/C,eAAe,GAAG,SAAS,CAY7B"}
1
+ {"version":3,"file":"api-pagination.d.ts","sourceRoot":"","sources":["../../../src/common/api-pagination/api-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAErD,UAAU,4BAA4B;IACpC,WAAW,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,wBAAgB,qBAAqB,CACnC,kBAAkB,CAAC,EAAE,kBAAkB,GACtC,eAAe,CASjB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,GAAG,EACH,YAAY,GACb,EAAE;IACD,GAAG,EAAE,GAAG,CAAC;IACT,YAAY,EAAE,eAAe,CAAC;CAC/B,GAAG,GAAG,CAMN;AAED,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,kBAAkB,GACnB,EAAE,4BAA4B,GAAG,GAAG,CAOpC;AAED,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,4BAA4B,GAC/C,eAAe,GAAG,SAAS,CAY7B"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QA2B5D;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,QA2B5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAKrB"}
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const t=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!t.hasAccessToken())throw new a;return t.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},m={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};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:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:m,MFA_METHODS:l,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"}});class g{constructor(){this.mfaPreference=l.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),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const p=g.getInstance(),h="https://embed.qonto.com",y="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",_={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,n=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(n)?n:u.SANDBOX}static getInstance(){return 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=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return _.production;{const e=_[this.environment];return Object.entries(e).reduce(((e,[n,t])=>({...e,[n]:t.replace("{branch}",`-${this.branch}`)})),{})}}}const w=I.getInstance(),b={requiresUI:!1};function E(e,{requiresUI:n}=b){const t=e?.uiParentElementId||p.getUIParentElementId();if(n&&!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=e?.mfaPreference||p.getMFAPreference();if(i){const e=(a=Object.values(l),w.isProductionEnvironment()?a.filter((e=>e!==l.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(w.isProductionEnvironment()&&i===l.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var a;const r=e?.debugMode||p.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||p.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:t,mfaPreference:i,debugMode:r,proxyRequestFunction:o,...e}}const A=Object.values(m);function k(e){if(!function(e){return A.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${A.join(", ")}.`);return e}function R(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&E(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&k(e.locale),e}class S{constructor(){this.currentLocale="en"}static getInstance(){return S.instance||(S.instance=new S),S.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const P=S.getInstance();const L={initialize:function(e){const{accessToken:n,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=R(e);n&&t.setAccessToken(n),i&&t.setStagingToken(i),o&&P.setLocale(o),a&&p.setSettings(a),r&&(w.setEnvironment(r),s&&w.setBranch(s))},logout:function(){t.clearAccessToken(),t.clearStagingToken(),P.setDefaultLocale()},constants:f},{initialize:v,logout:D,constants:O}=L;class N extends i{constructor(e){super();const n=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${n}`}}function U(){return"undefined"!=typeof window&&"undefined"!=typeof document}function C(){return!U()}function $({accessToken:e,stagingToken:n,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=n||t.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",P.getLocale()),r}function M(e){const n={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},t=JSON.stringify(n);return i=t,C()?Buffer.from(i).toString("base64"):btoa(i);var i}function F(e){return JSON.parse((n=e,C()?Buffer.from(n,"base64").toString("utf-8"):atob(n)));var n}var B;!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"}(B||(B={}));const q={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 j,x;function Y(e,n){const t=n.filter((n=>n.requiredIfPresent?!e[n.name]&&e[n.requiredIfPresent]:void 0===e[n.name])).map((e=>e.name));if(t.length>0)throw new s(t.map((e=>`Missing required parameter: ${e}`)))}function G(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function H(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function K(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"}(j||(j={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(x||(x={}));const z=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],V=[...z,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function X(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return Y(e,z),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(l),g=G({membershipId:n,organizationId:t,bankAccountId:i}),p=H({hasDailyLimit:a,hasTransactionLimit:r}),h=K({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=Q(u),T=J(m),_=[...f,...g,...p,...h,...y,...T];if(_.length>0)throw new s(_)}(e),e}(e):function(e){Y(e,V),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:l,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:y,hasAtmDailyLimit:T,atmDailyLimit:_,atmMonthlyLimit:I,address:w,cardDesign:b,typeOfPrint:E}=e,A=function(e){return Object.values(x).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(l),k=function(e){const n=null!=e&&"string"!=typeof e,t=!["print","embossed",void 0,null].includes(e);return n||t?['typeOfPrint must be one of "print", "embossed" or null']:[]}(E),R=G({membershipId:n,organizationId:t,bankAccountId:i}),S=H({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:T,shipToBusiness:h}),P=K({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:I}),L=Q(u),v=J(m),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,n){if(n)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(w,h),N=[...A,...R,...S,...P,...L,...v,...k,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function Q(e){const n=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&n?["activeDays must be an array of integers between 1 and 7"]:[]}function J(e){const n=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&n?["categories must be an array of strings"]:[]}class W extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const Z=[];for(let e=0;e<256;++e)Z.push((e+256).toString(16).slice(1));let ee;const ne=new Uint8Array(16);var te={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ie(e,n,t){if(te.randomUUID&&!e)return te.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!ee){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ee=crypto.getRandomValues.bind(crypto)}return ee(ne)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(Z[e[n+0]]+Z[e[n+1]]+Z[e[n+2]]+Z[e[n+3]]+"-"+Z[e[n+4]]+Z[e[n+5]]+"-"+Z[e[n+6]]+Z[e[n+7]]+"-"+Z[e[n+8]]+Z[e[n+9]]+"-"+Z[e[n+10]]+Z[e[n+11]]+Z[e[n+12]]+Z[e[n+13]]+Z[e[n+14]]+Z[e[n+15]]).toLowerCase()}(i)}class ae{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const n=new URL(e.iframeUrl);this.targetOrigin=`${n.protocol}//${n.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new W(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,n)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const t=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),n(new W(`Could not install the authentication UI because the timeout of ${t}ms was reached.\nPlease make sure the application can reach the Internet.`))}),t),a=n=>{n.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new W("Attempted to perform an Embed operation without having the authentication UI initialized."));const n=function({actionId:e,actionData:n}){const t=p.getMFAPreference();return{actionId:e,actionData:{...n,scaPreference:n.scaPreference||t,idempotencyKey:n.idempotencyKey||ie()}}}(e);return new Promise(((e,t)=>{const i=a=>{if(a.data?.actionId===n.actionId){if("error"===a.data.status)return this.removeMessageListener(n.actionId,i),t(new W(`An error occurred when performing the action ${n.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(n.actionId,i),e(a.data.payload)}};this.addMessageListener(n.actionId,i),this.iframe?.contentWindow?.postMessage(n,this.targetOrigin)}))}addMessageListener(e,n){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(n),window.addEventListener("message",n)}removeMessageListener(e,n){const t=this.messageListeners.get(e);if(t){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),window.removeEventListener("message",n))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function re({accessToken:e,stagingToken:n,locale:t,debugMode:i}){const a=i||!1,r=t||P.getLocale(),s=w.getEnvironmentUrls().IFRAME_URL,o=n?`;staging_token=${encodeURIComponent(n)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function se({parentElementId:e,iframeUrl:n}){return new ae({parentElementId:e,iframeUrl:n}).initialize()}function oe(e){return"virtual"===e.cardLevel?function(e){const n=de(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ie(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel}}}}}(e):function(e){const n=de(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ie(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ce(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 de(e){const n=Object.values(q);return(e||[]).filter((e=>n.includes(e)))}const ue={getCards:async function({membershipId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=w.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new N(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:t});return a.map((e=>ce(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:t});return ce(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});X(e.cardSettings);const s=re({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),o=await se({iframeUrl:s,parentElementId:i}),c=oe(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ce(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=G({cardId:e.cardId});if(n.length>0)throw new s(n)}(e.cardSettings);const o=re({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),d=await se({iframeUrl:o,parentElementId:i}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),m=await d.postMessage(u);return d.destroy(),ce(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:n,accessToken:t,stagingToken:i,debugMode:a,mfaPreference:o}=E(e.operationSettings,{requiresUI:!0}),c=t||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=G({cardId:e.cardId});if(n.length>0)throw new s(n);let t={};void 0!==e.allowPinReveal&&(t={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(t={...t,allowBlocking:e.allowBlocking});const i=H(t);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:n,stagingToken:t,mfaPreference:i}=e,a={method:"GET",headers:$({accessToken:n,stagingToken:t,mfaPreference:i})},r=w.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(!s.ok)throw o.errors?new N(o.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:u,allowBlocking:m}=e.cardSettings,l=function(e,n){const t=new URL(e);return"boolean"==typeof n.allowPinReveal&&t.searchParams.set("canSeePin",n.allowPinReveal.toString()),"boolean"==typeof n.allowBlocking&&t.searchParams.set("canBlock",n.allowBlocking.toString()),!0===n.debugMode&&t.searchParams.set("debug",n.debugMode.toString()),t.toString()}(d,{allowPinReveal:u,allowBlocking:m,debugMode:a}),f=await se({iframeUrl:l,parentElementId:n});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},me=ue;function le({endpointUrl:e,paginationSettings:n}){const t=new URL(e);return n?.page&&t.searchParams.set("page",n.page.toString()),n?.itemsPerPage&&t.searchParams.set("per_page",n.itemsPerPage.toString()),t}function fe(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 ge(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 pe(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 he="/v2/sepa/beneficiaries";async function ye({accessToken:e,stagingToken:n,beneficiaryId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}function Te({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${he}/${e.id}`,options:c}}async function _e({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=Te({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}),{beneficiary:s}=await async function({path:e,options:n}){const t=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,i=await fetch(t,{...n,headers:$(n.headers),body:JSON.stringify(n.body)}),a=await i.json();if(!i.ok)throw a.errors?new N(a.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${a.code}: ${a.detail}`);return a}(r);return s}const Ie=[{name:"name"},{name:"iban"}];const we={getBeneficiaries:async function(e){const n=e?.accessToken||r(),t=await async function({paginationSettings:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=le({endpointUrl:new URL(w.getEnvironmentUrls().THIRD_PARTY_API_URL+he),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=t.beneficiaries.map((e=>ge(e))),a=fe(t.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:n,stagingToken:t}){const i=n||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),ge(await ye({beneficiaryId:e,accessToken:i,stagingToken:t}))},addBeneficiary:async function({beneficiary:e,accessToken:n,stagingToken:t}){const i=n||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");Y(e,Ie);const n=G({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(n.length>0)throw new s(n)}(e);return ge(await async function({beneficiary:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:ie()}),body:JSON.stringify({beneficiary:pe(e)})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:t}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){const{id:n,name:t,email:i,activityTag:a}=e;if(!n)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!t&&!i&&!a)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=G({name:t,email:i,activityTag:a});if(r.length>0)throw new s(r);return{id:n,name:t,email:i,activityTag:a}}(e),{stagingToken:i,idempotencyKey:a,mfaPreference:o,proxyRequestFunction:c}=E(n),d={beneficiaryParamsBeingEdited:t,stagingToken:i,idempotencyKey:a,mfaPreference:o};if(c){const e=M(Te(d));return ge(F(await c(e)).body.beneficiary)}{const e=n?.accessToken||r();return ge(await _e({...d,accessToken:e}))}},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i=n||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:n,stagingToken:t}){const i={method:"PATCH",headers:$({accessToken:n,stagingToken:t}),body:JSON.stringify({ids:e})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${he}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:t})).map(ge)}},be="/v2/sepa/bulk_transfers";function Ee(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Ae(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 ke(e){const n=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:n,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}const Re="/v2/sepa/transfers";const Se=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Pe({sepaTransferSettings:e,operationSettings:n}){if(e?.beneficiary)return e.beneficiary;return ge(await ye({beneficiaryId:e?.beneficiaryId,accessToken:n?.accessToken,stagingToken:n?.stagingToken}))}const Le="browser",ve="server";class De extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Le:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case ve: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 Oe={getSepaTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),i=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=le({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),a=i.transfers.map(Ae),s=fe(i.meta);return{transfers:a,...s?{meta:s}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);return Ae(await async function({accessToken:e,stagingToken:n,sepaTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.transfer}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),o=n?.idempotencyKey||ie();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(Y(e,Se),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const n=[...G({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...K({amount:e.amount})].flat();if(n.length>0)throw new s(n);if(e.amount>3e4&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u={...e,beneficiary:await Pe({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(u.beneficiary?.trusted)d=await async function({transfer:e,accessToken:n,stagingToken:t,idempotencyKey:i}){const a=ke(e),r={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new N(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:u,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if(!U())throw new De(Le);const{uiParentElementId:e,debugMode:t}=E(n,{requiresUI:!0});let r;try{const n=re({accessToken:i,stagingToken:a||void 0,debugMode:t});r=await se({iframeUrl:n,parentElementId:e});const s=ke(u);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return Ae(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t})},a=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${Re}/${e}/cancel`,r=await fetch(a,i);if(204!==r.status){const e=await r.json();if(e.errors)throw new N(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken})},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),{stagingToken:i,paginationSettings:a}=E(n||{}),s=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=le({endpointUrl:new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${be}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:t,stagingToken:i,paginationSettings:a}),o=s.bulkTransfers?.map(Ee),c=fe(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),{stagingToken:i}=E(n||{}),a=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return Ee(await async function({accessToken:e,stagingToken:n,bulkTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=new URL(`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}${be}/${t}`),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:t,stagingToken:i,bulkTransferId:a}))}}};e.beneficiaries=we,e.cards=me,e.constants=O,e.initialize=v,e.logout=D,e.sepaTransfers=Oe}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const t=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!t.hasAccessToken())throw new a;return t.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},m={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},f={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};var l=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:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:m,MFA_METHODS:f,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"}});class g{constructor(){this.mfaPreference=f.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),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=f.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const p=g.getInstance(),h="https://embed.qonto.com",y="https://embed-js{branch}.staging.qonto.co",T="https://embed.dev.qonto.co",_={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:T,IFRAME_URL:`${T}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,n=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(n)?n:u.SANDBOX}static getInstance(){return 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=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return _.production;{const e=_[this.environment];return Object.entries(e).reduce(((e,[n,t])=>({...e,[n]:t.replace("{branch}",`-${this.branch}`)})),{})}}}const b=I.getInstance(),w={requiresUI:!1};function E(e,{requiresUI:n}=w){const t=e?.uiParentElementId||p.getUIParentElementId();if(n&&!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const i=e?.mfaPreference||p.getMFAPreference();if(i){const e=(a=Object.values(f),b.isProductionEnvironment()?a.filter((e=>e!==f.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(b.isProductionEnvironment()&&i===f.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var a;const r=e?.debugMode||p.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||p.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:t,mfaPreference:i,debugMode:r,proxyRequestFunction:o}}const k=Object.values(m);function A(e){if(!function(e){return k.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${k.join(", ")}.`);return e}function S(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&E(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&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 L=R.getInstance();const v={initialize:function(e){const{accessToken:n,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=S(e);n&&t.setAccessToken(n),i&&t.setStagingToken(i),o&&L.setLocale(o),a&&p.setSettings(a),r&&(b.setEnvironment(r),s&&b.setBranch(s))},logout:function(){t.clearAccessToken(),t.clearStagingToken(),L.setDefaultLocale(),p.clearSettings()},constants:l},{initialize:P,logout:D,constants:O}=v;class N extends i{constructor(e){super();const n=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${n}`}}function U(){return"undefined"!=typeof window&&"undefined"!=typeof document}function C(){return!U()}function $({accessToken:e,stagingToken:n,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=n||t.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",L.getLocale()),r}async function M({path:e,options:n}){const t=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,i=await fetch(t,{...n,headers:$(n.headers),body:JSON.stringify(n.body)}),a=await i.json();if(!i.ok)throw a.errors?new N(a.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${a.code}: ${a.detail}`);return a}function F(e){const n={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},t=JSON.stringify(n);return i=t,C()?Buffer.from(i).toString("base64"):btoa(i);var i}function q(e){return JSON.parse((n=e,C()?Buffer.from(n,"base64").toString("utf-8"):atob(n)));var n}var B;!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"}(B||(B={}));const x={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 j,G;function K(e,n){const t=n.filter((n=>n.requiredIfPresent?!e[n.name]&&e[n.requiredIfPresent]:void 0===e[n.name])).map((e=>e.name));if(t.length>0)throw new s(t.map((e=>`Missing required parameter: ${e}`)))}function Y(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function H(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function z(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"}(j||(j={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(G||(G={}));const V=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],X=[...V,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function Q(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return K(e,V),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:f}=e,l=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(f),g=Y({membershipId:n,organizationId:t,bankAccountId:i}),p=H({hasDailyLimit:a,hasTransactionLimit:r}),h=z({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=W(u),T=J(m),_=[...l,...g,...p,...h,...y,...T];if(_.length>0)throw new s(_)}(e),e}(e):function(e){K(e,X),function(e){const{membershipId:n,organizationId:t,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:m,cardLevel:f,hasNfcOption:l,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:y,hasAtmDailyLimit:T,atmDailyLimit:_,atmMonthlyLimit:I,address:b,cardDesign:w,typeOfPrint:E}=e,k=function(e){return Object.values(G).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(f),A=function(e){const n=null!=e&&"string"!=typeof e,t=!["print","embossed",void 0,null].includes(e);return n||t?['typeOfPrint must be one of "print", "embossed" or null']:[]}(E),S=Y({membershipId:n,organizationId:t,bankAccountId:i}),R=H({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:l,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:T,shipToBusiness:h}),L=z({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:I}),v=W(u),P=J(m),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(w),O=function(e,n){if(n)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(b,h),N=[...k,...S,...R,...L,...v,...P,...A,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function W(e){const n=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&n?["activeDays must be an array of integers between 1 and 7"]:[]}function J(e){const n=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&n?["categories must be an array of strings"]:[]}class Z extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const ee=[];for(let e=0;e<256;++e)ee.push((e+256).toString(16).slice(1));let ne;const te=new Uint8Array(16);var ie={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ae(e,n,t){if(ie.randomUUID&&!e)return ie.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!ne){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ne=crypto.getRandomValues.bind(crypto)}return ne(te)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(ee[e[n+0]]+ee[e[n+1]]+ee[e[n+2]]+ee[e[n+3]]+"-"+ee[e[n+4]]+ee[e[n+5]]+"-"+ee[e[n+6]]+ee[e[n+7]]+"-"+ee[e[n+8]]+ee[e[n+9]]+"-"+ee[e[n+10]]+ee[e[n+11]]+ee[e[n+12]]+ee[e[n+13]]+ee[e[n+14]]+ee[e[n+15]]).toLowerCase()}(i)}class re{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const n=new URL(e.iframeUrl);this.targetOrigin=`${n.protocol}//${n.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new Z(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,n)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const t=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),n(new Z(`Could not install the authentication UI because the timeout of ${t}ms was reached.\nPlease make sure the application can reach the Internet.`))}),t),a=n=>{n.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new Z("Attempted to perform an Embed operation without having the authentication UI initialized."));const n=function({actionId:e,actionData:n}){const t=p.getMFAPreference();return{actionId:e,actionData:{...n,scaPreference:n.scaPreference||t,idempotencyKey:n.idempotencyKey||ae()}}}(e);return new Promise(((e,t)=>{const i=a=>{if(a.data?.actionId===n.actionId){if("error"===a.data.status)return this.removeMessageListener(n.actionId,i),t(new Z(`An error occurred when performing the action ${n.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(n.actionId,i),e(a.data.payload)}};this.addMessageListener(n.actionId,i),this.iframe?.contentWindow?.postMessage(n,this.targetOrigin)}))}addMessageListener(e,n){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(n),window.addEventListener("message",n)}removeMessageListener(e,n){const t=this.messageListeners.get(e);if(t){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),window.removeEventListener("message",n))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function se({accessToken:e,stagingToken:n,locale:t,debugMode:i}){const a=i||!1,r=t||L.getLocale(),s=b.getEnvironmentUrls().IFRAME_URL,o=n?`;staging_token=${encodeURIComponent(n)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function oe({parentElementId:e,iframeUrl:n}){return new re({parentElementId:e,iframeUrl:n}).initialize()}function ce(e){return"virtual"===e.cardLevel?function(e){const n=ue(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ae(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel}}}}}(e):function(e){const n=ue(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:ae(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:n,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function de(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 ue(e){const n=Object.values(x);return(e||[]).filter((e=>n.includes(e)))}const me={getCards:async function({membershipId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=b.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 N(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:t});return a.map((e=>de(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:n,stagingToken:t}){try{const i=n||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:$({accessToken:n,stagingToken:t})},a=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:t});return de(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});Q(e.cardSettings);const s=se({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),o=await oe({iframeUrl:s,parentElementId:i}),c=ce(e.cardSettings),d=await o.postMessage(c);return o.destroy(),de(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const n=r(),{uiParentElementId:i,debugMode:a}=E(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=Y({cardId:e.cardId});if(n.length>0)throw new s(n)}(e.cardSettings);const o=se({accessToken:n,stagingToken:t.getStagingToken()||void 0,debugMode:a}),d=await oe({iframeUrl:o,parentElementId:i}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),m=await d.postMessage(u);return d.destroy(),de(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:n,accessToken:t,stagingToken:i,debugMode:a,mfaPreference:o}=E(e.operationSettings,{requiresUI:!0}),c=t||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const n=Y({cardId:e.cardId});if(n.length>0)throw new s(n);let t={};void 0!==e.allowPinReveal&&(t={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(t={...t,allowBlocking:e.allowBlocking});const i=H(t);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:n,stagingToken:t,mfaPreference:i}=e,a={method:"GET",headers:$({accessToken:n,stagingToken:t,mfaPreference:i})},r=b.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(!s.ok)throw o.errors?new N(o.errors.map((e=>`${e.code}: ${e.detail}`))):new N(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:u,allowBlocking:m}=e.cardSettings,f=function(e,n){const t=new URL(e);return"boolean"==typeof n.allowPinReveal&&t.searchParams.set("canSeePin",n.allowPinReveal.toString()),"boolean"==typeof n.allowBlocking&&t.searchParams.set("canBlock",n.allowBlocking.toString()),!0===n.debugMode&&t.searchParams.set("debug",n.debugMode.toString()),t.toString()}(d,{allowPinReveal:u,allowBlocking:m,debugMode:a}),l=await oe({iframeUrl:f,parentElementId:n});return{destroyEmbedUI:()=>{l.destroy()}}}catch(e){return Promise.reject(e)}}},fe=me;function le(e){const n=new URLSearchParams;return e?.page&&n.append("page",e.page.toString()),e?.itemsPerPage&&n.append("per_page",e.itemsPerPage.toString()),n}function ge({endpointUrl:e,paginationSettings:n}){return function({url:e,searchParams:n}){const t=new URL(e.toString());for(const[e,i]of n.entries())t.searchParams.append(e,i);return t}({url:new URL(e),searchParams:le(n)})}function pe(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 he(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 ye(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 Te="/v2/sepa/beneficiaries";function _e({paginationSettings:e,accessToken:n,stagingToken:t}){const i={method:"GET",headers:{accessToken:n,stagingToken:t}},a=le(e),r=a.size?`?${a.toString()}`:"";return{path:`${Te}${r}`,options:i}}function Ie({beneficiaryId:e,accessToken:n,stagingToken:t}){return{path:`${Te}/${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:t}}}}async function be({accessToken:e,stagingToken:n,beneficiaryId:t}){const i=Ie({beneficiaryId:t,accessToken:e,stagingToken:n}),{beneficiary:a}=await M(i);return a}function we({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i=ae()}){return{path:Te,options:{method:"POST",headers:{accessToken:n,stagingToken:t,idempotencyKey:i},body:{beneficiary:ye(e)}}}}function Ee({beneficiaryIds:e,accessToken:n,stagingToken:t}){return{path:`${Te}/untrust`,options:{method:"PATCH",headers:{accessToken:n,stagingToken:t},body:{ids:e}}}}function ke({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${Te}/${e.id}`,options:c}}const Ae=[{name:"name"},{name:"iban"}];const Se={getBeneficiaries:async function(e){const{stagingToken:n,proxyRequestFunction:t,accessToken:i,paginationSettings:a}=E(e?.operationSettings||{});if(t){const e=F(_e({paginationSettings:a})),n=q(await t(e)),i=n.body.beneficiaries.map((e=>he(e))),r=pe(n.body.meta);return{beneficiaries:i,...r?{meta:r}:{}}}{const e=i||r(),t=await async function({paginationSettings:e,accessToken:n,stagingToken:t}){const i=_e({paginationSettings:e,accessToken:n,stagingToken:t}),{beneficiaries:a,meta:r}=await M(i);return{beneficiaries:a,meta:r}}({accessToken:e,stagingToken:n,paginationSettings:a}),s=t.beneficiaries.map((e=>he(e))),o=pe(t.meta);return{beneficiaries:s,...o?{meta:o}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:i,accessToken:a,stagingToken:o}=E(n||{});if(i){const e=F(Ie({beneficiaryId:t}));return he(q(await i(e)).body.beneficiary)}{const e=a||r();return he(await be({beneficiaryId:t,accessToken:e,stagingToken:o}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");K(e,Ae);const n=Y({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(n.length>0)throw new s(n);return e}(e),{proxyRequestFunction:i,accessToken:a,stagingToken:o,idempotencyKey:c}=E(n||{});if(i){const e=F(we({beneficiary:t,idempotencyKey:c}));return he(q(await i(e)).body.beneficiary)}{const e=a||r(),n=await async function({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i=ae()}){const a=we({beneficiary:e,accessToken:n,stagingToken:t,idempotencyKey:i}),{beneficiary:r}=await M(a);return r}({beneficiary:t,accessToken:e,stagingToken:o,idempotencyKey:c});return he(n)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){const{id:n,name:t,email:i,activityTag:a}=e||{};if(!n)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!t&&!i&&!a)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=Y({name:t,email:i,activityTag:a});if(r.length>0)throw new s(r);return{id:n,name:t,email:i,activityTag:a}}(e),{stagingToken:i,idempotencyKey:a,mfaPreference:o,proxyRequestFunction:c}=E(n),d={beneficiaryParamsBeingEdited:t,idempotencyKey:a,mfaPreference:o};if(c){const e=F(ke(d));return he(q(await c(e)).body.beneficiary)}{const e=n?.accessToken||r(),t=await async function({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=ke({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:t,idempotencyKey:i,mfaPreference:a}),{beneficiary:s}=await M(r);return s}({...d,accessToken:e,stagingToken:i});return he(t)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:n}){const t=function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:i,accessToken:a,stagingToken:o}=E(n||{});if(i){const e=F(Ee({beneficiaryIds:t}));return q(await i(e)).body.beneficiaries.map(he)}{const e=a||r(),n=await async function({beneficiaryIds:e,accessToken:n,stagingToken:t}){const i=Ee({beneficiaryIds:e,accessToken:n,stagingToken:t}),{beneficiaries:a}=await M(i);return a}({beneficiaryIds:t,accessToken:e,stagingToken:o});return n.map(he)}}},Re=Se,Le="/v2/sepa/bulk_transfers";function ve(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Pe(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 De(e){const n=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:n,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}const Oe="/v2/sepa/transfers";const Ne=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Ue({sepaTransferSettings:e,operationSettings:n}){if(e?.beneficiary)return e.beneficiary;return he(await be({beneficiaryId:e?.beneficiaryId,accessToken:n?.accessToken,stagingToken:n?.stagingToken}))}const Ce="browser",$e="server";class Me extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ce:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case $e: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 Fe={getSepaTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),i=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=ge({endpointUrl:new URL(`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Oe}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),a=i.transfers.map(Pe),s=pe(i.meta);return{transfers:a,...s?{meta:s}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);return Pe(await async function({accessToken:e,stagingToken:n,sepaTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Oe}/${t}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.transfer}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const i=n?.accessToken||r(),a=n?.stagingToken||t.getStagingToken(),o=n?.idempotencyKey||ae();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(K(e,Ne),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const n=[...Y({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...z({amount:e.amount})].flat();if(n.length>0)throw new s(n);if(e.amount>3e4&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u={...e,beneficiary:await Ue({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(u.beneficiary?.trusted)d=await async function({transfer:e,accessToken:n,stagingToken:t,idempotencyKey:i}){const a=De(e),r={method:"POST",headers:$({accessToken:n,stagingToken:t,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Oe}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new N(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:u,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if(!U())throw new Me(Ce);const{uiParentElementId:e,debugMode:t}=E(n,{requiresUI:!0});let r;try{const n=se({accessToken:i,stagingToken:a||void 0,debugMode:t});r=await oe({iframeUrl:n,parentElementId:e});const s=De(u);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return Pe(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),i=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:n,stagingToken:t}){const i={method:"POST",headers:$({accessToken:n,stagingToken:t})},a=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Oe}/${e}/cancel`,r=await fetch(a,i);if(204!==r.status){const e=await r.json();if(e.errors)throw new N(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:i,accessToken:t,stagingToken:n?.stagingToken})},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:n}=e||{},t=n?.accessToken||r(),{stagingToken:i,paginationSettings:a}=E(n||{}),s=await async function({accessToken:e,stagingToken:n,paginationSettings:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=ge({endpointUrl:new URL(`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Le}`),paginationSettings:t}),r=await fetch(a,i);if(!r.ok)throw new N("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:t,stagingToken:i,paginationSettings:a}),o=s.bulkTransfers?.map(ve),c=pe(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:n}){const t=n?.accessToken||r(),{stagingToken:i}=E(n||{}),a=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return ve(await async function({accessToken:e,stagingToken:n,bulkTransferId:t}){const i={method:"GET",headers:$({accessToken:e,stagingToken:n})},a=new URL(`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Le}/${t}`),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:t,stagingToken:i,bulkTransferId:a}))}}};e.beneficiaries=Re,e.cards=fe,e.constants=O,e.initialize=P,e.logout=D,e.sepaTransfers=Fe}));
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The paymentLinks namespace contains all the functions related to paymentLinks
3
+ * operations. It can be accessed like this:
4
+ * ```ts
5
+ * import { paymentLinks } from '@qonto/embed-sdk/paymentLinks';
6
+ * ```
7
+ *
8
+ * Then, the paymentLinks object contains the functions to perform paymentLinks
9
+ * operations:
10
+ * ```ts
11
+ * const url = paymentLinks.getCreatePaymentLinkFlowUrl({accessToken, items, redirectUrl});
12
+ * window.open(url, '_blank');
13
+ * ```
14
+ */
15
+ export declare const paymentLinks: {
16
+ getCreatePaymentLinkFlowUrl: ({ paymentLinkSettings, operationSettings, }: import("./payment-links.types").PaymentLinkParams<import("./payment-links.types").CreatePaymentLinkSettings>) => string;
17
+ };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment-links/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY;;CAAqC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { CreatePaymentLinkSettings, PaymentLinkParams } from './payment-links.types';
2
+ /**
3
+ * Generates the URL for initiating a payment link creation flow with specified items.
4
+ *
5
+ * @param params - An object containing:
6
+ * - paymentLinkSettings: An object containing:
7
+ * - items: An array of items to be included in the payment link. Each item must conform to the Item type and will be validated.
8
+ * - redirectUrl: The URL to which the user will be redirected after completing the payment link flow. This will be validated for correctness.
9
+ * - operationSettings (optional): An object containing:
10
+ * - accessToken: The authentication token. If not provided, the function requires that authentication has already been initialized.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const url = getCreatePaymentLinkFlowUrl({
15
+ * paymentLinkSettings: {
16
+ * items: [{ id: '1', title: 'Item 1', type: 'product', quantity: 1, measureUnit: 'unit', unitPrice: { currency: 'EUR', value: 10 }, vatRate: '20' }],
17
+ * redirectUrl: 'https://www.example.com',
18
+ * },
19
+ * operationSettings: {
20
+ * accessToken: 'your-access-token',
21
+ * },
22
+ * });
23
+ * ```
24
+ * @returns The full URL as a string, which can be used to launch the payment link creation flow in an iframe or browser.
25
+ *
26
+ * @throws \{InvalidParametersError\} If the provided items array or redirectUrl is invalid.
27
+ * @throws \{AuthenticationError\} If the access token is missing or invalid, and initialize has not been called.
28
+ *
29
+ * @remarks Ensure initialize has been called before calling this function if you do not provide an accessToken.
30
+ */
31
+ export declare const getCreatePaymentLinkFlowUrl: ({ paymentLinkSettings, operationSettings, }: PaymentLinkParams<CreatePaymentLinkSettings>) => string;
32
+ //# sourceMappingURL=payment-links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-links.d.ts","sourceRoot":"","sources":["../../src/payment-links/payment-links.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAU/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,2BAA2B,GAAI,6CAGzC,iBAAiB,CAAC,yBAAyB,CAAC,WAe9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const paymentLinks: {
2
+ getCreatePaymentLinkFlowUrl: ({ paymentLinkSettings, operationSettings, }: import("./payment-links.types").PaymentLinkParams<import("./payment-links.types").CreatePaymentLinkSettings>) => string;
3
+ };
4
+ export { paymentLinks };
5
+ //# sourceMappingURL=payment-links.public-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-links.public-api.d.ts","sourceRoot":"","sources":["../../src/payment-links/payment-links.public-api.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;CAEjB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=payment-links.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-links.test.d.ts","sourceRoot":"","sources":["../../src/payment-links/payment-links.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { OperationSettings } from '@validation/operation-settings-validation';
2
+ export interface Item {
3
+ id: string;
4
+ title: string;
5
+ type: string;
6
+ description?: string;
7
+ quantity: number;
8
+ measureUnit: string;
9
+ unitPrice: Amount<string>;
10
+ vatRate: string;
11
+ }
12
+ interface Amount<T = number> {
13
+ currency: string;
14
+ value: T;
15
+ }
16
+ export interface CreatePaymentLinkSettings {
17
+ items?: Item[];
18
+ redirectUrl: string;
19
+ }
20
+ export interface PaymentLinkParams<T> {
21
+ paymentLinkSettings: T;
22
+ operationSettings?: OperationSettings;
23
+ }
24
+ export declare const LINK_TYPES: {
25
+ GOOD: string;
26
+ SERVICE: string;
27
+ };
28
+ export {};
29
+ //# sourceMappingURL=payment-links.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-links.types.d.ts","sourceRoot":"","sources":["../../src/payment-links/payment-links.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAEnF,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,MAAM,CAAC,CAAC,GAAG,MAAM;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,mBAAmB,EAAE,CAAC,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,eAAO,MAAM,UAAU;;;CAGtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const validateCurrency: (currency: string) => void;
2
+ //# sourceMappingURL=currency.validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.validation.d.ts","sourceRoot":"","sources":["../../../src/payment-links/validation/currency.validation.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,SAMhD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type Item } from '../payment-links.types';
2
+ export declare function validateItems(items: Item[] | undefined): never[] | undefined;
3
+ export declare function validateRedirectUrl(redirectUrl: string): void;
4
+ export declare const validateType: (type: string) => void;
5
+ //# sourceMappingURL=payment-links.validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-links.validate.d.ts","sourceRoot":"","sources":["../../../src/payment-links/validation/payment-links.validate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAgB/D,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,uBAqCtD;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,QAetD;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,SAOxC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const validateUnit: (unit: string) => void;
2
+ //# sourceMappingURL=unit.validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.validation.d.ts","sourceRoot":"","sources":["../../../src/payment-links/validation/unit.validation.ts"],"names":[],"mappings":"AAgDA,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,SAMxC,CAAC"}
@@ -1 +1 @@
1
- import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{addPaginationParamsToUrl as i}from"../common/api-pagination/api-pagination.js";import{serializeToNewBeneficiaryDataObject as r}from"./beneficiaries.serializer.js";import{buildRequestHeaders as a,makeNetworkCall as o}from"../common/network/network.js";import t from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";const s="/v2/sepa/beneficiaries";async function c({paginationSettings:r,accessToken:o,stagingToken:t}){const c={method:"GET",headers:a({accessToken:o,stagingToken:t})},m=new URL(n.getEnvironmentUrls().THIRD_PARTY_API_URL+s),f=i({endpointUrl:m,paginationSettings:r}),d=await fetch(f,c),g=await d.json();if(g.errors)throw new e(g.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:g.beneficiaries,meta:g.meta}}async function m({accessToken:i,stagingToken:r,beneficiaryId:o}){const t={method:"GET",headers:a({accessToken:i,stagingToken:r})},c=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${s}/${o}`,m=await fetch(c,t),f=await m.json();if(f.errors)throw new e(f.errors.map((e=>`${e.code}: ${e.detail}`)));return f.beneficiary}async function f({beneficiary:i,accessToken:o,stagingToken:c}){const m={method:"POST",headers:a({accessToken:o,stagingToken:c,idempotencyKey:t()}),body:JSON.stringify({beneficiary:r(i)})},f=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${s}`,d=await fetch(f,m),g=await d.json();if(g.errors)throw new e(g.errors.map((e=>`${e.code}: ${e.detail}`)));return g.beneficiary}async function d({beneficiaryIds:i,accessToken:r,stagingToken:o}){const t={method:"PATCH",headers:a({accessToken:r,stagingToken:o}),body:JSON.stringify({ids:i})},c=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${s}/untrust`,m=await fetch(c,t),f=await m.json();if(f.errors)throw new e(f.errors.map((e=>`${e.code}: ${e.detail}`)));return f.beneficiaries}function g({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:i,idempotencyKey:r,mfaPreference:a}){const{name:o,email:t,activityTag:c}=e,m={method:"PATCH",headers:{accessToken:n,stagingToken:i,idempotencyKey:r,mfaPreference:a},body:{beneficiary:{name:o,email:t,activity_tag:c}}};return{path:`${s}/${e.id}`,options:m}}async function T({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:i,idempotencyKey:r,mfaPreference:a}){const t=g({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:i,idempotencyKey:r,mfaPreference:a}),{beneficiary:s}=await o(t);return s}export{f as addBeneficiary,c as getBeneficiaries,m as getBeneficiary,g as prepareUpdateBeneficiaryCall,d as untrustBeneficiaries,T as updateBeneficiary};
1
+ import{buildPaginationParams as e}from"../common/api-pagination/api-pagination.js";import{serializeToNewBeneficiaryDataObject as n}from"./beneficiaries.serializer.js";import{makeNetworkCall as i}from"../common/network/network.js";import a from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";const s="/v2/sepa/beneficiaries";function o({paginationSettings:n,accessToken:i,stagingToken:a}){const o={method:"GET",headers:{accessToken:i,stagingToken:a}},t=e(n),c=t.size?`?${t.toString()}`:"";return{path:`${s}${c}`,options:o}}async function t({paginationSettings:e,accessToken:n,stagingToken:a}){const s=o({paginationSettings:e,accessToken:n,stagingToken:a}),{beneficiaries:t,meta:c}=await i(s);return{beneficiaries:t,meta:c}}function c({beneficiaryId:e,accessToken:n,stagingToken:i}){return{path:`${s}/${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:i}}}}async function r({accessToken:e,stagingToken:n,beneficiaryId:a}){const s=c({beneficiaryId:a,accessToken:e,stagingToken:n}),{beneficiary:o}=await i(s);return o}function g({beneficiary:e,accessToken:i,stagingToken:o,idempotencyKey:t=a()}){return{path:s,options:{method:"POST",headers:{accessToken:i,stagingToken:o,idempotencyKey:t},body:{beneficiary:n(e)}}}}async function T({beneficiary:e,accessToken:n,stagingToken:s,idempotencyKey:o=a()}){const t=g({beneficiary:e,accessToken:n,stagingToken:s,idempotencyKey:o}),{beneficiary:c}=await i(t);return c}function f({beneficiaryIds:e,accessToken:n,stagingToken:i}){return{path:`${s}/untrust`,options:{method:"PATCH",headers:{accessToken:n,stagingToken:i},body:{ids:e}}}}async function y({beneficiaryIds:e,accessToken:n,stagingToken:a}){const s=f({beneficiaryIds:e,accessToken:n,stagingToken:a}),{beneficiaries:o}=await i(s);return o}function d({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:i,idempotencyKey:a,mfaPreference:o}){const{name:t,email:c,activityTag:r}=e,g={method:"PATCH",headers:{accessToken:n,stagingToken:i,idempotencyKey:a,mfaPreference:o},body:{beneficiary:{name:t,email:c,activity_tag:r}}};return{path:`${s}/${e.id}`,options:g}}async function k({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:a,idempotencyKey:s,mfaPreference:o}){const t=d({beneficiaryParamsBeingEdited:e,accessToken:n,stagingToken:a,idempotencyKey:s,mfaPreference:o}),{beneficiary:c}=await i(t);return c}export{T as addBeneficiary,t as getBeneficiaries,r as getBeneficiary,g as prepareAddBeneficiaryCall,o as prepareGetBeneficiariesCall,c as prepareGetBeneficiaryCall,f as prepareUntrustBeneficiaryCall,d as prepareUpdateBeneficiaryCall,y as untrustBeneficiaries,k as updateBeneficiary};
@@ -1 +1 @@
1
- import"../common/auth/auth.js";import{validatePresenceOfAuthToken as e}from"../common/auth/auth.validate.js";import{untrustBeneficiaries as n,updateBeneficiary as i,addBeneficiary as a,getBeneficiary as t,getBeneficiaries as o,prepareUpdateBeneficiaryCall as s}from"./beneficiaries.api.js";import{serializeBeneficiary as c}from"./beneficiaries.serializer.js";import{validateTrustBeneficiariesParams as r,validateUpdateBeneficiaryParams as m,validateAddBeneficiaryParams as f,validateGetBeneficiaryParams as g}from"./beneficiaries.validate.js";import{serializePaginationResponse as p}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";import{validateOperationSettingsParams as y}from"../validation/operation-settings-validation.js";import{encodeNetworkCall as k,decodeNetworkResponse as u}from"../common/network/network.js";async function T(n){const i=n?.accessToken||e(),a=await o({accessToken:i,stagingToken:n?.stagingToken,paginationSettings:n?.paginationSettings}),t=a.beneficiaries.map((e=>c(e))),s=p(a.meta);return{beneficiaries:t,...s?{meta:s}:{}}}async function d({beneficiaryId:n,accessToken:i,stagingToken:a}){const o=i||e();g(n);const s=await t({beneficiaryId:n,accessToken:o,stagingToken:a});return c(s)}async function b({beneficiary:n,accessToken:i,stagingToken:t}){const o=i||e();f(n);const s=await a({beneficiary:n,accessToken:o,stagingToken:t});return c(s)}async function j({beneficiarySettings:n,operationSettings:a}){const t=m(n),{stagingToken:o,idempotencyKey:r,mfaPreference:f,proxyRequestFunction:g}=y(a),p={beneficiaryParamsBeingEdited:t,stagingToken:o,idempotencyKey:r,mfaPreference:f};if(g){const e=s(p),n=k(e),i=await g(n),a=u(i);return c(a.body.beneficiary)}{const n=a?.accessToken||e(),t=await i({...p,accessToken:n});return c(t)}}async function l({beneficiaryIds:i,accessToken:a,stagingToken:t}){const o=a||e();r(i);return(await n({beneficiaryIds:i,accessToken:o,stagingToken:t})).map(c)}export{b as addBeneficiary,T as getBeneficiaries,d as getBeneficiary,l as untrustBeneficiaries,j as updateBeneficiary};
1
+ import"../common/auth/auth.js";import{validatePresenceOfAuthToken as e}from"../common/auth/auth.validate.js";import{untrustBeneficiaries as n,updateBeneficiary as i,prepareAddBeneficiaryCall as t,addBeneficiary as a,getBeneficiary as o,prepareGetBeneficiariesCall as s,getBeneficiaries as c,prepareUntrustBeneficiaryCall as r,prepareUpdateBeneficiaryCall as m,prepareGetBeneficiaryCall as f}from"./beneficiaries.api.js";import{serializeBeneficiary as g}from"./beneficiaries.serializer.js";import{validateTrustBeneficiariesParams as y,validateUpdateBeneficiaryParams as p,validateAddBeneficiaryParams as u,validateGetBeneficiaryParams as b}from"./beneficiaries.validate.js";import{serializePaginationResponse as d}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";import{validateOperationSettingsParams as k}from"../validation/operation-settings-validation.js";import{encodeNetworkCall as T,decodeNetworkResponse as w}from"../common/network/network.js";async function S(n){const{stagingToken:i,proxyRequestFunction:t,accessToken:a,paginationSettings:o}=k(n?.operationSettings||{});if(t){const e=s({paginationSettings:o}),n=T(e),i=await t(n),a=w(i),c=a.body.beneficiaries.map((e=>g(e))),r=d(a.body.meta);return{beneficiaries:c,...r?{meta:r}:{}}}{const n=a||e(),t=await c({accessToken:n,stagingToken:i,paginationSettings:o}),s=t.beneficiaries.map((e=>g(e))),r=d(t.meta);return{beneficiaries:s,...r?{meta:r}:{}}}}async function j({beneficiarySettings:n,operationSettings:i}){const t=b(n?.beneficiaryId),{proxyRequestFunction:a,accessToken:s,stagingToken:c}=k(i||{});if(a){const e=f({beneficiaryId:t}),n=T(e),i=await a(n),o=w(i);return g(o.body.beneficiary)}{const n=s||e(),i=await o({beneficiaryId:t,accessToken:n,stagingToken:c});return g(i)}}async function l({beneficiarySettings:n,operationSettings:i}){const o=u(n),{proxyRequestFunction:s,accessToken:c,stagingToken:r,idempotencyKey:m}=k(i||{});if(s){const e=t({beneficiary:o,idempotencyKey:m}),n=T(e),i=await s(n),a=w(i);return g(a.body.beneficiary)}{const n=c||e(),i=await a({beneficiary:o,accessToken:n,stagingToken:r,idempotencyKey:m});return g(i)}}async function v({beneficiarySettings:n,operationSettings:t}){const a=p(n),{stagingToken:o,idempotencyKey:s,mfaPreference:c,proxyRequestFunction:r}=k(t),f={beneficiaryParamsBeingEdited:a,idempotencyKey:s,mfaPreference:c};if(r){const e=m(f),n=T(e),i=await r(n),t=w(i);return g(t.body.beneficiary)}{const n=t?.accessToken||e(),a=await i({...f,accessToken:n,stagingToken:o});return g(a)}}async function x({beneficiarySettings:i,operationSettings:t}){const a=y(i?.beneficiaryIds),{proxyRequestFunction:o,accessToken:s,stagingToken:c}=k(t||{});if(o){const e=r({beneficiaryIds:a}),n=T(e),i=await o(n);return w(i).body.beneficiaries.map(g)}{const i=s||e();return(await n({beneficiaryIds:a,accessToken:i,stagingToken:c})).map(g)}}export{l as addBeneficiary,S as getBeneficiaries,j as getBeneficiary,x as untrustBeneficiaries,v as updateBeneficiary};
@@ -1 +1 @@
1
- import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validateExpectedStringValues as i,validatePresenceOfRequiredParams as t}from"../validation/input-param-validation.js";const r=[{name:"name"},{name:"iban"}];function n(i){if(!i)throw new e("beneficiaryId parameter is required for the called function");if(i&&"string"!=typeof i)throw new e("beneficiaryId must be a string");return i}function a(n){if(!n)throw new e("beneficiary parameter is required for the called function");if("object"!=typeof n)throw new e("beneficiary must be an object");t(n,r);const a=i({name:n.name,iban:n.iban,email:n.email,activityTag:n.activityTag,bic:n.bic});if(a.length>0)throw new e(a);return n}function o(t){const{id:r,name:n,email:a,activityTag:o}=t;if(!r)throw new e("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!o)throw new e("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const f=i({name:n,email:a,activityTag:o});if(f.length>0)throw new e(f);return{id:r,name:n,email:a,activityTag:o}}function f(i){if(!i)throw new e("beneficiaryIds parameter is required for the called function");if(!Array.isArray(i)||!i.every((e=>"string"==typeof e)))throw new e("beneficiaryIds must be an array of strings");return i}export{a as validateAddBeneficiaryParams,n as validateGetBeneficiaryParams,f as validateTrustBeneficiariesParams,o as validateUpdateBeneficiaryParams};
1
+ import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validateExpectedStringValues as i,validatePresenceOfRequiredParams as t}from"../validation/input-param-validation.js";const r=[{name:"name"},{name:"iban"}];function n(i){if(!i)throw new e("beneficiaryId parameter is required for the called function");if(i&&"string"!=typeof i)throw new e("beneficiaryId must be a string");return i}function a(n){if(!n)throw new e("beneficiary parameter is required for the called function");if("object"!=typeof n)throw new e("beneficiary must be an object");t(n,r);const a=i({name:n.name,iban:n.iban,email:n.email,activityTag:n.activityTag,bic:n.bic});if(a.length>0)throw new e(a);return n}function o(t){const{id:r,name:n,email:a,activityTag:o}=t||{};if(!r)throw new e("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!o)throw new e("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const f=i({name:n,email:a,activityTag:o});if(f.length>0)throw new e(f);return{id:r,name:n,email:a,activityTag:o}}function f(i){if(!i)throw new e("beneficiaryIds parameter is required for the called function");if(!Array.isArray(i)||!i.every((e=>"string"==typeof e)))throw new e("beneficiaryIds must be an array of strings");return i}export{a as validateAddBeneficiaryParams,n as validateGetBeneficiaryParams,f as validateTrustBeneficiariesParams,o as validateUpdateBeneficiaryParams};
@@ -1 +1 @@
1
- function e({endpointUrl:e,paginationSettings:t}){const a=new URL(e);return t?.page&&a.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&a.searchParams.set("per_page",t.itemsPerPage.toString()),a}function t(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}}export{e as addPaginationParamsToUrl,t as serializePaginationResponse};
1
+ function e(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function t({url:e,searchParams:t}){const a=new URL(e.toString());for(const[e,n]of t.entries())a.searchParams.append(e,n);return a}function a({endpointUrl:a,paginationSettings:n}){return t({url:new URL(a),searchParams:e(n)})}function n(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}}export{a as addPaginationParamsToUrl,t as addSearchParamsToUrl,e as buildPaginationParams,n as serializePaginationResponse};
@@ -1 +1 @@
1
- import{authManager as e}from"../auth/auth.js";import{validateInitializeParams as t}from"./initialize.validate.js";import{operationSettingsManager as n}from"../operation-settings/operation-settings.js";import{environmentManager as o}from"../environment/environment-manager.js";import{localeManager as a}from"../locale/locale-manager.js";function i(i){const{accessToken:s,stagingToken:r,operationSettings:c,environment:m,branch:l,locale:g}=t(i);s&&e.setAccessToken(s),r&&e.setStagingToken(r),g&&a.setLocale(g),c&&n.setSettings(c),m&&(o.setEnvironment(m),l&&o.setBranch(l))}function s(){e.clearAccessToken(),e.clearStagingToken(),a.setDefaultLocale()}export{i as initialize,s as logout};
1
+ import{authManager as e}from"../auth/auth.js";import{validateInitializeParams as t}from"./initialize.validate.js";import{operationSettingsManager as n}from"../operation-settings/operation-settings.js";import{environmentManager as o}from"../environment/environment-manager.js";import{localeManager as a}from"../locale/locale-manager.js";function i(i){const{accessToken:s,stagingToken:r,operationSettings:c,environment:m,branch:l,locale:g}=t(i);s&&e.setAccessToken(s),r&&e.setStagingToken(r),g&&a.setLocale(g),c&&n.setSettings(c),m&&(o.setEnvironment(m),l&&o.setBranch(l))}function s(){e.clearAccessToken(),e.clearStagingToken(),a.setDefaultLocale(),n.clearSettings()}export{i as initialize,s as logout};
@@ -1 +1 @@
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";const r={requiresUI:!1};function i(i,{requiresUI:s}=r){const a=i?.uiParentElementId||n.getUIParentElementId();if(s&&!a)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 m=i?.mfaPreference||n.getMFAPreference();if(m){const n=(c=Object.values(t),o.isProductionEnvironment()?c.filter((e=>e!==t.MOCK)):c);if(!n.includes(m))throw new e(`operationSettings.mfaPreference must be one of ${n.join(", ")}`);if(o.isProductionEnvironment()&&m===t.MOCK)throw new e("operationSettings.mfaPreference cannot be set to mock in production environment.")}var c;const u=i?.debugMode||n.getDebugMode();if(void 0!==u&&"boolean"!=typeof u)throw new e("operationSettings.debugMode must be a boolean.");const f=i?.proxyRequestFunction||n.getProxyRequestFunction();if(f&&"function"!=typeof f)throw new e("operationSettings.proxyRequestFunction must be a function.");return{...i,uiParentElementId:a,mfaPreference:m,debugMode:u,proxyRequestFunction:f,...i}}export{i 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";const r={requiresUI:!1};function i(i,{requiresUI:s}=r){const a=i?.uiParentElementId||n.getUIParentElementId();if(s&&!a)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 m=i?.mfaPreference||n.getMFAPreference();if(m){const n=(c=Object.values(t),o.isProductionEnvironment()?c.filter((e=>e!==t.MOCK)):c);if(!n.includes(m))throw new e(`operationSettings.mfaPreference must be one of ${n.join(", ")}`);if(o.isProductionEnvironment()&&m===t.MOCK)throw new e("operationSettings.mfaPreference cannot be set to mock in production environment.")}var c;const u=i?.debugMode||n.getDebugMode();if(void 0!==u&&"boolean"!=typeof u)throw new e("operationSettings.debugMode must be a boolean.");const f=i?.proxyRequestFunction||n.getProxyRequestFunction();if(f&&"function"!=typeof f)throw new e("operationSettings.proxyRequestFunction must be a function.");return{...i,uiParentElementId:a,mfaPreference:m,debugMode:u,proxyRequestFunction:f}}export{i 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,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEtF;;;;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;IACxB;;;OAGG;IAEH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC;;;;;;;;;;;;;;;;;;OAkBG;IACH,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,wCAAwC;IACvD;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAMD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,EACE,UAAU,GACX,GAAE,wCAA0F,GAC5F,iBAAiB,CAuDnB"}
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,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEtF;;;;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;IACxB;;;OAGG;IAEH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC;;;;;;;;;;;;;;;;;;OAkBG;IACH,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,wCAAwC;IACvD;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAMD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,EACE,UAAU,GACX,GAAE,wCAA0F,GAC5F,iBAAiB,CAsDnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.23.1",
3
+ "version": "0.25.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,6 +29,10 @@
29
29
  "types": "./dist/organizations/index.d.ts",
30
30
  "import": "./dist/src/organizations/index.js"
31
31
  },
32
+ "./payment-links": {
33
+ "types": "./dist/payment-links/index.d.ts",
34
+ "import": "./dist/src/payment-links/index.js"
35
+ },
32
36
  "./types": {
33
37
  "types": "./dist/types/index.d.ts",
34
38
  "import": "./dist/src/types/index.js"